View Single Post
  #13  
Old 07-17-2018, 04:00
Avalon Avalon is offline
Friend
 
Join Date: Jul 2018
Posts: 7
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 1
Thanks Rcvd at 10 Times in 7 Posts
Avalon Reputation: 0
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
}

Last edited by Avalon; 07-17-2018 at 04:05.
Reply With Quote
The Following User Says Thank You to Avalon For This Useful Post:
niculaita (07-17-2018)