How exactly does RunDll32 call a function, without knowing the number/types of arguments that the function can take?
Does it have a built-in compiler or something of the sort?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
RunDll32 is pretty much a thin wrapper that calls
LoadLibraryto load the given DLL, callsGetProcAddressto get the function address of the desired function, and then calls the function.It can’t call just any exported function in the DLL, though—it assumes that the function has a very specific function signature of the following:
where
CALLBACKis a macro that expands to the__stdcallcalling convention. See this knowledge base article for a more detailed description.If your DLL’s function does not have the correct signature or calling convention, lots of badness will ensue. See What can go wrong when you mismatch the calling convention? for lots of gory details. Fortunately (or perhaps unfortunately), RunDll32 is written in such a way to ameliorate those types of errors, but that still doesn’t mean it’s a good idea. Do not use RunDll32 to call functions that do not have the correct signature. It’s just a ticking time bomb waiting to go off in the next version of Windows.