ReactOS 0.4.15-dev-7705-g2320c37
partition.c
Go to the documentation of this file.
1/*
2 * PROJECT: Partition manager driver
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Partition device code
5 * COPYRIGHT: 2020 Victor Perevertkin (victor.perevertkin@reactos.org)
6 */
7
8#include "partmgr.h"
9
10static const WCHAR PartitionSymLinkFormat[] = L"\\Device\\Harddisk%u\\Partition%u";
11
12
13CODE_SEG("PAGE")
16 _In_ PDEVICE_OBJECT FDObject,
17 _In_ PPARTITION_INFORMATION_EX PartitionEntry,
18 _In_ UINT32 PdoNumber,
19 _In_ PARTITION_STYLE PartitionStyle,
21{
22 PAGED_CODE();
23
24 static UINT32 HarddiskVolumeNextId = 1; // this is 1-based
25
26 WCHAR nameBuf[64];
27 UNICODE_STRING deviceName;
28
29 // create the device object
30
31 swprintf(nameBuf, L"\\Device\\HarddiskVolume%u", HarddiskVolumeNextId++);
32 RtlCreateUnicodeString(&deviceName, nameBuf);
33
34 PDEVICE_OBJECT partitionDevice;
35 NTSTATUS status = IoCreateDevice(FDObject->DriverObject,
36 sizeof(PARTITION_EXTENSION),
37 &deviceName,
40 FALSE,
41 &partitionDevice);
42
43 if (!NT_SUCCESS(status))
44 {
45 ERR("Unable to create device object %wZ\n", &deviceName);
46 return status;
47 }
48
49 INFO("Created device object %p %wZ\n", partitionDevice, &deviceName);
50
51 PPARTITION_EXTENSION partExt = partitionDevice->DeviceExtension;
52 RtlZeroMemory(partExt, sizeof(*partExt));
53
54 partitionDevice->StackSize = FDObject->StackSize;
55 partitionDevice->Flags |= DO_DIRECT_IO;
56
57 if (PartitionStyle == PARTITION_STYLE_MBR)
58 {
59 partExt->Mbr.PartitionType = PartitionEntry->Mbr.PartitionType;
60 partExt->Mbr.BootIndicator = PartitionEntry->Mbr.BootIndicator;
61 partExt->Mbr.HiddenSectors = PartitionEntry->Mbr.HiddenSectors;
62 }
63 else
64 {
65 partExt->Gpt.PartitionType = PartitionEntry->Gpt.PartitionType;
66 partExt->Gpt.PartitionId = PartitionEntry->Gpt.PartitionType;
67 partExt->Gpt.Attributes = PartitionEntry->Gpt.Attributes;
68
69 RtlCopyMemory(partExt->Gpt.Name, PartitionEntry->Gpt.Name, sizeof(partExt->Gpt.Name));
70 }
71
72 partExt->DeviceName = deviceName;
73 partExt->StartingOffset = PartitionEntry->StartingOffset.QuadPart;
74 partExt->PartitionLength = PartitionEntry->PartitionLength.QuadPart;
75 partExt->OnDiskNumber = PartitionEntry->PartitionNumber; // the "physical" partition number
76 partExt->DetectedNumber = PdoNumber; // counts only partitions with PDO created
77
78 partExt->DeviceObject = partitionDevice;
79 partExt->LowerDevice = FDObject;
80
81 partitionDevice->Flags &= ~DO_DEVICE_INITIALIZING;
82
83 *PDO = partitionDevice;
84
85 return status;
86}
87
88static
89CODE_SEG("PAGE")
94{
95 PAGED_CODE();
96
97 // first, create a symbolic link for our device
98 WCHAR nameBuf[64];
99 UNICODE_STRING partitionSymlink, interfaceName;
100 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
101
102 // \\Device\\Harddisk%u\\Partition%u
104 fdoExtension->DiskData.DeviceNumber, PartExt->DetectedNumber);
105
106 if (!RtlCreateUnicodeString(&partitionSymlink, nameBuf))
107 {
109 }
110
111 NTSTATUS status = IoCreateSymbolicLink(&partitionSymlink, &PartExt->DeviceName);
112
113 if (!NT_SUCCESS(status))
114 {
115 return status;
116 }
117
118 PartExt->SymlinkCreated = TRUE;
119
120 TRACE("Symlink created %wZ -> %wZ\n", &PartExt->DeviceName, &partitionSymlink);
121
122 // our partition device will have two interfaces:
123 // GUID_DEVINTERFACE_PARTITION and GUID_DEVINTERFACE_VOLUME
124 // the former one is used to notify mountmgr about new device
125
126 status = IoRegisterDeviceInterface(PartExt->DeviceObject,
127 &GUID_DEVINTERFACE_PARTITION,
128 NULL,
129 &interfaceName);
130
131 if (!NT_SUCCESS(status))
132 {
133 return status;
134 }
135
136 PartExt->PartitionInterfaceName = interfaceName;
137 status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
138
139 INFO("Partition interface %wZ\n", &interfaceName);
140
141 if (!NT_SUCCESS(status))
142 {
143 RtlFreeUnicodeString(&interfaceName);
144 RtlInitUnicodeString(&PartExt->PartitionInterfaceName, NULL);
145 return status;
146 }
147
148 status = IoRegisterDeviceInterface(PartExt->DeviceObject,
149 &GUID_DEVINTERFACE_VOLUME,
150 NULL,
151 &interfaceName);
152
153 if (!NT_SUCCESS(status))
154 {
155 return status;
156 }
157
158 PartExt->VolumeInterfaceName = interfaceName;
159 status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
160
161 INFO("Volume interface %wZ\n", &interfaceName);
162
163 if (!NT_SUCCESS(status))
164 {
165 RtlFreeUnicodeString(&interfaceName);
166 RtlInitUnicodeString(&PartExt->VolumeInterfaceName, NULL);
167 return status;
168 }
169
170 return STATUS_SUCCESS;
171}
172
173CODE_SEG("PAGE")
177 _In_ BOOLEAN FinalRemove)
178{
180
181 PAGED_CODE();
182
183 // remove the symbolic link
184 if (PartExt->SymlinkCreated)
185 {
186 WCHAR nameBuf[64];
187 UNICODE_STRING partitionSymlink;
188 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
189
191 fdoExtension->DiskData.DeviceNumber, PartExt->DetectedNumber);
192
193 RtlInitUnicodeString(&partitionSymlink, nameBuf);
194
195 status = IoDeleteSymbolicLink(&partitionSymlink);
196
197 if (!NT_SUCCESS(status))
198 {
199 return status;
200 }
201 PartExt->SymlinkCreated = FALSE;
202
203 INFO("Symlink removed %wZ -> %wZ\n", &PartExt->DeviceName, &partitionSymlink);
204 }
205
206 // release device interfaces
207 if (PartExt->PartitionInterfaceName.Buffer)
208 {
209 status = IoSetDeviceInterfaceState(&PartExt->PartitionInterfaceName, FALSE);
210 if (!NT_SUCCESS(status))
211 {
212 return status;
213 }
214 RtlFreeUnicodeString(&PartExt->PartitionInterfaceName);
215 RtlInitUnicodeString(&PartExt->PartitionInterfaceName, NULL);
216 }
217
218 if (PartExt->VolumeInterfaceName.Buffer)
219 {
220 status = IoSetDeviceInterfaceState(&PartExt->VolumeInterfaceName, FALSE);
221 if (!NT_SUCCESS(status))
222 {
223 return status;
224 }
225 RtlFreeUnicodeString(&PartExt->VolumeInterfaceName);
226 RtlInitUnicodeString(&PartExt->VolumeInterfaceName, NULL);
227 }
228
229 if (FinalRemove)
230 {
231 ASSERT(PartExt->DeviceName.Buffer);
232 if (PartExt->DeviceName.Buffer)
233 {
234 INFO("Removed device %wZ\n", &PartExt->DeviceName);
235 RtlFreeUnicodeString(&PartExt->DeviceName);
236 }
237
238 IoDeleteDevice(PartExt->DeviceObject);
239 }
240
241 return STATUS_SUCCESS;
242}
243
244static
245CODE_SEG("PAGE")
249 _In_ PIRP Irp)
250{
251 PAGED_CODE();
252
254 DEVICE_RELATION_TYPE type = ioStack->Parameters.QueryDeviceRelations.Type;
255
257 {
258 // Device relations has one entry built in to it's size.
259 PDEVICE_RELATIONS deviceRelations =
260 ExAllocatePoolZero(PagedPool, sizeof(DEVICE_RELATIONS), TAG_PARTMGR);
261
262 if (deviceRelations != NULL)
263 {
264 deviceRelations->Count = 1;
265 deviceRelations->Objects[0] = PartExt->DeviceObject;
266 ObReferenceObject(deviceRelations->Objects[0]);
267
268 Irp->IoStatus.Information = (ULONG_PTR)deviceRelations;
269 return STATUS_SUCCESS;
270 }
271 else
272 {
274 }
275 }
276 else
277 {
278 Irp->IoStatus.Information = 0;
279 return Irp->IoStatus.Status;
280 }
281}
282
283static
284CODE_SEG("PAGE")
288 _In_ PIRP Irp)
289{
291 BUS_QUERY_ID_TYPE idType = ioStack->Parameters.QueryId.IdType;
292 UNICODE_STRING idString;
294
295 PAGED_CODE();
296
297 switch (idType)
298 {
299 case BusQueryDeviceID:
300 status = RtlCreateUnicodeString(&idString, L"STORAGE\\Partition")
302 break;
304 {
305 static WCHAR volumeID[] = L"STORAGE\\Volume\0";
306
307 idString.Buffer = ExAllocatePoolWithTag(PagedPool, sizeof(volumeID), TAG_PARTMGR);
308 RtlCopyMemory(idString.Buffer, volumeID, sizeof(volumeID));
309
311 break;
312 }
314 {
315 WCHAR string[64];
316 PFDO_EXTENSION fdoExtension = PartExt->LowerDevice->DeviceExtension;
317
318 PartMgrAcquireLayoutLock(fdoExtension);
319
320 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
321 {
322 swprintf(string, L"S%08lx_O%I64x_L%I64x",
323 fdoExtension->DiskData.Mbr.Signature,
324 PartExt->StartingOffset,
325 PartExt->PartitionLength);
326 }
327 else
328 {
329 swprintf(string,
330 L"S%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
331 fdoExtension->DiskData.Gpt.DiskId.Data1,
332 fdoExtension->DiskData.Gpt.DiskId.Data2,
333 fdoExtension->DiskData.Gpt.DiskId.Data3,
334 fdoExtension->DiskData.Gpt.DiskId.Data4[0],
335 fdoExtension->DiskData.Gpt.DiskId.Data4[1],
336 fdoExtension->DiskData.Gpt.DiskId.Data4[2],
337 fdoExtension->DiskData.Gpt.DiskId.Data4[3],
338 fdoExtension->DiskData.Gpt.DiskId.Data4[4],
339 fdoExtension->DiskData.Gpt.DiskId.Data4[5],
340 fdoExtension->DiskData.Gpt.DiskId.Data4[6],
341 fdoExtension->DiskData.Gpt.DiskId.Data4[7],
342 PartExt->StartingOffset,
343 PartExt->PartitionLength);
344 }
345
346 PartMgrReleaseLayoutLock(fdoExtension);
347
348 status = RtlCreateUnicodeString(&idString, string)
350 break;
351 }
352 default:
354 break;
355 }
356
357 Irp->IoStatus.Information = NT_SUCCESS(status) ? (ULONG_PTR) idString.Buffer : 0;
358 return status;
359}
360
361static
362CODE_SEG("PAGE")
366 _In_ PIRP Irp)
367{
369 PDEVICE_CAPABILITIES devCaps = ioStack->Parameters.DeviceCapabilities.Capabilities;
370
371 PAGED_CODE();
372 ASSERT(devCaps);
373
374 devCaps->SilentInstall = TRUE;
375 devCaps->RawDeviceOK = TRUE;
376 devCaps->NoDisplayInUI = TRUE;
377 devCaps->Address = PartExt->OnDiskNumber;
378 devCaps->UniqueID = FALSE;
379
380 return STATUS_SUCCESS;
381}
382
383CODE_SEG("PAGE")
387 _In_ PIRP Irp)
388{
389 PPARTITION_EXTENSION partExt = DeviceObject->DeviceExtension;
392
393 PAGED_CODE();
394
395 switch (ioStack->MinorFunction)
396 {
398 {
400 break;
401 }
403 {
405 break;
406 }
412 {
414 break;
415 }
417 {
419 break;
420 }
422 {
424 break;
425 }
426 case IRP_MN_QUERY_ID:
427 {
429 break;
430 }
432 {
434 break;
435 }
436 default:
437 {
438 Irp->IoStatus.Information = 0;
440 }
441 }
442
443 Irp->IoStatus.Status = status;
445 return status;
446}
447
451 _In_ PIRP Irp)
452{
454 PPARTITION_EXTENSION partExt = DeviceObject->DeviceExtension;
455 PFDO_EXTENSION fdoExtension = partExt->LowerDevice->DeviceExtension;
457
458 ASSERT(!partExt->IsFDO);
459
460 if (!partExt->IsEnumerated)
461 {
462 Irp->IoStatus.Status = STATUS_DEVICE_DOES_NOT_EXIST;
465 }
466
467 switch (ioStack->Parameters.DeviceIoControl.IoControlCode)
468 {
469 // disk stuff
471 {
473 {
475 break;
476 }
477
478 PartMgrAcquireLayoutLock(fdoExtension);
479
480 // not supported on anything other than MBR
481 if (fdoExtension->DiskData.PartitionStyle != PARTITION_STYLE_MBR)
482 {
484 PartMgrReleaseLayoutLock(fdoExtension);
485 break;
486 }
487
488 PPARTITION_INFORMATION partInfo = Irp->AssociatedIrp.SystemBuffer;
489
490 *partInfo = (PARTITION_INFORMATION){
491 .PartitionType = partExt->Mbr.PartitionType,
492 .StartingOffset.QuadPart = partExt->StartingOffset,
493 .PartitionLength.QuadPart = partExt->PartitionLength,
494 .HiddenSectors = partExt->Mbr.HiddenSectors,
495 .PartitionNumber = partExt->DetectedNumber,
496 .BootIndicator = partExt->Mbr.BootIndicator,
497 .RecognizedPartition = partExt->Mbr.RecognizedPartition,
498 .RewritePartition = FALSE,
499 };
500
501 PartMgrReleaseLayoutLock(fdoExtension);
502
503 Irp->IoStatus.Information = sizeof(*partInfo);
505 break;
506 }
508 {
510 {
512 break;
513 }
514
515 PPARTITION_INFORMATION_EX partInfoEx = Irp->AssociatedIrp.SystemBuffer;
516
517 PartMgrAcquireLayoutLock(fdoExtension);
518
519 *partInfoEx = (PARTITION_INFORMATION_EX){
521 .PartitionLength.QuadPart = partExt->PartitionLength,
522 .PartitionNumber = partExt->DetectedNumber,
523 .PartitionStyle = fdoExtension->DiskData.PartitionStyle,
524 .RewritePartition = FALSE,
525 };
526
527 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
528 {
529 partInfoEx->Mbr = (PARTITION_INFORMATION_MBR){
530 .PartitionType = partExt->Mbr.PartitionType,
531 .HiddenSectors = partExt->Mbr.HiddenSectors,
532 .BootIndicator = partExt->Mbr.BootIndicator,
533 .RecognizedPartition = partExt->Mbr.RecognizedPartition,
534 };
535 }
536 else
537 {
538 partInfoEx->Gpt = (PARTITION_INFORMATION_GPT){
539 .PartitionType = partExt->Gpt.PartitionType,
540 .PartitionId = partExt->Gpt.PartitionId,
541 .Attributes = partExt->Gpt.Attributes,
542 };
543
544 RtlCopyMemory(partInfoEx->Gpt.Name,
545 partExt->Gpt.Name,
546 sizeof(partInfoEx->Gpt.Name));
547 }
548
549 PartMgrReleaseLayoutLock(fdoExtension);
550
551 Irp->IoStatus.Information = sizeof(*partInfoEx);
553 break;
554 }
556 {
557 PSET_PARTITION_INFORMATION inputBuffer = Irp->AssociatedIrp.SystemBuffer;
558 if (!VerifyIrpInBufferSize(Irp, sizeof(*inputBuffer)))
559 {
561 break;
562 }
563
564 PartMgrAcquireLayoutLock(fdoExtension);
565
566 // these functions use on disk numbers, not detected ones
568 fdoExtension->DiskData.BytesPerSector,
569 partExt->OnDiskNumber,
570 inputBuffer->PartitionType);
571
572 if (NT_SUCCESS(status))
573 {
574 partExt->Mbr.PartitionType = inputBuffer->PartitionType;
575 }
576
577 PartMgrReleaseLayoutLock(fdoExtension);
578
579 Irp->IoStatus.Information = 0;
580 break;
581 }
583 {
584 PSET_PARTITION_INFORMATION_EX inputBuffer = Irp->AssociatedIrp.SystemBuffer;
585 if (!VerifyIrpInBufferSize(Irp, sizeof(*inputBuffer)))
586 {
588 break;
589 }
590
591 PartMgrAcquireLayoutLock(fdoExtension);
592
593 // these functions use on disk numbers, not detected ones
595 partExt->OnDiskNumber,
596 inputBuffer);
597
598 if (NT_SUCCESS(status))
599 {
600 if (fdoExtension->DiskData.PartitionStyle == PARTITION_STYLE_MBR)
601 {
602 partExt->Mbr.PartitionType = inputBuffer->Mbr.PartitionType;
603 }
604 else
605 {
606 partExt->Gpt.PartitionType = inputBuffer->Gpt.PartitionType;
607 partExt->Gpt.PartitionId = inputBuffer->Gpt.PartitionId;
608 partExt->Gpt.Attributes = inputBuffer->Gpt.Attributes;
609
610 RtlMoveMemory(partExt->Gpt.Name,
611 inputBuffer->Gpt.Name,
612 sizeof(partExt->Gpt.Name));
613 }
614 }
615
616 PartMgrReleaseLayoutLock(fdoExtension);
617
618 Irp->IoStatus.Information = 0;
619 break;
620 }
622 {
623 PGET_LENGTH_INFORMATION lengthInfo = Irp->AssociatedIrp.SystemBuffer;
624 if (!VerifyIrpOutBufferSize(Irp, sizeof(*lengthInfo)))
625 {
627 break;
628 }
629
630 PartMgrAcquireLayoutLock(fdoExtension);
631
632 lengthInfo->Length.QuadPart = partExt->PartitionLength;
633
634 PartMgrReleaseLayoutLock(fdoExtension);
635
637 Irp->IoStatus.Information = sizeof(*lengthInfo);
638 break;
639 }
641 {
642 PVERIFY_INFORMATION verifyInfo = Irp->AssociatedIrp.SystemBuffer;
643 if (!VerifyIrpInBufferSize(Irp, sizeof(*verifyInfo)))
644 {
646 break;
647 }
648
649 // Partition device should just adjust the starting offset
650 verifyInfo->StartingOffset.QuadPart += partExt->StartingOffset;
652 }
654 {
655 fdoExtension->LayoutValid = FALSE;
657
659 break;
660 }
662 {
664 }
665 // volume stuff (most of that should be in volmgr.sys one it is implemented)
667 {
668 PVOLUME_DISK_EXTENTS volExts = Irp->AssociatedIrp.SystemBuffer;
669
670 // we fill only one extent entry so sizeof(*volExts) is enough
671 if (!VerifyIrpOutBufferSize(Irp, sizeof(*volExts)))
672 {
674 break;
675 }
676
677 PartMgrAcquireLayoutLock(fdoExtension);
678
679 // the only type of volume we support right now is disk partition
680 // so this structure is simple
681
682 *volExts = (VOLUME_DISK_EXTENTS) {
684 .Extents = {{
685 .DiskNumber = fdoExtension->DiskData.DeviceNumber,
686 .StartingOffset.QuadPart = partExt->StartingOffset,
687 .ExtentLength.QuadPart = partExt->PartitionLength
688 }}
689 };
690
691 PartMgrReleaseLayoutLock(fdoExtension);
692
694 Irp->IoStatus.Information = sizeof(*volExts);
695 break;
696 }
698 {
700 break;
701 }
703 {
704 PVOLUME_GET_GPT_ATTRIBUTES_INFORMATION gptAttrs = Irp->AssociatedIrp.SystemBuffer;
705 if (!VerifyIrpOutBufferSize(Irp, sizeof(*gptAttrs)))
706 {
708 break;
709 }
710
711 // not supported on anything other than GPT
712 if (fdoExtension->DiskData.PartitionStyle != PARTITION_STYLE_GPT)
713 {
715 break;
716 }
717
718 gptAttrs->GptAttributes = partExt->Gpt.Attributes;
719
721 Irp->IoStatus.Information = sizeof(*gptAttrs);
722 break;
723 }
724 // mountmgr stuff
726 {
727 PMOUNTDEV_NAME name = Irp->AssociatedIrp.SystemBuffer;
728
729 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT)))
730 {
732 break;
733 }
734
735 name->NameLength = partExt->DeviceName.Length;
736
737 // return NameLength back
738 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT) + name->NameLength))
739 {
740 Irp->IoStatus.Information = sizeof(USHORT);
742 break;
743 }
744
745 RtlCopyMemory(name->Name, partExt->DeviceName.Buffer, name->NameLength);
746
748 Irp->IoStatus.Information = sizeof(USHORT) + name->NameLength;
749 break;
750 }
752 {
753 PMOUNTDEV_UNIQUE_ID uniqueId = Irp->AssociatedIrp.SystemBuffer;
754
755 if (!partExt->VolumeInterfaceName.Buffer)
756 {
758 break;
759 }
760
761 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT)))
762 {
764 break;
765 }
766
767 uniqueId->UniqueIdLength = partExt->VolumeInterfaceName.Length;
768
769 // return UniqueIdLength back
770 if (!VerifyIrpOutBufferSize(Irp, sizeof(USHORT) + uniqueId->UniqueIdLength))
771 {
772 Irp->IoStatus.Information = sizeof(USHORT);
774 break;
775 }
776
777 RtlCopyMemory(uniqueId->UniqueId,
779 uniqueId->UniqueIdLength);
780
782 Irp->IoStatus.Information = sizeof(USHORT) + uniqueId->UniqueIdLength;
783 break;
784 }
785 default:
787 }
788
789 Irp->IoStatus.Status = status;
791 return status;
792}
#define PAGED_CODE()
unsigned char BOOLEAN
unsigned int UINT32
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS FASTCALL IoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, IN ULONG PartitionNumber, IN ULONG PartitionType)
Definition: ntoskrnl.c:46
#define ERR(fmt,...)
Definition: debug.h:110
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define IOCTL_DISK_VERIFY
Definition: cdrw_usr.h:170
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define swprintf
Definition: precomp.h:40
#define INFO
Definition: debug.h:89
#define ULONG_PTR
Definition: config.h:101
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
Definition: partition.c:175
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:449
static NTSTATUS PartitionHandleQueryId(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:286
static NTSTATUS PartitionHandleDeviceRelations(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:247
static const WCHAR PartitionSymLinkFormat[]
Definition: partition.c:10
static NTSTATUS PartitionHandleStartDevice(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:91
NTSTATUS PartitionHandlePnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:385
NTSTATUS PartitionCreateDevice(_In_ PDEVICE_OBJECT FDObject, _In_ PPARTITION_INFORMATION_EX PartitionEntry, _In_ UINT32 PdoNumber, _In_ PARTITION_STYLE PartitionStyle, _Out_ PDEVICE_OBJECT *PDO)
Definition: partition.c:15
static NTSTATUS PartitionHandleQueryCapabilities(_In_ PPARTITION_EXTENSION PartExt, _In_ PIRP Irp)
Definition: partition.c:364
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define PagedPool
Definition: env_spec_w32.h:308
#define IOCTL_DISK_GET_PARTITION_INFO_EX
Definition: ntddk_ex.h:206
NTSTATUS NTAPI IoSetPartitionInformationEx(IN PDEVICE_OBJECT DeviceObject, IN ULONG PartitionNumber, IN PSET_PARTITION_INFORMATION_EX PartitionInfo)
Definition: fstubex.c:2347
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
#define ASSERT(a)
Definition: mode.c:44
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
Definition: imports.h:93
struct _PARTITION_INFORMATION_EX PARTITION_INFORMATION_EX
#define IOCTL_DISK_GET_LENGTH_INFO
Definition: imports.h:192
enum _PARTITION_STYLE PARTITION_STYLE
#define IOCTL_MOUNTDEV_QUERY_UNIQUE_ID
Definition: imports.h:80
struct _PARTITION_INFORMATION_MBR PARTITION_INFORMATION_MBR
@ PARTITION_STYLE_GPT
Definition: imports.h:202
@ PARTITION_STYLE_MBR
Definition: imports.h:201
struct _PARTITION_INFORMATION_GPT PARTITION_INFORMATION_GPT
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IOCTL_DISK_SET_PARTITION_INFO
Definition: ntdddisk.h:214
#define IOCTL_DISK_SET_PARTITION_INFO_EX
Definition: ntdddisk.h:217
struct _PARTITION_INFORMATION PARTITION_INFORMATION
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
#define IOCTL_DISK_UPDATE_PROPERTIES
Definition: ntdddisk.h:242
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
#define IOCTL_VOLUME_GET_GPT_ATTRIBUTES
Definition: ntddvol.h:56
struct _VOLUME_DISK_EXTENTS VOLUME_DISK_EXTENTS
#define IOCTL_VOLUME_ONLINE
Definition: ntddvol.h:62
#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
Definition: ntddvol.h:41
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define L(x)
Definition: ntvdm.h:50
#define TAG_PARTMGR
Definition: partmgr.h:23
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:187
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:177
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:162
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:147
unsigned short USHORT
Definition: pedump.c:61
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1772
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define TRACE(s)
Definition: solgame.cpp:4
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
PDEVICE_OBJECT PhysicalDiskDO
Definition: partmgr.h:39
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:38
BOOLEAN LayoutValid
Definition: partmgr.h:42
struct _FDO_EXTENSION::@1314 DiskData
LARGE_INTEGER Length
Definition: imports.h:232
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
USHORT UniqueIdLength
Definition: imports.h:138
UCHAR UniqueId[1]
Definition: imports.h:139
struct _PARTITION_EXTENSION::@1319::@1322 Mbr
UNICODE_STRING VolumeInterfaceName
Definition: partmgr.h:99
UINT64 StartingOffset
Definition: partmgr.h:72
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:69
struct _PARTITION_EXTENSION::@1319::@1321 Gpt
UINT32 DetectedNumber
Definition: partmgr.h:76
UNICODE_STRING DeviceName
Definition: partmgr.h:100
UINT64 PartitionLength
Definition: partmgr.h:73
BOOLEAN IsEnumerated
Definition: partmgr.h:78
UINT32 OnDiskNumber
Definition: partmgr.h:77
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:68
LARGE_INTEGER StartingOffset
Definition: imports.h:221
PARTITION_INFORMATION_MBR Mbr
Definition: imports.h:226
PARTITION_INFORMATION_GPT Gpt
Definition: imports.h:227
LARGE_INTEGER StartingOffset
Definition: ntdddisk.h:656
ULONG NumberOfDiskExtents
Definition: ntddvol.h:119
Definition: name.c:39
Definition: ps.c:97
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define IRP_MN_CANCEL_STOP_DEVICE
@ BusRelations
Definition: iotypes.h:2152
@ TargetDeviceRelation
Definition: iotypes.h:2156
enum _BUS_QUERY_ID_TYPE BUS_QUERY_ID_TYPE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_QUERY_CAPABILITIES
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_REMOVE_DEVICE
#define ObReferenceObject
Definition: obfuncs.h:204
__wchar_t WCHAR
Definition: xmlstorage.h:180