Hotfix/patches

Discussion in 'C' started by kemnet, Nov 21, 2010.

  1. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    send him the executable file to overwrite the wrong one
     
  3. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  4. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    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
     
  5. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    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?
     
  6. seomanju

    seomanju Banned

    Joined:
    Nov 19, 2010
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    0
  7. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    what for :)
     
  8. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28

    you check only the executable file
     
  9. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    ok so i must redo the whole executable?
     
  10. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    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/transferring-psd-files-quickly/
     

    Attached Files:

    Last edited: Nov 21, 2010
    shabbir likes this.
  11. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Thanks! for this example im going to try to recreate it now :)
     
  12. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Hello so i did the did what u said and got this Long output with everything being different and wondering how I change this to a patch and then integrate it into patch1.

    Ive also been reading on Jojodif and it seems to be what im looking for. Tried it and seems to work but ill like to run the procedures over with you.

    So 1st i remaned my patches,
    so Patchm1 gives the output of
    Code:
    C=-1
    //1-2
    and Patch3 is C=3//2+1

    so lets call Patchm1 the error and Patch3 the revision.

    So i did Jdiff patchm1.exe patch3.exe patch.p
    ( First question:Is this the correct extension to use )

    then i did:Jptch patchm1.exe patch.p patch3
    (Thou i saw this in the example is causes the exe too bug out so i did)

    jptch patchm1.exe patch.p patch2
    So running Patch2 gave me"C=3"

    Therefore what I gather is
    Jdiff patchm1.exe patch3.exe patch.p
    Writes the difference into patch.p which is 1+2 into patch.p instead of 1-2
    and
    Jptch patchm1.exe patch.p patch3
    writes that into patch3?
     
  13. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    the extension of the patch file is something for you to decide
    you could use ptc to know its a patch file or whatever,just try to avoid
    known types of files like txt,exe,com,bat,jpg,... for obvious reasons.

    and finally
    Jptch patchm1.exe patch.p patch3

    convert it to

    Jptch patchm1.exe patch.p newpatch3.exe
     
  14. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Once again thanks for the help but...this isnt patching how id like.

    I added a simple line to patchm1.exe changed it too
    Hello
    c=-1

    then i do
    Jdiff patchm1.exe patch3.exe patch.p
    jptch patchm1.exe patch.p newpatch.exe

    this outputs C=3 without the Hello
    which is basically the data in patch3.exe

    Jdiff patch3.exe patchm1.exe patch.p
    jptch patch3.exe patch.p newpatch.exe

    outputs hello c=-1 which is patchm1.exe's data

    and when i do
    Jdiff patch3.exe patchm1.exe patch.p
    jptch patchm1.exe patch.p newpatch.exe

    it doesnt work :( so im stuck :embarasse
    cause im lookin for
    hello
    c=3
     
    Last edited: Nov 22, 2010
  15. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    are you sure that you open this program?---->newpatch.exe
    and not patch3.exe?
     
  16. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    yes very sure.
    I also keep getting the error "this version of the file is not compact. with my version of windows, im using a 64 bit visa
     
    Last edited: Nov 23, 2010
  17. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    Would you like me upload the files?
     
  18. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    yes
     
  19. kemnet

    kemnet New Member

    Joined:
    Nov 15, 2010
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    ok here it is,i also uploaded a screen shot of the commands i wrote.Thank you
     

    Attached Files:

  20. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    simple mathematics
    ===================
    A-B=C
    A+C=B

    jdiff patchm1.exe patch3.exe patch.p------>A(patchm1.exe) - B(patch3.exe) = C(patch.p)
    jptch patchm1.exe patch.p newpatch.exe--->A(patchm1.exe)+C(patch.p)=B(patch3.exe)=(newpatch.exe)


    how it works,generally idea
    ======================================================
    -You sent the wrong program named patchm1.exe to a user that bought your program
    So he has already patchm1.exe in his computer

    -Then you figure out that there is a bug to fix
    You fix it and make a new program called patch3.exe

    -instead of sending the patch3.exe to your user you decide to send him only
    the differences between the program with the bug and the one without it.
    So you send patch.p to him

    -He uses the jptch program to bring his file to the new version without the bug
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice