[C win32] Patching several bytes at once

Discussion in 'Mixed Languages' started by Pr3acher, Oct 16, 2012.

  1. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    142
    48
    10
    Hi,
    i'm very new to programmation and i want to know more on patching:
    how can i retrieve a string of opcode from an edit and patch a file with em ?
    For instance i have offset 0x3f3c and retrieve 0x908e from the edit; so i want to apply 0x90 at offset 0x3f3c
    and so 0x8e at offset 3f3d
    How to do such a thing ?

    Thanks.
     
  2. woot332

    woot332 MDL Senior Member

    Feb 18, 2011
    390
    810
    10
    Why not try this

    http://diablo2oo2.di.funpic.de/dup.html
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    142
    48
    10
    Yes thank you woot332 but i already know it. I don't want a patcher i want to know HOW to do it...
    I've already done a patecher but it can only patch a byte at a time and i want several...
     
  4. woot332

    woot332 MDL Senior Member

    Feb 18, 2011
    390
    810
    10
    I see, check out the offset patcher section

    http://arteam.accessroot.com/arteam/site/download.php?view.173
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    142
    48
    10
    Still thanks for trying to help woot332 but that still not what i was searching thoough it is interesting...
    i'll past a part of code if it can help:
    <code>
    FILE *f=0;
    f=fopen(filePathName,"r+");//filePathName is retrieved by GetOpenFileName()
    fseek(f,getOffset,SEEK_SET);//getOffset is retrieved by GetWindowText() as it is an edit
    fprintf(f,"%c",getOpcode);//then i retrieved the patch code (getOpcode) and patch
    fclose(f);
    </code>
    the problem here: if we have several offset to patch it would be boring to do it one by one...
    thanks for helping
     
  6. woot332

    woot332 MDL Senior Member

    Feb 18, 2011
    390
    810
    10
    If the offsets are incremental maybe you could swap out "c" format with "s".

    http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Pr3acher

    Pr3acher MDL Member

    Aug 24, 2012
    142
    48
    10
    yes, i've already tried it but the prog goes crash :(