From 06f0e767d13d4d68071c4fc51e25724e0fc8bc74 Mon Sep 17 00:00:00 2001 From: Augusto Righetto Date: Tue, 3 Mar 2020 07:26:59 -0800 Subject: BuildBreak: UWP apps can't call GetModuleHandle (#596) * BuildBreak: UWP apps can't call GetModuleHandle It is not possible to load RtlCaptureStackBackTrace at static init time in UWP. CaptureStackBackTrace is the public version of RtlCaptureStackBackTrace. * Using WINAPI_FAMILY_PARTITION family of macros Using WINAPI_FAMILY_PARTITION family of macros for detecting when building for UWP or Desktop. * Simplifying comment to please lint tool. --- absl/debugging/internal/stacktrace_win32-inl.inc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'absl/debugging/internal/stacktrace_win32-inl.inc') diff --git a/absl/debugging/internal/stacktrace_win32-inl.inc b/absl/debugging/internal/stacktrace_win32-inl.inc index 9c2c558044..af4578a506 100644 --- a/absl/debugging/internal/stacktrace_win32-inl.inc +++ b/absl/debugging/internal/stacktrace_win32-inl.inc @@ -46,11 +46,19 @@ typedef USHORT NTAPI RtlCaptureStackBackTrace_Function( OUT PVOID *backtrace, OUT PULONG backtrace_hash); +// It is not possible to load RtlCaptureStackBackTrace at static init time in +// UWP. CaptureStackBackTrace is the public version of RtlCaptureStackBackTrace +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn = + &::CaptureStackBackTrace; +#else // Load the function we need at static init time, where we don't have // to worry about someone else holding the loader's lock. static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn = (RtlCaptureStackBackTrace_Function*) GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace"); +#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP template static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, -- cgit 1.4.1