简体   繁体   English

C++读取内存崩溃

[英]C++ read memory crash

I'm trying to read memory in a different process, but every time I run the script, it crashes.我试图在不同的进程中读取内存,但每次运行脚本时,它都会崩溃。 [Windows 7 32-bit] [Windows 7 32 位]

Here's my code:这是我的代码:

#include <windows.h>
#include <iostream>
using namespace std;

unsigned int canJump;


int main()
{
    //DWORD oldProtect;
    //VirtualProtect((LPVOID)0x04565020, sizeof(unsigned int), PAGE_READONLY, &oldProtect);

    while(1)
    {
        canJump = *(unsigned int*)0x04565020;

        if(!paused)
        {
            if(GetAsyncKeyState(VK_SPACE) && canJump == 0)
                cout << "here" << endl;
        }

        if(GetAsyncKeyState(VK_F9))
            break;
    }
    return 0;
}

I looked into VirtualProtect (as you can see), but it did nothing.我查看了 VirtualProtect(如您所见),但它什么也没做。 :( :(

Your problem is you're using code intended for an internal hack, in an external hack.您的问题是您在外部黑客中使用了用于内部黑客的代码。

int main() indicates this is an external hack and you're targetting an external project int main()表示这是一个外部 hack 并且您的目标是外部项目

canJump = *(unsigned int*)0x04565020; is code you would normally see in an internal hack.是您通常会在内部 hack 中看到的代码。 This line is de-referencing an address to get it's value and store it in canJump.此行取消引用地址以获取其值并将其存储在 canJump 中。 Your program is external to the target process, therefore you cannot de-reference memory from an external process.您的程序在目标进程的外部,因此您不能从外部进程取消引用内存。 Your current code is de-referencing local memory.您当前的代码正在取消引用本地内存。

To solve your problem, you must either convert this to an internal DLL which you inject or re-write everything as an external hack.要解决您的问题,您必须将其转换为您注入的内部 DLL,或者将所有内容重写为外部 hack。 If you make it an external hack, you must use ToolHelp32Snapshot(), OpenProcess(), ReadProcessMemory() and WriteProcessMemory() to achieve your goal.如果您将其设为外部 hack,则必须使用 ToolHelp32Snapshot()、OpenProcess()、ReadProcessMemory() 和 WriteProcessMemory() 来实现您的目标。

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

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