FFFTPのソースコードです。
Revision | 732108b3e9b10886168500f6bd32e60da02e27db (tree) |
---|---|
Time | 2011-10-12 00:36:43 |
Author | s_kawamoto <s_kawamoto@user...> |
Commiter | s_kawamoto |
Change UI to enter a new master password.
Fix improper error handling of WinVerifyTrust.
@@ -72,12 +72,12 @@ | ||
72 | 72 | <Tool |
73 | 73 | Name="VCLinkerTool" |
74 | 74 | AdditionalOptions="/MACHINE:I386" |
75 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
75 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
76 | 76 | OutputFile=".\Debug\FFFTP.exe" |
77 | 77 | LinkIncremental="2" |
78 | 78 | SuppressStartupBanner="true" |
79 | 79 | GenerateManifest="false" |
80 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;imagehlp.dll;ole32.dll;sfc.dll;shell32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
80 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;imagehlp.dll;ole32.dll;sfc.dll;shell32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
81 | 81 | GenerateDebugInformation="true" |
82 | 82 | ProgramDatabaseFile=".\Debug\FFFTP.pdb" |
83 | 83 | SubSystem="2" |
@@ -165,12 +165,12 @@ | ||
165 | 165 | <Tool |
166 | 166 | Name="VCLinkerTool" |
167 | 167 | AdditionalOptions="/MACHINE:I386" |
168 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
168 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
169 | 169 | OutputFile=".\Release\FFFTP.exe" |
170 | 170 | LinkIncremental="1" |
171 | 171 | SuppressStartupBanner="true" |
172 | 172 | GenerateManifest="false" |
173 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
173 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
174 | 174 | ProgramDatabaseFile=".\Release\FFFTP.pdb" |
175 | 175 | SubSystem="2" |
176 | 176 | RandomizedBaseAddress="1" |
@@ -71,12 +71,12 @@ | ||
71 | 71 | <Tool |
72 | 72 | Name="VCLinkerTool" |
73 | 73 | AdditionalOptions="/MACHINE:I386" |
74 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
74 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
75 | 75 | OutputFile=".\Debug\FFFTP.exe" |
76 | 76 | LinkIncremental="2" |
77 | 77 | SuppressStartupBanner="true" |
78 | 78 | GenerateManifest="false" |
79 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
79 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
80 | 80 | GenerateDebugInformation="true" |
81 | 81 | ProgramDatabaseFile=".\Debug\FFFTP.pdb" |
82 | 82 | SubSystem="2" |
@@ -165,12 +165,12 @@ | ||
165 | 165 | <Tool |
166 | 166 | Name="VCLinkerTool" |
167 | 167 | AdditionalOptions="/MACHINE:I386" |
168 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
168 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
169 | 169 | OutputFile=".\Release\FFFTP.exe" |
170 | 170 | LinkIncremental="1" |
171 | 171 | SuppressStartupBanner="true" |
172 | 172 | GenerateManifest="false" |
173 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
173 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
174 | 174 | ProgramDatabaseFile=".\Release\FFFTP.pdb" |
175 | 175 | SubSystem="2" |
176 | 176 | /> |
@@ -73,12 +73,12 @@ | ||
73 | 73 | <Tool |
74 | 74 | Name="VCLinkerTool" |
75 | 75 | AdditionalOptions="/MACHINE:I386" |
76 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
76 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
77 | 77 | OutputFile=".\FFFTP_Eng_Debug\FFFTP.exe" |
78 | 78 | LinkIncremental="2" |
79 | 79 | SuppressStartupBanner="true" |
80 | 80 | GenerateManifest="false" |
81 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
81 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
82 | 82 | GenerateDebugInformation="true" |
83 | 83 | ProgramDatabaseFile=".\FFFTP_Eng_Debug\FFFTP.pdb" |
84 | 84 | SubSystem="2" |
@@ -165,12 +165,12 @@ | ||
165 | 165 | <Tool |
166 | 166 | Name="VCLinkerTool" |
167 | 167 | AdditionalOptions="/MACHINE:I386" |
168 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
168 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
169 | 169 | OutputFile=".\FFFTP_Eng_Release\FFFTP.exe" |
170 | 170 | LinkIncremental="1" |
171 | 171 | SuppressStartupBanner="true" |
172 | 172 | GenerateManifest="false" |
173 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
173 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
174 | 174 | ProgramDatabaseFile=".\FFFTP_Eng_Release\FFFTP.pdb" |
175 | 175 | SubSystem="2" |
176 | 176 | RandomizedBaseAddress="1" |
@@ -72,12 +72,12 @@ | ||
72 | 72 | <Tool |
73 | 73 | Name="VCLinkerTool" |
74 | 74 | AdditionalOptions="/MACHINE:I386" |
75 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
75 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
76 | 76 | OutputFile=".\FFFTP_Eng_Debug\FFFTP.exe" |
77 | 77 | LinkIncremental="2" |
78 | 78 | SuppressStartupBanner="true" |
79 | 79 | GenerateManifest="false" |
80 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
80 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
81 | 81 | GenerateDebugInformation="true" |
82 | 82 | ProgramDatabaseFile=".\FFFTP_Eng_Debug\FFFTP.pdb" |
83 | 83 | SubSystem="2" |
@@ -165,12 +165,12 @@ | ||
165 | 165 | <Tool |
166 | 166 | Name="VCLinkerTool" |
167 | 167 | AdditionalOptions="/MACHINE:I386" |
168 | - AdditionalDependencies="comctl32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
168 | + AdditionalDependencies="comctl32.lib crypt32.lib htmlhelp.lib imagehlp.lib rasapi32.lib sfc.lib winmm.lib wintrust.lib wsock32.lib" | |
169 | 169 | OutputFile=".\FFFTP_Eng_Release\FFFTP.exe" |
170 | 170 | LinkIncremental="1" |
171 | 171 | SuppressStartupBanner="true" |
172 | 172 | GenerateManifest="false" |
173 | - DelayLoadDLLs="advapi32.dll;comctl32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
173 | + DelayLoadDLLs="advapi32.dll;comctl32.dll;crypt32.dll;comdlg32.dll;gdi32.dll;sfc.dll;shell32.dll;ole32.dll;user32.dll;winmm.dll;wintrust.dll;wsock32.dll" | |
174 | 174 | ProgramDatabaseFile=".\FFFTP_Eng_Release\FFFTP.pdb" |
175 | 175 | SubSystem="2" |
176 | 176 | /> |
@@ -495,10 +495,10 @@ END | ||
495 | 495 | |
496 | 496 | newmasterpasswd_dlg DIALOGEX 0, 0, 187, 43 |
497 | 497 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION |
498 | -CAPTION "新しいマスターパスワードを入れてください" | |
498 | +CAPTION "新しいマスターパスワードを2回入れてください" | |
499 | 499 | FONT 9, "MS Pゴシック", 0, 0, 0x0 |
500 | 500 | BEGIN |
501 | - EDITTEXT INP_INPSTR,7,7,173,12,ES_AUTOHSCROLL | |
501 | + EDITTEXT INP_INPSTR,7,7,173,12,ES_PASSWORD | ES_AUTOHSCROLL | |
502 | 502 | DEFPUSHBUTTON "OK",IDOK,16,25,50,14 |
503 | 503 | PUSHBUTTON "キャンセル",IDCANCEL,68,25,50,14 |
504 | 504 | CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,172,31,8,8 |
@@ -498,10 +498,10 @@ END | ||
498 | 498 | |
499 | 499 | newmasterpasswd_dlg DIALOGEX 0, 0, 187, 43 |
500 | 500 | STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION |
501 | -CAPTION "Enter new master password" | |
501 | +CAPTION "Enter new master password twice" | |
502 | 502 | FONT 9, "MS Sans Serif", 0, 0, 0x0 |
503 | 503 | BEGIN |
504 | - EDITTEXT INP_INPSTR,7,7,173,12,ES_AUTOHSCROLL | |
504 | + EDITTEXT INP_INPSTR,7,7,173,12,ES_PASSWORD | ES_AUTOHSCROLL | |
505 | 505 | DEFPUSHBUTTON "OK",IDOK,25,25,43,14 |
506 | 506 | PUSHBUTTON "Cancel",IDCANCEL,72,25,43,14 |
507 | 507 | CONTROL "",INP_ANONYMOUS,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,172,31,8,8 |
@@ -499,7 +499,7 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow) | ||
499 | 499 | DispWindowTitle(); |
500 | 500 | // SourceForge.JPによるフォーク |
501 | 501 | // SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators."); |
502 | - SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 Hiromichi Matsushima, Suguru Kawamoto."); | |
502 | + SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto)."); | |
503 | 503 | |
504 | 504 | if(ForceIni) |
505 | 505 | SetTaskMsg("%s%s", MSGJPN283, IniPath); |
@@ -2767,12 +2767,29 @@ int AskAutoExit(void) | ||
2767 | 2767 | int EnterMasterPasswordAndSet( int Res, HWND hWnd ) |
2768 | 2768 | { |
2769 | 2769 | char buf[MAX_PASSWORD_LEN + 1]; |
2770 | + // パスワードの入力欄を非表示 | |
2771 | + // 非表示にしたため新しいパスワードを2回入力させる | |
2772 | + char buf1[MAX_PASSWORD_LEN + 1]; | |
2770 | 2773 | char *p; |
2771 | 2774 | int Flag; |
2772 | 2775 | |
2773 | 2776 | buf[0] = NUL; |
2774 | 2777 | if( InputDialogBox(Res, hWnd, NULL, buf, MAX_PASSWORD_LEN + 1, |
2775 | 2778 | &Flag, IDH_HELP_TOPIC_0000064) == YES){ |
2779 | + // パスワードの入力欄を非表示 | |
2780 | + if(Res == newmasterpasswd_dlg) | |
2781 | + { | |
2782 | + buf1[0] = NUL; | |
2783 | + if( InputDialogBox(Res, hWnd, NULL, buf1, MAX_PASSWORD_LEN + 1, | |
2784 | + &Flag, IDH_HELP_TOPIC_0000064) != YES){ | |
2785 | + return 0; | |
2786 | + } | |
2787 | + if(strcmp(buf, buf1) != 0) | |
2788 | + { | |
2789 | + MessageBox(hWnd, MSGJPN325, "FFFTP", MB_OK | MB_ICONERROR); | |
2790 | + return 0; | |
2791 | + } | |
2792 | + } | |
2776 | 2793 | /* 末尾の空白を削除 */ |
2777 | 2794 | RemoveTailingSpaces(buf); |
2778 | 2795 | /* 先頭の空白を削除 */ |
@@ -322,3 +322,4 @@ | ||
322 | 322 | #define MSGJPN322 "Debugger was detected." |
323 | 323 | #define MSGJPN323 "Failed to unload untrustworthy DLLs." |
324 | 324 | #define MSGJPN324 "Failed to hook required functions to protect the process." |
325 | +#define MSGJPN325 "New master passwords are not identical." |
@@ -322,3 +322,4 @@ | ||
322 | 322 | #define MSGJPN322 "Debugger was detected." |
323 | 323 | #define MSGJPN323 "Failed to unload untrustworthy DLLs." |
324 | 324 | #define MSGJPN324 "Failed to hook required functions to protect the process." |
325 | +#define MSGJPN325 "New master passwords are not identical." |
@@ -322,3 +322,4 @@ | ||
322 | 322 | #define MSGJPN322 "\xE3\x83\x87\xE3\x83\x90\xE3\x83\x83\xE3\x82\xAC\xE3\x81\x8C\xE6\xA4\x9C\xE5\x87\xBA\xE3\x81\x95\xE3\x82\x8C\xE3\x81\xBE\xE3\x81\x97\xE3\x81\x9F." |
323 | 323 | #define MSGJPN323 "\xE4\xBF\xA1\xE9\xA0\xBC\xE3\x81\xA7\xE3\x81\x8D\xE3\x81\xAA\xE3\x81\x84\x44LL\xE3\x82\x92\xE3\x82\xA2\xE3\x83\xB3\xE3\x83\xAD\xE3\x83\xBC\xE3\x83\x89\xE3\x81\xA7\xE3\x81\x8D\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93\xE3\x81\xA7\xE3\x81\x97\xE3\x81\x9F." |
324 | 324 | #define MSGJPN324 "\xE3\x83\x97\xE3\x83\xAD\xE3\x82\xBB\xE3\x82\xB9\xE3\x81\xAE\xE4\xBF\x9D\xE8\xAD\xB7\xE3\x81\xAB\xE5\xBF\x85\xE8\xA6\x81\xE3\x81\xAA\xE9\x96\xA2\xE6\x95\xB0\xE3\x82\x92\xE3\x83\x95\xE3\x83\x83\xE3\x82\xAF\xE3\x81\xA7\xE3\x81\x8D\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93\xE3\x81\xA7\xE3\x81\x97\xE3\x81\x9F." |
325 | +#define MSGJPN325 "\xE6\x96\xB0\xE3\x81\x97\xE3\x81\x84\xE3\x83\x9E\xE3\x82\xB9\xE3\x82\xBF\xE3\x83\xBC\xE3\x83\x91\xE3\x82\xB9\xE3\x83\xAF\xE3\x83\xBC\xE3\x83\x89\xE3\x81\x8C\xE4\xB8\x80\xE8\x87\xB4\xE3\x81\x97\xE3\x81\xBE\xE3\x81\x9B\xE3\x82\x93." |
@@ -322,3 +322,4 @@ | ||
322 | 322 | #define MSGJPN322 "デバッガが検出されました." |
323 | 323 | #define MSGJPN323 "信頼できないDLLをアンロードできませんでした." |
324 | 324 | #define MSGJPN324 "プロセスの保護に必要な関数をフックできませんでした." |
325 | +#define MSGJPN325 "新しいマスターパスワードが一致しません." |
@@ -388,27 +388,69 @@ BOOL FindTrustedModuleSHA1Hash(void* pHash) | ||
388 | 388 | // ファイルの署名を確認 |
389 | 389 | BOOL VerifyFileSignature(LPCWSTR Filename) |
390 | 390 | { |
391 | +// BOOL bResult; | |
392 | +// GUID g = WINTRUST_ACTION_GENERIC_VERIFY_V2; | |
393 | +// WINTRUST_FILE_INFO wfi; | |
394 | +// WINTRUST_DATA wd; | |
395 | +// LONG Error; | |
396 | +// bResult = FALSE; | |
397 | +// ZeroMemory(&wfi, sizeof(WINTRUST_FILE_INFO)); | |
398 | +// wfi.cbStruct = sizeof(WINTRUST_FILE_INFO); | |
399 | +// wfi.pcwszFilePath = Filename; | |
400 | +// ZeroMemory(&wd, sizeof(WINTRUST_DATA)); | |
401 | +// wd.cbStruct = sizeof(WINTRUST_DATA); | |
402 | +// wd.dwUIChoice = WTD_UI_NONE; | |
403 | +// wd.dwUnionChoice = WTD_CHOICE_FILE; | |
404 | +// wd.pFile = &wfi; | |
405 | +// Error = WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd); | |
406 | +// if(Error == ERROR_SUCCESS) | |
407 | +// bResult = TRUE; | |
408 | +// else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_EXPIRED) && Error == CERT_E_EXPIRED) | |
409 | +// bResult = TRUE; | |
410 | +// else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_UNAUTHORIZED) && (Error == CERT_E_UNTRUSTEDROOT || Error == CERT_E_UNTRUSTEDCA)) | |
411 | +// bResult = TRUE; | |
412 | +// return bResult; | |
391 | 413 | BOOL bResult; |
392 | - GUID g = WINTRUST_ACTION_GENERIC_VERIFY_V2; | |
393 | - WINTRUST_FILE_INFO wfi; | |
394 | - WINTRUST_DATA wd; | |
395 | - LONG Error; | |
414 | + HCERTSTORE hStore; | |
415 | + PCCERT_CONTEXT pcc; | |
416 | + CERT_CHAIN_PARA ccp; | |
417 | + CERT_CHAIN_CONTEXT* pccc; | |
418 | + CERT_CHAIN_POLICY_PARA ccpp; | |
419 | + CERT_CHAIN_POLICY_STATUS ccps; | |
396 | 420 | bResult = FALSE; |
397 | - ZeroMemory(&wfi, sizeof(WINTRUST_FILE_INFO)); | |
398 | - wfi.cbStruct = sizeof(WINTRUST_FILE_INFO); | |
399 | - wfi.pcwszFilePath = Filename; | |
400 | - ZeroMemory(&wd, sizeof(WINTRUST_DATA)); | |
401 | - wd.cbStruct = sizeof(WINTRUST_DATA); | |
402 | - wd.dwUIChoice = WTD_UI_NONE; | |
403 | - wd.dwUnionChoice = WTD_CHOICE_FILE; | |
404 | - wd.pFile = &wfi; | |
405 | - Error = WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd); | |
406 | - if(Error == ERROR_SUCCESS) | |
407 | - bResult = TRUE; | |
408 | - else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_EXPIRED) && Error == CERT_E_EXPIRED) | |
409 | - bResult = TRUE; | |
410 | - else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_UNAUTHORIZED) && (Error == CERT_E_UNTRUSTEDROOT || Error == CERT_E_UNTRUSTEDCA)) | |
411 | - bResult = TRUE; | |
421 | + if(CryptQueryObject(CERT_QUERY_OBJECT_FILE, Filename, CERT_QUERY_CONTENT_FLAG_ALL, CERT_QUERY_FORMAT_FLAG_ALL, 0, NULL, NULL, NULL, &hStore, NULL, NULL)) | |
422 | + { | |
423 | + pcc = NULL; | |
424 | + while(!bResult && (pcc = CertEnumCertificatesInStore(hStore, pcc))) | |
425 | + { | |
426 | + ZeroMemory(&ccp, sizeof(CERT_CHAIN_PARA)); | |
427 | + ccp.cbSize = sizeof(CERT_CHAIN_PARA); | |
428 | + if(CertGetCertificateChain(NULL, pcc, NULL, NULL, &ccp, 0, NULL, &pccc)) | |
429 | + { | |
430 | + ZeroMemory(&ccpp, sizeof(CERT_CHAIN_POLICY_PARA)); | |
431 | + ccpp.cbSize = sizeof(CERT_CHAIN_POLICY_PARA); | |
432 | + if(g_ProcessProtectionLevel & PROCESS_PROTECTION_EXPIRED) | |
433 | + ccpp.dwFlags |= CERT_CHAIN_POLICY_IGNORE_NOT_TIME_VALID_FLAG; | |
434 | + else if(g_ProcessProtectionLevel & PROCESS_PROTECTION_UNAUTHORIZED) | |
435 | + ccpp.dwFlags |= CERT_CHAIN_POLICY_ALLOW_UNKNOWN_CA_FLAG; | |
436 | + ZeroMemory(&ccps, sizeof(CERT_CHAIN_POLICY_STATUS)); | |
437 | + ccps.cbSize = sizeof(CERT_CHAIN_POLICY_STATUS); | |
438 | + if(CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_AUTHENTICODE, pccc, &ccpp, &ccps)) | |
439 | + { | |
440 | + if(ccps.dwError == ERROR_SUCCESS) | |
441 | + { | |
442 | + bResult = TRUE; | |
443 | + break; | |
444 | + } | |
445 | + } | |
446 | + CertFreeCertificateChain(pccc); | |
447 | + } | |
448 | + } | |
449 | + while(pcc = CertEnumCertificatesInStore(hStore, pcc)) | |
450 | + { | |
451 | + } | |
452 | + CertCloseStore(hStore, 0); | |
453 | + } | |
412 | 454 | return bResult; |
413 | 455 | } |
414 | 456 |
@@ -419,7 +461,6 @@ BOOL VerifyFileSignatureInCatalog(LPCWSTR Catalog, LPCWSTR Filename) | ||
419 | 461 | GUID g = WINTRUST_ACTION_GENERIC_VERIFY_V2; |
420 | 462 | WINTRUST_CATALOG_INFO wci; |
421 | 463 | WINTRUST_DATA wd; |
422 | - LONG Error; | |
423 | 464 | bResult = FALSE; |
424 | 465 | if(VerifyFileSignature(Catalog)) |
425 | 466 | { |
@@ -439,12 +480,7 @@ BOOL VerifyFileSignatureInCatalog(LPCWSTR Catalog, LPCWSTR Filename) | ||
439 | 480 | wd.dwUIChoice = WTD_UI_NONE; |
440 | 481 | wd.dwUnionChoice = WTD_CHOICE_CATALOG; |
441 | 482 | wd.pCatalog = &wci; |
442 | - Error = WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd); | |
443 | - if(Error == ERROR_SUCCESS) | |
444 | - bResult = TRUE; | |
445 | - else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_EXPIRED) && Error == CERT_E_EXPIRED) | |
446 | - bResult = TRUE; | |
447 | - else if((g_ProcessProtectionLevel & PROCESS_PROTECTION_UNAUTHORIZED) && (Error == CERT_E_UNTRUSTEDROOT || Error == CERT_E_UNTRUSTEDCA)) | |
483 | + if(WinVerifyTrust((HWND)INVALID_HANDLE_VALUE, &g, &wd) == ERROR_SUCCESS) | |
448 | 484 | bResult = TRUE; |
449 | 485 | } |
450 | 486 | free(wci.pbCalculatedFileHash); |