I think this prove that GetWindow is full of crap. Don't it make you wonder why GetNextWindow is not a API but a stupit C or C++ macro that you can't find anywhere. You barly hear the word mentioned even here.

Put this under any button like the Bmbutton.asm in masm32 and make it your TOP_MOST window. ..... TOP_MOST

GetWindow will find HWNDNEXT and show you the **** handle but when you go to GetWindowText for that so-called LEGAL handle it returns nothing.

All because of this is why i wanted to know about Ring0, Drivers, WriteProcessMemory, System Services and such. This simple thing that has trip me out for a long time. Now i am beleiving Windows itself is blocking and the way things happen as you play with it makes me wonder when M$ said "nothing can mess with your address space". Just Read the GetWindow API Doc. I'm sure i did every thing right.

If i can get pass this then my project is FINISH. But two more years wasting my time trying to learn ring0 and such should not be the answer.

"EnumWindows, Hooks, Macros" it should not take all of that just to get the Window infomation right under yours, expecially if you are TOP_MOST. But i be happy with ANYTHING except EnumWindows.

Maybe im just seeing things. crash crash crash..

I really hope i am wrong and that someone could help.


invoke GetForegroundWindow
mov ahand,eax

invoke MessageBox,0,ADDR ahand,0,0 ; see your TOP_MOST handle

invoke GetWindow,ahand,GW_HWNDNEXT
mov app_open, eax

invoke MessageBox,0,ADDR app_open,0,0 ; prove next handle

; ................................. GetWindowText eax or DD
PUSH 128
PUSH offset aClassCompare1
PUSH app_open
CALL GetWindowTextA

invoke MessageBox,0,offset aClassCompare1,0,0 ; SEE N O T H I N G




or try to close that window a few times and windows will crash your
machine and lie to you saying You are out of Resourses. " Dame i just booted up and click the button 2 times is all you will say"

Funny thing it will close another top_most window but not the one you are after.


crash crash crash..
invoke SendMessage, app_open, WM_CLOSE,NULL ,NULL


;GW_HWNDFIRST equ 0
;GW_HWNDLAST equ 1
;GW_HWNDNEXT equ 2
;GW_HWNDPREV equ 3
;GW_OWNER equ 4
;GW_CHILD equ 5
Posted on 2003-07-29 02:21:35 by cmax
sometimes GetWindowText doesnot work
you have to send a message with WM_GETTEXT and WM_GETEXTLENGHT to get the text lenght to allocate the buffer
Posted on 2003-07-29 02:51:18 by Jnrz
Jnrz,
You gave me a great idea. It's going to take a lot of better stupit rigging on my part but i think it might work...
Posted on 2003-07-29 04:53:29 by cmax


invoke SendMessage, hWnd, WM_GETEXTLENGTH, 0, 0
mov len, eax

will return the text lenght, you have to allocate a buffer that will hold the text, and after that



invoke SendMessage, hWnd, WM_GETEXT, len, offset szBuffer
lea eax, szBuffer
invoke MessageBox, 0, eax, eax, 0


will copy the text to szBuffer
Posted on 2003-07-30 04:03:30 by Jnrz
Jnrz

I tried your first idea last night and it did work with GetForegroundWindow Than Get Text Only just like mine did. But your idea lead me to trying out a lot of other things. That's what i ment.

But i am trying to get the full path name from the handle i get. GetForegroundWindow
only give you the caption name of the process.

I just had another idea thats why i came back so quick after shutting down. I remember how to get the process id from the handle so i may not need to use Process32 since i got the hadle if the window i want. The problem now is what do i do with that id to get the full path name of that window.

By the way my code above is what i came up with behind your suggestion. Also if you had tested out that piece of GetWindow code it use the bottom line which tells the whole story. Not just get text.

Thanks ... it was quite an experence on something new for me.
Posted on 2003-07-30 04:23:21 by cmax
Yes you can but this is as far as i know

aProcess DWORD ?

invoke GetForegroundWindow

push offset aProcess
push eax
call GetWindowThreadProcessId

It returns the scrible scrabble Thread ID for that window.

Do anyone know where i go from here to get the full path name

PS: i am getting my post confessed. I dumped the top most windiw idea but part of the problem is still getting the full path. Sorry about that.
Posted on 2003-07-30 04:57:43 by cmax
But remeber you are only getting Window Text not the FULL PATH
code like this is hard to find also. I never thought you could
sendmessage like that. It can replace GetWindowTextA if fixed


invoke GetForegroundWindow

; ............................... API Standard ... The Original Works
PUSH 128
PUSH offset b_CAPTION
PUSH eax
CALL GetWindowTextA

..................................................................................................

; For some reason It don't work. for me...
; I tried hard.... ***lea eax, b_CAPTION***

;invoke SendMessage, hWnd, WM_GETTEXT, len, offset b_PATH
;lea eax, b_CAPTION
;invoke MessageBox, 0, eax, eax, 0

..................................................................................................

; Mys don't work right either .. It only bring back 13 letters
; no matter how long string is


;PUSH offset b_CAPTION
;PUSH WM_GETTEXTLENGTH
;PUSH WM_GETTEXT
;PUSH eax
;CALL SendMessageA
Posted on 2003-07-30 06:07:33 by cmax

;PUSH offset b_CAPTION
;PUSH WM_GETTEXTLENGTH
;PUSH WM_GETTEXT
;PUSH eax
;CALL SendMessageA

That can't work... remember:
From WIN32.HLP:
WM_GETTEXT
wParam = (WPARAM) cchTextMax; // number of characters to copy
lParam = (LPARAM) lpszText; // address of buffer for text

WM_GETTEXTLENGTH
wParam = 0; // not used; must be zero
lParam = 0; // not used; must be zero

Besides, EAX is lost right after any API call, so make sure to push anything that uses eax BEFORE making the calls. So your code should be something like this:


invoke SendMessage,hWnd,WM_GETTEXTLENGTH,0,0
invoke SendMessage,hWnd,WM_GETTEXT,eax,offset b_CAPTION

You can't keep the window handle in EAX, as it will always get destroyed... Take a look at this thread:
http://www.asmcommunity.net/board/index.php?topic=8239
Posted on 2003-07-30 11:22:43 by QvasiModo