I want to add a method to my debugger which fills a THREADENTRY32 array with all threads of the process being currently debugged. For that, I want to use the method “EnumerateThreads” which I pass a THREADENTRY32 pointer which the function should fill out.
However, I’m having trouble using a THREADENTRY32 pointer as a function parameter.
Everytime I declare a function like this in my header file I receive an C2061 error (“syntax error : identifier ‘THREADENTRY32′”):
void EnumerateThreads(THREADENTRY32 *threadArray);
The header file includes already which defines the THREADENTRY32 structure if I read that correctly.
Using a custom struct and passing it to the function works without any problems:
struct Test
{
int bla;
DWORD boo;
};
[…]
void EnumerateThreads(Test *test);
I’ve worked with int-/char-/float-/etc. arrays, but I don’t have any experience with struct arrays.
I just wondered why it does work with my own structs but not with the THREADENTRY32 one.
try using:
this will inline forward declare the struct, however, you need the full definition from
Tlhelp32.hwhere ever you access the members of the struct or use thesizeofoperator.alternatively you need to declare the struct (by including the
Tlhelp32.h) in the same translation unit (but preceding) of the proto and its uses, or provide a forward declaration for the compiler to bind to viastruct THREADENTRY32;