xref: /reactos/sdk/lib/runtmchk/i386/_RTC_CheckEsp.S (revision 8a978a17)
1/*
2 * PROJECT:         MSVC runtime check support library
3 * LICENSE:         BSD - See COPYING.ARM in the top level directory
4 * PURPOSE:         Provides support functions for MSVC runtime checks
5 * PROGRAMMER:      Timo Kreuzer (timo.kreuzer@reactos.org)
6 */
7
8#include <asm.inc>
9.code
10
11EXTERN __RTC_Failure:PROC
12
13/*
14
15    This function is invoked like this:
16
17        mov esi, esp
18        // Do the actual function call
19        cmp esp, esi
20        call __RTC_CheckEsp
21
22    http://stackoverflow.com/questions/3914750/hows-rtc-checkesp-implemented
23*/
24PUBLIC __RTC_CheckEsp
25__RTC_CheckEsp:
26
27    /* We check if the zero flag is set, and if it is, everything is fine
28       and we return to the caller */
29    je __RTC_CheckEsp_return
30
31    push ebp
32    mov ebp, esp
33    pusha
34
35    // void _RTC_Failure(void* retaddr, int errnum);
36    push 0 // errnum
37    push dword ptr [esp + 4] // retaddr
38    call __RTC_Failure
39    add esp, 8
40
41    popa
42    pop ebp
43
44__RTC_CheckEsp_return:
45    ret
46
47END
48
49
50