100 DPRINT(
" An installation '%S' of unsupported type %lu\n",
101 BootEntry->FriendlyName, BootEntry->OsOptionsLength);
110 DPRINT1(
" A Win2k3 install '%S' without an ARC path?!\n", BootEntry->FriendlyName);
115 DPRINT(
" Found a candidate Win2k3 install '%S' with ARC path '%S'\n",
116 BootEntry->FriendlyName,
Options->OsLoadPath);
129 DPRINT(
" An NTOS installation with name \"%S\" from vendor \"%S\" already exists in SystemRoot '%wZ'\n",
130 NtOsInstall->InstallationName, NtOsInstall->VendorName, &NtOsInstall->SystemArcPath);
143 DPRINT1(
"ArcPathToNtPath(%S) failed, skip the installation.\n",
Options->OsLoadPath);
148 DPRINT(
"ArcPathToNtPath() succeeded: '%S' --> '%wZ'\n",
149 Options->OsLoadPath, &SystemRootPath);
158 DPRINT1(
" An NTOS installation with name \"%S\" from vendor \"%S\" already exists in SystemRoot '%wZ'\n",
159 NtOsInstall->InstallationName, NtOsInstall->VendorName, &NtOsInstall->SystemNtPath);
164 DPRINT(
"EnumerateInstallations: SystemRootPath: '%wZ'\n", &SystemRootPath);
167 RtlInitEmptyUnicodeString(&
VendorName, VendorNameBuffer,
sizeof(VendorNameBuffer));
174 DPRINT(
"Found a valid NTOS installation in SystemRoot ARC path '%S', NT path '%wZ'\n",
175 Options->OsLoadPath, &SystemRootPath);
180 DPRINT(
"SystemRootPath = '%wZ' points to disk #%d, partition #%d, path '%S'\n",
185 DPRINT1(
"NtPathToDiskPartComponents(%wZ) failed\n", &SystemRootPath);
190 BootEntry->FriendlyName,
202 DPRINT1(
"SelectPartition(disk #%d, partition #%d) failed\n",
205 NtOsInstall->Volume = (PartEntry ? PartEntry->
Volume :
NULL);
267 &SectionHandle, &ViewBase,
FALSE);
270 DPRINT1(
"Failed to open and map file '%S', Status 0x%08lx\n", PathNameToFile,
Status);
278 DPRINT1(
"File '%S' does not seem to be a valid NT PE file, bail out\n", PathNameToFile);
293 DPRINT1(
"Failed to get version resource for file '%S', Status 0x%08lx\n", PathNameToFile,
Status);
300 USHORT wCodePage = 0, wLangID = 0;
307 L"StringFileInfo\\%04X%04X\\CompanyName",
319 DPRINT(
"Found version vendor: \"%S\" for file '%S'\n",
pvData, PathNameToFile);
330 DPRINT(
"No version vendor found for file '%S'\n", PathNameToFile);
372 PathName =
L"System32\\";
380 PathName =
L"System32\\drivers\\";
388 PathName =
L"System32\\config\\";
400 PathName =
L"System32\\config\\SYSTEM";
406 PathName =
L"System32\\config\\SOFTWARE";
414 RtlInitEmptyUnicodeString(&LocalVendorName, VendorNameBuffer,
sizeof(VendorNameBuffer));
417 PathName =
L"System32\\ntoskrnl.exe";
420 DPRINT1(
"Kernel executable '%S' is either not a PE file, or does not have any vendor?\n", PathName);
437 DPRINT(
"IsValidNTOSInstallation: We've got an NTOS installation from %S !\n",
KnownVendors[
i]);
446 *Machine = LocalMachine;
462 PathName =
L"System32\\ntdll.dll";
465 DPRINT1(
"User-mode DLL '%S' is either not a PE file, or does not have any vendor?\n", PathName);
474 DPRINT(
"IsValidNTOSInstallation: The user-mode DLL '%S' is from %S\n", PathName,
KnownVendors[
i]);
483 *Machine = LocalMachine;
508 HANDLE SystemRootDirectory;
525 DPRINT1(
"Failed to open SystemRoot '%wZ', Status 0x%08lx\n", SystemRootPath,
Status);
546 DPRINT(
"There %s %d installation%s detected:\n",
547 NtOsInstallsCount >= 2 ?
"are" :
"is",
549 NtOsInstallsCount >= 2 ?
"s" :
"");
555 DPRINT(
" On disk #%d, partition #%d: Installation \"%S\" in SystemRoot '%wZ'\n",
579 if (!SystemRootArcPath && !SystemRootNtPath)
593 if ( (SystemRootArcPath &&
595 &SystemArcPath,
TRUE)) ||
598 SystemRootNtPath,
TRUE)) )
621 SIZE_T ArcPathLength, NtPathLength;
627 DPRINT1(
"An NTOS installation with name \"%S\" from vendor \"%S\" already exists on disk #%d, partition #%d, in SystemRoot '%wZ'\n",
637 ArcPathLength = (
wcslen(SystemRootArcPath) + 1) *
sizeof(
WCHAR);
639 NtPathLength = SystemRootNtPath->Length +
sizeof(
UNICODE_NULL);
643 sizeof(*NtOsInstall) +
644 ArcPathLength + NtPathLength);
650 NtOsInstall->
Machine = Machine;
653 (
PWCHAR)(NtOsInstall + 1),
685 HANDLE VolumeRootDirHandle;
690 PVOID BootStoreHandle;
697 L"%s\\",
Volume->Info.DeviceName);
699 DPRINT(
"FindNTOSInstallations(%wZ)\n", &VolumeRootPath);
715 DPRINT1(
"Failed to open volume '%wZ', Status 0x%08lx\n", &VolumeRootPath,
Status);
720 Data.PartList = PartList;
729 DPRINT(
"Loader type '%d' does not exist, or an error happened (Status 0x%08lx), continue with another one...\n",
735 DPRINT(
"Analyze the OS installations for loader type '%d' in Volume %wZ (Disk #%d, Partition #%d)\n",
736 Type, &VolumeRootPath,
737 Volume->PartEntry->DiskEntry->DiskNumber,
738 Volume->PartEntry->PartitionNumber);
744 DPRINT1(
"Could not open the NTOS boot store of type '%d' (Status 0x%08lx), continue with another one...\n",
776 for (
Entry = PartList->VolumesList.Flink;
777 Entry != &PartList->VolumesList;
791 DPRINT(
"Volume %S (%c%c) on Disk #%d, Partition #%d (%s), "
792 "index %d - Type 0x%02x, IsVolNew = %s, FormatState = %lu -- Should I check it? %s\n",
795 !
Volume->Info.DriveLetter ?
'-' :
':',
801 Volume->New ?
"Yes" :
"No",
813 DumpNTOSInstalls(
List);
static const char VendorName[]
static NTSTATUS CheckVolume(IN PCWSTR VolumePath, IN LONG TimeOut, IN BOOLEAN CheckOnlyIfDirty)
#define FILE_DIRECTORY_FILE
BOOLEAN ArcPathToNtPath(OUT PUNICODE_STRING NtPath, IN PCWSTR ArcPath, IN PPARTLIST PartList OPTIONAL)
NTSTATUS OpenBootStoreByHandle(_Out_ PVOID *Handle, _In_ HANDLE PartitionDirectoryHandle, _In_ BOOT_STORE_TYPE Type, _In_ BOOT_STORE_OPENMODE OpenMode, _In_ BOOT_STORE_ACCESS Access)
NTSTATUS CloseBootStore(_In_ PVOID Handle)
NTSTATUS EnumerateBootStoreEntries(IN PVOID Handle, IN PENUM_BOOT_ENTRIES_ROUTINE EnumBootEntriesRoutine, IN PVOID Parameter OPTIONAL)
NTSTATUS FindBootStore(IN HANDLE PartitionDirectoryHandle, IN BOOT_STORE_TYPE Type, OUT PULONG VersionNumber OPTIONAL)
struct _NTOS_OPTIONS * PNTOS_OPTIONS
#define NTOS_OPTIONS_SIGNATURE
enum _BOOT_STORE_TYPE BOOT_STORE_TYPE
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static const WCHAR SystemRoot[]
static const WCHAR Signature[]
#define RtlCompareMemory(s1, s2, l)
BOOLEAN NtPathToDiskPartComponents(IN PCWSTR NtPath, OUT PULONG pDiskNumber, OUT PULONG pPartNumber, OUT PCWSTR *PathComponent OPTIONAL)
NTSTATUS OpenAndMapFile(_In_opt_ HANDLE RootDirectory, _In_ PCWSTR PathNameToFile, _Out_opt_ PHANDLE FileHandle, _Out_opt_ PULONG FileSize, _Out_ PHANDLE SectionHandle, _Out_ PVOID *BaseAddress, _In_ BOOLEAN ReadWriteAccess)
Opens and maps a file in memory.
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress)
#define DoesDirExist(RootDirectory, DirName)
#define DoesFileExist(RootDirectory, FileName)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
#define RTL_FIELD_SIZE(type, field)
PGENERIC_LIST CreateGenericList(VOID)
PGENERIC_LIST_ENTRY GetFirstListEntry(IN PGENERIC_LIST List)
BOOLEAN AppendGenericListEntry(IN OUT PGENERIC_LIST List, IN PVOID Data, IN BOOLEAN Current)
ULONG GetNumberOfListEntries(IN PGENERIC_LIST List)
PVOID GetListEntryData(IN PGENERIC_LIST_ENTRY Entry)
PGENERIC_LIST_ENTRY GetNextListEntry(IN PGENERIC_LIST_ENTRY Entry)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
#define FILE_LIST_DIRECTORY
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define RTL_NUMBER_OF_FIELD(type, field)
#define STATUS_INVALID_IMAGE_FORMAT
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
NTSTATUS NtGetVersionResource(IN PVOID BaseAddress, OUT PVOID *Resource, OUT PULONG ResourceSize OPTIONAL)
NTSTATUS NtVerQueryValue(IN const VOID *pBlock, IN PCWSTR lpSubBlock, OUT PVOID *lplpBuffer, OUT PUINT puLen)
struct _ENUM_INSTALLS_DATA ENUM_INSTALLS_DATA
static PNTOS_INSTALLATION FindExistingNTOSInstall(IN PGENERIC_LIST List, IN PCWSTR SystemRootArcPath OPTIONAL, IN PUNICODE_STRING SystemRootNtPath OPTIONAL)
PGENERIC_LIST CreateNTOSInstallationsList(_In_ PPARTLIST PartList)
Create a list of available NT OS installations on the computer, by searching for recognized ones on e...
static const PCWSTR KnownVendors[]
static VOID FindNTOSInstallations(_Inout_ PGENERIC_LIST List, _In_ PPARTLIST PartList, _In_ PVOLENTRY Volume)
static PNTOS_INSTALLATION AddNTOSInstallation(_In_ PGENERIC_LIST List, _In_ PCWSTR InstallationName, _In_ USHORT Machine, _In_ PCWSTR VendorName, _In_ PCWSTR SystemRootArcPath, _In_ PUNICODE_STRING SystemRootNtPath, _In_ PCWSTR PathComponent, _In_ ULONG DiskNumber, _In_ ULONG PartitionNumber)
struct _ENUM_INSTALLS_DATA * PENUM_INSTALLS_DATA
static BOOLEAN IsValidNTOSInstallationByHandle(IN HANDLE SystemRootDirectory, OUT PUSHORT Machine OPTIONAL, OUT PUNICODE_STRING VendorName OPTIONAL)
static BOOLEAN IsValidNTOSInstallation(IN PUNICODE_STRING SystemRootPath, OUT PUSHORT Machine OPTIONAL, OUT PUNICODE_STRING VendorName OPTIONAL)
static BOOLEAN CheckForValidPEAndVendor(IN HANDLE RootDirectory OPTIONAL, IN PCWSTR PathNameToFile, OUT PUSHORT Machine, OUT PUNICODE_STRING VendorName)
static NTSTATUS NTAPI EnumerateInstallations(IN BOOT_STORE_TYPE Type, IN PBOOT_STORE_ENTRY BootEntry, IN PVOID Parameter OPTIONAL)
PCWSTR FindSubStrI(PCWSTR str, PCWSTR strSearch)
struct _NTOS_INSTALLATION * PNTOS_INSTALLATION
PPARTENTRY SelectPartition(_In_ PPARTLIST List, _In_ ULONG DiskNumber, _In_ ULONG PartitionNumber)
PULONG MinorVersion OPTIONAL
base of all file and directory entries
_Inout_ PGENERIC_LIST List
WCHAR InstallationName[MAX_PATH]
UNICODE_STRING SystemNtPath
WCHAR VendorName[MAX_PATH]
UNICODE_STRING SystemArcPath
struct _DISKENTRY * DiskEntry
#define RtlCopyMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
_Must_inspect_result_ _In_ WDFCMRESLIST List
_In_ ULONG _In_opt_ PVOID pvData
_In_ ULONG _In_ ULONG PartitionNumber
_Inout_opt_ PVOID Parameter