ReactOS  0.4.14-dev-342-gdc047f9
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_WINNT   0x500 /* For NTSTATUS */
 
#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

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x500 /* For NTSTATUS */

Definition at line 25 of file exception.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 30 of file exception.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 29 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 2711 of file exception.c.

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

Referenced by START_TEST().

◆ exit_code

const void void SIZE_T* static LONG exit_code

Definition at line 55 of file exception.c.

◆ func

Definition at line 50 of file exception.c.

◆ PBOOL

Definition at line 58 of file exception.c.

◆ PEXCEPTION_RECORD

Definition at line 48 of file exception.c.

◆ PROCESSINFOCLASS

Definition at line 56 of file exception.c.

◆ PULONG

Definition at line 56 of file exception.c.

Referenced by PrintStackTrace().

◆ PVOID

Definition at line 48 of file exception.c.

◆ SIZE_T

Definition at line 54 of file exception.c.

◆ ULONG

Definition at line 56 of file exception.c.