diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 5b026a2f..592f8b1c 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -15,8 +15,11 @@ namespace tracy #if defined _WIN32 || defined __CYGWIN__ +extern "C" t_RtlWalkFrameChain RtlWalkFrameChain = 0; + void InitCallstack() { + RtlWalkFrameChain = (t_RtlWalkFrameChain)GetProcAddress( GetModuleHandle( "ntdll.dll" ), "RtlWalkFrameChain" ); SymInitialize( GetCurrentProcess(), nullptr, true ); SymSetOptions( SYMOPT_LOAD_LINES ); } diff --git a/client/TracyCallstack.hpp b/client/TracyCallstack.hpp index 5d2482df..0f46ebc1 100644 --- a/client/TracyCallstack.hpp +++ b/client/TracyCallstack.hpp @@ -3,13 +3,11 @@ #if defined _WIN32 || defined __CYGWIN__ # define TRACY_HAS_CALLSTACK -# ifndef MAXLONG -# ifdef __CYGWIN__ -extern "C" __declspec(dllimport) unsigned short __stdcall RtlCaptureStackBackTrace( unsigned int, unsigned int, void**, unsigned int* ); -# else -extern "C" __declspec(dllimport) unsigned short __stdcall RtlCaptureStackBackTrace( unsigned long, unsigned long, void**, unsigned long* ); -# endif -# endif +extern "C" +{ + typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long ); + extern t_RtlWalkFrameChain RtlWalkFrameChain; +} #elif defined __ANDROID__ # define TRACY_HAS_CALLSTACK # include @@ -49,7 +47,7 @@ static tracy_force_inline void* Callstack( int depth ) assert( depth >= 1 && depth < 63 ); auto trace = (uintptr_t*)tracy_malloc( ( 1 + depth ) * sizeof( uintptr_t ) ); - const auto num = RtlCaptureStackBackTrace( 0, depth, (void**)( trace+1 ), nullptr ); + const auto num = RtlWalkFrameChain( (void**)( trace + 1 ), depth, 0 ); *trace = num; return trace;