views:

77

answers:

2

Hi all

I have a application (win32 exe file) without source code.

Is it possible I write C# application and reuse some function in that win32 .exe file?

Thanks for your reading.

Best regards!

+2  A: 

You can run

dumpbin.exe /exports [your-win32.exe]

and see what functions it exports. Then you can use (whatever is the C# equivalent of) LoadLibrary() and GetProcAddress() to call those functions.

Of course, you need to know the signatures of those functions in order to call them correctly; i.e. number and order of parameters, etc.

jeffamaphone
Executables rarely export anything.
PiotrLegnica
Of course, if the exe does *not* export any functions or it only exports functions you don't need, you're out of luck. (I know you know this but others might not)
Mark Rushakoff
+1  A: 

Don't know if this is what you're looking for, but if the other exe has a GUI, you can probably do some stuff by sending messages to it. Just run Spy++, do whatever you want with the other app, and watch the log when done. If no special controls are used, you can operate that GUI by getting the handles of the controls you want, and sending them the appropriate messages. If you don't want the user to know you're running the other app, you can run it on a different desktop.

Another option you can exploit is running your own thread inside the other exe's process, and communicating back to your app in one of the various IPC techniques available. Many questions have been asked here about remote thread injection, so just look around for it.

Lastly, if you're lucky the functionality you need is actually on one of the DLLs used by the exe, either as exported functions or as a COM interface. Take a look at run time using Process Explorer or so, and see if any of the modules looks interesting. As far as it goes to using other modules, DLLs are obviously much easier.

eran