ReactOS  0.4.15-dev-1070-ge1a01de
exception.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
#include "winreg.h"
#include "winternl.h"
#include "excpt.h"
#include "wine/test.h"
Include dependency graph for exception.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NONAMELESSUNION
 

Functions

static NTSTATUS (WINAPI *pNtGetContextThread)(HANDLE
 
static PVOID (WINAPI *pRtlUnwind)(PVOID
 
static VOID (WINAPI *pRtlCaptureContext)(CONTEXT *)
 
static ULONG (WINAPI *pRtlRemoveVectoredExceptionHandler)(PVOID handler)
 
static BOOL (WINAPI *pIsWow64Process)(HANDLE
 
 START_TEST (exception)
 

Variables

static voidcode_mem
 
static PVOID
 
static PEXCEPTION_RECORD
 
static PVECTORED_EXCEPTION_HANDLER func
 
static const void void SIZE_T
 
static const void void SIZE_T *static LONG exit_code
 
static PROCESSINFOCLASS
 
static ULONG
 
static PULONG
 
static PBOOL
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 26 of file exception.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file exception.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pIsWow64Process)
static

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtGetContextThread)
static

◆ PVOID()

static PVOID ( WINAPI pRtlUnwind)
static

◆ START_TEST()

START_TEST ( exception  )

Definition at line 2708 of file exception.c.

2709 {
2710  HMODULE hntdll = GetModuleHandleA("ntdll.dll");
2711 #if defined(__x86_64__)
2712  HMODULE hmsvcrt = LoadLibraryA("msvcrt.dll");
2713 #endif
2714 
2715 #ifdef __REACTOS__
2716  if (!winetest_interactive &&
2717  !strcmp(winetest_platform, "windows"))
2718  {
2719  skip("ROSTESTS-240: Skipping ntdll_winetest:exception because it hangs on WHS-Testbot. Set winetest_interactive to run it anyway.\n");
2720  return;
2721  }
2722 #endif
2724  if(!code_mem) {
2725  trace("VirtualAlloc failed\n");
2726  return;
2727  }
2728 
2729  pNtGetContextThread = (void *)GetProcAddress( hntdll, "NtGetContextThread" );
2730  pNtSetContextThread = (void *)GetProcAddress( hntdll, "NtSetContextThread" );
2731  pNtReadVirtualMemory = (void *)GetProcAddress( hntdll, "NtReadVirtualMemory" );
2732  pNtClose = (void *)GetProcAddress( hntdll, "NtClose" );
2733  pRtlUnwind = (void *)GetProcAddress( hntdll, "RtlUnwind" );
2734  pRtlRaiseException = (void *)GetProcAddress( hntdll, "RtlRaiseException" );
2735  pRtlCaptureContext = (void *)GetProcAddress( hntdll, "RtlCaptureContext" );
2736  pNtTerminateProcess = (void *)GetProcAddress( hntdll, "NtTerminateProcess" );
2737  pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
2738  "RtlAddVectoredExceptionHandler" );
2739  pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
2740  "RtlRemoveVectoredExceptionHandler" );
2741  pRtlAddVectoredContinueHandler = (void *)GetProcAddress( hntdll,
2742  "RtlAddVectoredContinueHandler" );
2743  pRtlRemoveVectoredContinueHandler = (void *)GetProcAddress( hntdll,
2744  "RtlRemoveVectoredContinueHandler" );
2745  pNtQueryInformationProcess = (void*)GetProcAddress( hntdll,
2746  "NtQueryInformationProcess" );
2747  pNtSetInformationProcess = (void*)GetProcAddress( hntdll,
2748  "NtSetInformationProcess" );
2749  pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
2750 
2751 #ifdef __i386__
2752  if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
2753 
2754  if (pRtlAddVectoredExceptionHandler && pRtlRemoveVectoredExceptionHandler)
2755  have_vectored_api = TRUE;
2756  else
2757  skip("RtlAddVectoredExceptionHandler or RtlRemoveVectoredExceptionHandler not found\n");
2758 
2759  my_argc = winetest_get_mainargs( &my_argv );
2760  if (my_argc >= 4)
2761  {
2762  void *addr;
2763  sscanf( my_argv[3], "%p", &addr );
2764 
2765  if (addr != &test_stage)
2766  {
2767  skip( "child process not mapped at same address (%p/%p)\n", &test_stage, addr);
2768  return;
2769  }
2770 
2771  /* child must be run under a debugger */
2772  if (!NtCurrentTeb()->Peb->BeingDebugged)
2773  {
2774  ok(FALSE, "child process not being debugged?\n");
2775  return;
2776  }
2777 
2778  if (pRtlRaiseException)
2779  {
2780  test_stage = 1;
2781  run_rtlraiseexception_test(0x12345);
2782  run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
2783  run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
2784  test_stage = 2;
2785  run_rtlraiseexception_test(0x12345);
2786  run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
2787  run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
2788  test_stage = 3;
2789  test_outputdebugstring(0);
2790  test_stage = 4;
2791  test_outputdebugstring(2);
2792  test_stage = 5;
2793  test_ripevent(0);
2794  test_stage = 6;
2795  test_ripevent(1);
2796  test_stage = 7;
2797  test_debug_service(0);
2798  test_stage = 8;
2799  test_debug_service(1);
2800  test_stage = 9;
2801  test_breakpoint(0);
2802  test_stage = 10;
2803  test_breakpoint(1);
2804  test_stage = 11;
2805  test_closehandle(0);
2806  test_stage = 12;
2807  test_closehandle(1);
2808  }
2809  else
2810  skip( "RtlRaiseException not found\n" );
2811 
2812  /* rest of tests only run in parent */
2813  return;
2814  }
2815 
2816  test_unwind();
2817  test_exceptions();
2818  test_rtlraiseexception();
2819  test_debug_registers();
2820  test_outputdebugstring(1);
2821  test_ripevent(1);
2822  test_debug_service(1);
2823  test_breakpoint(1);
2824  test_closehandle(0);
2825  test_vectored_continue_handler();
2826  test_debugger();
2827  test_simd_exceptions();
2828  test_fpu_exceptions();
2829  test_dpe_exceptions();
2830  test_prot_fault();
2831  test_thread_context();
2832 
2833 #elif defined(__x86_64__)
2834  pRtlAddFunctionTable = (void *)GetProcAddress( hntdll,
2835  "RtlAddFunctionTable" );
2836  pRtlDeleteFunctionTable = (void *)GetProcAddress( hntdll,
2837  "RtlDeleteFunctionTable" );
2838  pRtlInstallFunctionTableCallback = (void *)GetProcAddress( hntdll,
2839  "RtlInstallFunctionTableCallback" );
2840  pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll,
2841  "RtlLookupFunctionEntry" );
2842  p__C_specific_handler = (void *)GetProcAddress( hntdll,
2843  "__C_specific_handler" );
2844  pRtlCaptureContext = (void *)GetProcAddress( hntdll,
2845  "RtlCaptureContext" );
2846  pRtlRestoreContext = (void *)GetProcAddress( hntdll,
2847  "RtlRestoreContext" );
2848  pRtlUnwindEx = (void *)GetProcAddress( hntdll,
2849  "RtlUnwindEx" );
2850  p_setjmp = (void *)GetProcAddress( hmsvcrt,
2851  "_setjmp" );
2852 
2853  test_debug_registers();
2854  test_outputdebugstring(1);
2855  test_ripevent(1);
2856  test_debug_service(1);
2857  test_breakpoint(1);
2858  test_closehandle(0);
2859  test_vectored_continue_handler();
2860  test_virtual_unwind();
2861  test___C_specific_handler();
2862  test_restore_context();
2863 
2864  if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry)
2865  test_dynamic_unwind();
2866  else
2867  skip( "Dynamic unwind functions not found\n" );
2868 
2869 #endif
2870 
2872 }
PPEB Peb
Definition: dllmain.c:27
#define TRUE
Definition: types.h:120
#define EXCEPTION_INVALID_HANDLE
Definition: winbase.h:329
BYTE BeingDebugged
Definition: btrfs_drv.h:1955
int winetest_interactive
#define MEM_COMMIT
Definition: nt_native.h:1313
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:74
#define FALSE
Definition: types.h:117
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define MEM_RESERVE
Definition: nt_native.h:1314
smooth NULL
Definition: ftsmooth.c:416
const char * winetest_platform
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define trace
Definition: atltest.h:70
static BOOL is_wow64
Definition: loader.c:55
#define EXCEPTION_BREAKPOINT
Definition: winbase.h:310
int winetest_get_mainargs(char ***pargv)
GLenum const GLvoid * addr
Definition: glext.h:9621
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define GetCurrentProcess()
Definition: compat.h:507
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define ok(value,...)
Definition: atltest.h:57
static void * code_mem
Definition: exception.c:39
static HINSTANCE hntdll
Definition: process.c:66
#define skip(...)
Definition: atltest.h:64
#define MEM_RELEASE
Definition: nt_native.h:1316
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define GetProcAddress(x, y)
Definition: compat.h:501
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:128
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308

◆ ULONG()

static ULONG ( WINAPI pRtlRemoveVectoredExceptionHandler)
static

◆ VOID()

static VOID ( WINAPI pRtlCaptureContext)
static

Variable Documentation

◆ code_mem

void* code_mem
static

Definition at line 39 of file exception.c.

Referenced by START_TEST().

◆ exit_code

const void void SIZE_T* static LONG exit_code

Definition at line 51 of file exception.c.

◆ func

Definition at line 46 of file exception.c.

◆ PBOOL

Definition at line 54 of file exception.c.

◆ PEXCEPTION_RECORD

Definition at line 44 of file exception.c.

◆ PROCESSINFOCLASS

Definition at line 52 of file exception.c.

◆ PULONG

Definition at line 52 of file exception.c.

Referenced by PrintStackTrace().

◆ PVOID

Definition at line 44 of file exception.c.

◆ SIZE_T

Definition at line 50 of file exception.c.

◆ ULONG

Definition at line 52 of file exception.c.