OSDN Git Service

Add support for retaining time stamps on uploading files.
[ffftp/ffftp.git] / protectprocess.c
index a37fab2..f0669a8 100644 (file)
@@ -100,6 +100,7 @@ DWORD g_ProcessProtectionLevel;
 DWORD g_LockedThread[MAX_LOCKED_THREAD];\r
 WCHAR* g_pTrustedFilenameTable[MAX_TRUSTED_FILENAME_TABLE];\r
 BYTE g_TrustedMD5HashTable[MAX_TRUSTED_MD5_HASH_TABLE][20];\r
+WNDPROC g_PasswordEditControlProc;\r
 \r
 // 以下フック関数\r
 // フック対象を呼び出す場合は前後でSTART_HOOK_FUNCTIONとEND_HOOK_FUNCTIONを実行する必要がある\r
@@ -1089,3 +1090,55 @@ BOOL RestartProtectedProcess(LPCTSTR Keyword)
        return bResult;\r
 }\r
 \r
+INT_PTR CALLBACK PasswordEditControlWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)\r
+{\r
+       switch(Msg)\r
+       {\r
+       case EM_GETPASSWORDCHAR:\r
+               break;\r
+       case EM_SETPASSWORDCHAR:\r
+               break;\r
+       default:\r
+               return CallWindowProcW(g_PasswordEditControlProc, hWnd, Msg, wParam, lParam);\r
+       }\r
+       return 0;\r
+}\r
+\r
+BOOL ProtectPasswordEditControl(HWND hWnd)\r
+{\r
+       BOOL bResult;\r
+       WCHAR ClassName[MAX_PATH];\r
+       WNDPROC Proc;\r
+       bResult = FALSE;\r
+       if(g_ProcessProtectionLevel & PROCESS_PROTECTION_PASSWORD_EDIT)\r
+       {\r
+               if(GetClassNameW(hWnd, ClassName, MAX_PATH) > 0)\r
+               {\r
+                       if(_wcsicmp(ClassName, WC_EDITW) == 0)\r
+                       {\r
+                               Proc = (WNDPROC)GetWindowLongPtrW(hWnd, GWLP_WNDPROC);\r
+                               if(Proc != (WNDPROC)PasswordEditControlWndProc)\r
+                               {\r
+                                       g_PasswordEditControlProc = Proc;\r
+                                       SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)PasswordEditControlWndProc);\r
+                                       bResult = TRUE;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       return bResult;\r
+}\r
+\r
+BOOL CALLBACK ProtectAllEditControlsEnumChildProc(HWND hwnd , LPARAM lParam)\r
+{\r
+       ProtectPasswordEditControl(hwnd);\r
+       return TRUE;\r
+}\r
+\r
+BOOL ProtectAllEditControls(HWND hWnd)\r
+{\r
+       if(g_ProcessProtectionLevel & PROCESS_PROTECTION_PASSWORD_EDIT)\r
+               EnumChildWindows(hWnd, ProtectAllEditControlsEnumChildProc, 0);\r
+       return TRUE;\r
+}\r
+\r