精易论坛
标题:
想问下关于注入的问题
[打印本页]
作者:
1250015590
时间:
4 天前
标题:
想问下关于注入的问题
现在使用的是注入mfc动态链接库,但是有的游戏不让注入带窗口的,那就只能注入dll了,那注入dll以后,干啥呢,怎么跟外界的程序通讯呢,用soket吗?cplusplus实现有些复杂了吧,比如我想读内存,调call.hook什么的,外部程序发信息给dll,dll接收到读了后在吧结果发给外部程序,是这样子吗,还没有学到这些,但是比较好奇,有没有人来启蒙一下,如果能有的简单的demo就更好了,c++的,读个内存通讯给外部程序的demo就行,
作者:
huayuanderen
时间:
4 天前
#include <windows.h>
#include <cstdio>
#include <string>
// 命名管道通信
void StartPipeServer()
{
HANDLE hPipe;
char buffer[1024];
DWORD dwRead, dwWritten;
// 创建命名管道
hPipe = CreateNamedPipe(
TEXT("\\\\.\\pipe\\MyMemoryPipe"),
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
1,
1024,
1024,
0,
NULL);
if (hPipe == INVALID_HANDLE_VALUE) return;
while (true)
{
// 等待客户Duan连接
if (ConnectNamedPipe(hPipe, NULL)
{
// 读取客户Duan请求
if (ReadFile(hPipe, buffer, sizeof(buffer), &dwRead, NULL))
{
std::string request(buffer, dwRead);
// 处理读取内存请求
if (request == "ReadMemory")
{
// 示例:读取自身模块jz
HMODULE hModule = GetModuleHandle(NULL);
char result[64];
sprintf_s(result, "BaseAddress: 0x%p", hModule);
// 返回结果
WriteFile(hPipe, result, strlen(result)+1, &dwWritten, NULL);
}
}
}
DisconnectNamedPipe(hPipe);
}
CloseHandle(hPipe);
}
// 线程函数
DWORD WINAPI PipeThread(LPVOID lpParam)
{
StartPipeServer();
return 0;
}
// DLL入口点
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
// 创建通信线程
CreateThread(NULL, 0, PipeThread, NULL, 0, NULL);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
作者:
baitso
时间:
4 天前
SendMessage CopyData就可以了。但这结贴率。。。。
作者:
huayuanderen
时间:
4 天前
外部控制程序代码 (controller.cpp)
#include <windows.h>
#include <iostream>
void ReadFromInjectedDLL()
{
HANDLE hPipe;
char buffer[1024];
DWORD dwRead;
// 连接命名管道
hPipe = CreateFile(
TEXT("\\\\.\\pipe\\MyMemoryPipe"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hPipe == INVALID_HANDLE_VALUE)
{
std::cerr << "Failed to connect to pipe. Error: " << GetLastError() << std::endl;
return;
}
// 发送读取内存请求
std::string request = "ReadMemory";
DWORD dwWritten;
WriteFile(hPipe, request.c_str(), request.size()+1, &dwWritten, NULL);
// 读取响应
if (ReadFile(hPipe, buffer, sizeof(buffer), &dwRead, NULL))
{
std::cout << "Received from DLL: " << buffer << std::endl;
}
CloseHandle(hPipe);
}
int main()
{
ReadFromInjectedDLL();
return 0;
}
作者:
CigaretteWine
时间:
4 天前
谁跟你说不能出口的?别用mfc 需要运行库的 ,C++ dll+imgui 最牛逼的组合没有之一
欢迎光临 精易论坛 (https://125.confly.eu.org/)
Powered by Discuz! X3.4