1
0

Added headers from spti sample project

This commit is contained in:
Benjamin Höglinger-Stelzer 2023-06-25 15:56:59 +02:00
parent 17b6bc711a
commit cfd04750d3
4 changed files with 289 additions and 204 deletions

View File

@ -0,0 +1,190 @@
#pragma once
/************************************************************************************
* From spti sample sources
*/
#define SPT_CDB_LENGTH 32
#define SPT_SENSE_LENGTH 32
#define SPTWB_DATA_LENGTH 512
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS {
SCSI_PASS_THROUGH spt;
ULONG Filler; // realign buffers to double word boundary
UCHAR ucSenseBuf[SPT_SENSE_LENGTH];
UCHAR ucDataBuf[SPTWB_DATA_LENGTH];
} SCSI_PASS_THROUGH_WITH_BUFFERS, *PSCSI_PASS_THROUGH_WITH_BUFFERS;
typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER {
SCSI_PASS_THROUGH_DIRECT sptd;
ULONG Filler; // realign buffer to double word boundary
UCHAR ucSenseBuf[SPT_SENSE_LENGTH];
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER;
typedef struct _SCSI_PASS_THROUGH_WITH_BUFFERS_EX {
SCSI_PASS_THROUGH_EX spt;
UCHAR ucCdbBuf[SPT_CDB_LENGTH-1]; // cushion for spt.Cdb
ULONG Filler; // realign buffers to double word boundary
STOR_ADDR_BTL8 StorAddress;
UCHAR ucSenseBuf[SPT_SENSE_LENGTH];
UCHAR ucDataBuf[SPTWB_DATA_LENGTH]; // buffer for DataIn or DataOut
} SCSI_PASS_THROUGH_WITH_BUFFERS_EX, *PSCSI_PASS_THROUGH_WITH_BUFFERS_EX;
typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER_EX {
SCSI_PASS_THROUGH_DIRECT_EX sptd;
UCHAR ucCdbBuf[SPT_CDB_LENGTH-1]; // cushion for sptd.Cdb
ULONG Filler; // realign buffer to double word boundary
STOR_ADDR_BTL8 StorAddress;
UCHAR ucSenseBuf[SPT_SENSE_LENGTH];
} SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER_EX, *PSCSI_PASS_THROUGH_DIRECT_WITH_BUFFER_EX;
/************************************************************************************
* From cciss sources
*/
#include <pshpack1.h>
using id_ctlr = struct
{
unsigned char num_logical_drives;
uint32_t signature;
uint32_t running_firm_rev;
unsigned char rom_firm_rev[4];
unsigned char hardware_rev;
unsigned char reserved[4];
uint32_t drive_present_bit_map;
uint32_t external_drive_bit_map;
uint32_t board_id;
unsigned char reserved2;
uint32_t non_disk_map;
unsigned char reserved3[5];
unsigned char marketing_revision;
unsigned char controller_flags;
// unsigned char reserved4[2];
unsigned char host_flags;
unsigned char expand_disable_code;
unsigned char scsi_chip_count;
uint32_t reserved5;
uint32_t ctlr_clock;
unsigned char drives_per_scsi_bus;
uint16_t big_drive_present_map[8];
uint16_t big_ext_drive_map[8];
uint16_t big_non_disk_map[8];
/* Beyond this point is previously undisclosed stuff which
my higher-ups at HP have nonetheless allowed me to put in here.
Was told most of this stuff is exposed to some degree by
the Array Diagnostics Utility already anyhow, so no big deal.
*/
unsigned short task_flags; /* used for FW debugging */
unsigned char ICL_bus_map; /* Bitmap used for ICL between controllers */
unsigned char redund_ctlr_modes_support; /* See REDUNDANT MODE VALUES */
#define SUPPORT_ACTIVE_STANDBY 0x01
#define SUPPORT_PRIMARY_SECONDARY 0x02
unsigned char curr_redund_ctlr_mode; /* See REDUNDANT MODE VALUES */
#define ACTIVE_STANDBY_MODE 0x01
#define PRIMARY_SECONDARY_MODE 0x02
unsigned char redund_ctlr_status; /* See REDUNDANT STATUS FLAG */
#define PREFERRED_REDUNDANT_CTLR (0x04)
unsigned char redund_op_failure_code; /* See REDUNDANT FAILURE VALUES */
unsigned char unsupported_nile_bus;
unsigned char host_i2c_autorev;
unsigned char cpld_revision;
unsigned char fibre_chip_count;
unsigned char daughterboard_type;
unsigned char reserved6[2];
unsigned char access_module_status;
unsigned char features_supported[12];
unsigned char bRecRomInactiveRev[4]; /* Recovery ROM inactive f/w revision */
unsigned char bRecRomFlags; /* Recovery ROM flags */
unsigned char bPciToPciBridgeStatus; /* PCI to PCI bridge status */
unsigned int ulReserved; /* Reserved for future use */
unsigned char bPercentWriteCache; /* Percent of memory allocated to write cache */
unsigned short usDaughterboardCacheSize; /* Total cache board size */
unsigned char bCacheBatteryCount; /* Number of cache batteries */
unsigned short usTotalMemorySize; /* Total size (MB) of atttached memory */
unsigned char bMoreControllerFlags; /* Additional controller flags byte */
unsigned char bXboardHostI2cAutorev; /* 2nd byte of 3 byte autorev field */
unsigned char bBatteryPicRev; /* BBWC PIC revision */
unsigned char bDdffVersion[4]; /* DDFF update engine version */
unsigned short usMaxLogicalUnits; /* Maximum logical units supported */
unsigned short usExtLogicalUnitCount; /* Big num configured logical units */
unsigned short usMaxPhysicalDevices; /* Maximum physical devices supported */
unsigned short usMaxPhyDrvPerLogicalUnit; /* Max physical drive per logical unit */
unsigned char bEnclosureCount; /* Number of attached enclosures */
unsigned char bExpanderCount; /* Number of expanders detected */
unsigned short usOffsetToEDPbitmap; /* Offset to extended drive present map*/
unsigned short usOffsetToEEDPbitmap; /* Offset to extended external drive present map */
unsigned short usOffsetToENDbitmap; /* Offset to extended non-disk map */
unsigned char bInternalPortStatus[8]; /* Internal port status bytes */
unsigned char bExternalPortStatus[8]; /* External port status bytes */
unsigned int uiYetMoreControllerFlags; /* Yet More Controller flags */
unsigned char bLastLockup; /* Last lockup code */
unsigned char bSlot; /* PCI slot according to option ROM*/
unsigned short usBuildNum; /* Build number */
unsigned int uiMaxSafeFullStripeSize; /* Maximum safe full stripe size */
unsigned int uiTotalLength; /* Total structure length */
unsigned char bVendorID[8]; /* Vendor ID */
unsigned char bProductID[16]; /* Product ID */
unsigned char reserved7[288];
/* End of previously unexposed stuff */
};
using alarm_struct = struct alarm_struct_t
{
uint8_t alarm_status;
uint8_t temp_status;
uint8_t valid_alarm_bits;
uint16_t alarm_count;
uint16_t specific_alarm_counts[8];
};
using inquiry_data = struct inquiry_data_t
{
uint8_t peripheral_type;
uint8_t rmb;
uint8_t versions;
uint8_t misc;
uint8_t additional_length;
uint8_t reserved[2];
uint8_t support_bits;
uint8_t vendor_id[8];
uint8_t product_id[16];
uint8_t product_revision[4];
};
using sense_bus_param = struct sense_bus_param_t
{
inquiry_data inquiry;
uint8_t inquiry_valid;
uint32_t installed_drive_map;
uint16_t hot_plug_count[32];
uint8_t reserved1; /* physical box number? */
uint8_t reserved2;
alarm_struct alarm_data;
uint16_t connection_info; /* 0x01: External Connector is Used? */
uint8_t scsi_device_revision;
uint8_t fan_status;
uint8_t more_inquiry_data[64];
uint32_t scsi_device_type;
uint32_t bus_bit_map;
uint8_t reserved3[8];
uint8_t scsi_initiator_id;
uint8_t scsi_target_id;
uint8_t physical_port[2];
uint16_t big_installed_drive_map[8];
uint16_t big_bus_bit_map[8];
uint16_t big_box_bit_map[8];
uint8_t installed_box_map;
uint8_t more_connection_info;
uint8_t reserved4[2];
char chassis_sn[40];
};
#include <poppack.h>

View File

@ -1,152 +1,109 @@
//
// WinAPI
//
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <algorithm>
#include <iomanip>
#include <Windows.h> #include <Windows.h>
#include <winioctl.h> #include <winioctl.h>
#include <ntddscsi.h> #include <ntddscsi.h>
#include <devioctl.h>
#include <ntdddisk.h>
#include <ntddscsi.h>
#define _NTSCSI_USER_MODE_
#include <scsi.h>
#include <stdint.h>
#include "ScsiStuff.h"
//
// STL
//
#include <algorithm>
#include <iomanip>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <pshpack1.h>
typedef struct {
unsigned char num_logical_drives;
uint32_t signature;
uint32_t running_firm_rev;
unsigned char rom_firm_rev[4];
unsigned char hardware_rev;
unsigned char reserved[4];
uint32_t drive_present_bit_map;
uint32_t external_drive_bit_map;
uint32_t board_id;
unsigned char reserved2;
uint32_t non_disk_map;
unsigned char reserved3[5];
unsigned char marketing_revision;
unsigned char controller_flags;
// unsigned char reserved4[2];
unsigned char host_flags;
unsigned char expand_disable_code;
unsigned char scsi_chip_count;
uint32_t reserved5;
uint32_t ctlr_clock;
unsigned char drives_per_scsi_bus;
uint16_t big_drive_present_map[8];
uint16_t big_ext_drive_map[8];
uint16_t big_non_disk_map[8];
/* Beyond this point is previously undisclosed stuff which //
my higher-ups at HP have nonetheless allowed me to put in here. // Sends a sample request, sniffed from the official HP Array Configuration Utility
Was told most of this stuff is exposed to some degree by //
the Array Diagnostics Utility already anyhow, so no big deal. void MiniportExample(HANDLE handle)
*/ {
// this identifies a HP P410 under Windows HP storage driver
auto signature = "CPQCISS";
unsigned short task_flags; /* used for FW debugging */ // this request should return some info like HP, P410, Mar 26 2015 15:51:27, 6.63 etc.
unsigned char ICL_bus_map; /* Bitmap used for ICL between controllers */ UCHAR payload[] = {
unsigned char redund_ctlr_modes_support; /* See REDUNDANT MODE VALUES */ 0x1C, 0x00, 0x00, 0x00, 0x43, 0x50, 0x51, 0x43, 0x49, 0x53, 0x53, 0x00, 0xB4, 0x00, 0x00, 0x00, 0x02, 0x00,
#define SUPPORT_ACTIVE_STANDBY 0x01 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#define SUPPORT_PRIMARY_SECONDARY 0x02 0xB4, 0x00, 0x0A, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char curr_redund_ctlr_mode; /* See REDUNDANT MODE VALUES */ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#define ACTIVE_STANDBY_MODE 0x01 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#define PRIMARY_SECONDARY_MODE 0x02 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char redund_ctlr_status; /* See REDUNDANT STATUS FLAG */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
#define PREFERRED_REDUNDANT_CTLR (0x04) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char redund_op_failure_code; /* See REDUNDANT FAILURE VALUES */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char unsupported_nile_bus; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char host_i2c_autorev; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char cpld_revision; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char fibre_chip_count; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char daughterboard_type; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
unsigned char reserved6[2]; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
unsigned char access_module_status; DWORD bytesReturned = 0;
unsigned char features_supported[12]; BOOL ret = DeviceIoControl(
unsigned char bRecRomInactiveRev[4]; /* Recovery ROM inactive f/w revision */ handle,
unsigned char bRecRomFlags; /* Recovery ROM flags */ IOCTL_SCSI_MINIPORT,
unsigned char bPciToPciBridgeStatus; /* PCI to PCI bridge status */ payload,
unsigned int ulReserved; /* Reserved for future use */ ARRAYSIZE(payload),
unsigned char bPercentWriteCache; /* Percent of memory allocated to write cache */ payload,
unsigned short usDaughterboardCacheSize;/* Total cache board size */ ARRAYSIZE(payload),
unsigned char bCacheBatteryCount; /* Number of cache batteries */ &bytesReturned,
unsigned short usTotalMemorySize; /* Total size (MB) of atttached memory */ nullptr
unsigned char bMoreControllerFlags; /* Additional controller flags byte */ );
unsigned char bXboardHostI2cAutorev; /* 2nd byte of 3 byte autorev field */
unsigned char bBatteryPicRev; /* BBWC PIC revision */
unsigned char bDdffVersion[4]; /* DDFF update engine version */
unsigned short usMaxLogicalUnits; /* Maximum logical units supported */
unsigned short usExtLogicalUnitCount; /* Big num configured logical units */
unsigned short usMaxPhysicalDevices; /* Maximum physical devices supported */
unsigned short usMaxPhyDrvPerLogicalUnit; /* Max physical drive per logical unit */
unsigned char bEnclosureCount; /* Number of attached enclosures */
unsigned char bExpanderCount; /* Number of expanders detected */
unsigned short usOffsetToEDPbitmap; /* Offset to extended drive present map*/
unsigned short usOffsetToEEDPbitmap; /* Offset to extended external drive present map */
unsigned short usOffsetToENDbitmap; /* Offset to extended non-disk map */
unsigned char bInternalPortStatus[8]; /* Internal port status bytes */
unsigned char bExternalPortStatus[8]; /* External port status bytes */
unsigned int uiYetMoreControllerFlags; /* Yet More Controller flags */
unsigned char bLastLockup; /* Last lockup code */
unsigned char bSlot; /* PCI slot according to option ROM*/
unsigned short usBuildNum; /* Build number */
unsigned int uiMaxSafeFullStripeSize; /* Maximum safe full stripe size */
unsigned int uiTotalLength; /* Total structure length */
unsigned char bVendorID[8]; /* Vendor ID */
unsigned char bProductID[16]; /* Product ID */
unsigned char reserved7[288];
/* End of previously unexposed stuff */ if (ret)
{
std::wcout << L"Request succeeded" << std::endl;
} id_ctlr; const std::vector<char> buffer((PUCHAR)payload, (PUCHAR)payload + ARRAYSIZE(payload));
typedef struct alarm_struct_t { std::wostringstream ss;
uint8_t alarm_status;
uint8_t temp_status;
uint8_t valid_alarm_bits;
uint16_t alarm_count;
uint16_t specific_alarm_counts[8];
} alarm_struct;
typedef struct inquiry_data_t { ss << std::hex << std::uppercase << std::setfill(L'0');
uint8_t peripheral_type; std::for_each(buffer.cbegin(), buffer.cend(), [&](int c) { ss << std::setw(2) << c << L" "; });
uint8_t rmb;
uint8_t versions;
uint8_t misc;
uint8_t additional_length;
uint8_t reserved[2];
uint8_t support_bits;
uint8_t vendor_id[8];
uint8_t product_id[16];
uint8_t product_revision[4];
} inquiry_data;
typedef struct sense_bus_param_t { const std::wstring hexString = ss.str();
inquiry_data inquiry;
uint8_t inquiry_valid; std::wcout << L"Result buffer: " << hexString << std::endl;
uint32_t installed_drive_map; }
uint16_t hot_plug_count[32]; else
uint8_t reserved1; /* physical box number? */ {
uint8_t reserved2; std::wcerr << L"Failed to send request, error: 0x" << std::hex << GetLastError() << std::endl;
alarm_struct alarm_data; }
uint16_t connection_info; /* 0x01: External Connector is Used? */ }
uint8_t scsi_device_revision;
uint8_t fan_status;
uint8_t more_inquiry_data[64];
uint32_t scsi_device_type;
uint32_t bus_bit_map;
uint8_t reserved3[8];
uint8_t scsi_initiator_id;
uint8_t scsi_target_id;
uint8_t physical_port[2];
uint16_t big_installed_drive_map[8];
uint16_t big_bus_bit_map[8];
uint16_t big_box_bit_map[8];
uint8_t installed_box_map;
uint8_t more_connection_info;
uint8_t reserved4[2];
char chassis_sn[40];
} sense_bus_param;
#include <poppack.h>
int wmain(int argc, wchar_t* argv[]) int wmain(int argc, wchar_t* argv[])
{ {
@ -178,77 +135,7 @@ int wmain(int argc, wchar_t* argv[])
std::wcout << L"Successfully opened device " << deviceName << std::endl; std::wcout << L"Successfully opened device " << deviceName << std::endl;
MiniportExample(handle);
SCSI_PASS_THROUGH_DIRECT scsiPassThrough = { 0 };
scsiPassThrough.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
scsiPassThrough.PathId = 0;
scsiPassThrough.TargetId = 2; // Target ID of the RAID controller
scsiPassThrough.Lun = 0;
scsiPassThrough.DataIn = SCSI_IOCTL_DATA_IN;
//scsiPassThrough.DataTransferLength = bufferSize; // Size of the status buffer
scsiPassThrough.TimeOutValue = 2; // Timeout in seconds
//scsiPassThrough.DataBuffer = statusBuffer; // Buffer to store the status information
scsiPassThrough.CdbLength = 10; // SCSI command length
auto signature = "CPQCISS";
/*
const UCHAR payload[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x5B, 0x94, 0x04, 0x00, 0x00, 0x00, 0x00, 0x90, 0x4A,
0x4F, 0x0D, 0x00, 0x01, 0x00, 0x00, 0xA0, 0x62, 0x4F, 0x0D, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xA9, 0xDA, 0x03,
0x00, 0x00, 0x00, 0x00, 0xB0, 0xA9, 0xDA, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x84, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x4A, 0x4F, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x50, 0x8A, 0xC4, 0x03
};
*/
UCHAR payload[632];
ZeroMemory(payload, ARRAYSIZE(payload));
const size_t requestSize = sizeof(SRB_IO_CONTROL) + ARRAYSIZE(payload);
const PSRB_IO_CONTROL request = (PSRB_IO_CONTROL)malloc(requestSize);
ZeroMemory(request, sizeof(SRB_IO_CONTROL));
request->HeaderLength = sizeof(SRB_IO_CONTROL);
CopyMemory(request->Signature, signature, sizeof(request->Signature));
request->ControlCode = 2;
request->Timeout = 180;
request->Length = ARRAYSIZE(payload);
DWORD bytesReturned = 0;
BOOL ret = DeviceIoControl(
handle,
IOCTL_SCSI_MINIPORT,
request,
requestSize,
request,
requestSize,
&bytesReturned,
NULL
);
if (ret)
{
std::wcout << L"Request succeeded" << std::endl;
const std::vector<char> buffer((PUCHAR)request, (PUCHAR)request + requestSize);
std::wostringstream ss;
ss << std::hex << std::uppercase << std::setfill(L'0');
std::for_each(buffer.cbegin(), buffer.cend(), [&](int c) { ss << std::setw(2) << c << L" "; });
const std::wstring hexString = ss.str();
std::wcout << L"Result buffer: " << hexString << std::endl;
}
free(request);
CloseHandle(handle); CloseHandle(handle);
} }

View File

@ -133,6 +133,9 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="SmartArrayControllerTool.cpp" /> <ClCompile Include="SmartArrayControllerTool.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="ScsiStuff.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -19,4 +19,9 @@
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ClInclude Include="ScsiStuff.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project> </Project>