hello guys im not able to get the caption of a child window, check spy does:
(http://img43.imageshack.us/img43/9177/q43j.png)
I wan to get:
masm32.com/board/index.php
my code:
.586
.model flat,stdcall
include masm32rt.inc
.data
class1 db "Chrome_WidgetWin_1",0
subw db "Chrome_OmniboxView",0
.code
Start proc
invoke FindWindow,addr class1,0
invoke FindWindowEx,eax,0,addr subw,0
; eax = zero
Ret
Start EndP
End Start
EAX equal to zero, im not able to figure out the problem, any help please
Both windows are in same level.
"Chrome_OmniboxView" isn't child of "Chrome_WidgetWin_1" ?
EDIT:
Test with IronPortable:
"Chrome_OmniboxView" is child of "Chrome_WidgetWin_1"
SendMessage with WM_GETTEXT works.
Quote from: TWell on October 01, 2013, 06:29:53 PM
Both windows are in same level.
"Chrome_OmniboxView" isn't child of "Chrome_WidgetWin_1" ?
nope, calling FindWindow plus Chrome_OmniboxView string doesnt work.
Added:
also, I tried by calling EnumWindow or EnumChildWindow and no function was able to get the string...
Try FindWindow with lpClassName=null and lpWindowName=masm32.com/board/index.php
lpClassName=NULL
lpWindowName=>"masm32.com/board/index.php"
The problem is, I cannot get handle from title, because it will change constantly
Class is ok as it will not change never in the program.
program is google chrome. its very strange, I tried a lot of things :icon_eek:
EDIT: The class "Chrome_OmniboxView" was removed in newer versions.
TWell , your code shows me nothing, it does not find Chrome_OmniboxView class. is it working for you?
My google version is: Version 28.0.1500.95 m
if it is a child window, you want to use FindWindowEx
FindWindow is for top-level windows
to use FindWindowEx, you need the handle of the parent window
so...
.DATA
szParentClass db '????',0
szChildClass db '????',0
.CODE
INVOKE FindWindow,offset szParentClass,NULL
.if eax
INVOKE FindWindowEx,eax,NULL,offset szChildClass,NULL
.endif
now - you may have multiple instances of chrome
i will let you deal with that one, as i don't have it installed :P
Quote from: TWell on October 02, 2013, 03:51:23 AMEDIT: The class "Chrome_OmniboxView" was removed in newer versions.
If so how does spy do to get string, i dont think so :icon_eek:
@dedndave:
Check my post #1 I did so, but for some reason findWindowEx doesnt work but spy is able to get string.
I dont understand how the # spy is able to get string
I tried with several programs:
(http://img593.imageshack.us/img593/4844/g4to.png)
WinInspector is able to do it as well.
Edit # = Profanity
ok - there are a few complications that you may be running into
first - the window may be a UNICODE window - with a UNICODE class name
you should be able to look at the window properties under spy++ to see
i haven't had much experience here, but it's a possibility
secondly, under windows 7, some child windows/controls are isolated by a worker window
these windows seem to be all over the place if you use the aero glass theme
sometimes, these windows have "shell" and/or "dll" in the names
but - i think spy++ will spot those windows
otherwise - check the windows properties carefully for style bits - etc
anything unusual that might make them hard to find
i could be more help if i were using the same OS and chrome
but - i use XP and firefox :P
if all else fails, you should be able to get the parent handle and enumerate all child windows to find it
question - are you able to get the parent handle with FindWindow ???
display it in a MessageBox to verify it is non-zero
Quote from: dedndave on October 02, 2013, 07:16:58 AM
question - are you able to get the parent handle with FindWindow ???
display it in a MessageBox to verify it is non-zero
It is assumed that the parent is Chrome_WidgetWin_1 class, FindWindow finds it but FindWindowEx doesnt find the child (Chrome_OmniboxView). I will debug Spy++ to know how it works.
i would think spy++ uses EnumChildWindows
Quote from: dedndave on October 02, 2013, 07:35:55 AM
i would think spy++ uses EnumChildWindows
Yeah I think so, but it doesn work.
I tried EnumWindows plus EnumChildWindow as I said inabove posts :P
(http://img593.imageshack.us/img593/4844/g4to.png)
perhaps, when you ran EnumChildWindows, you were running it on the wrong parent handle
i see 2 "Chrome_WidgetWin_1" windows - one has no children - one does
you can run EnumWindows - filter out only parent Chrome_WidgetWin_1 windows
then, when you find one of those - call EnumChildWindows on it
i will get back to you in an hour or so with a program to try - have to take care of something :P
quick and dirty
let me know if it works :biggrin:
Not working :
(http://img94.imageshack.us/img94/9226/e2hr.png)
Even, I tried enumerating all windows on the system:
.586
.model flat,stdcall
include masm32rt.inc
.data
sparentcls db "PARENT > class: %ls ",0ah,0
sparenttit db "PARENT > title: %ls ",0ah,0
schildcls db " #CHILD > class: %ls",0ah,0
schildtit db " #CHILD > title: %ls",0ah,0
.code
getchilds proc hwnd:HWND,lparam:LPARAM
LOCAL classname[200*1]:WORD
LOCAL mtitle[200*5]:WORD
invoke GetClassNameW,hwnd,addr classname,sizeof classname
invoke GetWindowTextW,hwnd,addr mtitle,sizeof mtitle
lea eax,classname
push eax
push offset schildcls
call crt_printf
add esp,sizeof(DWORD) * 2
lea eax,mtitle
push eax
push offset schildtit
call crt_printf
add esp,sizeof(DWORD) * 2
mov eax,1
ret
getchilds endp
getparents proc hwnd:HWND,lparam:LPARAM
LOCAL classname[200*1]:WORD
LOCAL mtitle[200*5]:WORD
LOCAL written:DWORD
LOCAL h:HANDLE
invoke GetClassNameW,hwnd,addr classname,sizeof classname
invoke GetWindowTextW,hwnd,addr mtitle,sizeof mtitle
lea eax,classname
push eax
push offset sparentcls
call crt_printf
add esp,sizeof(DWORD) * 2
lea eax,mtitle
push eax
push offset sparenttit
call crt_printf
add esp,sizeof(DWORD) * 2
; get childs
invoke EnumChildWindows,hwnd,offset getchilds,0
mov eax,1
ret
getparents endp
Start proc
invoke EnumWindows,offset getparents,0
int 3 ; break
Ret
Start EndP
End Start
string is empty
Parent string is ok
child string is empty:
(http://img21.imageshack.us/img21/7679/yhsb.png)
Resolved guys lol use Sendmessage
Looks like the GetWindowText function has problems getting the string:
http://blogs.msdn.com/b/oldnewthing/archive/2003/08/21/54675.aspx
---
thank yall for your time, thanks dave :t
Write an enumeration callback as Dave suggested then be willing to scan parts of the data for each application instance to find data that indicates that it is Chrome.
i made a mistake on GetWindowText, actually
i only print the result if EAX is non-zero - just like GetClassName :redface:
well - GetWindowText isn't the same as GetClassName
i was in a hurry - what can i say - at least it put you on the right track
see if this one is a little better....
in the end - may be better to use WM_GETTEXT :t
EDIT: i went ahead and switched to WM_GETTEXT
i also cleaned up the output text format a little
Quote from: dedndave on October 02, 2013, 11:12:07 AM
i made a mistake on GetWindowText, actually
i only print the result if EAX is non-zero - just like GetClassName :redface:
well - GetWindowText isn't the same as GetClassName
i was in a hurry - what can i say - at least it put you on the right track
see if this one is a little better....
in the end - may be better to use WM_GETTEXT :t
EDIT: i went ahead and switched to WM_GETTEXT
i also cleaned up the output text format a little
mmm... I dont think so, GetWindowText is not working in actually, it returns an empty string, idk why but doesnt work.
SendMessage is working quite fine :P check it
Some tests with Dave's program in Win 7
Version 29.0.1547.76 m
Parent Handle: 000301A2
Parent Handle: 000301A4
Chrome_WidgetWin_0 , The MASM Forum - Index
Chrome_RenderWidgetHostHWND
CompositorHostWindowClass
Parent Handle: 00020182
Parent Handle: 0009015C
Version 30.0.1599.66 m
Parent Handle: 001502EA
Parent Handle: 00070162
Chrome_WidgetWin_0 , The MASM Forum - Index
Chrome_RenderWidgetHostHWND
CompositorHostWindowClass
Parent Handle: 000601A6
Parent Handle: 000B0188
IronPortable
Version 29.0.1600.1 (220100)
Parent Handle: 000506CA
Parent Handle: 00060644
Chrome_WidgetWin_0 , The MASM Forum - Index
Chrome_RenderWidgetHostHWND
Parent Handle: 00040664
Parent Handle: 00080674
So no more class "Chrome_OmniboxView"
Quote from: x64Core on October 02, 2013, 09:55:17 AM
Looks like the GetWindowText function has problems getting the string:
http://blogs.msdn.com/b/oldnewthing/archive/2003/08/21/54675.aspx
Looks familiar (http://www.masmforum.com/board/index.php?topic=18489.msg156383#msg156383) ;-)
The main problem here is that GetWindowText is no good for kids of other parents, while SendMessage works fine in general but may hang (see "What if I don't like these rules?" in Raymond Chen's blog quoted above). The only reliable solution (used for Win$() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1090)) is to use SendMessageTimeout with a timeout of e.g. 100 ms (of which 50 µs are typically needed).
In 32-bit versions of Windows, beware of asking for the text of kids in 16-bit processes: an exception will occur, and AFAIK there is no workaround.
TWell,
Have a look at a MASM32 example in version 11 called "enumwin.exe" in the enumerate directory of examples. Run Chrome, then start "enumwin.exe" then see what the class name, handle and window caption text is.
It isn't there. ("Chrome_OmniboxView" is removed from newer versions)
Such as:
IronPortable Version 29.0.1600.1 (220100)
I am running Version 27.0.1500.0 (201000) of Iron Portable and it shows up fine. Note though that this is one my older XP SP3 box.
You may find that they (the developers of Iron) don't want it to be easily found by other programs.
my chrome is 28.0.1500.95 m and its working
BTW, nice information jj, thank you
added:
I just updated my chrome to: Version 30.0.1599.66 m
not working anymore lol
any alternative, guys? injection :P