From 65ec2d5be0683119b23dcb14676fa98400703f49 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 20 May 2018 16:26:26 -0400 Subject: [PATCH] remove unneeded abstraction --- vnr/exclude.txt | 1 - vnr/vnrhook/CMakeLists.txt | 2 -- vnr/vnrhook/src/engine/engine.cc | 24 +++++++++++++++++++++--- vnr/winversion/winversion.cc | 30 ------------------------------ vnr/winversion/winversion.h | 16 ---------------- 5 files changed, 21 insertions(+), 52 deletions(-) delete mode 100644 vnr/exclude.txt delete mode 100644 vnr/winversion/winversion.cc delete mode 100644 vnr/winversion/winversion.h diff --git a/vnr/exclude.txt b/vnr/exclude.txt deleted file mode 100644 index 45946d4..0000000 --- a/vnr/exclude.txt +++ /dev/null @@ -1 +0,0 @@ -.bak diff --git a/vnr/vnrhook/CMakeLists.txt b/vnr/vnrhook/CMakeLists.txt index 74df062..1967b45 100644 --- a/vnr/vnrhook/CMakeLists.txt +++ b/vnr/vnrhook/CMakeLists.txt @@ -59,8 +59,6 @@ set(vnrhook_src ${PROJECT_SOURCE_DIR}/memdbg/memsearch.h ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.cc ${PROJECT_SOURCE_DIR}/ntinspect/ntinspect.h - ${PROJECT_SOURCE_DIR}/winversion/winversion.cc - ${PROJECT_SOURCE_DIR}/winversion/winversion.h ${PROJECT_SOURCE_DIR}/mono/monoobject.h ${PROJECT_SOURCE_DIR}/mono/monotype.h ) diff --git a/vnr/vnrhook/src/engine/engine.cc b/vnr/vnrhook/src/engine/engine.cc index 3d0cad4..3c1b27f 100644 --- a/vnr/vnrhook/src/engine/engine.cc +++ b/vnr/vnrhook/src/engine/engine.cc @@ -19,7 +19,6 @@ #include "memdbg/memsearch.h" #include "ntinspect/ntinspect.h" #include "disasm/disasm.h" -#include "winversion/winversion.h" #include "hashutil/hashstr.h" #include "cpputil/cppcstring.h" #include "ccutil/ccmacro.h" @@ -16633,8 +16632,27 @@ bool InsertPPSSPPHooks() ConsoleOutput("vnreng: PPSSPP: enter"); - //if (!WinVersion::queryFileVersion(process_path_, PPSSPP_VERSION)) - // ConsoleOutput("vnreng: failed to get PPSSPP version"); + // http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file + // get the version info for the file requested + if (DWORD dwSize = ::GetFileVersionInfoSizeW(process_path_, nullptr)) { + UINT len = 0; + BYTE * buf = new BYTE[dwSize]; + VS_FIXEDFILEINFO * info = nullptr; + if (::GetFileVersionInfoW(process_path_, 0, dwSize, buf) + && ::VerQueryValueW(buf, L"\\", (LPVOID*)&info, &len) + && info) + { + PPSSPP_VERSION[0] = HIWORD(info->dwFileVersionMS), + PPSSPP_VERSION[1] = LOWORD(info->dwFileVersionMS), + PPSSPP_VERSION[2] = HIWORD(info->dwFileVersionLS), + PPSSPP_VERSION[3] = LOWORD(info->dwFileVersionLS); + + } + else + ConsoleOutput("vnreng: failed to get PPSSPP version"); + delete[] buf; + + } InsertPPSSPPHLEHooks(); diff --git a/vnr/winversion/winversion.cc b/vnr/winversion/winversion.cc deleted file mode 100644 index 4a1a3ad..0000000 --- a/vnr/winversion/winversion.cc +++ /dev/null @@ -1,30 +0,0 @@ -// winversion.cc -// 9/5/2014 jichi - -#include "winversion/winversion.h" -#include - -// http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file -bool WinVersion::queryFileVersion(const wchar_t *path, int ver[]) -{ - bool ok = false; - // get the version info for the file requested - if (DWORD dwSize = ::GetFileVersionInfoSizeW(path, nullptr)) { - UINT len = 0; - BYTE *buf = new BYTE[dwSize]; - VS_FIXEDFILEINFO *info = nullptr; - ok = ::GetFileVersionInfoW(path, 0, dwSize, buf) - && ::VerQueryValueW(buf, L"\\", (LPVOID*)&info, &len) - && info; - if (ok) { - ver[0] = HIWORD(info->dwFileVersionMS), - ver[1] = LOWORD(info->dwFileVersionMS), - ver[2] = HIWORD(info->dwFileVersionLS), - ver[3] = LOWORD(info->dwFileVersionLS); - } - delete[] buf; - } - return ok; -} - -// EOF diff --git a/vnr/winversion/winversion.h b/vnr/winversion/winversion.h deleted file mode 100644 index 4bff0d0..0000000 --- a/vnr/winversion/winversion.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -// winversion.h -// 9/5/2014 jichi - -#ifdef _MSC_VER -# include // for wchar_t -#endif // _MSC_VER - -namespace WinVersion { - -bool queryFileVersion(const wchar_t *path, int ver[4]); - -} // namespace WinVersion - -// EOF