28 #define PVM_CHECKSUM_DONE (WM_APP + 1)
29 #define PVM_VERIFY_DONE (WM_APP + 2)
79 PROPSHEETHEADER propSheetHeader = {
sizeof(propSheetHeader) };
80 PROPSHEETPAGE propSheetPage;
81 HPROPSHEETPAGE pages[5];
84 PIMAGE_DATA_DIRECTORY entry;
90 PhShowStatus(NULL, L
"Unable to load the PE file", status, 0);
94 propSheetHeader.dwFlags =
98 propSheetHeader.hwndParent = NULL;
100 propSheetHeader.nPages = 0;
101 propSheetHeader.nStartPage = 0;
102 propSheetHeader.phpage = pages;
105 memset(&propSheetPage, 0,
sizeof(PROPSHEETPAGE));
106 propSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
109 pages[propSheetHeader.nPages++] = CreatePropertySheetPage(&propSheetPage);
115 memset(&propSheetPage, 0,
sizeof(PROPSHEETPAGE));
116 propSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
119 pages[propSheetHeader.nPages++] = CreatePropertySheetPage(&propSheetPage);
125 memset(&propSheetPage, 0,
sizeof(PROPSHEETPAGE));
126 propSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
129 pages[propSheetHeader.nPages++] = CreatePropertySheetPage(&propSheetPage);
135 memset(&propSheetPage, 0,
sizeof(PROPSHEETPAGE));
136 propSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
139 pages[propSheetHeader.nPages++] = CreatePropertySheetPage(&propSheetPage);
144 entry->VirtualAddress &&
147 status = STATUS_SUCCESS;
154 __except (EXCEPTION_EXECUTE_HANDLER)
156 status = GetExceptionCode();
161 memset(&propSheetPage, 0,
sizeof(PROPSHEETPAGE));
162 propSheetPage.dwSize =
sizeof(PROPSHEETPAGE);
163 propSheetPage.pszTemplate = MAKEINTRESOURCE(
IDD_PECLR);
165 pages[propSheetHeader.nPages++] = CreatePropertySheetPage(&propSheetPage);
169 PropertySheet(&propSheetHeader);
174 static NTSTATUS CheckSumImageThreadStart(
181 windowHandle = Parameter;
191 return STATUS_SUCCESS;
207 PCERT_CONTEXT *signatures;
208 ULONG numberOfSignatures;
222 ULONG_PTR indexOfBackslash;
225 remainingFileName = FileName->sr;
229 if (indexOfBackslash != -1)
231 baseFileName.
Buffer = FileName->Buffer;
232 baseFileName.
Length = windowsAppsPath->
Length + indexOfBackslash *
sizeof(WCHAR);
233 additionalCatalogFileName =
PhConcatStringRef2(&baseFileName, &codeIntegrityFileName);
240 if (additionalCatalogFileName)
250 numberOfSignatures = 0;
253 if (additionalCatalogFileName)
258 if (numberOfSignatures != 0)
269 static NTSTATUS VerifyImageThreadStart(
275 windowHandle = Parameter;
279 return STATUS_SUCCESS;
287 return String->Buffer;
340 switch (PvMappedImage.
NtHeaders->FileHeader.Machine)
342 case IMAGE_FILE_MACHINE_I386:
345 case IMAGE_FILE_MACHINE_AMD64:
348 case IMAGE_FILE_MACHINE_IA64:
351 case IMAGE_FILE_MACHINE_ARMNT:
352 type = L
"ARM Thumb-2";
363 SYSTEMTIME systemTime;
373 if (PvMappedImage.
Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
379 string =
PhFormatString(L
"0x%I64x", ((PIMAGE_OPTIONAL_HEADER64)&PvMappedImage.
NtHeaders->OptionalHeader)->ImageBase);
391 switch (PvMappedImage.
NtHeaders->OptionalHeader.Subsystem)
393 case IMAGE_SUBSYSTEM_NATIVE:
396 case IMAGE_SUBSYSTEM_WINDOWS_GUI:
397 type = L
"Windows GUI";
399 case IMAGE_SUBSYSTEM_WINDOWS_CUI:
400 type = L
"Windows CUI";
402 case IMAGE_SUBSYSTEM_OS2_CUI:
405 case IMAGE_SUBSYSTEM_POSIX_CUI:
408 case IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
409 type = L
"Windows CE CUI";
411 case IMAGE_SUBSYSTEM_EFI_APPLICATION:
412 type = L
"EFI Application";
414 case IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
415 type = L
"EFI Boot Service Driver";
417 case IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
418 type = L
"EFI Runtime Driver";
420 case IMAGE_SUBSYSTEM_EFI_ROM:
423 case IMAGE_SUBSYSTEM_XBOX:
426 case IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION:
427 type = L
"Windows Boot Application";
438 PvMappedImage.
NtHeaders->OptionalHeader.MajorSubsystemVersion,
439 PvMappedImage.
NtHeaders->OptionalHeader.MinorSubsystemVersion
446 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE)
448 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_DLL)
450 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_LARGE_ADDRESS_AWARE)
452 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP)
454 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_NET_RUN_FROM_SWAP)
456 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_SYSTEM)
458 if (PvMappedImage.
NtHeaders->FileHeader.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY)
461 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA)
463 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE)
465 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY)
467 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT)
469 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_ISOLATION)
471 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_SEH)
473 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_BIND)
475 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_APPCONTAINER)
477 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_WDM_DRIVER)
479 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_GUARD_CF)
481 if (PvMappedImage.
NtHeaders->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE)
490 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
500 WCHAR sectionName[9];
504 IMAGE_SIZEOF_SHORT_NAME, sectionName, 9, NULL))
520 ULONG headerCheckSum;
523 headerCheckSum = PvMappedImage.
NtHeaders->OptionalHeader.CheckSum;
524 realCheckSum = (ULONG)wParam;
526 if (headerCheckSum == 0)
533 else if (headerCheckSum == realCheckSum)
541 string =
PhFormatString(L
"0x%Ix (incorrect, real 0x%Ix)", headerCheckSum, realCheckSum);
553 if (PvImageSignerName)
582 LPNMHDR header = (LPNMHDR)lParam;
584 switch (header->code)
588 switch (header->idFrom)
609 _In_ HWND ListViewHandle,
611 _In_ BOOLEAN DelayImports
619 for (i = 0; i < Imports->NumberOfDlls; i++)
639 if (importEntry.
Name)
671 ULONG fallbackColumns[] = { 0, 1, 2 };
675 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
724 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
746 if (exportEntry.
Name)
762 if ((ULONG_PTR)exportFunction.
Function >= (ULONG_PTR)PvMappedImage.
ViewBase)
805 PIMAGE_LOAD_CONFIG_DIRECTORY32 config32;
806 PIMAGE_LOAD_CONFIG_DIRECTORY64 config64;
809 lvHandle = GetDlgItem(hwndDlg,
IDC_LIST);
815 #define ADD_VALUE(Name, Value) \
819 lvItemIndex = PhAddListViewItem(lvHandle, MAXINT, Name, NULL); \
820 PhSetListViewSubItem(lvHandle, lvItemIndex, 1, Value); \
823 #define ADD_VALUES(Config) \
826 LARGE_INTEGER time; \
827 SYSTEMTIME systemTime; \
829 RtlSecondsSince1970ToTime((Config)->TimeDateStamp, &time); \
830 PhLargeIntegerToLocalSystemTime(&systemTime, &time); \
832 string = PhFormatDateTime(&systemTime); \
833 ADD_VALUE(L"Time stamp", string->Buffer); \
834 PhDereferenceObject(string); \
837 ADD_VALUE(L"Version", PhaFormatString(L"%u.%u", (Config)->MajorVersion, (Config)->MinorVersion)->Buffer); \
838 ADD_VALUE(L"Global flags to clear", PhaFormatString(L"0x%x", (Config)->GlobalFlagsClear)->Buffer); \
839 ADD_VALUE(L"Global flags to set", PhaFormatString(L"0x%x", (Config)->GlobalFlagsSet)->Buffer); \
840 ADD_VALUE(L"Critical section default timeout", PhaFormatUInt64((Config)->CriticalSectionDefaultTimeout, TRUE)->Buffer); \
841 ADD_VALUE(L"De-commit free block threshold", PhaFormatUInt64((Config)->DeCommitFreeBlockThreshold, TRUE)->Buffer); \
842 ADD_VALUE(L"De-commit total free threshold", PhaFormatUInt64((Config)->DeCommitTotalFreeThreshold, TRUE)->Buffer); \
843 ADD_VALUE(L"LOCK prefix table", PhaFormatString(L"0x%Ix", (Config)->LockPrefixTable)->Buffer); \
844 ADD_VALUE(L"Maximum allocation size", PhaFormatString(L"0x%Ix", (Config)->MaximumAllocationSize)->Buffer); \
845 ADD_VALUE(L"Virtual memory threshold", PhaFormatString(L"0x%Ix", (Config)->VirtualMemoryThreshold)->Buffer); \
846 ADD_VALUE(L"Process affinity mask", PhaFormatString(L"0x%Ix", (Config)->ProcessAffinityMask)->Buffer); \
847 ADD_VALUE(L"Process heap flags", PhaFormatString(L"0x%Ix", (Config)->ProcessHeapFlags)->Buffer); \
848 ADD_VALUE(L"CSD version", PhaFormatString(L"%u", (Config)->CSDVersion)->Buffer); \
849 ADD_VALUE(L"Edit list", PhaFormatString(L"0x%Ix", (Config)->EditList)->Buffer); \
850 ADD_VALUE(L"Security cookie", PhaFormatString(L"0x%Ix", (Config)->SecurityCookie)->Buffer); \
851 ADD_VALUE(L"SEH handler table", PhaFormatString(L"0x%Ix", (Config)->SEHandlerTable)->Buffer); \
852 ADD_VALUE(L"SEH handler count", PhaFormatUInt64((Config)->SEHandlerCount, TRUE)->Buffer); \
857 if (PvMappedImage.
Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
899 ULONG versionStringLength;
942 __except (EXCEPTION_EXECUTE_HANDLER)
948 versionStringLength = 0;
955 versionStringLength = *(PULONG)((PCHAR)metaData + 12);
958 if (versionStringLength >= 0x100)
959 versionStringLength = 0;
962 if (versionStringLength != 0)
976 LPNMHDR header = (LPNMHDR)lParam;
978 switch (header->code)
980 case PSN_QUERYINITIALFOCUS:
982 SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)GetDlgItem(hwndDlg,
IDC_RUNTIMEVERSION));