flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitshifter
Q: Are you using unicode?
Non-Unicode: Code: format PE GUI 4.0 entry start include 'win32a.inc' section '.text' code readable executable start: invoke EnumWindows,EnumWindowsProc,0 invoke MessageBox,HWND_DESKTOP,_sb,_ct,MB_ICONINFORMATION or MB_OK invoke ExitProcess,0 proc EnumWindowsProc, hWnd, lParam invoke GetWindowText,[hWnd],_wt,128 test eax,eax jz @f invoke lstrcat,_sb,_wt invoke lstrcat,_sb,_nl @@: mov eax,TRUE ret endp section '.data' data readable writeable _ct db "xxx",0 _nl db 13,10,0 _sb rb 4096 ;careful!!! _wt rb 128 section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' |
|||
![]() |
|
asmMe
thx for the reply.
don't know if I'm using unicode or not? ![]() Anyway, it appears I misunderstood exactly what EnumWindows returns. Quote: The EnumWindows function enumerates all top-level windows on the screen by passing the handle of each window, in turn, to an application-defined callback function. I assumed this meant that if I had 8 items on the taskbar, it would return 8 handles. I wrote a little extra code to write all the handles and window titles to a file. With 8 apps on taskbar, I got 99 handles ¿¿¿ A lot of them had no titles (this is why I thought I was doing something wrong). I also got these (amongst others) Quote:
strange but, at least the real open windows were there with titles so I can continue with what I was doing ![]() thx again |
|||
![]() |
|
bitshifter
Unicode uses multibyte characters for languages with many chars.
In english we use ASCII characters, in other countries, sometimes not. To make a program unicode compatible we can include "win32w.inc" and use TCHAR data types instead of regular bytes with db See FASM example EXAMPLES/TEMPLATE/TEMPLATE.ASM for a basic Windows app which is unicode compatible. Have Fun ![]() |
|||
![]() |
|
AsmGuru62
You got all tasks and services enumerated, probably. When you get an HWND into your callback - check if it has an extended style of WS_EX_APPWINDOW - that will be the taskbar item most likely.
|
|||
![]() |
|
asmMe
thx bitshifter, no, I'm not using unicode then
![]() AsmGuru62: Thought your idea sounded promising but, unfortunately, it doesn't hold true. Very few apps set the WS_EX_APPWINDOW style, just search the boards for createwindowex to see how many have the ext style as 0. It appears the only way is to cycle through the titles to find what I'm looking for. thx again |
|||
![]() |
|
cod3b453
If oyu looking for all "normal" windows, I think the WS_VISIBLE style flag should be ok for this (and possibly WS_MINIMISED ?).
If you're looking for a specific window, it might be better to use FindWindow(Ex). |
|||
![]() |
|
asmMe
thx cod, I'll check out those flags. FindWindow would be no use for my purpose as I would only know part of the windows name (title).
Just as a note for anyone using the EnumWindows function, make sure your EnumWindowsProc returns with edi unchanged or thou shalt crash 'n' burn. update preserve all registers except eax or EnumWindows skips some of the open windows. |
|||
![]() |
|
bitshifter
You only need to preserve ESI, EDI, EBX like any other Win32 proc should.
|
|||
![]() |
|
vid
Quote: You only need to preserve ESI, EDI, EBX like any other Win32 proc should. Also EBP (and ESP of course) |
|||
![]() |
|
asmMe
Sounds fair enough bitshifter
![]() I assumed that EnumWindowsProc, being my own procedure could do as the info on it says Quote: Remarks and that windows would look after itself. Apparently not so for a callback proc ![]() Oh well, I suppose a couple of extra lines of code to look after Bill will do no harm ![]() |
|||
![]() |
|
AsmGuru62
Any callback function must preserve ESI,EDI,EBX,EBP and DF must be 0. If your code uses STD - DF must be restored with CLD. Callback is any procedure address passed to Windows to be called back (like a structure member or as any function parameter).
|
|||
![]() |
|
asmMe
thx guru, vid & bit for the clarification
![]() So if I use this template for all my procs I shouldn't go far wrong ![]() Code: proc whateverProc locals endl push ebx edi esi . . ; whatever code . . .finished: pop esi edi ebx cld ret endp |
|||
![]() |
|
bitshifter
Keep the template in your head and only use the parts
that are needed for each implementation thereof. No sense in useless instructions laying around, right. |
|||
![]() |
|
asmMe
thx bit
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.