• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Loweynet


Commit MetaInfo

Revisão554ddaeeff25cb5ca2494470a41834cfeadec8df (tree)
Hora2012-02-20 02:10:22
Autors_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Mensagem de Log

Add protection for password edit controls.

Mudança Sumário

Diff

Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/hostman.c
+++ b/hostman.c
@@ -1696,6 +1696,8 @@ static INT_PTR CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam,
16961696 switch (iMessage)
16971697 {
16981698 case WM_INITDIALOG :
1699+ // プロセス保護
1700+ ProtectAllEditControls(hDlg);
16991701 SendDlgItemMessage(hDlg, HSET_HOST, EM_LIMITTEXT, HOST_NAME_LEN, 0);
17001702 SendDlgItemMessage(hDlg, HSET_ADRS, EM_LIMITTEXT, HOST_ADRS_LEN, 0);
17011703 SendDlgItemMessage(hDlg, HSET_USER, EM_LIMITTEXT, USER_NAME_LEN, 0);
--- a/misc.c
+++ b/misc.c
@@ -145,6 +145,8 @@ static INT_PTR CALLBACK InputDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wPa
145145 switch (iMessage)
146146 {
147147 case WM_INITDIALOG :
148+ // プロセス保護
149+ ProtectAllEditControls(hDlg);
148150 if(strlen(DialogData->Title) != 0)
149151 SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)DialogData->Title);
150152 SendDlgItemMessage(hDlg, INP_INPSTR, EM_LIMITTEXT, DialogData->MaxLen-1, 0);
--- a/option.c
+++ b/option.c
@@ -1182,6 +1182,8 @@ static INT_PTR CALLBACK FireSettingProc(HWND hDlg, UINT message, WPARAM wParam,
11821182 switch (message)
11831183 {
11841184 case WM_INITDIALOG :
1185+ // プロセス保護
1186+ ProtectAllEditControls(hDlg);
11851187 Type = ConvertNum(FwallType, 1, TypeTbl, sizeof(TypeTbl)/sizeof(INTCONVTBL));
11861188 SendDlgItemMessage(hDlg, FIRE_TYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN204);
11871189 SendDlgItemMessage(hDlg, FIRE_TYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN205);
--- a/protectprocess.c
+++ b/protectprocess.c
@@ -100,6 +100,7 @@ DWORD g_ProcessProtectionLevel;
100100 DWORD g_LockedThread[MAX_LOCKED_THREAD];
101101 WCHAR* g_pTrustedFilenameTable[MAX_TRUSTED_FILENAME_TABLE];
102102 BYTE g_TrustedMD5HashTable[MAX_TRUSTED_MD5_HASH_TABLE][20];
103+WNDPROC g_PasswordEditControlProc;
103104
104105 // 以下フック関数
105106 // フック対象を呼び出す場合は前後でSTART_HOOK_FUNCTIONとEND_HOOK_FUNCTIONを実行する必要がある
@@ -1089,3 +1090,55 @@ BOOL RestartProtectedProcess(LPCTSTR Keyword)
10891090 return bResult;
10901091 }
10911092
1093+INT_PTR CALLBACK PasswordEditControlWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
1094+{
1095+ switch(Msg)
1096+ {
1097+ case EM_GETPASSWORDCHAR:
1098+ break;
1099+ case EM_SETPASSWORDCHAR:
1100+ break;
1101+ default:
1102+ return CallWindowProcW(g_PasswordEditControlProc, hWnd, Msg, wParam, lParam);
1103+ }
1104+ return 0;
1105+}
1106+
1107+BOOL ProtectPasswordEditControl(HWND hWnd)
1108+{
1109+ BOOL bResult;
1110+ WCHAR ClassName[MAX_PATH];
1111+ WNDPROC Proc;
1112+ bResult = FALSE;
1113+ if(g_ProcessProtectionLevel & PROCESS_PROTECTION_PASSWORD_EDIT)
1114+ {
1115+ if(GetClassNameW(hWnd, ClassName, MAX_PATH) > 0)
1116+ {
1117+ if(_wcsicmp(ClassName, WC_EDITW) == 0)
1118+ {
1119+ Proc = (WNDPROC)GetWindowLongPtrW(hWnd, GWLP_WNDPROC);
1120+ if(Proc != (WNDPROC)PasswordEditControlWndProc)
1121+ {
1122+ g_PasswordEditControlProc = Proc;
1123+ SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)PasswordEditControlWndProc);
1124+ bResult = TRUE;
1125+ }
1126+ }
1127+ }
1128+ }
1129+ return bResult;
1130+}
1131+
1132+BOOL CALLBACK ProtectAllEditControlsEnumChildProc(HWND hwnd , LPARAM lParam)
1133+{
1134+ ProtectPasswordEditControl(hwnd);
1135+ return TRUE;
1136+}
1137+
1138+BOOL ProtectAllEditControls(HWND hWnd)
1139+{
1140+ if(g_ProcessProtectionLevel & PROCESS_PROTECTION_PASSWORD_EDIT)
1141+ EnumChildWindows(hWnd, ProtectAllEditControlsEnumChildProc, 0);
1142+ return TRUE;
1143+}
1144+
--- a/protectprocess.h
+++ b/protectprocess.h
@@ -56,12 +56,14 @@ EXTERN_HOOK_FUNCTION_VAR(LoadLibraryExW)
5656 #define PROCESS_PROTECTION_EXPIRED 0x00000010
5757 // Authenticode署名の発行元を無視
5858 #define PROCESS_PROTECTION_UNAUTHORIZED 0x00000020
59+// パスワード入力コントロールを保護
60+#define PROCESS_PROTECTION_PASSWORD_EDIT 0x00000040
5961
6062 #define PROCESS_PROTECTION_NONE 0
6163 #define PROCESS_PROTECTION_DEFAULT PROCESS_PROTECTION_HIGH
62-#define PROCESS_PROTECTION_HIGH (PROCESS_PROTECTION_BUILTIN | PROCESS_PROTECTION_SIDE_BY_SIDE | PROCESS_PROTECTION_SYSTEM_FILE)
63-#define PROCESS_PROTECTION_MEDIUM (PROCESS_PROTECTION_HIGH | PROCESS_PROTECTION_LOADED | PROCESS_PROTECTION_EXPIRED)
64-#define PROCESS_PROTECTION_LOW (PROCESS_PROTECTION_MEDIUM | PROCESS_PROTECTION_UNAUTHORIZED)
64+#define PROCESS_PROTECTION_HIGH (PROCESS_PROTECTION_BUILTIN | PROCESS_PROTECTION_SIDE_BY_SIDE | PROCESS_PROTECTION_SYSTEM_FILE | PROCESS_PROTECTION_PASSWORD_EDIT)
65+#define PROCESS_PROTECTION_MEDIUM (PROCESS_PROTECTION_HIGH | PROCESS_PROTECTION_LOADED | PROCESS_PROTECTION_EXPIRED | PROCESS_PROTECTION_PASSWORD_EDIT)
66+#define PROCESS_PROTECTION_LOW (PROCESS_PROTECTION_MEDIUM | PROCESS_PROTECTION_UNAUTHORIZED | PROCESS_PROTECTION_PASSWORD_EDIT)
6567
6668 HMODULE System_LoadLibrary(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
6769 void SetProcessProtectionLevel(DWORD Level);
@@ -72,6 +74,8 @@ BOOL UnloadUntrustedModule();
7274 BOOL InitializeLoadLibraryHook();
7375 BOOL EnableLoadLibraryHook(BOOL bEnable);
7476 BOOL RestartProtectedProcess(LPCTSTR Keyword);
77+BOOL ProtectPasswordEditControl(HWND hWnd);
78+BOOL ProtectAllEditControls(HWND hWnd);
7579
7680 #endif
7781