Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have many options</p> <p><del>1) If your functions are small, you can make a macro that simply declares a function and adds function to an map of pointers to functions of your type (typedef your function)</p> <pre><code>int FunctionName() { //user code } map["FunctionName"] = FunctionName; </code></pre> <p><del> a macro that does that is not hard to write</del></p> <p> when you want to execute, simply select function function from map and call it </del> </p> <p>2) you your functions are larger you must consider a plugin system. Dlls that export a function. On "server" you can enum and load those dlls and exect requested function</p> <p>3) A nice version where be using a script engine that allows users to execute scrips on the server. You can achieve this my using <a href="http://msdn.microsoft.com/en-us/library/ky29ffxd%28v=vs.85%29.aspx" rel="nofollow">IActiveScript</a> or one of the many free script engines available.</p> <p><strong>Edit</strong>: </p> <p>4) One more possibility that came in my mind.</p> <ul> <li>Add your .c files to a dll project. </li> <li>Add __declspec( dllexport ) modifier to every function you wnat to add (eventually trough the macro) </li> <li>Enum exported function like this</li> </ul> <blockquote> <pre><code>void EnumDllFunctions() { BYTE *hMod = (BYTE*)GetModuleHandle("KERNEL32.DLL"); IMAGE_NT_HEADERS *pnt = (IMAGE_NT_HEADERS*)&amp;hMod[PIMAGE_DOS_HEADER(hMod)-&gt;e_lfanew]; IMAGE_EXPORT_DIRECTORY *exp = (IMAGE_EXPORT_DIRECTORY*)&amp;hMod[pnt-&gt;OptionalHeader.DataDirectory-&gt;VirtualAddress]; DWORD *dwFunctions = (DWORD*)&amp;hMod[exp-&gt;AddressOfNames]; for (DWORD ctr = 0; ctr &lt; exp-&gt;NumberOfNames; ctr++) { printf("%s\n", (char*)&amp;hMod[dwFunctions[ctr]]); } </code></pre> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload