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呼び出し元ホストを識別するGUIDへのポインタ。
optionsWLDP_EXECUTION_EVALUATION_OPTIONSin評価動作を制御するWLDP_EXECUTION_EVALUATION_OPTIONSフラグ。
bufferBYTE*in実行可否を評価する対象データを格納したバイトバッファへのポインタ。
bufferSizeDWORDinbufferが指すデータのバイトサイズ。
auditInfoLPCWSTRinoptional監査ログに記録する付加情報の文字列(Unicode)。NULL可。
resultWLDP_EXECUTION_POLICY*out出力として実行可否ポリシー(WLDP_EXECUTION_POLICY)を受け取るポインタ。

戻り値の型: 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, varptr(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, var
; 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 -> "var"
; ※出力/バッファ引数は 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, var
; 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 -> "var"
; ※出力/バッファ引数は 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)。
const std = @import("std");

extern "wldp" fn WldpCanExecuteBuffer(
    host: [*c]GUID, // GUID*
    options: i32, // WLDP_EXECUTION_EVALUATION_OPTIONS
    buffer: [*c]u8, // BYTE*
    bufferSize: u32, // DWORD
    auditInfo: [*c]const u16, // LPCWSTR optional
    result: [*c]i32 // WLDP_EXECUTION_POLICY* out
) callconv(std.os.windows.WINAPI) i32;
proc WldpCanExecuteBuffer(
    host: ptr GUID,  # GUID*
    options: int32,  # WLDP_EXECUTION_EVALUATION_OPTIONS
    buffer: ptr uint8,  # BYTE*
    bufferSize: uint32,  # DWORD
    auditInfo: WideCString,  # LPCWSTR optional
    result: ptr int32  # WLDP_EXECUTION_POLICY* out
): int32 {.importc: "WldpCanExecuteBuffer", stdcall, dynlib: "Wldp.dll".}
pragma(lib, "wldp");
extern(Windows)
int WldpCanExecuteBuffer(
    GUID* host,   // GUID*
    int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
    ubyte* buffer,   // BYTE*
    uint bufferSize,   // DWORD
    const(wchar)* auditInfo,   // LPCWSTR optional
    int* result   // WLDP_EXECUTION_POLICY* out
);
ccall((:WldpCanExecuteBuffer, "Wldp.dll"), stdcall, Int32,
      (Ptr{GUID}, Int32, Ptr{UInt8}, UInt32, Cwstring, Ptr{Int32}),
      host, options, buffer, bufferSize, auditInfo, result)
# host : GUID* -> Ptr{GUID}
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
# buffer : BYTE* -> Ptr{UInt8}
# bufferSize : DWORD -> UInt32
# auditInfo : LPCWSTR optional -> Cwstring
# result : WLDP_EXECUTION_POLICY* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WldpCanExecuteBuffer(
    void* host,
    int32_t options,
    uint8_t* buffer,
    uint32_t bufferSize,
    const uint16_t* auditInfo,
    int32_t* result);
]]
local wldp = ffi.load("wldp")
-- wldp.WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
-- host : GUID*
-- options : WLDP_EXECUTION_EVALUATION_OPTIONS
-- buffer : BYTE*
-- bufferSize : DWORD
-- auditInfo : LPCWSTR optional
-- result : WLDP_EXECUTION_POLICY* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('Wldp.dll');
const WldpCanExecuteBuffer = lib.func('__stdcall', 'WldpCanExecuteBuffer', 'int32_t', ['void *', 'int32_t', 'uint8_t *', 'uint32_t', 'str16', 'int32_t *']);
// WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
// host : GUID* -> 'void *'
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> 'int32_t'
// buffer : BYTE* -> 'uint8_t *'
// bufferSize : DWORD -> 'uint32_t'
// auditInfo : LPCWSTR optional -> 'str16'
// result : WLDP_EXECUTION_POLICY* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("Wldp.dll", {
  WldpCanExecuteBuffer: { parameters: ["pointer", "i32", "pointer", "u32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result)
// host : GUID* -> "pointer"
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> "i32"
// buffer : BYTE* -> "pointer"
// bufferSize : DWORD -> "u32"
// auditInfo : LPCWSTR optional -> "buffer"
// result : WLDP_EXECUTION_POLICY* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WldpCanExecuteBuffer(
    void* host,
    int32_t options,
    uint8_t* buffer,
    uint32_t bufferSize,
    const uint16_t* auditInfo,
    int32_t* result);
C, "Wldp.dll");
// $ffi->WldpCanExecuteBuffer(host, options, buffer, bufferSize, auditInfo, result);
// host : GUID*
// options : WLDP_EXECUTION_EVALUATION_OPTIONS
// buffer : BYTE*
// bufferSize : DWORD
// auditInfo : LPCWSTR optional
// result : WLDP_EXECUTION_POLICY* 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 Wldp extends StdCallLibrary {
    Wldp INSTANCE = Native.load("wldp", Wldp.class);
    int WldpCanExecuteBuffer(
        Pointer host,   // GUID*
        int options,   // WLDP_EXECUTION_EVALUATION_OPTIONS
        byte[] buffer,   // BYTE*
        int bufferSize,   // DWORD
        WString auditInfo,   // LPCWSTR optional
        IntByReference result   // WLDP_EXECUTION_POLICY* out
    );
}
@[Link("wldp")]
lib LibWldp
  fun WldpCanExecuteBuffer = WldpCanExecuteBuffer(
    host : GUID*,   # GUID*
    options : Int32,   # WLDP_EXECUTION_EVALUATION_OPTIONS
    buffer : UInt8*,   # BYTE*
    bufferSize : UInt32,   # DWORD
    auditInfo : UInt16*,   # LPCWSTR optional
    result : Int32*   # WLDP_EXECUTION_POLICY* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WldpCanExecuteBufferNative = Int32 Function(Pointer<Void>, Int32, Pointer<Uint8>, Uint32, Pointer<Utf16>, Pointer<Int32>);
typedef WldpCanExecuteBufferDart = int Function(Pointer<Void>, int, Pointer<Uint8>, int, Pointer<Utf16>, Pointer<Int32>);
final WldpCanExecuteBuffer = DynamicLibrary.open('Wldp.dll')
    .lookupFunction<WldpCanExecuteBufferNative, WldpCanExecuteBufferDart>('WldpCanExecuteBuffer');
// host : GUID* -> Pointer<Void>
// options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
// buffer : BYTE* -> Pointer<Uint8>
// bufferSize : DWORD -> Uint32
// auditInfo : LPCWSTR optional -> Pointer<Utf16>
// result : WLDP_EXECUTION_POLICY* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WldpCanExecuteBuffer"
  c_WldpCanExecuteBuffer :: Ptr () -> Int32 -> Ptr Word8 -> Word32 -> CWString -> Ptr Int32 -> IO Int32
-- host : GUID* -> Ptr ()
-- options : WLDP_EXECUTION_EVALUATION_OPTIONS -> Int32
-- buffer : BYTE* -> Ptr Word8
-- bufferSize : DWORD -> Word32
-- auditInfo : LPCWSTR optional -> CWString
-- result : WLDP_EXECUTION_POLICY* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wldpcanexecutebuffer =
  foreign "WldpCanExecuteBuffer"
    ((ptr void) @-> int32_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr int32_t) @-> returning int32_t)
(* host : GUID* -> (ptr void) *)
(* options : WLDP_EXECUTION_EVALUATION_OPTIONS -> int32_t *)
(* buffer : BYTE* -> (ptr uint8_t) *)
(* bufferSize : DWORD -> uint32_t *)
(* auditInfo : LPCWSTR optional -> (ptr uint16_t) *)
(* result : WLDP_EXECUTION_POLICY* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wldp (t "Wldp.dll"))
(cffi:use-foreign-library wldp)

(cffi:defcfun ("WldpCanExecuteBuffer" wldp-can-execute-buffer :convention :stdcall) :int32
  (host :pointer)   ; GUID*
  (options :int32)   ; WLDP_EXECUTION_EVALUATION_OPTIONS
  (buffer :pointer)   ; BYTE*
  (buffer-size :uint32)   ; DWORD
  (audit-info (:string :encoding :utf-16le))   ; LPCWSTR optional
  (result :pointer))   ; WLDP_EXECUTION_POLICY* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WldpCanExecuteBuffer = Win32::API::More->new('Wldp',
    'int WldpCanExecuteBuffer(LPVOID host, int options, LPVOID buffer, DWORD bufferSize, LPCWSTR auditInfo, LPVOID result)');
# my $ret = $WldpCanExecuteBuffer->Call($host, $options, $buffer, $bufferSize, $auditInfo, $result);
# host : GUID* -> LPVOID
# options : WLDP_EXECUTION_EVALUATION_OPTIONS -> int
# buffer : BYTE* -> LPVOID
# bufferSize : DWORD -> DWORD
# auditInfo : LPCWSTR optional -> LPCWSTR
# result : WLDP_EXECUTION_POLICY* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型