Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 我怎样才能确切地知道“什么是”呢;名称值“;任何时候程序启动时变量的大小?_Variables_Hook_Customization_Dll Injection_Aslr - Fatal编程技术网

Variables 我怎样才能确切地知道“什么是”呢;名称值“;任何时候程序启动时变量的大小?

Variables 我怎样才能确切地知道“什么是”呢;名称值“;任何时候程序启动时变量的大小?,variables,hook,customization,dll-injection,aslr,Variables,Hook,Customization,Dll Injection,Aslr,我在研究记忆,我在想这个问题: 根据系统,我如何钩住一个变量以便在程序中注入自定义值 如我所知(例如在windows中),如果要更改变量值,必须执行DLL注入,因此。。。我如何知道每次程序目标启动时变量的确切地址 我编写了一个简单的脚本,如下所示,它允许我用自定义值覆盖变量值: // include library #include <iostream> #include <windows.h> #include <tlhelp32.h> #include &

我在研究记忆,我在想这个问题:

根据系统,我如何钩住一个变量以便在程序中注入自定义值

如我所知(例如在windows中),如果要更改变量值,必须执行DLL注入,因此。。。我如何知道每次程序目标启动时变量的确切地址

我编写了一个简单的脚本,如下所示,它允许我用自定义值覆盖变量值:

// include library
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <vector>

// Declarations
using namespace std;

//DWORD pid = 19708;
DWORD address = 0x22A62C0E308;
int MyValue = 9000;

int main(int, char* []) 
{
    int i;

    std::vector<DWORD> pids;
    std::wstring targetProcessName = L"my_program.exe";

    HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //all processes

    PROCESSENTRY32W entry; //current process
    entry.dwSize = sizeof entry;

    if (!Process32FirstW(snap, &entry)) 
    { //start with the first in snapshot
        return 0;
    }

    do
    {
        if (std::wstring(entry.szExeFile) == targetProcessName) 
        {
            pids.emplace_back(entry.th32ProcessID); //name matches; add to list
        }
    } 
    while (Process32NextW(snap, &entry)); //keep going until end of snapshot

    for (int i(0); i < pids.size(); ++i) 
    {
        std::cout << pids[i] << std::endl;
    }

    for (int i(0); i < pids.size(); ++i)
    {
        HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pids[i]);
        printf("My pid: %lu\nMy address: %p\nMy vaule: %d\n\n", pids[i], address, MyValue);
        WriteProcessMemory(pHandle, (LPVOID)address, &MyValue, sizeof(MyValue+3), 0);
    }

    system("pause");
}
//包含库
#包括
#包括
#包括
#包括
//声明
使用名称空间std;
//德沃德pid=19708;
DWORD地址=0x22A62C0E308;
int MyValue=9000;
int main(int,char*[])
{
int i;
std::载体pids;
std::wstring targetProcessName=L“my_program.exe”;
HANDLE snap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);//所有进程
PROCESSENTRY32W条目;//当前进程
entry.dwSize=条目的大小;
if(!Process32FirstW(捕捉和输入))
{//从快照中的第一个开始
返回0;
}
做
{
if(std::wstring(entry.szExeFile)==targetProcessName)
{
pids.emplace_back(entry.th32ProcessID);//名称匹配;添加到列表
}
} 
while(Process32NextW(snap,&entry));//继续,直到快照结束
for(int i(0);i