Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <Windows.h>
- enum {OK, CANT_OPEN};
- int patch (TCHAR* fname)
- {
- char first_patch[2] = {0x90, 0x90}; // NOP NOP
- char second_patch[2] = {0xEB, 0x07}; // JMP 40124C
- HANDLE hFile = CreateFile(fname,
- FILE_ALL_ACCESS, NULL,
- NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE)
- return CANT_OPEN;
- int SizeFile = GetFileSize(hFile, NULL);
- HANDLE MhFile = CreateFileMapping(hFile, 0, PAGE_READWRITE, 0, SizeFile, 0);
- HANDLE View = MapViewOfFile(MhFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
- UnmapViewOfFile(View);
- CloseHandle(hFile);
- CloseHandle(MhFile);
- return OK;
- }
- int main (int argc, char *argv[])
- {
- TCHAR* default_fname = "CRACKME.EXE";
- if (argc > 1)
- {
- default_fname = argv[1];
- }
- patch(default_fname);
- std::cout << default_fname << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment