Patchers in c++

This is a discussion on Patchers in c++ within the C++ Programming forums, part of the General Programming Boards category; Hello! Can someone give me an example of a simple patcher in c++,which uses fseek(),fwrite() and such functions please....i thought ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Patchers in c++

    Hello!

    Can someone give me an example of a simple patcher in c++,which uses fseek(),fwrite() and such functions please....i thought of doing it like this...but i think it's wrong

    The Bytes i want to patch is at File Offset : 5B1 (1457)
    and the bytes look like 6886304000 (push 00403068)

    i want to push 00000000 at this Offset...how do i do this?


    fptr=fopen(file,"r+");
    if(fptr==NULL)
    {
    cout <<"::::Open File unsuccessful" << endl;
    }

    else
    {
    cout <<"::::Open File Successful" << endl;
    fseek(fptr,1457,SEEK_SET);
    fputs("00000000",fptr);
    cout <<"::::Bytes written" << endl;
    }

    fclose(fptr);
    Time for TOTAL WAR

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Open it for binary access, and then use fwrite( ). Actually, if you're doing it in C++ you should be using an ofstream.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    How do you know the exact offset you want to patch? I'm interested in how this works.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Well

    Use a dissassembler like Wdasm and you get the offset ...: )
    Time for TOTAL WAR

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    What can you use patches for? Legally, I mean.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    All kinds

    All kinds of things....like changing jumps and calls...make a button do something else then it's intended purpose...patch errors
    Time for TOTAL WAR

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Could you direct me to a good patching tutorial site?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    Registered User
    Join Date
    Jun 2002
    Posts
    36

    Sorry

    Nope...i don't have any sites...otherwise i wouldn't be asking in this forum
    Time for TOTAL WAR

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21