|
Новичок
Регистрация: 07.01.2024
Сообщений: 10
С нами:
1238284
Репутация:
3
|
|
У меня ошибка, @CleanLegend живой, поможешь?
Вообщем такое же окошко вылезает, без понятия что делать
Сообщение от Vintik
@CleanLegend опять какая-то ерунда.
Что уж теперь не так то? Я всё пофиксил из того, что ты сказал.
Сообщение от Спойлер
C++:
Код:
#include
#include
#include
#include
int
processId
;
DWORD sampdll
;
int
GetProcessIdByWindowName
(
std
::
string windowName
)
{
HWND window
=
FindWindowA
(
NULL
,
reinterpret_cast
(
windowName
.
c_str
(
)
)
)
;
int
pId
=
0
;
GetWindowThreadProcessId
(
window
,
reinterpret_cast
(
&
pId
)
)
;
return
pId
;
}
DWORD
GetModuleBaseAddress
(
DWORD pid
,
const
char
*
name
)
{
HANDLE snapshot
=
CreateToolhelp32Snapshot
(
TH32CS_SNAPMODULE
,
pid
)
;
MODULEENTRY32 mEntry
;
mEntry
.
dwSize
=
sizeof
(
MODULEENTRY32
)
;
do
{
if
(
!
strcmp
(
(
const
char
*
)
mEntry
.
szModule
,
name
)
)
{
CloseHandle
(
snapshot
)
;
return
(
DWORD
)
mEntry
.
modBaseAddr
;
}
}
while
(
Module32Next
(
snapshot
,
&
mEntry
)
)
;
}
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
;
DWORD addr
;
}
;
typedef
void
(
__cdecl
*
AddMessage
)
(
DWORD
,
int
,
const
char
*
,
int
,
int
,
int
)
;
DWORD __stdcall
RemoteThread
(
AddMessageArg
*
arg
)
{
AddMessage msg
=
(
AddMessage
)
arg
->
addr
;
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
(
sampdll
+
0x21A0E4
)
;
funcArg
.
arg2
=
4
;
funcArg
.
arg3
=
message
.
c_str
(
)
;
funcArg
.
arg4
=
0
;
funcArg
.
arg5
=
color
;
funcArg
.
arg6
=
0
;
funcArg
.
addr
=
sampdll
+
0x64010
;
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
,
reinterpret_cast
(
pRemoteThread
)
,
myArg
,
0
,
0
)
;
WaitForSingleObject
(
h2
,
INFINITE
)
;
CloseHandle
(
h2
)
;
VirtualFreeEx
(
h
,
myArg
,
0
,
MEM_RELEASE
)
;
CloseHandle
(
h
)
;
}
int
main
(
)
{
processId
=
GetProcessIdByWindowName
(
"GTA:SA:MP"
)
;
sampdll
=
GetModuleBaseAddress
(
processId
,
"samp.dll"
)
;
AddSampMessage
(
"This is C++, wow!"
,
0
)
;
}
|