Win32 API 日本語リファレンス
ホームSystem.Threading › AddIntegrityLabelToBoundaryDescriptor

AddIntegrityLabelToBoundaryDescriptor

関数
境界記述子に整合性ラベルのSIDを追加する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL AddIntegrityLabelToBoundaryDescriptor(
    HANDLE* BoundaryDescriptor,
    PSID IntegrityLabel
);

パラメーター

名前方向
BoundaryDescriptorHANDLE*inout
IntegrityLabelPSIDin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL AddIntegrityLabelToBoundaryDescriptor(
    HANDLE* BoundaryDescriptor,
    PSID IntegrityLabel
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool AddIntegrityLabelToBoundaryDescriptor(
    IntPtr BoundaryDescriptor,   // HANDLE* in/out
    IntPtr IntegrityLabel   // PSID
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function AddIntegrityLabelToBoundaryDescriptor(
    BoundaryDescriptor As IntPtr,   ' HANDLE* in/out
    IntegrityLabel As IntPtr   ' PSID
) As Boolean
End Function
' BoundaryDescriptor : HANDLE* in/out
' IntegrityLabel : PSID
Declare PtrSafe Function AddIntegrityLabelToBoundaryDescriptor Lib "kernel32" ( _
    ByVal BoundaryDescriptor As LongPtr, _
    ByVal IntegrityLabel As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AddIntegrityLabelToBoundaryDescriptor = ctypes.windll.kernel32.AddIntegrityLabelToBoundaryDescriptor
AddIntegrityLabelToBoundaryDescriptor.restype = wintypes.BOOL
AddIntegrityLabelToBoundaryDescriptor.argtypes = [
    ctypes.c_void_p,  # BoundaryDescriptor : HANDLE* in/out
    wintypes.HANDLE,  # IntegrityLabel : PSID
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
AddIntegrityLabelToBoundaryDescriptor = Fiddle::Function.new(
  lib['AddIntegrityLabelToBoundaryDescriptor'],
  [
    Fiddle::TYPE_VOIDP,  # BoundaryDescriptor : HANDLE* in/out
    Fiddle::TYPE_VOIDP,  # IntegrityLabel : PSID
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn AddIntegrityLabelToBoundaryDescriptor(
        BoundaryDescriptor: *mut *mut core::ffi::c_void,  // HANDLE* in/out
        IntegrityLabel: *mut core::ffi::c_void  // PSID
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool AddIntegrityLabelToBoundaryDescriptor(IntPtr BoundaryDescriptor, IntPtr IntegrityLabel);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_AddIntegrityLabelToBoundaryDescriptor' -Namespace Win32 -PassThru
# $api::AddIntegrityLabelToBoundaryDescriptor(BoundaryDescriptor, IntegrityLabel)
#uselib "KERNEL32.dll"
#func global AddIntegrityLabelToBoundaryDescriptor "AddIntegrityLabelToBoundaryDescriptor" sptr, sptr
; AddIntegrityLabelToBoundaryDescriptor BoundaryDescriptor, IntegrityLabel   ; 戻り値は stat
; BoundaryDescriptor : HANDLE* in/out -> "sptr"
; IntegrityLabel : PSID -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global AddIntegrityLabelToBoundaryDescriptor "AddIntegrityLabelToBoundaryDescriptor" sptr, sptr
; res = AddIntegrityLabelToBoundaryDescriptor(BoundaryDescriptor, IntegrityLabel)
; BoundaryDescriptor : HANDLE* in/out -> "sptr"
; IntegrityLabel : PSID -> "sptr"
; BOOL AddIntegrityLabelToBoundaryDescriptor(HANDLE* BoundaryDescriptor, PSID IntegrityLabel)
#uselib "KERNEL32.dll"
#cfunc global AddIntegrityLabelToBoundaryDescriptor "AddIntegrityLabelToBoundaryDescriptor" intptr, intptr
; res = AddIntegrityLabelToBoundaryDescriptor(BoundaryDescriptor, IntegrityLabel)
; BoundaryDescriptor : HANDLE* in/out -> "intptr"
; IntegrityLabel : PSID -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procAddIntegrityLabelToBoundaryDescriptor = kernel32.NewProc("AddIntegrityLabelToBoundaryDescriptor")
)

// BoundaryDescriptor (HANDLE* in/out), IntegrityLabel (PSID)
r1, _, err := procAddIntegrityLabelToBoundaryDescriptor.Call(
	uintptr(BoundaryDescriptor),
	uintptr(IntegrityLabel),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AddIntegrityLabelToBoundaryDescriptor(
  BoundaryDescriptor: Pointer;   // HANDLE* in/out
  IntegrityLabel: THandle   // PSID
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'AddIntegrityLabelToBoundaryDescriptor';
result := DllCall("KERNEL32\AddIntegrityLabelToBoundaryDescriptor"
    , "Ptr", BoundaryDescriptor   ; HANDLE* in/out
    , "Ptr", IntegrityLabel   ; PSID
    , "Int")   ; return: BOOL
●AddIntegrityLabelToBoundaryDescriptor(BoundaryDescriptor, IntegrityLabel) = DLL("KERNEL32.dll", "bool AddIntegrityLabelToBoundaryDescriptor(void*, void*)")
# 呼び出し: AddIntegrityLabelToBoundaryDescriptor(BoundaryDescriptor, IntegrityLabel)
# BoundaryDescriptor : HANDLE* in/out -> "void*"
# IntegrityLabel : PSID -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。