
Originally Posted by
Graaff
That doesn't really matter since if modules haven't been found my program will exit on it's own.
It doesn't really matter, but it's bad practice to leak handles or memory. In theory, you don't need to free memory any memory, since the OS will take care of the allocated memory when the program exits, however, it's not good practice to leak memory or handles.
- - - Updated - - -

Originally Posted by
derkrasseboy
If i go with 2 CloseHandles like this:
Code:
DWORD Module(char* szModuleName)
{
HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessID);
MODULEENTRY32 mEntry;
mEntry.dwSize = sizeof(mEntry);
if (Module32First(hModule, &mEntry))
{
do
{
if (!strcmp((char*)mEntry.szModule, szModuleName))
{
CloseHandle(hModule);
return (DWORD)mEntry.modBaseAddr;
}
} while (Module32Next(hModule, &mEntry));
}
CloseHandle(hModule);
return false;
}
its still returning 0
and do i have to call the function like this:
Code:
if (__Client == 0x0) __Client = Module("client.dll");
or like this:
Code:
while (__Client == 0x0) __Client = Module("client.dll");
?
It doesn't matter if you use an if statement or a while loop.
Use your debugger and see whats wrong. Also, after you returned 0, call GetLastError. I'm fairly certain it has something to do with your ProcessID.
You can use Process32First / Process32Next to traverse the process list and get the process id.