News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Process32First & Process32Next problem.

Started by -Alex-, February 09, 2012, 01:40:59 AM

Previous topic - Next topic

-Alex-

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.

dedndave

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

-Alex-

.obj : error LNK2001: unresolved external symbol _Process32First@8
.obj : error LNK2001: unresolved external symbol _Process32Next@8
.exe : fatal error LNK1120: 2 unresolved externals

dedndave

my mistake - they didn't get imported into kernel32.lib, of course

dedndave

...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

-Alex-

Process32First dont have an "A", only "W", still dont help. Can you make new lib?

dedndave

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

-Alex-

same error as before, unresolved external symbol _Process32FirstA@8

dedndave

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

Ramon Sala

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,
Greetings from Catalonia

diablo2oo2


donkey

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).

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Gunner

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.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

-Alex-

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.