ホーム › System.Ioctl › DRIVERSTATUS
DRIVERSTATUS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| bDriverError | BYTE | 1 | +0 | +0 | ドライバのエラーコード。 |
| bIDEError | BYTE | 1 | +1 | +1 | IDEエラーレジスタの値。bDriverErrorが該当時のみ有効。 |
| bReserved | BYTE | 2 | +2 | +2 | 予約領域。ゼロを設定する。 |
| dwReserved | DWORD | 8 | +4 | +4 | 予約領域。ゼロを設定する。 |
各言語での定義
#include <windows.h>
// DRIVERSTATUS (x64 12 / x86 12 バイト)
#pragma pack(push, 1)
typedef struct DRIVERSTATUS {
BYTE bDriverError;
BYTE bIDEError;
BYTE bReserved[2];
DWORD dwReserved[2];
} DRIVERSTATUS;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct DRIVERSTATUS
{
public byte bDriverError;
public byte bIDEError;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] bReserved;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] dwReserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure DRIVERSTATUS
Public bDriverError As Byte
Public bIDEError As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public bReserved() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public dwReserved() As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DRIVERSTATUS(ctypes.Structure):
_pack_ = 1
_fields_ = [
("bDriverError", ctypes.c_ubyte),
("bIDEError", ctypes.c_ubyte),
("bReserved", ctypes.c_ubyte * 2),
("dwReserved", wintypes.DWORD * 2),
]#[repr(C, packed(1))]
pub struct DRIVERSTATUS {
pub bDriverError: u8,
pub bIDEError: u8,
pub bReserved: [u8; 2],
pub dwReserved: [u32; 2],
}import "golang.org/x/sys/windows"
type DRIVERSTATUS struct {
bDriverError byte
bIDEError byte
bReserved [2]byte
dwReserved [2]uint32
}type
DRIVERSTATUS = packed record
bDriverError: Byte;
bIDEError: Byte;
bReserved: array[0..1] of Byte;
dwReserved: array[0..1] of DWORD;
end;const DRIVERSTATUS = extern struct {
bDriverError: u8,
bIDEError: u8,
bReserved: [2]u8,
dwReserved: [2]u32,
};type
DRIVERSTATUS {.packed.} = object
bDriverError: uint8
bIDEError: uint8
bReserved: array[2, uint8]
dwReserved: array[2, uint32]align(1)
struct DRIVERSTATUS
{
ubyte bDriverError;
ubyte bIDEError;
ubyte[2] bReserved;
uint[2] dwReserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DRIVERSTATUS サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; bDriverError : BYTE (+0, 1byte) poke st,0,値 / 値 = peek(st,0)
; bIDEError : BYTE (+1, 1byte) poke st,1,値 / 値 = peek(st,1)
; bReserved : BYTE (+2, 2byte) varptr(st)+2 を基点に操作(2byte:入れ子/配列)
; dwReserved : DWORD (+4, 8byte) varptr(st)+4 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DRIVERSTATUS, pack=1
#field byte bDriverError
#field byte bIDEError
#field byte bReserved 2
#field int dwReserved 2
#endstruct
stdim st, DRIVERSTATUS ; NSTRUCT 変数を確保
st->bDriverError = 100
mes "bDriverError=" + st->bDriverError