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

  #4  
Старый 08.10.2024, 22:20
ARMOR
Флудер
Регистрация: 02.02.2019
Сообщений: 5,070
С нами: 3831395

Репутация: 183


По умолчанию

C++:





Код:
using
CChat__AddEntry
=
void
(
__thiscall
*
)
(
void
*
,
int
,
const
char
*
,
const
char
*
,
unsigned
long
,
unsigned
long
)
;
CChat__AddEntry pOriginalFunction
=
nullptr
;
void
*
SetCallHook
(
uintptr_t HookAddress
,
void
*
DetourFunction
)
{
uintptr_t OriginalFunction
=
*
reinterpret_cast

(
HookAddress
+
1
)
+
HookAddress
+
5
;
DWORD oldProt
;
VirtualProtect
(
reinterpret_cast

(
HookAddress
+
1
)
,
sizeof
(
uintptr_t
)
,
PAGE_READWRITE
,
&
oldProt
)
;
*
reinterpret_cast

(
HookAddress
+
1
)
=
reinterpret_cast

(
DetourFunction
)
-
HookAddress
-
5
;
VirtualProtect
(
reinterpret_cast

(
HookAddress
+
1
)
,
sizeof
(
uintptr_t
)
,
oldProt
,
&
oldProt
)
;
return
reinterpret_cast

(
OriginalFunction
)
;
}
void
__fastcall
HOOK_AddEntry
(
void
*
pChat
,
int
nType
,
const
char
*
szText
,
const
char
*
szPrefix
,
unsigned
long
textColor
,
unsigned
long
prefixColor
)
{
pOriginalFunction
(
pChat
,
nType
,
szText
,
szPrefix
,
textColor
,
prefixColor
)
;
}
if
(
uintptr_t dwSAMP
=
reinterpret_cast

(
GetModuleHandleA
(
"samp.dll"
)
)
;
dwSAMP
!=
0
)
{
pOriginalFunction
=
reinterpret_cast

(
SetCallHook
(
dwSAMP
+
0x67460
,
&
HOOK_AddEntry
)
)
;
}


Если все равно крашит - проблема в адресе или функции для хука
 
Ответить с цитированием