Skip to content

Commit

Permalink
Fea #62, 新增RtlCaptureStackBackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
sonyps5201314 authored and mingkuang-Chuyu committed Aug 10, 2023
1 parent badef5c commit 9847db4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
| TzSpecificLocalTimeToSystemTimeEx | 不存在时,内部实现。
| GetFirmwareType | 不存在时,调用NtQuerySystemInformation。
| IsNativeVhdBoot | 不存在时,调用NtQuerySystemInformation。
| RtlCaptureStackBackTrace | 调用ntdll.RtlCaptureStackBackTrace。

## mfplat.dll
| 函数 | Fallback
Expand Down
33 changes: 33 additions & 0 deletions src/Thunks/api-ms-win-core-rtlsupport.hpp
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
<ItemGroup>
<ClInclude Include="..\Thunks\api-ms-win-core-com.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-core-kernel32-legacy.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-core-rtlsupport.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-eventing-provider.hpp" />
<ClInclude Include="..\Thunks\api-ms-win-power-base.hpp" />
<ClInclude Include="..\Thunks\bcrypt.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions src/YY-Thunks.UnitTest/YY-Thunks.UnitTest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@
<ClInclude Include="..\Thunks\api-ms-win-core-kernel32-legacy.hpp">
<Filter>Thunks</Filter>
</ClInclude>
<ClInclude Include="..\Thunks\api-ms-win-core-rtlsupport.hpp">
<Filter>Thunks</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\def\x86\PSAPI2Kernel32.def">
Expand Down

0 comments on commit 9847db4

Please sign in to comment.