Browse Source

Moved QueryVersion API to separate file

pull/277/head
Valentin Radu 4 years ago
parent
commit
9d3d916645
  1. 7
      ExplorerPatcher/ExplorerPatcher.vcxproj
  2. 3
      ExplorerPatcher/ExplorerPatcher.vcxproj.filters
  3. 35
      ExplorerPatcher/queryversion.h
  4. 30
      ExplorerPatcher/utility.c
  5. 3
      ExplorerPatcher/utility.h

7
ExplorerPatcher/ExplorerPatcher.vcxproj

@ -213,7 +213,11 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_window.c" /> <ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_window.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_WindowHelpers.c"> <ClCompile Include="..\libs\sws\SimpleWindowSwitcher\sws_WindowHelpers.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -287,6 +291,7 @@
<ClInclude Include="HideExplorerSearchBar.h" /> <ClInclude Include="HideExplorerSearchBar.h" />
<ClInclude Include="hooking.h" /> <ClInclude Include="hooking.h" />
<ClInclude Include="ep_private.h" /> <ClInclude Include="ep_private.h" />
<ClInclude Include="queryversion.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="SettingsMonitor.h" /> <ClInclude Include="SettingsMonitor.h" />
<ClInclude Include="StartMenu.h" /> <ClInclude Include="StartMenu.h" />

3
ExplorerPatcher/ExplorerPatcher.vcxproj.filters

@ -105,6 +105,9 @@
<ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_utility.h"> <ClInclude Include="..\libs\sws\SimpleWindowSwitcher\sws_utility.h">
<Filter>Header Files\sws</Filter> <Filter>Header Files\sws</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="queryversion.h">
<Filter>Header Files\internal</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="ExplorerPatcher.rc"> <ResourceCompile Include="ExplorerPatcher.rc">

35
ExplorerPatcher/queryversion.h

@ -0,0 +1,35 @@
#ifndef _H_QUERYVERSION_H_
#define _H_QUERYVERSION_H_
#include <Windows.h>
#pragma comment(lib, "Version.lib")
inline void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost, DWORD* dwSecondLeft, DWORD* dwSecondRight, DWORD* dwRightMost)
{
HRSRC hResInfo;
DWORD dwSize;
HGLOBAL hResData;
LPVOID pRes, pResCopy;
UINT uLen;
VS_FIXEDFILEINFO* lpFfi;
hResInfo = FindResource(hModule, MAKEINTRESOURCE(Resource), RT_VERSION);
dwSize = SizeofResource(hModule, hResInfo);
hResData = LoadResource(hModule, hResInfo);
pRes = LockResource(hResData);
pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
CopyMemory(pResCopy, pRes, dwSize);
FreeResource(hResData);
VerQueryValue(pResCopy, TEXT("\\"), (LPVOID*)&lpFfi, &uLen);
DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
*dwLeftMost = HIWORD(dwFileVersionMS);
*dwSecondLeft = LOWORD(dwFileVersionMS);
*dwSecondRight = HIWORD(dwFileVersionLS);
*dwRightMost = LOWORD(dwFileVersionLS);
LocalFree(pResCopy);
}
#endif

30
ExplorerPatcher/utility.c

@ -387,36 +387,6 @@ POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOO
return point; return point;
} }
void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD* dwLeftMost, DWORD* dwSecondLeft, DWORD* dwSecondRight, DWORD* dwRightMost)
{
HRSRC hResInfo;
DWORD dwSize;
HGLOBAL hResData;
LPVOID pRes, pResCopy;
UINT uLen;
VS_FIXEDFILEINFO* lpFfi;
hResInfo = FindResource(hModule, MAKEINTRESOURCE(Resource), RT_VERSION);
dwSize = SizeofResource(hModule, hResInfo);
hResData = LoadResource(hModule, hResInfo);
pRes = LockResource(hResData);
pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
CopyMemory(pResCopy, pRes, dwSize);
FreeResource(hResData);
VerQueryValue(pResCopy, TEXT("\\"), (LPVOID*)&lpFfi, &uLen);
DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
*dwLeftMost = HIWORD(dwFileVersionMS);
*dwSecondLeft = LOWORD(dwFileVersionMS);
*dwSecondRight = HIWORD(dwFileVersionLS);
*dwRightMost = LOWORD(dwFileVersionLS);
LocalFree(pResCopy);
}
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize) void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize)
{ {
void* ok = NULL; void* ok = NULL;

3
ExplorerPatcher/utility.h

@ -14,6 +14,7 @@
#pragma comment(lib, "Rstrtmgr.lib") #pragma comment(lib, "Rstrtmgr.lib")
#define _LIBVALINET_INCLUDE_UNIVERSAL #define _LIBVALINET_INCLUDE_UNIVERSAL
#include <valinet/universal/toast/toast.h> #include <valinet/universal/toast/toast.h>
#include "queryversion.h"
#define APPID L"Microsoft.Windows.Explorer" #define APPID L"Microsoft.Windows.Explorer"
#define REGPATH "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher" #define REGPATH "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ExplorerPatcher"
@ -104,8 +105,6 @@ __declspec(dllexport) CALLBACK ZZLaunchExplorerDelayed(HWND hWnd, HINSTANCE hIns
POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOOL bAdjust); POINT GetDefaultWinXPosition(BOOL bUseRcWork, BOOL* lpBottom, BOOL* lpRight, BOOL bAdjust);
void QueryVersionInfo(HMODULE hModule, WORD Resource, DWORD*, DWORD*, DWORD*, DWORD*);
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))

Loading…
Cancel
Save