Calling DLL from assembler code?
-
Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld
-
Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld
-
Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld
-
Hi, My problem is that I have to write a function that will at runtime accept a name of a dll and a name of a function contained in that dll and then call that function. The obvious problem is that a compile time we don't know the return type of a function be be called and the number and types of arguments to be passed to the dll. My guess is that we'd have to use assembler code in __asm blocks to pass any number of parameters of any types by manually pushing them into the stack. But then of what type do I declare the function pointer that will take the adress of function returned by GetProcAddress? Any Answers/Suggestions? Thanks in advance, Mvworld
Don't even bother making it a function pointer, just take and use it as void *. void *foo; int retval; foo = GetProcAddress (...); //push the things on to the stack here __asm { call foo mov retval, eax } You'll have to decide how to interpret the return value, of course. Also don't forget to push the things onto the stack in reverse order.