summaryrefslogtreecommitdiffstats
path: root/private/crt32/misc/i386/sehsupp.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/misc/i386/sehsupp.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/misc/i386/sehsupp.c')
-rw-r--r--private/crt32/misc/i386/sehsupp.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/private/crt32/misc/i386/sehsupp.c b/private/crt32/misc/i386/sehsupp.c
new file mode 100644
index 000000000..1dbce51bb
--- /dev/null
+++ b/private/crt32/misc/i386/sehsupp.c
@@ -0,0 +1,59 @@
+/***
+*sehsupp.c - helper functions for Structured Exception Handling support
+*
+* Copyright (C) 1993, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Contains _rt_probe_read. Helper for the SEH runtime support
+* routines (longjmp in particular). Much of the SEH code is written
+* in asm, so these routines are available when probing memory in ways
+* that must be guarded with __try/__except in case of access violation.
+*
+*Revision History:
+* 12-05-93 PML Module created.
+* 12-22-93 GJF Made #define WIN32_LEAN_AND_MEAN conditional.
+* 01-12-94 PML Rewritten - still need helpers, just different ones
+*
+*******************************************************************************/
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+
+#include <windows.h>
+
+/***
+*BOOL __stdcall _rt_probe_read4 - Check if a DWORD is readable
+*
+*Purpose:
+* Internal support function called by longjmp. Check if a DWORD is
+* readable under a __try/__except.
+*
+*Entry:
+* DWORD * p - Pointer to DWORD to be probed
+*
+*Exit:
+* Success: TRUE - Able to read
+* Failure: FALSE - Access violation while reading
+*
+******************************************************************************/
+
+BOOL __stdcall _rt_probe_read4(
+ DWORD * ptr)
+{
+ BOOL readable;
+
+ __try
+ {
+ *(volatile DWORD *)ptr;
+ readable = TRUE;
+ }
+ __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION
+ ? EXCEPTION_EXECUTE_HANDLER
+ : EXCEPTION_CONTINUE_SEARCH)
+ {
+ readable = FALSE;
+ }
+
+ return readable;
+}