ReadProcessMemory from a .DLL with offset
Hello,
i am kinda stuck with my function.
i want to read out a string from the game SAMP.
Found it in CE and looks exactly like this:

It is pretty easy to read out the memory from only a window, but reading with a pointer from a .DLL is a bit too unknow for me.
So far i got the GetModuleBaseAddress function:
Code:
DWORD GetModuleBaseAddress(LPCWSTR szProcessName, LPCWSTR szModuleName)
{
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe32;
if (hSnap == INVALID_HANDLE_VALUE)
{
return 0;
}
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnap, &pe32) == 0)
{
CloseHandle(hSnap);
return 0;
}
do
{
if (lstrcmp(pe32.szExeFile, szProcessName) == 0)
{
int PID;
PID = pe32.th32ProcessID;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
MODULEENTRY32 xModule;
if (hSnap == INVALID_HANDLE_VALUE)
{
return 0;
}
xModule.dwSize = sizeof(MODULEENTRY32);
if (Module32First(hSnap, &xModule) == 0)
{
CloseHandle(hSnap);
return 0;
}
do
{
if (lstrcmp(xModule.szModule, szModuleName) == 0)
{
CloseHandle(hSnap);
return (DWORD)xModule.modBaseAddr;
}
} while (Module32Next(hSnap, &xModule));
CloseHandle(hSnap);
return 0;
}
} while (Process32Next(hSnap, &pe32));
CloseHandle(hSnap);
return 0;
}
and this is in my main function:
Code:
pHandle = OpenProcess(PROCESS_ALL_ACCESS | PROCESS_VM_OPERATION, TRUE, pId);
DWORD ADDR;
DWORD SAMPDLLBASE = GetModuleBaseAddress(L"GTA:SA:MP", L"samp.dll");
const char* ServerString;
ReadProcessMemory(pHandle, (LPVOID)(SAMPDLLBASE + 0x21A0F8), (LPVOID)&ADDR, sizeof(ADDR), NULL);
ADDR += 121;
ReadProcessMemory(pHandle, (LPVOID)(ADDR), (LPVOID)&ServerString, sizeof(ServerString), NULL);
cout << ServerString;
hopefully some nice guy can post me an example or something where i can look up, how this works. Where I Need Put The Value?
Your Is Float how about 4bytes
What is in your dll?
Did you make it?
Is it re-used code?
What is your knowledge of pointers? Is it small?