
04.11.2023, 19:59
|
|
Участник форума
Регистрация: 27.05.2021
Сообщений: 140
С нами:
2614229
Репутация:
33
|
|
What is wrong with my code? When getting into a vehicle the game crashes (R1)
Что не так с моим кодом? При посадке в транспорт игра вылетает (R1)
C++:
Код:
bool
MemoryCheck
(
int
pAddress
,
unsigned
char
cByte
)
{
unsigned
long
dwProtect
[
2
]
;
unsigned
char
cValue
=
cByte
;
VirtualProtect
(
reinterpret_cast
(
pAddress
)
,
1
,
PAGE_READWRITE
,
&
dwProtect
[
0
]
)
;
memcpy
(
&
cValue
,
reinterpret_cast
(
pAddress
)
,
1
)
;
VirtualProtect
(
reinterpret_cast
(
pAddress
)
,
1
,
dwProtect
[
0
]
,
&
dwProtect
[
1
]
)
;
return
(
cValue
>
cByte
)
;
}
DWORD
GetVehicleCPEDPtr
(
)
{
unsigned
long
dwProtect
[
2
]
;
DWORD vehicleCPEDPtr
;
VirtualProtect
(
reinterpret_cast
(
0xBA18FC
)
,
sizeof
(
DWORD
)
,
PAGE_EXECUTE_READ
,
&
dwProtect
[
0
]
)
;
memcpy
(
&
vehicleCPEDPtr
,
reinterpret_cast
(
0xBA18FC
)
,
sizeof
(
DWORD
)
)
;
return
vehicleCPEDPtr
;
}
float
GetVehicleSpeed
(
DWORD vehicleCPEDPtr
)
{
unsigned
long
dwProtect
[
2
]
;
float
speedX
,
speedY
;
VirtualProtect
(
reinterpret_cast
(
vehicleCPEDPtr
+
0x44
)
,
sizeof
(
float
)
,
PAGE_EXECUTE_READ
,
&
dwProtect
[
0
]
)
;
memcpy
(
&
speedX
,
reinterpret_cast
(
vehicleCPEDPtr
+
0x44
)
,
sizeof
(
float
)
)
;
VirtualProtect
(
reinterpret_cast
(
vehicleCPEDPtr
+
0x44
)
,
sizeof
(
float
)
,
dwProtect
[
0
]
,
&
dwProtect
[
1
]
)
;
VirtualProtect
(
reinterpret_cast
(
vehicleCPEDPtr
+
0x48
)
,
sizeof
(
float
)
,
PAGE_EXECUTE_READ
,
&
dwProtect
[
0
]
)
;
memcpy
(
&
speedY
,
reinterpret_cast
(
vehicleCPEDPtr
+
0x48
)
,
sizeof
(
float
)
)
;
VirtualProtect
(
reinterpret_cast
(
vehicleCPEDPtr
+
0x48
)
,
sizeof
(
float
)
,
dwProtect
[
0
]
,
&
dwProtect
[
1
]
)
;
float
speed
=
(
speedX
+
speedY
)
*
4.0f
;
return
speed
;
}
int
WINAPI
Thread
(
)
{
while
(
*
(
DWORD
*
)
0xC8D4C0
!=
9
)
Sleep
(
100
)
;
InitHook
(
)
;
while
(
true
)
{
if
(
MemoryCheck
(
0xBA18FC
,
1
)
)
{
if
(
GetVehicleCPEDPtr
(
)
!=
0
)
{
float
speed
=
GetVehicleSpeed
(
GetVehicleCPEDPtr
(
)
)
;
if
(
speed
>=
0
&&
speed
60
&&
speed
120
&&
speed
180
)
{
speed
=
33
;
}
else
{
speed
=
0
;
}
}
}
}
return
0
;
}
The addresses are fine since in the cheat engine, when you obtain both speeds, add them and multiply them by 4, the returned value is the correct one.
С адресами все в порядке, поскольку в чит-движке, когда вы получаете обе скорости, складываете их и умножаете на 4, возвращаемое значение является правильным.
|
|
|