⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwin.cpp

📁 飞鸽传书源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	if (mode == IPMSG_BR_ENTRY && cfg->ExtendEntry)
		::SetTimer(hWnd, IPMSG_ENTRY_TIMER, IPMSG_ENTRYMINSEC * 1000, NULL);
}

/*
	IPMSG_ENTRY/IPMSG_EXIT/IPMSG_ABSENCE僷働僢僩憲弌Sub
*/
void TMainWin::BroadcastEntrySub(ULONG addr, int port_no, ULONG mode)
{
	if (addr == 0)
		return;

	HostSub	hostSub;

	hostSub.addr 	= addr;
	hostSub.portNo	= port_no;

	BroadcastEntrySub(&hostSub, mode);
}

void TMainWin::BroadcastEntrySub(HostSub *hostSub, ULONG mode)
{
	if (mode == IPMSG_NOOPERATION)
		msgMng->Send(hostSub, mode);
	else
		msgMng->Send(hostSub, mode | (cfg->DialUpCheck ? IPMSG_DIALUPOPT : 0) | HostStatus(), GetNickNameEx(),  cfg->GroupNameStr);
}

/*
	icon 斀揮張棟丅startFlg == TRUE偺応崌丄媡icon偵 Reset偝傟傞
*/
void TMainWin::ReverseIcon(BOOL startFlg)
{
	static	cnt = 0;

	if (startFlg)
		cnt = 0;

	SetIcon(cnt++ % 2 ? hMainIcon : hRevIcon);
}

/*
	巜掕icon傪 MainWindow or TaskTray 偵僙僢僩
*/
void TMainWin::SetIcon(HICON hSetIcon)
{
	if (IsNewShell())
		TaskBar(NIM_MODIFY, hSetIcon);
	else {
		::SetClassLong(hWnd, GCL_HICON, (LONG)hSetIcon);
		::FlashWindow(hWnd, FALSE);
	}
}

/*
	HostList憲弌張棟
	庤敳偒 ... 僨儕儈僞傗僨乕僞偑側偄応崌偵摿庩暥帤('\a','\b')傪巊梡
*/
void TMainWin::SendHostList(MsgBuf *msg)
{
	int		start_no, len, total_len = 0, host_cnt = 0;
	char	*buf = new char [MAX_UDPBUF];
	char	tmp[MAX_BUF];

	if ((start_no = atoi(msg->msgBuf)) < 0)
		start_no = 0;

	total_len = wsprintf(buf, "%5d%c%5d%c", 0, HOSTLIST_SEPARATOR, 0, HOSTLIST_SEPARATOR);

	for (int cnt=start_no; cnt < hosts.HostCnt(); cnt++)
	{
		Host	*host = hosts.GetHost(cnt);
		if ((len = wsprintf(tmp, "%s%c%s%c%ld%c%s%c%d%c%s%c%s%c",
			host->hostSub.userName, HOSTLIST_SEPARATOR,
			host->hostSub.hostName, HOSTLIST_SEPARATOR,
			host->hostStatus, HOSTLIST_SEPARATOR,
			inet_ntoa(*(LPIN_ADDR)&host->hostSub.addr), HOSTLIST_SEPARATOR,
			host->hostSub.portNo, HOSTLIST_SEPARATOR,
			*host->nickName ? host->nickName : HOSTLIST_DUMMY, HOSTLIST_SEPARATOR,
			*host->groupName ? host->groupName : HOSTLIST_DUMMY, HOSTLIST_SEPARATOR
			)) + total_len +80 >= MAX_UDPBUF)	// +80 : ipmsg protocol header reserve
		{
			break;
		}
		memcpy(buf + total_len, tmp, len +1);
		total_len += len;
		host_cnt++;
	}
	len = wsprintf(tmp, "%5d%c%5d", start_no + host_cnt == hosts.HostCnt() ? 0 : start_no + host_cnt, HOSTLIST_SEPARATOR, host_cnt);
	memcpy(buf, tmp, len);
	msgMng->Send(&msg->hostSub, IPMSG_ANSLIST, buf);
	delete [] buf;
}

/*
	HostList庴怣張棟
*/
void TMainWin::AddHostList(MsgBuf *msg)
{
	char	*tok, *nickName, *groupName, *p;
	HostSub	hostSub;
	ULONG	host_status;
	int		total_num, continue_cnt;

	if ((tok = separate_token(msg->msgBuf, HOSTLIST_SEPARATOR, &p)) == NULL)
		return;
	continue_cnt = atoi(tok);

	if ((tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
		return;
	total_num = atoi(tok);

	for (int host_cnt=0; (tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) != NULL; host_cnt++)
	{
		nickName = groupName = NULL;
		strncpyz(hostSub.userName, tok, sizeof(hostSub.userName));

		if ((tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		strncpyz(hostSub.hostName, tok, sizeof(hostSub.hostName));

		if ((tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		host_status = atol(tok);

		if ((tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		hostSub.addr = inet_addr(tok);

		if ((tok = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		hostSub.portNo = atoi(tok);

		if ((nickName = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		if (strcmp(nickName, HOSTLIST_DUMMY) == 0)
			nickName = "";

		if ((groupName = separate_token(NULL, HOSTLIST_SEPARATOR, &p)) == NULL)
			break;
		if (strcmp(groupName, HOSTLIST_DUMMY) == 0)
			groupName = "";

		AddHost(&hostSub, IPMSG_BR_ENTRY|host_status, nickName, groupName);
	}

	if (continue_cnt || host_cnt < total_num)
	{
		msgMng->Send(&msg->hostSub, IPMSG_GETLIST, abs(continue_cnt - (total_num - host_cnt)));
		if (::SetTimer(hWnd, IPMSG_LISTGETRETRY_TIMER, cfg->ListGetMSec, NULL))
			entryTimerStatus = IPMSG_LISTGETRETRY_TIMER;
	}
	else {
		entryStartTime = IPMSG_GETLIST_FINISH;
		if (cfg->ListGet)
			BroadcastEntry(IPMSG_BR_ENTRY);
	}
}

/*
	Log傪奐偔
*/
void TMainWin::LogOpen(void)
{
	int		ret;

	if ((ret = (int)ShellExecute(0, NULL, cfg->LogFile, NULL, NULL, SW_SHOW)) <= WINEXEC_ERR_MAX)
	{
		switch (ret)
		{
		case SE_ERR_NOASSOC: case SE_ERR_ASSOCINCOMPLETE:
			MessageBox(FILEEXTERR_MSGSTR);
			break;
		default:
			MessageBox(CANTOPENLOG_MSGSTR);
			break;
		}
	}
}

/*
	帺Host偺 Status (dialup mode / absence mode)
*/
ULONG TMainWin::HostStatus(void)
{
	return	(cfg->DialUpCheck ? IPMSG_DIALUPOPT : 0) | (cfg->AbsenceCheck ? IPMSG_ABSENCEOPT : 0) | (msgMng->IsAvailableTCP() ? IPMSG_FILEATTACHOPT : 0) | (cfg->pubKey.Key() || cfg->smallPubKey.Key() ? IPMSG_ENCRYPTOPT : 0);
}

/*
	IPMSG梡 icon弶婜壔
*/
void  TMainWin::InitIcon(void)
{
	if (*cfg->IconFile == 0 || (hMainIcon = ::ExtractIcon(TApp::hI, cfg->IconFile, 0)) == NULL)
		hMainIcon = ::LoadIcon(TApp::hI, (LPCSTR)IPMSG_ICON);
	if (*cfg->RevIconFile == 0 || (hRevIcon = ::ExtractIcon(TApp::hI, cfg->RevIconFile, 0)) == NULL)
		hRevIcon = ::LoadIcon(TApp::hI, (LPCSTR)RECV_ICON);
}

/*
	MainWindow icon傪嫵偊偰偁偘傞丅
	偙偺 routine偼 static member function 偱偁傝丄SendDlg側偳偐傜屇偽傟傞丅
*/
HICON TMainWin::GetIPMsgIcon(void)
{
	return	hMainIcon;
}

/*
	ListDlg 傪 Active or Hide偵乮扨側傞娙堈儖乕僠儞乯
*/
void TMainWin::ActiveListDlg(TList *list, BOOL active)
{
	for (TListDlg *dlg = (TListDlg *)list->TopObj(); dlg != NULL; dlg = (TListDlg *)list->NextObj(dlg))
		ActiveDlg(dlg, active);
}

/*
	ListDlg 傪 Delete 偡傞乮扨側傞娙堈儖乕僠儞乯
*/
void TMainWin::DeleteListDlg(TList *list)
{
	TListDlg *dlg;

	while ((dlg = (TListDlg *)list->TopObj()) != NULL)
	{
		list->DelObj(dlg);
		delete dlg;
	}
}

/*
	Dlg 傪 Active or Hide偵
*/
void TMainWin::ActiveDlg(TDlg *dlg, BOOL active)
{
	if (dlg->hWnd != 0)
		active ? dlg->Show(), dlg->SetForegroundWindow() : dlg->Show(SW_HIDE);
}

/*
	Extend NickName
*/
char *TMainWin::GetNickNameEx(void)
{
	static char buf[MAX_LISTBUF];

	if (cfg->AbsenceCheck && *cfg->AbsenceHead[cfg->AbsenceChoice])
		wsprintf(buf, "%s[%s]", *cfg->NickNameStr ? cfg->NickNameStr : msgMng->GetLocalHost()->userName, cfg->AbsenceHead[cfg->AbsenceChoice]);
	else
		strcpy(buf, *cfg->NickNameStr ? cfg->NickNameStr : msgMng->GetLocalHost()->userName);

	return	buf;
}

/* VC4 偱 CryptoAPI 傪巊梡壜擻偵偡傞 */
BOOL (WINAPI *pCryptAcquireContext)(HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD);
BOOL (WINAPI *pCryptDestroyKey)(HCRYPTKEY);
BOOL (WINAPI *pCryptGetKeyParam)(HCRYPTKEY, DWORD, BYTE *, DWORD *, DWORD);
BOOL (WINAPI *pCryptSetKeyParam)(HCRYPTKEY, DWORD, BYTE *, DWORD);
BOOL (WINAPI *pCryptExportKey)(HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, BYTE *, DWORD *);
BOOL (WINAPI *pCryptGetUserKey)(HCRYPTPROV, DWORD, HCRYPTKEY *);
BOOL (WINAPI *pCryptEncrypt)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD);
BOOL (WINAPI *pCryptGenKey)(HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY *);
BOOL (WINAPI *pCryptGenRandom)(HCRYPTPROV, DWORD, BYTE *);
BOOL (WINAPI *pCryptImportKey)(HCRYPTPROV, CONST BYTE *, DWORD, HCRYPTKEY, DWORD, HCRYPTKEY *);
BOOL (WINAPI *pCryptDecrypt)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *);
BOOL (WINAPI *pCryptReleaseContext)(HCRYPTPROV, DWORD);

BOOL (WINAPI *pCryptCreateHash)(HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH *);
BOOL (WINAPI *pCryptHashData)(HCRYPTHASH, BYTE *, DWORD, DWORD);
BOOL (WINAPI *pCryptSignHash)(HCRYPTHASH, DWORD, LPCSTR, DWORD, BYTE *, DWORD *);
BOOL (WINAPI *pCryptVerifySignature)(HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCSTR, DWORD);

BOOL TMainWin::SetupCryptAPI(void)
{
	HINSTANCE	advdll;

	cfg->hCsp = cfg->hSmallCsp = NULL;

	if ((advdll = ::LoadLibrary("advapi32.dll")) == NULL)
		return	GetLastErrorMsg("advapi32"), FALSE;

	pCryptAcquireContext = (BOOL (WINAPI *)(HCRYPTPROV *, LPCSTR, LPCSTR, DWORD, DWORD))::GetProcAddress(advdll, "CryptAcquireContextA");
	pCryptDestroyKey = (BOOL (WINAPI *)(HCRYPTKEY))::GetProcAddress(advdll, "CryptDestroyKey");
	pCryptGetKeyParam = (BOOL (WINAPI *)(HCRYPTKEY, DWORD, BYTE *, DWORD *, DWORD))::GetProcAddress(advdll, "CryptGetKeyParam");
	pCryptSetKeyParam = (BOOL (WINAPI *)(HCRYPTKEY, DWORD, BYTE *, DWORD))::GetProcAddress(advdll, "CryptSetKeyParam");
	pCryptExportKey = (BOOL (WINAPI *)(HCRYPTKEY, HCRYPTKEY, DWORD, DWORD, BYTE *, DWORD *))::GetProcAddress(advdll, "CryptExportKey");
	pCryptGetUserKey = (BOOL (WINAPI *)(HCRYPTPROV, DWORD, HCRYPTKEY *))::GetProcAddress(advdll, "CryptGetUserKey");
	pCryptEncrypt = (BOOL (WINAPI *)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD))::GetProcAddress(advdll, "CryptEncrypt");
	pCryptGenKey = (BOOL (WINAPI *)(HCRYPTPROV, ALG_ID, DWORD, HCRYPTKEY *))::GetProcAddress(advdll, "CryptGenKey");
	pCryptGenRandom = (BOOL (WINAPI *)(HCRYPTPROV, DWORD, BYTE *))::GetProcAddress(advdll, "CryptGenRandom");
	pCryptImportKey = (BOOL (WINAPI *)(HCRYPTPROV, CONST BYTE *, DWORD, HCRYPTKEY, DWORD, HCRYPTKEY *))::GetProcAddress(advdll, "CryptImportKey");
	pCryptDecrypt = (BOOL (WINAPI *)(HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *))::GetProcAddress(advdll, "CryptDecrypt");
	pCryptCreateHash = (BOOL (WINAPI *)(HCRYPTPROV, ALG_ID, HCRYPTKEY, DWORD, HCRYPTHASH *))::GetProcAddress(advdll, "CryptCreateHash");
	pCryptHashData = (BOOL (WINAPI *)(HCRYPTHASH, BYTE *, DWORD, DWORD))::GetProcAddress(advdll, "CryptHashData");
	pCryptSignHash = (BOOL (WINAPI *)(HCRYPTHASH, DWORD, LPCSTR, DWORD, BYTE *, DWORD *))::GetProcAddress(advdll, "CryptSignHashA");
	pCryptVerifySignature = (BOOL (WINAPI *)(HCRYPTHASH, CONST BYTE *, DWORD, HCRYPTKEY, LPCSTR, DWORD))::GetProcAddress(advdll, "CryptVerifySignatureA");
	pCryptReleaseContext = (BOOL (WINAPI *)(HCRYPTPROV, DWORD))::GetProcAddress(advdll, "CryptReleaseContext");

	if (pCryptAcquireContext == NULL)
		return	GetLastErrorMsg("GetProcAddress"), FALSE;

	SetupCryptAPICore();
#define MAX_RETRY	3
	int	cnt = 0;
	while (cfg->hCsp && cfg->pubKey.Key() == NULL || cfg->hSmallCsp && cfg->smallPubKey.Key() == NULL)
	{
		if (++cnt > MAX_RETRY)
			break;
		if (cfg->hCsp)
			pCryptReleaseContext(cfg->hCsp, 0), cfg->hCsp = NULL;
		if (cfg->hSmallCsp)
			pCryptReleaseContext(cfg->hSmallCsp, 0), cfg->hSmallCsp = NULL;
		::Sleep(1000);
		SetupCryptAPICore(cnt == MAX_RETRY ? KEY_DIAG : 0);
	}
	if (cnt > MAX_RETRY || cfg->pubKey.Key() == NULL && cfg->smallPubKey.Key() == NULL)
	{
		if (MessageBox("RSA failed. Create New RSA key?", "msg", MB_OKCANCEL) == IDOK)
			SetupCryptAPICore(KEY_REBUILD|KEY_DIAG);
	}

	return	cfg->pubKey.Key() || cfg->smallPubKey.Key();
}

BOOL TMainWin::SetupCryptAPICore(int ctl_flg)
{
	BYTE		data[MAX_BUF];
	char		*contName = (char *)data;
	HCRYPTKEY	hExKey;
	int			len = sizeof(data);
	int			capa = IPMSG_RSA_512 | IPMSG_RC2_40ALL;

// 1024 bit RSA 尞
	wsprintf(contName, "ipmsg.rsa1024.%s", msgMng->GetLocalHost()->userName);

	// rebuld 帪偵偼丄帠慜偵岞奐尞傪徚嫀
	if ((ctl_flg & KEY_REBUILD) && cfg->hCsp && cfg->pubKey.Key() == NULL)
	{
		pCryptReleaseContext(cfg->hCsp, 0), cfg->hCsp = NULL;
		if (!pCryptAcquireContext(&cfg->hCsp, contName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET))
			if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptAcquireContext1024(destroy)");
		!pCryptAcquireContext(&cfg->hCsp, contName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
	}

	// 岞奐尞偺庢摼
	if (pCryptAcquireContext(&cfg->hCsp, contName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET)
	|| pCryptAcquireContext(&cfg->hCsp, contName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET))
	{
		if (!pCryptGetUserKey(cfg->hCsp, AT_KEYEXCHANGE, &hExKey))
			if (!pCryptGenKey(cfg->hCsp, CALG_RSA_KEYX, CRYPT_EXPORTABLE, &hExKey))
				GetLastErrorMsg("CryptGenKey");
		if (pCryptExportKey(hExKey, 0, PUBLICKEYBLOB, 0, data, (DWORD *)&len))
		{
			capa |= IPMSG_RSA_1024 | IPMSG_BLOWFISH_128ALL /* | IPMSG_BLOWFISH_256 */;
			HCRYPTKEY	hKey;
			if (pCryptGenKey(cfg->hCsp, CALG_RC2, CRYPT_EXPORTABLE, &hKey))
			{
				DWORD		val=128;	// available 128bit RC2?
				if (pCryptSetKeyParam(hKey, KP_EFFECTIVE_KEYLEN, (BYTE *)&val, 0))
					capa |= IPMSG_RC2_128ALL;
				pCryptDestroyKey(hKey);
			}
			cfg->pubKey.SetByBlob(data, capa);
		} else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptExportKey");
		pCryptDestroyKey(hExKey);
	} /* else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptAcquireContext"); */

// 512 bit RSA 尞
	wsprintf(contName, "ipmsg.rsa512.%s", msgMng->GetLocalHost()->userName);

	// REBUILD 帪偵偼丄帠慜偵岞奐尞傪徚嫀
	if ((ctl_flg & KEY_REBUILD) && cfg->hSmallCsp && cfg->smallPubKey.Key() == NULL)
	{
		pCryptReleaseContext(cfg->hSmallCsp, 0), cfg->hSmallCsp = NULL;
		if (!pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET|CRYPT_MACHINE_KEYSET))
			if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptAcquireContext512(destroy)");
		pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
	}

	// 岞奐尞偺庢摼
	if (pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET) || pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, 0)
	|| pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET) || pCryptAcquireContext(&cfg->hSmallCsp, contName, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET))
	{
		if (!pCryptGetUserKey(cfg->hSmallCsp, AT_KEYEXCHANGE, &hExKey))
			pCryptGenKey(cfg->hSmallCsp, CALG_RSA_KEYX, CRYPT_EXPORTABLE, &hExKey);
		if (pCryptExportKey(hExKey, 0, PUBLICKEYBLOB, 0, data, (DWORD *)&len))
		{
			cfg->smallPubKey.SetByBlob(data, capa);
		} else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptExportKey512");
		pCryptDestroyKey(hExKey);
	} else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptAcquireContext512");

// Self Check 1024bit
	if (cfg->pubKey.Key()) {
		BOOL	ret = FALSE;

		cfg->pubKey.KeyBlob(data, sizeof(data), &len);
		if (pCryptImportKey(cfg->hCsp, data, len, 0, 0, &hExKey)) {
			len = 128/8;
			if (pCryptEncrypt(hExKey, 0, TRUE, 0, data, (DWORD *)&len, MAX_BUF))
				ret = TRUE;
			else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptEncrypt test1024");
			pCryptDestroyKey(hExKey);
		}
		else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptImportKey test1024");

		if (ret == TRUE) {
			ret = FALSE;
			if (pCryptGetUserKey(cfg->hCsp, AT_KEYEXCHANGE, &hExKey)) {
				if (pCryptDecrypt(hExKey, 0, TRUE, 0, (BYTE *)data, (DWORD *)&len))
					ret = TRUE;
				else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptDecrypt test1024");
				pCryptDestroyKey(hExKey);
			}
			else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptGetUserKey test1024");
		}

		if (ret == FALSE)
			cfg->pubKey.UnSet();
	}

// Self Check 512bit
	if (cfg->smallPubKey.Key()) {
		BOOL		ret = FALSE;
		BYTE		tmp[MAX_BUF];
		DWORD		tmplen = MAX_BUF / 2;
		HCRYPTKEY	hKey;

		cfg->smallPubKey.KeyBlob(data, sizeof(data), &len);
		if (pCryptImportKey(cfg->hSmallCsp, data, len, 0, 0, &hExKey)) {
			if (pCryptGenKey(cfg->hSmallCsp, CALG_RC2, CRYPT_EXPORTABLE, &hKey)) {
				pCryptExportKey(hKey, hExKey, SIMPLEBLOB, 0, NULL, (DWORD *)&len);
				if (pCryptExportKey(hKey, hExKey, SIMPLEBLOB, 0, data, (DWORD *)&len)) {
					if (pCryptEncrypt(hKey, 0, TRUE, 0, tmp, &tmplen, MAX_BUF))
						ret = TRUE;
					else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptEncrypt test512");
				}
				else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptExportKey test512");
				pCryptDestroyKey(hKey);
			}
			else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptGenKey test512");
			pCryptDestroyKey(hExKey);
		}
		else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptImportKey test512");

		if (ret == TRUE) {
			ret = FALSE;
			if (pCryptImportKey(cfg->hSmallCsp, data, len, 0, 0, &hKey)) {
				if (pCryptDecrypt(hKey, 0, TRUE, 0, (BYTE *)tmp, (DWORD *)&tmplen))
					ret = TRUE;
				else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptDecrypt test512");
				pCryptDestroyKey(hKey);
			}
			else if (ctl_flg & KEY_DIAG) GetLastErrorMsg("CryptImportKey test512");
		}

		if (ret == FALSE)
			cfg->smallPubKey.UnSet();
	}

	return	cfg->pubKey.Key() || cfg->smallPubKey.Key();
}

void TMainWin::ControlIME(TWin *win, BOOL open)
{
	HWND	targetWnd = (win && win->hWnd) ? win->GetDlgItem(SEND_EDIT) : hWnd;

	if (win && win->hWnd && open == FALSE)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -