ホーム › Networking.ActiveDirectory › ReallocADsMem
ReallocADsMem
関数ADSI用メモリブロックのサイズを再確保する。
シグネチャ
// ACTIVEDS.dll
#include <windows.h>
void* ReallocADsMem(
void* pOldMem,
DWORD cbOld,
DWORD cbNew
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pOldMem | void* | inout | 再割り当て元の既存メモリブロックへのポインタ。内容が新ブロックへコピーされる。 |
| cbOld | DWORD | in | 既存ブロックの現在のバイト数。コピー量の決定に用いる。 |
| cbNew | DWORD | in | 新たに確保するブロックのバイト数。拡大または縮小を指定する。 |
戻り値の型: void*
各言語での呼び出し定義
// ACTIVEDS.dll
#include <windows.h>
void* ReallocADsMem(
void* pOldMem,
DWORD cbOld,
DWORD cbNew
);[DllImport("ACTIVEDS.dll", ExactSpelling = true)]
static extern IntPtr ReallocADsMem(
IntPtr pOldMem, // void* in/out
uint cbOld, // DWORD
uint cbNew // DWORD
);<DllImport("ACTIVEDS.dll", ExactSpelling:=True)>
Public Shared Function ReallocADsMem(
pOldMem As IntPtr, ' void* in/out
cbOld As UInteger, ' DWORD
cbNew As UInteger ' DWORD
) As IntPtr
End Function' pOldMem : void* in/out
' cbOld : DWORD
' cbNew : DWORD
Declare PtrSafe Function ReallocADsMem Lib "activeds" ( _
ByVal pOldMem As LongPtr, _
ByVal cbOld As Long, _
ByVal cbNew As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ReallocADsMem = ctypes.windll.activeds.ReallocADsMem
ReallocADsMem.restype = ctypes.c_void_p
ReallocADsMem.argtypes = [
ctypes.POINTER(None), # pOldMem : void* in/out
wintypes.DWORD, # cbOld : DWORD
wintypes.DWORD, # cbNew : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ACTIVEDS.dll')
ReallocADsMem = Fiddle::Function.new(
lib['ReallocADsMem'],
[
Fiddle::TYPE_VOIDP, # pOldMem : void* in/out
-Fiddle::TYPE_INT, # cbOld : DWORD
-Fiddle::TYPE_INT, # cbNew : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "activeds")]
extern "system" {
fn ReallocADsMem(
pOldMem: *mut (), // void* in/out
cbOld: u32, // DWORD
cbNew: u32 // DWORD
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ACTIVEDS.dll")]
public static extern IntPtr ReallocADsMem(IntPtr pOldMem, uint cbOld, uint cbNew);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ACTIVEDS_ReallocADsMem' -Namespace Win32 -PassThru
# $api::ReallocADsMem(pOldMem, cbOld, cbNew)#uselib "ACTIVEDS.dll"
#func global ReallocADsMem "ReallocADsMem" sptr, sptr, sptr
; ReallocADsMem pOldMem, cbOld, cbNew ; 戻り値は stat
; pOldMem : void* in/out -> "sptr"
; cbOld : DWORD -> "sptr"
; cbNew : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ACTIVEDS.dll"
#cfunc global ReallocADsMem "ReallocADsMem" sptr, int, int
; res = ReallocADsMem(pOldMem, cbOld, cbNew)
; pOldMem : void* in/out -> "sptr"
; cbOld : DWORD -> "int"
; cbNew : DWORD -> "int"; void* ReallocADsMem(void* pOldMem, DWORD cbOld, DWORD cbNew)
#uselib "ACTIVEDS.dll"
#cfunc global ReallocADsMem "ReallocADsMem" intptr, int, int
; res = ReallocADsMem(pOldMem, cbOld, cbNew)
; pOldMem : void* in/out -> "intptr"
; cbOld : DWORD -> "int"
; cbNew : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
activeds = windows.NewLazySystemDLL("ACTIVEDS.dll")
procReallocADsMem = activeds.NewProc("ReallocADsMem")
)
// pOldMem (void* in/out), cbOld (DWORD), cbNew (DWORD)
r1, _, err := procReallocADsMem.Call(
uintptr(pOldMem),
uintptr(cbOld),
uintptr(cbNew),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function ReallocADsMem(
pOldMem: Pointer; // void* in/out
cbOld: DWORD; // DWORD
cbNew: DWORD // DWORD
): Pointer; stdcall;
external 'ACTIVEDS.dll' name 'ReallocADsMem';result := DllCall("ACTIVEDS\ReallocADsMem"
, "Ptr", pOldMem ; void* in/out
, "UInt", cbOld ; DWORD
, "UInt", cbNew ; DWORD
, "Ptr") ; return: void*●ReallocADsMem(pOldMem, cbOld, cbNew) = DLL("ACTIVEDS.dll", "void* ReallocADsMem(void*, dword, dword)")
# 呼び出し: ReallocADsMem(pOldMem, cbOld, cbNew)
# pOldMem : void* in/out -> "void*"
# cbOld : DWORD -> "dword"
# cbNew : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "activeds" fn ReallocADsMem(
pOldMem: ?*anyopaque, // void* in/out
cbOld: u32, // DWORD
cbNew: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc ReallocADsMem(
pOldMem: pointer, # void* in/out
cbOld: uint32, # DWORD
cbNew: uint32 # DWORD
): pointer {.importc: "ReallocADsMem", stdcall, dynlib: "ACTIVEDS.dll".}pragma(lib, "activeds");
extern(Windows)
void* ReallocADsMem(
void* pOldMem, // void* in/out
uint cbOld, // DWORD
uint cbNew // DWORD
);ccall((:ReallocADsMem, "ACTIVEDS.dll"), stdcall, Ptr{Cvoid},
(Ptr{Cvoid}, UInt32, UInt32),
pOldMem, cbOld, cbNew)
# pOldMem : void* in/out -> Ptr{Cvoid}
# cbOld : DWORD -> UInt32
# cbNew : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* ReallocADsMem(
void* pOldMem,
uint32_t cbOld,
uint32_t cbNew);
]]
local activeds = ffi.load("activeds")
-- activeds.ReallocADsMem(pOldMem, cbOld, cbNew)
-- pOldMem : void* in/out
-- cbOld : DWORD
-- cbNew : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ACTIVEDS.dll');
const ReallocADsMem = lib.func('__stdcall', 'ReallocADsMem', 'void *', ['void *', 'uint32_t', 'uint32_t']);
// ReallocADsMem(pOldMem, cbOld, cbNew)
// pOldMem : void* in/out -> 'void *'
// cbOld : DWORD -> 'uint32_t'
// cbNew : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ACTIVEDS.dll", {
ReallocADsMem: { parameters: ["pointer", "u32", "u32"], result: "pointer" },
});
// lib.symbols.ReallocADsMem(pOldMem, cbOld, cbNew)
// pOldMem : void* in/out -> "pointer"
// cbOld : DWORD -> "u32"
// cbNew : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* ReallocADsMem(
void* pOldMem,
uint32_t cbOld,
uint32_t cbNew);
C, "ACTIVEDS.dll");
// $ffi->ReallocADsMem(pOldMem, cbOld, cbNew);
// pOldMem : void* in/out
// cbOld : DWORD
// cbNew : DWORD
// 構造体/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 Activeds extends StdCallLibrary {
Activeds INSTANCE = Native.load("activeds", Activeds.class);
Pointer ReallocADsMem(
Pointer pOldMem, // void* in/out
int cbOld, // DWORD
int cbNew // DWORD
);
}@[Link("activeds")]
lib LibACTIVEDS
fun ReallocADsMem = ReallocADsMem(
pOldMem : Void*, # void* in/out
cbOld : UInt32, # DWORD
cbNew : UInt32 # DWORD
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ReallocADsMemNative = Pointer<Void> Function(Pointer<Void>, Uint32, Uint32);
typedef ReallocADsMemDart = Pointer<Void> Function(Pointer<Void>, int, int);
final ReallocADsMem = DynamicLibrary.open('ACTIVEDS.dll')
.lookupFunction<ReallocADsMemNative, ReallocADsMemDart>('ReallocADsMem');
// pOldMem : void* in/out -> Pointer<Void>
// cbOld : DWORD -> Uint32
// cbNew : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ReallocADsMem(
pOldMem: Pointer; // void* in/out
cbOld: DWORD; // DWORD
cbNew: DWORD // DWORD
): Pointer; stdcall;
external 'ACTIVEDS.dll' name 'ReallocADsMem';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ReallocADsMem"
c_ReallocADsMem :: Ptr () -> Word32 -> Word32 -> IO (Ptr ())
-- pOldMem : void* in/out -> Ptr ()
-- cbOld : DWORD -> Word32
-- cbNew : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let reallocadsmem =
foreign "ReallocADsMem"
((ptr void) @-> uint32_t @-> uint32_t @-> returning (ptr void))
(* pOldMem : void* in/out -> (ptr void) *)
(* cbOld : DWORD -> uint32_t *)
(* cbNew : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library activeds (t "ACTIVEDS.dll"))
(cffi:use-foreign-library activeds)
(cffi:defcfun ("ReallocADsMem" realloc-ads-mem :convention :stdcall) :pointer
(p-old-mem :pointer) ; void* in/out
(cb-old :uint32) ; DWORD
(cb-new :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ReallocADsMem = Win32::API::More->new('ACTIVEDS',
'LPVOID ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)');
# my $ret = $ReallocADsMem->Call($pOldMem, $cbOld, $cbNew);
# pOldMem : void* in/out -> LPVOID
# cbOld : DWORD -> DWORD
# cbNew : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。