ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   Общие вопросы программирования (https://forum.antichat.xyz/forumdisplay.php?f=206)
-   -   Замена текста в диалоге CHelpDialog::Show (https://forum.antichat.xyz/showthread.php?t=1524828)

vmprotect 12.11.2024 21:17

Всем привет пытаюсь изменить текст диалога который открывается через F1, но в игре возникает ошибка. Возможно, я что-то упускаю или делаю неправильно. Буду благодарен за любую помощь и советы.

hook:





Код:

using
CDialog__Show
=
void
(
__thiscall
*
)
(
void
*
,
void
*
,
int
,
int
,
int
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
bool
)
;
kthook
::
kthook_simple

CDialog__Show_Hook
;
void
customhook
(
)
{
SampDLL
=
reinterpret_cast

(
GetModuleHandle
(
"samp.dll"
)
)
;
CDialog__Show_Hook
.
set_dest
(
SampDLL
+
0x6B3E7
)
;
CDialog__Show_Hook
.
set_cb
(
[
]
(
const
decltype
(
CDialog__Show_Hook
)
&
hook
,
void
*
pDialog
,
void
*
EDX
,
int
a2
,
int
nId
,
int
nType
,
const
char
*
Source
,
const
char
*
szText
,
const
char
*
szLeftButton
,
const
char
*
szRightButton
,
bool
bServerside
)
{
Source
=
"custom text"
;
return
hook
.
get_trampoline
(
)
(
pDialog
,
EDX
,
a2
,
nId
,
nType
,
Source
,
szText
,
szLeftButton
,
szRightButton
,
bServerside
)
;
}
)
;
CDialog__Show_Hook
.
install
(
)
;
}



https://forum.antichat.xyz/attachments/28560054/

ставлю хук на call ShowDialog внутри функции CHelpDialog::Show

https://forum.antichat.xyz/attachments/28560054/

AdCKuY_DpO4uLa 12.11.2024 21:24

C++:





Код:

using
CDialogShow_t
=
void
(
__thiscall
*
)
(
void
*
,
int
,
int
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
BOOL
)
;
kthook
::
kthook_simple

CDialogShowHook
;
void
customhook
(
)
{
std
::
uintptr_t SampBase
=
reinterpret_cast

(
GetModuleHandle
(
"samp.dll"
)
)
;
CDialogShowHook
.
set_dest
(
SampBase
+
0x6B3E7
)
;
CDialogShowHook
.
set_cb
(
[
]
(
const
decltype
(
CDialogShowHook
)
&
hook
,
void
*
pDialog
,
void
*
edx86
,
int
nId
,
int
nType
,
const
char
*
szCaption
,
const
char
*
szText
,
const
char
*
szLeftButton
,
const
char
*
szRightButton
,
BOOL bServerside
)
{
std
::
string NewMessage
{
"test message"
}
;
return
hook
.
get_trampoline
(
)
(
pDialog
,
nId
,
nType
,
NewMessage
.
c_str
(
)
,
szText
,
szLeftButton
,
szRightButton
,
bServerside
)
;
}
)
;
CDialogShowHook
.
install
(
)
;
}


vmprotect 12.11.2024 21:30

Цитата:

Сообщение от AdCKuY_DpO4uLa

C++:





Код:

using
CDialogShow_t
=
void
(
__thiscall
*
)
(
void
*
,
int
,
int
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
BOOL
)
;
kthook
::
kthook_simple

CDialogShowHook
;
void
customhook
(
)
{
std
::
uintptr_t SampBase
=
reinterpret_cast

(
GetModuleHandle
(
"samp.dll"
)
)
;
CDialogShowHook
.
set_dest
(
SampBase
+
0x6B3E7
)
;
CDialogShowHook
.
set_cb
(
[
]
(
const
decltype
(
CDialogShowHook
)
&
hook
,
void
*
pDialog
,
void
*
edx86
,
int
nId
,
int
nType
,
const
char
*
szCaption
,
const
char
*
szText
,
const
char
*
szLeftButton
,
const
char
*
szRightButton
,
BOOL bServerside
)
{
std
::
string NewMessage
{
"test message"
}
;
return
hook
.
get_trampoline
(
)
(
pDialog
,
nId
,
nType
,
NewMessage
.
c_str
(
)
,
szText
,
szLeftButton
,
szRightButton
,
bServerside
)
;
}
)
;
CDialogShowHook
.
install
(
)
;
}



https://forum.antichat.xyz/attachments/28560058/

я изначально пытался таким методом делать, но у меня бьет эрроры на лямбду

ERROR:





Код:

no suitable user-defined conversion from "lambda [](const kthook::kthook_simple &hook, void *pDialog, void *edx86, int nId, int nType, const char *szCaption, const char *szText, const char *szLeftButton, const char *szRightButton, BOOL bServerside)->void" to "kthook::kthook_simple::cb_type" (aka "std::function &, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t)>") existsC/C++(312)

AdCKuY_DpO4uLa 12.11.2024 21:38

Ну сделай без лямбды. Вообще никогда лямбды не использовал для хуков

C++:





Код:

using
CDialogShow_t
=
void
(
__thiscall
*
)
(
void
*
,
int
,
int
,
const
char
*
,
const
char
*
,
const
char
*
,
const
char
*
,
BOOL
)
;
kthook
::
kthook_simple

CDialogShowHook
;
void
CDialogShow_HOOKED
(
const
decltype
(
CDialogShowHook
)
&
hook
,
void
*
pDialog
,
void
*
edx86
,
int
nId
,
int
nType
,
const
char
*
szCaption
,
const
char
*
szText
,
const
char
*
szLeftButton
,
const
char
*
szRightButton
,
BOOL bServerside
)
{
std
::
string NewMessage
{
"test message"
}
;
return
hook
.
get_trampoline
(
)
(
pDialog
,
nId
,
nType
,
NewMessage
.
c_str
(
)
,
szText
,
szLeftButton
,
szRightButton
,
bServerside
)
;
}
void
customhook
(
)
{
std
::
uintptr_t SampBase
=
reinterpret_cast

(
GetModuleHandle
(
"samp.dll"
)
)
;
CDialogShowHook
.
set_dest
(
SampBase
+
0x6B3E7
)
;
CDialogShowHook
.
set_cb
(
&
CDialogShow_HOOKED
)
;
CDialogShowHook
.
install
(
)
;
}


Musaigen 13.11.2024 00:24

Цитата:

Сообщение от vmprotect

я изначально пытался таким методом делать, но у меня бьет эрроры на лямбду

ERROR:





Код:

no suitable user-defined conversion from "lambda [](const kthook::kthook_simple &hook, void *pDialog, void *edx86, int nId, int nType, const char *szCaption, const char *szText, const char *szLeftButton, const char *szRightButton, BOOL bServerside)->void" to "kthook::kthook_simple::cb_type" (aka "std::function &, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t, std::add_lvalue_reference_t)>") existsC/C++(312)


Ну понятное дело бьет ошибку, в ктхуках добавлять параметр edx86 не нужно + нужно добавить всем параметрам lval reference


Время: 00:45