Commit 9ac8d63e authored by Alexandre Julliard's avatar Alexandre Julliard

include: Move unwinding functions definitions to rtlsupportapi.h.

parent 630d7943
......@@ -28,7 +28,7 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "wownt16.h"
#include "wownt32.h"
#include "wine/winbase16.h"
......
......@@ -23,6 +23,7 @@
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
......
......@@ -27,6 +27,7 @@
#include "winbase.h"
#include "winnt.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "unixlib.h"
#include "wine/asm.h"
......
......@@ -1551,10 +1551,10 @@ __ASM_GLOBAL_FUNC( "#KiUserCallbackDispatcher",
/**************************************************************************
* RtlIsEcCode (NTDLL.@)
*/
BOOLEAN WINAPI RtlIsEcCode( const void *ptr )
BOOLEAN WINAPI RtlIsEcCode( ULONG_PTR ptr )
{
const UINT64 *map = (const UINT64 *)NtCurrentTeb()->Peb->EcCodeBitMap;
ULONG_PTR page = (ULONG_PTR)ptr / page_size;
ULONG_PTR page = ptr / page_size;
return (map[page / 64] >> (page & 63)) & 1;
}
......@@ -1709,7 +1709,7 @@ void *check_call( void **target, void *exit_thunk, void *dest )
for (;;)
{
if (dest == __wine_unix_call_dispatcher) return dest;
if (RtlIsEcCode( dest )) return dest;
if (RtlIsEcCode( (ULONG_PTR)dest )) return dest;
if (code_match( dest, jmp_sequence, sizeof(jmp_sequence) ))
{
int *off_ptr = (int *)((char *)dest + sizeof(jmp_sequence));
......
......@@ -463,7 +463,7 @@ __ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
/**************************************************************************
* RtlIsEcCode (NTDLL.@)
*/
BOOLEAN WINAPI RtlIsEcCode( const void *ptr )
BOOLEAN WINAPI RtlIsEcCode( ULONG_PTR ptr )
{
return FALSE;
}
......
......@@ -30,6 +30,7 @@
#include "winreg.h"
#include "winuser.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "ddk/wdm.h"
#include "excpt.h"
#include "wine/test.h"
......
......@@ -30,6 +30,7 @@
#include "winreg.h"
#include "winnt.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "wine/test.h"
#ifndef __i386__
......
......@@ -134,8 +134,8 @@ BOOLEAN CDECL RtlInstallFunctionTableCallback( ULONG_PTR table, ULONG_PTR base,
/*************************************************************************
* RtlAddGrowableFunctionTable (NTDLL.@)
*/
DWORD WINAPI RtlAddGrowableFunctionTable( void **table, RUNTIME_FUNCTION *functions, DWORD count,
DWORD max_count, ULONG_PTR base, ULONG_PTR end )
NTSTATUS WINAPI RtlAddGrowableFunctionTable( void **table, RUNTIME_FUNCTION *functions, DWORD count,
DWORD max_count, ULONG_PTR base, ULONG_PTR end )
{
struct dynamic_unwind_entry *entry;
......@@ -249,7 +249,7 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionTable( ULONG_PTR pc, ULONG_PTR *base,
if (LdrFindEntryForAddress( (void *)pc, &module )) return NULL;
*base = (ULONG_PTR)module->DllBase;
#ifdef __arm64ec__
if (RtlIsEcCode( (void *)pc ))
if (RtlIsEcCode( pc ))
{
IMAGE_LOAD_CONFIG_DIRECTORY *cfg;
IMAGE_ARM64EC_METADATA *metadata;
......@@ -772,12 +772,12 @@ static ARM64_RUNTIME_FUNCTION *find_function_info_arm64( ULONG_PTR pc, ULONG_PTR
/**********************************************************************
* RtlVirtualUnwind (NTDLL.@)
*/
PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG_PTR base, ULONG_PTR pc,
ARM64_RUNTIME_FUNCTION *func, ARM64_NT_CONTEXT *context,
PVOID *handler_data, ULONG_PTR *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS_ARM64 *ctx_ptr )
PEXCEPTION_ROUTINE WINAPI RtlVirtualUnwind( ULONG type, ULONG_PTR base, ULONG_PTR pc,
ARM64_RUNTIME_FUNCTION *func, ARM64_NT_CONTEXT *context,
PVOID *handler_data, ULONG_PTR *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS_ARM64 *ctx_ptr )
{
void *handler;
PEXCEPTION_ROUTINE handler;
TRACE( "type %lx pc %I64x sp %I64x\n", type, pc, context->Sp );
......@@ -1370,12 +1370,12 @@ static RUNTIME_FUNCTION *find_function_info( ULONG_PTR pc, ULONG_PTR base,
/***********************************************************************
* RtlVirtualUnwind (NTDLL.@)
*/
PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG_PTR base, ULONG_PTR pc,
RUNTIME_FUNCTION *func, CONTEXT *context,
PVOID *handler_data, ULONG_PTR *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr )
PEXCEPTION_ROUTINE WINAPI RtlVirtualUnwind( ULONG type, ULONG_PTR base, ULONG_PTR pc,
RUNTIME_FUNCTION *func, CONTEXT *context,
PVOID *handler_data, ULONG_PTR *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr )
{
void *handler;
PEXCEPTION_ROUTINE handler;
TRACE( "type %lx pc %Ix sp %lx\n", type, pc, context->Sp );
......@@ -1810,10 +1810,10 @@ static RUNTIME_FUNCTION *find_function_info( ULONG_PTR pc, ULONG_PTR base,
/**********************************************************************
* RtlVirtualUnwind (NTDLL.@)
*/
PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc,
RUNTIME_FUNCTION *function, CONTEXT *context,
PVOID *data, ULONG64 *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr )
PEXCEPTION_ROUTINE WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc,
RUNTIME_FUNCTION *function, CONTEXT *context,
PVOID *data, ULONG64 *frame_ret,
KNONVOLATILE_CONTEXT_POINTERS *ctx_ptr )
{
union handler_data *handler_data;
ULONG64 frame, off;
......@@ -1822,11 +1822,11 @@ PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc,
BOOL mach_frame = FALSE;
#ifdef __arm64ec__
if (RtlIsEcCode( (void *)pc ))
if (RtlIsEcCode( pc ))
{
DWORD flags = context->ContextFlags & ~CONTEXT_UNWOUND_TO_CALL;
ARM64_NT_CONTEXT arm_context;
void *ret;
PEXCEPTION_ROUTINE ret;
context_x64_to_arm( &arm_context, (ARM64EC_NT_CONTEXT *)context );
ret = RtlVirtualUnwind_arm64( type, base, pc, (ARM64_RUNTIME_FUNCTION *)function,
......@@ -1963,7 +1963,7 @@ PVOID WINAPI RtlVirtualUnwind( ULONG type, ULONG64 base, ULONG64 pc,
if (prolog_offset != ~0) return NULL; /* inside prolog */
*data = &handler_data->handler + 1;
return (char *)base + handler_data->handler;
return (PEXCEPTION_ROUTINE)((char *)base + handler_data->handler);
}
......@@ -1978,7 +1978,7 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
ULONG size;
#ifdef __arm64ec__
if (RtlIsEcCode( (void *)pc ))
if (RtlIsEcCode( pc ))
return (RUNTIME_FUNCTION *)RtlLookupFunctionEntry_arm64( pc, base, table );
#endif
......
......@@ -26,6 +26,7 @@
#include "winbase.h"
#include "ntgdi.h"
#include "ntuser.h"
#include "rtlsupportapi.h"
#include "wine/unixlib.h"
#include "wine/asm.h"
#include "win32syscalls.h"
......
......@@ -25,6 +25,7 @@
#include "windef.h"
#include "winnt.h"
#include "winternl.h"
#include "rtlsupportapi.h"
#include "wine/asm.h"
#include "wine/debug.h"
......
......@@ -678,6 +678,7 @@ SOURCES = \
rstloc.idl \
rstnot.idl \
rstupd.idl \
rtlsupportapi.h \
rtutils.h \
rtworkq.idl \
sal.h \
......
/*
* Definitions for Rtl exception handling functions
*
* Copyright 2024 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _APISETRTLSUPPORT_
#define _APISETRTLSUPPORT_
NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
NTSYSAPI void WINAPI RtlCaptureContext2(CONTEXT*);
NTSYSAPI USHORT WINAPI RtlCaptureStackBackTrace(ULONG,ULONG,void**,ULONG*);
NTSYSAPI void WINAPI RtlRaiseException(EXCEPTION_RECORD*);
NTSYSAPI void CDECL RtlRestoreContext(CONTEXT*,EXCEPTION_RECORD*);
NTSYSAPI void WINAPI RtlUnwind(void*,void*,EXCEPTION_RECORD*,void*);
NTSYSAPI void* WINAPI RtlPcToFileHeader(void*,void**);
#ifndef __i386__
#define UNWIND_HISTORY_TABLE_SIZE 12
typedef struct _UNWIND_HISTORY_TABLE_ENTRY
{
ULONG_PTR ImageBase;
PRUNTIME_FUNCTION FunctionEntry;
} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
typedef struct _UNWIND_HISTORY_TABLE
{
DWORD Count;
BYTE LocalHint;
BYTE GlobalHint;
BYTE Search;
BYTE Once;
ULONG_PTR LowAddress;
ULONG_PTR HighAddress;
UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
#define RTL_VIRTUAL_UNWIND2_VALIDATE_PAC 0x0001
NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,ULONG,ULONG_PTR);
NTSYSAPI NTSTATUS WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,ULONG,ULONG,ULONG_PTR,ULONG_PTR);
NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,ULONG);
NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(ULONG_PTR,ULONG_PTR,ULONG,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(ULONG_PTR,ULONG_PTR*,UNWIND_HISTORY_TABLE*);
NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionTable(ULONG_PTR,ULONG_PTR*,ULONG*);
NTSYSAPI void WINAPI RtlUnwindEx(void*,void*,EXCEPTION_RECORD*,void*,CONTEXT*,UNWIND_HISTORY_TABLE*);
NTSYSAPI PEXCEPTION_ROUTINE WINAPI RtlVirtualUnwind(ULONG,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,void**,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
NTSYSAPI NTSTATUS WINAPI RtlVirtualUnwind2(ULONG,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,BOOLEAN*,void**,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*,ULONG_PTR*,ULONG_PTR*,PEXCEPTION_ROUTINE*,ULONG);
#ifdef __x86_64__
NTSYSAPI BOOLEAN WINAPI RtlIsEcCode(ULONG_PTR);
#endif
#endif /* __i386__ */
#endif /* _APISETRTLSUPPORT_ */
......@@ -27,6 +27,7 @@
#include <windef.h>
#include <winternl.h>
#include <rtlsupportapi.h>
#include <excpt.h>
#ifdef __cplusplus
......
......@@ -1963,8 +1963,6 @@ typedef ARM64_NT_CONTEXT CONTEXT, *PCONTEXT;
#error You need to define a CONTEXT for your CPU
#endif
NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
#define WOW64_CONTEXT_i386 0x00010000
#define WOW64_CONTEXT_i486 0x00010000
#define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
......@@ -1987,10 +1985,6 @@ NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
#define WOW64_SIZE_OF_80387_REGISTERS 80
#define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
#ifdef __x86_64__
NTSYSAPI BOOLEAN NTAPI RtlIsEcCode(const void*);
#endif
/* Exception definitions */
#define EXCEPTION_READ_FAULT 0
......@@ -2108,47 +2102,6 @@ typedef void (CALLBACK *PTERMINATION_HANDLER)(BOOLEAN,DWORD64);
#endif /* __aarch64__ */
NTSYSAPI void NTAPI RtlRaiseException(struct _EXCEPTION_RECORD*);
NTSYSAPI void CDECL RtlRestoreContext(CONTEXT*,struct _EXCEPTION_RECORD*);
NTSYSAPI void NTAPI RtlUnwind(void*,void*,struct _EXCEPTION_RECORD*,void*);
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
#define UNWIND_HISTORY_TABLE_SIZE 12
typedef struct _UNWIND_HISTORY_TABLE_ENTRY
{
ULONG_PTR ImageBase;
PRUNTIME_FUNCTION FunctionEntry;
} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
typedef struct _UNWIND_HISTORY_TABLE
{
DWORD Count;
BYTE LocalHint;
BYTE GlobalHint;
BYTE Search;
BYTE Once;
ULONG_PTR LowAddress;
ULONG_PTR HighAddress;
UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
typedef PRUNTIME_FUNCTION (CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK)(DWORD_PTR,PVOID);
NTSYSAPI BOOLEAN CDECL RtlAddFunctionTable(RUNTIME_FUNCTION*,DWORD,DWORD_PTR);
NTSYSAPI DWORD WINAPI RtlAddGrowableFunctionTable(void**,PRUNTIME_FUNCTION,DWORD,DWORD,ULONG_PTR,ULONG_PTR);
NTSYSAPI BOOLEAN CDECL RtlDeleteFunctionTable(RUNTIME_FUNCTION*);
NTSYSAPI void WINAPI RtlDeleteGrowableFunctionTable(void*);
NTSYSAPI void WINAPI RtlGrowFunctionTable(void*,DWORD);
NTSYSAPI BOOLEAN CDECL RtlInstallFunctionTableCallback(DWORD_PTR,DWORD_PTR,DWORD,PGET_RUNTIME_FUNCTION_CALLBACK,PVOID,PCWSTR);
NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry(DWORD_PTR,DWORD_PTR*,UNWIND_HISTORY_TABLE*);
NTSYSAPI PRUNTIME_FUNCTION WINAPI RtlLookupFunctionTable(DWORD_PTR,DWORD_PTR*,ULONG*);
NTSYSAPI void WINAPI RtlUnwindEx(PVOID,PVOID,struct _EXCEPTION_RECORD*,PVOID,CONTEXT*,UNWIND_HISTORY_TABLE*);
NTSYSAPI PVOID WINAPI RtlVirtualUnwind(DWORD,ULONG_PTR,ULONG_PTR,RUNTIME_FUNCTION*,CONTEXT*,PVOID*,ULONG_PTR*,KNONVOLATILE_CONTEXT_POINTERS*);
#endif
/*
* Product types
*/
......@@ -6845,7 +6798,6 @@ typedef VOID (CALLBACK *PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE,PVOID,PTP_WAIT,
NTSYSAPI BOOLEAN NTAPI RtlGetProductInfo(DWORD,DWORD,DWORD,DWORD,PDWORD);
NTSYSAPI void* NTAPI RtlPcToFileHeader(void*,void**);
typedef enum _RTL_UMS_THREAD_INFO_CLASS
{
......
......@@ -4688,7 +4688,6 @@ NTSYSAPI BOOLEAN WINAPI RtlAreAllAccessesGranted(ACCESS_MASK,ACCESS_MASK);
NTSYSAPI BOOLEAN WINAPI RtlAreAnyAccessesGranted(ACCESS_MASK,ACCESS_MASK);
NTSYSAPI BOOLEAN WINAPI RtlAreBitsSet(PCRTL_BITMAP,ULONG,ULONG);
NTSYSAPI BOOLEAN WINAPI RtlAreBitsClear(PCRTL_BITMAP,ULONG,ULONG);
NTSYSAPI USHORT WINAPI RtlCaptureStackBackTrace(ULONG,ULONG,PVOID*,ULONG*);
NTSYSAPI NTSTATUS WINAPI RtlCharToInteger(PCSZ,ULONG,PULONG);
NTSYSAPI NTSTATUS WINAPI RtlCheckRegistryKey(ULONG, PWSTR);
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment