ReactOS 0.4.15-dev-7842-g558ab78
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
34typedef struct _FDO_EXTENSION
35{
41
43 PDRIVE_LAYOUT_INFORMATION_EX LayoutCache;
44
48
49 struct {
54 union {
55 struct {
57 } Mbr;
58 struct {
60 } Gpt;
61 };
64
66{
71
75
77 UINT32 OnDiskNumber; // partition number for issuing Io requests to the kernel
78 BOOLEAN IsEnumerated; // reported via IRP_MN_QUERY_DEVICE_RELATIONS
80 BOOLEAN Attached; // attached to PartitionList of the FDO
81 union
82 {
83 struct
84 {
89 } Gpt;
90 struct
91 {
96 } Mbr;
97 };
102
103CODE_SEG("PAGE")
106 _In_ PDEVICE_OBJECT FDObject,
107 _In_ PPARTITION_INFORMATION_EX PartitionEntry,
108 _In_ UINT32 OnDiskNumber,
109 _In_ PARTITION_STYLE PartitionStyle,
110 _Out_ PDEVICE_OBJECT *PDO);
111
112CODE_SEG("PAGE")
116 _In_ BOOLEAN FinalRemove);
117
118CODE_SEG("PAGE")
122 _In_ PIRP Irp);
123
127 _In_ PIRP Irp);
128
130NTAPI
133 _In_ PIRP Irp);
134
144
148 _In_ PIRP Irp,
150{
152 if (ioStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
153 {
154 Irp->IoStatus.Information = Size;
155 return FALSE;
156 }
157 return TRUE;
158}
159
163 _In_ PIRP Irp,
165{
167 if (ioStack->Parameters.DeviceIoControl.InputBufferLength < Size)
168 {
169 Irp->IoStatus.Information = Size;
170 return FALSE;
171 }
172 return TRUE;
173}
174
176VOID
178 _In_ PFDO_EXTENSION FDOExtension)
179{
180 PAGED_CODE();
181
182 KeWaitForSingleObject(&FDOExtension->SyncEvent, Executive, KernelMode, FALSE, NULL);
183}
184
186VOID
188 _In_ PFDO_EXTENSION FDOExtension)
189{
190 PAGED_CODE();
191
192 KeSetEvent(&FDOExtension->SyncEvent, IO_NO_INCREMENT, FALSE);
193}
194
195#endif // _PARTMGR_H_
#define PAGED_CODE()
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
static CODE_SEG("PAGE")
Definition: isapnp.c:1482
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
NTSTATUS PartitionHandleRemove(_In_ PPARTITION_EXTENSION PartExt, _In_ BOOLEAN FinalRemove)
Definition: partition.c:175
struct _DISK_GEOMETRY_EX_INTERNAL * PDISK_GEOMETRY_EX_INTERNAL
NTSTATUS PartitionHandleDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:449
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:187
NTSTATUS PartitionHandlePnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: partition.c:385
struct _PARTITION_EXTENSION PARTITION_EXTENSION
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
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:147
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:53
SINGLE_LIST_ENTRY PartitionList
Definition: partmgr.h:45
GUID DiskId
Definition: partmgr.h:59
UINT32 Signature
Definition: partmgr.h:56
KEVENT SyncEvent
Definition: partmgr.h:40
PDRIVE_LAYOUT_INFORMATION_EX LayoutCache
Definition: partmgr.h:43
struct _FDO_EXTENSION::@1313::@1314::@1317 Gpt
PDEVICE_OBJECT PhysicalDiskDO
Definition: partmgr.h:39
UINT32 BytesPerSector
Definition: partmgr.h:52
struct _FDO_EXTENSION::@1313 DiskData
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:37
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:38
UINT32 DeviceNumber
Definition: partmgr.h:51
BOOLEAN LayoutValid
Definition: partmgr.h:42
UNICODE_STRING DiskInterfaceName
Definition: partmgr.h:47
UINT64 DiskSize
Definition: partmgr.h:50
BOOLEAN IsFDO
Definition: partmgr.h:36
UINT32 EnumeratedPartitionsTotal
Definition: partmgr.h:46
struct _FDO_EXTENSION::@1313::@1314::@1316 Mbr
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
UNICODE_STRING VolumeInterfaceName
Definition: partmgr.h:99
UINT64 StartingOffset
Definition: partmgr.h:72
struct _PARTITION_EXTENSION::@1318::@1320 Gpt
PDEVICE_OBJECT LowerDevice
Definition: partmgr.h:69
BOOLEAN RecognizedPartition
Definition: partmgr.h:94
PDEVICE_OBJECT Part0Device
Definition: partmgr.h:70
UINT32 HiddenSectors
Definition: partmgr.h:95
SINGLE_LIST_ENTRY ListEntry
Definition: partmgr.h:74
UINT32 DetectedNumber
Definition: partmgr.h:76
BOOLEAN Attached
Definition: partmgr.h:80
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
UNICODE_STRING PartitionInterfaceName
Definition: partmgr.h:98
PDEVICE_OBJECT DeviceObject
Definition: partmgr.h:68
BOOLEAN BootIndicator
Definition: partmgr.h:93
struct _PARTITION_EXTENSION::@1318::@1321 Mbr
BOOLEAN SymlinkCreated
Definition: partmgr.h:79
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
_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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
_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