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

WldpCanExecuteBuffer

関数
メモリバッファの内容が実行許可されるかを評価する。
DLLWldp.dll呼出規約winapi

シグネチャ

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

HRESULT WldpCanExecuteBuffer(
    const GUID* host,
    WLDP_EXECUTION_EVALUATION_OPTIONS options,
    const BYTE* buffer,
    DWORD bufferSize,
    LPCWSTR auditInfo,   // optional
    WLDP_EXECUTION_POLICY* result
);

パラメーター

名前方向
hostGUID*in
optionsWLDP_EXECUTION_EVALUATION_OPTIONSin
bufferBYTE*in
bufferSizeDWORDin
auditInfoLPCWSTRinoptional
resultWLDP_EXECUTION_POLICY*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WldpCanExecuteBuffer(
    const GUID* host,
    WLDP_EXECUTION_EVALUATION_OPTIONS options,
    const BYTE* buffer,
    DWORD bufferSize,
    LPCWSTR auditInfo,   // optional
    WLDP_EXECUTION_POLICY* result
);
[DllImport("Wldp.dll", ExactSpelling = true)]
static extern int WldpCanExecuteBuffer(
    ref Guid host,   // GUID*
    int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
    IntPtr buffer,   // BYTE*
    uint bufferSize,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string auditInfo,   // LPCWSTR optional
    out int result   // WLDP_EXECUTION_POLICY* out
);
<DllImport("Wldp.dll", ExactSpelling:=True)>
Public Shared Function WldpCanExecuteBuffer(
    ByRef host As Guid,   ' GUID*
    options As Integer,   ' WLDP_EXECUTION_EVALUATION_OPTIONS
    buffer As IntPtr,   ' BYTE*
    bufferSize As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> auditInfo As String,   ' LPCWSTR optional
    <Out> ByRef result As Integer   ' WLDP_EXECUTION_POLICY* out
) As Integer
End Function
' host : GUID*
' options : WLDP_EXECUTION_EVALUATION_OPTIONS
' buffer : BYTE*
' bufferSize : DWORD
' auditInfo : LPCWSTR optional
' result : WLDP_EXECUTION_POLICY* out
Declare PtrSafe Function WldpCanExecuteBuffer Lib "wldp" ( _
    ByVal host As LongPtr, _
    ByVal options As Long, _
    ByVal buffer As LongPtr, _
    ByVal bufferSize As Long, _
    ByVal auditInfo As LongPtr, _
    ByRef result As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WldpCanExecuteBuffer = ctypes.windll.wldp.WldpCanExecuteBuffer
WldpCanExecuteBuffer.restype = ctypes.c_int
WldpCanExecuteBuffer.argtypes = [
    ctypes.c_void_p,  # host : GUID*
    ctypes.c_int,  # options : WLDP_EXECUTION_EVALUATION_OPTIONS
    ctypes.POINTER(ctypes.c_ubyte),  # buffer : BYTE*
    wintypes.DWORD,  # bufferSize : DWORD
    wintypes.LPCWSTR,  # auditInfo : LPCWSTR optional
    ctypes.c_void_p,  # result : WLDP_EXECUTION_POLICY* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Wldp.dll')
WldpCanExecuteBuffer = Fiddle::Function.new(
  lib['WldpCanExecuteBuffer'],
  [
    Fiddle::TYPE_VOIDP,  # host : GUID*
    Fiddle::TYPE_INT,  # options : WLDP_EXECUTION_EVALUATION_OPTIONS
    Fiddle::TYPE_VOIDP,  # buffer : BYTE*
    -Fiddle::TYPE_INT,  # bufferSize : DWORD
    Fiddle::TYPE_VOIDP,  # auditInfo : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # result : WLDP_EXECUTION_POLICY* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wldp")]
extern "system" {
    fn WldpCanExecuteBuffer(
        host: *const GUID,  // GUID*
        options: i32,  // WLDP_EXECUTION_EVALUATION_OPTIONS
        buffer: *const u8,  // BYTE*
        bufferSize: u32,  // DWORD
        auditInfo: *const u16,  // LPCWSTR optional
        result: *mut i32  // WLDP_EXECUTION_POLICY* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("Wldp.dll")]
public static extern int WldpCanExecuteBuffer(ref Guid host, int options, IntPtr buffer, uint bufferSize, [MarshalAs(UnmanagedType.LPWStr)] string auditInfo, out int result);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Wldp_WldpCanExecuteBuffer' -Namespace Win32 -PassThru
# $api::WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
#uselib "Wldp.dll"
#func global WldpCanExecuteBuffer "WldpCanExecuteBuffer" sptr, sptr, sptr, sptr, sptr, sptr
; WldpCanExecuteBuffer varptr(host), options, varptr(buffer), bufferSize, auditInfo, result   ; 戻り値は stat
; host : GUID* -> "sptr"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "sptr"
; buffer : BYTE* -> "sptr"
; bufferSize : DWORD -> "sptr"
; auditInfo : LPCWSTR optional -> "sptr"
; result : WLDP_EXECUTION_POLICY* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "Wldp.dll"
#cfunc global WldpCanExecuteBuffer "WldpCanExecuteBuffer" var, int, var, int, wstr, int
; res = WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
; host : GUID* -> "var"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
; buffer : BYTE* -> "var"
; bufferSize : DWORD -> "int"
; auditInfo : LPCWSTR optional -> "wstr"
; result : WLDP_EXECUTION_POLICY* out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WldpCanExecuteBuffer(GUID* host, WLDP_EXECUTION_EVALUATION_OPTIONS options, BYTE* buffer, DWORD bufferSize, LPCWSTR auditInfo, WLDP_EXECUTION_POLICY* result)
#uselib "Wldp.dll"
#cfunc global WldpCanExecuteBuffer "WldpCanExecuteBuffer" var, int, var, int, wstr, int
; res = WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
; host : GUID* -> "var"
; options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
; buffer : BYTE* -> "var"
; bufferSize : DWORD -> "int"
; auditInfo : LPCWSTR optional -> "wstr"
; result : WLDP_EXECUTION_POLICY* out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldp = windows.NewLazySystemDLL("Wldp.dll")
	procWldpCanExecuteBuffer = wldp.NewProc("WldpCanExecuteBuffer")
)

// host (GUID*), options (WLDP_EXECUTION_EVALUATION_OPTIONS), buffer (BYTE*), bufferSize (DWORD), auditInfo (LPCWSTR optional), result (WLDP_EXECUTION_POLICY* out)
r1, _, err := procWldpCanExecuteBuffer.Call(
	uintptr(host),
	uintptr(options),
	uintptr(buffer),
	uintptr(bufferSize),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(auditInfo))),
	uintptr(result),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WldpCanExecuteBuffer(
  host: PGUID;   // GUID*
  options: Integer;   // WLDP_EXECUTION_EVALUATION_OPTIONS
  buffer: Pointer;   // BYTE*
  bufferSize: DWORD;   // DWORD
  auditInfo: PWideChar;   // LPCWSTR optional
  result: Pointer   // WLDP_EXECUTION_POLICY* out
): Integer; stdcall;
  external 'Wldp.dll' name 'WldpCanExecuteBuffer';
result := DllCall("Wldp\WldpCanExecuteBuffer"
    , "Ptr", host   ; GUID*
    , "Int", options   ; WLDP_EXECUTION_EVALUATION_OPTIONS
    , "Ptr", buffer   ; BYTE*
    , "UInt", bufferSize   ; DWORD
    , "WStr", auditInfo   ; LPCWSTR optional
    , "Ptr", result   ; WLDP_EXECUTION_POLICY* out
    , "Int")   ; return: HRESULT
●WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result) = DLL("Wldp.dll", "int WldpCanExecuteBuffer(void*, int, void*, dword, char*, void*)")
# 呼び出し: WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
# host : GUID* -> "void*"
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "int"
# buffer : BYTE* -> "void*"
# bufferSize : DWORD -> "dword"
# auditInfo : LPCWSTR optional -> "char*"
# result : WLDP_EXECUTION_POLICY* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。