ホーム › System.Antimalware › AMSI_UAC_REQUEST_CONTEXT
AMSI_UAC_REQUEST_CONTEXT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ulLength | DWORD | 4 | +0 | +0 | この構造体のバイト長。 |
| ulRequestorProcessId | DWORD | 4 | +4 | +4 | 昇格を要求したプロセスのプロセスID。 |
| UACTrustState | AMSI_UAC_TRUST_STATE | 4 | +8 | +8 | 要求元の信頼状態を示す列挙値。 |
| Type | AMSI_UAC_REQUEST_TYPE | 4 | +12 | +12 | UAC要求の種別を示す列挙値。共用体RequestTypeの解釈を決める。 |
| RequestType | _RequestType_e__Union | 80/44 | +16 | +16 | Typeに応じてEXE/COM/MSI等の要求情報を切り替える共用体。 |
| bAutoElevateRequest | BOOL | 4 | +96 | +60 | 自動昇格要求かを示す真偽値。TRUEで自動昇格。 |
共用体: _RequestType_e__Union x64 80B / x86 44B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| ExeInfo | AMSI_UAC_REQUEST_EXE_INFO | 32/16 | +0 | +0 |
| ComInfo | AMSI_UAC_REQUEST_COM_INFO | 40/28 | +0 | +0 |
| MsiInfo | AMSI_UAC_REQUEST_MSI_INFO | 80/44 | +0 | +0 |
| ActiveXInfo | AMSI_UAC_REQUEST_AX_INFO | 24/12 | +0 | +0 |
| PackagedAppInfo | AMSI_UAC_REQUEST_PACKAGED_APP_INFO | 40/20 | +0 | +0 |
各言語での定義
#include <windows.h>
// AMSI_UAC_REQUEST_CONTEXT (x64 104 / x86 64 バイト)
typedef struct AMSI_UAC_REQUEST_CONTEXT {
DWORD ulLength;
DWORD ulRequestorProcessId;
AMSI_UAC_TRUST_STATE UACTrustState;
AMSI_UAC_REQUEST_TYPE Type;
_RequestType_e__Union RequestType;
BOOL bAutoElevateRequest;
} AMSI_UAC_REQUEST_CONTEXT;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct AMSI_UAC_REQUEST_CONTEXT
{
public uint ulLength;
public uint ulRequestorProcessId;
public int UACTrustState;
public int Type;
public _RequestType_e__Union RequestType;
[MarshalAs(UnmanagedType.Bool)] public bool bAutoElevateRequest;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure AMSI_UAC_REQUEST_CONTEXT
Public ulLength As UInteger
Public ulRequestorProcessId As UInteger
Public UACTrustState As Integer
Public Type As Integer
Public RequestType As _RequestType_e__Union
<MarshalAs(UnmanagedType.Bool)> Public bAutoElevateRequest As Boolean
End Structureimport ctypes
from ctypes import wintypes
class AMSI_UAC_REQUEST_CONTEXT(ctypes.Structure):
_fields_ = [
("ulLength", wintypes.DWORD),
("ulRequestorProcessId", wintypes.DWORD),
("UACTrustState", ctypes.c_int),
("Type", ctypes.c_int),
("RequestType", _RequestType_e__Union),
("bAutoElevateRequest", wintypes.BOOL),
]#[repr(C)]
pub struct AMSI_UAC_REQUEST_CONTEXT {
pub ulLength: u32,
pub ulRequestorProcessId: u32,
pub UACTrustState: i32,
pub Type: i32,
pub RequestType: _RequestType_e__Union,
pub bAutoElevateRequest: i32,
}import "golang.org/x/sys/windows"
type AMSI_UAC_REQUEST_CONTEXT struct {
ulLength uint32
ulRequestorProcessId uint32
UACTrustState int32
Type int32
RequestType _RequestType_e__Union
bAutoElevateRequest int32
}type
AMSI_UAC_REQUEST_CONTEXT = record
ulLength: DWORD;
ulRequestorProcessId: DWORD;
UACTrustState: Integer;
Type: Integer;
RequestType: _RequestType_e__Union;
bAutoElevateRequest: BOOL;
end;const AMSI_UAC_REQUEST_CONTEXT = extern struct {
ulLength: u32,
ulRequestorProcessId: u32,
UACTrustState: i32,
Type: i32,
RequestType: _RequestType_e__Union,
bAutoElevateRequest: i32,
};type
AMSI_UAC_REQUEST_CONTEXT {.bycopy.} = object
ulLength: uint32
ulRequestorProcessId: uint32
UACTrustState: int32
Type: int32
RequestType: _RequestType_e__Union
bAutoElevateRequest: int32struct AMSI_UAC_REQUEST_CONTEXT
{
uint ulLength;
uint ulRequestorProcessId;
int UACTrustState;
int Type;
_RequestType_e__Union RequestType;
int bAutoElevateRequest;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; AMSI_UAC_REQUEST_CONTEXT サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; ulLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ulRequestorProcessId : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; UACTrustState : AMSI_UAC_TRUST_STATE (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; Type : AMSI_UAC_REQUEST_TYPE (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; RequestType : _RequestType_e__Union (+16, 44byte) varptr(st)+16 を基点に操作(44byte:入れ子/配列)
; bAutoElevateRequest : BOOL (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; AMSI_UAC_REQUEST_CONTEXT サイズ: 104 バイト(x64)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; ulLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ulRequestorProcessId : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; UACTrustState : AMSI_UAC_TRUST_STATE (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; Type : AMSI_UAC_REQUEST_TYPE (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; RequestType : _RequestType_e__Union (+16, 80byte) varptr(st)+16 を基点に操作(80byte:入れ子/配列)
; bAutoElevateRequest : BOOL (+96, 4byte) st.24 = 値 / 値 = st.24 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global AMSI_UAC_REQUEST_CONTEXT
#field int ulLength
#field int ulRequestorProcessId
#field int UACTrustState
#field int Type
#field byte RequestType 80
#field bool bAutoElevateRequest
#endstruct
stdim st, AMSI_UAC_REQUEST_CONTEXT ; NSTRUCT 変数を確保
st->ulLength = 100
mes "ulLength=" + st->ulLength
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。