|
@@ -1,5 +1,6 @@
|
|
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
|
// dllmain.cpp : 定义 DLL 应用程序的入口点。
|
|
#include "stdafx.h"
|
|
#include "stdafx.h"
|
|
|
|
+#include "PipeClient.h"
|
|
|
|
|
|
HMODULE g_hModule = NULL;
|
|
HMODULE g_hModule = NULL;
|
|
HANDLE hThreadProc = NULL;
|
|
HANDLE hThreadProc = NULL;
|
|
@@ -14,6 +15,8 @@ TCHAR g_szWindowTitle[MAX_PATH] = {0};
|
|
TCHAR g_szProcessName[MAX_PATH] = {0};
|
|
TCHAR g_szProcessName[MAX_PATH] = {0};
|
|
// 管道名称;
|
|
// 管道名称;
|
|
TCHAR g_szPipeName[MAX_PATH] = {0};
|
|
TCHAR g_szPipeName[MAX_PATH] = {0};
|
|
|
|
+// 管道实例;
|
|
|
|
+CPipeClient *g_pPipeClient = NULL;
|
|
|
|
|
|
typedef struct PIPE_MSG
|
|
typedef struct PIPE_MSG
|
|
{
|
|
{
|
|
@@ -76,7 +79,7 @@ HWND GetMainWnd()
|
|
DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
{
|
|
{
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
- Sleep(20000);
|
|
|
|
|
|
+ Sleep(5000);
|
|
#endif
|
|
#endif
|
|
TCHAR szLog[MAX_PATH] = {0};
|
|
TCHAR szLog[MAX_PATH] = {0};
|
|
TCHAR szWndTitle[MAXBYTE] = {0};
|
|
TCHAR szWndTitle[MAXBYTE] = {0};
|
|
@@ -104,32 +107,11 @@ DWORD WINAPI WorkThreadProc(LPVOID lParam)
|
|
// 2、创建后台线程;
|
|
// 2、创建后台线程;
|
|
MessageBox(NULL, szWndTitle, g_szWindowTitle, MB_OK);
|
|
MessageBox(NULL, szWndTitle, g_szWindowTitle, MB_OK);
|
|
#if 1
|
|
#if 1
|
|
- // 等待连接服务器管道;
|
|
|
|
- if ( WaitNamedPipe(g_szPipeName, NMPWAIT_WAIT_FOREVER) )
|
|
|
|
- {
|
|
|
|
- // 连接成功后,创建客户端管道;
|
|
|
|
- if ( (g_hPipe = CreateFile(g_szPipeName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL) ) == INVALID_HANDLE_VALUE )
|
|
|
|
- {
|
|
|
|
- // 创建失败;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- DWORD dwWrite = 0;
|
|
|
|
- TCHAR szValue[MAX_PATH] = {"test pipe"};
|
|
|
|
- if ( WriteFile(g_hPipe, szValue, sizeof(szValue)*sizeof(TCHAR), &dwWrite, NULL ) )
|
|
|
|
- {
|
|
|
|
- // 写完之后,进行读取;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // 写失败;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // 等待失败;
|
|
|
|
- }
|
|
|
|
|
|
+ if ( g_pPipeClient == NULL )
|
|
|
|
+ {
|
|
|
|
+ g_pPipeClient = new CPipeClient(g_szPipeName);
|
|
|
|
+ g_pPipeClient->StartWork();
|
|
|
|
+ }
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -156,12 +138,12 @@ BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserv
|
|
_tcscpy_s(g_szCurModulePath, szDrive);
|
|
_tcscpy_s(g_szCurModulePath, szDrive);
|
|
_tcscat_s(g_szCurModulePath, szDir);
|
|
_tcscat_s(g_szCurModulePath, szDir);
|
|
// 设置配置文件;
|
|
// 设置配置文件;
|
|
- _stprintf_s(g_szConfigFile, _T("%s%s"), g_szCurModulePath, _T("Assit.ini"));
|
|
|
|
|
|
+ _stprintf_s(g_szConfigFile, _T("%s%s"), g_szCurModulePath, _T("Assist.ini"));
|
|
|
|
|
|
// 读取配置文件;
|
|
// 读取配置文件;
|
|
TCHAR szValue[MAX_PATH] = {0};
|
|
TCHAR szValue[MAX_PATH] = {0};
|
|
GetPrivateProfileString(_T("Windows"), _T("Title"), _T(""), g_szWindowTitle, MAX_PATH, g_szConfigFile);
|
|
GetPrivateProfileString(_T("Windows"), _T("Title"), _T(""), g_szWindowTitle, MAX_PATH, g_szConfigFile);
|
|
- GetPrivateProfileString(_T("Pipe"), _T("Name"), _T("Assit"), szValue, MAX_PATH, g_szConfigFile);
|
|
|
|
|
|
+ GetPrivateProfileString(_T("Pipe"), _T("Name"), _T("Assist"), szValue, MAX_PATH, g_szConfigFile);
|
|
_stprintf_s(g_szPipeName, _T("\\\\.\\pipe\\%s"), szValue);
|
|
_stprintf_s(g_szPipeName, _T("\\\\.\\pipe\\%s"), szValue);
|
|
GetPrivateProfileString(_T("Process"), _T("Name"), _T("Game.exe"), g_szProcessName, MAX_PATH, g_szConfigFile);
|
|
GetPrivateProfileString(_T("Process"), _T("Name"), _T("Game.exe"), g_szProcessName, MAX_PATH, g_szConfigFile);
|
|
#endif
|
|
#endif
|