Skip to content

Commit 06f0e76

Browse files
authored
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.
1 parent bcefbdc commit 06f0e76

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

absl/debugging/internal/stacktrace_win32-inl.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,19 @@ typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(
4646
OUT PVOID *backtrace,
4747
OUT PULONG backtrace_hash);
4848

49+
// It is not possible to load RtlCaptureStackBackTrace at static init time in
50+
// UWP. CaptureStackBackTrace is the public version of RtlCaptureStackBackTrace
51+
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
52+
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
53+
static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn =
54+
&::CaptureStackBackTrace;
55+
#else
4956
// Load the function we need at static init time, where we don't have
5057
// to worry about someone else holding the loader's lock.
5158
static RtlCaptureStackBackTrace_Function* const RtlCaptureStackBackTrace_fn =
5259
(RtlCaptureStackBackTrace_Function*)
5360
GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlCaptureStackBackTrace");
61+
#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP
5462

5563
template <bool IS_STACK_FRAMES, bool IS_WITH_CONTEXT>
5664
static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,

0 commit comments

Comments
 (0)