From d71a902ace281725bf979b675f2a400034afe995 Mon Sep 17 00:00:00 2001 From: Mark Street <22226349+mkst@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:09:28 +0000 Subject: [PATCH] Add GetTempPathA (#68) * Add GetTempPathA * Update dll/kernel32.cpp Co-authored-by: Anghelo Carvajal --------- Co-authored-by: Anghelo Carvajal --- dll/kernel32.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dll/kernel32.cpp b/dll/kernel32.cpp index c7a4c6c..aa37e0a 100644 --- a/dll/kernel32.cpp +++ b/dll/kernel32.cpp @@ -633,6 +633,22 @@ namespace kernel32 { } } + DWORD WIN_FUNC GetTempPathA(DWORD nBufferLength, LPSTR lpBuffer) { + DEBUG_LOG("GetTempPathA\n"); + + if ((nBufferLength == 0) || (lpBuffer == 0)) { + return 0; + } + + const char* tmp_dir; + if (!(tmp_dir = getenv("WIBO_TMP_DIR"))) { + tmp_dir = "Z:\\tmp\\"; + } + + strcpy(lpBuffer, tmp_dir); + return strlen(tmp_dir); + } + struct FILETIME { unsigned int dwLowDateTime; unsigned int dwHighDateTime; @@ -2265,6 +2281,7 @@ static void *resolveByName(const char *name) { if (strcmp(name, "GetFileType") == 0) return (void *) kernel32::GetFileType; if (strcmp(name, "FileTimeToLocalFileTime") == 0) return (void *) kernel32::FileTimeToLocalFileTime; if (strcmp(name, "GetFileInformationByHandle") == 0) return (void *) kernel32::GetFileInformationByHandle; + if (strcmp(name, "GetTempPathA") == 0) return (void *) kernel32::GetTempPathA; // sysinfoapi.h if (strcmp(name, "GetSystemTime") == 0) return (void *) kernel32::GetSystemTime;