ホーム › System.Rpc › NdrUserMarshalUnmarshall
NdrUserMarshalUnmarshall
関数NDRでユーザー定義マーシャリング型をアンマーシャリングする。
シグネチャ
// RPCRT4.dll
#include <windows.h>
BYTE* NdrUserMarshalUnmarshall(
MIDL_STUB_MESSAGE* pStubMsg,
BYTE** ppMemory,
BYTE* pFormat,
BYTE fMustAlloc
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pStubMsg | MIDL_STUB_MESSAGE* | inout |
| ppMemory | BYTE** | inout |
| pFormat | BYTE* | inout |
| fMustAlloc | BYTE | in |
戻り値の型: BYTE*
各言語での呼び出し定義
// RPCRT4.dll
#include <windows.h>
BYTE* NdrUserMarshalUnmarshall(
MIDL_STUB_MESSAGE* pStubMsg,
BYTE** ppMemory,
BYTE* pFormat,
BYTE fMustAlloc
);[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern IntPtr NdrUserMarshalUnmarshall(
IntPtr pStubMsg, // MIDL_STUB_MESSAGE* in/out
IntPtr ppMemory, // BYTE** in/out
IntPtr pFormat, // BYTE* in/out
byte fMustAlloc // BYTE
);<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function NdrUserMarshalUnmarshall(
pStubMsg As IntPtr, ' MIDL_STUB_MESSAGE* in/out
ppMemory As IntPtr, ' BYTE** in/out
pFormat As IntPtr, ' BYTE* in/out
fMustAlloc As Byte ' BYTE
) As IntPtr
End Function' pStubMsg : MIDL_STUB_MESSAGE* in/out
' ppMemory : BYTE** in/out
' pFormat : BYTE* in/out
' fMustAlloc : BYTE
Declare PtrSafe Function NdrUserMarshalUnmarshall Lib "rpcrt4" ( _
ByVal pStubMsg As LongPtr, _
ByVal ppMemory As LongPtr, _
ByVal pFormat As LongPtr, _
ByVal fMustAlloc As Byte) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NdrUserMarshalUnmarshall = ctypes.windll.rpcrt4.NdrUserMarshalUnmarshall
NdrUserMarshalUnmarshall.restype = ctypes.c_void_p
NdrUserMarshalUnmarshall.argtypes = [
ctypes.c_void_p, # pStubMsg : MIDL_STUB_MESSAGE* in/out
ctypes.c_void_p, # ppMemory : BYTE** in/out
ctypes.POINTER(ctypes.c_ubyte), # pFormat : BYTE* in/out
ctypes.c_ubyte, # fMustAlloc : BYTE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
NdrUserMarshalUnmarshall = Fiddle::Function.new(
lib['NdrUserMarshalUnmarshall'],
[
Fiddle::TYPE_VOIDP, # pStubMsg : MIDL_STUB_MESSAGE* in/out
Fiddle::TYPE_VOIDP, # ppMemory : BYTE** in/out
Fiddle::TYPE_VOIDP, # pFormat : BYTE* in/out
-Fiddle::TYPE_CHAR, # fMustAlloc : BYTE
],
Fiddle::TYPE_VOIDP)#[link(name = "rpcrt4")]
extern "system" {
fn NdrUserMarshalUnmarshall(
pStubMsg: *mut MIDL_STUB_MESSAGE, // MIDL_STUB_MESSAGE* in/out
ppMemory: *mut *mut u8, // BYTE** in/out
pFormat: *mut u8, // BYTE* in/out
fMustAlloc: u8 // BYTE
) -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll")]
public static extern IntPtr NdrUserMarshalUnmarshall(IntPtr pStubMsg, IntPtr ppMemory, IntPtr pFormat, byte fMustAlloc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_NdrUserMarshalUnmarshall' -Namespace Win32 -PassThru
# $api::NdrUserMarshalUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc)#uselib "RPCRT4.dll"
#func global NdrUserMarshalUnmarshall "NdrUserMarshalUnmarshall" sptr, sptr, sptr, sptr
; NdrUserMarshalUnmarshall varptr(pStubMsg), varptr(ppMemory), varptr(pFormat), fMustAlloc ; 戻り値は stat
; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "sptr"
; ppMemory : BYTE** in/out -> "sptr"
; pFormat : BYTE* in/out -> "sptr"
; fMustAlloc : BYTE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RPCRT4.dll" #cfunc global NdrUserMarshalUnmarshall "NdrUserMarshalUnmarshall" var, var, var, int ; res = NdrUserMarshalUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc) ; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "var" ; ppMemory : BYTE** in/out -> "var" ; pFormat : BYTE* in/out -> "var" ; fMustAlloc : BYTE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCRT4.dll" #cfunc global NdrUserMarshalUnmarshall "NdrUserMarshalUnmarshall" sptr, sptr, sptr, int ; res = NdrUserMarshalUnmarshall(varptr(pStubMsg), varptr(ppMemory), varptr(pFormat), fMustAlloc) ; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "sptr" ; ppMemory : BYTE** in/out -> "sptr" ; pFormat : BYTE* in/out -> "sptr" ; fMustAlloc : BYTE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BYTE* NdrUserMarshalUnmarshall(MIDL_STUB_MESSAGE* pStubMsg, BYTE** ppMemory, BYTE* pFormat, BYTE fMustAlloc) #uselib "RPCRT4.dll" #cfunc global NdrUserMarshalUnmarshall "NdrUserMarshalUnmarshall" var, var, var, int ; res = NdrUserMarshalUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc) ; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "var" ; ppMemory : BYTE** in/out -> "var" ; pFormat : BYTE* in/out -> "var" ; fMustAlloc : BYTE -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BYTE* NdrUserMarshalUnmarshall(MIDL_STUB_MESSAGE* pStubMsg, BYTE** ppMemory, BYTE* pFormat, BYTE fMustAlloc) #uselib "RPCRT4.dll" #cfunc global NdrUserMarshalUnmarshall "NdrUserMarshalUnmarshall" intptr, intptr, intptr, int ; res = NdrUserMarshalUnmarshall(varptr(pStubMsg), varptr(ppMemory), varptr(pFormat), fMustAlloc) ; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "intptr" ; ppMemory : BYTE** in/out -> "intptr" ; pFormat : BYTE* in/out -> "intptr" ; fMustAlloc : BYTE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procNdrUserMarshalUnmarshall = rpcrt4.NewProc("NdrUserMarshalUnmarshall")
)
// pStubMsg (MIDL_STUB_MESSAGE* in/out), ppMemory (BYTE** in/out), pFormat (BYTE* in/out), fMustAlloc (BYTE)
r1, _, err := procNdrUserMarshalUnmarshall.Call(
uintptr(pStubMsg),
uintptr(ppMemory),
uintptr(pFormat),
uintptr(fMustAlloc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BYTE*function NdrUserMarshalUnmarshall(
pStubMsg: Pointer; // MIDL_STUB_MESSAGE* in/out
ppMemory: Pointer; // BYTE** in/out
pFormat: Pointer; // BYTE* in/out
fMustAlloc: Byte // BYTE
): Pointer; stdcall;
external 'RPCRT4.dll' name 'NdrUserMarshalUnmarshall';result := DllCall("RPCRT4\NdrUserMarshalUnmarshall"
, "Ptr", pStubMsg ; MIDL_STUB_MESSAGE* in/out
, "Ptr", ppMemory ; BYTE** in/out
, "Ptr", pFormat ; BYTE* in/out
, "UChar", fMustAlloc ; BYTE
, "Ptr") ; return: BYTE*●NdrUserMarshalUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc) = DLL("RPCRT4.dll", "void* NdrUserMarshalUnmarshall(void*, void*, void*, byte)")
# 呼び出し: NdrUserMarshalUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc)
# pStubMsg : MIDL_STUB_MESSAGE* in/out -> "void*"
# ppMemory : BYTE** in/out -> "void*"
# pFormat : BYTE* in/out -> "void*"
# fMustAlloc : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。