0

I need to append a certain check to an existing exe I don't have the sourcecode of. The existing exe calls a certain DLL. The program may only be started when the calculated CRC matches that of a known good DLL. If the CRC does not match a message needs to be displayed.

Let's assume I am able to write a short exe that does the check. Is it possible to "concatenate" these two exe and only execute the second exe when the first confirms the correctness of the dll ?

Marged
  • 10,577
  • 10
  • 57
  • 99
FcbInfo
  • 83
  • 1
  • 7
  • 1
    You can do this if load your file.dll dynamically within your program. Check this link: http://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll – Anon Mail Nov 05 '15 at 17:05
  • Thank you for try to help, but I need to find a toll of that I can insert in my exe. I don't have sources of these files. I just have exe and dll. I wants that exe check crc of dll, and not open if dll crc check fail. – FcbInfo Nov 05 '15 at 17:09
  • I'm not a Windows expert but I'm pretty sure you can do that. The loading of the DLLs is done by the Windows loader which starts the exe. Perhaps if you tell us the reason you want to do this? Windows experts can then chime in with solutions that may solve your need. – Anon Mail Nov 05 '15 at 17:12
  • I have an old program (of that I don't have more support, company stop to work with this), that exe file, connect to my server and my server check the version of this exe, if not match, the server reply with "fail connection", this exe file, use another dll file of that some customers have changed this dll code and able to do bad actions on my server. If i make this exe file to check dll crc, they will not be able to open exe and maybe ill have my problem solved. – FcbInfo Nov 05 '15 at 17:17
  • If you know where the file is, you can calculate the crc 32 with [this](https://github.com/damieng/DamienGKit/blob/master/CSharp/DamienG.Library/Security/Cryptography/Crc32.cs) – Oguz Ozgul Nov 05 '15 at 17:22
  • As I see, I'm not wrong when I try to search. A ready to use "plug in play" program to do it, doesn't exist. – FcbInfo Nov 05 '15 at 17:47
  • of course it doesnt. You will need to write your own application which starts before your current one. Its quite easy to calculate the CRC of a DLL and either start a new process or show a message ... thats basic programming right there – specializt Nov 05 '15 at 19:32

1 Answers1

0

I did similar things with a readymade program that may only be started when some criteria is met. In my case this is the membership in a certain Active Directory group but the same approach can be applied to your problem.

Rename the existing exe (I will name it so) to ensure it can not be run directly:

ren existing.exe existing.ldr

The dll stays like it was before:

file.dll

Now create your own exe and name it existing.exe, effectively replacing the previous exe. This exe has to do several things:

  • contain the crc of a valid file.dll as a constant
  • calculate the crc of the dll which can be found in its working directory
  • execute existing.ldr when the crc matches
  • output an informational message when the crc matches and exit the program
Marged
  • 10,577
  • 10
  • 57
  • 99