I don't have time to do a full sample, but the basic idea is to do the following. I have not
actually run any of this, but this is the basic idea...
{define-C-struct package PartitionInformation
field package starting-offset:int64
field package partition-length:int64
field package hidden-sectors:int
field package partition-number:int
field package partition-type:int8
field package boot-indicator:int8
field package recognized-partition:int8
field package rewrite-partition:int8
}
{define-dll-class package PartitionCalls
{defaults
calling-convention = stdcall,
string-rep = CStringUTF16
}
{constructor public {default}
{construct-super {SharedLibrary "kernel32"}}
{dll-method public {create-file ("CreateFileW")
filename:String, \\ desired-access:int, \\ share-mode:int, \\ security-attributes:CPointer, \\ creation-disposition:int, \\ flags:int, \\ template-file:int = 0 \\ }:int
}
{dll-method public {device-io-control ("DeviceIoControl")
device:int, \\ control-code:int, \\ in-buffer:CPointer \\ in-buffer-size:int \\ out-buffer:{Pointer-to PartitionInformation}, \\ out-buffer-size:int, \\ bytes-returns:{Pointer-to int}, \\ overlapped:CPointer
}:int
}
{let calls:PartitionCalls = {PartitionCalls}}
{for key k in {{url "file://"}.instantiate-Directory} do
let h:int = {calls.create-file k,...rest of the arguments...}
let dev-info:{Pointer-to DeviceInformation} = {new {Pointer-to DeviceInformation}}
let bytes-returned:{Pointer-to int} = {new {Pointer-to int}}
{calls.device-io-control h, <code>0x74004</code>|# IOCTL_DISK_GET_PARTITION_INFO #|, 0, 0, dev-info, 5 * 4, bytes-returned, 0}
}