Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
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)
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inline patche hp3 Source Code 3 06-04-2021 14:48
X64 inline asm Fyyre x64 OS 48 08-10-2014 16:50
Inline Patching MaRKuS-DJM General Discussion 1 01-24-2004 23:03


All times are GMT +8. The time now is 11:45.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )