Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › MEM_DES

MEM_DES

構造体
サイズx64: 32 バイト / x86: 32 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
MD_CountDWORD4+0+0後続のMEM_RANGE配列の要素数。
MD_TypeDWORD4+4+4メモリ記述子の種別を示す値。
MD_Alloc_BaseULONGLONG8+8+8割り当てられたメモリ範囲の開始物理アドレス。
MD_Alloc_EndULONGLONG8+16+16割り当てられたメモリ範囲の終了物理アドレス。
MD_FlagsMD_FLAGS4+24+24メモリ記述子のフラグ群(MD_FLAGS)。
MD_ReservedDWORD4+28+28システム内部利用の予約領域。

各言語での定義

#include <windows.h>

// MEM_DES  (x64 32 / x86 32 バイト)
#pragma pack(push, 1)
typedef struct MEM_DES {
    DWORD MD_Count;
    DWORD MD_Type;
    ULONGLONG MD_Alloc_Base;
    ULONGLONG MD_Alloc_End;
    MD_FLAGS MD_Flags;
    DWORD MD_Reserved;
} MEM_DES;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct MEM_DES
{
    public uint MD_Count;
    public uint MD_Type;
    public ulong MD_Alloc_Base;
    public ulong MD_Alloc_End;
    public uint MD_Flags;
    public uint MD_Reserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure MEM_DES
    Public MD_Count As UInteger
    Public MD_Type As UInteger
    Public MD_Alloc_Base As ULong
    Public MD_Alloc_End As ULong
    Public MD_Flags As UInteger
    Public MD_Reserved As UInteger
End Structure
import ctypes
from ctypes import wintypes

class MEM_DES(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("MD_Count", wintypes.DWORD),
        ("MD_Type", wintypes.DWORD),
        ("MD_Alloc_Base", ctypes.c_ulonglong),
        ("MD_Alloc_End", ctypes.c_ulonglong),
        ("MD_Flags", wintypes.DWORD),
        ("MD_Reserved", wintypes.DWORD),
    ]
#[repr(C, packed(1))]
pub struct MEM_DES {
    pub MD_Count: u32,
    pub MD_Type: u32,
    pub MD_Alloc_Base: u64,
    pub MD_Alloc_End: u64,
    pub MD_Flags: u32,
    pub MD_Reserved: u32,
}
import "golang.org/x/sys/windows"

type MEM_DES struct {
	MD_Count uint32
	MD_Type uint32
	MD_Alloc_Base uint64
	MD_Alloc_End uint64
	MD_Flags uint32
	MD_Reserved uint32
}
type
  MEM_DES = packed record
    MD_Count: DWORD;
    MD_Type: DWORD;
    MD_Alloc_Base: UInt64;
    MD_Alloc_End: UInt64;
    MD_Flags: DWORD;
    MD_Reserved: DWORD;
  end;
const MEM_DES = extern struct {
    MD_Count: u32,
    MD_Type: u32,
    MD_Alloc_Base: u64,
    MD_Alloc_End: u64,
    MD_Flags: u32,
    MD_Reserved: u32,
};
type
  MEM_DES {.packed.} = object
    MD_Count: uint32
    MD_Type: uint32
    MD_Alloc_Base: uint64
    MD_Alloc_End: uint64
    MD_Flags: uint32
    MD_Reserved: uint32
align(1)
struct MEM_DES
{
    uint MD_Count;
    uint MD_Type;
    ulong MD_Alloc_Base;
    ulong MD_Alloc_End;
    uint MD_Flags;
    uint MD_Reserved;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MEM_DES サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; MD_Count : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; MD_Type : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; MD_Alloc_Base : ULONGLONG (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; MD_Alloc_End : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; MD_Flags : MD_FLAGS (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; MD_Reserved : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MEM_DES, pack=1
    #field int MD_Count
    #field int MD_Type
    #field int64 MD_Alloc_Base
    #field int64 MD_Alloc_End
    #field int MD_Flags
    #field int MD_Reserved
#endstruct

stdim st, MEM_DES        ; NSTRUCT 変数を確保
st->MD_Count = 100
mes "MD_Count=" + st->MD_Count