| SafeModeOfficial |
26.12.2023 18:13 |
Цитата:
Сообщение от atomlin
Хукнуть отправку подключения к серверу (RakPeer::SendConnectionRequest( const char* host, unsigned short remotePort, char* passwordData, int passwordDataLength ))
(Можно хукнуть и socketlayer, но тогда будет ломаться connectfix)
(Ниже offset под r1)
C++:
Код:
#include
#include
#include "Windows.h"
uintptr_t dwSAMP
=
0xFF
;
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
)
;
}
using
SendConnectionRequest
=
bool
(
__fastcall
*
)
(
void
*
,
void
*
,
const
char
*
,
unsigned
short
,
char
*
,
int
)
;
SendConnectionRequest pSendConnectionRequest
=
nullptr
;
int
__fastcall
ConnectionHook
(
void
*
EDX
,
void
*
thats
,
const
char
*
host
,
unsigned
short
remotePort
,
char
*
passwordData
,
int
passwordDataLength
)
{
if
(
!
strncmp
(
host
,
"127.0.0.1"
,
9
)
)
return
0
;
return
pSendConnectionRequest
(
EDX
,
thats
,
host
,
remotePort
,
passwordData
,
passwordDataLength
)
;
}
void
Hooking
(
)
{
pSendConnectionRequest
=
reinterpret_cast
(
SetCallHook
(
dwSAMP
+
0x3CB16
,
&
ConnectionHook
)
)
;
}
BOOL APIENTRY
DllMain
(
HMODULE hModule
,
DWORD ul_reason_for_call
,
LPVOID lpReserved
)
{
switch
(
ul_reason_for_call
)
{
case
DLL_PROCESS_ATTACH
:
{
dwSAMP
=
reinterpret_cast
(
GetModuleHandleA
(
"samp.dll"
)
)
;
std
::
thread
(
Hooking
)
.
detach
(
)
;
break
;
}
}
return
TRUE
;
}
|
Как я понял он провеяет айпи хоста, и если он соотвествует, то полностью блокирует все подключения?
|