From c9a90cbf8064fd8f65cb53ab92ffe546dda2d815 Mon Sep 17 00:00:00 2001 From: vxunderground <57078196+vxunderground@users.noreply.github.com> Date: Sun, 17 Jul 2022 08:37:35 -0500 Subject: [PATCH] Create CfCreateLocalAppDataObjectPath.cpp --- .../CfCreateLocalAppDataObjectPath.cpp | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Windows API/CfCreateLocalAppDataObjectPath.cpp diff --git a/Windows API/CfCreateLocalAppDataObjectPath.cpp b/Windows API/CfCreateLocalAppDataObjectPath.cpp new file mode 100644 index 0000000..d16d809 --- /dev/null +++ b/Windows API/CfCreateLocalAppDataObjectPath.cpp @@ -0,0 +1,46 @@ +/* + +pBuffer == OUT +Path == concatted, must have \\ in front i.e. L"\\File.exe" + +Credit: smelly__vx +*/ +BOOL CfCreateLocalAppDataObjectPathW(PWCHAR pBuffer, PWCHAR Path, DWORD Size, BOOL bDoesObjectExist) +{ + if (pBuffer == NULL) + return FALSE; + + if (RfGetEnvironmentVariableW(L"LOCALAPPDATA", pBuffer, Size) == 0) + return FALSE; + + if (StringConcatW(pBuffer, Path) == 0) + return FALSE; + + if (bDoesObjectExist) + { + if (!IsPathValidW(pBuffer)) + return FALSE; + } + + return TRUE; +} + +BOOL CfCreateLocalAppDataObjectPathA(PCHAR pBuffer, PCHAR Path, DWORD Size, BOOL bDoesObjectExist) +{ + if (pBuffer == NULL) + return FALSE; + + if (RfGetEnvironmentVariableA("LOCALAPPDATA", pBuffer, Size) == 0) + return FALSE; + + if (StringConcatA(pBuffer, Path) == 0) + return FALSE; + + if (bDoesObjectExist) + { + if (!IsPathValidA(pBuffer)) + return FALSE; + } + + return TRUE; +}