|
Познавший АНТИЧАТ
Регистрация: 18.08.2017
Сообщений: 1,568
С нами:
4598023
Репутация:
183
|
|
@CleanLegend помоги братец
C++:
Код:
#include
#include
#include
#include
int
processId
;
int
GetProcessIdByWindowName
(
std
::
string windowName
)
{
HWND window
=
FindWindowA
(
NULL
,
reinterpret_cast
(
windowName
.
c_str
(
)
)
)
;
int
pId
=
0
;
GetWindowThreadProcessId
(
window
,
reinterpret_cast
(
&
pId
)
)
;
return
pId
;
}
template
T
readMem
(
int
address
)
{
T buf
;
HANDLE h
=
OpenProcess
(
PROCESS_VM_READ
,
false
,
processId
)
;
ReadProcessMemory
(
h
,
reinterpret_cast
(
address
)
,
&
buf
,
sizeof
(
T
)
,
NULL
)
;
CloseHandle
(
h
)
;
return
buf
;
}
template
void
writeMem
(
int
address
,
T buf
)
{
HANDLE h
=
OpenProcess
(
PROCESS_VM_WRITE
,
false
,
processId
)
;
int
oldProtect
=
0
;
VirtualProtectEx
(
h
,
reinterpret_cast
(
address
)
,
sizeof
(
T
)
,
PAGE_READWRITE
,
reinterpret_cast
(
&
oldProtect
)
)
;
WriteProcessMemory
(
h
,
reinterpret_cast
(
address
)
,
&
buf
,
sizeof
(
T
)
,
NULL
)
;
VirtualProtectEx
(
h
,
reinterpret_cast
(
address
)
,
sizeof
(
T
)
,
oldProtect
,
reinterpret_cast
(
&
oldProtect
)
)
;
CloseHandle
(
h
)
;
}
struct
AddMessageArg
{
DWORD arg1
;
int
arg2
;
const
char
*
arg3
;
int
arg4
;
int
arg5
;
int
arg6
;
}
;
typedef
void
(
__cdecl
*
AddMessage
)
(
DWORD
,
int
,
const
char
*
,
int
,
int
,
int
)
;
DWORD __stdcall
RemoteThread
(
AddMessageArg
*
arg
)
{
AddMessage msg
=
(
AddMessage
)
(
reinterpret_cast
(
GetModuleHandleA
(
"samp.dll"
)
+
0x64010
)
)
;
// передаем адрес
msg
(
arg
->
arg1
,
arg
->
arg2
,
arg
->
arg3
,
arg
->
arg4
,
arg
->
arg5
,
arg
->
arg6
)
;
// вызываем
return
0
;
}
void
__stdcall
RemoteThread_end
(
)
{
}
void
AddSampMessage
(
std
::
string message
,
int
color
)
{
AddMessageArg funcArg
;
funcArg
.
arg1
=
readMem
(
reinterpret_cast
(
GetModuleHandleA
(
"samp.dll"
)
+
0x21A0E4
)
)
;
funcArg
.
arg2
=
4
;
funcArg
.
arg3
=
message
.
c_str
(
)
;
funcArg
.
arg4
=
0
;
funcArg
.
arg5
=
color
;
funcArg
.
arg6
=
0
;
HANDLE h
=
OpenProcess
(
PROCESS_ALL_ACCESS
,
false
,
processId
)
;
LPVOID pRemoteThread
=
VirtualAllocEx
(
h
,
NULL
,
reinterpret_cast
(
RemoteThread_end
)
-
reinterpret_cast
(
RemoteThread
)
,
MEM_COMMIT
|
MEM_RESERVE
,
PAGE_EXECUTE_READWRITE
)
;
WriteProcessMemory
(
h
,
pRemoteThread
,
reinterpret_cast
(
RemoteThread
)
,
(
reinterpret_cast
(
RemoteThread_end
)
-
reinterpret_cast
(
RemoteThread
)
)
,
0
)
;
AddMessageArg
*
myArg
=
reinterpret_cast
(
VirtualAllocEx
(
h
,
NULL
,
sizeof
(
AddMessageArg
)
,
MEM_COMMIT
,
PAGE_READWRITE
)
)
;
writeMem
(
reinterpret_cast
(
myArg
)
,
funcArg
)
;
HANDLE h2
=
CreateRemoteThread
(
h
,
0
,
0
,
(
LPTHREAD_START_ROUTINE
)
pRemoteThread
,
myArg
,
0
,
0
)
;
CloseHandle
(
h2
)
;
VirtualFreeEx
(
h
,
myArg
,
sizeof
(
AddMessageArg
)
,
MEM_RELEASE
)
;
CloseHandle
(
h
)
;
}
int
main
(
)
{
processId
=
GetProcessIdByWindowName
(
"GTA:SA:MP"
)
;
AddSampMessage
(
"This is C++, wow!"
,
0
)
;
}
Укажите на ошибки, почему сообщение в чат не отправляется, непон.
И да, на эту строку
C++:
Код:
VirtualFreeEx
(
h
,
myArg
,
sizeof
(
AddMessageArg
)
,
MEM_RELEASE
)
;
Выдаёт пред, очково
Код:
Код:
Предупреждение C6333 Недопустимый параметр: передача MEM_RELEASE и ненулевого параметра dwSize в "VirtualFreeEx" не допускается. Это приведет к сбою вызова.
|