简体   繁体   English

'LPVOID': 非法将此类型用作表达式

[英]'LPVOID': illegal use of this type as an expression

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我将 -> 'LPVOID': 非法使用这种类型作为表达式

#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 RPM 模板

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最后在这里附上dll

Okey guys im waiting answer have good day:)好的,我正在等待答案,祝你有美好的一天:)

You are not calling ReadProcessMemory() correctly.您没有正确调用ReadProcessMemory() You are passing it a type where a memory address is expected.您传递给它的类型是 memory 地址。 You are ignoring the address parameter being passed in to Read() , that is what you should be type casting to LPVOID , eg:您忽略了传递给Read()address参数,这就是您应该将类型转换为LPVOID的内容,例如:

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.第二个参数只是(LPVOID) ,它只是一个类型,但它需要是一个表达式。 Are you trying to cast something to LPVOID ?您是否尝试将某些内容投射到LPVOID

Perhaps you meant (LPVOID)&VALUE or maybe (LPVOID)0 ?也许您的意思是(LPVOID)&VALUE(LPVOID)0

The error message issued to you by your compiler should have given you this line number.编译器向您发出的错误消息应该给您这个行号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM