ホーム › System.ApplicationInstallationAndServicing › GetFilePatchSignatureByBuffer
GetFilePatchSignatureByBuffer
関数メモリバッファからパッチ用のファイル署名値を計算する。
シグネチャ
// mspatcha.dll
#include <windows.h>
BOOL GetFilePatchSignatureByBuffer(
BYTE* FileBufferWritable,
DWORD FileSize,
DWORD OptionFlags,
void* OptionData, // optional
DWORD IgnoreRangeCount,
PATCH_IGNORE_RANGE* IgnoreRangeArray, // optional
DWORD RetainRangeCount,
PATCH_RETAIN_RANGE* RetainRangeArray, // optional
DWORD SignatureBufferSize,
LPSTR SignatureBuffer
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| FileBufferWritable | BYTE* | inout |
| FileSize | DWORD | in |
| OptionFlags | DWORD | in |
| OptionData | void* | inoptional |
| IgnoreRangeCount | DWORD | in |
| IgnoreRangeArray | PATCH_IGNORE_RANGE* | inoptional |
| RetainRangeCount | DWORD | in |
| RetainRangeArray | PATCH_RETAIN_RANGE* | inoptional |
| SignatureBufferSize | DWORD | in |
| SignatureBuffer | LPSTR | out |
戻り値の型: BOOL
各言語での呼び出し定義
// mspatcha.dll
#include <windows.h>
BOOL GetFilePatchSignatureByBuffer(
BYTE* FileBufferWritable,
DWORD FileSize,
DWORD OptionFlags,
void* OptionData, // optional
DWORD IgnoreRangeCount,
PATCH_IGNORE_RANGE* IgnoreRangeArray, // optional
DWORD RetainRangeCount,
PATCH_RETAIN_RANGE* RetainRangeArray, // optional
DWORD SignatureBufferSize,
LPSTR SignatureBuffer
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll", ExactSpelling = true)]
static extern bool GetFilePatchSignatureByBuffer(
IntPtr FileBufferWritable, // BYTE* in/out
uint FileSize, // DWORD
uint OptionFlags, // DWORD
IntPtr OptionData, // void* optional
uint IgnoreRangeCount, // DWORD
IntPtr IgnoreRangeArray, // PATCH_IGNORE_RANGE* optional
uint RetainRangeCount, // DWORD
IntPtr RetainRangeArray, // PATCH_RETAIN_RANGE* optional
uint SignatureBufferSize, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder SignatureBuffer // LPSTR out
);<DllImport("mspatcha.dll", ExactSpelling:=True)>
Public Shared Function GetFilePatchSignatureByBuffer(
FileBufferWritable As IntPtr, ' BYTE* in/out
FileSize As UInteger, ' DWORD
OptionFlags As UInteger, ' DWORD
OptionData As IntPtr, ' void* optional
IgnoreRangeCount As UInteger, ' DWORD
IgnoreRangeArray As IntPtr, ' PATCH_IGNORE_RANGE* optional
RetainRangeCount As UInteger, ' DWORD
RetainRangeArray As IntPtr, ' PATCH_RETAIN_RANGE* optional
SignatureBufferSize As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> SignatureBuffer As System.Text.StringBuilder ' LPSTR out
) As Boolean
End Function' FileBufferWritable : BYTE* in/out
' FileSize : DWORD
' OptionFlags : DWORD
' OptionData : void* optional
' IgnoreRangeCount : DWORD
' IgnoreRangeArray : PATCH_IGNORE_RANGE* optional
' RetainRangeCount : DWORD
' RetainRangeArray : PATCH_RETAIN_RANGE* optional
' SignatureBufferSize : DWORD
' SignatureBuffer : LPSTR out
Declare PtrSafe Function GetFilePatchSignatureByBuffer Lib "mspatcha" ( _
ByVal FileBufferWritable As LongPtr, _
ByVal FileSize As Long, _
ByVal OptionFlags As Long, _
ByVal OptionData As LongPtr, _
ByVal IgnoreRangeCount As Long, _
ByVal IgnoreRangeArray As LongPtr, _
ByVal RetainRangeCount As Long, _
ByVal RetainRangeArray As LongPtr, _
ByVal SignatureBufferSize As Long, _
ByVal SignatureBuffer As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetFilePatchSignatureByBuffer = ctypes.windll.mspatcha.GetFilePatchSignatureByBuffer
GetFilePatchSignatureByBuffer.restype = wintypes.BOOL
GetFilePatchSignatureByBuffer.argtypes = [
ctypes.POINTER(ctypes.c_ubyte), # FileBufferWritable : BYTE* in/out
wintypes.DWORD, # FileSize : DWORD
wintypes.DWORD, # OptionFlags : DWORD
ctypes.POINTER(None), # OptionData : void* optional
wintypes.DWORD, # IgnoreRangeCount : DWORD
ctypes.c_void_p, # IgnoreRangeArray : PATCH_IGNORE_RANGE* optional
wintypes.DWORD, # RetainRangeCount : DWORD
ctypes.c_void_p, # RetainRangeArray : PATCH_RETAIN_RANGE* optional
wintypes.DWORD, # SignatureBufferSize : DWORD
wintypes.LPSTR, # SignatureBuffer : LPSTR out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mspatcha.dll')
GetFilePatchSignatureByBuffer = Fiddle::Function.new(
lib['GetFilePatchSignatureByBuffer'],
[
Fiddle::TYPE_VOIDP, # FileBufferWritable : BYTE* in/out
-Fiddle::TYPE_INT, # FileSize : DWORD
-Fiddle::TYPE_INT, # OptionFlags : DWORD
Fiddle::TYPE_VOIDP, # OptionData : void* optional
-Fiddle::TYPE_INT, # IgnoreRangeCount : DWORD
Fiddle::TYPE_VOIDP, # IgnoreRangeArray : PATCH_IGNORE_RANGE* optional
-Fiddle::TYPE_INT, # RetainRangeCount : DWORD
Fiddle::TYPE_VOIDP, # RetainRangeArray : PATCH_RETAIN_RANGE* optional
-Fiddle::TYPE_INT, # SignatureBufferSize : DWORD
Fiddle::TYPE_VOIDP, # SignatureBuffer : LPSTR out
],
Fiddle::TYPE_INT)#[link(name = "mspatcha")]
extern "system" {
fn GetFilePatchSignatureByBuffer(
FileBufferWritable: *mut u8, // BYTE* in/out
FileSize: u32, // DWORD
OptionFlags: u32, // DWORD
OptionData: *mut (), // void* optional
IgnoreRangeCount: u32, // DWORD
IgnoreRangeArray: *mut PATCH_IGNORE_RANGE, // PATCH_IGNORE_RANGE* optional
RetainRangeCount: u32, // DWORD
RetainRangeArray: *mut PATCH_RETAIN_RANGE, // PATCH_RETAIN_RANGE* optional
SignatureBufferSize: u32, // DWORD
SignatureBuffer: *mut u8 // LPSTR out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll")]
public static extern bool GetFilePatchSignatureByBuffer(IntPtr FileBufferWritable, uint FileSize, uint OptionFlags, IntPtr OptionData, uint IgnoreRangeCount, IntPtr IgnoreRangeArray, uint RetainRangeCount, IntPtr RetainRangeArray, uint SignatureBufferSize, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder SignatureBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mspatcha_GetFilePatchSignatureByBuffer' -Namespace Win32 -PassThru
# $api::GetFilePatchSignatureByBuffer(FileBufferWritable, FileSize, OptionFlags, OptionData, IgnoreRangeCount, IgnoreRangeArray, RetainRangeCount, RetainRangeArray, SignatureBufferSize, SignatureBuffer)#uselib "mspatcha.dll"
#func global GetFilePatchSignatureByBuffer "GetFilePatchSignatureByBuffer" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetFilePatchSignatureByBuffer varptr(FileBufferWritable), FileSize, OptionFlags, OptionData, IgnoreRangeCount, varptr(IgnoreRangeArray), RetainRangeCount, varptr(RetainRangeArray), SignatureBufferSize, varptr(SignatureBuffer) ; 戻り値は stat
; FileBufferWritable : BYTE* in/out -> "sptr"
; FileSize : DWORD -> "sptr"
; OptionFlags : DWORD -> "sptr"
; OptionData : void* optional -> "sptr"
; IgnoreRangeCount : DWORD -> "sptr"
; IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "sptr"
; RetainRangeCount : DWORD -> "sptr"
; RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "sptr"
; SignatureBufferSize : DWORD -> "sptr"
; SignatureBuffer : LPSTR out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mspatcha.dll" #cfunc global GetFilePatchSignatureByBuffer "GetFilePatchSignatureByBuffer" var, int, int, sptr, int, var, int, var, int, var ; res = GetFilePatchSignatureByBuffer(FileBufferWritable, FileSize, OptionFlags, OptionData, IgnoreRangeCount, IgnoreRangeArray, RetainRangeCount, RetainRangeArray, SignatureBufferSize, SignatureBuffer) ; FileBufferWritable : BYTE* in/out -> "var" ; FileSize : DWORD -> "int" ; OptionFlags : DWORD -> "int" ; OptionData : void* optional -> "sptr" ; IgnoreRangeCount : DWORD -> "int" ; IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "var" ; RetainRangeCount : DWORD -> "int" ; RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "var" ; SignatureBufferSize : DWORD -> "int" ; SignatureBuffer : LPSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mspatcha.dll" #cfunc global GetFilePatchSignatureByBuffer "GetFilePatchSignatureByBuffer" sptr, int, int, sptr, int, sptr, int, sptr, int, sptr ; res = GetFilePatchSignatureByBuffer(varptr(FileBufferWritable), FileSize, OptionFlags, OptionData, IgnoreRangeCount, varptr(IgnoreRangeArray), RetainRangeCount, varptr(RetainRangeArray), SignatureBufferSize, varptr(SignatureBuffer)) ; FileBufferWritable : BYTE* in/out -> "sptr" ; FileSize : DWORD -> "int" ; OptionFlags : DWORD -> "int" ; OptionData : void* optional -> "sptr" ; IgnoreRangeCount : DWORD -> "int" ; IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "sptr" ; RetainRangeCount : DWORD -> "int" ; RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "sptr" ; SignatureBufferSize : DWORD -> "int" ; SignatureBuffer : LPSTR out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetFilePatchSignatureByBuffer(BYTE* FileBufferWritable, DWORD FileSize, DWORD OptionFlags, void* OptionData, DWORD IgnoreRangeCount, PATCH_IGNORE_RANGE* IgnoreRangeArray, DWORD RetainRangeCount, PATCH_RETAIN_RANGE* RetainRangeArray, DWORD SignatureBufferSize, LPSTR SignatureBuffer) #uselib "mspatcha.dll" #cfunc global GetFilePatchSignatureByBuffer "GetFilePatchSignatureByBuffer" var, int, int, intptr, int, var, int, var, int, var ; res = GetFilePatchSignatureByBuffer(FileBufferWritable, FileSize, OptionFlags, OptionData, IgnoreRangeCount, IgnoreRangeArray, RetainRangeCount, RetainRangeArray, SignatureBufferSize, SignatureBuffer) ; FileBufferWritable : BYTE* in/out -> "var" ; FileSize : DWORD -> "int" ; OptionFlags : DWORD -> "int" ; OptionData : void* optional -> "intptr" ; IgnoreRangeCount : DWORD -> "int" ; IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "var" ; RetainRangeCount : DWORD -> "int" ; RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "var" ; SignatureBufferSize : DWORD -> "int" ; SignatureBuffer : LPSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetFilePatchSignatureByBuffer(BYTE* FileBufferWritable, DWORD FileSize, DWORD OptionFlags, void* OptionData, DWORD IgnoreRangeCount, PATCH_IGNORE_RANGE* IgnoreRangeArray, DWORD RetainRangeCount, PATCH_RETAIN_RANGE* RetainRangeArray, DWORD SignatureBufferSize, LPSTR SignatureBuffer) #uselib "mspatcha.dll" #cfunc global GetFilePatchSignatureByBuffer "GetFilePatchSignatureByBuffer" intptr, int, int, intptr, int, intptr, int, intptr, int, intptr ; res = GetFilePatchSignatureByBuffer(varptr(FileBufferWritable), FileSize, OptionFlags, OptionData, IgnoreRangeCount, varptr(IgnoreRangeArray), RetainRangeCount, varptr(RetainRangeArray), SignatureBufferSize, varptr(SignatureBuffer)) ; FileBufferWritable : BYTE* in/out -> "intptr" ; FileSize : DWORD -> "int" ; OptionFlags : DWORD -> "int" ; OptionData : void* optional -> "intptr" ; IgnoreRangeCount : DWORD -> "int" ; IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "intptr" ; RetainRangeCount : DWORD -> "int" ; RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "intptr" ; SignatureBufferSize : DWORD -> "int" ; SignatureBuffer : LPSTR out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mspatcha = windows.NewLazySystemDLL("mspatcha.dll")
procGetFilePatchSignatureByBuffer = mspatcha.NewProc("GetFilePatchSignatureByBuffer")
)
// FileBufferWritable (BYTE* in/out), FileSize (DWORD), OptionFlags (DWORD), OptionData (void* optional), IgnoreRangeCount (DWORD), IgnoreRangeArray (PATCH_IGNORE_RANGE* optional), RetainRangeCount (DWORD), RetainRangeArray (PATCH_RETAIN_RANGE* optional), SignatureBufferSize (DWORD), SignatureBuffer (LPSTR out)
r1, _, err := procGetFilePatchSignatureByBuffer.Call(
uintptr(FileBufferWritable),
uintptr(FileSize),
uintptr(OptionFlags),
uintptr(OptionData),
uintptr(IgnoreRangeCount),
uintptr(IgnoreRangeArray),
uintptr(RetainRangeCount),
uintptr(RetainRangeArray),
uintptr(SignatureBufferSize),
uintptr(SignatureBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetFilePatchSignatureByBuffer(
FileBufferWritable: Pointer; // BYTE* in/out
FileSize: DWORD; // DWORD
OptionFlags: DWORD; // DWORD
OptionData: Pointer; // void* optional
IgnoreRangeCount: DWORD; // DWORD
IgnoreRangeArray: Pointer; // PATCH_IGNORE_RANGE* optional
RetainRangeCount: DWORD; // DWORD
RetainRangeArray: Pointer; // PATCH_RETAIN_RANGE* optional
SignatureBufferSize: DWORD; // DWORD
SignatureBuffer: PAnsiChar // LPSTR out
): BOOL; stdcall;
external 'mspatcha.dll' name 'GetFilePatchSignatureByBuffer';result := DllCall("mspatcha\GetFilePatchSignatureByBuffer"
, "Ptr", FileBufferWritable ; BYTE* in/out
, "UInt", FileSize ; DWORD
, "UInt", OptionFlags ; DWORD
, "Ptr", OptionData ; void* optional
, "UInt", IgnoreRangeCount ; DWORD
, "Ptr", IgnoreRangeArray ; PATCH_IGNORE_RANGE* optional
, "UInt", RetainRangeCount ; DWORD
, "Ptr", RetainRangeArray ; PATCH_RETAIN_RANGE* optional
, "UInt", SignatureBufferSize ; DWORD
, "Ptr", SignatureBuffer ; LPSTR out
, "Int") ; return: BOOL●GetFilePatchSignatureByBuffer(FileBufferWritable, FileSize, OptionFlags, OptionData, IgnoreRangeCount, IgnoreRangeArray, RetainRangeCount, RetainRangeArray, SignatureBufferSize, SignatureBuffer) = DLL("mspatcha.dll", "bool GetFilePatchSignatureByBuffer(void*, dword, dword, void*, dword, void*, dword, void*, dword, char*)")
# 呼び出し: GetFilePatchSignatureByBuffer(FileBufferWritable, FileSize, OptionFlags, OptionData, IgnoreRangeCount, IgnoreRangeArray, RetainRangeCount, RetainRangeArray, SignatureBufferSize, SignatureBuffer)
# FileBufferWritable : BYTE* in/out -> "void*"
# FileSize : DWORD -> "dword"
# OptionFlags : DWORD -> "dword"
# OptionData : void* optional -> "void*"
# IgnoreRangeCount : DWORD -> "dword"
# IgnoreRangeArray : PATCH_IGNORE_RANGE* optional -> "void*"
# RetainRangeCount : DWORD -> "dword"
# RetainRangeArray : PATCH_RETAIN_RANGE* optional -> "void*"
# SignatureBufferSize : DWORD -> "dword"
# SignatureBuffer : LPSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。