TOKEN_STATISTICS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| TokenId | LUID | 8 | +0 | +0 | トークンを一意に識別するLUID。 |
| AuthenticationId | LUID | 8 | +8 | +8 | ログオンセッションを識別する認証ID(LUID)。 |
| ExpirationTime | LONGLONG | 8 | +16 | +16 | トークンの有効期限。現状は使用されない。 |
| TokenType | TOKEN_TYPE | 4 | +24 | +24 | トークンの種別(プライマリか偽装か)を示す列挙値。 |
| ImpersonationLevel | SECURITY_IMPERSONATION_LEVEL | 4 | +28 | +28 | 偽装トークンの偽装レベルを示す列挙値。 |
| DynamicCharged | DWORD | 4 | +32 | +32 | 動的部分に割り当てられたメモリのバイト数。 |
| DynamicAvailable | DWORD | 4 | +36 | +36 | 動的部分で利用可能な空きメモリのバイト数。 |
| GroupCount | DWORD | 4 | +40 | +40 | トークンに含まれるグループSIDの数。 |
| PrivilegeCount | DWORD | 4 | +44 | +44 | トークンに含まれる特権の数。 |
| ModifiedId | LUID | 8 | +48 | +48 | トークンが変更されるたびに変わる変更識別LUID。 |
各言語での定義
#include <windows.h>
// LUID (x64 8 / x86 8 バイト)
typedef struct LUID {
DWORD LowPart;
INT HighPart;
} LUID;
// TOKEN_STATISTICS (x64 56 / x86 56 バイト)
typedef struct TOKEN_STATISTICS {
LUID TokenId;
LUID AuthenticationId;
LONGLONG ExpirationTime;
TOKEN_TYPE TokenType;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
DWORD DynamicCharged;
DWORD DynamicAvailable;
DWORD GroupCount;
DWORD PrivilegeCount;
LUID ModifiedId;
} TOKEN_STATISTICS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LUID
{
public uint LowPart;
public int HighPart;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TOKEN_STATISTICS
{
public LUID TokenId;
public LUID AuthenticationId;
public long ExpirationTime;
public int TokenType;
public int ImpersonationLevel;
public uint DynamicCharged;
public uint DynamicAvailable;
public uint GroupCount;
public uint PrivilegeCount;
public LUID ModifiedId;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LUID
Public LowPart As UInteger
Public HighPart As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TOKEN_STATISTICS
Public TokenId As LUID
Public AuthenticationId As LUID
Public ExpirationTime As Long
Public TokenType As Integer
Public ImpersonationLevel As Integer
Public DynamicCharged As UInteger
Public DynamicAvailable As UInteger
Public GroupCount As UInteger
Public PrivilegeCount As UInteger
Public ModifiedId As LUID
End Structureimport ctypes
from ctypes import wintypes
class LUID(ctypes.Structure):
_fields_ = [
("LowPart", wintypes.DWORD),
("HighPart", ctypes.c_int),
]
class TOKEN_STATISTICS(ctypes.Structure):
_fields_ = [
("TokenId", LUID),
("AuthenticationId", LUID),
("ExpirationTime", ctypes.c_longlong),
("TokenType", ctypes.c_int),
("ImpersonationLevel", ctypes.c_int),
("DynamicCharged", wintypes.DWORD),
("DynamicAvailable", wintypes.DWORD),
("GroupCount", wintypes.DWORD),
("PrivilegeCount", wintypes.DWORD),
("ModifiedId", LUID),
]#[repr(C)]
pub struct LUID {
pub LowPart: u32,
pub HighPart: i32,
}
#[repr(C)]
pub struct TOKEN_STATISTICS {
pub TokenId: LUID,
pub AuthenticationId: LUID,
pub ExpirationTime: i64,
pub TokenType: i32,
pub ImpersonationLevel: i32,
pub DynamicCharged: u32,
pub DynamicAvailable: u32,
pub GroupCount: u32,
pub PrivilegeCount: u32,
pub ModifiedId: LUID,
}import "golang.org/x/sys/windows"
type LUID struct {
LowPart uint32
HighPart int32
}
type TOKEN_STATISTICS struct {
TokenId LUID
AuthenticationId LUID
ExpirationTime int64
TokenType int32
ImpersonationLevel int32
DynamicCharged uint32
DynamicAvailable uint32
GroupCount uint32
PrivilegeCount uint32
ModifiedId LUID
}type
LUID = record
LowPart: DWORD;
HighPart: Integer;
end;
TOKEN_STATISTICS = record
TokenId: LUID;
AuthenticationId: LUID;
ExpirationTime: Int64;
TokenType: Integer;
ImpersonationLevel: Integer;
DynamicCharged: DWORD;
DynamicAvailable: DWORD;
GroupCount: DWORD;
PrivilegeCount: DWORD;
ModifiedId: LUID;
end;const LUID = extern struct {
LowPart: u32,
HighPart: i32,
};
const TOKEN_STATISTICS = extern struct {
TokenId: LUID,
AuthenticationId: LUID,
ExpirationTime: i64,
TokenType: i32,
ImpersonationLevel: i32,
DynamicCharged: u32,
DynamicAvailable: u32,
GroupCount: u32,
PrivilegeCount: u32,
ModifiedId: LUID,
};type
LUID {.bycopy.} = object
LowPart: uint32
HighPart: int32
TOKEN_STATISTICS {.bycopy.} = object
TokenId: LUID
AuthenticationId: LUID
ExpirationTime: int64
TokenType: int32
ImpersonationLevel: int32
DynamicCharged: uint32
DynamicAvailable: uint32
GroupCount: uint32
PrivilegeCount: uint32
ModifiedId: LUIDstruct LUID
{
uint LowPart;
int HighPart;
}
struct TOKEN_STATISTICS
{
LUID TokenId;
LUID AuthenticationId;
long ExpirationTime;
int TokenType;
int ImpersonationLevel;
uint DynamicCharged;
uint DynamicAvailable;
uint GroupCount;
uint PrivilegeCount;
LUID ModifiedId;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TOKEN_STATISTICS サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; TokenId : LUID (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; AuthenticationId : LUID (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ExpirationTime : LONGLONG (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; TokenType : TOKEN_TYPE (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ImpersonationLevel : SECURITY_IMPERSONATION_LEVEL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; DynamicCharged : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; DynamicAvailable : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; GroupCount : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; PrivilegeCount : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; ModifiedId : LUID (+48, 8byte) varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global LUID
#field int LowPart
#field int HighPart
#endstruct
#defstruct global TOKEN_STATISTICS
#field LUID TokenId
#field LUID AuthenticationId
#field int64 ExpirationTime
#field int TokenType
#field int ImpersonationLevel
#field int DynamicCharged
#field int DynamicAvailable
#field int GroupCount
#field int PrivilegeCount
#field LUID ModifiedId
#endstruct
stdim st, TOKEN_STATISTICS ; NSTRUCT 変数を確保
st->ExpirationTime = 100
mes "ExpirationTime=" + st->ExpirationTime