Skip to content

Commit 094a90a

Browse files
committed
[NTOS:PS] Fix an issue with PROCESS_DEVICEMAP_INFORMATION size on 64 bit builds
The PROCESS_DEVICEMAP_INFORMATION union has 2 fields, one is a handle, the other one is a structure of 36 bytes (independent of architecture). The handle forces 64 bit alignment on 64 bit builds, making the structure 4 bytes bigger than on 32 bit builds. The site is checked in NtQueryInformationProcess (case ProcessDeviceMap). The expected size on x64 is the size of the Query structure without alignment. autocheck correctly passes the site of the Query union member, while smss passes the full size of PROCESS_DEVICEMAP_INFORMATION. Packing the structure is not an option, since it is defined in public headers without packing. Using the original headers sizeof(PROCESS_DEVICEMAP_INFORMATION) is 0x28, sizeof(PROCESS_DEVICEMAP_INFORMATION::Query) is 0x24.
1 parent 36174f9 commit 094a90a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

base/system/smss/pagefile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,8 @@ SmpCreateVolumeDescriptors(VOID)
837837
/* Query the device map so we can get the drive letters */
838838
Status = NtQueryInformationProcess(NtCurrentProcess(),
839839
ProcessDeviceMap,
840-
&ProcessInformation,
841-
sizeof(ProcessInformation),
840+
&ProcessInformation.Query,
841+
sizeof(ProcessInformation.Query),
842842
NULL);
843843
if (!NT_SUCCESS(Status))
844844
{

dll/win32/kernel32/client/file/disk.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ GetLogicalDrives(VOID)
115115
/* Get the Device Map for this Process */
116116
Status = NtQueryInformationProcess(NtCurrentProcess(),
117117
ProcessDeviceMap,
118-
&ProcessDeviceMapInfo,
119-
sizeof(ProcessDeviceMapInfo),
118+
&ProcessDeviceMapInfo.Query,
119+
sizeof(ProcessDeviceMapInfo.Query),
120120
NULL);
121121

122122
/* Return the Drive Map */
@@ -557,9 +557,10 @@ GetDriveTypeW(IN LPCWSTR lpRootPathName)
557557
PROCESS_DEVICEMAP_INFORMATION DeviceMap;
558558

559559
/* Query the device map */
560-
Status = NtQueryInformationProcess(NtCurrentProcess(), ProcessDeviceMap,
561-
&DeviceMap,
562-
sizeof(PROCESS_DEVICEMAP_INFORMATION),
560+
Status = NtQueryInformationProcess(NtCurrentProcess(),
561+
ProcessDeviceMap,
562+
&DeviceMap.Query,
563+
sizeof(DeviceMap.Query),
563564
NULL);
564565
/* Zero output if we failed */
565566
if (!NT_SUCCESS(Status))

ntoskrnl/ps/query.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
564564
/* DOS Device Map */
565565
case ProcessDeviceMap:
566566

567-
if (ProcessInformationLength != sizeof(PROCESS_DEVICEMAP_INFORMATION))
567+
if (ProcessInformationLength != RTL_FIELD_SIZE(PROCESS_DEVICEMAP_INFORMATION, Query))
568568
{
569569
if (ProcessInformationLength == sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
570570
{

0 commit comments

Comments
 (0)