diff --git a/ThunksList.md b/ThunksList.md index 01bb32b..43e169b 100644 --- a/ThunksList.md +++ b/ThunksList.md @@ -289,6 +289,7 @@ | TzSpecificLocalTimeToSystemTimeEx | 不存在时,内部实现。 | GetFirmwareType | 不存在时,调用NtQuerySystemInformation。 | IsNativeVhdBoot | 不存在时,调用NtQuerySystemInformation。 +| RtlCaptureStackBackTrace | 调用ntdll.RtlCaptureStackBackTrace。 ## mfplat.dll | 函数 | Fallback diff --git a/src/Thunks/api-ms-win-core-rtlsupport.hpp b/src/Thunks/api-ms-win-core-rtlsupport.hpp new file mode 100644 index 0000000..50b050a --- /dev/null +++ b/src/Thunks/api-ms-win-core-rtlsupport.hpp @@ -0,0 +1,33 @@ + + +namespace YY +{ + namespace Thunks + { + +#if (YY_Thunks_Support_Version < NTDDI_WINXP) + + // Available in starting with Windows XP. + // Windows 2000时这个函数就已经存在了,只是从XP开始才从kernel32.dll中导出 + __DEFINE_THUNK( + ntdll, + 16, + WORD, + NTAPI, + RtlCaptureStackBackTrace, + _In_ DWORD _uFramesToSkip, + _In_ DWORD _uFramesToCapture, + _Out_writes_to_(_uFramesToCapture, return) PVOID* _pBackTrace, + _Out_opt_ PDWORD _puBackTraceHash + ) + { + if (const auto _pfnRtlCaptureStackBackTrace = try_get_RtlCaptureStackBackTrace()) + { + return _pfnRtlCaptureStackBackTrace(_uFramesToSkip, _uFramesToCapture, _pBackTrace, _puBackTraceHash); + } + + return 0; + } +#endif + } +} diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj index bf3d61e..9c9cd42 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj @@ -193,6 +193,7 @@ + diff --git a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters index 493974a..251c101 100644 --- a/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters +++ b/src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters @@ -224,6 +224,9 @@ Thunks + + Thunks +