It is very similar to the previous case with just one small inconvenience. Because 64-bits version of MS C/C++ compiler doesn’t support inline assembly, all tricks should be done in a separate .asm file. Below there are definitions of X86_Start and X86_End macros for MASM64:
X86_Start MACRO
LOCAL xx, rt call $+5
xx equ $ mov dword ptr [rsp + 4], 23h add dword ptr [rsp], rt - xx retf
rt:ENDMX86_End MACRO
db 6Ah, 33h ; push 33h
db 0E8h, 0, 0, 0, 0 ; call $+5
db 83h, 4, 24h, 5 ; add dword ptr [esp], 5
db 0CBh ; retfENDM