X-Git-Url: http://git.sourceforge.jp/view?p=ffftp%2Fffftp.git;a=blobdiff_plain;f=main.c;h=b8900862a9e7e2a3acd43ab7b5fcd0a8dec229d8;hp=dc72034f106a7e14dff5d00c84936a898e5dbf26;hb=663728dfaea4b4e0da170722b4046764e01555dc;hpb=e3fbb7cd21b2044f9158af2ebf9b5cf7f2860bbe diff --git a/main.c b/main.c index dc72034..b890086 100644 --- a/main.c +++ b/main.c @@ -28,6 +28,8 @@ /============================================================================*/ #define STRICT +// IPv6対応 +#include #include #include #include @@ -37,11 +39,14 @@ #include #include #include -#include +// IPv6対応 +//#include #include "common.h" #include "resource.h" #include "aes.h" +// 暗号化通信対応 +#include "sha.h" #include #include "helpid.h" @@ -79,7 +84,9 @@ static void CalcWinSize(void); static void CheckResizeFrame(WPARAM Keys, int x, int y); static void DispDirInfo(void); static void DeleteAlltempFile(void); -static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +// 64ビット対応 +//static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); static int EnterMasterPasswordAndSet( int Res, HWND hWnd ); /*===== ローカルなワーク =====*/ @@ -125,6 +132,11 @@ static int SuppressRefresh = 0; static DWORD dwCookie; +// 暗号化通信対応 +static char SSLRootCAFilePath[FMAX_PATH+1]; +// マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策 +static DWORD MainThreadId; + /*===== グローバルなワーク =====*/ @@ -133,12 +145,20 @@ HWND hHelpWin = NULL; /* 設定値 */ int WinPosX = CW_USEDEFAULT; int WinPosY = 0; -int WinWidth = 630; -int WinHeight = 393; -int LocalWidth = 309; -int TaskHeight = 50; -int LocalTabWidth[4] = { 120, 90, 60, 37 }; -int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 }; +// 機能が増えたためサイズ変更 +// VGAサイズに収まるようになっていたのをSVGAサイズに引き上げ +//int WinWidth = 630; +//int WinHeight = 393; +//int LocalWidth = 309; +//int TaskHeight = 50; +//int LocalTabWidth[4] = { 120, 90, 60, 37 }; +//int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 }; +int WinWidth = 790; +int WinHeight = 513; +int LocalWidth = 389; +int TaskHeight = 100; +int LocalTabWidth[4] = { 160, 110, 60, 37 }; +int RemoteTabWidth[6] = { 160, 110, 60, 37, 60, 60 }; char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" }; char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } }; HFONT ListFont = NULL; @@ -208,8 +228,14 @@ int MirUpDelNotify = YES; int MirDownDelNotify = YES; int FolderAttr = NO; int FolderAttrNum = 777; -// 同時接続対応 -int MaxThreadCount = 1; +// 暗号化通信対応 +BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20]; +BYTE SSLRootCAFileHash[20]; +// ファイルアイコン表示対応 +int DispFileIcon = NO; +// ディレクトリ自動作成 +int MakeAllDir = NO; + @@ -234,71 +260,75 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi // プロセス保護 #ifdef ENABLE_PROCESS_PROTECTION - DWORD ProtectLevel; - char* pCommand; - char Option[FMAX_PATH+1]; - ProtectLevel = PROCESS_PROTECTION_NONE; - pCommand = lpszCmdLine; - while(pCommand = GetToken(pCommand, Option)) { - if(strcmp(Option, "--protect") == 0) + DWORD ProtectLevel; + char* pCommand; + char Option[FMAX_PATH+1]; + ProtectLevel = PROCESS_PROTECTION_NONE; + pCommand = lpszCmdLine; + while(pCommand = GetToken(pCommand, Option)) { - ProtectLevel = PROCESS_PROTECTION_DEFAULT; - break; - } - else if(strcmp(Option, "--protect-high") == 0) - { - ProtectLevel = PROCESS_PROTECTION_HIGH; - break; - } - else if(strcmp(Option, "--protect-medium") == 0) - { - ProtectLevel = PROCESS_PROTECTION_MEDIUM; - break; - } - else if(strcmp(Option, "--protect-low") == 0) - { - ProtectLevel = PROCESS_PROTECTION_LOW; - break; + if(strcmp(Option, "--protect") == 0) + { + ProtectLevel = PROCESS_PROTECTION_DEFAULT; + break; + } + else if(strcmp(Option, "--protect-high") == 0) + { + ProtectLevel = PROCESS_PROTECTION_HIGH; + break; + } + else if(strcmp(Option, "--protect-medium") == 0) + { + ProtectLevel = PROCESS_PROTECTION_MEDIUM; + break; + } + else if(strcmp(Option, "--protect-low") == 0) + { + ProtectLevel = PROCESS_PROTECTION_LOW; + break; + } } - } - if(ProtectLevel != PROCESS_PROTECTION_NONE) - { - SetProcessProtectionLevel(ProtectLevel); - if(!InitializeLoadLibraryHook()) + if(ProtectLevel != PROCESS_PROTECTION_NONE) { - MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR); - return 0; - } + SetProcessProtectionLevel(ProtectLevel); + if(!InitializeLoadLibraryHook()) + { + MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR); + return 0; + } #ifndef _DEBUG - if(IsDebuggerPresent()) - { - MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR); - return 0; - } + if(IsDebuggerPresent()) + { + MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR); + return 0; + } #endif - if(!UnloadUntrustedModule()) - { - MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR); - return 0; - } + if(!UnloadUntrustedModule()) + { + MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR); + return 0; + } #ifndef _DEBUG - if(RestartProtectedProcess(" --restart")) - return 0; + if(RestartProtectedProcess(" --restart")) + return 0; #endif - if(!EnableLoadLibraryHook(TRUE)) - { - MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR); - return 0; + if(!EnableLoadLibraryHook(TRUE)) + { + MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR); + return 0; + } } + else + InitializeLoadLibraryHook(); } - else - InitializeLoadLibraryHook(); #endif + // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策 #ifdef DISABLE_MULTI_CPUS SetProcessAffinityMask(GetCurrentProcess(), 1); #endif + MainThreadId = GetCurrentThreadId(); // yutaka if(OleInitialize(NULL) != S_OK){ @@ -313,6 +343,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi LoadOpenSSL(); #endif + // SFTP対応 + LoadPuTTY(); + Ret = FALSE; hWndFtp = NULL; hInstFtp = hInstance; @@ -324,7 +357,9 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi if((Sts == 0) || (Sts == -1)) break; - if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) + // 64ビット対応 +// if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) + if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg)) { /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */ /* コンボボックス内ではアクセラレータを無効にする */ @@ -346,6 +381,8 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi #ifdef USE_OPENSSL FreeOpenSSL(); #endif + // SFTP対応 + FreePuTTY(); OleUninitialize(); return(Ret); } @@ -378,7 +415,9 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) aes_init(); srand(GetTickCount()); - HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie); + // 64ビット対応 +// HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie); + HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie); SaveUpdateBellInfo(); @@ -388,7 +427,11 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) { Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel)); - GetTempPath(FMAX_PATH, TmpPath); + // 環境依存の不具合対策 +// GetTempPath(FMAX_PATH, TmpPath); + GetAppTempPath(TmpPath); + _mkdir(TmpPath); + SetYenTail(TmpPath); GetModuleFileName(NULL, HelpPath, FMAX_PATH); strcpy(GetFileName(HelpPath), "ffftp.chm"); @@ -409,7 +452,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) /* 2010.02.01 genta マスターパスワードを入力させる -z オプションがあるときは最初だけスキップ -z オプションがないときは,デフォルトパスワードをまず試す - LoadRegistory()する + LoadRegistry()する パスワードが不一致なら再入力するか尋ねる. (破損していた場合はさせない) */ @@ -454,10 +497,14 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) if(masterpass != 0) { - LoadRegistory(); + LoadRegistry(); // 暗号化通信対応 SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback); + SetSSLConfirmCallback(SSLConfirmCallback); + GetModuleFileName(NULL, SSLRootCAFilePath, FMAX_PATH); + strcpy(GetFileName(SSLRootCAFilePath), "ssl.pem"); + LoadSSLRootCAFile(); LoadJre(); if(NoRasControl == NO) @@ -499,7 +546,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) DispWindowTitle(); // SourceForge.JPによるフォーク // SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators."); - SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, raido)."); + SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011-2012 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, Asami, fortran90, tomo1192, Yuji Tanaka, Moriguchi Hirokazu)."); if(ForceIni) SetTaskMsg("%s%s", MSGJPN283, IniPath); @@ -607,13 +654,7 @@ static int MakeAllWindows(int cmdShow) WinPosX = CW_USEDEFAULT; WinPosY = 0; } - // UTF-8対応 - // ユーザー定義のクラスはデフォルトのWNDPROCがShift_JIS専用のため -// hWndFtp = CreateWindow(FtpClassStr, "FFFTP", -// WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, -// WinPosX, WinPosY, WinWidth, WinHeight, -// HWND_DESKTOP, 0, hInstFtp, NULL); - hWndFtp = CreateWindowA(FtpClassStr, "FFFTP", + hWndFtp = CreateWindow(FtpClassStr, "FFFTP", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WinPosX, WinPosY, WinWidth, WinHeight, HWND_DESKTOP, 0, hInstFtp, NULL); @@ -820,21 +861,43 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA { PAINTSTRUCT ps; LPTOOLTIPTEXT lpttt; + // UTF-8対応 + LPTOOLTIPTEXTW wlpttt; RECT Rect; int TmpTransType; switch (message) { + // 自動切断対策 + case WM_TIMER : + if(wParam == 1) + NoopProc(); + break; + case WM_COMMAND : + // 同時接続対応 + // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない + if(CancelFlg == YES) + RemoveReceivedData(AskCmdCtrlSkt()); switch(LOWORD(wParam)) { case MENU_CONNECT : + // 自動切断対策 + KillTimer(hWnd, 1); ConnectProc(DLG_TYPE_CON, -1); + // 自動切断対策 + if(AskNoopInterval() > 0) + SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL); break; case MENU_CONNECT_NUM : + // 自動切断対策 + KillTimer(hWnd, 1); ConnectProc(DLG_TYPE_CON, (int)lParam); + // 自動切断対策 + if(AskNoopInterval() > 0) + SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL); if(AskConnecting() == YES) { if(HIWORD(wParam) & OPT_MIRROR) @@ -855,11 +918,21 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case MENU_SET_CONNECT : + // 自動切断対策 + KillTimer(hWnd, 1); ConnectProc(DLG_TYPE_SET, -1); + // 自動切断対策 + if(AskNoopInterval() > 0) + SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL); break; case MENU_QUICK : + // 自動切断対策 + KillTimer(hWnd, 1); QuickConnectProc(); + // 自動切断対策 + if(AskNoopInterval() > 0) + SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL); break; case MENU_DISCONNECT : @@ -893,7 +966,12 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_HIST_18 : case MENU_HIST_19 : case MENU_HIST_20 : + // 自動切断対策 + KillTimer(hWnd, 1); HistoryConnectProc(LOWORD(wParam)); + // 自動切断対策 + if(AskNoopInterval() > 0) + SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL); break; case MENU_UPDIR : @@ -905,6 +983,22 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_DCLICK : if(hWndCurFocus == GetLocalHwnd()) + // ローカルフォルダを開く +// DoubleClickProc(WIN_LOCAL, YES, -1); + DoubleClickProc(WIN_LOCAL, NO, -1); + else + { + SuppressRefresh = 1; + // ローカルフォルダを開く +// DoubleClickProc(WIN_REMOTE, YES, -1); + DoubleClickProc(WIN_REMOTE, NO, -1); + SuppressRefresh = 0; + } + break; + + // ローカルフォルダを開く + case MENU_OPEN : + if(hWndCurFocus == GetLocalHwnd()) DoubleClickProc(WIN_LOCAL, YES, -1); else { @@ -973,42 +1067,42 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_DOWNLOAD : SetCurrentDirAsDirHist(); - DownLoadProc(NO, NO, NO); + DownloadProc(NO, NO, NO); break; case MENU_DOWNLOAD_AS : SetCurrentDirAsDirHist(); - DownLoadProc(YES, NO, NO); + DownloadProc(YES, NO, NO); break; case MENU_DOWNLOAD_AS_FILE : SetCurrentDirAsDirHist(); - DownLoadProc(NO, YES, NO); + DownloadProc(NO, YES, NO); break; case MENU_DOWNLOAD_ALL : SetCurrentDirAsDirHist(); - DownLoadProc(NO, NO, YES); + DownloadProc(NO, NO, YES); break; case MENU_DOWNLOAD_NAME : SetCurrentDirAsDirHist(); - InputDownLoadProc(); + InputDownloadProc(); break; case MENU_UPLOAD : SetCurrentDirAsDirHist(); - UpLoadListProc(NO, NO); + UploadListProc(NO, NO); break; case MENU_UPLOAD_AS : SetCurrentDirAsDirHist(); - UpLoadListProc(YES, NO); + UploadListProc(YES, NO); break; case MENU_UPLOAD_ALL : SetCurrentDirAsDirHist(); - UpLoadListProc(NO, YES); + UploadListProc(NO, YES); break; case MENU_MIRROR_UPLOAD : @@ -1076,12 +1170,16 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case MENU_FILTER : + // 同時接続対応 + CancelFlg = NO; SetFilter(&CancelFlg); break; case MENU_SORT : if(SortSetting() == YES) { + // 同時接続対応 + CancelFlg = NO; LocalFileSort = AskSortType(ITEM_LFILE); LocalDirSort = AskSortType(ITEM_LDIR); RemoteFileSort = AskSortType(ITEM_RFILE); @@ -1135,6 +1233,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_KNJ_EUC : case MENU_KNJ_JIS : case MENU_KNJ_UTF8N : + case MENU_KNJ_UTF8BOM : case MENU_KNJ_NONE : SetHostKanjiCode(LOWORD(wParam)); break; @@ -1143,6 +1242,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_L_KNJ_EUC : case MENU_L_KNJ_JIS : case MENU_L_KNJ_UTF8N : + case MENU_L_KNJ_UTF8BOM : SetLocalKanjiCode(LOWORD(wParam)); break; @@ -1151,6 +1251,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case MENU_REFRESH : + // 同時接続対応 + CancelFlg = NO; SuppressRefresh = 1; GetLocalDirForWnd(); if(CheckClosedAndReconnect() == FFFTP_SUCCESS) @@ -1175,6 +1277,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case REFRESH_REMOTE : + // 同時接続対応 + CancelFlg = NO; SuppressRefresh = 1; if(CheckClosedAndReconnect() == FFFTP_SUCCESS) GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg); @@ -1203,7 +1307,9 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case MENU_HELP_TROUBLE : - ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW); + // 任意のコードが実行されるバグ修正 +// ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW); + ShellExecute(NULL, "open", MYWEB_URL, NULL, NULL, SW_SHOW); break; case MENU_BMARK_ADD : @@ -1239,6 +1345,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA break; case MENU_DOTFILE : + // 同時接続対応 + CancelFlg = NO; DotFile ^= 1; DispDotFileMode(); GetLocalDirForWnd(); @@ -1255,7 +1363,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_REGSAVE : GetListTabWidth(); - SaveRegistory(); + SaveRegistry(); SaveSettingsToFile(); break; @@ -1271,7 +1379,7 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_REGINIT : if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES) { - ClearRegistory(); + ClearRegistry(); SaveExit = NO; PostMessage(hWnd, WM_CLOSE, 0, 0L); } @@ -1319,6 +1427,12 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA LocalRbuttonMenu(1); break; +#if defined(HAVE_TANDEM) + case MENU_SWITCH_OSS : + SwitchOSSProc(); + break; +#endif + default : if((LOWORD(wParam) >= MENU_BMARK_TOP) && (LOWORD(wParam) < MENU_BMARK_TOP+100)) @@ -1336,8 +1450,13 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA switch(((LPNMHDR)lParam)->code) { /* ツールチップコントロールメッセージの処理 */ - case TTN_NEEDTEXT: + // UTF-8対応 +// case TTN_NEEDTEXT: + case TTN_NEEDTEXTW: lpttt = (LPTOOLTIPTEXT)lParam; + // UTF-8対応 + // lptttは単なる警告回避用 + wlpttt = (LPTOOLTIPTEXTW)lParam; lpttt->hinst = hInstFtp; switch(lpttt->hdr.idFrom) { @@ -1356,7 +1475,15 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case MENU_DOWNLOAD : lpttt->lpszText = MSGJPN157; break; +#if defined(HAVE_TANDEM) + case MENU_DOWNLOAD_AS : + lpttt->lpszText = MSGJPN065; + break; + case MENU_UPLOAD_AS : + lpttt->lpszText = MSGJPN064; + break; +#endif case MENU_UPLOAD : lpttt->lpszText = MSGJPN158; break; @@ -1427,6 +1554,10 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA lpttt->lpszText = MSGJPN308; break; + case MENU_KNJ_UTF8BOM : + lpttt->lpszText = MSGJPN330; + break; + case MENU_KNJ_NONE : lpttt->lpszText = MSGJPN173; break; @@ -1447,6 +1578,10 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA lpttt->lpszText = MSGJPN312; break; + case MENU_L_KNJ_UTF8BOM : + lpttt->lpszText = MSGJPN331; + break; + case MENU_KANACNV : lpttt->lpszText = MSGJPN174; break; @@ -1459,15 +1594,14 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA lpttt->lpszText = MSGJPN176; break; } - // UTF-8からShift_JISへ変換 + // UTF-8対応 + // UTF-8からUTF-16 LEへ変換 { static wchar_t StringBufferUTF16[1024]; - static char StringBufferSJIS[1024]; if(lpttt->lpszText) { MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1); - WtoA(StringBufferSJIS, sizeof(StringBufferSJIS)/ sizeof(char), StringBufferUTF16, -1); - lpttt->lpszText = StringBufferSJIS; + wlpttt->lpszText = StringBufferUTF16; } } break; @@ -1475,6 +1609,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA case LVN_COLUMNCLICK : if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd()) { + // 同時接続対応 + CancelFlg = NO; SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem); ReSortDispList(WIN_LOCAL, &CancelFlg); } @@ -1482,6 +1618,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA { if(((NM_LISTVIEW *)lParam)->iSubItem != 4) { + // 同時接続対応 + CancelFlg = NO; SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem); ReSortDispList(WIN_REMOTE, &CancelFlg); } @@ -1927,6 +2065,9 @@ static char *GetToken(char *Str, char *Buf) static void ExitProc(HWND hWnd) { + // 環境依存の不具合対策 + char Tmp[FMAX_PATH+1]; + CancelFlg = YES; CloseTransferThread(); @@ -1945,7 +2086,7 @@ static void ExitProc(HWND hWnd) if(SaveExit == YES) { GetListTabWidth(); - SaveRegistory(); + SaveRegistry(); if((CacheEntry > 0) && (CacheSave == YES)) SaveCache(); @@ -1955,6 +2096,14 @@ static void ExitProc(HWND hWnd) else DeleteCache(); + // 環境依存の不具合対策 + GetAppTempPath(Tmp); + SetYenTail(Tmp); + strcat(Tmp, "file"); + _rmdir(Tmp); + GetAppTempPath(Tmp); + _rmdir(Tmp); + if(RasClose == YES) { DisconnectRas(RasCloseNotify); @@ -1998,7 +2147,9 @@ void DoubleClickProc(int Win, int Mode, int App) if(Win == WIN_LOCAL) { - if((App != -1) || (Type == NODE_FILE)) + // ローカルフォルダを開く +// if((App != -1) || (Type == NODE_FILE)) + if((App != -1) || (Type == NODE_FILE) || (Mode == YES)) { if((DclickOpen == YES) || (Mode == YES)) { @@ -2028,6 +2179,10 @@ void DoubleClickProc(int Win, int Mode, int App) strcpy(Remote, TmpPath); SetYenTail(Remote); + // 環境依存の不具合対策 + strcat(Remote, "file"); + _mkdir(Remote); + SetYenTail(Remote); if (UseDiffViewer == YES) { strcat(Remote, "remote."); } @@ -2071,10 +2226,12 @@ void DoubleClickProc(int Win, int Mode, int App) /* 不正なパスを検出 */ if(CheckPathViolation(&MainTransPkt) == NO) { -// if((Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429) +// if((Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429) // { // ReConnectCmdSkt(); - Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg); + // 同時接続対応 + CancelFlg = NO; + Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg); // } } @@ -2126,6 +2283,11 @@ static void ChangeDir(int Win, char *Path) char Local[FMAX_PATH+1]; char Remote[FMAX_PATH+1]; + // 同時接続対応 + CancelFlg = NO; + + // デッドロック対策 + DisableUserOpe(); Sync = AskSyncMoveMode(); if(Sync == YES) { @@ -2157,6 +2319,8 @@ static void ChangeDir(int Win, char *Path) GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg); } } + // デッドロック対策 + EnableUserOpe(); return; } @@ -2414,6 +2578,8 @@ void ExecViewer(char *Fname, int App) char AssocProg[FMAX_PATH+1]; char ComLine[FMAX_PATH*2+3+1]; char CurDir[FMAX_PATH+1]; + // 任意のコードが実行されるバグ修正 + char SysDir[FMAX_PATH+1]; /* FindExecutable()は関連付けられたプログラムのパス名にスペースが */ /* 含まれている時、間違ったパス名を返す事がある。 */ @@ -2421,11 +2587,21 @@ void ExecViewer(char *Fname, int App) AskLocalCurDir(CurDir, FMAX_PATH); - if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32)) + // 任意のコードが実行されるバグ修正 + // 拡張子が無いと補完されるため +// if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32)) + if((App == -1) && (strlen(GetFileExt(GetFileName(Fname))) > 0) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32)) { DoPrintf("ShellExecute - %s", Fname); ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW); } + // ローカルフォルダを開く + else if((App == -1) && (GetFileAttributes(Fname) & FILE_ATTRIBUTE_DIRECTORY)) + { + MakeDistinguishableFileName(ComLine, Fname); + DoPrintf("ShellExecute - %s", Fname); + ShellExecute(NULL, "open", ComLine, NULL, Fname, SW_SHOW); + } else { App = max1(0, App); @@ -2441,10 +2617,26 @@ void ExecViewer(char *Fname, int App) memset(&Startup, NUL, sizeof(STARTUPINFO)); Startup.cb = sizeof(STARTUPINFO); Startup.wShowWindow = SW_SHOW; - if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) + // 任意のコードが実行されるバグ修正 +// if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) +// { +// SetTaskMsg(MSGJPN182, GetLastError()); +// SetTaskMsg(">>%s", ComLine); +// } + if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0) { - SetTaskMsg(MSGJPN182, GetLastError()); - SetTaskMsg(">>%s", ComLine); + if(GetSystemDirectory(SysDir, FMAX_PATH) > 0) + { + if(SetCurrentDirectory(SysDir)) + { + if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) + { + SetTaskMsg(MSGJPN182, GetLastError()); + SetTaskMsg(">>%s", ComLine); + } + SetCurrentDirectory(CurDir); + } + } } } return; @@ -2469,6 +2661,8 @@ void ExecViewer2(char *Fname1, char *Fname2, int App) char AssocProg[FMAX_PATH+1]; char ComLine[FMAX_PATH*2+3+1]; char CurDir[FMAX_PATH+1]; + // 任意のコードが実行されるバグ修正 + char SysDir[FMAX_PATH+1]; /* FindExecutable()は関連付けられたプログラムのパス名にスペースが */ /* 含まれている時、間違ったパス名を返す事がある。 */ @@ -2488,10 +2682,26 @@ void ExecViewer2(char *Fname1, char *Fname2, int App) memset(&Startup, NUL, sizeof(STARTUPINFO)); Startup.cb = sizeof(STARTUPINFO); Startup.wShowWindow = SW_SHOW; - if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) + // 任意のコードが実行されるバグ修正 +// if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) +// { +// SetTaskMsg(MSGJPN182, GetLastError()); +// SetTaskMsg(">>%s", ComLine); +// } + if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0) { - SetTaskMsg(MSGJPN182, GetLastError()); - SetTaskMsg(">>%s", ComLine); + if(GetSystemDirectory(SysDir, FMAX_PATH) > 0) + { + if(SetCurrentDirectory(SysDir)) + { + if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE) + { + SetTaskMsg(MSGJPN182, GetLastError()); + SetTaskMsg(">>%s", ComLine); + } + SetCurrentDirectory(CurDir); + } + } } return; @@ -2573,7 +2783,9 @@ static void DeleteAlltempFile(void) * BOOL TRUE/FALSE *----------------------------------------------------------------------------*/ -static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +// 64ビット対応 +//static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static char Tmp[80]; int Ver; @@ -2701,7 +2913,11 @@ int BackgrndMessageProc(void) Ret = NO; while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { - if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) + // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策 +// if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) + // 64ビット対応 +// if(!IsMainThread() || !HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg)) + if(!IsMainThread() || !HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg)) { /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */ /* コンボボックス内ではアクセラレータを無効にする */ @@ -2810,17 +3026,104 @@ int EnterMasterPasswordAndSet( int Res, HWND hWnd ) } // 暗号化通信対応 -BOOL __stdcall SSLTimeoutCallback() +BOOL __stdcall SSLTimeoutCallback(BOOL* pbAborted) { Sleep(1); if(BackgrndMessageProc() == YES) return TRUE; - // 念のためツールバーのMENU_ABORTも確認 -// if(MainTransPkt.Abort != ABORT_NONE) -// { -// MainTransPkt.Abort = ABORT_NONE; -// return TRUE; -// } + if(*pbAborted == YES) + return TRUE; return FALSE; } +BOOL __stdcall SSLConfirmCallback(BOOL* pbAborted, BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName) +{ + BOOL bResult; + uint32 Hash[5]; + int i; + char* pm0; + bResult = FALSE; + sha_memory((char*)Certificate, (uint32)(strlen(Certificate) * sizeof(char)), (uint32*)&Hash); + // sha.cはビッグエンディアンのため + for(i = 0; i < 5; i++) + Hash[i] = _byteswap_ulong(Hash[i]); + i = 0; + while(i < MAX_CERT_CACHE_HASH) + { + if(memcmp(&CertificateCacheHash[i], &Hash, 20) == 0) + { + bResult = TRUE; + break; + } + i++; + } + if(!bResult) + { + if(pm0 = AllocateStringM(strlen(Certificate) + 1024)) + { + sprintf(pm0, MSGJPN326, IsHostNameMatched(AskHostAdrs(), CommonName) ? MSGJPN327 : MSGJPN328, bVerified ? MSGJPN327 : MSGJPN328, Certificate); + if(MessageBox(GetMainHwnd(), pm0, "FFFTP", MB_YESNO) == IDYES) + { + for(i = MAX_CERT_CACHE_HASH - 1; i >= 1; i--) + memcpy(&CertificateCacheHash[i], &CertificateCacheHash[i - 1], 20); + memcpy(&CertificateCacheHash[0], &Hash, 20); + bResult = TRUE; + } + FreeDuplicatedString(pm0); + } + } + if(!bResult) + *pbAborted = YES; + return bResult; +} + +BOOL LoadSSLRootCAFile() +{ + BOOL bResult; + HANDLE hFile; + DWORD Size; + BYTE* pBuffer; + uint32 Hash[5]; + int i; + bResult = FALSE; + if((hFile = CreateFile(SSLRootCAFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) + { + Size = GetFileSize(hFile, NULL); + if(pBuffer = (BYTE*)malloc(Size)) + { + if(ReadFile(hFile, pBuffer, Size, &Size, NULL)) + { + sha_memory((char*)pBuffer, (uint32)Size, (uint32*)&Hash); + // sha.cはビッグエンディアンのため + for(i = 0; i < 5; i++) + Hash[i] = _byteswap_ulong(Hash[i]); + // 同梱する"ssl.pem"に合わせてSHA1ハッシュ値を変更すること + if(memcmp(&Hash, &SSLRootCAFileHash, 20) == 0 || memcmp(&Hash, "\xF0\x1B\x48\x26\x67\x44\x3A\xFF\x0A\x16\xD3\xBB\x8A\x33\xEB\x70\x6D\x75\xA6\x0D", 20) == 0 + || DialogBox(GetFtpInst(), MAKEINTRESOURCE(updatesslroot_dlg), GetMainHwnd(), ExeEscDialogProc) == YES) + { + memcpy(&SSLRootCAFileHash, &Hash, 20); + if(SetSSLRootCertificate(pBuffer, Size)) + bResult = TRUE; + } + } + free(pBuffer); + } + CloseHandle(hFile); + } + return bResult; +} + +// マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策 +BOOL IsMainThread() +{ + if(GetCurrentThreadId() != MainThreadId) + return FALSE; + return TRUE; +} + +// ファイルアイコン表示対応 +int AskDispFileIcon(void) +{ + return(DispFileIcon); +} +