Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › LsaRegisterLogonProcess

LsaRegisterLogonProcess

関数
ログオンプロセスとしてLSAに登録し接続ハンドルを取得する。
DLLSECUR32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SECUR32.dll
#include <windows.h>

NTSTATUS LsaRegisterLogonProcess(
    LSA_STRING* LogonProcessName,
    HANDLE* LsaHandle,
    DWORD* SecurityMode
);

パラメーター

名前方向
LogonProcessNameLSA_STRING*in
LsaHandleHANDLE*out
SecurityModeDWORD*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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // NTSTATUS
function 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)。