Permalink
Please sign in to comment.
Showing
with
340 additions
and 1 deletion.
- +11 −1 Revive.sln
- +175 −0 RevivePlatform/RevivePlatform.vcxproj
- +22 −0 RevivePlatform/RevivePlatform.vcxproj.filters
- +132 −0 RevivePlatform/main.cpp
12
Revive.sln
| @@ -0,0 +1,175 @@ | ||
| +<?xml version="1.0" encoding="utf-8"?> | ||
| +<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| + <ItemGroup Label="ProjectConfigurations"> | ||
| + <ProjectConfiguration Include="Debug|Win32"> | ||
| + <Configuration>Debug</Configuration> | ||
| + <Platform>Win32</Platform> | ||
| + </ProjectConfiguration> | ||
| + <ProjectConfiguration Include="Release|Win32"> | ||
| + <Configuration>Release</Configuration> | ||
| + <Platform>Win32</Platform> | ||
| + </ProjectConfiguration> | ||
| + <ProjectConfiguration Include="Debug|x64"> | ||
| + <Configuration>Debug</Configuration> | ||
| + <Platform>x64</Platform> | ||
| + </ProjectConfiguration> | ||
| + <ProjectConfiguration Include="Release|x64"> | ||
| + <Configuration>Release</Configuration> | ||
| + <Platform>x64</Platform> | ||
| + </ProjectConfiguration> | ||
| + </ItemGroup> | ||
| + <PropertyGroup Label="Globals"> | ||
| + <ProjectGuid>{EC5504AD-0357-4FBF-9B3A-1CD89C2BDA21}</ProjectGuid> | ||
| + <Keyword>Win32Proj</Keyword> | ||
| + <RootNamespace>RevivePlatform</RootNamespace> | ||
| + <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> | ||
| + </PropertyGroup> | ||
| + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
| + <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| + <UseDebugLibraries>true</UseDebugLibraries> | ||
| + <PlatformToolset>v140</PlatformToolset> | ||
| + <CharacterSet>Unicode</CharacterSet> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
| + <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| + <UseDebugLibraries>false</UseDebugLibraries> | ||
| + <PlatformToolset>v140</PlatformToolset> | ||
| + <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| + <CharacterSet>Unicode</CharacterSet> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
| + <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| + <UseDebugLibraries>true</UseDebugLibraries> | ||
| + <PlatformToolset>v140</PlatformToolset> | ||
| + <CharacterSet>Unicode</CharacterSet> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
| + <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| + <UseDebugLibraries>false</UseDebugLibraries> | ||
| + <PlatformToolset>v140</PlatformToolset> | ||
| + <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| + <CharacterSet>Unicode</CharacterSet> | ||
| + </PropertyGroup> | ||
| + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| + <ImportGroup Label="ExtensionSettings"> | ||
| + </ImportGroup> | ||
| + <ImportGroup Label="Shared"> | ||
| + </ImportGroup> | ||
| + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| + </ImportGroup> | ||
| + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| + </ImportGroup> | ||
| + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| + </ImportGroup> | ||
| + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| + </ImportGroup> | ||
| + <PropertyGroup Label="UserMacros" /> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| + <LinkIncremental>true</LinkIncremental> | ||
| + <OutDir>$(SolutionDir)$(Configuration)\Revive\x86\</OutDir> | ||
| + <TargetName>LibOVRPlatform32_1</TargetName> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| + <LinkIncremental>true</LinkIncremental> | ||
| + <OutDir>$(SolutionDir)$(Configuration)\Revive\x64\</OutDir> | ||
| + <TargetName>LibOVRPlatform64_1</TargetName> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| + <LinkIncremental>false</LinkIncremental> | ||
| + <OutDir>$(SolutionDir)$(Configuration)\Revive\x86\</OutDir> | ||
| + <TargetName>LibOVRPlatform32_1</TargetName> | ||
| + </PropertyGroup> | ||
| + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| + <LinkIncremental>false</LinkIncremental> | ||
| + <OutDir>$(SolutionDir)$(Configuration)\Revive\x64\</OutDir> | ||
| + <TargetName>LibOVRPlatform64_1</TargetName> | ||
| + </PropertyGroup> | ||
| + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| + <ClCompile> | ||
| + <PrecompiledHeader> | ||
| + </PrecompiledHeader> | ||
| + <WarningLevel>Level3</WarningLevel> | ||
| + <Optimization>Disabled</Optimization> | ||
| + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;REVIVEPLATFORM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| + <SDLCheck>true</SDLCheck> | ||
| + <AdditionalIncludeDirectories>..\minhook\include</AdditionalIncludeDirectories> | ||
| + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> | ||
| + </ClCompile> | ||
| + <Link> | ||
| + <SubSystem>Windows</SubSystem> | ||
| + <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| + </Link> | ||
| + </ItemDefinitionGroup> | ||
| + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| + <ClCompile> | ||
| + <PrecompiledHeader> | ||
| + </PrecompiledHeader> | ||
| + <WarningLevel>Level3</WarningLevel> | ||
| + <Optimization>Disabled</Optimization> | ||
| + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;REVIVEPLATFORM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| + <SDLCheck>true</SDLCheck> | ||
| + <AdditionalIncludeDirectories>..\minhook\include</AdditionalIncludeDirectories> | ||
| + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> | ||
| + </ClCompile> | ||
| + <Link> | ||
| + <SubSystem>Windows</SubSystem> | ||
| + <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| + </Link> | ||
| + </ItemDefinitionGroup> | ||
| + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| + <ClCompile> | ||
| + <WarningLevel>Level3</WarningLevel> | ||
| + <PrecompiledHeader> | ||
| + </PrecompiledHeader> | ||
| + <Optimization>MaxSpeed</Optimization> | ||
| + <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| + <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;REVIVEPLATFORM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| + <SDLCheck>true</SDLCheck> | ||
| + <AdditionalIncludeDirectories>..\minhook\include</AdditionalIncludeDirectories> | ||
| + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
| + </ClCompile> | ||
| + <Link> | ||
| + <SubSystem>Windows</SubSystem> | ||
| + <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
| + <OptimizeReferences>true</OptimizeReferences> | ||
| + <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| + </Link> | ||
| + </ItemDefinitionGroup> | ||
| + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| + <ClCompile> | ||
| + <WarningLevel>Level3</WarningLevel> | ||
| + <PrecompiledHeader> | ||
| + </PrecompiledHeader> | ||
| + <Optimization>MaxSpeed</Optimization> | ||
| + <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| + <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| + <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;REVIVEPLATFORM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| + <SDLCheck>true</SDLCheck> | ||
| + <AdditionalIncludeDirectories>..\minhook\include</AdditionalIncludeDirectories> | ||
| + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
| + </ClCompile> | ||
| + <Link> | ||
| + <SubSystem>Windows</SubSystem> | ||
| + <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
| + <OptimizeReferences>true</OptimizeReferences> | ||
| + <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| + </Link> | ||
| + </ItemDefinitionGroup> | ||
| + <ItemGroup> | ||
| + <ClCompile Include="main.cpp" /> | ||
| + </ItemGroup> | ||
| + <ItemGroup> | ||
| + <ProjectReference Include="..\minhook\build\VC15\libMinHook.vcxproj"> | ||
| + <Project>{f142a341-5ee0-442d-a15f-98ae9b48dbae}</Project> | ||
| + </ProjectReference> | ||
| + </ItemGroup> | ||
| + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
| + <ImportGroup Label="ExtensionTargets"> | ||
| + </ImportGroup> | ||
| +</Project> |
| @@ -0,0 +1,22 @@ | ||
| +<?xml version="1.0" encoding="utf-8"?> | ||
| +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| + <ItemGroup> | ||
| + <Filter Include="Source Files"> | ||
| + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
| + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
| + </Filter> | ||
| + <Filter Include="Header Files"> | ||
| + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
| + <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
| + </Filter> | ||
| + <Filter Include="Resource Files"> | ||
| + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
| + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
| + </Filter> | ||
| + </ItemGroup> | ||
| + <ItemGroup> | ||
| + <ClCompile Include="main.cpp"> | ||
| + <Filter>Source Files</Filter> | ||
| + </ClCompile> | ||
| + </ItemGroup> | ||
| +</Project> |
| @@ -0,0 +1,132 @@ | ||
| +#include <Windows.h> | ||
| +#include <stdlib.h> | ||
| +#include <stdio.h> | ||
| +#include <stdint.h> | ||
| + | ||
| +#include "MinHook.h" | ||
| + | ||
| +HMODULE PlatformModule; | ||
| +WCHAR ovrModuleName[MAX_PATH]; | ||
| + | ||
| +typedef uint64_t ovrID; | ||
| +typedef uint64_t ovrRequest; | ||
| +typedef struct ovrMessage *ovrMessageHandle; | ||
| +typedef enum ovrMessageType_ ovrMessageType; | ||
| +typedef struct ovrError *ovrErrorHandle; | ||
| + | ||
| +typedef void(__stdcall* _FreeMessage)(ovrMessageHandle); | ||
| +typedef bool(__stdcall* _IsError)(const ovrMessageHandle); | ||
| +typedef ovrMessageType(__stdcall* _GetType)(const ovrMessageHandle); | ||
| +typedef ovrErrorHandle(__stdcall* _GetError)(const ovrMessageHandle); | ||
| +typedef const char*(__stdcall* _GetMessage)(const ovrErrorHandle); | ||
| +typedef ovrID(__stdcall* _GetLoggedInUserID)(void); | ||
| + | ||
| +_FreeMessage TrueFreeMessage = NULL; | ||
| +_IsError TrueIsError = NULL; | ||
| +_GetType TrueGetType = NULL; | ||
| +_GetError TrueGetError = NULL; | ||
| +_GetMessage TrueGetMessage = NULL; | ||
| +_GetLoggedInUserID TrueGetLoggedInUserID = NULL; | ||
| + | ||
| +typedef HMODULE(__stdcall* _GetModuleHandle)(LPCWSTR lpModuleName); | ||
| +_GetModuleHandle TrueGetModuleHandle; | ||
| + | ||
| +void GetRuntimePath(LPWSTR path, DWORD size) | ||
| +{ | ||
| + HKEY oculusKey; | ||
| + RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Oculus VR, LLC\\Oculus", 0, KEY_READ | KEY_WOW64_32KEY, &oculusKey); | ||
| + RegQueryValueEx(oculusKey, L"Base", NULL, NULL, (PBYTE)path, &size); | ||
| + wcsncat(path, L"Support\\oculus-runtime\\", size); | ||
| +} | ||
| + | ||
| +HMODULE WINAPI HookGetModuleHandle(LPCWSTR lpModuleName) | ||
| +{ | ||
| + if (lpModuleName && wcscmp(lpModuleName, ovrModuleName) == 0) { | ||
| + return PlatformModule; | ||
| + } | ||
| + | ||
| + return TrueGetModuleHandle(lpModuleName); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) ovrRequest ovr_Entitlement_GetIsViewerEntitled() | ||
| +{ | ||
| + // Sorry, we can't verify your entitlement without an Oculus Rift... | ||
| + return 0; | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) void ovr_FreeMessage(ovrMessageHandle obj) | ||
| +{ | ||
| + if (!TrueFreeMessage) | ||
| + TrueFreeMessage = (_FreeMessage)GetProcAddress(PlatformModule, "ovr_FreeMessage"); | ||
| + | ||
| + TrueFreeMessage(obj); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) bool ovr_Message_IsError(const ovrMessageHandle obj) | ||
| +{ | ||
| + if (!TrueIsError) | ||
| + TrueIsError = (_IsError)GetProcAddress(PlatformModule, "ovr_Message_IsError"); | ||
| + | ||
| + return TrueIsError(obj); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) ovrMessageType ovr_Message_GetType(const ovrMessageHandle obj) | ||
| +{ | ||
| + if (!TrueGetType) | ||
| + TrueGetType = (_GetType)GetProcAddress(PlatformModule, "ovr_Message_GetType"); | ||
| + | ||
| + return TrueGetType(obj); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) ovrErrorHandle ovr_Message_GetError(const ovrMessageHandle obj) | ||
| +{ | ||
| + if (!TrueGetError) | ||
| + TrueGetError = (_GetError)GetProcAddress(PlatformModule, "ovr_Message_GetError"); | ||
| + | ||
| + return TrueGetError(obj); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) const char * ovr_Error_GetMessage(const ovrErrorHandle obj) | ||
| +{ | ||
| + if (!TrueGetMessage) | ||
| + TrueGetMessage = (_GetMessage)GetProcAddress(PlatformModule, "ovr_Error_GetMessage"); | ||
| + | ||
| + return TrueGetMessage(obj); | ||
| +} | ||
| + | ||
| +extern "C" __declspec(dllexport) ovrID ovr_GetLoggedInUserID() | ||
| +{ | ||
| + if (!TrueGetLoggedInUserID) | ||
| + TrueGetLoggedInUserID = (_GetLoggedInUserID)GetProcAddress(PlatformModule, "ovr_GetLoggedInUserID"); | ||
| + | ||
| + return TrueGetLoggedInUserID(); | ||
| +} | ||
| + | ||
| +BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) | ||
| +{ | ||
| + WCHAR path[MAX_PATH]; | ||
| +#if defined(_WIN64) | ||
| + const char* pBitDepth = "64"; | ||
| +#else | ||
| + const char* pBitDepth = "32"; | ||
| +#endif | ||
| + switch (ul_reason_for_call) | ||
| + { | ||
| + case DLL_PROCESS_ATTACH: | ||
| + MH_Initialize(); | ||
| + MH_CreateHook(GetModuleHandleW, HookGetModuleHandle, (PVOID*)&TrueGetModuleHandle); | ||
| + MH_EnableHook(GetModuleHandleW); | ||
| + swprintf(ovrModuleName, MAX_PATH, L"LibOVRPlatform%hs_1.dll", pBitDepth); | ||
| + GetRuntimePath(path, MAX_PATH); | ||
| + wcsncat(path, ovrModuleName, MAX_PATH); | ||
| + PlatformModule = LoadLibraryW(path); | ||
| + break; | ||
| + case DLL_PROCESS_DETACH: | ||
| + MH_RemoveHook(GetModuleHandleW); | ||
| + MH_Uninitialize(); | ||
| + break; | ||
| + default: | ||
| + break; | ||
| + } | ||
| + return TRUE; | ||
| +} |
0 comments on commit
3bca929