كيفيه استخدام ال array داخل تعليمات الاسمبلى - Elmasry - 22-10-2022
السلام عليكم ورحمه الله وبركاته
قمت بعمل هوك على لعبه واخدت عنوان من ال ebx الى متغير (value)
ال ebx داخل loop وفى اكتر من عنوان ف انا حولت اضيف كل العناوين داخل array ولو فى عنوان موجود داخل ال array او متكرر لا يتم اضافته
ولكن اللعبه بتقفل , [ اللعبه بقت تفصل لما ضفت ال array]
#include <Windows.h>
#include <iostream>
#include <string>
#include <TCHAR.H>
#include "Header.h";
using namespace std;
#pragma comment( lib, "psapi.lib" )
Memory memory;
DWORD jmpBackAddys;
DWORD items = 0x00;
//===============================================//
DWORD lpitemsAddress = 0x00;
vector<uint32_t> itemsID;
int n = sizeof(itemsID) / sizeof(itemsID[0]);
int index = -1;
//===============================================//
bool Hook(void * toHook, void * ourFunct, int len)
{
if (len < 5)
{
return false;
}
else
{
}
DWORD curProtection;
VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
memset(toHook, 0x90, len);
DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;
*(BYTE*)toHook = 0xE9;
*(DWORD*)((DWORD)toHook + 1) = relativeAddress; // <-- I DID NOT UNDERSTAND THIS
DWORD temp;
VirtualProtect(toHook, len, curProtection, &temp);
return true;
}
void __declspec(naked) server_buffer()
{
__asm
{
mov ebx, dword ptr ss : [ebp - 0x1C]
pushad
pushfd
mov lpitemsAddress, ebx
}
//===================================================//
for (int i = 0; i < n; i++)
{
if (itemsID[i] == lpitemsAddress)
{
index = i;
break;
}
}
if (index == -1)
{
itemsID.push_back(lpitemsAddress);
}
//===================================================//
__asm{
popfd
popad
test ebx, ebx
jmp jmpBackAddys
}
}
DWORD WINAPI MainThread(LPVOID param)
{
int itemshookLength = 5;
DWORD itemshookAdd = 0x00BD73A1 ; //
jmpBackAddys = itemshookAdd + itemshookLength;
Hook((void*)itemshookAdd, server_buffer, itemshookLength);
AllocConsole();
FILE* f;
freopen_s(&f, "CONOUT$", "w", stdout);
while (true)
{
Sleep(10);
if (GetAsyncKeyState(VK_F1) & 0x8000)
{
for (int i = 0; i < itemsID.size(); i++) {
cout << "_test" << itemsID[i] << endl;
}
Sleep(1000);
}
}
fclose(f);
FreeConsole();
FreeLibraryAndExitThread((HMODULE)param, 0);
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) {
switch (dwReason) {
case DLL_PROCESS_ATTACH:
CreateThread(0, 0, MainThread, hModule, 0, 0);
break;
}
return TRUE;
}
|