GetSecurityDescriptorControl
関数セキュリティ記述子の制御フラグと改訂を取得する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL GetSecurityDescriptorControl(
PSECURITY_DESCRIPTOR pSecurityDescriptor,
WORD* pControl,
DWORD* lpdwRevision
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pSecurityDescriptor | PSECURITY_DESCRIPTOR | in | 制御情報とリビジョン情報を取得する対象の SECURITY_DESCRIPTOR 構造体へのポインターです。 |
| pControl | WORD* | out | セキュリティ記述子の制御情報を受け取る SECURITY_DESCRIPTOR_CONTROL 構造体へのポインターです。 |
| lpdwRevision | DWORD* | out | セキュリティ記述子のリビジョン値を受け取る変数へのポインターです。この値は、GetSecurityDescriptorControl がエラーを返した場合でも常に設定されます。 |
戻り値の型: BOOL
公式ドキュメント
セキュリティ記述子の制御情報とリビジョン情報を取得します。
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL GetSecurityDescriptorControl(
PSECURITY_DESCRIPTOR pSecurityDescriptor,
WORD* pControl,
DWORD* lpdwRevision
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetSecurityDescriptorControl(
IntPtr pSecurityDescriptor, // PSECURITY_DESCRIPTOR
out ushort pControl, // WORD* out
out uint lpdwRevision // DWORD* out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetSecurityDescriptorControl(
pSecurityDescriptor As IntPtr, ' PSECURITY_DESCRIPTOR
<Out> ByRef pControl As UShort, ' WORD* out
<Out> ByRef lpdwRevision As UInteger ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pSecurityDescriptor : PSECURITY_DESCRIPTOR
' pControl : WORD* out
' lpdwRevision : DWORD* out
Declare PtrSafe Function GetSecurityDescriptorControl Lib "advapi32" ( _
ByVal pSecurityDescriptor As LongPtr, _
ByRef pControl As Integer, _
ByRef lpdwRevision As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSecurityDescriptorControl = ctypes.windll.advapi32.GetSecurityDescriptorControl
GetSecurityDescriptorControl.restype = wintypes.BOOL
GetSecurityDescriptorControl.argtypes = [
wintypes.HANDLE, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
ctypes.POINTER(ctypes.c_ushort), # pControl : WORD* out
ctypes.POINTER(wintypes.DWORD), # lpdwRevision : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
GetSecurityDescriptorControl = Fiddle::Function.new(
lib['GetSecurityDescriptorControl'],
[
Fiddle::TYPE_VOIDP, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
Fiddle::TYPE_VOIDP, # pControl : WORD* out
Fiddle::TYPE_VOIDP, # lpdwRevision : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn GetSecurityDescriptorControl(
pSecurityDescriptor: *mut core::ffi::c_void, // PSECURITY_DESCRIPTOR
pControl: *mut u16, // WORD* out
lpdwRevision: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool GetSecurityDescriptorControl(IntPtr pSecurityDescriptor, out ushort pControl, out uint lpdwRevision);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetSecurityDescriptorControl' -Namespace Win32 -PassThru
# $api::GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)#uselib "ADVAPI32.dll"
#func global GetSecurityDescriptorControl "GetSecurityDescriptorControl" sptr, sptr, sptr
; GetSecurityDescriptorControl pSecurityDescriptor, varptr(pControl), varptr(lpdwRevision) ; 戻り値は stat
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"
; pControl : WORD* out -> "sptr"
; lpdwRevision : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorControl "GetSecurityDescriptorControl" sptr, var, var ; res = GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr" ; pControl : WORD* out -> "var" ; lpdwRevision : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorControl "GetSecurityDescriptorControl" sptr, sptr, sptr ; res = GetSecurityDescriptorControl(pSecurityDescriptor, varptr(pControl), varptr(lpdwRevision)) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr" ; pControl : WORD* out -> "sptr" ; lpdwRevision : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, WORD* pControl, DWORD* lpdwRevision) #uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorControl "GetSecurityDescriptorControl" intptr, var, var ; res = GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr" ; pControl : WORD* out -> "var" ; lpdwRevision : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, WORD* pControl, DWORD* lpdwRevision) #uselib "ADVAPI32.dll" #cfunc global GetSecurityDescriptorControl "GetSecurityDescriptorControl" intptr, intptr, intptr ; res = GetSecurityDescriptorControl(pSecurityDescriptor, varptr(pControl), varptr(lpdwRevision)) ; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr" ; pControl : WORD* out -> "intptr" ; lpdwRevision : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procGetSecurityDescriptorControl = advapi32.NewProc("GetSecurityDescriptorControl")
)
// pSecurityDescriptor (PSECURITY_DESCRIPTOR), pControl (WORD* out), lpdwRevision (DWORD* out)
r1, _, err := procGetSecurityDescriptorControl.Call(
uintptr(pSecurityDescriptor),
uintptr(pControl),
uintptr(lpdwRevision),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetSecurityDescriptorControl(
pSecurityDescriptor: THandle; // PSECURITY_DESCRIPTOR
pControl: Pointer; // WORD* out
lpdwRevision: Pointer // DWORD* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetSecurityDescriptorControl';result := DllCall("ADVAPI32\GetSecurityDescriptorControl"
, "Ptr", pSecurityDescriptor ; PSECURITY_DESCRIPTOR
, "Ptr", pControl ; WORD* out
, "Ptr", lpdwRevision ; DWORD* out
, "Int") ; return: BOOL●GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision) = DLL("ADVAPI32.dll", "bool GetSecurityDescriptorControl(void*, void*, void*)")
# 呼び出し: GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "void*"
# pControl : WORD* out -> "void*"
# lpdwRevision : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn GetSecurityDescriptorControl(
pSecurityDescriptor: ?*anyopaque, // PSECURITY_DESCRIPTOR
pControl: [*c]u16, // WORD* out
lpdwRevision: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc GetSecurityDescriptorControl(
pSecurityDescriptor: pointer, # PSECURITY_DESCRIPTOR
pControl: ptr uint16, # WORD* out
lpdwRevision: ptr uint32 # DWORD* out
): int32 {.importc: "GetSecurityDescriptorControl", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
int GetSecurityDescriptorControl(
void* pSecurityDescriptor, // PSECURITY_DESCRIPTOR
ushort* pControl, // WORD* out
uint* lpdwRevision // DWORD* out
);ccall((:GetSecurityDescriptorControl, "ADVAPI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{UInt16}, Ptr{UInt32}),
pSecurityDescriptor, pControl, lpdwRevision)
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> Ptr{Cvoid}
# pControl : WORD* out -> Ptr{UInt16}
# lpdwRevision : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetSecurityDescriptorControl(
void* pSecurityDescriptor,
uint16_t* pControl,
uint32_t* lpdwRevision);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR
-- pControl : WORD* out
-- lpdwRevision : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const GetSecurityDescriptorControl = lib.func('__stdcall', 'GetSecurityDescriptorControl', 'int32_t', ['void *', 'uint16_t *', 'uint32_t *']);
// GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)
// pSecurityDescriptor : PSECURITY_DESCRIPTOR -> 'void *'
// pControl : WORD* out -> 'uint16_t *'
// lpdwRevision : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
GetSecurityDescriptorControl: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)
// pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "pointer"
// pControl : WORD* out -> "pointer"
// lpdwRevision : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetSecurityDescriptorControl(
void* pSecurityDescriptor,
uint16_t* pControl,
uint32_t* lpdwRevision);
C, "ADVAPI32.dll");
// $ffi->GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision);
// pSecurityDescriptor : PSECURITY_DESCRIPTOR
// pControl : WORD* out
// lpdwRevision : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class);
boolean GetSecurityDescriptorControl(
Pointer pSecurityDescriptor, // PSECURITY_DESCRIPTOR
ShortByReference pControl, // WORD* out
IntByReference lpdwRevision // DWORD* out
);
}@[Link("advapi32")]
lib LibADVAPI32
fun GetSecurityDescriptorControl = GetSecurityDescriptorControl(
pSecurityDescriptor : Void*, # PSECURITY_DESCRIPTOR
pControl : UInt16*, # WORD* out
lpdwRevision : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetSecurityDescriptorControlNative = Int32 Function(Pointer<Void>, Pointer<Uint16>, Pointer<Uint32>);
typedef GetSecurityDescriptorControlDart = int Function(Pointer<Void>, Pointer<Uint16>, Pointer<Uint32>);
final GetSecurityDescriptorControl = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<GetSecurityDescriptorControlNative, GetSecurityDescriptorControlDart>('GetSecurityDescriptorControl');
// pSecurityDescriptor : PSECURITY_DESCRIPTOR -> Pointer<Void>
// pControl : WORD* out -> Pointer<Uint16>
// lpdwRevision : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetSecurityDescriptorControl(
pSecurityDescriptor: THandle; // PSECURITY_DESCRIPTOR
pControl: Pointer; // WORD* out
lpdwRevision: Pointer // DWORD* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'GetSecurityDescriptorControl';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetSecurityDescriptorControl"
c_GetSecurityDescriptorControl :: Ptr () -> Ptr Word16 -> Ptr Word32 -> IO CInt
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR -> Ptr ()
-- pControl : WORD* out -> Ptr Word16
-- lpdwRevision : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getsecuritydescriptorcontrol =
foreign "GetSecurityDescriptorControl"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* pSecurityDescriptor : PSECURITY_DESCRIPTOR -> (ptr void) *)
(* pControl : WORD* out -> (ptr uint16_t) *)
(* lpdwRevision : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("GetSecurityDescriptorControl" get-security-descriptor-control :convention :stdcall) :int32
(p-security-descriptor :pointer) ; PSECURITY_DESCRIPTOR
(p-control :pointer) ; WORD* out
(lpdw-revision :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetSecurityDescriptorControl = Win32::API::More->new('ADVAPI32',
'BOOL GetSecurityDescriptorControl(HANDLE pSecurityDescriptor, LPVOID pControl, LPVOID lpdwRevision)');
# my $ret = $GetSecurityDescriptorControl->Call($pSecurityDescriptor, $pControl, $lpdwRevision);
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> HANDLE
# pControl : WORD* out -> LPVOID
# lpdwRevision : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f GetSecurityDescriptorDacl — セキュリティ記述子からDACLを取得する。
- f GetSecurityDescriptorGroup — セキュリティ記述子からプライマリグループSIDを取得する。
- f GetSecurityDescriptorLength — セキュリティ記述子のバイト長を取得する。
- f GetSecurityDescriptorOwner — セキュリティ記述子から所有者SIDを取得する。
- f GetSecurityDescriptorSacl — セキュリティ記述子からSACLを取得する。
- f IsValidSecurityDescriptor — セキュリティ記述子が有効かどうかを検証する。
- s SECURITY_DESCRIPTOR