void WriteAsm(void* pxAddress, BYTE *code, int Bytes)
{
unsigned long Protection;
VirtualProtect((void*)pxAddress, Bytes, PAGE_READWRITE, &Protection);
memcpy((void*)pxAddress, (const void*)code, Bytes);
VirtualProtect((void*)pxAddress, Bytes, Protection, 0);
}
Quote:
Hallo,
ich nutze derzeit die folgende funktion um den Opcode zu ändern:
WriteAsm((void*)Player_...., (BYTE*)"\x..\x..\x..\x..\x..", 5);Code:void WriteAsm(void* pxAddress, BYTE *code, int Bytes) { unsigned long Protection; VirtualProtect((void*)pxAddress, Bytes, PAGE_READWRITE, &Protection); memcpy((void*)pxAddress, (const void*)code, Bytes); VirtualProtect((void*)pxAddress, Bytes, Protection, 0); }
Jedoch crasht es mir kurz nachdem ich die Funktion nutze woran liegt das ?
Es liegt nicht daran das ich etwas falsch umschreibe.
Bitteschön :)Quote:
lpflOldProtect [out]
A pointer to a variable that receives the previous access protection value of the first page in the specified region of pages. If this parameter is NULL or does not point to a valid variable, the function fails.
° -° danke omdiharchen <3 hatte das zwar schon hatte aber vergessen das hier zu posten das es erledigt ist ;DQuote:
Bitteschön :)
Der zweite Aufruf von VirtualProtect schlägt fehl, sodass die Memory Protection bei PAGE_READWRITE bleibt und beim Ausführen der jeweiligen ASM Instructions eine unbehandelte Ausnahme geworfen wird.
void WriteAsm(void* pxAddress, BYTE *code, int Bytes)
{
DWORD dwOldProtect, dwBkup;
VirtualProtect(pxAddress, Bytes, PAGE_EXECUTE_READWRITE, &dwOldProtect);
memcpy((void*)pxAddress, (const void*)code, Bytes);
VirtualProtect(pxAddress, Bytes, dwOldProtect, &dwBkup);
}
Here ~Quote:
Could someone give me the clean weapon_spydagger.7 ? Please.