浏览代码

添加项目:hook动态库,WeChat主程序

unknown 6 年之前
父节点
当前提交
fc5a314648

+ 26 - 0
source/hook/WeChats.sln

@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hook", "hook\hook.vcproj", "{4E160416-52D6-454E-943D-4DD7E1150D25}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WeChats", "WeChats\WeChats.vcproj", "{7704A546-A786-41C8-B22A-04BC05AE4F82}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{4E160416-52D6-454E-943D-4DD7E1150D25}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4E160416-52D6-454E-943D-4DD7E1150D25}.Debug|Win32.Build.0 = Debug|Win32
+		{4E160416-52D6-454E-943D-4DD7E1150D25}.Release|Win32.ActiveCfg = Release|Win32
+		{4E160416-52D6-454E-943D-4DD7E1150D25}.Release|Win32.Build.0 = Release|Win32
+		{7704A546-A786-41C8-B22A-04BC05AE4F82}.Debug|Win32.ActiveCfg = Debug|Win32
+		{7704A546-A786-41C8-B22A-04BC05AE4F82}.Debug|Win32.Build.0 = Debug|Win32
+		{7704A546-A786-41C8-B22A-04BC05AE4F82}.Release|Win32.ActiveCfg = Release|Win32
+		{7704A546-A786-41C8-B22A-04BC05AE4F82}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 822 - 0
source/hook/WeChats/Global.cpp

@@ -0,0 +1,822 @@
+#include "StdAfx.h"
+#include "Global.h"
+
+// 获取文件版本号函数头文件;
+#include <WinVer.h>		
+#pragma comment(lib,"version.lib")
+using namespace std;
+
+TCHAR g_szModulePath[MAX_PATH] = _T("");			// 软件目录;
+TCHAR g_szModuleFileName[MAX_PATH] = _T("");		// 软件名称;
+TCHAR g_szIniFile[MAX_PATH] = _T("");
+
+// 配置文件信息;
+TCHAR g_szServAddress[MAX_PATH] = _T("");		
+DWORD g_dwServPort = 0;		
+TCHAR g_szAccount[MAX_PATH] = _T("");		
+TCHAR g_szPassword[MAX_PATH] = _T("");	
+TCHAR g_szWeChatPath[MAX_PATH] = _T("");		
+TCHAR g_szCacheDir[MAX_PATH] = _T("");		
+TCHAR g_szDynamicLibraryPath[MAX_PATH] = _T("");
+
+// 控制台输出;
+BOOL g_bStdOut = FALSE;
+
+/************************************************************************/
+/*  函数:[1/6/2019 Home];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+int GetIniInfo(LPCTSTR lpIniDir /* = NULL */, LPCTSTR lpIniName /* = NULL */)
+{
+	TCHAR szDrive[_MAX_DRIVE] = { 0 };
+	TCHAR szDir[_MAX_DIR] = { 0 };
+	TCHAR szFna[_MAX_DIR] = { 0 };
+	TCHAR szExt[_MAX_DIR] = { 0 };
+	::GetModuleFileName(NULL, g_szModulePath, sizeof(g_szModulePath) / sizeof(TCHAR));
+	swprintf_s(g_szModuleFileName, _T("%s"), g_szModulePath);
+
+	_tsplitpath_s(g_szModulePath, szDrive, szDir, szFna, szExt);
+	_tcscpy_s(g_szModulePath, szDrive);
+	_tcscat_s(g_szModulePath, szDir);
+
+	// 动态库路径;
+	_stprintf_s(g_szDynamicLibraryPath, _T("%shook.dll"), g_szModulePath);
+
+	if (lpIniDir != NULL && lpIniName != NULL)
+		_stprintf_s(g_szIniFile, _T("%s%s"), lpIniDir, lpIniName);
+	else
+		_stprintf_s(g_szIniFile, _T("%sconfig.ini"), g_szModulePath);
+
+	HANDLE hFile = CreateFile(g_szIniFile, 0/*GENERIC_READ*/, 0, NULL, OPEN_EXISTING, 0, NULL);
+
+	if (ERROR_FILE_NOT_FOUND == GetLastError())
+	{
+		return -1;
+	}
+
+	CloseHandle(hFile);
+	hFile = NULL;
+
+	// 获取服务器端信息;
+	GetPrivateProfileString(_T("ServerInfo"), _T("IP"), _T(""), g_szServAddress, MAX_PATH, g_szIniFile);
+	g_dwServPort = GetPrivateProfileInt(_T("ServerInfo"), _T("Port"), 0, g_szIniFile);
+	GetPrivateProfileString(_T("CustomerInfo"), _T("Account"), _T(""), g_szAccount, MAX_PATH, g_szIniFile);
+	GetPrivateProfileString(_T("CustomerInfo"), _T("Password"), _T(""), g_szPassword, MAX_PATH, g_szIniFile);
+	GetPrivateProfileString(_T("CustomerInfo"), _T("WeChat"), _T(""), g_szWeChatPath, MAX_PATH, g_szIniFile);
+	GetPrivateProfileString(_T("CustomerInfo"), _T("Cache"), _T(""), g_szCacheDir, MAX_PATH, g_szIniFile);
+
+	g_bStdOut = GetPrivateProfileInt(_T("CustomerInfo"), _T("StdOut"), 0, g_szIniFile);
+	if ( g_bStdOut )
+	{
+		AllocConsole();                             // 开辟控制台;
+		SetConsoleTitle(_T("调试输出"));			// 设置控制台窗口标题;
+		freopen("CONOUT$", "w+t", stdout);			// 重定向输出;
+		freopen("CONIN$", "r+t", stdin);			// 重定向输入;
+
+		HWND hWnd = NULL;
+again:
+		hWnd = ::FindWindow(NULL, _T("调试输出"));
+		if( hWnd )
+		{
+			if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE)) 
+			{
+				_tprintf_s(_T("前置设置失败\n"));
+			}
+			else
+			{
+				_tprintf_s(_T("前置设置成功\n"));
+			}
+		}
+		else
+		{
+			goto again;
+		}
+	}
+
+	return 0;
+}
+
+/************************************************************************/
+/*  函数:[1/6/2019 Home];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+DWORD FindProcess(LPCTSTR lpProName)
+{
+	ASSERT(lpProName!=NULL);
+
+	DWORD dwPID = 0;
+	PROCESSENTRY32 pe32 = { 0 };
+
+	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hSnapshot == NULL)
+	{
+		return 0;
+	}
+	pe32.dwSize = sizeof(PROCESSENTRY32);
+
+	if (Process32First(hSnapshot, &pe32))
+	{
+		do {
+			if (_tcsicmp(lpProName, pe32.szExeFile) == 0)
+			{
+				dwPID = pe32.th32ProcessID;
+				break;
+			}
+		} while (Process32Next(hSnapshot, &pe32));
+	}
+	CloseHandle(hSnapshot);
+
+	return dwPID;
+}
+
+vector<DWORD> FindAllProcess(LPCTSTR lpProName)
+{
+	ASSERT(lpProName!=NULL);
+
+	vector<DWORD> vtPID;
+	PROCESSENTRY32 pe32 = { 0 };
+
+	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hSnapshot == NULL)
+		return vector<DWORD>();
+
+	pe32.dwSize = sizeof(PROCESSENTRY32);
+	if (Process32First(hSnapshot, &pe32))
+	{
+		do {
+			if (_tcsicmp(lpProName, pe32.szExeFile) == 0)
+			{
+				vtPID.push_back(pe32.th32ProcessID);
+			}
+		} while (Process32Next(hSnapshot, &pe32));
+	}
+	CloseHandle(hSnapshot);
+
+	return vtPID;
+}
+
+MODULEENTRY32 FindModule(LPCTSTR lpModuleName, DWORD dwPID)
+{
+	ASSERT(lpModuleName!=NULL);
+
+	DWORD dwMID = 0;
+	MODULEENTRY32 me32 = { 0 };
+	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwPID);
+	if (hSnapshot == NULL)
+		return me32;
+
+	me32.dwSize = sizeof(PROCESSENTRY32);
+	if (Module32First(hSnapshot, &me32))
+	{
+		do {
+			if (_tcsicmp(lpModuleName, me32.szModule) == 0)
+			{
+				break;
+			}
+		} while (Module32Next(hSnapshot, &me32));
+	}
+	CloseHandle(hSnapshot);
+
+	return me32;
+}
+
+// WINDOWS NT 以上的内核需要提权,才能对系统进行高级管理;
+/************************************************************************/
+/*  函数:[1/6/2019 Home];
+/*  描述:;
+/*  参数:;
+/*  	[IN] :;
+/*  	[OUT] :;
+/*  	[IN/OUT] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+BOOL GetDebugPriv()
+{
+	// 返回的访问令牌指针;
+	HANDLE	hToken;
+	// 接收所返回的制定特权名称的信息;
+	LUID	sedebugnameValue;
+	// 新特权信息的指针(结构体);
+	TOKEN_PRIVILEGES tkp;
+	DWORD	dwCurProcId = GetCurrentProcessId();
+	// 要修改访问权限的进程句柄;
+	HANDLE	hCurProc;
+	hCurProc = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwCurProcId);
+
+	if (!::OpenProcessToken(hCurProc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+	{
+		//ShowSystemErrorInfo(_T("升级包OpenProcessToken失败."),GetLastError());
+		return FALSE;
+	}
+
+	if (!::LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue))
+	{
+		//ShowSystemErrorInfo(_T("升级包LookupPrivilegeValue失败."),GetLastError());
+		CloseHandle(hToken);
+		return FALSE;
+	}
+
+	tkp.PrivilegeCount = 1;
+	tkp.Privileges[0].Luid = sedebugnameValue;
+	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+	if (!::AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL))
+	{
+		//ShowSystemErrorInfo(_T("升级包AdjustTokenPrivileges失败."),GetLastError());
+		CloseHandle(hToken);
+		return FALSE;
+	}
+
+	CloseHandle(hCurProc);
+	CloseHandle(hToken);
+	return TRUE;
+}
+
+/************************************************************************/
+/* 
+	函数:GetFileVersion
+	描述:获取可执行文件的文件版号;
+	参数:
+	hModule[IN]		可执行文件模块句柄;
+	dwArray[OUT]	返回的文件版本号;
+	返回:
+	成功返回TRUE,失败返回FALSE;
+	注意:
+	当hModule为空时,表示要获取的可执行文件为本程序的文件版本号;
+*/
+/************************************************************************/
+BOOL GetFileVersion( IN HMODULE hModule, OUT DWORD (&dwArray)[4])
+{
+	TCHAR fname[MAX_PATH];
+	VS_FIXEDFILEINFO *pVi;
+	DWORD dwHandle;
+
+	if ( GetModuleFileName(hModule, fname, MAX_PATH))
+	{
+		INT nSize = GetFileVersionInfoSize(fname, &dwHandle);
+
+		if (nSize > 0)
+		{
+			BYTE *pBuffer = new BYTE[nSize];
+			memset(pBuffer, 0, nSize);
+
+			if (GetFileVersionInfo(fname, dwHandle, nSize, pBuffer))
+			{
+				if (VerQueryValue(pBuffer, _T("\\"), (LPVOID *)&pVi, (PUINT)&nSize))
+				{
+					dwArray[0] = HIWORD(pVi->dwFileVersionMS);
+					dwArray[1] = LOWORD(pVi->dwFileVersionMS);
+					dwArray[2] = HIWORD(pVi->dwFileVersionLS);
+					dwArray[3] = LOWORD(pVi->dwFileVersionLS);
+
+					delete[]pBuffer;
+					return TRUE;
+				}
+			}
+
+			if ( pBuffer )
+				delete[]pBuffer;
+		}
+	}
+
+	return FALSE;
+}
+
+/************************************************************************/
+/* 
+	函数:GetFileVersion
+	描述:获取可执行文件的文件版号;
+	参数:
+	lpFileName[IN]	可执行文件名全路径;
+	dwArray[OUT]	返回的文件版本号;
+	返回:
+	成功返回TRUE,失败返回FALSE;
+	注意:
+*/
+/************************************************************************/
+BOOL GetFileVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] )
+{
+	if ( lpFileName == NULL || !PathFileExists(lpFileName) )
+	{
+		OutputDebugString(_T("文件名错误或文件不存在\n"));
+		return FALSE;
+	}
+
+	DWORD dwHandle = 0;
+	VS_FIXEDFILEINFO *pVi = NULL;
+	INT nSize = GetFileVersionInfoSize(lpFileName, &dwHandle);
+	if ( nSize > 0 )
+	{
+		BYTE *pBuffer = new BYTE[nSize];
+		memset(pBuffer, 0, nSize);
+
+		if ( GetFileVersionInfo(lpFileName, dwHandle, nSize, pBuffer) )
+		{
+			if (VerQueryValue(pBuffer, _T("\\"), (LPVOID *)&pVi, (PUINT)&nSize))
+			{
+				dwArray[0] = HIWORD(pVi->dwFileVersionMS);
+				dwArray[1] = LOWORD(pVi->dwFileVersionMS);
+				dwArray[2] = HIWORD(pVi->dwFileVersionLS);
+				dwArray[3] = LOWORD(pVi->dwFileVersionLS);
+
+				if (pBuffer)
+					delete[]pBuffer;
+				return TRUE;
+			}
+		}
+
+		if (pBuffer)
+			delete[]pBuffer;
+	}
+
+	return FALSE;
+}
+
+/************************************************************************/
+/* 
+	函数:GetProductVersion
+	描述:获取可执行文件的产品版号;
+	参数:
+	hModule[IN]		可执行文件模块句柄;
+	dwArray[OUT]	返回的产品版本号;
+	返回:
+	成功返回TRUE,失败返回FALSE;
+	注意:
+	当hModule为空时,表示要获取的可执行文件为本程序的产品版本号;
+*/
+/************************************************************************/
+BOOL GetProductVersion(IN HMODULE hModule, IN DWORD (&dwArray)[4] )
+{
+	TCHAR fname[MAX_PATH];
+	VS_FIXEDFILEINFO *pVi;
+	DWORD dwHandle;
+
+	if (::GetModuleFileName(hModule, fname, MAX_PATH))
+	{
+		INT nSize = GetFileVersionInfoSize(fname, &dwHandle);
+
+		if (nSize > 0)
+		{
+			BYTE *pBuffer = new BYTE[nSize];
+			memset(pBuffer, 0, nSize);
+
+			if (GetFileVersionInfo(fname, dwHandle, nSize, pBuffer))
+			{
+				if (VerQueryValue(pBuffer, _T("\\"), (LPVOID *)&pVi, (PUINT)&nSize))
+				{
+					dwArray[0] = HIWORD(pVi->dwProductVersionMS);
+					dwArray[1] = LOWORD(pVi->dwProductVersionMS);
+					dwArray[2] = HIWORD(pVi->dwProductVersionLS);
+					dwArray[3] = LOWORD(pVi->dwProductVersionLS);
+
+					if(pBuffer)
+						delete[]pBuffer;
+					return TRUE;
+				}
+			}
+			if(pBuffer)
+				delete[]pBuffer;
+		}
+	}
+
+	return FALSE;
+}
+
+/************************************************************************/
+/* 
+	函数:GetProductVersion
+	描述:获取可执行文件的产品版号;
+	参数:
+	lpFileName[IN]	可执行文件名全路径;
+	dwArray[OUT]	返回的产品版本号;
+	返回:
+	成功返回TRUE,失败返回FALSE;
+	注意:
+*/
+/************************************************************************/
+BOOL GetProductVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] )
+{
+	if ( lpFileName == NULL || !PathFileExists(lpFileName) )
+	{
+		OutputDebugString(_T("文件名错误或文件不存在\n"));
+		return FALSE;
+	}
+
+	DWORD dwHandle = 0;
+	VS_FIXEDFILEINFO *pVi = NULL;
+	INT nSize = GetFileVersionInfoSize(lpFileName, &dwHandle);
+	if ( nSize > 0 )
+	{
+		BYTE *pBuffer = new BYTE[nSize];
+		memset(pBuffer, 0, nSize);
+
+		if ( GetFileVersionInfo(lpFileName, dwHandle, nSize, pBuffer) )
+		{
+			if (VerQueryValue(pBuffer, _T("\\"), (LPVOID *)&pVi, (PUINT)&nSize))
+			{
+				dwArray[0] = HIWORD(pVi->dwProductVersionMS);
+				dwArray[1] = LOWORD(pVi->dwProductVersionMS);
+				dwArray[2] = HIWORD(pVi->dwProductVersionLS);
+				dwArray[3] = LOWORD(pVi->dwProductVersionLS);
+
+				if (pBuffer)
+					delete[]pBuffer;
+				return TRUE;
+			}
+		}
+
+		if (pBuffer)
+			delete[]pBuffer;
+	}
+
+	return FALSE;
+}
+
+/************************************************************************/
+/*  函数:WriteTextLog[7/28/2016 IT];
+/*  描述:写文本日志;
+/*  参数:;
+/*  	[IN] :;
+/*  返回:void;
+/*  注意:;
+/*  示例:;
+/*
+/*  修改:;
+/*  日期:;
+/*  内容:;
+/************************************************************************/
+void WriteTextLog(const TCHAR *format, ...)
+{
+	try
+	{
+		//static ThreadSection _critSection;
+		//AutoThreadSection aSection(&_critSection);
+		// 解析出日志路径;
+		TCHAR szlogpath[MAX_PATH] = {0};
+		static TCHAR szModulePath[MAX_PATH] = {0};
+		static TCHAR szFna[_MAX_DIR] = { 0 };
+		if ( szModulePath[0] == _T('\0') )
+		{
+			TCHAR szDrive[_MAX_DRIVE] = { 0 };
+			TCHAR szDir[_MAX_DIR] = { 0 };
+			TCHAR szExt[_MAX_DIR] = { 0 };
+			::GetModuleFileName(NULL, szModulePath, sizeof(szModulePath) / sizeof(TCHAR));
+			_tsplitpath_s(szModulePath, szDrive, szDir, szFna, szExt);
+			_tcscpy_s(szModulePath, szDrive);
+			_tcscat_s(szModulePath, szDir);
+		}
+
+		_stprintf_s(szlogpath, _T("%s日志\\%s%s.txt"), szModulePath, szFna, CTime::GetCurrentTime().Format("[%Y-%m-%d]"));
+
+		// 打开或创建文件;
+		CStdioFile fp;
+		if (PathFileExists(szlogpath))
+		{
+			if (fp.Open(szlogpath, CFile::modeWrite) == FALSE)
+			{
+				return;
+			}
+			fp.SeekToEnd();
+		}
+		else
+		{
+			fp.Open(szlogpath, CFile::modeCreate | CFile::modeWrite);
+		}
+
+		// 格式化前设置语言区域;
+		TCHAR* old_locale = _tcsdup(_tsetlocale(LC_CTYPE, NULL));
+		_tsetlocale(LC_CTYPE, _T("chs"));//设定中文;
+
+		// 格式化日志内容;
+		va_list		args = NULL;
+		int			len = 0;
+		TCHAR		*buffer = NULL;
+		va_start( args, format );
+		// _vscprintf doesn't count. terminating '\0'
+		len = _vsctprintf( format, args )  + 1;
+		buffer = (TCHAR*)malloc( len * sizeof(TCHAR) );
+		_vstprintf_s( buffer, len, format, args ); // C4996
+		// Note: vsprintf is deprecated; consider using vsprintf_s instead
+
+		// 将日志内容输入到文件中;
+		fp.WriteString( CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S ")) );
+		fp.WriteString(buffer);
+		fp.WriteString(_T("\n"));
+
+		// 关闭文件,释放资源并设置回原语言区域;
+		free( buffer );
+		_tsetlocale(LC_CTYPE, old_locale);
+		free(old_locale);//还原区域设定;
+		fp.Close();
+	}
+	catch (CException *e)
+	{
+		e->ReportError();
+		e->Delete();
+	}
+}
+
+
+//---------------------------------------------------------------------
+// add by Jeff 2014.10.27
+// 函数:全局函数IsDirectoryLegitimate,多字节版本,非UNICODE
+// 描述:判断一个目录路径字符串,是否属于合法的、可创建的目录路径。
+// 参数:strDirectory 被验证的路径字符串;
+//		
+// 返回:合法路径返回TRUE;
+//---------------------------------------------------------------------
+BOOL IsDirectoryLegitimate(const CString &strDirectory)
+{
+	if (strDirectory.Find('/') != -1 ||
+		strDirectory.Find('\\') != -1 ||
+		strDirectory.Find(':') != -1 ||
+		strDirectory.Find('*') != -1 ||
+		strDirectory.Find('?') != -1 ||
+		strDirectory.Find('\"') != -1 ||
+		strDirectory.Find('>') != -1 ||
+		strDirectory.Find('<') != -1 ||
+		strDirectory.Find('|') != -1
+		)
+		return FALSE;
+
+	return TRUE;
+}
+
+
+//--------------------------------------------------------------------------------
+// Jeff add 2014.06.23;
+// 函数:ErrorExit
+// 描述:
+// 参数:
+//     lpszFunction:函数名;
+//     dwError:错误码; 
+//
+//--------------------------------------------------------------------------------
+void ShowSystemErrorInfo(CString strDescription, const DWORD &dwError)
+{
+#if 1
+	LPVOID lpMsgBuf;
+
+	BOOL fOk = FormatMessage(
+		FORMAT_MESSAGE_ALLOCATE_BUFFER |
+		FORMAT_MESSAGE_FROM_SYSTEM |
+		FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		dwError,
+		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+		(LPTSTR)&lpMsgBuf,
+		0, NULL);
+
+	if (!fOk)
+	{
+		// Is it a network-related error?
+		HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
+
+		if (hDll != NULL)
+		{
+			FormatMessage(
+				FORMAT_MESSAGE_FROM_HMODULE |
+				FORMAT_MESSAGE_FROM_SYSTEM |
+				FORMAT_MESSAGE_IGNORE_INSERTS,
+				hDll,
+				dwError,
+				MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+				(LPTSTR)&lpMsgBuf,
+				0,
+				NULL);
+
+			FreeLibrary(hDll);
+		}
+	}
+
+	if (lpMsgBuf != NULL)
+	{
+		CString strDisplay;
+		strDisplay.Format(_T("%s.错误码=%d,Windows描述:%s"), strDescription, dwError, (PCTSTR)LocalLock(lpMsgBuf));
+		//WriteLog(strDisplay);
+		LocalFree(lpMsgBuf);
+	}
+	else
+	{
+		//WriteLog(strDescription);
+	}
+#else
+	HLOCAL hlocal = NULL;   // Buffer that gets the error message string
+
+	// Get the error code's textual description
+	BOOL fOk = FormatMessage(
+		FORMAT_MESSAGE_FROM_SYSTEM |
+		FORMAT_MESSAGE_ALLOCATE_BUFFER |
+		FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		dwError,
+		MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+		(PTSTR)&hlocal,
+		0,
+		NULL);
+
+	if (!fOk)
+	{
+		// Is it a network-related error?
+		HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
+
+		if (hDll != NULL)
+		{
+			FormatMessage(
+				FORMAT_MESSAGE_FROM_HMODULE |
+				FORMAT_MESSAGE_FROM_SYSTEM |
+				FORMAT_MESSAGE_IGNORE_INSERTS,
+				hDll,
+				dwError,
+				MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+				(PTSTR)&hlocal,
+				0,
+				NULL);
+			FreeLibrary(hDll);
+		}
+	}
+
+	if (hlocal != NULL)
+	{
+		CString strDisplay;
+		strDisplay.Format("%s 失败错误码=%d,Windows系统描述:%s", strDescription, dwError, (PCTSTR)LocalLock(hlocal));
+		//WriteLog(strDisplay);
+		LocalFree(hlocal);
+	}
+	else
+	{
+		//WriteLog("Error number not found.");
+	}
+#endif
+
+}
+
+// The system displays a dialog box with a custom message and a message to the user to close applications within the specified time-out interval (30 seconds). 
+// After the time-out interval elapses, the system is restarted.
+//The application must enable the SE_SHUTDOWN_NAME privilege before calling InitiateSystemShutdown
+BOOL MySystemShutdown(LPTSTR lpMsg)
+{
+	HANDLE hToken;              // handle to process token 
+	TOKEN_PRIVILEGES tkp;       // pointer to token structure 
+
+	BOOL fResult;               // system shutdown flag 
+
+	// Get the current process token handle so we can get shutdown 
+	// privilege. 
+
+	if (!OpenProcessToken(GetCurrentProcess(),
+		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+		return FALSE;
+
+	// Get the LUID for shutdown privilege. 
+
+	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
+		&tkp.Privileges[0].Luid);
+
+	tkp.PrivilegeCount = 1;  // one privilege to set    
+	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+	// Get shutdown privilege for this process. 
+
+	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+		(PTOKEN_PRIVILEGES)NULL, 0);
+
+	// Cannot test the return value of AdjustTokenPrivileges. 
+
+	if (GetLastError() != ERROR_SUCCESS)
+		return FALSE;
+
+	// Display the shutdown dialog box and start the countdown. 
+
+	fResult = InitiateSystemShutdown(
+		NULL,    // shut down local computer 
+		lpMsg,   // message for user
+		30,      // time-out period, in seconds 
+		FALSE,   // ask user to close apps 
+		TRUE);   // reboot after shutdown 
+
+	if (!fResult)
+		return FALSE;
+
+	// Disable shutdown privilege. 
+
+	tkp.Privileges[0].Attributes = 0;
+	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+		(PTOKEN_PRIVILEGES)NULL, 0);
+
+	return TRUE;
+}
+
+// If the AbortSystemShutdown function is executed in the time-out period specified by InitiateSystemShutdown, 
+// the system does not shut down. For example, if PreventSystemShutdown is called after MySystemShutdown, 
+// the system closes the dialog box and does not restart the system.
+BOOL PreventSystemShutdown()
+{
+	HANDLE hToken;              // handle to process token 
+	TOKEN_PRIVILEGES tkp;       // pointer to token structure 
+
+	// Get the current process token handle  so we can get shutdown 
+	// privilege. 
+
+	if (!OpenProcessToken(GetCurrentProcess(),
+		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+		return FALSE;
+
+	// Get the LUID for shutdown privilege. 
+
+	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
+		&tkp.Privileges[0].Luid);
+
+	tkp.PrivilegeCount = 1;  // one privilege to set    
+	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+	// Get shutdown privilege for this process. 
+
+	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+		(PTOKEN_PRIVILEGES)NULL, 0);
+
+	if (GetLastError() != ERROR_SUCCESS)
+		return FALSE;
+
+	// Prevent the system from shutting down. 
+
+	if (!AbortSystemShutdown(NULL))
+		return FALSE;
+
+	// Disable shutdown privilege. 
+
+	tkp.Privileges[0].Attributes = 0;
+	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+		(PTOKEN_PRIVILEGES)NULL, 0);
+
+	return TRUE;
+}
+
+// Shutting down flushes file buffers to disk and brings the system to a condition in which it is safe to turn off the computer
+// The application must first enable the SE_SHUTDOWN_NAME privilege. 
+// The final parameter in the call to ExitWindowsEx indicates that the system was shut down for a planning update of the operating system.
+BOOL MySystemShutdown()
+{
+	HANDLE hToken;
+	TOKEN_PRIVILEGES tkp;
+
+	// Get a token for this process. 
+
+	if (!OpenProcessToken(GetCurrentProcess(),
+		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+		return(FALSE);
+
+	// Get the LUID for the shutdown privilege. 
+
+	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
+		&tkp.Privileges[0].Luid);
+
+	tkp.PrivilegeCount = 1;  // one privilege to set    
+	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+	// Get the shutdown privilege for this process. 
+
+	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+		(PTOKEN_PRIVILEGES)NULL, 0);
+
+	if (GetLastError() != ERROR_SUCCESS)
+		return FALSE;
+
+	// Shut down the system and force all applications to close. 
+
+	if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE,
+		SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
+		SHTDN_REASON_MINOR_UPGRADE |
+		SHTDN_REASON_FLAG_PLANNED))
+		return FALSE;
+
+	return TRUE;
+}

+ 57 - 0
source/hook/WeChats/Global.h

@@ -0,0 +1,57 @@
+#ifndef __GLOBAL_WECHAT__
+#define __GLOBAL_WECHAT__
+
+#include <tlhelp32.h>
+#include <vector>
+#include <string>
+using namespace std;
+
+#ifdef UNICODE
+typedef wstring TString;
+#else
+typedef string TString;
+#endif
+
+#define WECHAT _T("WeChat.exe")
+
+// 全局变量;
+extern TCHAR g_szModulePath[MAX_PATH];			// 软件目录;
+extern TCHAR g_szModuleFileName[MAX_PATH];		// 软件名称;
+extern TCHAR g_szIniFile[MAX_PATH];
+
+// 配置文件信息;
+extern TCHAR g_szServAddress[MAX_PATH];		
+extern DWORD g_dwServPort;					
+extern TCHAR g_szAccount[MAX_PATH];			
+extern TCHAR g_szPassword[MAX_PATH];		
+extern TCHAR g_szWeChatPath[MAX_PATH];		
+extern TCHAR g_szCacheDir[MAX_PATH];	
+extern TCHAR g_szDynamicLibraryPath[MAX_PATH];
+
+// 控制台输出;
+extern BOOL g_bStdOut;
+
+extern int GetIniInfo(LPCTSTR lpIniDir = NULL, LPCTSTR lpIniName = NULL);
+extern DWORD FindProcess(LPCTSTR lpProName);
+extern vector<DWORD> FindAllProcess(LPCTSTR lpProName);
+extern MODULEENTRY32 FindModule(LPCTSTR lpModuleName, DWORD dwPID);
+extern BOOL GetDebugPriv();
+
+extern BOOL GetFileVersion( IN HMODULE hModule, IN DWORD (&dwArray)[4]);
+extern BOOL GetFileVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] );
+extern BOOL GetProductVersion( IN HMODULE hModule, IN DWORD (&dwArray)[4]);
+extern BOOL GetProductVersionEx( IN LPCTSTR lpFileName, IN DWORD (&dwArray)[4] );
+
+extern BOOL GetOSDisplayString(LPTSTR pszOS);
+extern void WriteTextLog(const TCHAR *format, ...);
+extern BOOL CopyFileEx(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, const BOOL &bFailIfExists=TRUE);
+extern void tSplitpath(const char *path, char *drive, char *dir, char *fname, char *ext);
+extern void tSplitpath(const char *path, char *drive, char *dir, const int &nTimes);
+extern BOOL IsDirectoryLegitimate(const CString &strDirectory);
+extern void ShowSystemErrorInfo(CString strDescription, const DWORD &dwError);
+extern BOOL MySystemShutdown(LPTSTR lpMsg);
+extern BOOL PreventSystemShutdown();
+extern BOOL MySystemShutdown();
+
+
+#endif

+ 30 - 0
source/hook/WeChats/InjectInterface.h

@@ -0,0 +1,30 @@
+/************************************************************************/
+/*  Copyright (C), 2016-2020, [Home], 保留所有权利;
+/*  模 块 名:;
+/*  描    述:;
+/*
+/*  版    本:[V];	
+/*  作    者:[Home];
+/*  日    期:[1/6/2019];
+/*
+/*
+/*  注    意:;
+/*
+/*  修改记录:[Home];
+/*  修改日期:;
+/*  修改版本:;
+/*  修改内容:;
+/************************************************************************/
+
+#ifndef _INJECT_INTERFACE_HEAD_
+#define _INJECT_INTERFACE_HEAD_
+
+interface IInject{
+	// 进程注入;
+	virtual int ProcessInjection(LPCTSTR lpDLLPath, LPCTSTR lpPID) = 0;
+	// 卸载注入;
+	virtual int FreeInjection(LPCTSTR lpPID) = 0;
+};
+
+
+#endif

+ 91 - 0
source/hook/WeChats/Injection.cpp

@@ -0,0 +1,91 @@
+#include "StdAfx.h"
+#include "Injection.h"
+
+CInjection::CInjection(DWORD dwPid, LPCTSTR lpDynamicLibraryPath)
+:m_dwInjectionPID(dwPid),
+m_hInjectionProcess(NULL),
+m_lpPathData(NULL),
+m_hInjectThread(NULL),
+m_hUnInjectThread(NULL),
+m_dwPathLen(0)
+{
+	ASSERT(dwPid!=0);
+	ASSERT(lpDynamicLibraryPath!=NULL);
+
+	memset(m_szDllPath, 0, sizeof(m_szDllPath));
+	_tcscpy_s(m_szDllPath,lpDynamicLibraryPath);
+	m_hInjectionProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, m_dwInjectionPID);
+}
+
+CInjection::~CInjection(void)
+{
+	FreeInjection();
+}
+
+int CInjection::ProcessInjection()
+{
+	ASSERT(m_hInjectionProcess!=NULL);
+
+	m_dwPathLen = _tcslen(m_szDllPath)*sizeof(TCHAR);
+	m_lpPathData = VirtualAllocEx(m_hInjectionProcess,NULL, m_dwPathLen, MEM_COMMIT, PAGE_READWRITE);
+	if (NULL == m_lpPathData)
+		return -1;
+
+	if (WriteProcessMemory(m_hInjectionProcess, m_lpPathData, m_szDllPath, m_dwPathLen, NULL) == 0)
+	{
+		VirtualFreeEx(m_hInjectionProcess, m_lpPathData, m_dwPathLen, MEM_DECOMMIT);
+		return -1;
+	}
+
+	HMODULE hk32 = GetModuleHandle(_T("kernel32.dll"));
+	// 注意:微信使用的是W版本;
+	LPVOID lpAddr = GetProcAddress(hk32,"LoadLibraryW");
+
+	m_hInjectThread = CreateRemoteThread(m_hInjectionProcess, NULL, 0, (LPTHREAD_START_ROUTINE)lpAddr, m_lpPathData, 0, NULL);
+	if (NULL == m_hInjectThread)
+		return -1;
+
+	return 0;
+}
+
+int CInjection::FreeInjection()
+{
+	ASSERT(m_hInjectionProcess!=NULL);
+
+	TString str = m_szDllPath;
+	int nIndex = str.find_last_of(_T('\\'));
+	if (nIndex != TString::npos)
+		str = str.substr(nIndex+1);
+
+	MODULEENTRY32 me32 = FindModule(str.c_str(), m_dwInjectionPID);
+	if (me32.hModule == NULL )
+	{
+		MessageBox(NULL, _T("xxxxx"), _T("dfdf"), MB_OK);
+		return -1;
+	}
+
+	LPVOID lpAddr = GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "FreeLibrary");//FreeLibraryAndExitThread//FreeLibrary
+
+	m_hUnInjectThread = CreateRemoteThread(m_hInjectionProcess, NULL, 0, (LPTHREAD_START_ROUTINE)lpAddr, me32.hModule, 0, NULL);
+
+	WaitForSingleObject(m_hUnInjectThread, INFINITE);
+
+	// 释放所有资源;
+	if (m_hInjectThread)
+		CloseHandle(m_hInjectThread);
+	if (m_hUnInjectThread)
+		CloseHandle(m_hUnInjectThread);
+	if (m_lpPathData)
+		VirtualFreeEx(m_hInjectionProcess, m_lpPathData, m_dwPathLen, MEM_DECOMMIT);
+	
+	if (m_hInjectionProcess)
+		CloseHandle(m_hInjectionProcess);
+
+	return 0;
+}
+
+void CInjection::InjectionExistProcess()
+{
+	// 查找现在的进程;
+	vector<DWORD> vtPID = FindAllProcess(WECHAT);
+}

+ 56 - 0
source/hook/WeChats/Injection.h

@@ -0,0 +1,56 @@
+/************************************************************************/
+/*  Copyright (C), 2016-2020, [Home], 保留所有权利;
+/*  模 块 名:;
+/*  描    述:;
+/*
+/*  版    本:[V];	
+/*  作    者:[Home];
+/*  日    期:[1/6/2019];
+/*
+/*
+/*  注    意:;
+/*
+/*  修改记录:[Home];
+/*  修改日期:;
+/*  修改版本:;
+/*  修改内容:;
+/************************************************************************/
+#ifndef __INJECTION_OBJ__
+#define __INJECTION_OBJ__
+
+#pragma once
+
+class CInjection
+{
+public:
+	CInjection(DWORD dwPid, LPCTSTR lpDynamicLibraryPath);
+	~CInjection(void);
+
+	int ProcessInjection();
+	int FreeInjection();
+
+	// 当前注入的进程ID;
+	DWORD			m_dwInjectionPID;
+	// 动态库路径;
+	TCHAR			m_szDllPath[MAX_PATH];
+	// 当前注入的进程句柄;
+	HANDLE			m_hInjectionProcess;
+	// 路径分配的内存;
+	LPVOID			m_lpPathData;
+	// 路径长度;
+	DWORD			m_dwPathLen;
+	// 注入线程句柄;
+	HANDLE			m_hInjectThread;
+	// 卸载线程句柄;
+	HANDLE			m_hUnInjectThread;
+
+public:
+	// 注入已有的进程;
+	void InjectionExistProcess();
+
+	// 创建新进程并注入;
+
+};
+
+
+#endif

+ 69 - 0
source/hook/WeChats/ReadMe.txt

@@ -0,0 +1,69 @@
+================================================================================
+    MICROSOFT 基础类库: WeChats 项目概述
+===============================================================================
+
+应用程序向导已为您创建此 WeChats 应用程序。此应用程序不仅演示使用 Microsoft 基础类的基本知识,而且可作为编写应用程序的起点。
+
+此文件包含组成 WeChats 应用程序的各个文件的内容摘要。
+
+WeChats.vcproj
+    这是使用应用程序向导生成的 VC++ 项目的主项目文件。
+    它包含有关生成文件的 Visual C++ 版本的信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
+
+WeChats.h
+    这是应用程序的主要头文件。它包括其他项目特定的头文件(包括 Resource.h),并声明 CWeChatsApp 应用程序类。
+
+WeChats.cpp
+    这是包含应用程序类 CWeChatsApp 的主要应用程序源文件。
+
+WeChats.rc
+    这是程序使用的所有 Microsoft Windows 资源的列表。它包括 RES 子目录中存储的图标、位图和光标。此文件可以直接在 Microsoft Visual C++ 中进行编辑。项目资源位于 2052 中。
+
+res\WeChats.ico
+    这是用作应用程序图标的图标文件。此图标包括在主要资源文件 WeChats.rc 中。
+
+res\WeChats.rc2
+    此文件包含不是由 Microsoft Visual C++ 编辑的资源。您应该将不可由资源编辑器编辑的所有资源放在此文件中。
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+应用程序向导创建一个对话框类:
+
+WeChatsDlg.h,WeChatsDlg.cpp - 对话框
+    这些文件包含 CWeChatsDlg 类。该类定义应用程序主对话框的行为。该对话框的模板位于 WeChats.rc 中,该文件可以在 Microsoft Visual C++ 中进行编辑。
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+其他功能:
+
+ActiveX 控件
+    应用程序包括对使用 ActiveX 控件的支持。
+
+打印及打印预览支持
+    应用程序向导已通过从 MFC 库调用 CView 类中的成员函数,生成了用于处理打印、打印设置和打印预览命令的代码。
+
+/////////////////////////////////////////////////////////////////////////////
+
+其他标准文件:
+
+StdAfx.h, StdAfx.cpp
+    这些文件用于生成名为 WeChats.pch 的预编译头(PCH)文件和名为 StdAfx.obj 的预编译类型文件。
+
+Resource.h
+    这是标准头文件,它定义新资源 ID。
+    Microsoft Visual C++ 将读取并更新此文件。
+
+WeChats.manifest
+	Windows XP 使用应用程序清单文件描述应用程序	对特定版本并行程序集的依赖性。加载程序使用此	信息从程序集缓存加载相应程序集或	从应用程序加载私有信息。应用程序清单可能作为	与应用程序可执行文件安装在同一文件夹中的外部 .manifest 文件包括在内以便重新发布,	也可能以资源的形式包括在该可执行文件中。
+/////////////////////////////////////////////////////////////////////////////
+
+其他注释:
+
+应用程序向导使用“TODO:”指示应添加或自定义的源代码部分。
+
+如果应用程序在共享 DLL 中使用 MFC,则将需要重新发布 MFC DLL。如果应用程序所用与操作系统的区域设置不同,则也将必须重新发布对应的本地化资源 MFC90XXX.DLL。
+有关这两个主题的详细信息,请参阅 MSDN 文档中有关重新发布 Visual C++ 应用程序的部分。
+
+/////////////////////////////////////////////////////////////////////////////

+ 21 - 0
source/hook/WeChats/Resource.h

@@ -0,0 +1,21 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by WeChats.rc
+//
+#define IDR_MAINFRAME					128
+#define IDM_ABOUTBOX					0x0010
+#define IDD_ABOUTBOX					100
+#define IDS_ABOUTBOX					101
+#define IDD_WECHATS_DIALOG				102
+
+// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE	129
+#define _APS_NEXT_CONTROL_VALUE		1000
+#define _APS_NEXT_SYMED_VALUE		101
+#define _APS_NEXT_COMMAND_VALUE		32771
+#endif
+#endif

+ 94 - 0
source/hook/WeChats/WeChats.cpp

@@ -0,0 +1,94 @@
+
+// WeChats.cpp : 定义应用程序的类行为。
+//
+
+#include "stdafx.h"
+#include "WeChats.h"
+#include "WeChatsDlg.h"
+#include "Injection.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// CWeChatsApp
+
+BEGIN_MESSAGE_MAP(CWeChatsApp, CWinAppEx)
+	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+
+// CWeChatsApp 构造
+
+CWeChatsApp::CWeChatsApp()
+{
+	// TODO: 在此处添加构造代码,
+	// 将所有重要的初始化放置在 InitInstance 中
+}
+
+
+// 唯一的一个 CWeChatsApp 对象
+
+CWeChatsApp theApp;
+
+
+// CWeChatsApp 初始化
+
+BOOL CWeChatsApp::InitInstance()
+{
+	// 如果一个运行在 Windows XP 上的应用程序清单指定要
+	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
+	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
+	INITCOMMONCONTROLSEX InitCtrls;
+	InitCtrls.dwSize = sizeof(InitCtrls);
+	// 将它设置为包括所有要在应用程序中使用的
+	// 公共控件类。
+	InitCtrls.dwICC = ICC_WIN95_CLASSES;
+	InitCommonControlsEx(&InitCtrls);
+
+	CWinAppEx::InitInstance();
+
+	AfxEnableControlContainer();
+	
+	// 获取配置信息;
+	GetIniInfo();
+	TCHAR szDllPath[MAX_PATH];
+	ZeroMemory(szDllPath,MAX_PATH);
+	DWORD ss = sizeof(szDllPath);
+	DWORD sss = _tcslen(szDllPath)*sizeof(TCHAR);
+	_stprintf_s(szDllPath, _T("%shook.dll"), g_szModulePath);
+	vector<DWORD> vtPID = FindAllProcess(WECHAT);
+	CInjection inject(*vtPID.begin(),szDllPath);
+	inject.ProcessInjection();
+	Sleep(5000);
+
+
+
+	// 标准初始化
+	// 如果未使用这些功能并希望减小
+	// 最终可执行文件的大小,则应移除下列
+	// 不需要的特定初始化例程
+	// 更改用于存储设置的注册表项
+	// TODO: 应适当修改该字符串,
+	// 例如修改为公司或组织名
+	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
+
+	CWeChatsDlg dlg;
+	m_pMainWnd = &dlg;
+	INT_PTR nResponse = dlg.DoModal();
+	if (nResponse == IDOK)
+	{
+		// TODO: 在此放置处理何时用
+		//  “确定”来关闭对话框的代码
+	}
+	else if (nResponse == IDCANCEL)
+	{
+		// TODO: 在此放置处理何时用
+		//  “取消”来关闭对话框的代码
+	}
+
+	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
+	//  而不是启动应用程序的消息泵。
+	return FALSE;
+}

+ 32 - 0
source/hook/WeChats/WeChats.h

@@ -0,0 +1,32 @@
+
+// WeChats.h : PROJECT_NAME 应用程序的主头文件
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+	#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
+#endif
+
+#include "resource.h"		// 主符号
+
+
+// CWeChatsApp:
+// 有关此类的实现,请参阅 WeChats.cpp
+//
+
+class CWeChatsApp : public CWinAppEx
+{
+public:
+	CWeChatsApp();
+
+// 重写
+	public:
+	virtual BOOL InitInstance();
+
+// 实现
+
+	DECLARE_MESSAGE_MAP()
+};
+
+extern CWeChatsApp theApp;

+ 197 - 0
source/hook/WeChats/WeChats.rc

@@ -0,0 +1,197 @@
+// Microsoft Visual C++ 生成的资源脚本。
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// 从 TEXTINCLUDE 2 资源生成。
+//
+#ifndef APSTUDIO_INVOKED
+#include "targetver.h"
+#endif
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+	"#ifndef APSTUDIO_INVOKED\r\n"
+    "#include ""targetver.h""\r\n"
+    "#endif\r\n"
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+    "#define _AFX_NO_OLE_RESOURCES\r\n"
+    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+    "\r\n"
+    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"
+    "LANGUAGE 4, 2\r\n"
+    "#pragma code_page(936)\r\n"
+    "#include ""res\\WeChats.rc2""  // 非 Microsoft Visual C++ 编辑的资源\r\n"
+    "#include ""l.CHS\\afxres.rc""  	// 标准组件\r\n"
+    "#endif\r\n"
+    "\0"
+END
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 图标
+//
+
+// ID 值最低的图标放在最前面,以确保应用程序图标
+// 在所有系统中保持一致。
+IDR_MAINFRAME           ICON         "res\\WeChats.ico"
+
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+LANGUAGE 4, 2
+#pragma code_page(936)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 对话框
+//
+
+IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "关于 WeChats"
+FONT 9, "MS Shell Dlg"
+BEGIN
+    ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20
+    LTEXT           "WeChats,1.0 版",IDC_STATIC,42,14,114,8,SS_NOPREFIX
+    LTEXT           "Copyright (C) 2019",IDC_STATIC,42,26,114,8
+    DEFPUSHBUTTON   "确定",IDOK,113,41,50,14,WS_GROUP
+END
+
+IDD_WECHATS_DIALOG DIALOGEX  0, 0, 320, 200
+STYLE DS_SHELLFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION
+ | DS_MODALFRAME
+ | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "WeChats"
+FONT 9, "MS Shell Dlg"
+BEGIN
+    DEFPUSHBUTTON   "确定",IDOK,209,179,50,14
+    PUSHBUTTON      "取消",IDCANCEL,263,179,50,14
+	CTEXT           "TODO: 在此放置对话框控件。",IDC_STATIC,10,96,300,8
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 版本
+//
+
+VS_VERSION_INFO     VERSIONINFO
+  FILEVERSION       1,0,0,1
+  PRODUCTVERSION    1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+	BLOCK "StringFileInfo"
+	BEGIN
+        BLOCK "080403a8"
+		BEGIN
+            VALUE "CompanyName", "TODO: <公司名>"
+            VALUE "FileDescription", "TODO: <文件说明>"
+			VALUE "FileVersion",     "1.0.0.1"
+			VALUE "InternalName",    "WeChats.exe"
+            VALUE "LegalCopyright", "TODO: (C) <公司名>。保留所有权利。"
+			VALUE "OriginalFilename","WeChats.exe"
+            VALUE "ProductName", "TODO: <产品名>"
+			VALUE "ProductVersion",  "1.0.0.1"
+		END
+	END
+	BLOCK "VarFileInfo"
+	BEGIN
+		VALUE "Translation", 0x0804, 936
+    END
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+    IDD_ABOUTBOX, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 163
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 55
+    END
+    IDD_WECHATS_DIALOG, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 313
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 193
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 字符串表
+//
+
+STRINGTABLE
+BEGIN
+    IDS_ABOUTBOX            "关于 WeChats(&A)..."
+END
+
+
+#endif
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// 从 TEXTINCLUDE 3 资源生成。
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+LANGUAGE 4, 2
+#pragma code_page(936)
+#include "res\\WeChats.rc2"  // 非 Microsoft Visual C++ 编辑的资源
+#include "l.CHS\\afxres.rc"  	// 标准组件
+#endif
+/////////////////////////////////////////////////////////////////////////////
+#endif    // 不是 APSTUDIO_INVOKED
+

+ 294 - 0
source/hook/WeChats/WeChats.vcproj

@@ -0,0 +1,294 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="WeChats"
+	ProjectGUID="{7704A546-A786-41C8-B22A-04BC05AE4F82}"
+	RootNamespace="WeChats"
+	Keyword="MFCProj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)\"
+			ConfigurationType="1"
+			UseOfMFC="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="_DEBUG"
+				MkTypLibCompatible="false"
+				ValidateParameters="true"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="2052"
+				AdditionalIncludeDirectories="$(IntDir)"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				UACExecutionLevel="2"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)\"
+			ConfigurationType="1"
+			UseOfMFC="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				PreprocessorDefinitions="NDEBUG"
+				MkTypLibCompatible="false"
+				ValidateParameters="true"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
+				MinimalRebuild="false"
+				RuntimeLibrary="0"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="2052"
+				AdditionalIncludeDirectories="$(IntDir)"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				UACExecutionLevel="2"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Ô´Îļþ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\Global.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\Injection.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\WeChats.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\WeChatsDlg.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Í·Îļþ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\Global.h"
+				>
+			</File>
+			<File
+				RelativePath=".\InjectInterface.h"
+				>
+			</File>
+			<File
+				RelativePath=".\Injection.h"
+				>
+			</File>
+			<File
+				RelativePath=".\Resource.h"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.h"
+				>
+			</File>
+			<File
+				RelativePath=".\targetver.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WeChats.h"
+				>
+			</File>
+			<File
+				RelativePath=".\WeChatsDlg.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="×ÊÔ´Îļþ"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+			<File
+				RelativePath=".\res\WeChats.ico"
+				>
+			</File>
+			<File
+				RelativePath=".\WeChats.rc"
+				>
+			</File>
+			<File
+				RelativePath=".\res\WeChats.rc2"
+				>
+			</File>
+		</Filter>
+		<File
+			RelativePath=".\config.ini"
+			>
+		</File>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 153 - 0
source/hook/WeChats/WeChatsDlg.cpp

@@ -0,0 +1,153 @@
+
+// WeChatsDlg.cpp : 实现文件
+//
+
+#include "stdafx.h"
+#include "WeChats.h"
+#include "WeChatsDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
+
+class CAboutDlg : public CDialog
+{
+public:
+	CAboutDlg();
+
+// 对话框数据
+	enum { IDD = IDD_ABOUTBOX };
+
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
+
+// 实现
+protected:
+	DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+END_MESSAGE_MAP()
+
+
+// CWeChatsDlg 对话框
+
+
+
+
+CWeChatsDlg::CWeChatsDlg(CWnd* pParent /*=NULL*/)
+	: CDialog(CWeChatsDlg::IDD, pParent)
+{
+	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CWeChatsDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialog::DoDataExchange(pDX);
+}
+
+BEGIN_MESSAGE_MAP(CWeChatsDlg, CDialog)
+	ON_WM_SYSCOMMAND()
+	ON_WM_PAINT()
+	ON_WM_QUERYDRAGICON()
+	//}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+// CWeChatsDlg 消息处理程序
+
+BOOL CWeChatsDlg::OnInitDialog()
+{
+	CDialog::OnInitDialog();
+
+	// 将“关于...”菜单项添加到系统菜单中。
+
+	// IDM_ABOUTBOX 必须在系统命令范围内。
+	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+	ASSERT(IDM_ABOUTBOX < 0xF000);
+
+	CMenu* pSysMenu = GetSystemMenu(FALSE);
+	if (pSysMenu != NULL)
+	{
+		BOOL bNameValid;
+		CString strAboutMenu;
+		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
+		ASSERT(bNameValid);
+		if (!strAboutMenu.IsEmpty())
+		{
+			pSysMenu->AppendMenu(MF_SEPARATOR);
+			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+		}
+	}
+
+	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
+	//  执行此操作
+	SetIcon(m_hIcon, TRUE);			// 设置大图标
+	SetIcon(m_hIcon, FALSE);		// 设置小图标
+
+	// TODO: 在此添加额外的初始化代码
+
+	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
+}
+
+void CWeChatsDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+	{
+		CAboutDlg dlgAbout;
+		dlgAbout.DoModal();
+	}
+	else
+	{
+		CDialog::OnSysCommand(nID, lParam);
+	}
+}
+
+// 如果向对话框添加最小化按钮,则需要下面的代码
+//  来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
+//  这将由框架自动完成。
+
+void CWeChatsDlg::OnPaint()
+{
+	if (IsIconic())
+	{
+		CPaintDC dc(this); // 用于绘制的设备上下文
+
+		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
+
+		// 使图标在工作区矩形中居中
+		int cxIcon = GetSystemMetrics(SM_CXICON);
+		int cyIcon = GetSystemMetrics(SM_CYICON);
+		CRect rect;
+		GetClientRect(&rect);
+		int x = (rect.Width() - cxIcon + 1) / 2;
+		int y = (rect.Height() - cyIcon + 1) / 2;
+
+		// 绘制图标
+		dc.DrawIcon(x, y, m_hIcon);
+	}
+	else
+	{
+		CDialog::OnPaint();
+	}
+}
+
+//当用户拖动最小化窗口时系统调用此函数取得光标
+//显示。
+HCURSOR CWeChatsDlg::OnQueryDragIcon()
+{
+	return static_cast<HCURSOR>(m_hIcon);
+}
+

+ 32 - 0
source/hook/WeChats/WeChatsDlg.h

@@ -0,0 +1,32 @@
+
+// WeChatsDlg.h : 头文件
+//
+
+#pragma once
+
+
+// CWeChatsDlg 对话框
+class CWeChatsDlg : public CDialog
+{
+// 构造
+public:
+	CWeChatsDlg(CWnd* pParent = NULL);	// 标准构造函数
+
+// 对话框数据
+	enum { IDD = IDD_WECHATS_DIALOG };
+
+	protected:
+	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持
+
+
+// 实现
+protected:
+	HICON m_hIcon;
+
+	// 生成的消息映射函数
+	virtual BOOL OnInitDialog();
+	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+	afx_msg void OnPaint();
+	afx_msg HCURSOR OnQueryDragIcon();
+	DECLARE_MESSAGE_MAP()
+};

+ 17 - 0
source/hook/WeChats/config.ini

@@ -0,0 +1,17 @@
+[ServerInfo]
+;服务器地址;
+IP=127.0.0.1
+;服务器端口号;
+Port=5566
+
+[CustomerInfo]
+;微信执行文件路径
+WeChat=C:\Program Files (x86)\Tencent\WeChat\WeChat.exe
+;客户端账号
+Account=
+;客户端密码
+Password=
+;缓存路径
+Cache=
+;是否调试
+StdOut=1

二进制
source/hook/WeChats/res/WeChats.ico


+ 13 - 0
source/hook/WeChats/res/WeChats.rc2

@@ -0,0 +1,13 @@
+//
+// WeChats.RC2 - Microsoft Visual C++ 不会直接编辑的资源
+//
+
+#ifdef APSTUDIO_INVOKED
+#error 此文件不能用 Microsoft Visual C++ 编辑
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// 在此处添加手动编辑的资源...
+
+/////////////////////////////////////////////////////////////////////////////

+ 8 - 0
source/hook/WeChats/stdafx.cpp

@@ -0,0 +1,8 @@
+
+// stdafx.cpp : 只包括标准包含文件的源文件
+// WeChats.pch 将作为预编译头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+
+

+ 60 - 0
source/hook/WeChats/stdafx.h

@@ -0,0 +1,60 @@
+
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+
+#pragma once
+
+#ifndef _SECURE_ATL
+#define _SECURE_ATL 1
+#endif
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN            // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // 某些 CString 构造函数将是显式的
+
+// 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏
+#define _AFX_ALL_WARNINGS
+
+#include <afxwin.h>         // MFC 核心组件和标准组件
+#include <afxext.h>         // MFC 扩展
+
+
+#include <afxdisp.h>        // MFC 自动化类
+
+
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include <afxdtctl.h>           // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h>             // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include <afxcontrolbars.h>     // 功能区和控件条的 MFC 支持
+
+
+#include "Global.h"
+
+
+
+
+
+
+#ifdef _UNICODE
+#if defined _M_IX86
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_IA64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#elif defined _M_X64
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#else
+#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+#endif
+#endif
+
+

+ 26 - 0
source/hook/WeChats/targetver.h

@@ -0,0 +1,26 @@
+
+#pragma once
+
+// 以下宏定义要求的最低平台。要求的最低平台
+// 是具有运行应用程序所需功能的 Windows、Internet Explorer 等产品的
+// 最早版本。通过在指定版本及更低版本的平台上启用所有可用的功能,宏可以
+// 正常工作。
+
+// 如果必须要针对低于以下指定版本的平台,请修改下列定义。
+// 有关不同平台对应值的最新信息,请参考 MSDN。
+#ifndef WINVER                          // 指定要求的最低平台是 Windows Vista。
+#define WINVER 0x0600           // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINNT            // 指定要求的最低平台是 Windows Vista。
+#define _WIN32_WINNT 0x0600     // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINDOWS          // 指定要求的最低平台是 Windows 98。
+#define _WIN32_WINDOWS 0x0410 // 将此值更改为适当的值,以适用于 Windows Me 或更高版本。
+#endif
+
+#ifndef _WIN32_IE                       // 指定要求的最低平台是 Internet Explorer 7.0。
+#define _WIN32_IE 0x0700        // 将此值更改为相应的值,以适用于 IE 的其他版本。
+#endif
+

+ 37 - 0
source/hook/hook/ReadMe.txt

@@ -0,0 +1,37 @@
+========================================================================
+    动态链接库:hook 项目概述
+========================================================================
+
+应用程序向导已为您创建了此 hook DLL。
+
+本文件概要介绍组成 hook 应用程序的
+的每个文件的内容。
+
+
+hook.vcproj
+    这是使用应用程序向导生成的 VC++ 项目的主项目文件,
+    其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
+
+hook.cpp
+    这是主 DLL 源文件。
+
+	此 DLL 在创建时不导出任何符号。因此,在生成此 DLL 时
+	将不会产生 .lib 文件。如果希望此项目
+	成为其他某个项目的项目依赖项,则需要
+	添加代码以从 DLL 导出某些符号,
+	以便产生一个导出库,或者,也可以在项目“属性页”对话框中的
+	“链接器”文件夹中,将“常规”属性页上的
+	“忽略输入库”属性设置为“是”。
+
+/////////////////////////////////////////////////////////////////////////////
+其他标准文件:
+
+StdAfx.h, StdAfx.cpp
+    这些文件用于生成名为 hook.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
+
+/////////////////////////////////////////////////////////////////////////////
+其他注释:
+
+应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
+
+/////////////////////////////////////////////////////////////////////////////

+ 21 - 0
source/hook/hook/dllmain.cpp

@@ -0,0 +1,21 @@
+// dllmain.cpp : 定义 DLL 应用程序的入口点。
+#include "stdafx.h"
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+                       DWORD  ul_reason_for_call,
+                       LPVOID lpReserved
+					 )
+{
+	switch (ul_reason_for_call)
+	{
+	case DLL_PROCESS_ATTACH:
+		MessageBox(NULL, _T("dll已成功注入"), _T("注入"), MB_OK);
+	case DLL_THREAD_ATTACH:
+	case DLL_THREAD_DETACH:
+	case DLL_PROCESS_DETACH:
+		MessageBox(NULL, _T("dll已成功卸载"), _T("注入"), MB_OK);
+		break;
+	}
+	return TRUE;
+}
+

+ 6 - 0
source/hook/hook/hook.cpp

@@ -0,0 +1,6 @@
+// hook.cpp : 定义 DLL 应用程序的导出函数。
+//
+
+#include "stdafx.h"
+
+

+ 247 - 0
source/hook/hook/hook.vcproj

@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="gb2312"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="hook"
+	ProjectGUID="{4E160416-52D6-454E-943D-4DD7E1150D25}"
+	RootNamespace="hook"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)\"
+			ConfigurationType="2"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)\"
+			ConfigurationType="2"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;HOOK_EXPORTS"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Ô´Îļþ"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath=".\dllmain.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+						CompileAsManaged="0"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+						CompileAsManaged="0"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath=".\hook.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Í·Îļþ"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath=".\stdafx.h"
+				>
+			</File>
+			<File
+				RelativePath=".\targetver.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="×ÊÔ´Îļþ"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 8 - 0
source/hook/hook/stdafx.cpp

@@ -0,0 +1,8 @@
+// stdafx.cpp : 只包括标准包含文件的源文件
+// hook.pch 将作为预编译头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+
+// TODO: 在 STDAFX.H 中
+// 引用任何所需的附加头文件,而不是在此文件中引用

+ 16 - 0
source/hook/hook/stdafx.h

@@ -0,0 +1,16 @@
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN             // 从 Windows 头中排除极少使用的资料
+// Windows 头文件:
+#include <windows.h>
+#include <tchar.h>
+
+
+// TODO: 在此处引用程序需要的其他头文件

+ 24 - 0
source/hook/hook/targetver.h

@@ -0,0 +1,24 @@
+#pragma once
+
+// 以下宏定义要求的最低平台。要求的最低平台
+// 是具有运行应用程序所需功能的 Windows、Internet Explorer 等产品的
+// 最早版本。通过在指定版本及更低版本的平台上启用所有可用的功能,宏可以
+// 正常工作。
+
+// 如果必须要针对低于以下指定版本的平台,请修改下列定义。
+// 有关不同平台对应值的最新信息,请参考 MSDN。
+#ifndef WINVER                          // 指定要求的最低平台是 Windows Vista。
+#define WINVER 0x0600           // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINNT            // 指定要求的最低平台是 Windows Vista。
+#define _WIN32_WINNT 0x0600     // 将此值更改为相应的值,以适用于 Windows 的其他版本。
+#endif
+
+#ifndef _WIN32_WINDOWS          // 指定要求的最低平台是 Windows 98。
+#define _WIN32_WINDOWS 0x0410 // 将此值更改为适当的值,以适用于 Windows Me 或更高版本。
+#endif
+
+#ifndef _WIN32_IE                       // 指定要求的最低平台是 Internet Explorer 7.0。
+#define _WIN32_IE 0x0700        // 将此值更改为相应的值,以适用于 IE 的其他版本。
+#endif