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