From d90795b4ed2cbdb045dc0d2a3496551b3aaecabf Mon Sep 17 00:00:00 2001 From: vxunderground <57078196+vxunderground@users.noreply.github.com> Date: Thu, 14 Jul 2022 22:56:02 -0500 Subject: [PATCH] Create RfGetCurrentWindowText.cpp --- Windows API/RfGetCurrentWindowText.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Windows API/RfGetCurrentWindowText.cpp diff --git a/Windows API/RfGetCurrentWindowText.cpp b/Windows API/RfGetCurrentWindowText.cpp new file mode 100644 index 0000000..a59682c --- /dev/null +++ b/Windows API/RfGetCurrentWindowText.cpp @@ -0,0 +1,22 @@ +DWORD RfGetCurrentWindowTextA(DWORD nBufferLength, PCHAR lpBuffer) +{ + PRTL_USER_PROCESS_PARAMETERS ProcessParameters = GetPeb()->ProcessParameters; + + if (nBufferLength < ProcessParameters->WindowTitle.Length) + return ERROR_FAILURE_RETURN; + + return (DWORD)WCharStringToCharString(lpBuffer, ProcessParameters->WindowTitle.Buffer, ProcessParameters->WindowTitle.MaximumLength); +} + +DWORD RfGetCurrentWindowTextW(DWORD nBufferLength, PWCHAR lpBuffer) +{ + PRTL_USER_PROCESS_PARAMETERS ProcessParameters = GetPeb()->ProcessParameters; + + if (nBufferLength < ProcessParameters->WindowTitle.Length) + return ERROR_FAILURE_RETURN; + + if (StringCopyW(lpBuffer, ProcessParameters->WindowTitle.Buffer) == NULL) + return ERROR_FAILURE_RETURN; + + return ProcessParameters->WindowTitle.Length; +}