Reputation: 5541
I was analyzing this code from the companion CD rom that comes with the book "Windows via C\C++" and I came across this statement
m_hSnapshot = CreateToolhelp32Snapshot(dwFlags, dwProcessID);
where dwFlags
and dwProcessID
are DWORD's
And when I jumped to the defination of this function CreateToolhelp32Snapshot
I found this
HANDLE
WINAPI
CreateToolhelp32Snapshot(
DWORD dwFlags,
DWORD th32ProcessID
);
How could such a function without a body exist?
I tried to debug the code but the compiler doesn't step into this function, instead it simply steps over the first statement with a value of 0x00000754 stored in m_hSnapshot.
Upvotes: 2
Views: 4517
Reputation: 930
Yeah, that's just a prototype for a function that's defined in an existing Windows DLL (Kernel32.dll)
Upvotes: 0
Reputation: 2860
Its just a function to accept parameters, it is probably used by a method somewhere else, after user initialization. It looks like it is actually just getting a snapshot of the processID to display when you say go into the command prompt and request a process display.
Upvotes: 0
Reputation: 3586
The body may be at different places, in a static or dynamic library that you link against for example.
Upvotes: 0
Reputation: 81349
What you see is not a function definition but a declaration. The actual definition is provided by dlls in Windows itself, linked to your executable.
Upvotes: 5
Reputation: 258618
The function has a body, but it's just not visible.
That's just the declaration. If it was visible, Windows would be open source (don't laugh). C++ is a compiled language. Binary files are generated from code, the code itself isn't required to call a function.
Upvotes: 0
Reputation: 500457
How could such a function without a body exist?
It doesn't. What you're seeing is just a function prototype. The body is defined elsewhere.
Upvotes: 7