Hotfix/patches

kemnet's Avatar, Join Date: Nov 2010
Go4Expert Member
Hello.
Question.

Lets say I write an executable program that is supposed to do

A+B+C

but i made a mistake and it does
A+B-C

and i only discovered this error after i built the program and sold it so someone.
how do i write a separate executable / patch i can send to the person that will correct that error IN c++.
Thank YOU
virxen's Avatar, Join Date: Nov 2009
Pro contributor
send him the executable file to overwrite the wrong one
kemnet's Avatar, Join Date: Nov 2010
Go4Expert Member
well yes...but...im thinking if its a big program. Cant I just write up a little code that will do that?instead of the WHOleeeee Executable?
virxen's Avatar, Join Date: Nov 2009
Pro contributor
then try the patch method

read both files and find the differences(what the difference is and where)
write the data in a file
and send this with an exe patcher program to issue the changes to the old program
kemnet's Avatar, Join Date: Nov 2010
Go4Expert Member
ok with this patch method if you have four forms will you be able to specify that you only want to check out the code on the 1st form?
seomanju's Avatar
Banned
thanks
kemnet's Avatar, Join Date: Nov 2010
Go4Expert Member
Quote:
Originally Posted by seomanju View Post
thanks
what for
virxen's Avatar, Join Date: Nov 2009
Pro contributor
Quote:
Originally Posted by kemnet View Post
ok with this patch method if you have four forms will you be able to specify that you only want to check out the code on the 1st form?

you check only the executable file
kemnet's Avatar, Join Date: Nov 2010
Go4Expert Member
ok so i must redo the whole executable?
virxen's Avatar, Join Date: Nov 2009
Pro contributor
this is patch1.cpp
Code:
#include <stdio.h>

int main(){
    int A=1,B=2,C=0;
    C=A+B;
    printf("\nC=%d",C);
    getchar();
    return 0;
}

this patch2.cpp
Code:
#include <stdio.h>

int main(){
    int A=1,B=2,C=0;
    C=A-B;
    printf("\nC=%d",C);
    getchar();
    return 0;
}

patch2.cpp is the program with the error and patch1.cpp is the correct one

you compile both of them

if you see the executables in a hex editor and compare them with each other
you will see that most of the files are the same.
you need to change only the differences

in dos prompt you can use fc=filecompare like this
fc patch1.exe patch2.exe >differences.txt

in this text file you will see what you have to change in patch2.exe in order to become patch1.exe

see the files in the zip file.


p.s. all the above must be done programatically by you
or you can use something like this to do it automatically http://sourceforge.net/projects/jojodiff/



also another article based on what you want is here http://www.codediesel.com/tools/tran...files-quickly/
Attached Files
File Type: rar patch.rar (10.1 KB, 3 views)

Last edited by virxen; 22Nov2010 at 01:01..
shabbir like this