Just create a .ASM file, change the build rule to MASM, define the subroutine and call it from the C file.
masm.asm
Quote:
.CODE
PUBLIC MyAsmRoutine
PUBLIC ChangeRaxRoutine
MyAsmRoutine PROC
push rbp
mov rbp, rsp
call qword ptr [rcx]
mov rsp, rbp
pop rbp
ret
MyAsmRoutine ENDP
ChangeRaxRoutine PROC
mov rax, 0x4141
ChangeRcxRoutine ENDP
END
|
file.c
Quote:
void MyAsmRoutine(PVOID pFunc);
void __declspec(naked) ChangeRaxRoutine();
int main()
{
PVOID pNtDirectCall = ....
MyAsmRoutine(pNtDirectCall);
ChangeRaxRoutine();
//now your program will return 0x4141 as RAX is the return code
}
|