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

  #13  
Старый 09.10.2024, 20:45
nonelike
Познающий
Регистрация: 22.12.2018
Сообщений: 72
С нами: 3890632

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

код:





Код:
#include "plugin.h"
#include 
void
*
pOriginalFunction
=
nullptr
;
void
*
SetJmpHook
(
uintptr_t HookAddress
,
size_t HookSize
,
void
*
DetourFunction
)
{
void
*
Trampoline
=
VirtualAlloc
(
0
,
HookSize
+
5
,
MEM_COMMIT
|
MEM_RESERVE
,
PAGE_EXECUTE_READWRITE
)
;
if
(
Trampoline
)
{
uintptr_t TrampolineJmpBack
=
reinterpret_cast

(
Trampoline
)
+
HookSize
;
memcpy
(
Trampoline
,
reinterpret_cast

(
HookAddress
)
,
HookSize
)
;
DWORD oldProt
;
VirtualProtect
(
reinterpret_cast

(
HookAddress
)
,
HookSize
,
PAGE_READWRITE
,
&
oldProt
)
;
memset
(
reinterpret_cast

(
HookAddress
)
,
0x90
,
HookSize
)
;
*
reinterpret_cast

(
HookAddress
)
=
0xE9
;
*
reinterpret_cast

(
HookAddress
+
1
)
=
reinterpret_cast

(
DetourFunction
)
-
HookAddress
-
5
;
VirtualProtect
(
reinterpret_cast

(
HookAddress
)
,
HookSize
,
oldProt
,
&
oldProt
)
;
*
reinterpret_cast

(
TrampolineJmpBack
)
=
0xE9
;
*
reinterpret_cast

(
TrampolineJmpBack
+
1
)
=
(
HookAddress
+
HookSize
)
-
TrampolineJmpBack
-
5
;
return
Trampoline
;
}
return
nullptr
;
}
void
HOOK_AddChatMessage
(
void
*
pChat
,
int
nType
,
const
char
*
szText
,
const
char
*
szPrefix
,
unsigned
long
textColor
,
unsigned
long
prefixColor
)
{
std
::
cout
: "

ref
(
)
==
nullptr
)
return
game_loop_hook
.
call_original
(
)
;
if
(
uintptr_t dwSAMP
=
reinterpret_cast

(
GetModuleHandleA
(
"samp.dll"
)
)
;
dwSAMP
!=
0
)
{
SetJmpHook
(
dwSAMP
+
0x67460
,
5
,
&
HOOK_Raw_AddChatMessage
)
;
}
initialized
=
true
;
return
game_loop_hook
.
call_original
(
)
;
}
void
c_plugin
::
attach_console
(
)
{
if
(
!
AllocConsole
(
)
)
return
;
FILE
*
f
;
freopen_s
(
&
f
,
"CONOUT$"
,
"w"
,
stdout
)
;
freopen_s
(
&
f
,
"CONOUT$"
,
"w"
,
stderr
)
;
freopen_s
(
&
f
,
"CONIN$"
,
"r"
,
stdin
)
;
}
c_plugin
::
c_plugin
(
HMODULE hmodule
)
:
hmodule
(
hmodule
)
{
attach_console
(
)
;
game_loop_hook
.
add
(
&
c_plugin
::
game_loop
)
;
}
c_plugin
::
~
c_plugin
(
)
{
rakhook
::
destroy
(
)
;
}


че то все равно крашит
 
Ответить с цитированием