ntdll: Move RtlAddFunctionTable() to the CPU backends.
This commit is contained in:
parent
02ebacca0c
commit
ab69f71912
5 changed files with 65 additions and 68 deletions
|
@ -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 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.@)
|
* RtlInstallFunctionTableCallback (NTDLL.@)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1208,6 +1208,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
|
* call_consolidate_callback
|
||||||
*
|
*
|
||||||
|
|
|
@ -1110,6 +1110,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
|
* call_consolidate_callback
|
||||||
*
|
*
|
||||||
|
|
|
@ -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.@)
|
* 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
|
struct unwind_exception_frame
|
||||||
{
|
{
|
||||||
EXCEPTION_REGISTRATION_RECORD frame;
|
EXCEPTION_REGISTRATION_RECORD frame;
|
||||||
|
|
Loading…
Add table
Reference in a new issue