Hey,
glad to see you're getting into hacking.
Firstly, I can't resist to comment on your LoopToAddress function, it's poorly written. Having an if statement like that in a for loop is usually an indicator of bad design, but I'll leave that up to you.
Here's the real problem:
Not only is your GetProcessThreadID function completely wrong, but it's also not the right thing to do. In case you wonder,
Code:
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
You pass in 0 for the process id, that's completely wrong and will surely fail, you're supposed to pass in the process id of the remote process.
Anyways, what you actually need to figure out is the base address of the main module. The code to do that is quite similar to your GetProcessThreadID function, also using TlHelp32:
Code:
HMODULE RemoteGetModuleHandle(HANDLE processHandle, const char* moduleName)
{
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetProcessId(processHandle));
if (snapshot == INVALID_HANDLE_VALUE)
return NULL;
MODULEENTRY32 entry;
entry.dwSize = sizeof(MODULEENTRY32);
if (!Module32First(snapshot, &entry))
return NULL;
do {
if (!strcmpi(moduleName, entry.szModule))
return entry.hModule;
entry.dwSize = sizeof(MODULEENTRY32);
} while (Module32Next(snapshot, &entry));
return NULL;
}
Now do this instead:
Code:
HMODULE hModule = RemoteGetModuleHandle(hProcHandle, "witcher3.exe");
valueToTest = LoopToAddress(3, hProcHandle, OffSet, (DWORD)hModule + 0x02BA2890);
Also it doesn't matter that you use DWORD instead of float, they're the same size. It will only start to matter when you print it out. You can't simply cast it at this point, you would have to do something like this:
Code:
DWORD value = LoopToAddress(3, hProcHandle, OffSet, (ProcessId + 0x02BA2890));
valueToTest = *(float*)&value;
But again, that could be avoided if you would re-write LoopToAddress...
If you still need help ask me.
-- Xen0
EDIT: I just realized that witcher3 is 64 bit, so instead of using DWORD's for pointers you actually have to use QWORDs. I'll leave making those changes up to you. This will actually force you to re-write your LoopToAddress function because now in the last iteration you would read 8 bytes instead of only 4.