I don't know the very vell the Dynamic-Link-Library if i ask the bad question sorry guys
Im taking the -> 'LPVOID': illegal use of this type as an expression
#include "pch.h"
#include <iostream>
#include <Windows.h>
Library
HANDLE handle;
HWND hwnd;
DWORD pID;
Some requires for giving the handle game
template <class T>
T Read(DWORD address)
{
T VALUE;
ReadProcessMemory(handle, (LPVOID), &VALUE, sizeof(T), 0);
return VALUE;
}
RPM Template
void readingvariables()
{
// 00DB0000 - sauerbraten.exe
DWORD localplayer = Read<DWORD>(0x00DB0000 + 0x213EA8);
int health = Read<int>(localplayer + 0x15C);
printf("Health :", health);
}
Reading variables there is here
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
readingvariables();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Last here to attach dll
Okey guys im waiting answer have good day:)
You are not calling ReadProcessMemory()
correctly. You are passing it a type where a memory address is expected. You are ignoring the address
parameter being passed in to Read()
, that is what you should be type casting to LPVOID
, eg:
template <class T>
T Read(DWORD address)
{
T VALUE;
if (!ReadProcessMemory(handle, (LPVOID)address, &VALUE, sizeof(T), NULL))
{
// error handling...
}
return VALUE;
}
Your problem is here:
ReadProcessMemory(handle, (LPVOID), &VALUE, sizeof(T), 0);
The second argument is just (LPVOID)
, which is just a type, but it needs to be an expression. Are you trying to cast something to LPVOID
?
Perhaps you meant (LPVOID)&VALUE
or maybe (LPVOID)0
?
The error message issued to you by your compiler should have given you this line number.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.