In my upcoming assignment (the one that made me canceled my leave), I was asked to "verify" that a set of assemblies are indeed the compiled product of a set of source codes. *Gee! I'm a walking assembler or what?*
Anyway, here's how it can be done. You will need two tools - fc.exe (to diff files) and ildasm.exe (to disassemble a .NET assembly). You will also need the original source codes.
First, compile the source codes to produce the assembly (.dll or .exe). We will call this our source assembly. The target assembly will be the one already present. Next, use ildasm.exe to disassemble both assemblies and output the result to a file. Example:
ildasm /out=source.txt c:\source\MyAssembly.exe
ildasm /out=target.txt c:\target\MyAssembly.exe
To compare both files, use the fc.exe tool. Example:
fc source.txt target.txt
In the event where both assemblies are indeed produced by the same source codes, the comparison result will only show a minor difference on a comment line. It will be something like:
***** source.txt
.corflags 0x00000001 // ILONLY
// Image base: 0x00250000
***** target.txt
.corflags 0x00000001 // ILONLY
// Image base: 0x009F0000
Take note that the base address will be different on your machine. If no other changes are reported, then it is quite likely that both assemblies come from the same source code.
To compare the differences (i.e line-by-line) at a programming language level, I recommend Reflector and the Reflector.Diff add-in.
Why Not Do A Binary Comparison?
The fc.exe tool has a /b flag to perform binary comparisons. The reason why this will not work is because .NET assemblies are always different whenever they are being recompiled. Therefore, while a binary comparison on an assembly that was originally produced by the same compilation would yield no differences, a binary comparison on an assembly that was compiled on different compilations will reveal differences.
I would like to thank Tom Hollander for bringing up the disassemble and compare idea.
Popular Post
-
I am not really a big fan of Jackie Chan and usually don't keep-up with his movies because I find his kung-fu techniques too comical. ...
-
I was playing with a VM on my Windows Server 2012 and without me knowing it, the .vhdx file has grew to over 40 GB of hard disk space. I che...
-
I've been promoting a lot on Paladin lately. A check on the download counter today shows 88 downloads for release 0.8.7. That's the...
-
S tumbled on the following while I was reading up on Unified Dimensional Model (UDM) One UDM to rule them all, One UDM to find them, One UDM...
-
I found out something interesting. When dealing with Spatial data, SQL Server Management Studio will provide us with a tab that looks like t...
-
While working on a new ASP.NET MVC layer sample with SignalR, I have constantly encountered the following error when I tried to access the ...
-
Yikes! I'm really far behind in my academy classes on C# 2.0 :(. Tried to read the chapter on Generics today and boy, was I blur wit...
-
No technical specification available (click images for a larger view)
-
Recently, I have been relooking into my Paladin framework as I hope to incorporate some SOA concepts into it. So far, I have built Paladin ...
-
My course leader had given the green light to go ahead with Oracle 10g for this semester. So, I made a trip to MPH Subang Parade (my favour...
No comments:
Post a Comment