ホーム › System.Memory › SetProcessValidCallTargetsForMappedView
SetProcessValidCallTargetsForMappedView
関数マップビューに対しCFG有効呼び出しターゲットを設定する。
シグネチャ
// api-ms-win-core-memory-l1-1-7.dll
#include <windows.h>
BOOL SetProcessValidCallTargetsForMappedView(
HANDLE Process,
void* VirtualAddress,
UINT_PTR RegionSize,
DWORD NumberOfOffsets,
CFG_CALL_TARGET_INFO* OffsetInformation,
HANDLE Section,
ULONGLONG ExpectedFileOffset
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Process | HANDLE | in | CFG有効呼び出し先を設定する対象プロセスのハンドル。 |
| VirtualAddress | void* | in | 対象マップビュー領域の開始アドレス。 |
| RegionSize | UINT_PTR | in | 対象領域のバイト数。 |
| NumberOfOffsets | DWORD | in | OffsetInformation配列の要素数。 |
| OffsetInformation | CFG_CALL_TARGET_INFO* | inout | 各呼び出し先のオフセットと有効化フラグを示すCFG_CALL_TARGET_INFO配列。 |
| Section | HANDLE | in | マップ元セクションオブジェクトのハンドル。 |
| ExpectedFileOffset | ULONGLONG | in | セクション内で期待されるファイルオフセット。 |
戻り値の型: BOOL
各言語での呼び出し定義
// api-ms-win-core-memory-l1-1-7.dll
#include <windows.h>
BOOL SetProcessValidCallTargetsForMappedView(
HANDLE Process,
void* VirtualAddress,
UINT_PTR RegionSize,
DWORD NumberOfOffsets,
CFG_CALL_TARGET_INFO* OffsetInformation,
HANDLE Section,
ULONGLONG ExpectedFileOffset
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-7.dll", ExactSpelling = true)]
static extern bool SetProcessValidCallTargetsForMappedView(
IntPtr Process, // HANDLE
IntPtr VirtualAddress, // void*
UIntPtr RegionSize, // UINT_PTR
uint NumberOfOffsets, // DWORD
IntPtr OffsetInformation, // CFG_CALL_TARGET_INFO* in/out
IntPtr Section, // HANDLE
ulong ExpectedFileOffset // ULONGLONG
);<DllImport("api-ms-win-core-memory-l1-1-7.dll", ExactSpelling:=True)>
Public Shared Function SetProcessValidCallTargetsForMappedView(
Process As IntPtr, ' HANDLE
VirtualAddress As IntPtr, ' void*
RegionSize As UIntPtr, ' UINT_PTR
NumberOfOffsets As UInteger, ' DWORD
OffsetInformation As IntPtr, ' CFG_CALL_TARGET_INFO* in/out
Section As IntPtr, ' HANDLE
ExpectedFileOffset As ULong ' ULONGLONG
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' Process : HANDLE
' VirtualAddress : void*
' RegionSize : UINT_PTR
' NumberOfOffsets : DWORD
' OffsetInformation : CFG_CALL_TARGET_INFO* in/out
' Section : HANDLE
' ExpectedFileOffset : ULONGLONG
Declare PtrSafe Function SetProcessValidCallTargetsForMappedView Lib "api-ms-win-core-memory-l1-1-7" ( _
ByVal Process As LongPtr, _
ByVal VirtualAddress As LongPtr, _
ByVal RegionSize As LongPtr, _
ByVal NumberOfOffsets As Long, _
ByVal OffsetInformation As LongPtr, _
ByVal Section As LongPtr, _
ByVal ExpectedFileOffset As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetProcessValidCallTargetsForMappedView = ctypes.windll.LoadLibrary("api-ms-win-core-memory-l1-1-7.dll").SetProcessValidCallTargetsForMappedView
SetProcessValidCallTargetsForMappedView.restype = wintypes.BOOL
SetProcessValidCallTargetsForMappedView.argtypes = [
wintypes.HANDLE, # Process : HANDLE
ctypes.POINTER(None), # VirtualAddress : void*
ctypes.c_size_t, # RegionSize : UINT_PTR
wintypes.DWORD, # NumberOfOffsets : DWORD
ctypes.c_void_p, # OffsetInformation : CFG_CALL_TARGET_INFO* in/out
wintypes.HANDLE, # Section : HANDLE
ctypes.c_ulonglong, # ExpectedFileOffset : ULONGLONG
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-memory-l1-1-7.dll')
SetProcessValidCallTargetsForMappedView = Fiddle::Function.new(
lib['SetProcessValidCallTargetsForMappedView'],
[
Fiddle::TYPE_VOIDP, # Process : HANDLE
Fiddle::TYPE_VOIDP, # VirtualAddress : void*
Fiddle::TYPE_UINTPTR_T, # RegionSize : UINT_PTR
-Fiddle::TYPE_INT, # NumberOfOffsets : DWORD
Fiddle::TYPE_VOIDP, # OffsetInformation : CFG_CALL_TARGET_INFO* in/out
Fiddle::TYPE_VOIDP, # Section : HANDLE
-Fiddle::TYPE_LONG_LONG, # ExpectedFileOffset : ULONGLONG
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-memory-l1-1-7")]
extern "system" {
fn SetProcessValidCallTargetsForMappedView(
Process: *mut core::ffi::c_void, // HANDLE
VirtualAddress: *mut (), // void*
RegionSize: usize, // UINT_PTR
NumberOfOffsets: u32, // DWORD
OffsetInformation: *mut CFG_CALL_TARGET_INFO, // CFG_CALL_TARGET_INFO* in/out
Section: *mut core::ffi::c_void, // HANDLE
ExpectedFileOffset: u64 // ULONGLONG
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-7.dll")]
public static extern bool SetProcessValidCallTargetsForMappedView(IntPtr Process, IntPtr VirtualAddress, UIntPtr RegionSize, uint NumberOfOffsets, IntPtr OffsetInformation, IntPtr Section, ulong ExpectedFileOffset);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-memory-l1-1-7_SetProcessValidCallTargetsForMappedView' -Namespace Win32 -PassThru
# $api::SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)#uselib "api-ms-win-core-memory-l1-1-7.dll"
#func global SetProcessValidCallTargetsForMappedView "SetProcessValidCallTargetsForMappedView" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetProcessValidCallTargetsForMappedView Process, VirtualAddress, RegionSize, NumberOfOffsets, varptr(OffsetInformation), Section, ExpectedFileOffset ; 戻り値は stat
; Process : HANDLE -> "sptr"
; VirtualAddress : void* -> "sptr"
; RegionSize : UINT_PTR -> "sptr"
; NumberOfOffsets : DWORD -> "sptr"
; OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "sptr"
; Section : HANDLE -> "sptr"
; ExpectedFileOffset : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-memory-l1-1-7.dll" #cfunc global SetProcessValidCallTargetsForMappedView "SetProcessValidCallTargetsForMappedView" sptr, sptr, sptr, int, var, sptr, int64 ; res = SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset) ; Process : HANDLE -> "sptr" ; VirtualAddress : void* -> "sptr" ; RegionSize : UINT_PTR -> "sptr" ; NumberOfOffsets : DWORD -> "int" ; OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "var" ; Section : HANDLE -> "sptr" ; ExpectedFileOffset : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "api-ms-win-core-memory-l1-1-7.dll" #cfunc global SetProcessValidCallTargetsForMappedView "SetProcessValidCallTargetsForMappedView" sptr, sptr, sptr, int, sptr, sptr, int64 ; res = SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, varptr(OffsetInformation), Section, ExpectedFileOffset) ; Process : HANDLE -> "sptr" ; VirtualAddress : void* -> "sptr" ; RegionSize : UINT_PTR -> "sptr" ; NumberOfOffsets : DWORD -> "int" ; OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "sptr" ; Section : HANDLE -> "sptr" ; ExpectedFileOffset : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; BOOL SetProcessValidCallTargetsForMappedView(HANDLE Process, void* VirtualAddress, UINT_PTR RegionSize, DWORD NumberOfOffsets, CFG_CALL_TARGET_INFO* OffsetInformation, HANDLE Section, ULONGLONG ExpectedFileOffset) #uselib "api-ms-win-core-memory-l1-1-7.dll" #cfunc global SetProcessValidCallTargetsForMappedView "SetProcessValidCallTargetsForMappedView" intptr, intptr, intptr, int, var, intptr, int64 ; res = SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset) ; Process : HANDLE -> "intptr" ; VirtualAddress : void* -> "intptr" ; RegionSize : UINT_PTR -> "intptr" ; NumberOfOffsets : DWORD -> "int" ; OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "var" ; Section : HANDLE -> "intptr" ; ExpectedFileOffset : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetProcessValidCallTargetsForMappedView(HANDLE Process, void* VirtualAddress, UINT_PTR RegionSize, DWORD NumberOfOffsets, CFG_CALL_TARGET_INFO* OffsetInformation, HANDLE Section, ULONGLONG ExpectedFileOffset) #uselib "api-ms-win-core-memory-l1-1-7.dll" #cfunc global SetProcessValidCallTargetsForMappedView "SetProcessValidCallTargetsForMappedView" intptr, intptr, intptr, int, intptr, intptr, int64 ; res = SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, varptr(OffsetInformation), Section, ExpectedFileOffset) ; Process : HANDLE -> "intptr" ; VirtualAddress : void* -> "intptr" ; RegionSize : UINT_PTR -> "intptr" ; NumberOfOffsets : DWORD -> "int" ; OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "intptr" ; Section : HANDLE -> "intptr" ; ExpectedFileOffset : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_memory_l1_1_7 = windows.NewLazySystemDLL("api-ms-win-core-memory-l1-1-7.dll")
procSetProcessValidCallTargetsForMappedView = api_ms_win_core_memory_l1_1_7.NewProc("SetProcessValidCallTargetsForMappedView")
)
// Process (HANDLE), VirtualAddress (void*), RegionSize (UINT_PTR), NumberOfOffsets (DWORD), OffsetInformation (CFG_CALL_TARGET_INFO* in/out), Section (HANDLE), ExpectedFileOffset (ULONGLONG)
r1, _, err := procSetProcessValidCallTargetsForMappedView.Call(
uintptr(Process),
uintptr(VirtualAddress),
uintptr(RegionSize),
uintptr(NumberOfOffsets),
uintptr(OffsetInformation),
uintptr(Section),
uintptr(ExpectedFileOffset),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetProcessValidCallTargetsForMappedView(
Process: THandle; // HANDLE
VirtualAddress: Pointer; // void*
RegionSize: NativeUInt; // UINT_PTR
NumberOfOffsets: DWORD; // DWORD
OffsetInformation: Pointer; // CFG_CALL_TARGET_INFO* in/out
Section: THandle; // HANDLE
ExpectedFileOffset: UInt64 // ULONGLONG
): BOOL; stdcall;
external 'api-ms-win-core-memory-l1-1-7.dll' name 'SetProcessValidCallTargetsForMappedView';result := DllCall("api-ms-win-core-memory-l1-1-7\SetProcessValidCallTargetsForMappedView"
, "Ptr", Process ; HANDLE
, "Ptr", VirtualAddress ; void*
, "UPtr", RegionSize ; UINT_PTR
, "UInt", NumberOfOffsets ; DWORD
, "Ptr", OffsetInformation ; CFG_CALL_TARGET_INFO* in/out
, "Ptr", Section ; HANDLE
, "Int64", ExpectedFileOffset ; ULONGLONG
, "Int") ; return: BOOL●SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset) = DLL("api-ms-win-core-memory-l1-1-7.dll", "bool SetProcessValidCallTargetsForMappedView(void*, void*, int, dword, void*, void*, qword)")
# 呼び出し: SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)
# Process : HANDLE -> "void*"
# VirtualAddress : void* -> "void*"
# RegionSize : UINT_PTR -> "int"
# NumberOfOffsets : DWORD -> "dword"
# OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "void*"
# Section : HANDLE -> "void*"
# ExpectedFileOffset : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-memory-l1-1-7" fn SetProcessValidCallTargetsForMappedView(
Process: ?*anyopaque, // HANDLE
VirtualAddress: ?*anyopaque, // void*
RegionSize: usize, // UINT_PTR
NumberOfOffsets: u32, // DWORD
OffsetInformation: [*c]CFG_CALL_TARGET_INFO, // CFG_CALL_TARGET_INFO* in/out
Section: ?*anyopaque, // HANDLE
ExpectedFileOffset: u64 // ULONGLONG
) callconv(std.os.windows.WINAPI) i32;proc SetProcessValidCallTargetsForMappedView(
Process: pointer, # HANDLE
VirtualAddress: pointer, # void*
RegionSize: uint, # UINT_PTR
NumberOfOffsets: uint32, # DWORD
OffsetInformation: ptr CFG_CALL_TARGET_INFO, # CFG_CALL_TARGET_INFO* in/out
Section: pointer, # HANDLE
ExpectedFileOffset: uint64 # ULONGLONG
): int32 {.importc: "SetProcessValidCallTargetsForMappedView", stdcall, dynlib: "api-ms-win-core-memory-l1-1-7.dll".}pragma(lib, "api-ms-win-core-memory-l1-1-7");
extern(Windows)
int SetProcessValidCallTargetsForMappedView(
void* Process, // HANDLE
void* VirtualAddress, // void*
size_t RegionSize, // UINT_PTR
uint NumberOfOffsets, // DWORD
CFG_CALL_TARGET_INFO* OffsetInformation, // CFG_CALL_TARGET_INFO* in/out
void* Section, // HANDLE
ulong ExpectedFileOffset // ULONGLONG
);ccall((:SetProcessValidCallTargetsForMappedView, "api-ms-win-core-memory-l1-1-7.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Csize_t, UInt32, Ptr{CFG_CALL_TARGET_INFO}, Ptr{Cvoid}, UInt64),
Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)
# Process : HANDLE -> Ptr{Cvoid}
# VirtualAddress : void* -> Ptr{Cvoid}
# RegionSize : UINT_PTR -> Csize_t
# NumberOfOffsets : DWORD -> UInt32
# OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> Ptr{CFG_CALL_TARGET_INFO}
# Section : HANDLE -> Ptr{Cvoid}
# ExpectedFileOffset : ULONGLONG -> UInt64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetProcessValidCallTargetsForMappedView(
void* Process,
void* VirtualAddress,
uintptr_t RegionSize,
uint32_t NumberOfOffsets,
void* OffsetInformation,
void* Section,
uint64_t ExpectedFileOffset);
]]
local api-ms-win-core-memory-l1-1-7 = ffi.load("api-ms-win-core-memory-l1-1-7")
-- api-ms-win-core-memory-l1-1-7.SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)
-- Process : HANDLE
-- VirtualAddress : void*
-- RegionSize : UINT_PTR
-- NumberOfOffsets : DWORD
-- OffsetInformation : CFG_CALL_TARGET_INFO* in/out
-- Section : HANDLE
-- ExpectedFileOffset : ULONGLONG
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-memory-l1-1-7.dll');
const SetProcessValidCallTargetsForMappedView = lib.func('__stdcall', 'SetProcessValidCallTargetsForMappedView', 'int32_t', ['void *', 'void *', 'uintptr_t', 'uint32_t', 'void *', 'void *', 'uint64_t']);
// SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)
// Process : HANDLE -> 'void *'
// VirtualAddress : void* -> 'void *'
// RegionSize : UINT_PTR -> 'uintptr_t'
// NumberOfOffsets : DWORD -> 'uint32_t'
// OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> 'void *'
// Section : HANDLE -> 'void *'
// ExpectedFileOffset : ULONGLONG -> 'uint64_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-memory-l1-1-7.dll", {
SetProcessValidCallTargetsForMappedView: { parameters: ["pointer", "pointer", "usize", "u32", "pointer", "pointer", "u64"], result: "i32" },
});
// lib.symbols.SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset)
// Process : HANDLE -> "pointer"
// VirtualAddress : void* -> "pointer"
// RegionSize : UINT_PTR -> "usize"
// NumberOfOffsets : DWORD -> "u32"
// OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> "pointer"
// Section : HANDLE -> "pointer"
// ExpectedFileOffset : ULONGLONG -> "u64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetProcessValidCallTargetsForMappedView(
void* Process,
void* VirtualAddress,
size_t RegionSize,
uint32_t NumberOfOffsets,
void* OffsetInformation,
void* Section,
uint64_t ExpectedFileOffset);
C, "api-ms-win-core-memory-l1-1-7.dll");
// $ffi->SetProcessValidCallTargetsForMappedView(Process, VirtualAddress, RegionSize, NumberOfOffsets, OffsetInformation, Section, ExpectedFileOffset);
// Process : HANDLE
// VirtualAddress : void*
// RegionSize : UINT_PTR
// NumberOfOffsets : DWORD
// OffsetInformation : CFG_CALL_TARGET_INFO* in/out
// Section : HANDLE
// ExpectedFileOffset : ULONGLONG
// 構造体/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 Api-ms-win-core-memory-l1-1-7 extends StdCallLibrary {
Api-ms-win-core-memory-l1-1-7 INSTANCE = Native.load("api-ms-win-core-memory-l1-1-7", Api-ms-win-core-memory-l1-1-7.class);
boolean SetProcessValidCallTargetsForMappedView(
Pointer Process, // HANDLE
Pointer VirtualAddress, // void*
long RegionSize, // UINT_PTR
int NumberOfOffsets, // DWORD
Pointer OffsetInformation, // CFG_CALL_TARGET_INFO* in/out
Pointer Section, // HANDLE
long ExpectedFileOffset // ULONGLONG
);
}@[Link("api-ms-win-core-memory-l1-1-7")]
lib Libapi-ms-win-core-memory-l1-1-7
fun SetProcessValidCallTargetsForMappedView = SetProcessValidCallTargetsForMappedView(
Process : Void*, # HANDLE
VirtualAddress : Void*, # void*
RegionSize : LibC::SizeT, # UINT_PTR
NumberOfOffsets : UInt32, # DWORD
OffsetInformation : CFG_CALL_TARGET_INFO*, # CFG_CALL_TARGET_INFO* in/out
Section : Void*, # HANDLE
ExpectedFileOffset : UInt64 # ULONGLONG
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetProcessValidCallTargetsForMappedViewNative = Int32 Function(Pointer<Void>, Pointer<Void>, UintPtr, Uint32, Pointer<Void>, Pointer<Void>, Uint64);
typedef SetProcessValidCallTargetsForMappedViewDart = int Function(Pointer<Void>, Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>, int);
final SetProcessValidCallTargetsForMappedView = DynamicLibrary.open('api-ms-win-core-memory-l1-1-7.dll')
.lookupFunction<SetProcessValidCallTargetsForMappedViewNative, SetProcessValidCallTargetsForMappedViewDart>('SetProcessValidCallTargetsForMappedView');
// Process : HANDLE -> Pointer<Void>
// VirtualAddress : void* -> Pointer<Void>
// RegionSize : UINT_PTR -> UintPtr
// NumberOfOffsets : DWORD -> Uint32
// OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> Pointer<Void>
// Section : HANDLE -> Pointer<Void>
// ExpectedFileOffset : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetProcessValidCallTargetsForMappedView(
Process: THandle; // HANDLE
VirtualAddress: Pointer; // void*
RegionSize: NativeUInt; // UINT_PTR
NumberOfOffsets: DWORD; // DWORD
OffsetInformation: Pointer; // CFG_CALL_TARGET_INFO* in/out
Section: THandle; // HANDLE
ExpectedFileOffset: UInt64 // ULONGLONG
): BOOL; stdcall;
external 'api-ms-win-core-memory-l1-1-7.dll' name 'SetProcessValidCallTargetsForMappedView';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetProcessValidCallTargetsForMappedView"
c_SetProcessValidCallTargetsForMappedView :: Ptr () -> Ptr () -> CUIntPtr -> Word32 -> Ptr () -> Ptr () -> Word64 -> IO CInt
-- Process : HANDLE -> Ptr ()
-- VirtualAddress : void* -> Ptr ()
-- RegionSize : UINT_PTR -> CUIntPtr
-- NumberOfOffsets : DWORD -> Word32
-- OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> Ptr ()
-- Section : HANDLE -> Ptr ()
-- ExpectedFileOffset : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setprocessvalidcalltargetsformappedview =
foreign "SetProcessValidCallTargetsForMappedView"
((ptr void) @-> (ptr void) @-> size_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> uint64_t @-> returning int32_t)
(* Process : HANDLE -> (ptr void) *)
(* VirtualAddress : void* -> (ptr void) *)
(* RegionSize : UINT_PTR -> size_t *)
(* NumberOfOffsets : DWORD -> uint32_t *)
(* OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> (ptr void) *)
(* Section : HANDLE -> (ptr void) *)
(* ExpectedFileOffset : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-memory-l1-1-7 (t "api-ms-win-core-memory-l1-1-7.dll"))
(cffi:use-foreign-library api-ms-win-core-memory-l1-1-7)
(cffi:defcfun ("SetProcessValidCallTargetsForMappedView" set-process-valid-call-targets-for-mapped-view :convention :stdcall) :int32
(process :pointer) ; HANDLE
(virtual-address :pointer) ; void*
(region-size :uint64) ; UINT_PTR
(number-of-offsets :uint32) ; DWORD
(offset-information :pointer) ; CFG_CALL_TARGET_INFO* in/out
(section :pointer) ; HANDLE
(expected-file-offset :uint64)) ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetProcessValidCallTargetsForMappedView = Win32::API::More->new('api-ms-win-core-memory-l1-1-7',
'BOOL SetProcessValidCallTargetsForMappedView(HANDLE Process, LPVOID VirtualAddress, WPARAM RegionSize, DWORD NumberOfOffsets, LPVOID OffsetInformation, HANDLE Section, UINT64 ExpectedFileOffset)');
# my $ret = $SetProcessValidCallTargetsForMappedView->Call($Process, $VirtualAddress, $RegionSize, $NumberOfOffsets, $OffsetInformation, $Section, $ExpectedFileOffset);
# Process : HANDLE -> HANDLE
# VirtualAddress : void* -> LPVOID
# RegionSize : UINT_PTR -> WPARAM
# NumberOfOffsets : DWORD -> DWORD
# OffsetInformation : CFG_CALL_TARGET_INFO* in/out -> LPVOID
# Section : HANDLE -> HANDLE
# ExpectedFileOffset : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。