#### Archived

This topic is now archived and is closed to further replies.

# Patches

This topic is 5888 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Basically, how do they work? For example, when you log on to Battle.net and it downloads the newest update. What''s a way I could essentially make a game I write patchable? ---- "Caw, caw, BANG f**k I''m dead!" --The Crow

##### Share on other sites
Make a program that can read and execute the patch-files.

They can be designed like this:

* number of files to be updated / added

CHUNK 2: LIST OF PATCH ITEMS
they store the actual data that has to be added or is used to exchange older files. The list contains exactly the number of items you declared in the header definitions (chunk 1).

* bool: replaces whole file?

if yes, just skip the following passage...

* position in file (where do you have to start copying / inserting)

* bool: just copy or do you have to replace

* if replace: datasize you have to DELETE from original file.

and then (-finally-) the data (image, sound, ...)

FINISHED!

With such a simple system you can keep your game patch-able...

Hope it helped...

Yours,

Indeterminatus

--si tacuisses, philosophus mansisses--

##### Share on other sites
Some patches are just self extracting archives containing the newest versions of changed files. This is much easier than actually patching the executable.

##### Share on other sites
of course, you''re right...i didn''t mean to patch the executable, but to WRITE an executable that can read your patchfile (just like an archive, but cut to the needs of a patch...)

i got the idea of an own patching system when i thought of a huge game project...if you have a huge file (around 60 megs, for example) it would be useless to download the complete file again, if only one megabyte has changed in the new version...do you get the idea?
If you tell the patch executable to copy the following data in file at position you would only need to provide the changed bytes + some xtra bytes with informations on what to do with the embedded data (in the patchfile)...

Hope it''s clearer now...

Yours,

Indeterminatus

--si tacuisses, philosophus mansisses--

##### Share on other sites
Look up each of "longest common subsequence" and "diff algorithm" on the web to get you started. I've never done it myself, so I can't offer much help, but it's worth a look.

[edited by - chronos on May 30, 2002 9:45:07 PM]

##### Share on other sites
That is a good idea Indeterminatus, but how would you know where to tell your patch file to put the updated section of code. What I mean is, say you have an executable that needs to be patched, how do you know where in the file the patch is suppose to go?

##### Share on other sites
By the way, for a bit of fun you can do this under Linux:
od -tx1 -w1 -v old_file | awk '{print ($2)}' > old_file.hexod -tx1 -w1 -v new_file | awk '{print ($2)}' > new_file.hexdiff old_file.hex new_file.hex
The first two commands convert binary files to hexadecimal, one byte per line. The last command outputs a list of differences between the two files. Because each line represents a byte, what you get is list of bytes which are either new or different.

[edited by - chronos on May 30, 2002 6:36:52 PM]

##### Share on other sites
You don''t need to do anything special to be able to write patachable programs.

For example:

The file "enemy.dat" contain all the possible words the enemy can say at you. Then, later, you want to add some more words. So, you create the new file and plug it into an installer. You hand out the ''patch'' that will allow the enemy to say more stuff. It''s a patch because it not a complet upgrade from the prior version.

Sometimes, you might need to upgrade the executable, if it can be done without the need to re-install the whole thing, you call it a patch.

So, basically a patch is the new file that will over write the old file. A small updrade.

It''s all you need

##### Share on other sites
Not always.

If you have small files, sure, overwrite them. But if you have a big data file, you need to update just what was changed.

##### Share on other sites
quote:
Original post by Anonymous Poster
That is a good idea Indeterminatus, but how would you know where to tell your patch file to put the updated section of code. What I mean is, say you have an executable that needs to be patched, how do you know where in the file the patch is suppose to go?

compiliers can ouput what is called a map file.
map files contain locations of everything that youve
declared in your code..be it variables, functions,
everything.

with such information, it is trivial to write a tool that
patches a chunk of code into the desired location and then
fixes up the subsequent addresses..this is not necessary if
the new piece of code is the _exact_ size as the original.

ive never actually patched an executable, but the above
would be my first attempt to do so..ive used a similar
method for generating loadable code segments for the n64
games ive worked on..so im sure it would work..

however, there are probably better ways to do it that i
am not aware of..

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631750
• Total Posts
3002060
×