Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
pavledev committed Sep 26, 2021
1 parent d562f7c commit cdc9da2
Show file tree
Hide file tree
Showing 1,948 changed files with 60,397 additions and 36,370 deletions.
749 changes: 395 additions & 354 deletions HitmanAbsolutionSDK.vcxproj

Large diffs are not rendered by default.

1,991 changes: 1,054 additions & 937 deletions HitmanAbsolutionSDK.vcxproj.filters

Large diffs are not rendered by default.

109 changes: 36 additions & 73 deletions dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
#pragma warning(disable : 4005)
#pragma warning(disable : 26812)

#include <Windows.h>
#include <iostream>
#include <vector>
#include <fstream>
#include <cstdarg>
#include <Psapi.h>
#include <TlHelp32.h>
#include <mutex>

#include "MinHook.h"
#include "imgui_impl_dx11.h"
#include "imgui_impl_win32.h"
#include "InputHook.h"
#include "ZRenderManager.h"
#include "ZRenderDevice.h"
#include "ApplicationHooks.h"
#include "ZDebugConsoleHooks.h"
#include "ZInputActionManager.h"
#include "Menu.h"
#include "Globals.h"
#include "Singletons.h"
#include "BaseAddresses.h"
#include "Mods.h"
#include "HM5DebugConsole.h"

using namespace std;
#include "imgui.h"

Menu menu;
InputHook inputHook;
Expand All @@ -37,17 +32,17 @@ const int openMenuKey = VK_F9;
static once_flag isInitialized;

static bool gravityGunEnabled;
static bool killNearbyActors;
static bool displayNearbyActorsInfo;
static bool killNearbyActorsEnabled;
static bool displayNearbyActorsInfoEnabled;

void __fastcall ZRenderDevicePresentHook(ZRenderDevice* pThis)
void __fastcall ZRenderDevicePresentHook(ZRenderDevice* renderDevice)
{
call_once(isInitialized, [&]()
{
ImGui::CreateContext();

ImGui_ImplWin32_Init(ApplicationHooks::hwnd);
ImGui_ImplDX11_Init(pThis->m_pDirect3DDevice, pThis->m_pDeviceContextImmediate);
ImGui_ImplDX11_Init(renderDevice->m_pDirect3DDevice, renderDevice->m_pDeviceContextImmediate);

inputHook.Init(ApplicationHooks::hwnd);
});
Expand All @@ -56,7 +51,7 @@ void __fastcall ZRenderDevicePresentHook(ZRenderDevice* pThis)
{
menu.isOpen = !menu.isOpen;

static ZInputActionManager* inputActionManager = *reinterpret_cast<ZInputActionManager**>(Globals::g_pInputActionManagerSingleton);
static ZInputActionManager* inputActionManager = Singletons::GetInputActionManager();

if (inputActionManager)
{
Expand All @@ -73,23 +68,7 @@ void __fastcall ZRenderDevicePresentHook(ZRenderDevice* pThis)

menu.Render();

pOriginalZRenderDevicePresent(pThis);
}

typedef void(__thiscall* InitPatchReader)(void* pThis, ZString* sPatchPath);
InitPatchReader pOriginalInitPatchReader;

void __fastcall InitPatchReaderHook(void* pThis, int padding, ZString* sPatchPath)
{
pOriginalInitPatchReader(pThis, sPatchPath);
}

typedef void(__thiscall* ResourceReady)(void* pThis, ZRuntimeResourceID id, ZResourceStub* pStub, int nPriority, ZString sFileName, unsigned int nFileOffset);
ResourceReady pOriginalResourceReady;

void __fastcall ResourceReadyHook(void* pThis, int padding, ZRuntimeResourceID id, ZResourceStub* pStub, int nPriority, ZString sFileName, unsigned int nFileOffset)
{
pOriginalResourceReady(pThis, id, pStub, nPriority, sFileName, nFileOffset);
pOriginalZRenderDevicePresent(renderDevice);
}

void InitializeGlobalVariables()
Expand Down Expand Up @@ -216,19 +195,35 @@ void GetDLLAddresses()
{
uintptr_t engine = reinterpret_cast<uintptr_t>(GetModuleHandle(nullptr));
uintptr_t hitman5Dll = reinterpret_cast<uintptr_t>(GetModuleHandle(L"hitman5Dll.dll"));
uintptr_t runtimeRenderDll = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.render.dll"));
uintptr_t runtimeRender = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.render.dll"));
uintptr_t runtimeAnimation = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.render.dll"));
uintptr_t runtimeInputDll = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.input.dll"));
uintptr_t runtimePathFinder = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.pathfinder.dll"));
uintptr_t runtimePathfinder = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.pathfinder.dll"));
uintptr_t runtimeEntity = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.entity.dll"));
uintptr_t runtimeResource = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.resource.dll"));
uintptr_t runtimePhysics = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.physics.dll"));
uintptr_t runtimeFacefx = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.facefx.dll"));
uintptr_t runtimeMorpheme = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.morpheme.dll"));
uintptr_t runtimePhysicsPhysx = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.physics.physx.dll"));
uintptr_t runtimeSound = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.sound.dll"));
uintptr_t runtimeCrowds = reinterpret_cast<uintptr_t>(GetModuleHandle(L"runtime.crowds.dll"));
uintptr_t systemIO = reinterpret_cast<uintptr_t>(GetModuleHandle(L"system.io.dll"));

BaseAddresses::engine = engine;
BaseAddresses::hitman5Dll = hitman5Dll;
BaseAddresses::runtimeRenderDll = runtimeRenderDll;
BaseAddresses::runtimeRender = runtimeRender;
BaseAddresses::runtimeAnimation = runtimeAnimation;
BaseAddresses::runtimeInputDll = runtimeInputDll;
BaseAddresses::runtimePathFinder = runtimePathFinder;
BaseAddresses::runtimePathfinder = runtimePathfinder;
BaseAddresses::runtimeEntity = runtimeEntity;
BaseAddresses::runtimeResource = runtimeResource;
BaseAddresses::runtimePhysics = runtimePhysics;
BaseAddresses::runtimeFacefx = runtimeFacefx;
BaseAddresses::runtimeMorpheme = runtimeMorpheme;
BaseAddresses::runtimePhysicsPhysx = runtimePhysicsPhysx;
BaseAddresses::runtimeSound = runtimeSound;
BaseAddresses::runtimeCrowds = runtimeCrowds;
BaseAddresses::systemIO = systemIO;
}

DWORD WINAPI MainThread(HMODULE hModule)
Expand All @@ -245,11 +240,11 @@ DWORD WINAPI MainThread(HMODULE hModule)
GetDLLAddresses();
InitializeGlobalVariables();

ZRenderDevicePresent pZRenderDevicePresent = reinterpret_cast<ZRenderDevicePresent>(BaseAddresses::runtimeRenderDll + 0xBB5A0);
ZRenderDevicePresent pZRenderDevicePresent = reinterpret_cast<ZRenderDevicePresent>(BaseAddresses::runtimeRender + 0xBB5A0);

if (MH_CreateHook(reinterpret_cast<LPVOID>(pZRenderDevicePresent), reinterpret_cast<LPVOID>(ZRenderDevicePresentHook), reinterpret_cast<LPVOID*>(&pOriginalZRenderDevicePresent)) != MH_OK)
{
HM5_LOG("IFailed to create ZRenderDevicePresent hook.\n");
HM5_LOG("Failed to create ZRenderDevicePresent hook.\n");

return 1;
}
Expand All @@ -261,38 +256,6 @@ DWORD WINAPI MainThread(HMODULE hModule)
return 1;
}

InitPatchReader pInitPatchReader = reinterpret_cast<InitPatchReader>(BaseAddresses::runtimeResource + 0x374F0);

if (MH_CreateHook(reinterpret_cast<LPVOID>(pInitPatchReader), reinterpret_cast<LPVOID>(InitPatchReaderHook), reinterpret_cast<LPVOID*>(&pOriginalInitPatchReader)) != MH_OK)
{
HM5_LOG("IFailed to create InitPatchReader hook.\n");

return 1;
}

if (MH_EnableHook(reinterpret_cast<LPVOID>(pInitPatchReader)) != MH_OK)
{
HM5_LOG("Failed to enable InitPatchReader hook.\n");

return 1;
}

ResourceReady pResourceReady = reinterpret_cast<ResourceReady>(BaseAddresses::runtimeResource + 0x212B0);

if (MH_CreateHook(reinterpret_cast<LPVOID>(pResourceReady), reinterpret_cast<LPVOID>(ResourceReadyHook), reinterpret_cast<LPVOID*>(&pOriginalResourceReady)) != MH_OK)
{
HM5_LOG("IFailed to create ResourceReady hook.\n");

return 1;
}

if (MH_EnableHook(reinterpret_cast<LPVOID>(pResourceReady)) != MH_OK)
{
HM5_LOG("Failed to enable ResourceReady hook.\n");

return 1;
}

ApplicationHooks::CreateAndEnableHooks();
ZDebugConsoleHooks::CreateAndEnableHooks();

Expand All @@ -310,25 +273,25 @@ DWORD WINAPI MainThread(HMODULE hModule)

if (GetAsyncKeyState(VK_F5) & 1)
{
killNearbyActors = !killNearbyActors;
killNearbyActorsEnabled = !killNearbyActorsEnabled;
}

if (GetAsyncKeyState(VK_F6) & 1)
{
displayNearbyActorsInfo = !displayNearbyActorsInfo;
displayNearbyActorsInfoEnabled = !displayNearbyActorsInfoEnabled;
}

if (gravityGunEnabled)
{
mods.EnableGravityGun();
}

if (killNearbyActors)
if (killNearbyActorsEnabled)
{
mods.KillNearbyActors();
}

if (displayNearbyActorsInfo)
if (displayNearbyActorsInfoEnabled)
{
mods.DisplayNearbyActorsInfo();
}
Expand Down
4 changes: 2 additions & 2 deletions include/AI/EAIActorRelationshipType.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

enum EAIActorRelationshipType : __int32
enum EAIActorRelationshipType
{
AIART_Boss = 0x0
AIART_Boss = 0
};
19 changes: 17 additions & 2 deletions include/AI/SAISharedEvent.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#pragma once

#include "ZGameTime.h"

struct SAISharedEvent
{
unsigned int m_start;
unsigned int m_end;
unsigned int m_start;
unsigned int m_end;

SAISharedEvent() = default;
~SAISharedEvent() = default;
float GetAge() const;
float GetExpired() const;
bool IsExpired() const;
static bool IsCurrent(SAISharedEvent* pEvent);
void SetStartTime(ZGameTime startTime);
void SetEndTime(ZGameTime endTime);
ZGameTime GetStartTime() const;
ZGameTime GetEndTime() const;
static unsigned int GameTimeToEventTime(ZGameTime gameTime);
static ZGameTime EventTimeToGameTime(unsigned int eventTime);
};
18 changes: 10 additions & 8 deletions include/AI/SActorCounts.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once

class SActorCounts
struct SActorCounts
{
public:
int nAlerted;
int nAlertedArmed;
int nEngaged;
int nInCombat;
int nAlertableActorOnScreen;
int nAlertableGuardOnScreen;
int nAlerted;
int nAlertedArmed;
int nEngaged;
int nInCombat;
int nAlertableActorOnScreen;
int nAlertableGuardOnScreen;

SActorCounts() = default;
~SActorCounts() = default;
};
34 changes: 19 additions & 15 deletions include/AI/SClosestActorInfo.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#pragma once

#include "TEntityRef.h"
#include "ZActor.h"

class SClosestActorInfo
class ZActor;

struct SClosestActorInfo
{
public:
TEntityRef<ZActor> m_pMaxFacingAlertableActor;
TEntityRef<ZActor> m_pClosestAlertableActor;
TEntityRef<ZActor> m_pClosestAlertableGuard;
TEntityRef<ZActor> m_pClosestEngagedActor;
float m_fMaxFacingAlertableActor;
float m_fClosestAlertableActor;
float m_fClosestAlertableGuard;
float m_fClosestEngagedActor;
float m_fMaxFacingAlertablePan;
float m_fClosestAlertablePan;
float m_fClosestAlertableGuardPan;
float m_fClosestEngangedPan;
TEntityRef<ZActor> m_pMaxFacingAlertableActor;
TEntityRef<ZActor> m_pClosestAlertableActor;
TEntityRef<ZActor> m_pClosestAlertableGuard;
TEntityRef<ZActor> m_pClosestEngagedActor;
float m_fMaxFacingAlertableActor;
float m_fClosestAlertableActor;
float m_fClosestAlertableGuard;
float m_fClosestEngagedActor;
float m_fMaxFacingAlertablePan;
float m_fClosestAlertablePan;
float m_fClosestAlertableGuardPan;
float m_fClosestEngangedPan;

SClosestActorInfo() = default;
~SClosestActorInfo() = default;
SClosestActorInfo& operator=(const SClosestActorInfo& __that);
};
51 changes: 47 additions & 4 deletions include/AI/ZAIEventEmitterEntity.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,56 @@
#pragma once

#include "ZGameStatsEntityBase.h"
#include "ZAIGameState.h"
#include "EGameEventArgType.h"
#include "SComponentMapEntry.h"
#include "SGameEventArgs.h"
#include "ZVariantRef.h"

class ZAIGameState;
class ZComponentCreateInfo;
class ZString;
struct STypeID;

class ZAIEventEmitterEntity : public ZGameStatsEntityBase
{
public:
float m_AlertableActorOnScreenCooldown;
float m_AlertableGuardOnScreenCooldown;
enum
{
COPYABLE = 0,
ASSIGNABLE = 0
};

float m_AlertableActorOnScreenCooldown;
float m_AlertableGuardOnScreenCooldown;

static SComponentMapEntry s_componentMap[0];
static const unsigned int s_pinidSoundTensionAmbient;
static const unsigned int s_pinidSoundTensionUpToYellow;
static const unsigned int s_pinidSoundTensionDownToYellow;
static const unsigned int s_pinidSoundTensionUpToOrange;
static const unsigned int s_pinidSoundTensionDownToOrange;
static const unsigned int s_pinidSoundTensionUpToRed;

~ZAIEventEmitterEntity() override = default;
ZVariantRef GetVariantRef() const override;
int AddRef() override;
int Release() override;
void* QueryInterface(STypeID* iid) override;
void Activate(const ZString& sSubset) override;
void Deactivate(const ZString& sSubset) override;
void Init() override;
virtual void SendSignals(const ZAIGameState& oldState, const ZAIGameState& newState);

void ProcessGameEvent(const SGameEventArgs& args) override;
EGameEventArgType GetArgType() const override;

virtual void SendSignals(const ZAIGameState*, const ZAIGameState*);
ZAIEventEmitterEntity() = default;
static void RegisterType();
ZAIEventEmitterEntity(ZComponentCreateInfo& info);
void SignalSoundTensionAmbient();
void SignalSoundTensionUpToYellow();
void SignalSoundTensionDownToYellow();
void SignalSoundTensionUpToOrange();
void SignalSoundTensionDownToOrange();
void SignalSoundTensionUpToRed();
};
Loading

0 comments on commit cdc9da2

Please sign in to comment.