TEXT SEGMENT PUBLIC _my_entry_point EXTRN _pre_load:NEAR _my_entry_point PROC NEAR mov rax,QWORD PTR[rsp] ; fetch the return address sub rax,16 ; and rebias it back to the mov QWORD PTR[rsp],rax ; original entry point push r9 ; I don't know if system passes push r8 ; any arguments, so I save them push rdx ; just in case... push rcx sub rsp,40 ; allocate register parameter area mov rcx,rax ; NB!!! it's _pre_load that is call _pre_load ; reponsible for putting the add rsp,40 ; original machine code back!!! pop rcx pop rdx pop r8 pop r9 ret _my_entry_point ENDP TEXT ENDS