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

  #6  
Старый 05.01.2021, 06:01
Gunborg Johansson
Познающий
Регистрация: 30.10.2020
Сообщений: 32
С нами: 2914352

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

Цитата:
Сообщение от imring  

включает курсор (нужен plugin-sdk)

C++:





Код:
#ifdef IMGUI_VERSION
void
show_cursor
(
bool
show
,
bool
is_imgui
=
false
)
#else
void
show_cursor
(
bool
show
)
#endif
{
if
(
show
)
{
patch
::
Nop
(
0x541DF5
,
5
)
;
// don't call CControllerConfigManager::AffectPadFromKeyBoard
patch
::
Nop
(
0x53F417
,
5
)
;
// don't call CPad__getMouseState
patch
::
SetRaw
(
0x53F41F
,
"\x33\xC0\x0F\x84"
,
4
)
;
// test eax, eax -> xor eax, eax
// jl loc_53F526 -> jz loc_53F526
patch
::
PutRetn
(
0x6194A0
)
;
// disable RsMouseSetPos (ret)
#ifdef IMGUI_VERSION
if
(
is_imgui
)
ImGui
::
GetIO
(
)
.
MouseDrawCursor
=
true
;
else
#endif
static_cast

(
RwD3D9GetCurrentD3DDevice
(
)
)
->
ShowCursor
(
TRUE
)
;
}
else
{
patch
::
SetRaw
(
0x541DF5
,
"\xE8\x46\xF3\xFE\xFF"
,
5
)
;
// call CControllerConfigManager::AffectPadFromKeyBoard
patch
::
SetRaw
(
0x53F417
,
"\xE8\xB4\x7A\x20\x00"
,
5
)
;
// call CPad__getMouseState
patch
::
SetRaw
(
0x53F41F
,
"\x85\xC0\x0F\x8C"
,
4
)
;
// xor eax, eax -> test eax, eax
// jz loc_53F526 -> jl loc_53F526
patch
::
SetUChar
(
0x6194A0
,
0xE9
)
;
// jmp setup
static_cast

(
RwD3D9GetCurrentD3DDevice
(
)
)
->
ShowCursor
(
FALSE
)
;
#ifdef IMGUI_VERSION
ImGui
::
GetIO
(
)
.
MouseDrawCursor
=
false
;
#endif
}
CPad
::
NewMouseControllerState
.
X
=
0
;
CPad
::
NewMouseControllerState
.
Y
=
0
;
Call

(
)
;
// CPad::ClearMouseHistory
Call

(
)
;
// CPad::UpdatePads
}

Alternative realization (w/o plugin sdk):

C++:





Код:
void
showCursor
(
bool
state
)
{
using
RwD3D9GetCurrentD3DDevice_t
=
LPDIRECT3DDEVICE9
(
__cdecl
*
)
(
)
;
auto
rwCurrentD3dDevice
{
reinterpret_cast

(
0x7F9D50U
)
(
)
}
;
if
(
nullptr
==
rwCurrentD3dDevice
)
{
return
;
}
static
DWORD
        updateMouseProtection
,
rsMouseSetPosProtFirst
,
rsMouseSetPosProtSecond
;
if
(
state
)
{
::
VirtualProtect
(
reinterpret_cast

(
0x53F3C6U
)
,
5U
,
PAGE_EXECUTE_READWRITE
,
&
updateMouseProtection
)
;
::
VirtualProtect
(
reinterpret_cast

(
0x53E9F1U
)
,
5U
,
PAGE_EXECUTE_READWRITE
,
&
rsMouseSetPosProtFirst
)
;
::
VirtualProtect
(
reinterpret_cast

(
0x748A1BU
)
,
5U
,
PAGE_EXECUTE_READWRITE
,
&
rsMouseSetPosProtSecond
)
;
// NOP: CPad::UpdateMouse
*
reinterpret_cast

(
0x53F3C6U
)
=
0xE9U
;
*
reinterpret_cast

(
0x53F3C6U
+
1U
)
=
0x15BU
;
// NOP: RsMouseSetPos
memset
(
reinterpret_cast

(
0x53E9F1U
)
,
0x90
,
5U
)
;
memset
(
reinterpret_cast

(
0x748A1BU
)
,
0x90
,
5U
)
;
rwCurrentD3dDevice
->
ShowCursor
(
TRUE
)
;
}
else
{
// Original: CPad::UpdateMouse
memcpy
(
reinterpret_cast

(
0x53F3C6U
)
,
"\xE8\x95\x6C\x20\x00"
,
5U
)
;
// Original: RsMouseSetPos
memcpy
(
reinterpret_cast

(
0x53E9F1U
)
,
"\xE8\xAA\xAA\x0D\x00"
,
5U
)
;
memcpy
(
reinterpret_cast

(
0x748A1BU
)
,
"\xE8\x80\x0A\xED\xFF"
,
5U
)
;
using
CPad_ClearMouseHistory_t
=
void
(
__cdecl
*
)
(
)
;
using
CPad_UpdatePads_t
=
void
(
__cdecl
*
)
(
)
;
reinterpret_cast

(
0x541BD0U
)
(
)
;
reinterpret_cast

(
0x541DD0U
)
(
)
;
::
VirtualProtect
(
reinterpret_cast

(
0x53F3C6U
)
,
5U
,
updateMouseProtection
,
&
updateMouseProtection
)
;
::
VirtualProtect
(
reinterpret_cast

(
0x53E9F1U
)
,
5U
,
rsMouseSetPosProtFirst
,
&
rsMouseSetPosProtFirst
)
;
::
VirtualProtect
(
reinterpret_cast

(
0x748A1BU
)
,
5U
,
rsMouseSetPosProtSecond
,
&
rsMouseSetPosProtSecond
)
;
rwCurrentD3dDevice
->
ShowCursor
(
FALSE
)
;
}
}
 
Ответить с цитированием