Loweynet
Revisão | 554ddaeeff25cb5ca2494470a41834cfeadec8df (tree) |
---|---|
Hora | 2012-02-20 02:10:22 |
Autor | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Add protection for password edit controls.
@@ -1696,6 +1696,8 @@ static INT_PTR CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, | ||
1696 | 1696 | switch (iMessage) |
1697 | 1697 | { |
1698 | 1698 | case WM_INITDIALOG : |
1699 | + // プロセス保護 | |
1700 | + ProtectAllEditControls(hDlg); | |
1699 | 1701 | SendDlgItemMessage(hDlg, HSET_HOST, EM_LIMITTEXT, HOST_NAME_LEN, 0); |
1700 | 1702 | SendDlgItemMessage(hDlg, HSET_ADRS, EM_LIMITTEXT, HOST_ADRS_LEN, 0); |
1701 | 1703 | SendDlgItemMessage(hDlg, HSET_USER, EM_LIMITTEXT, USER_NAME_LEN, 0); |
@@ -145,6 +145,8 @@ static INT_PTR CALLBACK InputDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wPa | ||
145 | 145 | switch (iMessage) |
146 | 146 | { |
147 | 147 | case WM_INITDIALOG : |
148 | + // プロセス保護 | |
149 | + ProtectAllEditControls(hDlg); | |
148 | 150 | if(strlen(DialogData->Title) != 0) |
149 | 151 | SendMessage(hDlg, WM_SETTEXT, 0, (LPARAM)DialogData->Title); |
150 | 152 | SendDlgItemMessage(hDlg, INP_INPSTR, EM_LIMITTEXT, DialogData->MaxLen-1, 0); |
@@ -1182,6 +1182,8 @@ static INT_PTR CALLBACK FireSettingProc(HWND hDlg, UINT message, WPARAM wParam, | ||
1182 | 1182 | switch (message) |
1183 | 1183 | { |
1184 | 1184 | case WM_INITDIALOG : |
1185 | + // プロセス保護 | |
1186 | + ProtectAllEditControls(hDlg); | |
1185 | 1187 | Type = ConvertNum(FwallType, 1, TypeTbl, sizeof(TypeTbl)/sizeof(INTCONVTBL)); |
1186 | 1188 | SendDlgItemMessage(hDlg, FIRE_TYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN204); |
1187 | 1189 | SendDlgItemMessage(hDlg, FIRE_TYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN205); |
@@ -100,6 +100,7 @@ DWORD g_ProcessProtectionLevel; | ||
100 | 100 | DWORD g_LockedThread[MAX_LOCKED_THREAD]; |
101 | 101 | WCHAR* g_pTrustedFilenameTable[MAX_TRUSTED_FILENAME_TABLE]; |
102 | 102 | BYTE g_TrustedMD5HashTable[MAX_TRUSTED_MD5_HASH_TABLE][20]; |
103 | +WNDPROC g_PasswordEditControlProc; | |
103 | 104 | |
104 | 105 | // 以下フック関数 |
105 | 106 | // フック対象を呼び出す場合は前後でSTART_HOOK_FUNCTIONとEND_HOOK_FUNCTIONを実行する必要がある |
@@ -1089,3 +1090,55 @@ BOOL RestartProtectedProcess(LPCTSTR Keyword) | ||
1089 | 1090 | return bResult; |
1090 | 1091 | } |
1091 | 1092 | |
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 | + |
@@ -56,12 +56,14 @@ EXTERN_HOOK_FUNCTION_VAR(LoadLibraryExW) | ||
56 | 56 | #define PROCESS_PROTECTION_EXPIRED 0x00000010 |
57 | 57 | // Authenticode署名の発行元を無視 |
58 | 58 | #define PROCESS_PROTECTION_UNAUTHORIZED 0x00000020 |
59 | +// パスワード入力コントロールを保護 | |
60 | +#define PROCESS_PROTECTION_PASSWORD_EDIT 0x00000040 | |
59 | 61 | |
60 | 62 | #define PROCESS_PROTECTION_NONE 0 |
61 | 63 | #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) | |
65 | 67 | |
66 | 68 | HMODULE System_LoadLibrary(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); |
67 | 69 | void SetProcessProtectionLevel(DWORD Level); |
@@ -72,6 +74,8 @@ BOOL UnloadUntrustedModule(); | ||
72 | 74 | BOOL InitializeLoadLibraryHook(); |
73 | 75 | BOOL EnableLoadLibraryHook(BOOL bEnable); |
74 | 76 | BOOL RestartProtectedProcess(LPCTSTR Keyword); |
77 | +BOOL ProtectPasswordEditControl(HWND hWnd); | |
78 | +BOOL ProtectAllEditControls(HWND hWnd); | |
75 | 79 | |
76 | 80 | #endif |
77 | 81 |