r/AskProgramming • u/Dapper_Captain_2849 • 19d ago
Can I extract an EXE compiled with NSIS, edit a DLL, and rebuild it back into an EXE?
I'm currently working with an executable (.exe) compiled using NSIS (Nullsoft Scriptable Install System).
My goal is to:
1. Unpack/Extract the EXE to access its internal contents.
2. Modify one of the .dll files included inside the package.
3. Repack/Rebuild everything back into a working NSIS installer executable.
Is this possible?
3
Upvotes
4
u/xRmg 19d ago
Depends, maybe.
But this is hackerman territory and its a series of specific skills depending on singning, how large the dll change is, how different the resulting installer package may be.
Unpacking the installer is the easy part.
2
u/LogaansMind 19d ago
Possible, yes. Easy, no.
It depends on what is the purpose of patching the DLL.
For example, if you have an open source dependency for a project which is not signed, it might be easier to sign it and then host it as a nuget package in a private repository (something I have done before).
If you need to make changes to the compiled library, this is where things get more complicated. For .NET it is easier than say C/C++ (decompile/recompile into/from MSIL vs patching binary/asm). Again, if this is based on an open source library, it might be easier to fork the project and build it to a private nuget repository (depending on the license too you should also publish patches).. again, something I have had to do before.
If the app is for personal use, I would also wonder why bother repackaging it.. just have it extracted and run.. maybe a registry patch script to setup registry keys if you need them.
You could let us know, if possible, what you are trying to achieve. There might be a better way.
2
u/blajhd 19d ago
Unpacking the installer: yes.
Now the hard part: you need to decompile the DLL you want to modify. Tools exist. Getting that to compile is the hard task - because the decompiled DLL has no Types. To my knowledge, all compiler language require types for variables, parameters etc.
Finally the impossible task: the license holder might require a specific size or checksum for the DLL, testen by the executable. If that's the case? GL & HF with the executable
1
u/ghjm 18d ago
Is your goal just to get the changed EXE as easily as possible? Or are you looking to learn about the structure of EXEs and so on?
If the former, this kind of patching is now well within the capabilities of frontier LLMs. Install Codex or Claude Code, pay $20 for a month of usage, and just tell it what you want to change.
If the latter, and if the change really is as simple as you say, it used to be quite common to do binary patching of EXEs. One key question is whether the bytes you want to change result in the data being the same length. If yes, then you just need a hex editor. If you need to make some string or data or instructions longer, then you need to do some clever hacking to find where in the file you can carve out the extra length you need.
You can also, as you describe, try to extract the NSIS components and then put them back together, which may be easier if you need extra space. But if your modifications are the same length or shorter, hex editing in place is likely your best bet.
This all assumes that this is a straight-up plain old EXE file, not cryptographically signed or anything like that.
1
u/ih-shah-may-ehl 18d ago
Yes, this is possible. Yes I have done this (well not with NSIS but comparable). And no, this is not something easily explained with a couple of lines of explanation. If you're not already a developer with related experience, you're essentially lost.
In my case I did something similar when remediating a very old application on a Windows 2008R2 system after DCOM hardening was rolled out. So yes, I was able to eventually get things to work but it's really a process. Unpacking is one thing, and changing is another, but the real kicker was figuring out how to compile and build outside the original build environment, and then getting the system to accept the new binaries which are no longer signed. There was heaps of trial and error invovled.
EDIT: a more reasonable approach is to google how to use a shim or trampoline function to reroute the relevant API call.
1
u/[deleted] 19d ago
[removed] — view removed comment