Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly testing a function that is a part of a big DLL project

I use VS2010 for C++ development, and I often end up doing work in some dll project and after everything compiles nicely I would like to try to run dummy data on some classes, but ofc the fact that it is a dll and not an exe with main makes that a no go. So is there a simple way to do what I want, or Im cursed till eternity to c/p parts of a big project into small testing one? Ofc changing the type of the project also works, but I would like to have some almost like iteractive shell way of testing functions.

like image 424
NoSenseEtAl Avatar asked Dec 15 '22 23:12

NoSenseEtAl


1 Answers

I know this isn't a library or anything, but if you want to run the dll on windows simply without framing it into anything, or writing a script, you can use rundll32.exe within windows. It allows you to run any of the exported functions in the dll. The syntax should be similiar to:

rundll32.exe PathAndNameofDll,exportedFunctionName [ArgsToTheExportedFunction]

http://best-windows.vlaurie.com/rundll32.html -- is a good simple still relevant tutorial on how to use this binary. Its got some cool tricks in there that may surprise you.

If you are wondering about a 64-bit version, it has the same name (seriously microsoft?) check it out here: rundll32.exe equivalent for 64-bit DLLs

Furthermore, if you wanted to go low level, you could in theory utilize OllyDbg which comes with a DLL loader for running DLL's you want to debug (in assembly), which you can do the same type of stuff in (call exported functions and pass args) but the debugger is more for reverse engineering than code debugging.

like image 55
Ryan Avatar answered Apr 02 '23 05:04

Ryan