Author Topic: Find classname for EnumWindows  (Read 6670 times)

Magnum

  • Member
  • *****
  • Posts: 2309
Find classname for EnumWindows
« on: December 05, 2012, 11:31:31 AM »
How do you find the Classnames for other programs ?

Code: [Select]
szClassname                 byte            "IEFrame", 0
szFilename                  byte            "iexplore.exe", 0

.data?

we                          WINDOWENTRY32   <>
szCurrentFilename           byte 255 dup    (?)
szCurrentClassname          byte 255 dup    (?)

.code
    Start:

xor ebx, ebx

mov we.lpszClassname, offset szClassname
mov we.lpszFilename, offset szFilename

    invoke EnumWindows, addr EnumFunc, addr we
    invoke ExitProcess, ebx

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Find classname for EnumWindows
« Reply #1 on: December 05, 2012, 11:47:13 AM »
How do you find the Classnames for other programs ?
That's not possible (I assume you mean the classname of a window).
You can search for a top level window with FindWindow()  either by Titel, by Calssname or both. From the found window handle you can get the Process ID by using GetWindowThreadProcessId
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Find classname for EnumWindows
« Reply #2 on: December 05, 2012, 11:53:38 AM »
i suppose EnumProcesses, then GetGUIThreadInfo and GetClassName in the callback

i seem to remember something in the old forum   :P

you can google "get window handle from process ID" for clues

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Find classname for EnumWindows
« Reply #3 on: December 05, 2012, 11:59:21 AM »
i suppose EnumProcesses, then GetGUIThreadInfo and GetClassName in the callback

i seem to remember something in the old forum   :P
Interesting solution, but only sense full if you know that the application has only one window. But even in this case, you can commonly determine the class name by using tools like WinSpy++ and then use FindWindow() to get the window handle.(?)
MREAL macros - when you need floating point arithmetic while assembling!

Magnum

  • Member
  • *****
  • Posts: 2309
Re: Find classname for EnumWindows
« Reply #4 on: December 05, 2012, 12:12:55 PM »
qWord,

http://www.masmforum.com/board/index.php?topic=11603.0

Classname must be constant for every program based on the code above.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Find classname for EnumWindows
« Reply #5 on: December 05, 2012, 12:20:45 PM »
qWord,

http://www.masmforum.com/board/index.php?topic=11603.0

Classname must be constant for every program based on the code above.

Andy
no it must not. For example you can dynamically create the class name (or atom). Furthermore, there generally no direct link between a window class and a process. A process can have N windows of K classes -> which is the "correct" class in that case?
MREAL macros - when you need floating point arithmetic while assembling!

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Find classname for EnumWindows
« Reply #6 on: December 05, 2012, 12:51:45 PM »
Magnum,
maybe misunderstand you: you already have the class name "IEFrame" and/or the image name and you want to enumerate all TLWs and test if their class name and/or the process name match?
In that case, use the window handle in the Enum-Callback with GetClassName() to get the class name. The executable path can be obtained (for example) with GetWindowThreadProcessId() +OpenProcess() and GetProcessImageFileName().

You may describe what you want to do exactly.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Find classname for EnumWindows
« Reply #7 on: December 05, 2012, 01:23:27 PM »
the EnumWindows function only enumerates top-level windows (not child windows/controls)
the callback gives you the main window handle for each program that has a window
from that, you can get the main window classname with GetClassName

so - unless you have some specific reason for using EnumProcesses (process IDs), use EnumWindows

Magnum

  • Member
  • *****
  • Posts: 2309
Re: Find classname for EnumWindows
« Reply #8 on: December 05, 2012, 01:54:50 PM »
The code doesn't use EnumProcess.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Find classname for EnumWindows
« Reply #9 on: December 05, 2012, 02:06:05 PM »
well, maybe it should - lol

you aren't being clear about what you are trying to accomplish
pretend, for a moment, that you are not Secret Sam, and tell us what you want to do

How do you find the Classnames for other programs ?

dedndave

  • Member
  • *****
  • Posts: 8825
  • Still using Abacus 2.0
    • DednDave
Re: Find classname for EnumWindows
« Reply #10 on: December 05, 2012, 02:13:34 PM »
sorry, Andy - i shouldn't be so harsh

but - if you use EnumProcesses, the Process ID is passed to the callback routine
generally, i try to avoid the PID and stick with window handles - lol
but - some operations may require it

the simplest way to get the class names for all top-level windows is EnumWindows/GetClassName