
25.07.2018, 06:48
|
|
Участник форума
Регистрация: 12.07.2013
Сообщений: 161
С нами:
6755146
Репутация:
78
|
|
Сообщение от imring
пытаюсь перевести с lua на c++, но чет хуево получается
Lua:
Код:
-- lua code
local
callback
=
ffi
.
cast
(
'void(__thiscall *)(void *_this, char *killer, char *killed, uint32_t clKiller, uint32_t clKilled, uint8_t reason)'
,
hook
)
local
detour_addr
=
tonumber
(
ffi
.
cast
(
'uintptr_t'
,
callback
)
)
local
hook_addr
=
getModuleHandle
(
'samp.dll'
)
+
0x2B2A3B
memory
.
setint8
(
hook_addr
,
0xE8
,
true
)
memory
.
setuint32
(
hook_addr
+
1
,
detour_addr
-
hook_addr
-
5
,
true
)
C++:
Код:
// c++ code
void
(
__thiscall
*
callback
)
(
void
*
,
char
*
,
char
*
,
uint32_t
,
uint32_t
,
uint8_t
)
=
(
void
(
__thiscall
*
)
(
void
*
_this
,
char
*
killer
,
char
*
killed
,
uint32_t
clKiller
,
uint32_t
clKilled
,
uint8_t
reason
)
)
(
hook
)
;
uintptr_t detour_addr
=
(
uintptr_t
)
callback
;
uintptr_t hook_addr
=
(
uintptr_t
)
GetModuleHandleA
(
"samp.dll"
)
+
0x2B2A3B
;
*
reinterpret_cast
(
hook_addr
)
=
(
INT8
)
0xE8
;
*
reinterpret_cast
(
hook_addr
+
1
)
=
detour_addr
-
hook_addr
-
5
;
виснет игра из-за этой строки:
C++:
Код:
*
reinterpret_cast
(
hook_addr
)
=
(
INT8
)
0xE8
;
Перед записью в память установи права на запись при помощи VirtualProtect, после как закончишь восстанови предыдущие права.
|
|
|