ホーム › System.WindowsProgramming › SYSTEM_THREAD_INFORMATION
SYSTEM_THREAD_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Reserved1 | LONGLONG | 24 | +0 | +0 | 予約LONGLONG配列(時刻情報等)。 |
| Reserved2 | DWORD | 4 | +24 | +24 | 予約DWORD。 |
| StartAddress | void* | 8/4 | +32 | +28 | スレッドの開始アドレス。 |
| ClientId | CLIENT_ID | 16/8 | +40 | +32 | スレッドのプロセスID/スレッドIDを保持するCLIENT_ID。 |
| Priority | INT | 4 | +56 | +40 | スレッドの現在の優先度。 |
| BasePriority | INT | 4 | +60 | +44 | スレッドの基本優先度。 |
| Reserved3 | DWORD | 4 | +64 | +48 | 予約DWORD(コンテキストスイッチ数等)。 |
| ThreadState | DWORD | 4 | +68 | +52 | スレッドの状態を示す値(実行中/待機中など)。 |
| WaitReason | DWORD | 4 | +72 | +56 | スレッドが待機している理由を示す値。 |
各言語での定義
#include <windows.h>
// CLIENT_ID (x64 16 / x86 8 バイト)
typedef struct CLIENT_ID {
HANDLE UniqueProcess;
HANDLE UniqueThread;
} CLIENT_ID;
// SYSTEM_THREAD_INFORMATION (x64 80 / x86 64 バイト)
typedef struct SYSTEM_THREAD_INFORMATION {
LONGLONG Reserved1[3];
DWORD Reserved2;
void* StartAddress;
CLIENT_ID ClientId;
INT Priority;
INT BasePriority;
DWORD Reserved3;
DWORD ThreadState;
DWORD WaitReason;
} SYSTEM_THREAD_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CLIENT_ID
{
public IntPtr UniqueProcess;
public IntPtr UniqueThread;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SYSTEM_THREAD_INFORMATION
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public long[] Reserved1;
public uint Reserved2;
public IntPtr StartAddress;
public CLIENT_ID ClientId;
public int Priority;
public int BasePriority;
public uint Reserved3;
public uint ThreadState;
public uint WaitReason;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CLIENT_ID
Public UniqueProcess As IntPtr
Public UniqueThread As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SYSTEM_THREAD_INFORMATION
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> Public Reserved1() As Long
Public Reserved2 As UInteger
Public StartAddress As IntPtr
Public ClientId As CLIENT_ID
Public Priority As Integer
Public BasePriority As Integer
Public Reserved3 As UInteger
Public ThreadState As UInteger
Public WaitReason As UInteger
End Structureimport ctypes
from ctypes import wintypes
class CLIENT_ID(ctypes.Structure):
_fields_ = [
("UniqueProcess", ctypes.c_void_p),
("UniqueThread", ctypes.c_void_p),
]
class SYSTEM_THREAD_INFORMATION(ctypes.Structure):
_fields_ = [
("Reserved1", ctypes.c_longlong * 3),
("Reserved2", wintypes.DWORD),
("StartAddress", ctypes.c_void_p),
("ClientId", CLIENT_ID),
("Priority", ctypes.c_int),
("BasePriority", ctypes.c_int),
("Reserved3", wintypes.DWORD),
("ThreadState", wintypes.DWORD),
("WaitReason", wintypes.DWORD),
]#[repr(C)]
pub struct CLIENT_ID {
pub UniqueProcess: *mut core::ffi::c_void,
pub UniqueThread: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct SYSTEM_THREAD_INFORMATION {
pub Reserved1: [i64; 3],
pub Reserved2: u32,
pub StartAddress: *mut core::ffi::c_void,
pub ClientId: CLIENT_ID,
pub Priority: i32,
pub BasePriority: i32,
pub Reserved3: u32,
pub ThreadState: u32,
pub WaitReason: u32,
}import "golang.org/x/sys/windows"
type CLIENT_ID struct {
UniqueProcess uintptr
UniqueThread uintptr
}
type SYSTEM_THREAD_INFORMATION struct {
Reserved1 [3]int64
Reserved2 uint32
StartAddress uintptr
ClientId CLIENT_ID
Priority int32
BasePriority int32
Reserved3 uint32
ThreadState uint32
WaitReason uint32
}type
CLIENT_ID = record
UniqueProcess: Pointer;
UniqueThread: Pointer;
end;
SYSTEM_THREAD_INFORMATION = record
Reserved1: array[0..2] of Int64;
Reserved2: DWORD;
StartAddress: Pointer;
ClientId: CLIENT_ID;
Priority: Integer;
BasePriority: Integer;
Reserved3: DWORD;
ThreadState: DWORD;
WaitReason: DWORD;
end;const CLIENT_ID = extern struct {
UniqueProcess: ?*anyopaque,
UniqueThread: ?*anyopaque,
};
const SYSTEM_THREAD_INFORMATION = extern struct {
Reserved1: [3]i64,
Reserved2: u32,
StartAddress: ?*anyopaque,
ClientId: CLIENT_ID,
Priority: i32,
BasePriority: i32,
Reserved3: u32,
ThreadState: u32,
WaitReason: u32,
};type
CLIENT_ID {.bycopy.} = object
UniqueProcess: pointer
UniqueThread: pointer
SYSTEM_THREAD_INFORMATION {.bycopy.} = object
Reserved1: array[3, int64]
Reserved2: uint32
StartAddress: pointer
ClientId: CLIENT_ID
Priority: int32
BasePriority: int32
Reserved3: uint32
ThreadState: uint32
WaitReason: uint32struct CLIENT_ID
{
void* UniqueProcess;
void* UniqueThread;
}
struct SYSTEM_THREAD_INFORMATION
{
long[3] Reserved1;
uint Reserved2;
void* StartAddress;
CLIENT_ID ClientId;
int Priority;
int BasePriority;
uint Reserved3;
uint ThreadState;
uint WaitReason;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SYSTEM_THREAD_INFORMATION サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Reserved1 : LONGLONG (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; Reserved2 : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; StartAddress : void* (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ClientId : CLIENT_ID (+32, 8byte) varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; Priority : INT (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; BasePriority : INT (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; Reserved3 : DWORD (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; ThreadState : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; WaitReason : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SYSTEM_THREAD_INFORMATION サイズ: 80 バイト(x64)
dim st, 20 ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; Reserved1 : LONGLONG (+0, 24byte) varptr(st)+0 を基点に操作(24byte:入れ子/配列)
; Reserved2 : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; StartAddress : void* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ClientId : CLIENT_ID (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; Priority : INT (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; BasePriority : INT (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; Reserved3 : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; ThreadState : DWORD (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; WaitReason : DWORD (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CLIENT_ID
#field intptr UniqueProcess
#field intptr UniqueThread
#endstruct
#defstruct global SYSTEM_THREAD_INFORMATION
#field int64 Reserved1 3
#field int Reserved2
#field intptr StartAddress
#field CLIENT_ID ClientId
#field int Priority
#field int BasePriority
#field int Reserved3
#field int ThreadState
#field int WaitReason
#endstruct
stdim st, SYSTEM_THREAD_INFORMATION ; NSTRUCT 変数を確保
st->Reserved2 = 100
mes "Reserved2=" + st->Reserved2