-
Автор темы
- #1
Здравствуйте, зеленый в теме хуков помогите пожалуйста вставить хук с форума в код киеро.
Код:
#include "includes.h"
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
Present oPresent;
HWND window = NULL;
WNDPROC oWndProc;
ID3D11Device* pDevice = NULL;
ID3D11DeviceContext* pContext = NULL;
ID3D11RenderTargetView* mainRenderTargetView;
void InitImGui()
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange;
ImGui_ImplWin32_Init(window);
ImGui_ImplDX11_Init(pDevice, pContext);
}
LRESULT __stdcall WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (true && ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
return true;
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
}
bool init = false;
HRESULT __stdcall hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
if (!init)
{
if (SUCCEEDED(pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)& pDevice)))
{
pDevice->GetImmediateContext(&pContext);
DXGI_SWAP_CHAIN_DESC sd;
pSwapChain->GetDesc(&sd);
window = sd.OutputWindow;
ID3D11Texture2D* pBackBuffer;
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)& pBackBuffer);
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
pBackBuffer->Release();
oWndProc = (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)WndProc);
InitImGui();
init = true;
}
else
return oPresent(pSwapChain, SyncInterval, Flags);
}
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
ImGui::Begin("ImGui Window");
ImGui::End();
ImGui::Render();
pContext->OMSetRenderTargets(1, &mainRenderTargetView, NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
return oPresent(pSwapChain, SyncInterval, Flags);
}
DWORD WINAPI MainThread(LPVOID lpReserved)
{
bool init_hook = false;
do
{
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
{
kiero::bind(8, (void**)& oPresent, hkPresent);
init_hook = true;
}
} while (!init_hook);
return TRUE;
}
BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hMod);
CreateThread(nullptr, 0, MainThread, hMod, 0, nullptr);
break;
case DLL_PROCESS_DETACH:
kiero::shutdown();
break;
}
return TRUE;
}
Хук:
class CNetInputMessage
{
public:
std::int32_t m_nRenderTickCount; //0x0000
float m_flRenderTickFraction; //0x0004
std::int32_t m_nPlayerTickCount; //0x0008
float m_flPlayerTickFraction; //0x000C
char __pad0010[ 24 ]; //0x0010
std::int32_t m_nInvalidIndex; //0x0028
char __pad002C[ 8 ]; //0x002C
}; // size: 0x0034
__int64 __fastcall C_Hooks::ModifyInputHistory( CNetInputMessage* a1, void* a2, char a3, __int64 a4, __int64 a5, __int64 a6 )
{
if ( Globals::m_bUnloading )
return ogModifyInputHistory( a1, a2, a3, a4, a5, a6 );
// its just an example, in order to do it properly you need to backtrack yourself here. backtracking works the same as in csgo
// modify tickcount in createmove and recieve your instant VAC.
if ( a1 != nullptr )
{
if ( Config::m_bRapidFire )
{
a1->m_nPlayerTickCount = 0;
a1->m_nRenderTickCount = 0;
// another input history?
[I]( int[/I] ) ( ( DWORD64 ) a2 + 0x0068 ) = 0; // nPlayerTickCount
[I]( int[/I] ) ( ( DWORD64 ) a2 + 0x0060 ) = 0; // nRenderTickCount
}
// you should restore after the user disabled rapidfire
}
return ogModifyInputHistory( a1, a2, a3, a4, a5, a6 );
}