-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.cpp
More file actions
96 lines (79 loc) · 3.39 KB
/
hooks.cpp
File metadata and controls
96 lines (79 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "hooks.h"
namespace hooks
{
HRESULT hkResizeBuffers( IDXGISwapChain *swap, UINT bufferCount, UINT width, UINT height, DXGI_FORMAT newFormat, UINT flags )
{
Beep( 1000, 100 );
// just mark that we need to recreate on the next frame
g_needsResize = true;
g_newWidth = width;
g_newHeight = height;
return oResizeBuffers( swap, bufferCount, width, height, newFormat, flags );
}
void *hkIEntityConstructor( __int64 Block, __int64 a2, int a3 )
{
/*
printf( "entity %llX\n", Block );
void *stack[256];
USHORT nFrames = RtlCaptureStackBackTrace( 0, 256, stack, NULL );
for ( USHORT i = 0; i < nFrames; ++i )
{
uint64_t addr = (uint64_t)stack[i] - base;
addr += 0x140000000;
printf( "\t%llX frame %d: %p\n", Block, i, addr );
}
*/
return oIEntityConstructor( Block, a2, a3 );
}
void *hkIObjectInitalizer( __int64 IObject, __int64 a2, int a3 )
{
if ( IObject && std::find( g_IEntity.begin( ), g_IEntity.end( ), IObject ) == g_IEntity.end( ) ) // && sdk::can_read( (void *)IObject, sizeof( void * ) )
{
g_IEntity.push_back( IObject );
}
return oIObjectInitalizer( IObject, a2, a3 );
}
void *hkIObjectDeconstructor( __int64 *Block )
{
if ( Block )
{
if ( *Block == bloodstrike::renderer::camera ) bloodstrike::renderer::camera = 0x0;
if ( std::find( bloodstrike::renderer::all_cameras.begin( ), bloodstrike::renderer::all_cameras.end( ), *Block ) == bloodstrike::renderer::all_cameras.end( ) )
{
bloodstrike::renderer::all_cameras.erase( std::remove( bloodstrike::renderer::all_cameras.begin( ), bloodstrike::renderer::all_cameras.end( ), *Block ), bloodstrike::renderer::all_cameras.end( ) );
}
g_IEntity.erase( std::remove( g_IEntity.begin( ), g_IEntity.end( ), *Block ), g_IEntity.end( ) );
}
return oIObjectDeconstructor( Block );
}
UINT WINAPI hkGetRawInputData( HRAWINPUT hRaw, UINT uiCmd, LPVOID pData, PUINT pcbSize, UINT cbHeader ) {
UINT ret = oGetRawInputData( hRaw, uiCmd, pData, pcbSize, cbHeader );
if ( !should_change_mouse ) return ret;
if ( pData ) {
RAWINPUT *ri = (RAWINPUT *)pData;
if ( ri->header.dwType == RIM_TYPEMOUSE ) {
ri->data.mouse.lLastX = dx;
ri->data.mouse.lLastY = dy;
}
}
return ret;
}
/*
HRESULT hkResizeBuffers( IDXGISwapChain *swap, UINT bufferCount, UINT width, UINT height, DXGI_FORMAT newFormat, UINT flags )
{
if ( bloodstrike::renderer::rtv ) {
bloodstrike::renderer::rtv->Release( );
bloodstrike::renderer::rtv = nullptr;
}
HRESULT hr = oResizeBuffers( swap, bufferCount, width, height, newFormat, flags );
if ( FAILED( hr ) ) return hr;
ID3D11Texture2D *backBuffer = nullptr;
swap->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (void **)&backBuffer );
if ( backBuffer ) {
bloodstrike::renderer::deviceInstance->CreateRenderTargetView( backBuffer, nullptr, &bloodstrike::renderer::rtv );
backBuffer->Release( );
}
return hr;
}
*/
}