ホーム › Storage.IscsiDisc › SetIScsiInitiatorCHAPSharedSecret
SetIScsiInitiatorCHAPSharedSecret
関数iSCSIイニシエーターのCHAP共有シークレットを設定する。
シグネチャ
// ISCSIDSC.dll
#include <windows.h>
DWORD SetIScsiInitiatorCHAPSharedSecret(
DWORD SharedSecretLength,
BYTE* SharedSecret
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SharedSecretLength | DWORD | in | SharedSecretが指すCHAP共有秘密のバイト長。 |
| SharedSecret | BYTE* | inout | イニシエータ側に設定するCHAP共有秘密(認証用パスワード)のバイト列へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// ISCSIDSC.dll
#include <windows.h>
DWORD SetIScsiInitiatorCHAPSharedSecret(
DWORD SharedSecretLength,
BYTE* SharedSecret
);[DllImport("ISCSIDSC.dll", ExactSpelling = true)]
static extern uint SetIScsiInitiatorCHAPSharedSecret(
uint SharedSecretLength, // DWORD
IntPtr SharedSecret // BYTE* in/out
);<DllImport("ISCSIDSC.dll", ExactSpelling:=True)>
Public Shared Function SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength As UInteger, ' DWORD
SharedSecret As IntPtr ' BYTE* in/out
) As UInteger
End Function' SharedSecretLength : DWORD
' SharedSecret : BYTE* in/out
Declare PtrSafe Function SetIScsiInitiatorCHAPSharedSecret Lib "iscsidsc" ( _
ByVal SharedSecretLength As Long, _
ByVal SharedSecret As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetIScsiInitiatorCHAPSharedSecret = ctypes.windll.iscsidsc.SetIScsiInitiatorCHAPSharedSecret
SetIScsiInitiatorCHAPSharedSecret.restype = wintypes.DWORD
SetIScsiInitiatorCHAPSharedSecret.argtypes = [
wintypes.DWORD, # SharedSecretLength : DWORD
ctypes.POINTER(ctypes.c_ubyte), # SharedSecret : BYTE* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ISCSIDSC.dll')
SetIScsiInitiatorCHAPSharedSecret = Fiddle::Function.new(
lib['SetIScsiInitiatorCHAPSharedSecret'],
[
-Fiddle::TYPE_INT, # SharedSecretLength : DWORD
Fiddle::TYPE_VOIDP, # SharedSecret : BYTE* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iscsidsc")]
extern "system" {
fn SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength: u32, // DWORD
SharedSecret: *mut u8 // BYTE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ISCSIDSC.dll")]
public static extern uint SetIScsiInitiatorCHAPSharedSecret(uint SharedSecretLength, IntPtr SharedSecret);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ISCSIDSC_SetIScsiInitiatorCHAPSharedSecret' -Namespace Win32 -PassThru
# $api::SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret)#uselib "ISCSIDSC.dll"
#func global SetIScsiInitiatorCHAPSharedSecret "SetIScsiInitiatorCHAPSharedSecret" sptr, sptr
; SetIScsiInitiatorCHAPSharedSecret SharedSecretLength, varptr(SharedSecret) ; 戻り値は stat
; SharedSecretLength : DWORD -> "sptr"
; SharedSecret : BYTE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ISCSIDSC.dll" #cfunc global SetIScsiInitiatorCHAPSharedSecret "SetIScsiInitiatorCHAPSharedSecret" int, var ; res = SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret) ; SharedSecretLength : DWORD -> "int" ; SharedSecret : BYTE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ISCSIDSC.dll" #cfunc global SetIScsiInitiatorCHAPSharedSecret "SetIScsiInitiatorCHAPSharedSecret" int, sptr ; res = SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, varptr(SharedSecret)) ; SharedSecretLength : DWORD -> "int" ; SharedSecret : BYTE* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetIScsiInitiatorCHAPSharedSecret(DWORD SharedSecretLength, BYTE* SharedSecret) #uselib "ISCSIDSC.dll" #cfunc global SetIScsiInitiatorCHAPSharedSecret "SetIScsiInitiatorCHAPSharedSecret" int, var ; res = SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret) ; SharedSecretLength : DWORD -> "int" ; SharedSecret : BYTE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetIScsiInitiatorCHAPSharedSecret(DWORD SharedSecretLength, BYTE* SharedSecret) #uselib "ISCSIDSC.dll" #cfunc global SetIScsiInitiatorCHAPSharedSecret "SetIScsiInitiatorCHAPSharedSecret" int, intptr ; res = SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, varptr(SharedSecret)) ; SharedSecretLength : DWORD -> "int" ; SharedSecret : BYTE* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iscsidsc = windows.NewLazySystemDLL("ISCSIDSC.dll")
procSetIScsiInitiatorCHAPSharedSecret = iscsidsc.NewProc("SetIScsiInitiatorCHAPSharedSecret")
)
// SharedSecretLength (DWORD), SharedSecret (BYTE* in/out)
r1, _, err := procSetIScsiInitiatorCHAPSharedSecret.Call(
uintptr(SharedSecretLength),
uintptr(SharedSecret),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength: DWORD; // DWORD
SharedSecret: Pointer // BYTE* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'SetIScsiInitiatorCHAPSharedSecret';result := DllCall("ISCSIDSC\SetIScsiInitiatorCHAPSharedSecret"
, "UInt", SharedSecretLength ; DWORD
, "Ptr", SharedSecret ; BYTE* in/out
, "UInt") ; return: DWORD●SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret) = DLL("ISCSIDSC.dll", "dword SetIScsiInitiatorCHAPSharedSecret(dword, void*)")
# 呼び出し: SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret)
# SharedSecretLength : DWORD -> "dword"
# SharedSecret : BYTE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "iscsidsc" fn SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength: u32, // DWORD
SharedSecret: [*c]u8 // BYTE* in/out
) callconv(std.os.windows.WINAPI) u32;proc SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength: uint32, # DWORD
SharedSecret: ptr uint8 # BYTE* in/out
): uint32 {.importc: "SetIScsiInitiatorCHAPSharedSecret", stdcall, dynlib: "ISCSIDSC.dll".}pragma(lib, "iscsidsc");
extern(Windows)
uint SetIScsiInitiatorCHAPSharedSecret(
uint SharedSecretLength, // DWORD
ubyte* SharedSecret // BYTE* in/out
);ccall((:SetIScsiInitiatorCHAPSharedSecret, "ISCSIDSC.dll"), stdcall, UInt32,
(UInt32, Ptr{UInt8}),
SharedSecretLength, SharedSecret)
# SharedSecretLength : DWORD -> UInt32
# SharedSecret : BYTE* in/out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SetIScsiInitiatorCHAPSharedSecret(
uint32_t SharedSecretLength,
uint8_t* SharedSecret);
]]
local iscsidsc = ffi.load("iscsidsc")
-- iscsidsc.SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret)
-- SharedSecretLength : DWORD
-- SharedSecret : BYTE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ISCSIDSC.dll');
const SetIScsiInitiatorCHAPSharedSecret = lib.func('__stdcall', 'SetIScsiInitiatorCHAPSharedSecret', 'uint32_t', ['uint32_t', 'uint8_t *']);
// SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret)
// SharedSecretLength : DWORD -> 'uint32_t'
// SharedSecret : BYTE* in/out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ISCSIDSC.dll", {
SetIScsiInitiatorCHAPSharedSecret: { parameters: ["u32", "pointer"], result: "u32" },
});
// lib.symbols.SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret)
// SharedSecretLength : DWORD -> "u32"
// SharedSecret : BYTE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SetIScsiInitiatorCHAPSharedSecret(
uint32_t SharedSecretLength,
uint8_t* SharedSecret);
C, "ISCSIDSC.dll");
// $ffi->SetIScsiInitiatorCHAPSharedSecret(SharedSecretLength, SharedSecret);
// SharedSecretLength : DWORD
// SharedSecret : BYTE* in/out
// 構造体/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 Iscsidsc extends StdCallLibrary {
Iscsidsc INSTANCE = Native.load("iscsidsc", Iscsidsc.class);
int SetIScsiInitiatorCHAPSharedSecret(
int SharedSecretLength, // DWORD
byte[] SharedSecret // BYTE* in/out
);
}@[Link("iscsidsc")]
lib LibISCSIDSC
fun SetIScsiInitiatorCHAPSharedSecret = SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength : UInt32, # DWORD
SharedSecret : UInt8* # BYTE* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetIScsiInitiatorCHAPSharedSecretNative = Uint32 Function(Uint32, Pointer<Uint8>);
typedef SetIScsiInitiatorCHAPSharedSecretDart = int Function(int, Pointer<Uint8>);
final SetIScsiInitiatorCHAPSharedSecret = DynamicLibrary.open('ISCSIDSC.dll')
.lookupFunction<SetIScsiInitiatorCHAPSharedSecretNative, SetIScsiInitiatorCHAPSharedSecretDart>('SetIScsiInitiatorCHAPSharedSecret');
// SharedSecretLength : DWORD -> Uint32
// SharedSecret : BYTE* in/out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetIScsiInitiatorCHAPSharedSecret(
SharedSecretLength: DWORD; // DWORD
SharedSecret: Pointer // BYTE* in/out
): DWORD; stdcall;
external 'ISCSIDSC.dll' name 'SetIScsiInitiatorCHAPSharedSecret';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetIScsiInitiatorCHAPSharedSecret"
c_SetIScsiInitiatorCHAPSharedSecret :: Word32 -> Ptr Word8 -> IO Word32
-- SharedSecretLength : DWORD -> Word32
-- SharedSecret : BYTE* in/out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setiscsiinitiatorchapsharedsecret =
foreign "SetIScsiInitiatorCHAPSharedSecret"
(uint32_t @-> (ptr uint8_t) @-> returning uint32_t)
(* SharedSecretLength : DWORD -> uint32_t *)
(* SharedSecret : BYTE* in/out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library iscsidsc (t "ISCSIDSC.dll"))
(cffi:use-foreign-library iscsidsc)
(cffi:defcfun ("SetIScsiInitiatorCHAPSharedSecret" set-iscsi-initiator-chapshared-secret :convention :stdcall) :uint32
(shared-secret-length :uint32) ; DWORD
(shared-secret :pointer)) ; BYTE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetIScsiInitiatorCHAPSharedSecret = Win32::API::More->new('ISCSIDSC',
'DWORD SetIScsiInitiatorCHAPSharedSecret(DWORD SharedSecretLength, LPVOID SharedSecret)');
# my $ret = $SetIScsiInitiatorCHAPSharedSecret->Call($SharedSecretLength, $SharedSecret);
# SharedSecretLength : DWORD -> DWORD
# SharedSecret : BYTE* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。