OSDN Git Service

Fix bugs of process protection on Windows 7.
[ffftp/ffftp.git] / protectprocess.c
index 7c7c60f..82a3e37 100644 (file)
@@ -385,31 +385,8 @@ BOOL FindTrustedModuleSHA1Hash(void* pHash)
        return bResult;
 }
 
-// \83t\83@\83C\83\8b\82Ì\8f\90\96¼\82ð\8am\94F
-BOOL VerifyFileSignature(LPCWSTR Filename)
+BOOL VerifyFileSignature_Function(LPCWSTR Filename)
 {
-//     BOOL bResult;
-//     GUID g = WINTRUST_ACTION_GENERIC_VERIFY_V2;
-//     WINTRUST_FILE_INFO wfi;
-//     WINTRUST_DATA wd;
-//     LONG Error;
-//     bResult = FALSE;
-//     ZeroMemory(&wfi, sizeof(WINTRUST_FILE_INFO));
-//     wfi.cbStruct = sizeof(WINTRUST_FILE_INFO);
-//     wfi.pcwszFilePath = Filename;
-//     ZeroMemory(&wd, sizeof(WINTRUST_DATA));
-//     wd.cbStruct = sizeof(WINTRUST_DATA);
-//     wd.dwUIChoice = WTD_UI_NONE;
-//     wd.dwUnionChoice = WTD_CHOICE_FILE;
-//     wd.pFile = &wfi;
-//     Error = WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd);
-//     if(Error == ERROR_SUCCESS)
-//             bResult = TRUE;
-//     else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_EXPIRED) && Error == CERT_E_EXPIRED)
-//             bResult = TRUE;
-//     else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_UNAUTHORIZED) && (Error == CERT_E_UNTRUSTEDROOT || Error == CERT_E_UNTRUSTEDCA))
-//             bResult = TRUE;
-//     return bResult;
        BOOL bResult;
        HCERTSTORE hStore;
        PCCERT_CONTEXT pcc;
@@ -454,6 +431,29 @@ BOOL VerifyFileSignature(LPCWSTR Filename)
        return bResult;
 }
 
+// \83t\83@\83C\83\8b\82Ì\8f\90\96¼\82ð\8am\94F
+BOOL VerifyFileSignature(LPCWSTR Filename)
+{
+       BOOL bResult;
+       GUID g = WINTRUST_ACTION_GENERIC_VERIFY_V2;
+       WINTRUST_FILE_INFO wfi;
+       WINTRUST_DATA wd;
+       bResult = FALSE;
+       ZeroMemory(&wfi, sizeof(WINTRUST_FILE_INFO));
+       wfi.cbStruct = sizeof(WINTRUST_FILE_INFO);
+       wfi.pcwszFilePath = Filename;
+       ZeroMemory(&wd, sizeof(WINTRUST_DATA));
+       wd.cbStruct = sizeof(WINTRUST_DATA);
+       wd.dwUIChoice = WTD_UI_NONE;
+       wd.dwUnionChoice = WTD_CHOICE_FILE;
+       wd.pFile = &wfi;
+       if(WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd) == ERROR_SUCCESS)
+               bResult = TRUE;
+       else
+               bResult = VerifyFileSignature_Function(Filename);
+       return bResult;
+}
+
 // \83t\83@\83C\83\8b\82Ì\8f\90\96¼\82ð\83J\83^\83\8d\83O\83t\83@\83C\83\8b\82Å\8am\94F
 BOOL VerifyFileSignatureInCatalog(LPCWSTR Catalog, LPCWSTR Filename)
 {