Hi, can someone help me?
I want to write a programm that patch a file at an specific offset, but i dont know how to do this. Im very happy when someone can help me!!
thx
(sorry for my bad english )
Hi, can someone help me?
I want to write a programm that patch a file at an specific offset, but i dont know how to do this. Im very happy when someone can help me!!
thx
(sorry for my bad english )
A general question like this probably means that you are new to C++ programming. (?)
If you haven't done any C++ programming yet, then you have to learn the basics before attempting something like this. If you know some C++, then study-up on file I/O and write some code... then if you have problems, post your code here, and someone will help you to get your program working. If you haven't read the board guidelines yet, read them. (Nobody is going to write your program for you.)
If all you want to do is change a few bytes in a file, then it would be easier to use a hex editor. I found a nice one free on the net, but I've forgotten the name, (and I don't have it with me here).
And, make sure you have a backup of the original file before you start changing it!
Patching a file can be done in binary file mode. All you need to know is where to start inserting the code. The location can be found by a careful analysis of your code in an assembly language listing or even a memory dump.
hmm, your right. Im not an experience programmer, but im also not an "stupid" newbie .
I dont want to use a HexEditor of course (for what im learning c++ !?), so anything i want to know is how to open a file (in my programm) and patch the file at an specific offset.
If someone can post a little code i were very glad .
The word "an" is reserved for vowel sounds. For example, you can have "an arm", but not "an leg" or "an specific". Note it's vowel sounds, you can't for example have "an european" because it is pronounced with a 'u' sound.
- Grammar Police.
btw I'm guessing english isn't your first language, so don't be insulted or anything, it's just 1:14AM and I'm bored.
also (to make my post relevant) is this kind of patching common? I guess it is for large files, but these days patches can be massive and not visibly change anything.
Thor's self help tip:
Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.
OS: Windows XP
Compiler: MSVC
I think this example will demonstrate techniques of overwriting data in a file. If the "patch" involves more than just overwriting, then the read to file/change data/write back to file method offers more flexibility. I have not run program to rule out logic errors or errors of other types.
Code://////// //myFile.dat /////// abdd ////////// //myProgram.cpp ///////// //goal---change abdd to abcd //assumption--desired position is 2 (zero based counting) #include <fstream> #include <string> int main() { //patch file method //open file for writing without truncating data. ofstream fout("myFile.dat", ios::in | ios::out | ios::trunc); //first position ouput pointer to correct position fout.seekp(2, ios::beg); //then overwrite (patch) data at that position fout << c; fout.close(); //change file data in program method //open stream to write and stream to read fout.open("myFile.dat", ios::in | ios::out | ios::trunc); ifstream fin("myFile.dat"); string temp; //read data into program from file fin >> temp; //ovewrite data in program temp[2] = 'c'; //return data to file from program fout << temp; fout.close(); fin.close(); return 0; }
stupid noobie
Just a point noobie's aren't stupid just ignorant. I have been studying programming for over a year now and will probably be a newbie for the next ten years if not life.
btw this is an interesting topice, are the above methods used professionally like in games such as Planetside or AC2?
Do the patches usually overwrite exisiting exe s or are they rebuilt somwhow without a compiler. I know they are all done via Networking so is there some other special technique.
Last edited by curlious; 09-18-2003 at 11:34 AM.
I'd assume most patches by game creators are auto-generated; they probably do nothing more than compare the desired .exe with the pre-patched .exe and create a program to change one to the other.
I've patched files in this manner before, for example, when I feel particularly ambitious I will write patches for games, especially old games that are no longer ever going to be supported by their manufacturers, and if I like the patches, I usually share an .EXE that does the patching.
I also used to patch my own .EXEs many many years ago, because I always lost my damned manuals so I couldn't know what "word 4 in paragraph 2 on page 11 of the manual" was. In my defense, I legally owned all the games, and never distributed those patches, but I found the patching useful.
Last edited by Cat; 09-18-2003 at 03:01 PM.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
Is there some utilitity that compares two exe files and creates a patch.exe to convert from one to the other if so could you please post a link.
I don't know of a program, but it would be fairly simple to write one if the patch only requires overwriting and/or appending. If you have to insert-and-shift... this might be a little more "interesting".Is there some utilitity that compares two exe files and creates a patch.exe to convert from one to the other if so could you please post a link.
hehe, you right... my english is not very good .
but thx for your help!!
----------------------------------------------------------------
curlious: you looking for a file comparer-patcher?
try:
http://www.softnews.ro/public/cat/5/3/5-3-1.shtml