Last active
February 26, 2021 08:05
-
-
Save aaaddress1/55d88fa73e78c95f169448b634cf0004 to your computer and use it in GitHub Desktop.
dynPatchSelf.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dynamic patch self function by [email protected] | |
#include <windows.h> | |
#include <algorithm> | |
#include <iterator> | |
using namespace std; | |
void hello() | |
{ | |
puts("Are You Helloing?"); | |
} | |
int main(void) | |
{ | |
BYTE pattern[] = "\xCD\x03\xCD\x03\xCD\x03\xCD\x03"; | |
PBYTE pFound = search((PBYTE)main, &((PBYTE)main)[0x200], pattern, &pattern[sizeof(pattern) - 1]); | |
VirtualProtect(pFound, 5, PAGE_EXECUTE_READWRITE, (PDWORD)&pattern); | |
pFound[0] = '\xE8'; | |
*(PDWORD)&pFound[1] = (DWORD)hello - (DWORD)pFound - 5; | |
asm __volatile__(".byte 0xCD;.byte 0x03;.byte 0xCD;.byte 0x03;.byte 0xCD;.byte 0x03;.byte 0xCD;.byte 0x03;"); | |
return 0; | |
} |
Author
aaaddress1
commented
Feb 26, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment