ホーム › Security.Cryptography › CryptUnprotectMemory
CryptUnprotectMemory
関数CryptProtectMemoryで保護されたメモリを復号する。
シグネチャ
// CRYPT32.dll
#include <windows.h>
BOOL CryptUnprotectMemory(
void* pDataIn,
DWORD cbDataIn,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pDataIn | void* | inout |
| cbDataIn | DWORD | in |
| dwFlags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPT32.dll
#include <windows.h>
BOOL CryptUnprotectMemory(
void* pDataIn,
DWORD cbDataIn,
DWORD dwFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CryptUnprotectMemory(
IntPtr pDataIn, // void* in/out
uint cbDataIn, // DWORD
uint dwFlags // DWORD
);<DllImport("CRYPT32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CryptUnprotectMemory(
pDataIn As IntPtr, ' void* in/out
cbDataIn As UInteger, ' DWORD
dwFlags As UInteger ' DWORD
) As Boolean
End Function' pDataIn : void* in/out
' cbDataIn : DWORD
' dwFlags : DWORD
Declare PtrSafe Function CryptUnprotectMemory Lib "crypt32" ( _
ByVal pDataIn As LongPtr, _
ByVal cbDataIn As Long, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptUnprotectMemory = ctypes.windll.crypt32.CryptUnprotectMemory
CryptUnprotectMemory.restype = wintypes.BOOL
CryptUnprotectMemory.argtypes = [
ctypes.POINTER(None), # pDataIn : void* in/out
wintypes.DWORD, # cbDataIn : DWORD
wintypes.DWORD, # dwFlags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPT32.dll')
CryptUnprotectMemory = Fiddle::Function.new(
lib['CryptUnprotectMemory'],
[
Fiddle::TYPE_VOIDP, # pDataIn : void* in/out
-Fiddle::TYPE_INT, # cbDataIn : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "crypt32")]
extern "system" {
fn CryptUnprotectMemory(
pDataIn: *mut (), // void* in/out
cbDataIn: u32, // DWORD
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPT32.dll", SetLastError = true)]
public static extern bool CryptUnprotectMemory(IntPtr pDataIn, uint cbDataIn, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPT32_CryptUnprotectMemory' -Namespace Win32 -PassThru
# $api::CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags)#uselib "CRYPT32.dll"
#func global CryptUnprotectMemory "CryptUnprotectMemory" sptr, sptr, sptr
; CryptUnprotectMemory pDataIn, cbDataIn, dwFlags ; 戻り値は stat
; pDataIn : void* in/out -> "sptr"
; cbDataIn : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPT32.dll"
#cfunc global CryptUnprotectMemory "CryptUnprotectMemory" sptr, int, int
; res = CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags)
; pDataIn : void* in/out -> "sptr"
; cbDataIn : DWORD -> "int"
; dwFlags : DWORD -> "int"; BOOL CryptUnprotectMemory(void* pDataIn, DWORD cbDataIn, DWORD dwFlags)
#uselib "CRYPT32.dll"
#cfunc global CryptUnprotectMemory "CryptUnprotectMemory" intptr, int, int
; res = CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags)
; pDataIn : void* in/out -> "intptr"
; cbDataIn : DWORD -> "int"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
crypt32 = windows.NewLazySystemDLL("CRYPT32.dll")
procCryptUnprotectMemory = crypt32.NewProc("CryptUnprotectMemory")
)
// pDataIn (void* in/out), cbDataIn (DWORD), dwFlags (DWORD)
r1, _, err := procCryptUnprotectMemory.Call(
uintptr(pDataIn),
uintptr(cbDataIn),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptUnprotectMemory(
pDataIn: Pointer; // void* in/out
cbDataIn: DWORD; // DWORD
dwFlags: DWORD // DWORD
): BOOL; stdcall;
external 'CRYPT32.dll' name 'CryptUnprotectMemory';result := DllCall("CRYPT32\CryptUnprotectMemory"
, "Ptr", pDataIn ; void* in/out
, "UInt", cbDataIn ; DWORD
, "UInt", dwFlags ; DWORD
, "Int") ; return: BOOL●CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags) = DLL("CRYPT32.dll", "bool CryptUnprotectMemory(void*, dword, dword)")
# 呼び出し: CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags)
# pDataIn : void* in/out -> "void*"
# cbDataIn : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。