Commit ab69f719 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move RtlAddFunctionTable() to the CPU backends.

parent 02ebacca
......@@ -382,74 +382,6 @@ static RTL_CRITICAL_SECTION_DEBUG dynamic_unwind_debug =
};
static RTL_CRITICAL_SECTION dynamic_unwind_section = { &dynamic_unwind_debug, -1, 0, 0, 0, 0 };
static ULONG_PTR get_runtime_function_end( RUNTIME_FUNCTION *func, ULONG_PTR addr )
{
#ifdef __x86_64__
return func->EndAddress;
#elif defined(__arm__)
if (func->Flag) return func->BeginAddress + func->FunctionLength * 2;
else
{
struct unwind_info
{
DWORD function_length : 18;
DWORD version : 2;
DWORD x : 1;
DWORD e : 1;
DWORD f : 1;
DWORD count : 5;
DWORD words : 4;
} *info = (struct unwind_info *)(addr + func->UnwindData);
return func->BeginAddress + info->function_length * 2;
}
#else /* __aarch64__ */
if (func->Flag) return func->BeginAddress + func->FunctionLength * 4;
else
{
struct unwind_info
{
DWORD function_length : 18;
DWORD version : 2;
DWORD x : 1;
DWORD e : 1;
DWORD epilog : 5;
DWORD codes : 5;
} *info = (struct unwind_info *)(addr + func->UnwindData);
return func->BeginAddress + info->function_length * 4;
}
#endif
}
/**********************************************************************
* RtlAddFunctionTable (NTDLL.@)
*/
BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, ULONG_PTR addr )
{
struct dynamic_unwind_entry *entry;
TRACE( "%p %lu %Ix\n", table, count, addr );
/* NOTE: Windows doesn't check if table is aligned or a NULL pointer */
entry = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*entry) );
if (!entry)
return FALSE;
entry->base = addr;
entry->end = addr + (count ? get_runtime_function_end( &table[count - 1], addr ) : 0);
entry->table = table;
entry->count = count;
entry->max_count = 0;
entry->callback = NULL;
entry->context = NULL;
RtlEnterCriticalSection( &dynamic_unwind_section );
list_add_tail( &dynamic_unwind_list, &entry->entry );
RtlLeaveCriticalSection( &dynamic_unwind_section );
return TRUE;
}
/**********************************************************************
* RtlInstallFunctionTableCallback (NTDLL.@)
*/
......
......@@ -1209,6 +1209,24 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
/**********************************************************************
* RtlAddFunctionTable (NTDLL.@)
*/
BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, ULONG_PTR base )
{
ULONG_PTR end = base;
void *ret;
if (count)
{
RUNTIME_FUNCTION *func = table + count - 1;
struct unwind_info *info = (struct unwind_info *)(base + func->UnwindData);
end += func->BeginAddress + 2 * (func->Flag ? func->FunctionLength : info->function_length);
}
return !RtlAddGrowableFunctionTable( &ret, table, count, 0, base, end );
}
/**********************************************************************
* call_consolidate_callback
*
* Wrapper function to call a consolidate callback from a fake frame.
......
......@@ -1111,6 +1111,25 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
/**********************************************************************
* RtlAddFunctionTable (NTDLL.@)
*/
BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, ULONG_PTR base )
{
ULONG_PTR end = base;
void *ret;
if (count)
{
RUNTIME_FUNCTION *func = table + count - 1;
ULONG len = func->Flag ? func->FunctionLength :
((IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA *)(base + func->UnwindData))->FunctionLength;
end += func->BeginAddress + 4 * len;
}
return !RtlAddGrowableFunctionTable( &ret, table, count, 0, base, end );
}
/**********************************************************************
* call_consolidate_callback
*
* Wrapper function to call a consolidate callback from a fake frame.
......
......@@ -1858,6 +1858,20 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
}
/**********************************************************************
* RtlAddFunctionTable (NTDLL.@)
*/
BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, ULONG_PTR base )
{
ULONG_PTR end = base;
void *ret;
if (count) end += table[count - 1].EndAddress;
return !RtlAddGrowableFunctionTable( &ret, table, count, 0, base, end );
}
/*******************************************************************
* RtlUnwindEx (NTDLL.@)
*/
......
......@@ -1079,6 +1079,20 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
}
/**********************************************************************
* RtlAddFunctionTable (NTDLL.@)
*/
BOOLEAN CDECL RtlAddFunctionTable( RUNTIME_FUNCTION *table, DWORD count, ULONG_PTR base )
{
ULONG_PTR end = base;
void *ret;
if (count) end += table[count - 1].EndAddress;
return !RtlAddGrowableFunctionTable( &ret, table, count, 0, base, end );
}
struct unwind_exception_frame
{
EXCEPTION_REGISTRATION_RECORD frame;
......
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