1 /*=============================================================================
\r
5 ===============================================================================
\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.
\r
8 / Redistribution and use in source and binary forms, with or without
\r
9 / modification, are permitted provided that the following conditions
\r
12 / 1. Redistributions of source code must retain the above copyright
\r
13 / notice, this list of conditions and the following disclaimer.
\r
14 / 2. Redistributions in binary form must reproduce the above copyright
\r
15 / notice, this list of conditions and the following disclaimer in the
\r
16 / documentation and/or other materials provided with the distribution.
\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 /============================================================================*/
\r
32 #include <winsock2.h>
\r
33 #include <windows.h>
\r
37 #include <commctrl.h>
\r
38 #include <windowsx.h>
\r
41 #include "resource.h"
\r
43 #include <htmlhelp.h>
\r
47 #undef __MBSWRAPPER_H__
\r
48 #include "mbswrapper.h"
\r
51 /*===== プロトタイプ =====*/
\r
54 //static BOOL CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
\r
55 static INT_PTR CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
\r
58 /*===== 外部参照 =====*/
\r
60 extern HWND hHelpWin;
\r
63 /*----- ワンタイムパスワード計算 ----------------------------------------------
\r
70 *----------------------------------------------------------------------------*/
\r
72 void OtpCalcTool(void)
\r
74 DialogBox(GetFtpInst(), MAKEINTRESOURCE(otp_calc_dlg), GetMainHwnd(), OtpCalcWinProc);
\r
79 /*----- ワンタイムパスワード計算ウインドウのコールバック ----------------------
\r
82 * HWND hDlg : ウインドウハンドル
\r
83 * UINT message : メッセージ番号
\r
84 * WPARAM wParam : メッセージの WPARAM 引数
\r
85 * LPARAM lParam : メッセージの LPARAM 引数
\r
89 *----------------------------------------------------------------------------*/
\r
92 //static BOOL CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
93 static INT_PTR CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
99 char Seed[MAX_SEED_LEN+1];
\r
100 char Pass[PASSWORD_LEN+1];
\r
102 static const RADIOBUTTON AlgoButton[] = {
\r
103 { OTPCALC_MD4, MD4 },
\r
104 { OTPCALC_MD5, MD5 },
\r
105 { OTPCALC_SHA1, SHA1 }
\r
107 #define ALGOBUTTONS (sizeof(AlgoButton)/sizeof(RADIOBUTTON))
\r
111 case WM_INITDIALOG :
\r
112 SendDlgItemMessage(hDlg, OTPCALC_KEY, EM_LIMITTEXT, 40, 0);
\r
113 SendDlgItemMessage(hDlg, OTPCALC_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);
\r
114 SetRadioButtonByValue(hDlg, MD4, AlgoButton, ALGOBUTTONS);
\r
118 switch(GET_WM_COMMAND_ID(wParam, lParam))
\r
121 SendDlgItemMessage(hDlg, OTPCALC_KEY, WM_GETTEXT, 41, (LPARAM)Tmp);
\r
122 SendDlgItemMessage(hDlg, OTPCALC_PASS, WM_GETTEXT, PASSWORD_LEN+1, (LPARAM)Pass);
\r
123 Type = AskRadioButtonValue(hDlg, AlgoButton, ALGOBUTTONS);
\r
133 if((Pos = GetNextField(Pos)) != NULL)
\r
135 if(GetOneField(Pos, Seed, MAX_SEED_LEN) == FFFTP_SUCCESS)
\r
137 Make6WordPass(Seq, Seed, Pass, Type, Tmp);
\r
140 strcpy(Tmp, MSGJPN251);
\r
143 strcpy(Tmp, MSGJPN252);
\r
146 strcpy(Tmp, MSGJPN253);
\r
148 SendDlgItemMessage(hDlg, OTPCALC_RES, WM_SETTEXT, 0, (LPARAM)Tmp);
\r
152 EndDialog(hDlg, NO);
\r
156 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000037);
\r
167 void TurnStatefulFTPFilter()
\r
170 char CurDir[FMAX_PATH+1];
\r
171 char SysDir[FMAX_PATH+1];
\r
172 ID = MessageBox(GetMainHwnd(), MSGJPN341, "FFFTP", MB_YESNOCANCEL);
\r
173 if(ID == IDYES || ID == IDNO)
\r
175 if(GetCurrentDirectory(FMAX_PATH, CurDir) > 0)
\r
177 if(GetSystemDirectory(SysDir, FMAX_PATH) > 0)
\r
179 if(SetCurrentDirectory(SysDir))
\r
181 if(ShellExecute(NULL, "runas", "netsh", ID == IDYES ? "advfirewall set global statefulftp enable" : "advfirewall set global statefulftp disable", NULL, SW_SHOW) <= (HINSTANCE)32)
\r
183 MessageBox(GetMainHwnd(), MSGJPN342, "FFFTP", MB_OK | MB_ICONERROR);
\r
185 SetCurrentDirectory(CurDir);
\r