patchdiff2-like lib for usage in a script/CLI menu

User Tag List

Results 1 to 6 of 6
  1. #1
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    patchdiff2-like lib for usage in a script/CLI

    Hi,

    some time ago, I took the step from hardcoded offsets to describing them in terms of pattern matches.
    This works quite well, but it still sucks having to update a broken pattern every ~3 patches, so I came up with the idea of inventing a binary regex-like pattern matcher.
    I don't know how well this works, but I suspect it breaks when instructions are reordered. So I did some quick google to find an equivalent to patchdiff2 as a standalone script.
    I was hardly successful, I could only with DarunGrim: A Patch Analysis and Binary Diffing Tool .

    Has anyone of you experience with this kind of offset automation?

    patchdiff2-like lib for usage in a script/CLI
  2. #2
    Empted's Avatar Contributor
    Reputation
    83
    Join Date
    Aug 2011
    Posts
    117
    Thanks G/R
    0/5
    Trade Feedback
    2 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have nearly same idea to avoid any hardcoded function offsets. Currently trying to make some function signatures that are based on assembly analys. Like conditional jump count, hardcoded constants, number of calls, returns, type of params and so on. This should end up in more robust offset finding, but still with some global changes even this kind of searching will fail. But implementing something like match measure, can probably solve this. The process will not be completely autonomic, but with some kind of choosing the function that fits good under the signature.
    P.S. the idea was born to match functions from MAC binaries with the PC versions, but it's double that hard because of different assembly styles and params passing and so on.

  3. #3
    boredevil's Avatar Active Member
    Reputation
    46
    Join Date
    Feb 2008
    Posts
    166
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Empted View Post
    Have nearly same idea to avoid any hardcoded function offsets. Currently trying to make some function signatures that are based on assembly analys. Like conditional jump count, hardcoded constants, number of calls, returns, type of params and so on. This should end up in more robust offset finding, but still with some global changes even this kind of searching will fail. But implementing something like match measure, can probably solve this. The process will not be completely autonomic, but with some kind of choosing the function that fits good under the signature.
    P.S. the idea was born to match functions from MAC binaries with the PC versions, but it's double that hard because of different assembly styles and params passing and so on.
    This sounds promising for finding correspondences between mac and PC binaries of the same version, but consider for example Spell_C_Failed, which got an additional parameter since the last patch. Although this would be much more reliable than simple pattern matching.

    Originally Posted by boredevil View Post
    Awesome reads on that topic. I was pondering in the same direction as the blog post, although the techniques mentioned might not be generic enough to diff between patches.
    We don't need exact matches, rather some way to wildcard instructions.
    Perhaps one could intermingle it with some nondeterminism/optional nodes.

    Meanwhile I am reconsidering pattern matching, but with a more nondeterministic notion, perhaps with a tree/graph structure, to model data flows. E.g.:
    Code:
    useeax = seq("mov eax, <x>", "mov eax, [eax+<y>]")
    useebx = seq("mov ebx, <x>", "call [ebx]")
    res = seq(all(useeax, useebx), "add eax 5")
    Where the instructions are replaced with their respective byte patterns.
    seq requires the matches to be in sequential order, with 0..n bytes inbetween. I figure there might be other matchers like seq_strict(...), any(...), all(...), many(m) [1..n], opt(m) [0..1].
    "ab d9" is actually shorthand for seq_strict(0xab, 0xd9). I wonder if this can be realized sufficiently efficient.

    Edit: I'm baffled. asmDiff works really well on Spell_C_Failed. I'll try some other samples and then probably look into I could leverage that.
    Last edited by Bananenbrot; 03-08-2013 at 06:50 AM.

  5. #5
    Lecht's Avatar Member
    Reputation
    15
    Join Date
    Sep 2009
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've actually been researching this a bit myself. I have written a tool I'm calling ZDiff in C#, it uses BeaEngine to analyze two exes. The first pass it analyzes instructions and saves their locations for easy traversal later on while also caching cross references and the start addresses of potential procedures, on the second pass it tries to determine the end of those procedures.

    It works fairly well so far, I'm wanting to evolve it into a patchdiff tool. It's not perfect as of yet (and may never be), but it finds the addresses without any pre-written patterns, just give it the addresses and go heh. I hope to get a chance to fine tune it to add some more robust methods to finding new addresses. For instance block comparison like patchdiff.

    Takes about 3 minutes to analyze an exe, can analyze multiple at a time.
    Last edited by Lecht; 03-08-2013 at 08:26 AM. Reason: Will upload pictures later.

  6. #6
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm currently reversing mmBBQ, which is a host for asmDIFF along with other cool inject-in-lua functionality, which I don't plan to use. Sadly asmDIFF is closed source.
    I don't know if you are comfortable to upload your work to GitHub or BitBucket, but in case you are, I would be willing to contribute.

Similar Threads

  1. Need a Coder for a Few Quick Scripts
    By HellgFails in forum Programming
    Replies: 2
    Last Post: 02-19-2009, 05:42 PM
  2. World editor like noggit for 3.0.3 ?
    By Wheeze201 in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 01-24-2009, 09:30 AM
  3. Looking for a new register script for mangos new core
    By slameys in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 11-14-2008, 10:05 AM
  4. Wiimote like controller for World of Warcraft
    By niagairt in forum World of Warcraft General
    Replies: 4
    Last Post: 07-10-2008, 11:40 PM
  5. [Questions] Couple Of Questions Id Like Answers For
    By Performer in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 12-31-2007, 08:46 AM
All times are GMT -5. The time now is 04:01 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search