|
@@ -1,28 +1,7 @@
|
|
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
|
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
|
#include "stdafx.h"
|
|
#include "stdafx.h"
|
|
#include "PipeClient.h"
|
|
#include "PipeClient.h"
|
|
-
|
|
|
|
-HMODULE g_hModule = NULL;
|
|
|
|
-HANDLE hThreadProc = NULL;
|
|
|
|
-TCHAR g_szCurModulePath[MAX_PATH] = {0};
|
|
|
|
-TCHAR g_szFna[MAX_PATH] = {0};
|
|
|
|
-HANDLE g_hPipe = NULL;
|
|
|
|
-// 配置文件名称;
|
|
|
|
-TCHAR g_szConfigFile[MAX_PATH] = {0};
|
|
|
|
-// 配置的窗口名称;
|
|
|
|
-TCHAR g_szWindowTitle[MAX_PATH] = {0};
|
|
|
|
-// 配置的窗口进程名称;
|
|
|
|
-TCHAR g_szProcessName[MAX_PATH] = {0};
|
|
|
|
-// 管道名称;
|
|
|
|
-TCHAR g_szPipeName[MAX_PATH] = {0};
|
|
|
|
-// 管道实例;
|
|
|
|
-CPipeClient *g_pPipeClient = NULL;
|
|
|
|
-
|
|
|
|
-typedef struct PIPE_MSG
|
|
|
|
-{
|
|
|
|
- //消息类型;
|
|
|
|
- //消息内容;
|
|
|
|
-};
|
|
|
|
|
|
+#include "Utility.h"
|
|
|
|
|
|
// 枚举屏幕上的所有顶级窗口
|
|
// 枚举屏幕上的所有顶级窗口
|
|
BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lParam)
|
|
BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lParam)
|
|
@@ -88,7 +67,7 @@ DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
if ( hWnd == NULL )
|
|
if ( hWnd == NULL )
|
|
{
|
|
{
|
|
OutputDebugString(_T("<Injecter> 没有找到窗口句柄"));
|
|
OutputDebugString(_T("<Injecter> 没有找到窗口句柄"));
|
|
- FreeLibraryAndExitThread(g_hModule, 0);
|
|
|
|
|
|
+ FreeLibraryAndExitThread(Utility::g_hDLLModule, 0);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,24 +80,22 @@ DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
#endif
|
|
#endif
|
|
OutputDebugString(szLog);
|
|
OutputDebugString(szLog);
|
|
//是否名称是计算器
|
|
//是否名称是计算器
|
|
- if( _tcsstr(szWndTitle, g_szWindowTitle) )
|
|
|
|
|
|
+ if( _tcsstr(szWndTitle, Utility::g_cfgCtx.szWindowTitel) )
|
|
{
|
|
{
|
|
OutputDebugString(_T("<Injecter> 找到指定窗口!!!"));
|
|
OutputDebugString(_T("<Injecter> 找到指定窗口!!!"));
|
|
// 2、创建后台线程;
|
|
// 2、创建后台线程;
|
|
- MessageBox(NULL, szWndTitle, g_szWindowTitle, MB_OK);
|
|
|
|
-#if 1
|
|
|
|
- if ( g_pPipeClient == NULL )
|
|
|
|
|
|
+ MessageBox(NULL, szWndTitle, Utility::g_cfgCtx.szWindowTitel, MB_OK);
|
|
|
|
+ if ( Utility::g_pPipeClient == NULL )
|
|
{
|
|
{
|
|
- g_pPipeClient = new CPipeClient(g_szPipeName);
|
|
|
|
- g_pPipeClient->StartWork();
|
|
|
|
|
|
+ Utility::g_pPipeClient = new CPipeClient(Utility::g_cfgCtx.szPipeName);
|
|
|
|
+ Utility::g_pPipeClient->StartWork();
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
OutputDebugString(_T("<Injecter> 不满足条件,DLL自我卸载!!!"));
|
|
OutputDebugString(_T("<Injecter> 不满足条件,DLL自我卸载!!!"));
|
|
// 如果不满足条件,DLL自我卸载;
|
|
// 如果不满足条件,DLL自我卸载;
|
|
- FreeLibraryAndExitThread(g_hModule, 0);
|
|
|
|
|
|
+ Utility::FreeLibraryAndExit();
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -127,32 +104,14 @@ DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
|
|
|
|
BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
|
BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
|
|
{
|
|
{
|
|
- g_hModule = hModule;
|
|
|
|
-#if 1
|
|
|
|
- // 获取dll的目录;
|
|
|
|
- TCHAR szDrive[MAX_PATH] = { 0 };
|
|
|
|
- TCHAR szDir[MAX_PATH] = { 0 };
|
|
|
|
- TCHAR szExt[MAX_PATH] = { 0 };
|
|
|
|
- ::GetModuleFileName(g_hModule, g_szCurModulePath, sizeof(g_szCurModulePath) / sizeof(TCHAR));
|
|
|
|
- _tsplitpath_s(g_szCurModulePath, szDrive, szDir, g_szFna, szExt);
|
|
|
|
- _tcscpy_s(g_szCurModulePath, szDrive);
|
|
|
|
- _tcscat_s(g_szCurModulePath, szDir);
|
|
|
|
- // 设置配置文件;
|
|
|
|
- _stprintf_s(g_szConfigFile, _T("%s%s"), g_szCurModulePath, _T("Assist.ini"));
|
|
|
|
-
|
|
|
|
- // 读取配置文件;
|
|
|
|
- TCHAR szValue[MAX_PATH] = {0};
|
|
|
|
- GetPrivateProfileString(_T("Windows"), _T("Title"), _T(""), g_szWindowTitle, MAX_PATH, g_szConfigFile);
|
|
|
|
- GetPrivateProfileString(_T("Pipe"), _T("Name"), _T("Assist"), szValue, MAX_PATH, g_szConfigFile);
|
|
|
|
- _stprintf_s(g_szPipeName, _T("\\\\.\\pipe\\%s"), szValue);
|
|
|
|
- GetPrivateProfileString(_T("Process"), _T("Name"), _T("Game.exe"), g_szProcessName, MAX_PATH, g_szConfigFile);
|
|
|
|
-#endif
|
|
|
|
|
|
+ Utility::g_hDLLModule = hModule;
|
|
|
|
+ Utility::GetConfigContent();
|
|
|
|
|
|
switch (ul_reason_for_call)
|
|
switch (ul_reason_for_call)
|
|
{
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
case DLL_PROCESS_ATTACH:
|
|
{
|
|
{
|
|
- hThreadProc = CreateThread(NULL, 0, WorkThreadProc, NULL, 0, NULL);
|
|
|
|
|
|
+ HANDLE hThreadProc = CreateThread(NULL, 0, WorkThreadProc, NULL, 0, NULL);
|
|
CloseHandle(hThreadProc);
|
|
CloseHandle(hThreadProc);
|
|
}
|
|
}
|
|
break;
|
|
break;
|