Can someone tell me why this doesn't work? thanks
there's a problem in dwSize. wrong size but also it works with masm10 but not masm11. I've seen some strange things happening with structures in masm version 11. Does anyone know how to fix it?
Hi
xandaz
We talked about Process32 problem earlier
http://www.masm32.com/board/index.php?topic=18850.0 (http://www.masm32.com/board/index.php?topic=18850.0 )
i don't think that's his problem - at least not his only one (he could have the prototype/lib issue, as well)
his problem is related to the size of the PROCESSENTRY32 structure, which has not changed from v10 to v11
so - i don't know why one works and one doesn't - if that is the case
but - i do know that this is wrong...
process32 PROCESSENTRY32 <36+256,<>>
the correct size of the structure is 296 bytes - not 292 bytes
the reason for this is that MAX_PATH is 260 - not 256
in any event, i would not hard-wire the size of the structure with a numeric expression
if you want to do it, do it with the SIZEOF directive
process32 PROCESSENTRY32 <sizeof PROCESSENTRY32,<>>
i wouldn't do it that way, either :bg
the size of the structure is 296 bytes
if you define it in the .DATA section, it adds 296 bytes (or more) to the size of the EXE
however, if you define it in the .DATA? section, and fill in the size with code, the EXE will be at least 287 bytes smaller
(assuming it takes ~9 bytes to fill in the structure size with code)
.DATA?
process32 PROCESSENTRY32 <>
.CODE
mov process32.dwSize,sizeof PROCESSENTRY32
in fact, i would use register base-index addressing because you can use the register twice, like so...
invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS+TH32CS_SNAPMODULE,0
mov hSnap,eax
mov edx,offset process32
mov [edx].PROCESSENTRY32.dwSize,sizeof PROCESSENTRY32
invoke Process32First,eax,edx
as it happens, the index is for the first member is 0, so it's really register base addressing :bg
i know dave.... i forgot to clear that when i submitted the file. I was just counting size by myself thinking had miscalculated it. Wrong count tho.
[TYPO]....thinking Masm had miscalculated...
then - you probably want to look through the thread that Force linked and use Erol's tools to rebuild the lib
while you're at it, the same problem exists in 2 include\lib pairs; kernel32 and kernl32p
and 4 functions; Module32First, Module32Next, Process32First, Process32Next
for a total of 8 fixes :bg
I already made the changes for process32first/next but still doesn't enumerate. Only does so when i make that change in PROCESSENTRY32. The szExeFile from DB to DW. Can you garantee it works for you?
that works - in the ANSI form
i added a structure definition for the UNICODE version
it works also...
A good way to check structure sizes is with a Microsoft C compiler and the structure definitions from the Microsoft header files.
This should be happening in the new forum, where it has a future.