Skip to content

Commit

Permalink
- Add SharedData::Discard method
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrM committed Feb 23, 2023
1 parent 76538f3 commit b38e0d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/UnrealInternalExample/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "CleanCheat.h"

#define GAME_VIEW_PORT_INDEX 0x02 // Maybe you need to change that number

typedef void (__thiscall* ProcessEventType)(CG::UObject*, CG::UFunction*, void*);
typedef void (__thiscall* PostRenderType)(CG::UGameViewportClient*, CG::UCanvas*);

Expand Down Expand Up @@ -64,6 +66,7 @@ void __stdcall PostRenderHook(CG::UGameViewportClient* gameViewportClient, CG::U
Once = true;

CleanCheat::Hook->Detour(reinterpret_cast<void**>(&OProcessEvent), reinterpret_cast<void*>(&ProcessEventHook));
LOG("Hook 'ProcessEvent' ... Success");
}
}
catch (...)
Expand Down Expand Up @@ -134,7 +137,7 @@ void MainEntryPoint(HMODULE hModule)
std::vector<CG::UGameViewportClient*> gameViewportClients = CG::UObject::FindObjects<CG::UGameViewportClient>();
LOG("GameViewportClientCount: %d", static_cast<int>(gameViewportClients.size()));

CG::UGameViewportClient*& gameViewportClient = gameViewportClients[1]; // Maybe you need to change that number
CG::UGameViewportClient*& gameViewportClient = gameViewportClients[GAME_VIEW_PORT_INDEX];
void** gameViewportClientVmt = *reinterpret_cast<void***>(gameViewportClient);
LOG("PostRender : 0x%llx", reinterpret_cast<uintptr_t>(gameViewportClientVmt[POST_RENDER_INDEX]));

Expand Down
3 changes: 3 additions & 0 deletions src/CleanCheat/CleanCheatManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ class CleanCheat final
// Un hook all functions
Hook->UnSwapAll();
Hook->UnDetourAll();

// Shared data
SharedData->Discard();

// Free memory
DELETE_HEAP(Memory);
Expand Down
14 changes: 14 additions & 0 deletions src/CleanCheat/SharedDataBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ ABSTRACT class SharedDataBase
{
public:
virtual ~SharedDataBase() = default;

protected:
/// <summary>
/// Called by Discard method
/// </summary>
virtual void OnDestroy() { }

public:
/// <summary>
/// Called every tick
/// </summary>
virtual void Tick(TInit* data) = 0;

/// <summary>
/// Discard runner task
/// </summary>
void Discard()
{
OnDestroy();
}
};

0 comments on commit b38e0d1

Please sign in to comment.