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.
This commit is contained in:
jp9000 2015-10-05 14:00:52 -07:00
parent a468777614
commit b4597218f0
2 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,5 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#include <windows.h> #include <windows.h>
#include <shlobj.h>
#include <psapi.h> #include <psapi.h>
#include "graphics-hook.h" #include "graphics-hook.h"
#include "../obfuscate.h" #include "../obfuscate.h"
@ -139,10 +138,9 @@ static inline bool init_mutexes(void)
static inline bool init_system_path(void) static inline bool init_system_path(void)
{ {
HRESULT hr = SHGetFolderPathA(NULL, CSIDL_SYSTEM, NULL, UINT ret = GetSystemDirectoryA(system_path, MAX_PATH);
SHGFP_TYPE_CURRENT, system_path); if (!ret) {
if (hr != S_OK) { hlog("Failed to get windows system path: %lu", GetLastError());
hlog("Failed to get windows system path: %08lX", hr);
return false; return false;
} }

View File

@ -7,7 +7,6 @@
#include <util/pipe.h> #include <util/pipe.h>
#include <windows.h> #include <windows.h>
#include <shlobj.h>
#include "graphics-hook-info.h" #include "graphics-hook-info.h"
extern struct graphics_offsets offsets32; 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) struct win_version_info *ver)
{ {
wchar_t path[MAX_PATH]; wchar_t path[MAX_PATH];
UINT ret;
HRESULT hr = SHGetFolderPathW(NULL, CSIDL_SYSTEMX86, NULL, #ifdef _WIN64
SHGFP_TYPE_CURRENT, path); ret = GetSystemWow64DirectoryW(path, MAX_PATH);
if (hr != S_OK) { #else
ret = GetSystemDirectoryW(path, MAX_PATH);
#endif
if (!ret) {
blog(LOG_ERROR, "Failed to get windows 32bit system path: " blog(LOG_ERROR, "Failed to get windows 32bit system path: "
"%08lX", hr); "%lu", GetLastError());
return false; return false;
} }