DWORD ProcMem::Module(LPSTR ModuleName){
HANDLE hModule = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
MODULEENTRY32 mEntry;
mEntry.dwSize = sizeof(mEntry);
do
if (!strcmp(mEntry.szModule, ModuleName))
{
CloseHandle(hModule);
return (DWORD)mEntry.modBaseAddr;
}
while (Module32Next(hModule, &mEntry));
cout << "\nMODULE: Process Platform Invalid\n";
return 0;
}
the argument of type WCHAR* is not compatible with "const char*"`.
while holding my cursor on mEntry.
Your project is compiled with Unicode enabled, so CreateToolhelp32Snapshot()
maps to CreateToolhelp32SnapshotW()
, PROCESSENTRY32
maps to PROCESSENTRY32W
, and Process32Next()
maps to Process32NextW()
. Thus, ProcEntry.szExeFile
field is a WCHAR[]
array.
You are passing szExeFile
to strcmp()
, which does not support wchar_t*
strings, only char*
strings. You need to either:
use WideCharToMultiByte()
to convert szExeFile
to a char[]
array so you can then pass that to strcmp()
.
change your ProcessName
parameter to wchar_t*
, or use MultiByteToWideChar()
to convert ProcessName
to a wchar_t[]
array, and pass that to wcscmp()
or lstrcmpW()
instead of strcmp()
.
if you want to continue using TCHAR
-based APIs, change your ProcessName
parameter to LPTSTR
and then use _tcscmp()
or lstrcmp()
instead of strcmp()
.