ホーム › Security.Authentication.Identity › LsaRegisterLogonProcess
LsaRegisterLogonProcess
関数ログオンプロセスとしてLSAに登録し接続ハンドルを取得する。
シグネチャ
// SECUR32.dll
#include <windows.h>
NTSTATUS LsaRegisterLogonProcess(
LSA_STRING* LogonProcessName,
HANDLE* LsaHandle,
DWORD* SecurityMode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| LogonProcessName | LSA_STRING* | in | 登録するログオンプロセスの識別名を保持するLSA_STRINGへのポインタ。 |
| LsaHandle | HANDLE* | out | 確立されたLSAへの接続ハンドルを受け取る出力先。 |
| SecurityMode | DWORD* | out | 返されるセキュリティモードを受け取る出力先。 |
戻り値の型: NTSTATUS
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
NTSTATUS LsaRegisterLogonProcess(
LSA_STRING* LogonProcessName,
HANDLE* LsaHandle,
DWORD* SecurityMode
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int LsaRegisterLogonProcess(
IntPtr LogonProcessName, // LSA_STRING*
IntPtr LsaHandle, // HANDLE* out
out uint SecurityMode // DWORD* out
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function LsaRegisterLogonProcess(
LogonProcessName As IntPtr, ' LSA_STRING*
LsaHandle As IntPtr, ' HANDLE* out
<Out> ByRef SecurityMode As UInteger ' DWORD* out
) As Integer
End Function' LogonProcessName : LSA_STRING*
' LsaHandle : HANDLE* out
' SecurityMode : DWORD* out
Declare PtrSafe Function LsaRegisterLogonProcess Lib "secur32" ( _
ByVal LogonProcessName As LongPtr, _
ByVal LsaHandle As LongPtr, _
ByRef SecurityMode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LsaRegisterLogonProcess = ctypes.windll.secur32.LsaRegisterLogonProcess
LsaRegisterLogonProcess.restype = ctypes.c_int
LsaRegisterLogonProcess.argtypes = [
ctypes.c_void_p, # LogonProcessName : LSA_STRING*
ctypes.c_void_p, # LsaHandle : HANDLE* out
ctypes.POINTER(wintypes.DWORD), # SecurityMode : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
LsaRegisterLogonProcess = Fiddle::Function.new(
lib['LsaRegisterLogonProcess'],
[
Fiddle::TYPE_VOIDP, # LogonProcessName : LSA_STRING*
Fiddle::TYPE_VOIDP, # LsaHandle : HANDLE* out
Fiddle::TYPE_VOIDP, # SecurityMode : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn LsaRegisterLogonProcess(
LogonProcessName: *mut LSA_STRING, // LSA_STRING*
LsaHandle: *mut *mut core::ffi::c_void, // HANDLE* out
SecurityMode: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int LsaRegisterLogonProcess(IntPtr LogonProcessName, IntPtr LsaHandle, out uint SecurityMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_LsaRegisterLogonProcess' -Namespace Win32 -PassThru
# $api::LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode)#uselib "SECUR32.dll"
#func global LsaRegisterLogonProcess "LsaRegisterLogonProcess" sptr, sptr, sptr
; LsaRegisterLogonProcess varptr(LogonProcessName), LsaHandle, varptr(SecurityMode) ; 戻り値は stat
; LogonProcessName : LSA_STRING* -> "sptr"
; LsaHandle : HANDLE* out -> "sptr"
; SecurityMode : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SECUR32.dll" #cfunc global LsaRegisterLogonProcess "LsaRegisterLogonProcess" var, sptr, var ; res = LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode) ; LogonProcessName : LSA_STRING* -> "var" ; LsaHandle : HANDLE* out -> "sptr" ; SecurityMode : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SECUR32.dll" #cfunc global LsaRegisterLogonProcess "LsaRegisterLogonProcess" sptr, sptr, sptr ; res = LsaRegisterLogonProcess(varptr(LogonProcessName), LsaHandle, varptr(SecurityMode)) ; LogonProcessName : LSA_STRING* -> "sptr" ; LsaHandle : HANDLE* out -> "sptr" ; SecurityMode : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; NTSTATUS LsaRegisterLogonProcess(LSA_STRING* LogonProcessName, HANDLE* LsaHandle, DWORD* SecurityMode) #uselib "SECUR32.dll" #cfunc global LsaRegisterLogonProcess "LsaRegisterLogonProcess" var, intptr, var ; res = LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode) ; LogonProcessName : LSA_STRING* -> "var" ; LsaHandle : HANDLE* out -> "intptr" ; SecurityMode : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; NTSTATUS LsaRegisterLogonProcess(LSA_STRING* LogonProcessName, HANDLE* LsaHandle, DWORD* SecurityMode) #uselib "SECUR32.dll" #cfunc global LsaRegisterLogonProcess "LsaRegisterLogonProcess" intptr, intptr, intptr ; res = LsaRegisterLogonProcess(varptr(LogonProcessName), LsaHandle, varptr(SecurityMode)) ; LogonProcessName : LSA_STRING* -> "intptr" ; LsaHandle : HANDLE* out -> "intptr" ; SecurityMode : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procLsaRegisterLogonProcess = secur32.NewProc("LsaRegisterLogonProcess")
)
// LogonProcessName (LSA_STRING*), LsaHandle (HANDLE* out), SecurityMode (DWORD* out)
r1, _, err := procLsaRegisterLogonProcess.Call(
uintptr(LogonProcessName),
uintptr(LsaHandle),
uintptr(SecurityMode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // NTSTATUSfunction LsaRegisterLogonProcess(
LogonProcessName: Pointer; // LSA_STRING*
LsaHandle: Pointer; // HANDLE* out
SecurityMode: Pointer // DWORD* out
): Integer; stdcall;
external 'SECUR32.dll' name 'LsaRegisterLogonProcess';result := DllCall("SECUR32\LsaRegisterLogonProcess"
, "Ptr", LogonProcessName ; LSA_STRING*
, "Ptr", LsaHandle ; HANDLE* out
, "Ptr", SecurityMode ; DWORD* out
, "Int") ; return: NTSTATUS●LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode) = DLL("SECUR32.dll", "int LsaRegisterLogonProcess(void*, void*, void*)")
# 呼び出し: LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode)
# LogonProcessName : LSA_STRING* -> "void*"
# LsaHandle : HANDLE* out -> "void*"
# SecurityMode : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "secur32" fn LsaRegisterLogonProcess(
LogonProcessName: [*c]LSA_STRING, // LSA_STRING*
LsaHandle: ?*anyopaque, // HANDLE* out
SecurityMode: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc LsaRegisterLogonProcess(
LogonProcessName: ptr LSA_STRING, # LSA_STRING*
LsaHandle: pointer, # HANDLE* out
SecurityMode: ptr uint32 # DWORD* out
): int32 {.importc: "LsaRegisterLogonProcess", stdcall, dynlib: "SECUR32.dll".}pragma(lib, "secur32");
extern(Windows)
int LsaRegisterLogonProcess(
LSA_STRING* LogonProcessName, // LSA_STRING*
void* LsaHandle, // HANDLE* out
uint* SecurityMode // DWORD* out
);ccall((:LsaRegisterLogonProcess, "SECUR32.dll"), stdcall, Int32,
(Ptr{LSA_STRING}, Ptr{Cvoid}, Ptr{UInt32}),
LogonProcessName, LsaHandle, SecurityMode)
# LogonProcessName : LSA_STRING* -> Ptr{LSA_STRING}
# LsaHandle : HANDLE* out -> Ptr{Cvoid}
# SecurityMode : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t LsaRegisterLogonProcess(
void* LogonProcessName,
void* LsaHandle,
uint32_t* SecurityMode);
]]
local secur32 = ffi.load("secur32")
-- secur32.LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode)
-- LogonProcessName : LSA_STRING*
-- LsaHandle : HANDLE* out
-- SecurityMode : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SECUR32.dll');
const LsaRegisterLogonProcess = lib.func('__stdcall', 'LsaRegisterLogonProcess', 'int32_t', ['void *', 'void *', 'uint32_t *']);
// LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode)
// LogonProcessName : LSA_STRING* -> 'void *'
// LsaHandle : HANDLE* out -> 'void *'
// SecurityMode : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SECUR32.dll", {
LsaRegisterLogonProcess: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode)
// LogonProcessName : LSA_STRING* -> "pointer"
// LsaHandle : HANDLE* out -> "pointer"
// SecurityMode : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t LsaRegisterLogonProcess(
void* LogonProcessName,
void* LsaHandle,
uint32_t* SecurityMode);
C, "SECUR32.dll");
// $ffi->LsaRegisterLogonProcess(LogonProcessName, LsaHandle, SecurityMode);
// LogonProcessName : LSA_STRING*
// LsaHandle : HANDLE* out
// SecurityMode : DWORD* 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 Secur32 extends StdCallLibrary {
Secur32 INSTANCE = Native.load("secur32", Secur32.class);
int LsaRegisterLogonProcess(
Pointer LogonProcessName, // LSA_STRING*
Pointer LsaHandle, // HANDLE* out
IntByReference SecurityMode // DWORD* out
);
}@[Link("secur32")]
lib LibSECUR32
fun LsaRegisterLogonProcess = LsaRegisterLogonProcess(
LogonProcessName : LSA_STRING*, # LSA_STRING*
LsaHandle : Void*, # HANDLE* out
SecurityMode : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef LsaRegisterLogonProcessNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef LsaRegisterLogonProcessDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final LsaRegisterLogonProcess = DynamicLibrary.open('SECUR32.dll')
.lookupFunction<LsaRegisterLogonProcessNative, LsaRegisterLogonProcessDart>('LsaRegisterLogonProcess');
// LogonProcessName : LSA_STRING* -> Pointer<Void>
// LsaHandle : HANDLE* out -> Pointer<Void>
// SecurityMode : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function LsaRegisterLogonProcess(
LogonProcessName: Pointer; // LSA_STRING*
LsaHandle: Pointer; // HANDLE* out
SecurityMode: Pointer // DWORD* out
): Integer; stdcall;
external 'SECUR32.dll' name 'LsaRegisterLogonProcess';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "LsaRegisterLogonProcess"
c_LsaRegisterLogonProcess :: Ptr () -> Ptr () -> Ptr Word32 -> IO Int32
-- LogonProcessName : LSA_STRING* -> Ptr ()
-- LsaHandle : HANDLE* out -> Ptr ()
-- SecurityMode : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let lsaregisterlogonprocess =
foreign "LsaRegisterLogonProcess"
((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* LogonProcessName : LSA_STRING* -> (ptr void) *)
(* LsaHandle : HANDLE* out -> (ptr void) *)
(* SecurityMode : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library secur32 (t "SECUR32.dll"))
(cffi:use-foreign-library secur32)
(cffi:defcfun ("LsaRegisterLogonProcess" lsa-register-logon-process :convention :stdcall) :int32
(logon-process-name :pointer) ; LSA_STRING*
(lsa-handle :pointer) ; HANDLE* out
(security-mode :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $LsaRegisterLogonProcess = Win32::API::More->new('SECUR32',
'int LsaRegisterLogonProcess(LPVOID LogonProcessName, HANDLE LsaHandle, LPVOID SecurityMode)');
# my $ret = $LsaRegisterLogonProcess->Call($LogonProcessName, $LsaHandle, $SecurityMode);
# LogonProcessName : LSA_STRING* -> LPVOID
# LsaHandle : HANDLE* out -> HANDLE
# SecurityMode : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型