I have some C code and I want to port it to c++, the problem is that in C++ I can’t use an assembly function due to it’s dynamic use
C version
extern asmFunc(); // C function prototype version
//actual use example
asmFunc(var1,ptr2,HANDLE);
asmFunc(ptr4,var2,NULL,eg ...); //everything works
C++ version
extern "C" VOID asmFunc(); // C++ function prototype version
//actual use example
asmFunc(var1,ptr2,HANDLE); // E0140 too many arguments in function call
asmFunc(ptr4,var2,NULL,eg ...); // E0140 too many arguments in function call
The Assembly function is declared in a separate asm file and it uses direct syscalls from ntdll.dll’s functions, that’s why it requires dynamic arguments
How to make it work?
>Solution :
Use ... in the argument list to specify the function is a variadic function taking unspecified arguments, eg:
extern "C" VOID asmFunc(...); // C++ function prototype version
//actual use example
asmFUNC(var1,ptr2,HANDLE);
asmFUNC(ptr4,var2,NULL,eg);