Hi guys, my code can read alphabet based player name correctly, but failed for not alphabet .
for example , this player name: Ashbringér , the letter é cannot be displayed correctly. my code is here
Code:
#include <iostream>
#include <windows.h>
#include <Tlhelp32.h>
#pragma comment(lib, "User32.lib")
#pragma comment(lib, "Advapi32.lib")
DWORD GetPID(char* procName);
DWORD GetBaseAddress(int pid);
int main ()
{
DWORD id = GetPID("Wow.exe");
DWORD base = GetBaseAddress(id);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, id);
char name[50] = {0};
ReadProcessMemory(hProcess, reinterpret_cast<const void*>(base + 0xF24D40), &name, 50, nullptr);
printf(name);
CloseHandle( hProcess );
return 0;
}
DWORD GetPID(char* procName)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if( hProcessSnap == INVALID_HANDLE_VALUE )
return 0;
// Set the size of the structure before using it.
pe32.dwSize = sizeof(PROCESSENTRY32);
// Retrieve information about the first process,
if(!Process32First(hProcessSnap, &pe32))
return 0;
do
{
if(strcmp(pe32.szExeFile, procName) == 0)
{
DWORD pid = pe32.th32ProcessID;
CloseHandle(hProcessSnap);
return pid;
}
} while(Process32Next(hProcessSnap, &pe32));
CloseHandle(hProcessSnap);
return 0;
}
DWORD GetBaseAddress(int pid)
{
HANDLE phandle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);//get permission to read
MODULEENTRY32 module;
module.dwSize = sizeof(MODULEENTRY32);
Module32First(phandle, &module);
CloseHandle(phandle);
return reinterpret_cast<unsigned int>(module.modBaseAddr);
}