From 57640cad49e61b89300350b95e6e5b469a7cc79b Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 30 Mar 2022 13:11:49 -0500 Subject: [PATCH] Implement RtlGetCallersAddress --- src/core/kernel/exports/EmuKrnlRtl.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/core/kernel/exports/EmuKrnlRtl.cpp b/src/core/kernel/exports/EmuKrnlRtl.cpp index 356eb20d1..7bca75c46 100644 --- a/src/core/kernel/exports/EmuKrnlRtl.cpp +++ b/src/core/kernel/exports/EmuKrnlRtl.cpp @@ -1106,7 +1106,31 @@ XBSYSAPI EXPORTNUM(288) xbox::void_xt NTAPI xbox::RtlGetCallersAddress LOG_FUNC_ARG_OUT(CallersCaller) LOG_FUNC_END; - LOG_UNIMPLEMENTED(); + /* Get the tow back trace address */ + PVOID BackTrace[2]; + ushort_xt FrameCount = RtlCaptureStackBackTrace(2, 2, &BackTrace[0], zeroptr); + + /* Only if user want it */ + if (CallersAddress != NULL) { + /* only when first frames exist */ + if (FrameCount >= 1) { + *CallersAddress = BackTrace[0]; + } + else { + *CallersAddress = zeroptr; + } + } + + /* Only if user want it */ + if (CallersCaller != NULL) { + /* only when second frames exist */ + if (FrameCount >= 2) { + *CallersCaller = BackTrace[1]; + } + else { + *CallersCaller = zeroptr; + } + } } // ******************************************************************