Показать сообщение отдельно

  #5  
Старый 15.12.2018, 20:15
gresearch
Новичок
Регистрация: 05.11.2018
Сообщений: 9
С нами: 3958797

Репутация: 0
По умолчанию

Цитата:
Сообщение от DucaRii  

cDraw.cpp

C++:





Код:
#define Серый  D3DCOLOR_ARGB(160, 46, 46, 46)




Я предлагаю сделать более удобный хук таблиц, не Detour.

VMTHook.h

C++:





Код:
#pragma once
#include 
#include 
#include 
#include 
class
VMTHook
{
private
:
std
::
uintptr_t
*
*
BaseClass
=
nullptr
;
std
::
unique_ptr

CurrentVTF
=
nullptr
;
std
::
uintptr_t
*
OriginalVTF
=
nullptr
;
std
::
size_t TotalFuncs
=
0
;
public
:
VMTHook
(
void
)
=
default
;
VMTHook
(
void
*
BaseClass
)
{
this
->
BaseClass
=
static_cast

(
BaseClass
)
;
while
(
static_cast

(
*
this
->
BaseClass
)
[
this
->
TotalFuncs
]
)
++
this
->
TotalFuncs
;
const
std
::
size_t TableSize
=
this
->
TotalFuncs
*
sizeof
(
std
::
uintptr_t
)
;
this
->
OriginalVTF
=
*
this
->
BaseClass
;
this
->
CurrentVTF
=
std
::
make_unique

(
this
->
TotalFuncs
)
;
std
::
memcpy
(
this
->
CurrentVTF
.
get
(
)
,
this
->
OriginalVTF
,
TableSize
)
;
*
this
->
BaseClass
=
this
->
CurrentVTF
.
get
(
)
;
}
;
~
VMTHook
(
)
{
*
this
->
BaseClass
=
this
->
OriginalVTF
;
}
;
template

inline
const
Fn
GetOrigIndex
(
std
::
size_t FunctionIndex
)
{
return
reinterpret_cast

(
this
->
OriginalVTF
[
FunctionIndex
]
)
;
}
inline
bool
TableIndexHook
(
void
*
new_function
,
const
std
::
size_t FunctionIndex
)
{
if
(
FunctionIndex
>
this
->
TotalFuncs
)
return
false
;
this
->
CurrentVTF
[
FunctionIndex
]
=
reinterpret_cast

(
new_function
)
;
return
true
;
}
inline
bool
TableIndexUnHook
(
const
std
::
size_t FunctionIndex
)
{
if
(
FunctionIndex
>
this
->
TotalFuncs
)
return
false
;
this
->
CurrentVTF
[
FunctionIndex
]
=
this
->
OriginalVTF
[
FunctionIndex
]
;
return
true
;
}
inline
std
::
size_t
GetMaxIndex
(
)
{
return
this
->
TotalFuncs
;
}
}
;


Отрывок из главного потока main.cpp
0x0 - адрес девайса.

C++:





Код:
IDirect3DDevice9
*
pDevice
=
*
(
IDirect3DDevice9
*
*
)
0x0
;
MyDevice
=
new
VMTHook
(
pDevice
)
;
MyDevice
->
TableIndexHook
(
Hooks
::
Reset
,
16
)
;
MyDevice
->
TableIndexHook
(
Hooks
::
Present
,
17
)
;


Заодно, можно будет сделать урок как искать адрес на девайс и тому подобное.
Думаю с Overlay побаловаться
 
Ответить с цитированием