ホーム › System.WindowsProgramming › RtlIsNameLegalDOS8Dot3
RtlIsNameLegalDOS8Dot3
関数名前がDOSの8.3形式として有効かを判定する。
シグネチャ
// ntdll.dll
#include <windows.h>
BOOLEAN RtlIsNameLegalDOS8Dot3(
UNICODE_STRING* Name,
STRING* OemName,
BOOLEAN* NameContainsSpaces
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Name | UNICODE_STRING* | inout | 検査対象のファイル名を保持するUNICODE_STRING構造体へのポインタ。 |
| OemName | STRING* | inout | 8.3形式に変換したOEM文字列を受け取るSTRING構造体へのポインタ。NULL可。 |
| NameContainsSpaces | BOOLEAN* | inout | 名前に空白が含まれるかを受け取るBOOLEAN変数へのポインタ。NULL可。 |
戻り値の型: BOOLEAN
各言語での呼び出し定義
// ntdll.dll
#include <windows.h>
BOOLEAN RtlIsNameLegalDOS8Dot3(
UNICODE_STRING* Name,
STRING* OemName,
BOOLEAN* NameContainsSpaces
);[return: MarshalAs(UnmanagedType.U1)]
[DllImport("ntdll.dll", ExactSpelling = true)]
static extern bool RtlIsNameLegalDOS8Dot3(
IntPtr Name, // UNICODE_STRING* in/out
IntPtr OemName, // STRING* in/out
[MarshalAs(UnmanagedType.U1)] ref bool NameContainsSpaces // BOOLEAN* in/out
);<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlIsNameLegalDOS8Dot3(
Name As IntPtr, ' UNICODE_STRING* in/out
OemName As IntPtr, ' STRING* in/out
<MarshalAs(UnmanagedType.U1)> ByRef NameContainsSpaces As Boolean ' BOOLEAN* in/out
) As <MarshalAs(UnmanagedType.U1)> Boolean
End Function' Name : UNICODE_STRING* in/out
' OemName : STRING* in/out
' NameContainsSpaces : BOOLEAN* in/out
Declare PtrSafe Function RtlIsNameLegalDOS8Dot3 Lib "ntdll" ( _
ByVal Name As LongPtr, _
ByVal OemName As LongPtr, _
ByRef NameContainsSpaces As Byte) As Byte
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RtlIsNameLegalDOS8Dot3 = ctypes.windll.ntdll.RtlIsNameLegalDOS8Dot3
RtlIsNameLegalDOS8Dot3.restype = wintypes.BOOLEAN
RtlIsNameLegalDOS8Dot3.argtypes = [
ctypes.c_void_p, # Name : UNICODE_STRING* in/out
ctypes.c_void_p, # OemName : STRING* in/out
ctypes.c_void_p, # NameContainsSpaces : BOOLEAN* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ntdll.dll')
RtlIsNameLegalDOS8Dot3 = Fiddle::Function.new(
lib['RtlIsNameLegalDOS8Dot3'],
[
Fiddle::TYPE_VOIDP, # Name : UNICODE_STRING* in/out
Fiddle::TYPE_VOIDP, # OemName : STRING* in/out
Fiddle::TYPE_VOIDP, # NameContainsSpaces : BOOLEAN* in/out
],
Fiddle::TYPE_CHAR)#[link(name = "ntdll")]
extern "system" {
fn RtlIsNameLegalDOS8Dot3(
Name: *mut UNICODE_STRING, // UNICODE_STRING* in/out
OemName: *mut STRING, // STRING* in/out
NameContainsSpaces: *mut u8 // BOOLEAN* in/out
) -> u8;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.U1)]
[DllImport("ntdll.dll")]
public static extern bool RtlIsNameLegalDOS8Dot3(IntPtr Name, IntPtr OemName, [MarshalAs(UnmanagedType.U1)] ref bool NameContainsSpaces);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlIsNameLegalDOS8Dot3' -Namespace Win32 -PassThru
# $api::RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces)#uselib "ntdll.dll"
#func global RtlIsNameLegalDOS8Dot3 "RtlIsNameLegalDOS8Dot3" sptr, sptr, sptr
; RtlIsNameLegalDOS8Dot3 varptr(Name), varptr(OemName), varptr(NameContainsSpaces) ; 戻り値は stat
; Name : UNICODE_STRING* in/out -> "sptr"
; OemName : STRING* in/out -> "sptr"
; NameContainsSpaces : BOOLEAN* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ntdll.dll" #cfunc global RtlIsNameLegalDOS8Dot3 "RtlIsNameLegalDOS8Dot3" var, var, var ; res = RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces) ; Name : UNICODE_STRING* in/out -> "var" ; OemName : STRING* in/out -> "var" ; NameContainsSpaces : BOOLEAN* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ntdll.dll" #cfunc global RtlIsNameLegalDOS8Dot3 "RtlIsNameLegalDOS8Dot3" sptr, sptr, sptr ; res = RtlIsNameLegalDOS8Dot3(varptr(Name), varptr(OemName), varptr(NameContainsSpaces)) ; Name : UNICODE_STRING* in/out -> "sptr" ; OemName : STRING* in/out -> "sptr" ; NameContainsSpaces : BOOLEAN* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOLEAN RtlIsNameLegalDOS8Dot3(UNICODE_STRING* Name, STRING* OemName, BOOLEAN* NameContainsSpaces) #uselib "ntdll.dll" #cfunc global RtlIsNameLegalDOS8Dot3 "RtlIsNameLegalDOS8Dot3" var, var, var ; res = RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces) ; Name : UNICODE_STRING* in/out -> "var" ; OemName : STRING* in/out -> "var" ; NameContainsSpaces : BOOLEAN* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOLEAN RtlIsNameLegalDOS8Dot3(UNICODE_STRING* Name, STRING* OemName, BOOLEAN* NameContainsSpaces) #uselib "ntdll.dll" #cfunc global RtlIsNameLegalDOS8Dot3 "RtlIsNameLegalDOS8Dot3" intptr, intptr, intptr ; res = RtlIsNameLegalDOS8Dot3(varptr(Name), varptr(OemName), varptr(NameContainsSpaces)) ; Name : UNICODE_STRING* in/out -> "intptr" ; OemName : STRING* in/out -> "intptr" ; NameContainsSpaces : BOOLEAN* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdll = windows.NewLazySystemDLL("ntdll.dll")
procRtlIsNameLegalDOS8Dot3 = ntdll.NewProc("RtlIsNameLegalDOS8Dot3")
)
// Name (UNICODE_STRING* in/out), OemName (STRING* in/out), NameContainsSpaces (BOOLEAN* in/out)
r1, _, err := procRtlIsNameLegalDOS8Dot3.Call(
uintptr(Name),
uintptr(OemName),
uintptr(NameContainsSpaces),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLEANfunction RtlIsNameLegalDOS8Dot3(
Name: Pointer; // UNICODE_STRING* in/out
OemName: Pointer; // STRING* in/out
NameContainsSpaces: Pointer // BOOLEAN* in/out
): ByteBool; stdcall;
external 'ntdll.dll' name 'RtlIsNameLegalDOS8Dot3';result := DllCall("ntdll\RtlIsNameLegalDOS8Dot3"
, "Ptr", Name ; UNICODE_STRING* in/out
, "Ptr", OemName ; STRING* in/out
, "Ptr", NameContainsSpaces ; BOOLEAN* in/out
, "Char") ; return: BOOLEAN●RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces) = DLL("ntdll.dll", "byte RtlIsNameLegalDOS8Dot3(void*, void*, void*)")
# 呼び出し: RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces)
# Name : UNICODE_STRING* in/out -> "void*"
# OemName : STRING* in/out -> "void*"
# NameContainsSpaces : BOOLEAN* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ntdll" fn RtlIsNameLegalDOS8Dot3(
Name: [*c]UNICODE_STRING, // UNICODE_STRING* in/out
OemName: [*c]STRING, // STRING* in/out
NameContainsSpaces: [*c]u8 // BOOLEAN* in/out
) callconv(std.os.windows.WINAPI) u8;proc RtlIsNameLegalDOS8Dot3(
Name: ptr UNICODE_STRING, # UNICODE_STRING* in/out
OemName: ptr STRING, # STRING* in/out
NameContainsSpaces: ptr uint8 # BOOLEAN* in/out
): uint8 {.importc: "RtlIsNameLegalDOS8Dot3", stdcall, dynlib: "ntdll.dll".}pragma(lib, "ntdll");
extern(Windows)
ubyte RtlIsNameLegalDOS8Dot3(
UNICODE_STRING* Name, // UNICODE_STRING* in/out
STRING* OemName, // STRING* in/out
ubyte* NameContainsSpaces // BOOLEAN* in/out
);ccall((:RtlIsNameLegalDOS8Dot3, "ntdll.dll"), stdcall, UInt8,
(Ptr{UNICODE_STRING}, Ptr{STRING}, Ptr{UInt8}),
Name, OemName, NameContainsSpaces)
# Name : UNICODE_STRING* in/out -> Ptr{UNICODE_STRING}
# OemName : STRING* in/out -> Ptr{STRING}
# NameContainsSpaces : BOOLEAN* in/out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint8_t RtlIsNameLegalDOS8Dot3(
void* Name,
void* OemName,
uint8_t* NameContainsSpaces);
]]
local ntdll = ffi.load("ntdll")
-- ntdll.RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces)
-- Name : UNICODE_STRING* in/out
-- OemName : STRING* in/out
-- NameContainsSpaces : BOOLEAN* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ntdll.dll');
const RtlIsNameLegalDOS8Dot3 = lib.func('__stdcall', 'RtlIsNameLegalDOS8Dot3', 'uint8_t', ['void *', 'void *', 'uint8_t *']);
// RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces)
// Name : UNICODE_STRING* in/out -> 'void *'
// OemName : STRING* in/out -> 'void *'
// NameContainsSpaces : BOOLEAN* in/out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ntdll.dll", {
RtlIsNameLegalDOS8Dot3: { parameters: ["pointer", "pointer", "pointer"], result: "u8" },
});
// lib.symbols.RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces)
// Name : UNICODE_STRING* in/out -> "pointer"
// OemName : STRING* in/out -> "pointer"
// NameContainsSpaces : BOOLEAN* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint8_t RtlIsNameLegalDOS8Dot3(
void* Name,
void* OemName,
uint8_t* NameContainsSpaces);
C, "ntdll.dll");
// $ffi->RtlIsNameLegalDOS8Dot3(Name, OemName, NameContainsSpaces);
// Name : UNICODE_STRING* in/out
// OemName : STRING* in/out
// NameContainsSpaces : BOOLEAN* 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 Ntdll extends StdCallLibrary {
Ntdll INSTANCE = Native.load("ntdll", Ntdll.class);
byte RtlIsNameLegalDOS8Dot3(
Pointer Name, // UNICODE_STRING* in/out
Pointer OemName, // STRING* in/out
ByteByReference NameContainsSpaces // BOOLEAN* in/out
);
}@[Link("ntdll")]
lib Libntdll
fun RtlIsNameLegalDOS8Dot3 = RtlIsNameLegalDOS8Dot3(
Name : UNICODE_STRING*, # UNICODE_STRING* in/out
OemName : STRING*, # STRING* in/out
NameContainsSpaces : UInt8* # BOOLEAN* in/out
) : UInt8
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtlIsNameLegalDOS8Dot3Native = Uint8 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint8>);
typedef RtlIsNameLegalDOS8Dot3Dart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint8>);
final RtlIsNameLegalDOS8Dot3 = DynamicLibrary.open('ntdll.dll')
.lookupFunction<RtlIsNameLegalDOS8Dot3Native, RtlIsNameLegalDOS8Dot3Dart>('RtlIsNameLegalDOS8Dot3');
// Name : UNICODE_STRING* in/out -> Pointer<Void>
// OemName : STRING* in/out -> Pointer<Void>
// NameContainsSpaces : BOOLEAN* in/out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtlIsNameLegalDOS8Dot3(
Name: Pointer; // UNICODE_STRING* in/out
OemName: Pointer; // STRING* in/out
NameContainsSpaces: Pointer // BOOLEAN* in/out
): ByteBool; stdcall;
external 'ntdll.dll' name 'RtlIsNameLegalDOS8Dot3';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtlIsNameLegalDOS8Dot3"
c_RtlIsNameLegalDOS8Dot3 :: Ptr () -> Ptr () -> Ptr Word8 -> IO Word8
-- Name : UNICODE_STRING* in/out -> Ptr ()
-- OemName : STRING* in/out -> Ptr ()
-- NameContainsSpaces : BOOLEAN* in/out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtlisnamelegaldos8dot3 =
foreign "RtlIsNameLegalDOS8Dot3"
((ptr void) @-> (ptr void) @-> (ptr uint8_t) @-> returning uint8_t)
(* Name : UNICODE_STRING* in/out -> (ptr void) *)
(* OemName : STRING* in/out -> (ptr void) *)
(* NameContainsSpaces : BOOLEAN* in/out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ntdll (t "ntdll.dll"))
(cffi:use-foreign-library ntdll)
(cffi:defcfun ("RtlIsNameLegalDOS8Dot3" rtl-is-name-legal-dos8-dot3 :convention :stdcall) :uint8
(name :pointer) ; UNICODE_STRING* in/out
(oem-name :pointer) ; STRING* in/out
(name-contains-spaces :pointer)) ; BOOLEAN* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtlIsNameLegalDOS8Dot3 = Win32::API::More->new('ntdll',
'BYTE RtlIsNameLegalDOS8Dot3(LPVOID Name, LPVOID OemName, LPVOID NameContainsSpaces)');
# my $ret = $RtlIsNameLegalDOS8Dot3->Call($Name, $OemName, $NameContainsSpaces);
# Name : UNICODE_STRING* in/out -> LPVOID
# OemName : STRING* in/out -> LPVOID
# NameContainsSpaces : BOOLEAN* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。