DLL/EXE Decompiler

Louis the XIV

Sun King
Joined
Jun 23, 2020
Messages
838
Location
Court of Versailles
I have searched the internet, asked programmer friends but I have not gotten an answer that fully explained how to Decompile a DLL file or an EXE application.
I am unsure whether or not it's possible to decompile a DLL but I am still in hope that it is possible to decompile an EXE.
If you have any idea how to decompile an EXE or a DLL please let me know!
 
I haven't checked the EULA, but it's likely that doing so would be illegal, at least for the EXE. You might be able to argue that decompiling the DLL is okay, because its source code has been provided, but that raises the question why you want to do this when you already have its source code. Obviously IANAL.

Some jurisdictions allow decompiling if required for interoperability, so it might be alright to look into the EXE to see how it interfaces with the DLL. In general, I don't think it is worth it. You will never be able to magically recover the source code the EXE has been compiled from. That would be like decompiling a cake to find out how much yeast went into it.

Moderator Action: The forum rules prohibit discussion of intellectual property violations, so I have considered closing this thread. For the time being, an abstract discussion of the topic should be okay. An explicit discussion of how you would go about decompiling the EXE, or any advocacy for doing so, would be against the forum rules and will result in infractions and closing the thread.
 
AFAIK this is close to impossible without significant effort. Tools like Snowman or Hex-Rays Decompiler can generate C/C++-like code, but
a) the result will be very far from the original source code, think more like c-like assembly code than the readable code in the released DLL sources
b) due to the fact that a release DLL/EXE doesn't come with debug symbols, at best you would get function names like abcd123()
c) these tools are mainly for analysis of existing programs, so the generated code will obviously not compile. Though they could be useful for recovering the sources of small (by small I mean just a few lines of code) programs, but in Civ4 terms it's out of question.

If a DLL has a feature but doesn't provide its source code, it's far easier to code said feature yourself than to somehow try to suffer with decompilation/disassembly. Larger mods usually provide their source code unless if they precisely don't want you to use it, so it's not like you'd be saving that much effort with decompilation anyways.

For studying the behavior of the executable (for e.g. debugging mysterious crashes happening in the EXE) you are out of luck, remember to use version control so you can go back to the last version of your DLL that did work and figure out what displeased the EXE. I believe there are other, more sophisticated ways to debug such problems as well.

This goes for modifying the EXE too. With enough effort however it would certainly be possible to write a compatible EXE without the original source. Note that this would take lots of effort and time even for a skilled programmer (or a group of skilled programmers for that matter). Either way, even in that case, legally you're most likely better off avoiding any attempts to look at any implementation details; see e.g. the Wine project which forbids individuals who have seen Windows source code from contributing to avoid legal trouble.

(Regarding legality: I always thought reverse-engineering itself is legal (at least in the EU) so long as you do not redistribute the code (or reuse parts of it), and redistribution of the Civ4 executable in binary form would be an intellectual property violation as well. But I'm no lawyer either.)
 
I haven't checked the EULA, but it's likely that doing so would be illegal, at least for the EXE. You might be able to argue that decompiling the DLL is okay, because its source code has been provided, but that raises the question why you want to do this when you already have its source code. Obviously IANAL.

Some jurisdictions allow decompiling if required for interoperability, so it might be alright to look into the EXE to see how it interfaces with the DLL. In general, I don't think it is worth it. You will never be able to magically recover the source code the EXE has been compiled from. That would be like decompiling a cake to find out how much yeast went into it.
I want to decompile an exe because I am curious how it is written and because I want to fix some errors. Also I have found an app that decompiles EXE's though it misses some stuff when decompiling them and doesn't work all the time.
Anyway I am just very curious at how the code was wrought and also I am not planning on decompiling DLL's or EXE's of Copyrighted applications/games. I want to decompile the DLL of a hack from a game I play because it has some errors and I would like to fix them, I asked the creator if he could share the source code so I could try and fix it anyway.
Another question, does Visual Studio 2010 Express which I downloaded from Leoreth's Tutorial on how to compile a DLL allow compiliation of C and C#? Or only C++?
 
AFAIK this is close to impossible without significant effort. Tools like Snowman or Hex-Rays Decompiler can generate C/C++-like code, but
a) the result will be very far from the original source code, think more like c-like assembly code than the readable code in the released DLL sources
b) due to the fact that a release DLL/EXE doesn't come with debug symbols, at best you would get function names like abcd123()
c) these tools are mainly for analysis of existing programs, so the generated code will obviously not compile. Though they could be useful for recovering the sources of small (by small I mean just a few lines of code) programs, but in Civ4 terms it's out of question.

If a DLL has a feature but doesn't provide its source code, it's far easier to code said feature yourself than to somehow try to suffer with decompilation/disassembly. Larger mods usually provide their source code unless if they precisely don't want you to use it, so it's not like you'd be saving that much effort with decompilation anyways.

For studying the behavior of the executable (for e.g. debugging mysterious crashes happening in the EXE) you are out of luck, remember to use version control so you can go back to the last version of your DLL that did work and figure out what displeased the EXE. I believe there are other, more sophisticated ways to debug such problems as well.
Does the EXE contain C or C++ or other kind of files? Or only a file specifying the path to the DLL or simply just the DLL?
 
Does the EXE contain C or C++ or other kind of files? Or only a file specifying the path to the DLL or simply just the DLL?

No, an executable file contains executable machine code instructions. Though it can theoretically contain any kinds of files in binary format, but it would make no sense to include C or C++ source code in an exe, since unlike Python (an interpreted language) languages like C++ (compiled languages) were specifically designed for generating native machine code.
 
I want to decompile an exe because I am curious how it is written and because I want to fix some errors. Also I have found an app that decompiles EXE's though it misses some stuff when decompiling them and doesn't work all the time.
So we are not talking about the Civ4 EXE here? It seems like you are under the impression that decompiling is the inverse operation of compiling, and will give you the source code as written by the original author. That is not the case. As bluepotato mentions, C++ is a compiled language that creates native machine code. At best, a decompiler can give you some approximate source code that would produce the same machine code. Unless the compiled code comes with additional information, even function and variable names, packages, arrangement of code in the file, the file structure itself, would be essentially random and in effect often entirely unusable. Since including this additional information requires additional space, negatively impacts performance, and in fact makes it easier for a pirate to reverse engineer the software, it is never included in a shipped product. Reverse engineering a compiled executable is a very difficult task that even a dedicated team of specialists usually only has limited success with it. Essentially the entire digital economy relies on this fact.

In turn, this is why commercial products are closed source, and why making the source code publically available is considered good form for software that is freely shared.

Anyway I am just very curious at how the code was wrought and also I am not planning on decompiling DLL's or EXE's of Copyrighted applications/games. I want to decompile the DLL of a hack from a game I play because it has some errors and I would like to fix them, I asked the creator if he could share the source code so I could try and fix it anyway.
That seems like a much more promising avenue to pursue.

Another question, does Visual Studio 2010 Express which I downloaded from Leoreth's Tutorial on how to compile a DLL allow compiliation of C and C#? Or only C++?
Pretty sure it can, at the very least there are Visual Studio editions for either of these languages. I would not recommend using VS2010 for anything but Civ4 modding, which is only chosen here because it comes with some DLLs required for compiling that are not included in newer versions (in fact, you can use a modern version like VS2019 just fine as long as VS2010 is also installed).

There is no reason to tie yourself to a decade old IDE for any other project.
 
May it be possible to gain more control over the Great Wall's drawing? Like having two or more versions of the Great Wall with different graphics? AFAIK it is impossible at the moment because of the EXE.
 
It's impossible to change or recompile the exe. And also illegal.
 
It's impossible to change or recompile the exe. And also illegal.
I understand that and sorry if I wasn't clear enough. I meant that by understanding the exe better maybe there could be a workaround for the GW.
But I am very much a noon in this regard. My curiosity is bigger than my understanding :crazyeye:
 
Sorry for being curt, but the great wall art is hardcoded in the exe so to change it you would have to recompile the exe. You can change what the wall segments look like but the fundamental rules of where and how it pops up are unchangeable.
 
Back
Top Bottom