Merge branch 'Mauler125:master' into master

This commit is contained in:
PixieCore 2021-08-03 17:33:01 +02:00 committed by GitHub
commit e8c339083e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 241 additions and 57 deletions

View File

@ -99,45 +99,45 @@ extern "C" {
// ONCE at the end of your program.
MH_STATUS WINAPI MH_Uninitialize(VOID);
// Creates a Hook for the specified target function, in disabled state.
// Creates a hook for the specified target function, in disabled state.
// Parameters:
// pTarget [in] A pointer to the target function, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
// pTarget [in] A pointer to the target function, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal);
// Creates a Hook for the specified API function, in disabled state.
// Creates a hook for the specified API function, in disabled state.
// Parameters:
// pszModule [in] A pointer to the loaded module name which contains the
// target function.
// pszTarget [in] A pointer to the target function name, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
// pszModule [in] A pointer to the loaded module name which contains the
// target function.
// pszProcName [in] A pointer to the target function name, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
MH_STATUS WINAPI MH_CreateHookApi(
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal);
// Creates a Hook for the specified API function, in disabled state.
// Creates a hook for the specified API function, in disabled state.
// Parameters:
// pszModule [in] A pointer to the loaded module name which contains the
// target function.
// pszTarget [in] A pointer to the target function name, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
// ppTarget [out] A pointer to the target function, which will be used
// with other functions.
// This parameter can be NULL.
// pszModule [in] A pointer to the loaded module name which contains the
// target function.
// pszProcName [in] A pointer to the target function name, which will be
// overridden by the detour function.
// pDetour [in] A pointer to the detour function, which will override
// the target function.
// ppOriginal [out] A pointer to the trampoline function, which will be
// used to call the original target function.
// This parameter can be NULL.
// ppTarget [out] A pointer to the target function, which will be used
// with other functions.
// This parameter can be NULL.
MH_STATUS WINAPI MH_CreateHookApiEx(
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget);
@ -183,4 +183,3 @@ extern "C" {
#ifdef __cplusplus
}
#endif

Binary file not shown.

View File

@ -0,0 +1,8 @@
Tsuda Kageyu <tsuda.kageyu@gmail.com>
Creator, maintainer
Michael Maltsev <leahcimmar@gmail.com>
Added "Queue" functions. A lot of bug fixes.
Andrey Unis <uniskz@gmail.com>
Rewrote the hook engine in plain C.

View File

@ -0,0 +1,81 @@
MinHook - The Minimalistic API Hooking Library for x64/x86
Copyright (C) 2009-2017 Tsuda Kageyu.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
Portions of this software are Copyright (c) 2008-2009, Vyacheslav Patkov.
================================================================================
Hacker Disassembler Engine 32 C
Copyright (c) 2008-2009, Vyacheslav Patkov.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
Hacker Disassembler Engine 64 C
Copyright (c) 2008-2009, Vyacheslav Patkov.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,16 +1,20 @@
#include <string>
#include <stdio.h>
#include <Windows.h>
#include <detours.h>
#include "main.h"
/*-----------------------------------------------------------------------------
* _main.cpp
*-----------------------------------------------------------------------------*/
//----------------------------------------------------------------------------
// Print the error message to the console if any
//----------------------------------------------------------------------------
void PrintLastError()
{
///////////////////////////////////////////////////////////////////////////
// Get the error message, if any.
DWORD errorMessageID = ::GetLastError();
if (errorMessageID == 0)
{
@ -25,19 +29,21 @@ void PrintLastError()
LocalFree(messageBuffer);
}
bool LaunchR5Apex()
//-----------------------------------------------------------------------------
// Purpose case switch:
// * Launch the game in user specified mode and state.
// * Load specified command line arguments from a file on the disk.
// * Format the file paths for the game exe and specified hook dll.
//-----------------------------------------------------------------------------
bool LaunchR5Apex(LAUNCHMODE lMode, LAUNCHSTATE lState)
{
BOOL result;
FILE* sLaunchParams;
CHAR sArgumentBuffer[1024] = { 0 };
CHAR sCommandDirectory[MAX_PATH];
LPSTR sCommandLine = sCommandDirectory;
///////////////////////////////////////////////////////////////////////////
// '+exec autoexec -dev -fnf -noplatform'
fopen_s(&sLaunchParams, "platform\\cfg\\startup_debug.cfg", "r");
BOOL result;
CHAR sDevDll[MAX_PATH];
CHAR sGameExe[MAX_PATH];
CHAR sGameDirectory[MAX_PATH];
@ -49,24 +55,69 @@ bool LaunchR5Apex()
// Initialize the startup info structure.
StartupInfo.cb = sizeof(STARTUPINFO);
///////////////////////////////////////////////////////////////////////////
// Load command line arguments from a file on the disk.
if (sLaunchParams)
GetCurrentDirectory(MAX_PATH, sGameDirectory);
switch (lMode)
{
while (fread(sArgumentBuffer, sizeof(sArgumentBuffer), 1, sLaunchParams) != NULL)
case LAUNCHMODE::LM_DEDI:
{
fclose(sLaunchParams);
fopen_s(&sLaunchParams, "platform\\cfg\\startup_dedi.cfg", "r");
if (sLaunchParams)
{
while (fread(sArgumentBuffer, sizeof(sArgumentBuffer), 1, sLaunchParams) != NULL)
{
fclose(sLaunchParams);
}
}
snprintf(sGameExe, sizeof(sGameExe), "%s\\r5apex.exe", sGameDirectory);
snprintf(sDevDll, sizeof(sDevDll), "%s\\dedicated.dll", sGameDirectory);
snprintf(sCommandLine, sizeof(sCommandDirectory), "%s\\r5apex.exe %s", sGameDirectory, sArgumentBuffer);
printf("*** LAUNCHING DEDICATED SERVER ***\n");
break;
}
case LAUNCHMODE::LM_DEBUG:
{
fopen_s(&sLaunchParams, "platform\\cfg\\startup_debug.cfg", "r");
if (sLaunchParams)
{
while (fread(sArgumentBuffer, sizeof(sArgumentBuffer), 1, sLaunchParams) != NULL)
{
fclose(sLaunchParams);
}
}
snprintf(sGameExe, sizeof(sGameExe), "%s\\r5apex.exe", sGameDirectory);
snprintf(sDevDll, sizeof(sDevDll), "%s\\r5dev.dll", sGameDirectory);
snprintf(sCommandLine, sizeof(sCommandDirectory), "%s\\r5apex.exe %s", sGameDirectory, sArgumentBuffer);
printf("*** LAUNCHING GAME [DEBUG] ***\n");
break;
}
case LAUNCHMODE::LM_GAME:
{
fopen_s(&sLaunchParams, "platform\\cfg\\startup_retail.cfg", "r");
if (sLaunchParams)
{
while (fread(sArgumentBuffer, sizeof(sArgumentBuffer), 1, sLaunchParams) != NULL)
{
fclose(sLaunchParams);
}
}
snprintf(sGameExe, sizeof(sGameExe), "%s\\r5apex.exe", sGameDirectory);
snprintf(sDevDll, sizeof(sDevDll), "%s\\r5detours.dll", sGameDirectory);
snprintf(sCommandLine, sizeof(sCommandDirectory), "%s\\r5apex.exe %s", sGameDirectory, sArgumentBuffer);
printf("*** LAUNCHING GAME [RETAIL] ***\n");
break;
}
default:
{
printf("*** ERROR: NO LAUNCHMODE SPECIFIED ***\n");
return false;
}
}
///////////////////////////////////////////////////////////////////////////
// Format the file paths for the game exe and dll.
GetCurrentDirectory(MAX_PATH, sGameDirectory);
snprintf(sGameExe, sizeof(sGameExe), "%s\\r5apex.exe", sGameDirectory);
snprintf(sDevDll, sizeof(sDevDll), "%s\\r5detours.dll", sGameDirectory);
snprintf(sCommandLine, sizeof(sCommandDirectory), "%s\\r5apex.exe %s", sGameDirectory, sArgumentBuffer);
printf("Launching Apex Dev...\n");
// Print the filepaths and arguments.
printf(" - CWD: %s\n", sGameDirectory);
printf(" - EXE: %s\n", sGameExe);
printf(" - DLL: %s\n", sDevDll);
@ -122,7 +173,23 @@ bool LaunchR5Apex()
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[], char* envp[])
{
LaunchR5Apex();
Sleep(1000);
return 0;
}
for (int i = 1; i < argc; ++i)
{
std::string arg = argv[i];
if ((arg == "-dedicated") || (arg == "-dedi"))
{
LaunchR5Apex(LAUNCHMODE::LM_DEDI, LAUNCHSTATE::LS_CHEATS);
Sleep(2000);
return EXIT_SUCCESS;
}
if ((arg == "-debug") || (arg == "-dbg"))
{
LaunchR5Apex(LAUNCHMODE::LM_DEBUG, LAUNCHSTATE::LS_CHEATS);
Sleep(2000);
return EXIT_SUCCESS;
}
}
LaunchR5Apex(LAUNCHMODE::LM_GAME, LAUNCHSTATE::LS_CHEATS);
Sleep(2000);
return EXIT_SUCCESS;
}

21
r5launcher/main.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
//-----------------------------------------------------------------------------
// Launch and inject specified dll based on launchmode
//-----------------------------------------------------------------------------
enum class LAUNCHMODE : int
{
LM_GAME, // Dev DLL
LM_DEDI, // Dedi DLL
LM_DEBUG // Debug DLL
};
//-----------------------------------------------------------------------------
// [TODO] Launch with FCVAR_DEVELOPMENTONLY and FCVAR_CHEATS disabled/enabled
//-----------------------------------------------------------------------------
enum class LAUNCHSTATE : int
{
LS_NOCHEATS, // Disabled cheats
LS_CHEATS, // Enable cheats
LS_DEBUG // Enable debug
};

View File

@ -165,6 +165,9 @@
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -19,4 +19,9 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>