From cfd04750d36576ade74fdc8b687bf213a6fcc9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sun, 25 Jun 2023 15:56:59 +0200 Subject: [PATCH] Added headers from spti sample project --- SmartArrayControllerTool/ScsiStuff.h | 190 +++++++++++ .../SmartArrayControllerTool.cpp | 295 ++++++------------ .../SmartArrayControllerTool.vcxproj | 3 + .../SmartArrayControllerTool.vcxproj.filters | 5 + 4 files changed, 289 insertions(+), 204 deletions(-) create mode 100644 SmartArrayControllerTool/ScsiStuff.h diff --git a/SmartArrayControllerTool/ScsiStuff.h b/SmartArrayControllerTool/ScsiStuff.h new file mode 100644 index 0000000..8cc0079 --- /dev/null +++ b/SmartArrayControllerTool/ScsiStuff.h @@ -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 + +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 + diff --git a/SmartArrayControllerTool/SmartArrayControllerTool.cpp b/SmartArrayControllerTool/SmartArrayControllerTool.cpp index 15bfb9c..b7b7ad9 100644 --- a/SmartArrayControllerTool/SmartArrayControllerTool.cpp +++ b/SmartArrayControllerTool/SmartArrayControllerTool.cpp @@ -1,152 +1,109 @@ +// +// WinAPI +// #define WIN32_LEAN_AND_MEAN -#include -#include #include #include #include +#include +#include +#include +#define _NTSCSI_USER_MODE_ +#include +#include +#include "ScsiStuff.h" +// +// STL +// +#include +#include #include #include #include -#include -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. - Was told most of this stuff is exposed to some degree by - the Array Diagnostics Utility already anyhow, so no big deal. - */ +// +// Sends a sample request, sniffed from the official HP Array Configuration Utility +// +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 */ - 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]; + // this request should return some info like HP, P410, Mar 26 2015 15:51:27, 6.63 etc. + UCHAR payload[] = { + 0x1C, 0x00, 0x00, 0x00, 0x43, 0x50, 0x51, 0x43, 0x49, 0x53, 0x53, 0x00, 0xB4, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xB4, 0x00, 0x0A, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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; - 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]; + DWORD bytesReturned = 0; + BOOL ret = DeviceIoControl( + handle, + IOCTL_SCSI_MINIPORT, + payload, + ARRAYSIZE(payload), + payload, + ARRAYSIZE(payload), + &bytesReturned, + nullptr + ); - /* End of previously unexposed stuff */ + if (ret) + { + std::wcout << L"Request succeeded" << std::endl; -} id_ctlr; + const std::vector buffer((PUCHAR)payload, (PUCHAR)payload + ARRAYSIZE(payload)); -typedef 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]; -} alarm_struct; + std::wostringstream ss; -typedef 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]; -} inquiry_data; + ss << std::hex << std::uppercase << std::setfill(L'0'); + std::for_each(buffer.cbegin(), buffer.cend(), [&](int c) { ss << std::setw(2) << c << L" "; }); -typedef 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]; -} sense_bus_param; -#include + const std::wstring hexString = ss.str(); + + std::wcout << L"Result buffer: " << hexString << std::endl; + } + else + { + std::wcerr << L"Failed to send request, error: 0x" << std::hex << GetLastError() << std::endl; + } +} 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; - - - 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 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); + MiniportExample(handle); + CloseHandle(handle); } diff --git a/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj b/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj index 3028728..1cc1048 100644 --- a/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj +++ b/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj @@ -133,6 +133,9 @@ + + + diff --git a/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj.filters b/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj.filters index 021ae52..3f8e140 100644 --- a/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj.filters +++ b/SmartArrayControllerTool/SmartArrayControllerTool.vcxproj.filters @@ -19,4 +19,9 @@ Source Files + + + Header Files + + \ No newline at end of file