Advertisement
mrexodia

for qpt ;)

Dec 9th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. unsigned int filesize=0;
  5. unsigned int patch_offset=0;
  6. BYTE* file_buffer=0;
  7.  
  8. int main()
  9. {
  10.     DWORD high=0;
  11.     HANDLE hFile=CreateFileA("Security.dll", GENERIC_ALL, 0, 0, OPEN_EXISTING, 0, 0);
  12.     filesize=GetFileSize(hFile, &high);
  13.     long allocated=(long)VirtualAlloc(VirtualAlloc(0, filesize, MEM_RESERVE, PAGE_EXECUTE_READWRITE), filesize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  14.     ReadFile(hFile, (void*)allocated, filesize, &high, 0);
  15.     CloseHandle(hFile);
  16.     file_buffer=(BYTE*)allocated;
  17.     for(unsigned int i=0; i<filesize; i++) //Pattern: 11 22 33 44 55 66 77 88 99 ?? BB ?? ?? EE FF
  18.     {
  19.         if(file_buffer[i]==0x11)
  20.         {
  21.             if(file_buffer[i+1]==0x22)
  22.             {
  23.                 if(file_buffer[i+2]==0x33)
  24.                 {
  25.                     if(file_buffer[i+3]==0x44)
  26.                     {
  27.                         if(file_buffer[i+4]==0x55)
  28.                         {
  29.                             if(file_buffer[i+5]==0x66)
  30.                             {
  31.                                 if(file_buffer[i+6]==0x77)
  32.                                 {
  33.                                     if(file_buffer[i+7]==0x88)
  34.                                     {
  35.                                         if(file_buffer[i+8]==0x99)
  36.                                         {
  37.                                             if(file_buffer[i+10]==0xBB)
  38.                                             {
  39.                                                 if(file_buffer[i+13]==0xEE)
  40.                                                 {
  41.                                                     if(file_buffer[i+14]==0xFF)
  42.                                                     {
  43.                                                         patch_offset=i;
  44.                                                     }
  45.                                                 }
  46.                                             }
  47.                                         }
  48.                                     }
  49.                                 }
  50.                             }
  51.                         }
  52.                     }
  53.                 }
  54.             }
  55.         }
  56.     }
  57.     if(!patch_offset)
  58.         puts("Pattern not found, maybe the version is too new/old..\n");
  59.     else
  60.         printf("Raw patch offset: %08X\n\n", patch_offset);
  61.     system("pause");
  62.  
  63.     //patching:
  64.     char patch_data[10]={0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0x00};
  65.     memcpy((void*)patch_offset+file_buffer, (void*)patch_data, 10);
  66.  
  67.     //write a new file here (no time)
  68.  
  69.     return 0;
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement