Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

  1. /***
  2. *sehsupp.c - helper functions for Structured Exception Handling support
  3. *
  4. * Copyright (C) 1993-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Contains _rt_probe_read. Helper for the SEH runtime support
  8. * routines (longjmp in particular). Much of the SEH code is written
  9. * in asm, so these routines are available when probing memory in ways
  10. * that must be guarded with __try/__except in case of access violation.
  11. *
  12. *Revision History:
  13. * 12-05-93 PML Module created.
  14. * 12-22-93 GJF Made #define WIN32_LEAN_AND_MEAN conditional.
  15. * 01-12-94 PML Rewritten - still need helpers, just different ones
  16. *
  17. *******************************************************************************/
  18. #ifndef WIN32_LEAN_AND_MEAN
  19. #define WIN32_LEAN_AND_MEAN 1
  20. #endif
  21. #include <windows.h>
  22. /***
  23. *BOOL __stdcall _rt_probe_read4 - Check if a DWORD is readable
  24. *
  25. *Purpose:
  26. * Internal support function called by longjmp. Check if a DWORD is
  27. * readable under a __try/__except.
  28. *
  29. *Entry:
  30. * DWORD * p - Pointer to DWORD to be probed
  31. *
  32. *Exit:
  33. * Success: TRUE - Able to read
  34. * Failure: FALSE - Access violation while reading
  35. *
  36. ******************************************************************************/
  37. BOOL __stdcall _rt_probe_read4(
  38. DWORD * ptr)
  39. {
  40. BOOL readable;
  41. __try
  42. {
  43. *(volatile DWORD *)ptr;
  44. readable = TRUE;
  45. }
  46. __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION
  47. ? EXCEPTION_EXECUTE_HANDLER
  48. : EXCEPTION_CONTINUE_SEARCH)
  49. {
  50. readable = FALSE;
  51. }
  52. return readable;
  53. }