You need to define a function with a very specific signature so that it can be called by rundll32. See this blog post for information on how and why you might fail.
Also, take a look at this answer to a similar question, which details the function signature.
Essentially, for your function to be safe to call, you would need to define it something like:
void CALLBACK MyEntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR pszCmdLine, int nCmdShow);
or
void CALLBACK MyEntryPointW(HWND hwnd, HINSTANCE hinst, LPWSTR pszCmdLine, int nCmdShow);
Everything else will ruin the stack and may (or may not) cause a crash. I think that in later versions of Windows, rundll will first look for the MyEntryPointW function, and if a call is found, the difference is in the Unicode parameter pszCmdLine .
For more information on how to use rundll32 , see the MSDN , which details what to expect from each parameter, etc.
source share