[SECTION .text]
Spoof:
    pop    r11
    add    rsp, 8
    mov    rax, [rsp + 24]
    mov    r10, [rax]
    mov    [rsp], r10
    mov    r10, [rax + 8]
    mov    [rax + 8], r11
    mov    [rax + 16], rbx
    lea    rbx, [fixup]
    mov    [rax], rbx
    mov    rbx, rax
    jmp    r10

fixup:
    sub    rsp, 16
    mov    rcx, rbx
    mov    rbx, [rcx + 16]
    jmp    QWORD [rcx + 8]
PVOID SpoofRetAddr( PVOID Function, HANDLE Module, ULONG Size, PVOID a, PVOID b, PVOID c, PVOID d, PVOID e, PVOID f, PVOID g, PVOID h )
{
    PVOID Trampoline = NULL;

    if ( Function != NULL )
    {
        Trampoline = FindGadget( Module, Size );
        if ( Trampoline != NULL )
        {
            PRM param = { Trampoline, Function };
            return ( ( PVOID( * ) ( PVOID, PVOID, PVOID, PVOID, PPRM, PVOID, PVOID, PVOID, PVOID, PVOID ) ) ( ( PVOID ) Spoof ) ) ( a, b, c, d, &param, NULL, e, f, g, h );
        }
    }

    return NULL;
}