Problems with my small code
Jun 12, 2012 at 6:44am UTC
Hello all, well, I have problems with my small code, please check it:
I'm making a small call api, with GetModuleHanlde and getprocaddress, but in the end of the function, I give a error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <Windows.h>
char Kernel[] = "KERNEL32" ;
void CallAPI(DWORD Mod,char * APIName, DWORD nParam,...)
{
va_list listaArgs;
PVOID* args;
DWORD Ret;
HMODULE hMod = NULL;
LONG hProc = NULL;
hMod = GetModuleHandleA(Kernel);
hProc = (LONG) GetProcAddress(hMod,APIName);
va_start(listaArgs, nParam);
args = &va_arg(listaArgs, void *);
for (int n = nParam - 1; n >= 0; n--)
{
PVOID temp = args[n];
__asm push [temp]
}
va_end(listaArgs);
__asm call hProc
//return Ret;
}
int main()
{
DWORD myRet;
CallAPI(1,"Sleep" ,2,400,400);
return 0;
}
could someone help me? thanks in advanced :D
Jun 12, 2012 at 11:31pm UTC
That looks interesting, and very error prone..
Sleep()
takes one argument, not two.
1 2
CallAPI(1,"Sleep" ,2,400,400);
CallAPI(1,"Sleep" ,1,400);
Jun 13, 2012 at 7:33am UTC
yeah,my bad, thanks a lot bro!
Topic archived. No new replies allowed.