ntdll: Implement RtlWalkFrameChain on x86-64.

This commit is contained in:
Alexandre Julliard 2024-03-11 16:52:36 +01:00
parent 6d8b4e661f
commit f127448d00
2 changed files with 31 additions and 0 deletions

View file

@ -958,6 +958,36 @@ __ASM_GLOBAL_FUNC( RtlRaiseException,
"call " __ASM_NAME("RtlRaiseStatus") /* does not return */ );
/*************************************************************************
* RtlWalkFrameChain (NTDLL.@)
*/
ULONG WINAPI RtlWalkFrameChain( void **buffer, ULONG count, ULONG flags )
{
UNWIND_HISTORY_TABLE table;
RUNTIME_FUNCTION *func;
PEXCEPTION_ROUTINE handler;
ULONG_PTR frame, base;
CONTEXT context;
void *data;
ULONG i, skip = flags >> 8, num_entries = 0;
RtlCaptureContext( &context );
for (i = 0; i < count; i++)
{
func = RtlLookupFunctionEntry( context.Rip, &base, &table );
if (RtlVirtualUnwind2( UNW_FLAG_NHANDLER, base, context.Rip, func, &context, NULL,
&data, &frame, NULL, NULL, NULL, &handler, 0 ))
break;
if (!context.Rip) break;
if (!frame || !is_valid_frame( frame )) break;
if (context.Rsp == (ULONG_PTR)NtCurrentTeb()->Tib.StackBase) break;
if (i >= skip) buffer[num_entries++] = (void *)context.Rip;
}
return num_entries;
}
static inline ULONG hash_pointers( void **ptrs, ULONG count )
{
/* Based on MurmurHash2, which is in the public domain */

View file

@ -28,6 +28,7 @@ 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**);
NTSYSAPI ULONG WINAPI RtlWalkFrameChain(void**,ULONG,ULONG);
#ifndef __i386__