MDIFF - MPATCH Release 1.50 Simple but complete program to produce and apply patches to your programs and data files for Dos, OS/2, Windows95 and WindowsNT. English manual (C) 1995/96 Maurizio Giunti - All rights reserved 1.INDEX 1.INDEX 2 2.DISCLAIMER OF WARRANTY 3 3.DISTRIBUTION AND USE 3 4.WHY? 3 5.WHAT MDIFF-MPATCH DO? 3 6.EXAMPLE 3 7.DOS, OS/2, WINDOWS 95 AND WINDOWS NT 4 8.LIMITS AND KNOWN BUGS 4 9.MDIFF - MDIFF2 - MDIFFW 4 10.MPATCH - MPATCH2 - MPATCHW 5 11.MDF2EXE - MDF2EXE2 - MDF2EXEW 6 12.SUGGESTIONS 6 13.LIBRARIES TO APPLY PATCHES 6 14.REGISTERING MDIFF 6 15.HOW TO CONTACT THE AUTHOR 7 16.ACKNOWLEDGEMENTS 7 2 2.DISCLAIMER OF WARRANTY THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. The only warranty that comes with this software is that it will occupy disk space. I absolutely can NOT warrant that it will perfectly work, or that it will be your problems' solution. Nevertheless, it is not a virus and does not contain (unless infected or modified after the compilation) Trojan-horses, backdoors and similar tricky garbage. In any case, the author is not responsible for any damage, moral or material, direct or indirect, derived from its use. 3.DISTRIBUTION AND USE This software belongs to Shareware programs: anyone can freely distribute and use it for a trial period of 15 days. After this period, users that continue to use it must register their copy by sending the registration fee to the author, Maurizio Giunti. The registered users will receive a "registration key" which contains their name (or their firm/organisation name for site-licenses). This software can be freely distributed at no cost, except for eventual copy and/or shipping expenses. It is imperative anyway that the ORIGINAL PACKET is distributed without any modification WHATSOEVER. There is an exception: you can distribute MPATCH.EXE, MPATCH2.EXE and/or MPATCHW.EXE with one or more *.MDF files produced with a REGISTERED copy of MDIFF. Moreover you can distribute any executable file produced by MDF2EXE.EXE, MDF2EXE2.EXE and MDF2EXEW.EXE which contains ONLY MDF patches built by a registered copy of MDIFF. About *.MDF patches the author of this program does not claim rights. 4.WHY? A few months ago I was updating a program of mine: since the compressed packet was about 200 Kbytes, I thought it was better to use a patch, but I could not find a program of my satisfaction among the patch makers/appliers. In addition I could not trace a program that could run under DOS and OS/2. I decided to make my own patch software and.....here it is ! 8-) 5.WHAT MDIFF-MPATCH DO? MDIFF creates a binary difference between two files. With MPATCH and the older file you can create a new file using the difference file. What is the advantage? Usually the difference file is smaller and therefore more suitable for distribution, especially by modem. 6.EXAMPLE As an example I put in two directories named OLD and NEW, respectively MDIFF.EXE release 1.45a (a work in progress alpha release) and MDIFF.EXE release 1.45: Directory of OLD\*.EXE MDIFF.EXE 46602 16/08/95 21.01 Directory of NEW\*.EXE MDIFF.EXE 46602 21/08/95 00.45 3 C:\>mdiff OLD\MDIFF.EXE NEW\MDIFF.EXE MDIFF V1.50 - MDF file generator (Dos) (C) Copyright 1995/96 Maurizio Giunti Registered to: MAURIZIO GIUNTI OLD\MDIFF.EXE,NEW\MDIFF.EXE => MDIFF.MDF Working...(100%) MDF size: 1215 bytes Rate: 2% Directory of *.MDF MDIFF.MDF 1215 7/10/95 13.43 Now, we can apply the patch named MDIFF.MDF to the old file to rebuild the new one: C:\>mpatch MDIFF.MDF old\MDIFF.EXE MPATCH V1.50 - MDF file applier (Dos) (C) Copyright 1995/96 Maurizio Giunti MDF file produced by: MAURIZIO GIUNTI Working: 0% |###########| 100% I obtain the following file: Directory of *.EXE MDIFF.EXE 46602 21/08/95 0.41 which is BINARY EQUAL to the new file. 7.DOS, OS/2, WINDOWS 95 AND WINDOWS NT I usually build MDIFF and MPATCH for Dos, OS/2 and Windows32 by compiling the same source, so there is NO difference between them. Moreover difference files produced with MDIFF for Dos can be used with MPATCH for OS/2 or Windows32 and viceversa. 8.LIMITS AND KNOWN BUGS MDIFF can't work on files greater than 16 Mbytes and it can't process files smaller than 20 times the current chunk length. Since its source is the same as Dos' MDIFF, OS/2's MDIFF can't manage Extended Attributes: it will ignore them. Moreover if you build a patch by MDIFF for Dos or OS/2, when applying it by MPATCH for Windows32 and viceversa if you build a patch by MDIFF for Windows32 and apply it by MPATCH for Dos or OS/2, you will obtain a wrong date and time on the new file. This bug depends from a different implementation of the utime() function in Borland and Microsoft compilers. 9.MDIFF - MDIFF2 - MDIFFW MDIFF compares 2 files and stores the differences between them in a difference file. This is the command line syntax: 4 MDIFF [-C] [-R] [-F] [-S] [-Z] [-P] [] is the name of the older file, is the name of the new file. If you wish you can specify the name of the difference file that MDIFF will produce, otherwise MDIFF will create a file with the name of the new file but with the extension ".MDF". To search differences between files, MDIFF uses a base string of defined length named Chunk. The Chunk length is by default 16 bytes, but you can change it, in the range 4-256, with the -C switch followed by the desired length. When MDIFF loses the synchronism between the two files being compared, it scans the older file searching the current chunk. This scansion is executed, by default, in a range of 8 blocks of 512 bytes each. You can change the number of the blocks scanned, in the range 1-16, with the -R switch followed by the desired number of blocks. If this search fails, MDIFF tries to force synchronisation through a large range search. This range is defined as 1/16 of the old file length, but you can change it by the -F switch on the command line. If you specify -S switch, MDIFF will provide some information about the composition of the difference file. Moreover you can add to the difference file produced a short comment (max. 2 Kbytes) to display when the patch is applied, with the -Z switch. MDIFF gets the comment from standard input, so you can type it directly or redirect it from a file with the "<" command. You can also protect the patch by a password using the -P switch followed by the password. Please notice that the password field is case sensitive. 10.MPATCH - MPATCH2 - MPATCHW With the old file and the .MDF file you can rebuild the new file by running MPATCH. This is the command line syntax: MPATCH [-P] [ []] MPATCH needs only the name of the MDF file () because it contains the names of the other 2 files, but it's possible to override these names specifying the desired names on the command line. MPATCH has only the -P switch by which you can specify a password. If there are errors during the patch applying, MPATCH returns an errorlevel as follows: 0 "OK!" 1 "Out of memory !" 2 "Can't open MDF file !" 3 "Invalid MDF file !" 4 "MDF file version mismatch !" 5 "UNREGISTERED !" 6 "Bad or incorrect OLD file !" 7 "Can't open OLD file !" 8 "Can't create NEW file !" 9 "General failure: NEW file corrupted !" 10 "OLD and NEW can't be the same file !" 11 "NEW file was already patched !" 12 "Wrong password !" 5 11.MDF2EXE - MDF2EXE2 - MDF2EXEW MDF2EXE is a simple utility which stores one or more (up to 127) MDF patch files created by MDIFF, to an executable (Dos, OS/2 or Windows32). This kind of executable is called self installing patch. MDF2EXE syntax is: MDF2EXE [....] Where can contain wildcards. The (which MUST have .EXE extension) will be executed without any parameters on the command line. It will automatically search the files to update. Eventually you can use a -P switch to specify a password or the -V or -L switches to list the patches stored in the file. Warning: don't compress a self installing patch by PKLite or LZexe or other similar compression/encryption tools. 12.SUGGESTIONS The best method to build a difference file, is to search the chunks of the new file in the entire older file, but this is a very slow way to do! MDIFF's algorithm tries to give a small diff file in a faster way; so you are sometimes required to tune the work parameters with the command line switches. Let's look at some typical situations: 1. Very similar files: use a large chunk (32, 64 or more) to reduce the size of the diff file, in particular if the files contain text or archives. 2. Text files: try to use a chunk size of 32, sometimes it is better to turn the forced sync off or reduce its range by the -F switch. 3. Very large executable: try to use a larger resync range (16 or more), with the -R switch. Remember: MDIFF can't make miracles! If the two files are really different, the patch will result very large. In this situation you must distribute the entire new file. MDIFF is useful only when the amount of changes is limited. 13.LIBRARIES TO APPLY PATCHES Included in this packet you will find a complete set of libraries to build your own programs to apply patches. These libraries CAN'T apply MDF patches built by an UNREGISTERED copy of MDIFF. This does not mean they are not fully functional. It means the libraries can only apply patches produced by a registered copy of MDiff. 14.REGISTERING MDIFF By registering MDIFF you will obtain a REGISTRATION KEY which contains your name (or your firm/organisation for site-licenses). When you produce a patch by a registered MDIFF, it will store your name in the patch. When MPATCH will install your patches it will display your name. Moreover any registered user has permission to freely distribute MPATCH.EXE, MPATCH2.EXE and MPATCHW.EXE with any MDF file prepared by the user. Any self-installing patches produced by the registered user can be freely distributed and used. No royalty or extra charge required! Included in MDIFF packet you will find a Windows registration program named REGISTER.EXE. Please run it on Windows environment. 6 REGISTER.EXE is a small Windows application written by Grzegorz (Greg) Kochaniak, which provides all info needed to purchase MDIFF and it allows you to send them directly to Kagi Shareware service by snail mail, e-mail or fax. If you do not use Windows please contact me. For any info about Kagi Shareware please read KAGI.TXT file. 15.HOW TO CONTACT THE AUTHOR For any problem or question you can contact me at the following addresses: snail mail: Maurizio Giunti Via G.B. Foggini, 24 50142 Firenze (FI) ITALY e-mail: Fidonet: 2:332/102.3 Internet: giunti@kagi.com giunti@abeline.it giunti@statsun.ds.unifi.it 16.ACKNOWLEDGEMENTS I'd like to thank all those who helped me to develop this software and its documentation and all those who helped me in beta-testing. In alphabetical order: Mauricio Mello de Andreade Andrea Baitelli Silvia Borri Juan Jose Comellas Filippo Dini Fabrizio Fioravanti Cristiano Guidoccio Giovanni Lopes Pegna Marco Maccaferri Marco Menichelli Giuseppe Scarpi Toni Tatafiore Duncan Wilcox 7