Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- unsigned int filesize=0;
- unsigned int patch_offset=0;
- BYTE* file_buffer=0;
- int main()
- {
- DWORD high=0;
- HANDLE hFile=CreateFileA("Security.dll", GENERIC_ALL, 0, 0, OPEN_EXISTING, 0, 0);
- filesize=GetFileSize(hFile, &high);
- long allocated=(long)VirtualAlloc(VirtualAlloc(0, filesize, MEM_RESERVE, PAGE_EXECUTE_READWRITE), filesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
- ReadFile(hFile, (void*)allocated, filesize, &high, 0);
- CloseHandle(hFile);
- file_buffer=(BYTE*)allocated;
- for(unsigned int i=0; i<filesize; i++) //Pattern: 11 22 33 44 55 66 77 88 99 ?? BB ?? ?? EE FF
- {
- if(file_buffer[i]==0x11)
- {
- if(file_buffer[i+1]==0x22)
- {
- if(file_buffer[i+2]==0x33)
- {
- if(file_buffer[i+3]==0x44)
- {
- if(file_buffer[i+4]==0x55)
- {
- if(file_buffer[i+5]==0x66)
- {
- if(file_buffer[i+6]==0x77)
- {
- if(file_buffer[i+7]==0x88)
- {
- if(file_buffer[i+8]==0x99)
- {
- if(file_buffer[i+10]==0xBB)
- {
- if(file_buffer[i+13]==0xEE)
- {
- if(file_buffer[i+14]==0xFF)
- {
- patch_offset=i;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if(!patch_offset)
- puts("Pattern not found, maybe the version is too new/old..\n");
- else
- printf("Raw patch offset: %08X\n\n", patch_offset);
- system("pause");
- //patching:
- char patch_data[10]={0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0x00};
- memcpy((void*)patch_offset+file_buffer, (void*)patch_data, 10);
- //write a new file here (no time)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement