From b4597218f085acb81fcac03db2cb6fdea8600c12 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 5 Oct 2015 14:00:52 -0700 Subject: [PATCH] win-capture: Use GetSytemDirectory instead of SH* Instead of using shell functions to get the windows system directory, use the kernel32 functions (GetSystemDirectory and GetSystemWow64Directory). Reduces a bit of unnecessary overhead. --- plugins/win-capture/graphics-hook/graphics-hook.c | 8 +++----- plugins/win-capture/load-graphics-offsets.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/win-capture/graphics-hook/graphics-hook.c b/plugins/win-capture/graphics-hook/graphics-hook.c index 95c2cf8a1..a5797114f 100644 --- a/plugins/win-capture/graphics-hook/graphics-hook.c +++ b/plugins/win-capture/graphics-hook/graphics-hook.c @@ -1,6 +1,5 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include #include #include "graphics-hook.h" #include "../obfuscate.h" @@ -139,10 +138,9 @@ static inline bool init_mutexes(void) static inline bool init_system_path(void) { - HRESULT hr = SHGetFolderPathA(NULL, CSIDL_SYSTEM, NULL, - SHGFP_TYPE_CURRENT, system_path); - if (hr != S_OK) { - hlog("Failed to get windows system path: %08lX", hr); + UINT ret = GetSystemDirectoryA(system_path, MAX_PATH); + if (!ret) { + hlog("Failed to get windows system path: %lu", GetLastError()); return false; } diff --git a/plugins/win-capture/load-graphics-offsets.c b/plugins/win-capture/load-graphics-offsets.c index 6ad4021a3..9b23305a9 100644 --- a/plugins/win-capture/load-graphics-offsets.c +++ b/plugins/win-capture/load-graphics-offsets.c @@ -7,7 +7,6 @@ #include #include -#include #include "graphics-hook-info.h" extern struct graphics_offsets offsets32; @@ -98,12 +97,16 @@ static bool get_32bit_system_dll_ver(const wchar_t *system_lib, struct win_version_info *ver) { wchar_t path[MAX_PATH]; + UINT ret; - HRESULT hr = SHGetFolderPathW(NULL, CSIDL_SYSTEMX86, NULL, - SHGFP_TYPE_CURRENT, path); - if (hr != S_OK) { +#ifdef _WIN64 + ret = GetSystemWow64DirectoryW(path, MAX_PATH); +#else + ret = GetSystemDirectoryW(path, MAX_PATH); +#endif + if (!ret) { blog(LOG_ERROR, "Failed to get windows 32bit system path: " - "%08lX", hr); + "%lu", GetLastError()); return false; }