Win32 API 日本語リファレンス
ホームSecurity › SE_SID

SE_SID

共用体
サイズx64: 68 バイト / x86: 68 バイト

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

フィールド

フィールドサイズx64x86説明
SidSID12+0+0SID構造体としての表現。
BufferBYTE68+0+0最大サイズのSIDを格納するための固定長バイトバッファ。

各言語での定義

#include <windows.h>

// SID_IDENTIFIER_AUTHORITY  (x64 6 / x86 6 バイト)
typedef struct SID_IDENTIFIER_AUTHORITY {
    BYTE Value[6];
} SID_IDENTIFIER_AUTHORITY;

// SID  (x64 12 / x86 12 バイト)
typedef struct SID {
    BYTE Revision;
    BYTE SubAuthorityCount;
    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    DWORD SubAuthority[1];
} SID;

// SE_SID  (x64 68 / x86 68 バイト)
typedef struct SE_SID {
    SID Sid;
    BYTE Buffer[68];
} SE_SID;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SID_IDENTIFIER_AUTHORITY
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] Value;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SID
{
    public byte Revision;
    public byte SubAuthorityCount;
    public SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] SubAuthority;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SE_SID
{
    public SID Sid;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 68)] public byte[] Buffer;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SID_IDENTIFIER_AUTHORITY
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=6)> Public Value() As Byte
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SID
    Public Revision As Byte
    Public SubAuthorityCount As Byte
    Public IdentifierAuthority As SID_IDENTIFIER_AUTHORITY
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public SubAuthority() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SE_SID
    Public Sid As SID
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=68)> Public Buffer() As Byte
End Structure
import ctypes
from ctypes import wintypes

class SID_IDENTIFIER_AUTHORITY(ctypes.Structure):
    _fields_ = [
        ("Value", ctypes.c_ubyte * 6),
    ]

class SID(ctypes.Structure):
    _fields_ = [
        ("Revision", ctypes.c_ubyte),
        ("SubAuthorityCount", ctypes.c_ubyte),
        ("IdentifierAuthority", SID_IDENTIFIER_AUTHORITY),
        ("SubAuthority", wintypes.DWORD * 1),
    ]

class SE_SID(ctypes.Structure):
    _fields_ = [
        ("Sid", SID),
        ("Buffer", ctypes.c_ubyte * 68),
    ]
#[repr(C)]
pub struct SID_IDENTIFIER_AUTHORITY {
    pub Value: [u8; 6],
}

#[repr(C)]
pub struct SID {
    pub Revision: u8,
    pub SubAuthorityCount: u8,
    pub IdentifierAuthority: SID_IDENTIFIER_AUTHORITY,
    pub SubAuthority: [u32; 1],
}

#[repr(C)]
pub struct SE_SID {
    pub Sid: SID,
    pub Buffer: [u8; 68],
}
import "golang.org/x/sys/windows"

type SID_IDENTIFIER_AUTHORITY struct {
	Value [6]byte
}

type SID struct {
	Revision byte
	SubAuthorityCount byte
	IdentifierAuthority SID_IDENTIFIER_AUTHORITY
	SubAuthority [1]uint32
}

type SE_SID struct {
	Sid SID
	Buffer [68]byte
}
type
  SID_IDENTIFIER_AUTHORITY = record
    Value: array[0..5] of Byte;
  end;

  SID = record
    Revision: Byte;
    SubAuthorityCount: Byte;
    IdentifierAuthority: SID_IDENTIFIER_AUTHORITY;
    SubAuthority: array[0..0] of DWORD;
  end;

  SE_SID = record
    Sid: SID;
    Buffer: array[0..67] of Byte;
  end;
const SID_IDENTIFIER_AUTHORITY = extern struct {
    Value: [6]u8,
};

const SID = extern struct {
    Revision: u8,
    SubAuthorityCount: u8,
    IdentifierAuthority: SID_IDENTIFIER_AUTHORITY,
    SubAuthority: [1]u32,
};

const SE_SID = extern struct {
    Sid: SID,
    Buffer: [68]u8,
};
type
  SID_IDENTIFIER_AUTHORITY {.bycopy.} = object
    Value: array[6, uint8]

  SID {.bycopy.} = object
    Revision: uint8
    SubAuthorityCount: uint8
    IdentifierAuthority: SID_IDENTIFIER_AUTHORITY
    SubAuthority: array[1, uint32]

  SE_SID {.bycopy.} = object
    Sid: SID
    Buffer: array[68, uint8]
struct SID_IDENTIFIER_AUTHORITY
{
    ubyte[6] Value;
}

struct SID
{
    ubyte Revision;
    ubyte SubAuthorityCount;
    SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
    uint[1] SubAuthority;
}

struct SE_SID
{
    SID Sid;
    ubyte[68] Buffer;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SE_SID サイズ: 68 バイト(x64)
dim st, 17    ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; Sid : SID (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; Buffer : BYTE (+0, 68byte)  varptr(st)+0 を基点に操作(68byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SID_IDENTIFIER_AUTHORITY
    #field byte Value 6
#endstruct

#defstruct global SID
    #field byte Revision
    #field byte SubAuthorityCount
    #field SID_IDENTIFIER_AUTHORITY IdentifierAuthority
    #field int SubAuthority 1
#endstruct

#defstruct global SE_SID
    #field SID Sid
    #field byte Buffer 68
#endstruct

stdim st, SE_SID        ; NSTRUCT 変数を確保