@@ -2024,7 +2024,8 @@ type SocketAddress struct {
2024
2024
2025
2025
// IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
2026
2026
func (addr * SocketAddress ) IP () net.IP {
2027
- if uintptr (addr .SockaddrLength ) >= unsafe .Sizeof (RawSockaddrInet4 {}) && addr .Sockaddr .Addr .Family == AF_INET {
2027
+ if uintptr (addr .SockaddrLength ) >= unsafe .Sizeof (RawSockaddrInet4 {}) &&
2028
+ addr .Sockaddr .Addr .Family == AF_INET {
2028
2029
return (* RawSockaddrInet4 )(unsafe .Pointer (addr .Sockaddr )).Addr [:]
2029
2030
} else if uintptr (addr .SockaddrLength ) >= unsafe .Sizeof (RawSockaddrInet6 {}) && addr .Sockaddr .Addr .Family == AF_INET6 {
2030
2031
return (* RawSockaddrInet6 )(unsafe .Pointer (addr .Sockaddr )).Addr [:]
@@ -3380,3 +3381,219 @@ type BLOB struct {
3380
3381
Size uint32
3381
3382
BlobData * byte
3382
3383
}
3384
+
3385
+ // Constants and structs for DeviceIoControl
3386
+ const (
3387
+ FILE_ANY_ACCESS = 0
3388
+ FILE_SPECIAL_ACCESS = 0
3389
+ FILE_READ_ACCESS = FILE_READ_DATA
3390
+ FILE_WRITE_ACCESS = FILE_WRITE_DATA
3391
+ )
3392
+
3393
+ const (
3394
+ METHOD_BUFFERED = 0
3395
+ METHOD_IN_DIRECT = 1
3396
+ METHOD_OUT_DIRECT = 2
3397
+ METHOD_NEITHER = 3
3398
+ )
3399
+
3400
+ const (
3401
+ IOCTL_DISK_BASE = 0x00000007
3402
+ IOCTL_SCSI_BASE = 0x00000004
3403
+ IOCTL_STORAGE_BASE = 0x0000002D
3404
+ IOCTL_VOLUME_BASE = 0x00000056
3405
+ )
3406
+
3407
+ const (
3408
+ IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = (IOCTL_DISK_BASE << 16 ) | (FILE_ANY_ACCESS << 14 ) | (0x0028 << 2 ) | METHOD_BUFFERED
3409
+ IOCTL_SCSI_GET_ADDRESS = (IOCTL_SCSI_BASE << 16 ) | (FILE_ANY_ACCESS << 14 ) | (0x0406 << 2 ) | METHOD_BUFFERED
3410
+ IOCTL_STORAGE_CHECK_VERIFY = (IOCTL_STORAGE_BASE << 16 ) | (FILE_READ_ACCESS << 14 ) | (0x0200 << 2 ) | METHOD_BUFFERED
3411
+ IOCTL_STORAGE_CHECK_VERIFY2 = (IOCTL_STORAGE_BASE << 16 ) | (FILE_ANY_ACCESS << 14 ) | (0x0200 << 2 ) | METHOD_BUFFERED
3412
+ IOCTL_STORAGE_QUERY_PROPERTY = (IOCTL_STORAGE_BASE << 16 ) | (FILE_ANY_ACCESS << 14 ) | (0x0500 << 2 ) | METHOD_BUFFERED
3413
+ IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS = (IOCTL_VOLUME_BASE << 16 ) | (FILE_ANY_ACCESS << 14 ) | (0x0000 << 2 ) | METHOD_BUFFERED
3414
+ )
3415
+
3416
+ // MEDIA_TYPE enumeration
3417
+ type MEDIA_TYPE uint32
3418
+
3419
+ const (
3420
+ Unknown = iota // Format is unknown
3421
+ F5_1Pt2_512 // 5.25", 1.2MB, 512 bytes/sector
3422
+ F3_1Pt44_512 // 3.5", 1.44MB, 512 bytes/sector
3423
+ F3_2Pt88_512 // 3.5", 2.88MB, 512 bytes/sector
3424
+ F3_20Pt8_512 // 3.5", 20.8MB, 512 bytes/sector
3425
+ F3_720_512 // 3.5", 720KB, 512 bytes/sector
3426
+ F5_360_512 // 5.25", 360KB, 512 bytes/sector
3427
+ F5_320_512 // 5.25", 320KB, 512 bytes/sector
3428
+ F5_320_1024 // 5.25", 320KB, 1024 bytes/sector
3429
+ F5_180_512 // 5.25", 180KB, 512 bytes/sector
3430
+ F5_160_512 // 5.25", 160KB, 512 bytes/sector
3431
+ RemovableMedia // Removable media other than floppy
3432
+ FixedMedia // Fixed hard disk media
3433
+ F3_120M_512 // 3.5", 120M Floppy
3434
+ F3_640_512 // 3.5" , 640KB, 512 bytes/sector
3435
+ F5_640_512 // 5.25", 640KB, 512 bytes/sector
3436
+ F5_720_512 // 5.25", 720KB, 512 bytes/sector
3437
+ F3_1Pt2_512 // 3.5" , 1.2Mb, 512 bytes/sector
3438
+ F3_1Pt23_1024 // 3.5" , 1.23Mb, 1024 bytes/sector
3439
+ F5_1Pt23_1024 // 5.25", 1.23MB, 1024 bytes/sector
3440
+ F3_128Mb_512 // 3.5" MO 128Mb 512 bytes/sector
3441
+ F3_230Mb_512 // 3.5" MO 230Mb 512 bytes/sector
3442
+ F8_256_128 // 8", 256KB, 128 bytes/sector
3443
+ F3_200Mb_512 // 3.5", 200M Floppy (HiFD)
3444
+ F3_240M_512 // 3.5", 240Mb Floppy (HiFD)
3445
+ F3_32M_512 // 3.5", 32Mb Floppy
3446
+ )
3447
+
3448
+ // PARTITION_STYLE enumeration
3449
+ type PARTITION_STYLE uint32
3450
+
3451
+ const (
3452
+ PARTITION_STYLE_MBR = iota
3453
+ PARTITION_STYLE_GPT
3454
+ PARTITION_STYLE_RAW
3455
+ )
3456
+
3457
+ // STORAGE_BUS_TYPE enumeration
3458
+ type STORAGE_BUS_TYPE uint32
3459
+
3460
+ const (
3461
+ BusTypeUnknown = iota
3462
+ BusTypeScsi
3463
+ BusTypeAtapi
3464
+ BusTypeAta
3465
+ BusType1394
3466
+ BusTypeSsa
3467
+ BusTypeFibre
3468
+ BusTypeUsb
3469
+ BusTypeRAID
3470
+ BusTypeiScsi
3471
+ BusTypeSas
3472
+ BusTypeSata
3473
+ BusTypeSd
3474
+ BusTypeMmc
3475
+ BusTypeVirtual
3476
+ BusTypeFileBackedVirtual
3477
+ BusTypeMax
3478
+ BusTypeMaxReserved = 0x7F
3479
+ )
3480
+
3481
+ // STORAGE_PROPERTY_ID enumeration
3482
+ type STORAGE_PROPERTY_ID uint32
3483
+
3484
+ const (
3485
+ StorageDeviceProperty = iota
3486
+ StorageAdapterProperty
3487
+ StorageDeviceIdProperty
3488
+ StorageDeviceUniqueIdProperty
3489
+ StorageDeviceWriteCacheProperty
3490
+ StorageMiniportProperty
3491
+ StorageAccessAlignmentProperty
3492
+ StorageDeviceSeekPenaltyProperty
3493
+ StorageDeviceTrimProperty
3494
+ StorageDeviceWriteAggregationProperty
3495
+ StorageDeviceDeviceTelemetryProperty
3496
+ StorageDeviceLBProvisioningProperty
3497
+ StorageDevicePowerProperty
3498
+ StorageDeviceCopyOffloadProperty
3499
+ StorageDeviceResiliencyProperty
3500
+ StorageDeviceMediumProductType
3501
+ StorageAdapterRpmbProperty
3502
+ StorageAdapterCryptoProperty
3503
+ StorageDeviceTieringProperty
3504
+ StorageDeviceFaultDomainProperty
3505
+ StorageDeviceClusportProperty
3506
+ StorageDeviceDependantDevicesProperty
3507
+ StorageDeviceIoCapabilityProperty = 48
3508
+ StorageAdapterProtocolSpecificProperty
3509
+ StorageDeviceProtocolSpecificProperty
3510
+ StorageAdapterTemperatureProperty
3511
+ StorageDeviceTemperatureProperty
3512
+ StorageAdapterPhysicalTopologyProperty
3513
+ StorageDevicePhysicalTopologyProperty
3514
+ StorageDeviceAttributesProperty
3515
+ StorageDeviceManagementStatus
3516
+ StorageAdapterSerialNumberProperty
3517
+ StorageDeviceLocationProperty
3518
+ StorageDeviceNumaProperty
3519
+ StorageDeviceZonedDeviceProperty
3520
+ StorageDeviceUnsafeShutdownCount
3521
+ StorageDeviceEnduranceProperty
3522
+ )
3523
+
3524
+ // STORAGE_QUERY_TYPE enumeration
3525
+ type STORAGE_QUERY_TYPE uint32
3526
+
3527
+ const (
3528
+ PropertyStandardQuery = iota
3529
+ PropertyExistsQuery
3530
+ PropertyMaskQuery
3531
+ PropertyQueryMaxDefined
3532
+ )
3533
+
3534
+ type DISK_EXTENT struct {
3535
+ DiskNumber uint32
3536
+ StartingOffset uint64
3537
+ ExtentLength uint64
3538
+ }
3539
+
3540
+ type DISK_PARTITION_INFO_MBR struct {
3541
+ SizeOfPartitionInfo uint32
3542
+ PartitionStyle PARTITION_STYLE
3543
+ Signature uint32
3544
+ CheckSum uint32
3545
+ }
3546
+
3547
+ type DISK_PARTITION_INFO_GPT struct {
3548
+ SizeOfPartitionInfo uint32
3549
+ PartitionStyle PARTITION_STYLE
3550
+ DiskId [16 ]byte // UUID
3551
+ }
3552
+
3553
+ type DISK_GEOMETRY struct {
3554
+ Cylinders uint64
3555
+ MediaType MEDIA_TYPE
3556
+ TracksPerCylinder uint32
3557
+ SectorsPerTrack uint32
3558
+ BytesPerSector uint32
3559
+ }
3560
+
3561
+ type DISK_GEOMETRY_EX struct {
3562
+ Geometry DISK_GEOMETRY
3563
+ DiskSize uint64
3564
+ DiskPartitionMBR * DISK_PARTITION_INFO_MBR
3565
+ DiskPartitionGPT * DISK_PARTITION_INFO_GPT
3566
+ }
3567
+
3568
+ type DISK_GEOMETRY_EX_RAW struct {
3569
+ Geometry DISK_GEOMETRY
3570
+ DiskSize uint64
3571
+ }
3572
+
3573
+ type STORAGE_DEVICE_DESCRIPTOR struct {
3574
+ Version uint32
3575
+ Size uint32
3576
+ DeviceType byte
3577
+ DeviceTypeModifier byte
3578
+ RemovableMedia bool
3579
+ CommandQueueing bool
3580
+ VendorIdOffset uint32
3581
+ ProductIdOffset uint32
3582
+ ProductRevisionOffset uint32
3583
+ SerialNumberOffset uint32
3584
+ BusType STORAGE_BUS_TYPE
3585
+ RawPropertiesLength uint32
3586
+ RawDeviceProperties [1 ]byte
3587
+ }
3588
+
3589
+ type STORAGE_PROPERTY_QUERY struct {
3590
+ PropertyId STORAGE_PROPERTY_ID
3591
+ QueryType STORAGE_QUERY_TYPE
3592
+ AdditionalParameters [1 ]byte
3593
+ }
3594
+
3595
+ const (
3596
+ FSCTL_LOCK_VOLUME = (0x00000009 << 16 ) | (FILE_ANY_ACCESS << 14 ) | (6 << 2 ) | METHOD_BUFFERED
3597
+ FSCTL_UNLOCK_VOLUME = (0x00000009 << 16 ) | (FILE_ANY_ACCESS << 14 ) | (7 << 2 ) | METHOD_BUFFERED
3598
+ FSCTL_DISMOUNT_VOLUME = (0x00000009 << 16 ) | (FILE_ANY_ACCESS << 14 ) | (8 << 2 ) | METHOD_BUFFERED
3599
+ )
0 commit comments