ReactOS 0.4.15-dev-8222-g9164419
partmgr.h
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: Main header
5 * COPYRIGHT: 2020 Victor Perevertkin (victor.perevertkin@reactos.org)
6 */
7
8#ifndef _PARTMGR_H_
9#define _PARTMGR_H_
10
11#include <ntifs.h>
12#include <mountdev.h>
13#include <ntddvol.h>
14#include <ntdddisk.h>
15#include <ndk/psfuncs.h>
16#include <ndk/section_attribs.h>
17#include <ioevent.h>
18#include <stdio.h>
19#include <debug/driverdbg.h>
20
21#include "debug.h"
22
23#define TAG_PARTMGR 'MtrP'
24
25// from disk.sys
26typedef struct _DISK_GEOMETRY_EX_INTERNAL
27{
30 DISK_PARTITION_INFO Partition;
31 DISK_DETECTION_INFO Detection;
33
34// Unique ID data for basic (disk partition-based) volumes.
35// It is stored in the MOUNTDEV_UNIQUE_ID::UniqueId member
36// as an array of bytes.
37#include <pshpack1.h>
39{
40 struct
41 {
44 } Mbr;
45 struct
46 {
47 ULONGLONG Signature; // UCHAR[8] // "DMIO:ID:"
49 } Gpt;
51#include <poppack.h>
54
55#define DMIO_ID_SIGNATURE (*(ULONGLONG*)"DMIO:ID:")
56
57typedef struct _FDO_EXTENSION
58{
64
66 PDRIVE_LAYOUT_INFORMATION_EX LayoutCache;
67
71
72 struct {
77 union {
78 struct {
80 } Mbr;
81 struct {
83 } Gpt;
84 };
88
90{
95
99
100 UINT32 VolumeNumber; // Volume number in the "\Device\HarddiskVolumeN" device name
102 UINT32 OnDiskNumber; // partition number for issuing Io requests to the kernel
103 BOOLEAN IsEnumerated; // reported via IRP_MN_QUERY_DEVICE_RELATIONS
105 BOOLEAN Attached; // attached to PartitionList of the FDO
106 union
107 {
108 struct
109 {
115 struct
116 {
122 };
127
128CODE_SEG("PAGE")
131 _In_ PDEVICE_OBJECT FDObject,
132 _In_ PPARTITION_INFORMATION_EX PartitionEntry,
133 _In_ UINT32 OnDiskNumber,
134 _In_ PARTITION_STYLE PartitionStyle,
135 _Out_ PDEVICE_OBJECT *PDO);
136
137CODE_SEG("PAGE")
141 _In_ BOOLEAN FinalRemove);
142
143CODE_SEG("PAGE")
147 _In_ PIRP Irp);
148
152 _In_ PIRP Irp);
153
155NTAPI
158 _In_ PIRP Irp);
159
169
173 _In_ PIRP Irp,
175{
177 if (ioStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
178 {
179 Irp->IoStatus.Information = Size;
180 return FALSE;
181 }
182 return TRUE;
183}
184
188 _In_ PIRP Irp,
190{
192 if (ioStack->Parameters.DeviceIoControl.InputBufferLength < Size)
193 {
194 Irp->IoStatus.Information = Size;
195 return FALSE;
196 }
197 return TRUE;
198}
199
201VOID
203 _In_ PFDO_EXTENSION FDOExtension)
204{
205 PAGED_CODE();
206
207 KeWaitForSingleObject(&FDOExtension->SyncEvent, Executive, KernelMode, FALSE, NULL);
208}
209
211VOID
213 _In_ PFDO_EXTENSION FDOExtension)
214{
215 PAGED_CODE();
216
217 KeSetEvent(&FDOExtension->SyncEvent, IO_NO_INCREMENT, FALSE);
218}
219
220#endif // _PARTMGR_H_
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
#define CODE_SEG(...)
unsigned char BOOLEAN
unsigned long long UINT64
unsigned char UINT8
unsigned int UINT32
signed long long INT64
LONG NTSTATUS
Definition: precomp.h:26
_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 KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
#define C_ASSERT(e)
Definition: intsafe.h:73
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
enum _PARTITION_STYLE PARTITION_STYLE
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define KernelMode
Definition: asm.h:34
union _BASIC_VOLUME_UNIQUE_ID BASIC_VOLUME_UNIQUE_ID
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
Definition: partition.c:178
struct _DISK_GEOMETRY_EX_INTERNAL * PDISK_GEOMETRY_EX_INTERNAL
union _BASIC_VOLUME_UNIQUE_ID * PBASIC_VOLUME_UNIQUE_ID
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:452
struct _FDO_EXTENSION * PFDO_EXTENSION
struct _DISK_GEOMETRY_EX_INTERNAL DISK_GEOMETRY_EX_INTERNAL
struct _PARTITION_EXTENSION * PPARTITION_EXTENSION
FORCEINLINE VOID PartMgrReleaseLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:212
NTSTATUS PartitionHandlePnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:388
struct _PARTITION_EXTENSION PARTITION_EXTENSION
FORCEINLINE VOID PartMgrAcquireLayoutLock(_In_ PFDO_EXTENSION FDOExtension)
Definition: partmgr.h:202
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:187
NTSTATUS IssueSyncIoControlRequest(_In_ UINT32 IoControlCode, _In_ PDEVICE_OBJECT DeviceObject, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _In_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _In_ BOOLEAN InternalDeviceIoControl)
Definition: utils.c:19
struct _FDO_EXTENSION FDO_EXTENSION
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: partmgr.h:172
NTSTATUS PartitionCreateDevice(_In_ PDEVICE_OBJECT FDObject, _In_ PPARTITION_INFORMATION_EX PartitionEntry, _In_ UINT32 OnDiskNumber, _In_ PARTITION_STYLE PartitionStyle, _Out_ PDEVICE_OBJECT *PDO)
Definition: partition.c:15
DISK_PARTITION_INFO Partition
Definition: disk.c:3667
DISK_GEOMETRY Geometry
Definition: disk.c:3665
DISK_DETECTION_INFO Detection
Definition: disk.c:3668
PARTITION_STYLE PartitionStyle
Definition: partmgr.h:76
SINGLE_LIST_ENTRY PartitionList
Definition: partmgr.h:68
GUID DiskId
Definition: partmgr.h:82
UINT32 Signature
Definition: partmgr.h:79
KEVENT SyncEvent
Definition: partmgr.h:63
PDRIVE_LAYOUT_INFORMATION_EX LayoutCache
Definition: partmgr.h:66
struct _FDO_EXTENSION::@1323::@1324::@1327 Gpt
PDEVICE_OBJECT PhysicalDiskDO
Definition: partmgr.h:62
UINT32 BytesPerSector
Definition: partmgr.h:75
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:60
struct _FDO_EXTENSION::@1323::@1324::@1326 Mbr
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:61
UINT32 DeviceNumber
Definition: partmgr.h:74
BOOLEAN LayoutValid
Definition: partmgr.h:65
BOOLEAN IsSuperFloppy
Definition: partmgr.h:70
UNICODE_STRING DiskInterfaceName
Definition: partmgr.h:86
UINT64 DiskSize
Definition: partmgr.h:73
BOOLEAN IsFDO
Definition: partmgr.h:59
UINT32 EnumeratedPartitionsTotal
Definition: partmgr.h:69
struct _FDO_EXTENSION::@1323 DiskData
union _IO_STACK_LOCATION::@1573 Parameters
struct _IO_STACK_LOCATION::@1573::@1574 DeviceIoControl
UNICODE_STRING VolumeInterfaceName
Definition: partmgr.h:124
UINT64 StartingOffset
Definition: partmgr.h:96
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:93
BOOLEAN RecognizedPartition
Definition: partmgr.h:119
PDEVICE_OBJECT Part0Device
Definition: partmgr.h:94
UINT32 HiddenSectors
Definition: partmgr.h:120
SINGLE_LIST_ENTRY ListEntry
Definition: partmgr.h:98
UINT32 DetectedNumber
Definition: partmgr.h:101
UNICODE_STRING DeviceName
Definition: partmgr.h:125
UINT64 PartitionLength
Definition: partmgr.h:97
BOOLEAN IsEnumerated
Definition: partmgr.h:103
UNICODE_STRING PartitionInterfaceName
Definition: partmgr.h:123
struct _PARTITION_EXTENSION::@1328::@1331 Mbr
struct _PARTITION_EXTENSION::@1328::@1330 Gpt
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:92
BOOLEAN BootIndicator
Definition: partmgr.h:118
BOOLEAN SymlinkCreated
Definition: partmgr.h:104
Definition: ntbasedef.h:628
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
struct _BASIC_VOLUME_UNIQUE_ID::@1322 Gpt
ULONGLONG Signature
Definition: partmgr.h:47
struct _BASIC_VOLUME_UNIQUE_ID::@1321 Mbr
ULONGLONG StartingOffset
Definition: partmgr.h:43
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
#define FORCEINLINE
Definition: wdftypes.h:67
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID _In_ ULONG _In_ BOOLEAN InternalDeviceIoControl
Definition: iofuncs.h:720
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ Executive
Definition: ketypes.h:415
__wchar_t WCHAR
Definition: xmlstorage.h:180