![]() |
![]() |
![]() |
![]() |
![]() |
||||||||||
|
||||||||||||||
![]() |
#1
|
|||
|
|||
![]() Hello,
I need help with making a patch for .exe file. I can patch it with OllyDbg. I need to write a patch to automate the process. I am just asking for example source code in c. For example: change a conditional jump to nops (0X90h) on 2 addresses. Thanks, |
#2
|
|||
|
|||
![]() Use any of ready patch builder softwares available (Diablo universal patcher is good enough).
If you insist for source code here one very simple (any decent compiler should compile it): Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { FILE *pFile = NULL; char inp_file[256] = "MyOriginalFile.exe"; char out_file[256] = ""; unsigned char *file_buffer = NULL; pFile = fopen(inp_file, "rb"); if(pFile == NULL) return; // obtain file size fseek(pFile, 0, SEEK_END); long file_size = ftell(pFile); rewind(pFile); // note this example require at least file_size memory!!!! file_buffer = (unsigned char*)malloc(sizeof(unsigned char) * file_size); fread (file_buffer, 1, file_size, pFile); fclose (pFile); unsigned int offset_to_patch_1 = 0x10000; unsigned int offset_to_patch_2 = 0x20000; unsigned char patch_data[] = { 0x90, 0x90 }; // nop, nop memcpy(&file_buffer[offset_to_patch_1], patch_data, sizeof(patch_data)); memcpy(&file_buffer[offset_to_patch_2], patch_data, sizeof(patch_data)); // outfile name sprintf(out_file, "%s_patch.exe", inp_file); // and write as new file pFile = fopen(out_file, "wb"); fwrite (file_buffer, 1, file_size, pFile); fclose (pFile); free(file_buffer); } |
#3
|
|||
|
|||
![]() Sverox,
Thanks for your help and the source code that you provided. I appreciate your time and help. Regards, |