The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: -Alex- on February 09, 2012, 01:40:59 AM

Title: Process32First & Process32Next problem.
Post by: -Alex- on February 09, 2012, 01:40:59 AM
Why I cant use Process32First and Process32Next anymore? I get: error A2006: undefined symbol : Process32First
However, the same project can be compiled with MASM32 v10.
Title: Re: MASM32 Version 11 Release posted.
Post by: dedndave on February 09, 2012, 02:30:54 AM
oops...
it looks like only the unicode version has a prototype
appears not to be the only one in kernel32.inc like that, too

for a quick test, add these to the beginning of your program...

IFNDEF Process32First
Process32First PROTO :DWORD,:DWORD
ENDIF

IFNDEF Process32Next
Process32Next PROTO :DWORD,:DWORD
ENDIF
Title: Re: MASM32 Version 11 Release posted.
Post by: -Alex- on February 09, 2012, 02:42:24 AM
.obj : error LNK2001: unresolved external symbol _Process32First@8
.obj : error LNK2001: unresolved external symbol _Process32Next@8
.exe : fatal error LNK1120: 2 unresolved externals
Title: Re: MASM32 Version 11 Release posted.
Post by: dedndave on February 09, 2012, 02:58:36 AM
my mistake - they didn't get imported into kernel32.lib, of course
Title: Re: MASM32 Version 11 Release posted.
Post by: dedndave on February 09, 2012, 03:03:46 AM
...and, i forgot the "A"
IFNDEF Process32FirstA
Process32FirstA PROTO :DWORD,:DWORD
ENDIF

IFNDEF Process32First
Process32First TEXTEQU <Process32FirstA>
ENDIF

IFNDEF Process32NextA
Process32NextA PROTO :DWORD,:DWORD
ENDIF

IFNDEF Process32Next
Process32Next TEXTEQU <Process32NextA>
ENDIF


if that doesn't work, we'll have to make a new kernel32.lib
in the mean time, you can use GetProcAddress
Title: Re: MASM32 Version 11 Release posted.
Post by: -Alex- on February 09, 2012, 03:07:43 AM
Process32First dont have an "A", only "W", still dont help. Can you make new lib?
Title: Re: MASM32 Version 11 Release posted.
Post by: dedndave on February 09, 2012, 03:16:20 AM
this worked for me
IFNDEF Process32FirstA
Process32FirstA PROTO :DWORD,:DWORD
ENDIF

IFNDEF Process32First
Process32First TEXTEQU <Process32FirstA>
ENDIF

IFNDEF Process32NextA
Process32NextA PROTO :DWORD,:DWORD
ENDIF

IFNDEF Process32Next
Process32Next TEXTEQU <Process32NextA>
ENDIF
Title: Re: MASM32 Version 11 Release posted.
Post by: -Alex- on February 09, 2012, 03:17:58 AM
same error as before, unresolved external symbol _Process32FirstA@8
Title: Re: MASM32 Version 11 Release posted.
Post by: dedndave on February 09, 2012, 03:27:18 AM
sorry - i thought it worked - i had a pre-existing EXE file in the folder, so i thought it linked properly

the problem with creating a new lib is...
it appears there are several (or many) functions that need to be "fixed"
i don't feel like fixing them all   :P

you can make one using inc2lib...
add the ASCII prototypes to kernel32.inc
Process32FirstA PROTO :DWORD,:DWORD
Process32NextA PROTO :DWORD,:DWORD


in the existing kernel32.inc, you will find these aliases...
IFDEF __UNICODE__
  Process32First equ <Process32FirstW>
ENDIF

IFDEF __UNICODE__
  Process32Next equ <Process32NextW>
ENDIF


modify them like so...
IFDEF __UNICODE__
  Process32First equ <Process32FirstW>
ELSE
  Process32First equ <Process32FirstA>
ENDIF

IFDEF __UNICODE__
  Process32Next equ <Process32NextW>
ELSE
  Process32Next equ <Process32NextA>
ENDIF

then use inc2lib to create a new lib

or, you can wait for Hutch to update it   :P
he will probably take care of this in the next day or so
Title: Re: Process32First & Process32Next problem.
Post by: Ramon Sala on February 09, 2012, 08:32:17 AM
Hi Alex,

The problem is that the Process32FirstA and Process32NextA do not exist. The ANSI versions are named Process32First and Process32Next, while the Unicode versions are Process32FirstW and Process32NextW. The Kernek.inc file coming with MASM32 v11 has the following declarations (and I'm the responsible):

Module32FirstW PROTO STDCALL :DWORD,:DWORD
IFDEF __UNICODE__
  Module32First equ <Module32FirstW>
ENDIF

Module32NextW PROTO STDCALL :DWORD,:DWORD
IFDEF __UNICODE__
  Module32Next equ <Module32NextW>
ENDIF


and according to Microsoft they should be:

Module32First PROTO STDCALL :DWORD,:DWORD
Module32FirstW PROTO STDCALL :DWORD,:DWORD

Module32Next PROTO STDCALL :DWORD,:DWORD
Module32NextW PROTO STDCALL :DWORD,:DWORD


So lines:

Module32First PROTO STDCALL :DWORD,:DWORD
Module32Next PROTO STDCALL :DWORD,:DWORD


are missing.


This is what MSDN says for Module32First (the same applies to Module32Next):

Header
Tlhelp32.h

Library   
Kernel32.lib

DLL
Kernel32.dll

Unicode and ANSI names
Module32FirstW (Unicode) and Module32First (ANSI)


Regards,
Title: Re: Process32First & Process32Next problem.
Post by: diablo2oo2 on March 12, 2012, 04:06:59 PM
this should be fixed in the latest SDK
Title: Re: Process32First & Process32Next problem.
Post by: donkey on March 13, 2012, 04:21:01 PM
You should also make sure you use the proper structures, the UNICODE and ANSI versions of PROCESSENTRY32 and MODULEENTRY32 are different sizes because of character width (TCHAR).

Title: Re: Process32First & Process32Next problem.
Post by: Gunner on March 14, 2012, 02:21:17 AM
Where is outCLSID defined?

Mods will probably close this topic now and remove that link since it seems to be source for something malicious and we don't help with that.
Title: Re: Process32First & Process32Next problem.
Post by: -Alex- on March 14, 2012, 08:36:49 AM
For all others who have same prob like me before, here is simple solution:

Change in kernel32.inc

Process32FirstW PROTO STDCALL :DWORD,:DWORD
Process32NextW PROTO STDCALL :DWORD,:DWORD

to

Process32First PROTO STDCALL :DWORD,:DWORD
Process32Next PROTO STDCALL :DWORD,:DWORD

and make a new kernel32.lib or take the one from windows sdk.