Solved

Make a patcher program.

Posted on 2000-03-11
13
185 Views
Last Modified: 2012-05-04
How to make a patcher program,please?
I need it to compare two Exe Files,then find out the differences between them,then patch the object file to the source file. And need it can create a exe file to patch automatically.

Two functions must in the program:
1.Patch a exe file.
2.Create a exe file, the file can patch the object file automatically.

Thanks!!
0
Comment
Question by:prefix
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2607647
I find that it's just easier to patch by replacing the EXE with a new EXE...  Do you have a specific reason for wanting to patch the EXE directly??


Cheers!®©
0
 
LVL 1

Expert Comment

by:jonder
ID: 2607745
The best way to do this is during the initial programming stages is to create your forms but instead of placing the code with the forms you create classes for each of the forms with the code inside. When you have completed your form, build the class into a DLL.

When you have an update you simply replace the DLL. *This will only work if you change coding not the Form it self. But with no code in the forms other than the Class Calls it make the EXE very small and flexible. If you do change a form for any reason you would submit the changed EXE and if any coding you submit the DLL. I have found it makes updates very easy for myself and my clients..

As for File Dates and so forth play with the following example.

    Dim fso As New FileSystemObject, FileDef As File
    Set FileDef = fso.GetFile("c:\tmp.txt")  '<--- Your file
    Debug.Print FileDef.DateLastModified
    ' FileDef has a more options to use


0
 
LVL 6

Expert Comment

by:andyclap
ID: 2608641
Although I use jonder's technique myself, pathcher programs are available if you have a search around. It's a lot less effor than writing one yourself.
Check out http://www.funduc.com/pamain1.htm
for just one example.
0
 
LVL 6

Expert Comment

by:andyclap
ID: 2608666
another one .... a bit better I think.
http://www.clickteam.com/web/pm/about_cadre.htm
0
 
LVL 6

Expert Comment

by:andyclap
ID: 2608673
just a note: neither of these two seem to really 'patch' the original file - they just replace it, albeit compressed, with a nice setup program.
I'd be interested too if anybody finds a patcher program which does a proper patch, ie just replace the changed bytes within the original. I'd love to be able to patch my setup.cab file to save my client downloading 2MBs worth.
0
 
LVL 1

Author Comment

by:prefix
ID: 2608737
mcrider:
the reason is: sometimes I need to write a program that some functions are not available before somebody register it,after registering, I can patch the EXE to a full version. And there's only a little diference between the two version. Replacing an EXE with a new one I don't think it's OK if the new EXE if too big.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Accepted Solution

by:
mcrider earned 15 total points
ID: 2608932
The way alot of people handle this is that the complete code for the program is already in the program and when they call a function, they do it like this:


   Function MyFunction() As Boolean
      If Registered = "YEP!" Then
         'This program is registered
         'Do whatever and return TRUE
         MyFunction = True
      Else
         'Program is not registered
         'Do whatever and return FALSE
         MyDunction = False
      End If
   End Function


Then, define a constant like this:

   Const Registered = "NOP!"

Compile your program and take a look at it using something like "QuickView Plus" in hex... when you do you will see something like this:

========================================================================================================================
000810  28 14 40 00 00 00 00 00-A0 C4 5D 00 FF FF 00 00  (¶@     á-] __
000820  83 80 01 00 00 00 00 00-46 6F 72 6D 31 00 00 00  âÇ     Form1
000830  50 72 6F 6A 65 63 74 31-00 00 00 00 08 00 00 00  Project1    
000840  4E 00 4F 00 50 00 21 00-00 00 00 00 32 A4 2E 52  N O P !     2ñ.R
000850  87 1D 63 4E 92 3E B8 50-E8 12 F6 F8 3B 72 F3 27  çcNÆ>+P_÷°;r_'
========================================================================================================================

Notice that at offset x840 (2112 decimal) you see the bytes 4E 00 4F 00 50 00 21 00

To get the program to run as registered, you would open the EXE file in binary and change those bytes to 59 00 45 00 50 00 21

The offset of this buffer will vary depending on where it gets compiled into your program, but I think you get the idea....



Cheers!®©


0
 
LVL 1

Author Comment

by:prefix
ID: 2609181
mcrider:
I need a source program to do that, give me a example? I know I can do like you said, but I don't know how to implement.
Come on...OK?
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2611228
Here you go... In the above example, we used a hex dumping program like "Quick View Plus" to find the "NOP!" definition at offset hex 000840.  You would manually locate this string in your program, and then set the "PatchOffset" constant below.  in the example, I am using the hex 840. This will patch  the "YEP!" string over the "NOP!" string...

    Const PatchOffset = &H840
    Dim fNum As Long
    Dim FileName As String
   
    fNum = FreeFile
    FileName = "c:\windows\desktop\testfile.exe"
    Open FileName For Binary As #fNum
    Seek #fNum, PatchOffset + 1
    Put #fNum, , Chr$(&H59)
    Put #fNum, , Chr$(&H0)
    Put #fNum, , Chr$(&H45)
    Put #fNum, , Chr$(&H0)
    Put #fNum, , Chr$(&H50)
    Put #fNum, , Chr$(&H0)
    Put #fNum, , Chr$(&H21)
    Close fNum



Cheers!®©
0
 
LVL 1

Author Comment

by:prefix
ID: 2612061
Yes,great!
But I don't why must "Put #fNum, , Chr$(&H0)" and "Put #fNum, , Chr$(&H21)". What are their meaning?




Cheers!
   
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2612149
Well, you don't have to do the last two... the &H21 is the exclamation point (!) on "YEP!"

Thanks for the points...


Cheers!®©
0
 
LVL 1

Author Comment

by:prefix
ID: 2612202
But the &H0? Why to put it?
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2612247
In the EXE, "NOP!" is actually stored like this:

4E 00 4F 00 50 00 21
 N     O     P     !    



Cheers!®©
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now