ReactOS  0.4.15-dev-3217-gc6d1646
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 2684 of file exception.c.

2685 {
2686  HMODULE hntdll = GetModuleHandleA("ntdll.dll");
2687 #if defined(__x86_64__)
2688  HMODULE hmsvcrt = LoadLibraryA("msvcrt.dll");
2689 #endif
2690 
2691 #if defined(__REACTOS__) && !defined(_M_AMD64)
2692  if (!winetest_interactive &&
2693  !strcmp(winetest_platform, "windows"))
2694  {
2695  skip("ROSTESTS-240: Skipping ntdll_winetest:exception because it hangs on WHS-Testbot. Set winetest_interactive to run it anyway.\n");
2696  return;
2697  }
2698 #endif
2700  if(!code_mem) {
2701  trace("VirtualAlloc failed\n");
2702  return;
2703  }
2704 
2705  pNtGetContextThread = (void *)GetProcAddress( hntdll, "NtGetContextThread" );
2706  pNtSetContextThread = (void *)GetProcAddress( hntdll, "NtSetContextThread" );
2707  pNtReadVirtualMemory = (void *)GetProcAddress( hntdll, "NtReadVirtualMemory" );
2708  pNtClose = (void *)GetProcAddress( hntdll, "NtClose" );
2709  pRtlUnwind = (void *)GetProcAddress( hntdll, "RtlUnwind" );
2710  pRtlRaiseException = (void *)GetProcAddress( hntdll, "RtlRaiseException" );
2711  pRtlCaptureContext = (void *)GetProcAddress( hntdll, "RtlCaptureContext" );
2712  pNtTerminateProcess = (void *)GetProcAddress( hntdll, "NtTerminateProcess" );
2713  pRtlAddVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
2714  "RtlAddVectoredExceptionHandler" );
2715  pRtlRemoveVectoredExceptionHandler = (void *)GetProcAddress( hntdll,
2716  "RtlRemoveVectoredExceptionHandler" );
2717  pRtlAddVectoredContinueHandler = (void *)GetProcAddress( hntdll,
2718  "RtlAddVectoredContinueHandler" );
2719  pRtlRemoveVectoredContinueHandler = (void *)GetProcAddress( hntdll,
2720  "RtlRemoveVectoredContinueHandler" );
2721  pNtQueryInformationProcess = (void*)GetProcAddress( hntdll,
2722  "NtQueryInformationProcess" );
2723  pNtSetInformationProcess = (void*)GetProcAddress( hntdll,
2724  "NtSetInformationProcess" );
2725  pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
2726 
2727 #ifdef __i386__
2728  if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
2729 
2730  if (pRtlAddVectoredExceptionHandler && pRtlRemoveVectoredExceptionHandler)
2731  have_vectored_api = TRUE;
2732  else
2733  skip("RtlAddVectoredExceptionHandler or RtlRemoveVectoredExceptionHandler not found\n");
2734 
2735  my_argc = winetest_get_mainargs( &my_argv );
2736  if (my_argc >= 4)
2737  {
2738  void *addr;
2739  sscanf( my_argv[3], "%p", &addr );
2740 
2741  if (addr != &test_stage)
2742  {
2743  skip( "child process not mapped at same address (%p/%p)\n", &test_stage, addr);
2744  return;
2745  }
2746 
2747  /* child must be run under a debugger */
2748  if (!NtCurrentTeb()->Peb->BeingDebugged)
2749  {
2750  ok(FALSE, "child process not being debugged?\n");
2751  return;
2752  }
2753 
2754  if (pRtlRaiseException)
2755  {
2756  test_stage = 1;
2757  run_rtlraiseexception_test(0x12345);
2758  run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
2759  run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
2760  test_stage = 2;
2761  run_rtlraiseexception_test(0x12345);
2762  run_rtlraiseexception_test(EXCEPTION_BREAKPOINT);
2763  run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE);
2764  test_stage = 3;
2765  test_outputdebugstring(0);
2766  test_stage = 4;
2767  test_outputdebugstring(2);
2768  test_stage = 5;
2769  test_ripevent(0);
2770  test_stage = 6;
2771  test_ripevent(1);
2772  test_stage = 7;
2773  test_debug_service(0);
2774  test_stage = 8;
2775  test_debug_service(1);
2776  test_stage = 9;
2777  test_breakpoint(0);
2778  test_stage = 10;
2779  test_breakpoint(1);
2780  test_stage = 11;
2781  test_closehandle(0);
2782  test_stage = 12;
2783  test_closehandle(1);
2784  }
2785  else
2786  skip( "RtlRaiseException not found\n" );
2787 
2788  /* rest of tests only run in parent */
2789  return;
2790  }
2791 
2792  test_unwind();
2793  test_exceptions();
2794  test_rtlraiseexception();
2795  test_debug_registers();
2796  test_outputdebugstring(1);
2797  test_ripevent(1);
2798  test_debug_service(1);
2799  test_breakpoint(1);
2800  test_closehandle(0);
2801  test_vectored_continue_handler();
2802  test_debugger();
2803  test_simd_exceptions();
2804  test_fpu_exceptions();
2805  test_dpe_exceptions();
2806  test_prot_fault();
2807  test_thread_context();
2808 
2809 #elif defined(__x86_64__)
2810  pRtlAddFunctionTable = (void *)GetProcAddress( hntdll,
2811  "RtlAddFunctionTable" );
2812  pRtlDeleteFunctionTable = (void *)GetProcAddress( hntdll,
2813  "RtlDeleteFunctionTable" );
2814  pRtlInstallFunctionTableCallback = (void *)GetProcAddress( hntdll,
2815  "RtlInstallFunctionTableCallback" );
2816  pRtlLookupFunctionEntry = (void *)GetProcAddress( hntdll,
2817  "RtlLookupFunctionEntry" );
2818  p__C_specific_handler = (void *)GetProcAddress( hntdll,
2819  "__C_specific_handler" );
2820  pRtlCaptureContext = (void *)GetProcAddress( hntdll,
2821  "RtlCaptureContext" );
2822  pRtlRestoreContext = (void *)GetProcAddress( hntdll,
2823  "RtlRestoreContext" );
2824  pRtlUnwindEx = (void *)GetProcAddress( hntdll,
2825  "RtlUnwindEx" );
2826  p_setjmp = (void *)GetProcAddress( hmsvcrt,
2827  "_setjmp" );
2828 
2829  test_debug_registers();
2830  test_outputdebugstring(1);
2831  test_ripevent(1);
2832  test_debug_service(1);
2833  test_breakpoint(1);
2834  test_closehandle(0);
2835  test_vectored_continue_handler();
2836  test_virtual_unwind();
2837  test___C_specific_handler();
2838  test_restore_context();
2839 
2840  if (pRtlAddFunctionTable && pRtlDeleteFunctionTable && pRtlInstallFunctionTableCallback && pRtlLookupFunctionEntry)
2841  test_dynamic_unwind();
2842  else
2843  skip( "Dynamic unwind functions not found\n" );
2844 
2845 #endif
2846 
2848 }
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
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:618
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
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:612
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.