簡體   English   中英

簡化多個ReadProcessMemory調用

[英]Simplify multiple ReadProcessMemory calls

最近,我開始對Cheat Engine進行一些實驗,以便能夠從正在運行的進程的內存中讀取數據,並偶然發現了本教程的第8步。 我想從我的應用程序中讀取一個特定的值,該值存儲在我正在讀取的第二個進程的[[[[[0x00645390]+0xC]+0x14]+0x0]+0x18]中,其中0x00645390是靜態的。

當前,它可以與以下瘋狂的指針處理代碼段一起使用:

::ReadProcessMemory(hProcess, (void *)0x00645390,           (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0xc),    (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0x14),   (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress),          (void *)&dwAddress, sizeof(dwAddress), NULL);
::ReadProcessMemory(hProcess, (void *)(dwAddress + 0x18),   (void *)&dwValue,   sizeof(dwAddress), NULL);

我想知道當同時具有基本地址和一些偏移量時是否可以使用某個函數或更短的符號。

您當然可以使用以下靜態數組:

int offset[] = { 0, 12, 20, 0, 24 };/* (or 0xC, 0x14,m 0, 0x18) */

dwAddress = 0x00645390;
for( auto i : offset)
    ::ReadProcessMemory(hProcess, (void *)(dwAddress + i),
                        (void *)&dwAddress, sizeof(dwAddress), NULL);
dwValue = dwAddress;

不確定它能帶來多少收益。

您要做的基本上是遵循一組指針,因此:

 global->something->other->thingy->value

您需要在每個級別讀取每個指針,因此讀取所有地址沒有捷徑。 [這也適用於編譯器必須訪問一長串指針的情況-必須在讀取指針所指向的元素之前讀取每個指針]

(不確定我在那里沒有足夠的元素,但是這個概念適用)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM