This is part of some CSGO code and I don't know how to fix this problem; It's on line 8 of the snippet shown below:

uintptr_t GetModuleBaseAddress(const char* modName) {
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
if (hSnap != INVALID_HANDLE_VALUE) {
MODULEENTRY32 modEntry;
modEntry.dwSize = sizeof(modEntry);
if (Module32First(hSnap, &modEntry)) {
do {
if (!strcmp(modEntry.szModule, modName)) {
CloseHandle(hSnap);
return (uintptr_t)modEntry.modBaseAddr;
}
} while (Module32Next(hSnap, &modEntry));
}
}
}
Error message:
Argument Type (WCHAR*) is incompatible with parameter of type "const char*)
As mentioned in the comments, your problem lies in the fact that your (new) project has the "Use Unicode Character Set" option set for builds but the (old) code base expects to be built using the "Use Multi-Byte Character Set" option. (The former uses the
wchar_t*type for strings in Windows API calls and structures, whereas the latter uses thechar*type; these are incompatible pointers.)So, the 'quick fix' is to set your project's build options to use the "Multi-Byte" character set. In Visual Studio 2019, this option is the project's Properties -> Advanced -> Character Set when you right-click on the project in the Solution Explorer; earlier versions of Visual Studio have the option in the General property tab, IIRC.
If you are using some other IDE, then you'll need to 'manually' undefine the
UNICODEmacro (which signals to the compiler that the "Unicode Character Set" is in use); an#undef UNICODEline before any of your#include <...>lines for the system headers would work.For much (most) of the Windows API, this issue can also be resolved by using explicit
wchar_torcharversions of structures and functions; for example, theGetModuleFileNamefunction, mentioned in the comments, resolves to eitherGetModuleFileNameWorGetModuleFileNameA, depending on which character set is chosen for the build, and structures used in those calls haveWandAversions defined explicitly. Thus, one can 'override' the default call for the project's setting by explicitly using theA- orW-suffixed versions of those functions and structures.However, in your particular case, unfortunately, the
TlHelp32.hheader file (and the functions it defines) are not so well defined: There are no explicitA-suffixed versions, so you can't simply suffix yourMODULEENTRY32andModule32Firstreferences with anA, as one would like. (For Unicode builds, theW-suffixed versions simply overwrite the 'original' function and structure names, so these are then lost to your code.)Thus, without changing your code to use
TCHARtypes throughout (TCHARresolves to eithercharorwchar_t, depending on the character set option), your only sensible option is the aforementioned quick fix: change the build settings.