Win32 API 日本語リファレンス
ホームFoundation › RtlNtStatusToDosError

RtlNtStatusToDosError

関数
NTSTATUSコードを対応するWin32エラーに変換する。
DLLntdll.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD RtlNtStatusToDosError(
    NTSTATUS Status
);

パラメーター

名前方向
StatusNTSTATUSin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD RtlNtStatusToDosError(
    NTSTATUS Status
);
[DllImport("ntdll.dll", ExactSpelling = true)]
static extern uint RtlNtStatusToDosError(
    int Status   // NTSTATUS
);
<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlNtStatusToDosError(
    Status As Integer   ' NTSTATUS
) As UInteger
End Function
' Status : NTSTATUS
Declare PtrSafe Function RtlNtStatusToDosError Lib "ntdll" ( _
    ByVal Status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RtlNtStatusToDosError = ctypes.windll.ntdll.RtlNtStatusToDosError
RtlNtStatusToDosError.restype = wintypes.DWORD
RtlNtStatusToDosError.argtypes = [
    ctypes.c_int,  # Status : NTSTATUS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ntdll.dll')
RtlNtStatusToDosError = Fiddle::Function.new(
  lib['RtlNtStatusToDosError'],
  [
    Fiddle::TYPE_INT,  # Status : NTSTATUS
  ],
  -Fiddle::TYPE_INT)
#[link(name = "ntdll")]
extern "system" {
    fn RtlNtStatusToDosError(
        Status: i32  // NTSTATUS
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ntdll.dll")]
public static extern uint RtlNtStatusToDosError(int Status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlNtStatusToDosError' -Namespace Win32 -PassThru
# $api::RtlNtStatusToDosError(Status)
#uselib "ntdll.dll"
#func global RtlNtStatusToDosError "RtlNtStatusToDosError" sptr
; RtlNtStatusToDosError Status   ; 戻り値は stat
; Status : NTSTATUS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ntdll.dll"
#cfunc global RtlNtStatusToDosError "RtlNtStatusToDosError" int
; res = RtlNtStatusToDosError(Status)
; Status : NTSTATUS -> "int"
; DWORD RtlNtStatusToDosError(NTSTATUS Status)
#uselib "ntdll.dll"
#cfunc global RtlNtStatusToDosError "RtlNtStatusToDosError" int
; res = RtlNtStatusToDosError(Status)
; Status : NTSTATUS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ntdll = windows.NewLazySystemDLL("ntdll.dll")
	procRtlNtStatusToDosError = ntdll.NewProc("RtlNtStatusToDosError")
)

// Status (NTSTATUS)
r1, _, err := procRtlNtStatusToDosError.Call(
	uintptr(Status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function RtlNtStatusToDosError(
  Status: Integer   // NTSTATUS
): DWORD; stdcall;
  external 'ntdll.dll' name 'RtlNtStatusToDosError';
result := DllCall("ntdll\RtlNtStatusToDosError"
    , "Int", Status   ; NTSTATUS
    , "UInt")   ; return: DWORD
●RtlNtStatusToDosError(Status) = DLL("ntdll.dll", "dword RtlNtStatusToDosError(int)")
# 呼び出し: RtlNtStatusToDosError(Status)
# Status : NTSTATUS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。