views:

401

answers:

7

Is there any way to disassemble my .dll file again into machine code? What applications do I need for this and how much could be recovered?

A: 

You won't be able to get more than assembly code, because Delphi is native unlike Java or .Net Languages, where you can get a whole bunch more of information.

HalloDu
It depends on the Delphi version. There's a Delphi .NET. Even for Win32, some of the old tools could extract resources (like forms) and restore them with everything but the code-behind.
TrueWill
Could anyone of you guys look into it and try helping me?
Microsoft has an article describing how you can Compile MSIL to Native Code. (http://msdn.microsoft.com/en-us/library/ht8ecch6(VS.71).aspx). You can use Ngen, or commercial tools. Java byte code can be compiled to native code too.
mjustin
This genius named Dmitriy Goldobin had a product called EXE2DPR that would recreate "all project forms and data modules with all assigned properties and events" (just without any code under the events). It was amazing, but the last version I know of only worked with Delphi 4 and below.
TrueWill
+1  A: 

have you googled "delphi decompiler"? this result looks promising, it lists several disassemblers and their features: http://delphi.about.com/od/devutilities/a/decompiling_3.htm

stmax
+1  A: 

You need a disassembler, like IDA Pro. They have a free edition too. You'll get back machine code (assembly), and you should be able to pick out the function calls made to the Windows API.

Mick
Okey, thanks for all answers :)Could you, or anyone help me with translating the whole thing so i could get my work back?
+5  A: 

Check PE File Explorer, this tool is amazing, is built with Delphi, and has special support for Delphi applications.

You can analyze, disassemble, edit the resources

PE Explorer is the most feature-packed program for inspecting the inner workings of your own software, and more importantly, third party Windows applications and libraries for which you do not have source code. Once you have selected the file you wish to examine, PE Explorer will analyze the file and display a summary of the PE header information, and all of the resources contained in the PE file. From here, the tool allows you to explore the specific elements within an executable file.

alt text

RRUZ
A: 

Okey, thanks for all answers :) Could anyone help me with translating the whole thing so i could get my work back

+1  A: 

If you lost the source file and you really only need to "get your work back", then you might as well start re-coding it because you're not going to get anything useful out of decompiler. I haven't been able to get anything re-compilable out of a decompiler since the days of Ms-DOS COM files (not to be confused with Windows COM!).

A modern file, written in an high level language, ran throw an optimizing compiler simply doesn't include everything that's needed to reconstruct the source code.

Examples, and it's just the top of the iceberg:

  • Delphi's optimizing linker will SKIP code that's not used. Ever noticed when you want to place an brakepoint on a line of code and when the program starts the brakepoint is ignored because the code has been optimized-out?
  • Delphi's optimizing compiler has the option of doing all sorts of things with your code:
    • It can inline procedures (so they're no longer where you wrote them, they're where the call is made).
    • It can unwind "for" loops (so where you had an "for i:=1 to 10 do something" you now have "something; something; something;...".
    • Local variables get optimized, addresses get reused.
  • Data structures are aligned to whatever the rule of the day is. So your one word + 1 byte structures might have 4 or 8 bytes in memory, not 3 as you might expect.
  • Code gets imported from other libraries. An DLL is not an DCU. A 3 lines DLL might actually import thousands of lines of code from those "uses" clauses.
Cosmin Prund
I have never seen the Delphi compiler unrolling a loop, and I doubt that it does. Could you post an example?
mghie
+1  A: 

Use DeDe to get more information about delphi app (form events and its code, form structure)

http://www.woodmann.com/collaborative/tools/index.php/DeDe

Bartosz Wójcik