ReactOS  0.4.12-dev-918-g6c6e7b8
RtlNtPathNameToDosPathName.c File Reference
#include "precomp.h"
Include dependency graph for RtlNtPathNameToDosPathName.c:

Go to the source code of this file.

Classes

struct  test_entry
 

Macros

#define ok_hex_(expression, result)
 
#define ok_ptr_(expression, result)
 
#define ok_wstr_(x, y)   winetest_ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
 

Functions

 NTSTATUS (NTAPI *pRtlNtPathNameToDosPathName)(ULONG Flags
 
static void test_specialhandling ()
 
static void test_table (struct test_entry *Entry)
 
 START_TEST (RtlNtPathNameToDosPathName)
 

Variables

PRTL_UNICODE_STRING_BUFFER Path
 
PRTL_UNICODE_STRING_BUFFER PULONG Type
 
PRTL_UNICODE_STRING_BUFFER PULONG PULONG Unknown4
 
static struct test_entry test_data []
 

Macro Definition Documentation

◆ ok_hex_

#define ok_hex_ (   expression,
  result 
)
Value:
do { \
int _value = (expression); \
winetest_ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
#expression, (int)(result), _value); \
} while (0)
GLuint64EXT * result
Definition: glext.h:11304

Definition at line 12 of file RtlNtPathNameToDosPathName.c.

◆ ok_ptr_

#define ok_ptr_ (   expression,
  result 
)
Value:
do { \
void *_value = (expression); \
winetest_ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
#expression, (void*)(result), _value); \
} while (0)
GLuint64EXT * result
Definition: glext.h:11304

Definition at line 20 of file RtlNtPathNameToDosPathName.c.

◆ ok_wstr_

#define ok_wstr_ (   x,
  y 
)    winetest_ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)

Definition at line 27 of file RtlNtPathNameToDosPathName.c.

Function Documentation

◆ NTSTATUS()

NTSTATUS ( NTAPI pRtlNtPathNameToDosPathName)

◆ START_TEST()

START_TEST ( RtlNtPathNameToDosPathName  )

Definition at line 403 of file RtlNtPathNameToDosPathName.c.

404 {
405  RTL_UNICODE_STRING_BUFFER Buffer = { { 0 } };
406  ULONG Type;
407  size_t n;
408 
409  HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
410  pRtlNtPathNameToDosPathName = (void *)GetProcAddress(ntdll, "RtlNtPathNameToDosPathName");
411 
412  if (!pRtlNtPathNameToDosPathName)
413  {
414  skip("RtlNtPathNameToDosPathName not found?\n");
415  return;
416  }
417 
418  ok_ntstatus(pRtlNtPathNameToDosPathName(0, NULL, NULL, NULL), STATUS_INVALID_PARAMETER);
419  ok_ntstatus(pRtlNtPathNameToDosPathName(0, &Buffer, NULL, NULL), STATUS_SUCCESS);
420  ok_ntstatus(pRtlNtPathNameToDosPathName(1, &Buffer, NULL, NULL), STATUS_INVALID_PARAMETER);
421 
422  Type = 0x12345;
423  ok_ntstatus(pRtlNtPathNameToDosPathName(0, NULL, &Type, NULL), STATUS_INVALID_PARAMETER);
424  ok_int(Type, 0);
425  Type = 0x12345;
426  ok_ntstatus(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
428  Type = 0x12345;
429  ok_ntstatus(pRtlNtPathNameToDosPathName(1, &Buffer, &Type, NULL), STATUS_INVALID_PARAMETER);
430  ok_int(Type, 0);
431 
433 
434  for (n = 0; n < _countof(test_data); ++n)
435  {
438  }
439 }
Type
Definition: Type.h:6
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define _countof(array)
Definition: fontsub.cpp:30
#define ok_int(x, y)
Definition: sprintf.c:21
GLdouble n
Definition: glext.h:7729
static void test_table(struct test_entry *Entry)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define ok_ntstatus(status, expected)
Definition: test.h:800
PRTL_UNICODE_STRING_BUFFER PULONG Type
Definition: ncftp.h:79
static const WCHAR L[]
Definition: oid.c:1250
static void test_specialhandling()
#define skip(...)
Definition: CString.cpp:57
#define RTL_UNCHANGED_UNK_PATH
Definition: rtlfuncs.h:2843
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define GetProcAddress(x, y)
Definition: compat.h:410
Definition: File.h:15
return STATUS_SUCCESS
Definition: btrfs.c:2725
void winetest_set_location(const char *file, int line)

◆ test_specialhandling()

static void test_specialhandling ( )
static

Definition at line 234 of file RtlNtPathNameToDosPathName.c.

235 {
237  const WCHAR TestString[] = L"\\??\\C:\\Test";
238  WCHAR StaticBuffer[_countof(TestString)];
239  ULONG Type;
240  //PUCHAR Ptr;
241 
242  /* Just initializing the ByteBuffer does not work */
243  memset(&Buffer, 0, sizeof(Buffer));
244  RtlInitBuffer(&Buffer.ByteBuffer, (PUCHAR)StaticBuffer, sizeof(StaticBuffer));
245  memcpy(StaticBuffer, TestString, sizeof(TestString));
246  Type = 0x12345;
247 
248  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
250  ok_ptr(Buffer.String.Buffer, NULL);
251  ok_int(Buffer.String.Length, 0);
252  ok_int(Buffer.String.MaximumLength, 0);
253  ok_ptr(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
254  ok_int(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
255  RtlFreeBuffer(&Buffer.ByteBuffer);
256 
257  /* Different strings in the String and ByteBuffer part */
258  memset(&Buffer, 0, sizeof(Buffer));
259  RtlInitBuffer(&Buffer.ByteBuffer, (PUCHAR)StaticBuffer, sizeof(StaticBuffer));
260  memcpy(StaticBuffer, TestString, sizeof(TestString));
261  Type = 0x12345;
262 
263  RtlInitUnicodeString(&Buffer.String, L"\\??\\D:\\1234");
264 
265  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
267  ok_wstr(Buffer.String.Buffer, L"C:\\Test");
268  ok_int(Buffer.String.Length, 14);
269  ok_int(Buffer.String.MaximumLength, 24);
270  ok_ptr(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
271  ok_int(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
272  RtlFreeBuffer(&Buffer.ByteBuffer);
273 
274 
275  /* Different strings, Buffer.String is not prefixed with \??\ */
276  memset(&Buffer, 0, sizeof(Buffer));
277  RtlInitBuffer(&Buffer.ByteBuffer, (PUCHAR)StaticBuffer, sizeof(StaticBuffer));
278  memcpy(StaticBuffer, TestString, sizeof(TestString));
279  Type = 0x12345;
280 
281  RtlInitUnicodeString(&Buffer.String, L"D:\\1234");
282 
283  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
285  ok_wstr(Buffer.String.Buffer, L"D:\\1234");
286  ok_int(Buffer.String.Length, 14);
287  ok_int(Buffer.String.MaximumLength, 16);
288  ok_ptr(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
289  ok_int(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
290  RtlFreeBuffer(&Buffer.ByteBuffer);
291 
292 
293  /* Different strings, smaller ByteBuffer */
294  memset(&Buffer, 0, sizeof(Buffer));
295  RtlInitBuffer(&Buffer.ByteBuffer, (PUCHAR)StaticBuffer, sizeof(StaticBuffer));
296  memcpy(StaticBuffer, TestString, sizeof(TestString));
297  Type = 0x12345;
298 
299  RtlInitUnicodeString(&Buffer.String, L"\\??\\D:\\1234");
300  Buffer.ByteBuffer.Size -= 4 * sizeof(WCHAR);
301 
302  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
304  ok_wstr(Buffer.String.Buffer, L"C:\\Test");
305  ok_int(Buffer.String.Length, 14);
306  ok_ptr(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
307  ok_int(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize - 4 * sizeof(WCHAR));
308  RtlFreeBuffer(&Buffer.ByteBuffer);
309 
310 
311  /* These tests show that the size of the ByteBuffer should
312  at least equal the size of the string (minus 4, in case of \??\)!
313  The results are all over the place, and are most likely the result of implementation details.. */
314 
315 #if 0
316  /* Different strings, too small ByteBuffer
317  --> corrupt buffer, but none of the output params suggests so? */
318  memset(&Buffer, 0, sizeof(Buffer));
319  Buffer.ByteBuffer.Size = wcslen(TestString) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
320  Buffer.ByteBuffer.Buffer = Ptr = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Buffer.ByteBuffer.Size);
321  memcpy(Buffer.ByteBuffer.Buffer, TestString, Buffer.ByteBuffer.Size);
322  Type = 0x12345;
323 
324  RtlInitUnicodeString(&Buffer.String, L"\\??\\D:\\1234");
325  Buffer.ByteBuffer.Size -= 5 * sizeof(WCHAR);
326 
327  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
329  //ok_wstr(Buffer.String.Buffer, L"C:\\");
330  ok_int(Buffer.String.Length, 14);
331  ok_int(Buffer.String.MaximumLength, 16);
332  //ok_ptr(Buffer.ByteBuffer.Buffer, Ptr); // An attempt is made at allocating a buffer, but the move fails because the size of ByteBuffer seems to be used??
333  ok_int(Buffer.ByteBuffer.Size, 16);
334 
335  RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer.ByteBuffer.Buffer);
336 
337  /* Different strings, too small ByteBuffer, different path separators
338  --> corrupt buffer, but none of the output params suggests so? */
339  memset(&Buffer, 0, sizeof(Buffer));
340  Buffer.ByteBuffer.Size = wcslen(L"\\??\\C://Test") * sizeof(WCHAR) + sizeof(UNICODE_NULL);
341  Buffer.ByteBuffer.Buffer = Ptr = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Buffer.ByteBuffer.Size);
342  memcpy(Buffer.ByteBuffer.Buffer, L"\\??\\C://Test", Buffer.ByteBuffer.Size);
343  Type = 0x12345;
344 
345  RtlInitUnicodeString(&Buffer.String, L"\\??\\D:\\1234");
346  Buffer.ByteBuffer.Size -= 5 * sizeof(WCHAR);
347 
348  ok_hex(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
350  //ok_wstr(Buffer.String.Buffer, L"C:\\");
351  ok_int(Buffer.String.Length, 14);
352  ok_int(Buffer.String.MaximumLength, 16);
353  ok_ptr(Buffer.ByteBuffer.Buffer, Ptr);
354  ok_int(Buffer.ByteBuffer.Size, 16);
355 
356  RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer.ByteBuffer.Buffer);
357 #endif
358 }
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30
Type
Definition: Type.h:6
#define _countof(array)
Definition: fontsub.cpp:30
unsigned char * PUCHAR
Definition: retypes.h:3
#define ok_int(x, y)
Definition: sprintf.c:21
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define RTL_UNCHANGED_DOS_PATH
Definition: rtlfuncs.h:2846
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
#define UNICODE_NULL
#define ok_wstr(x, y)
Definition: test.h:795
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
PRTL_UNICODE_STRING_BUFFER PULONG Type
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
#define ok_hex(expression, result)
Definition: test.h:759
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ok_ptr(expression, result)
Definition: test.h:773
#define RTL_CONVERTED_NT_PATH
Definition: rtlfuncs.h:2845
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define RTL_UNCHANGED_UNK_PATH
Definition: rtlfuncs.h:2843
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define memset(x, y, z)
Definition: compat.h:39
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by START_TEST().

◆ test_table()

static void test_table ( struct test_entry Entry)
static

Definition at line 360 of file RtlNtPathNameToDosPathName.c.

361 {
362  RTL_UNICODE_STRING_BUFFER Buffer = { { 0 } };
363  WCHAR StaticBuffer[MAX_PATH];
364  ULONG Type = 0x12345;
365 
366  RtlInitBuffer(&Buffer.ByteBuffer, (PUCHAR)StaticBuffer, sizeof(StaticBuffer));
367 
368  RtlInitUnicodeString(&Buffer.String, Entry->InputPath);
369  RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &Buffer.ByteBuffer, Buffer.String.MaximumLength);
370  memcpy(Buffer.ByteBuffer.Buffer, Buffer.String.Buffer, Buffer.String.MaximumLength);
371 
372  ok_hex_(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
373 
374  ok_hex_(Type, Entry->Type);
375  ok_wstr_(Buffer.String.Buffer, Entry->OutputPath);
376  /* If there is no change in the path, the pointer is unchanged */
377  if (!wcscmp(Entry->InputPath, Entry->OutputPath))
378  {
379  ok_ptr_(Buffer.String.Buffer, Entry->InputPath);
380  }
381  else
382  {
383  /* If there is a change in the path, the 'ByteBuffer' is used */
384  winetest_ok((PUCHAR)Buffer.String.Buffer >= Buffer.ByteBuffer.StaticBuffer &&
385  (PUCHAR)Buffer.String.Buffer <= (Buffer.ByteBuffer.StaticBuffer + Buffer.ByteBuffer.StaticSize),
386  "Expected Buffer to point inside StaticBuffer\n");
387  }
388  ok_wstr_((const WCHAR *)Buffer.ByteBuffer.Buffer, Entry->OutputPath);
389 
390  ok_hex_(Buffer.MinimumStaticBufferForTerminalNul, 0);
391 
392  /* For none of our tests should we exceed the StaticBuffer size! */
393  ok_ptr_(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
394  ok_hex_(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
395 
396  ok_hex_(Buffer.ByteBuffer.ReservedForAllocatedSize, 0);
397  ok_ptr_(Buffer.ByteBuffer.ReservedForIMalloc, NULL);
398 
399  RtlFreeBuffer(&Buffer.ByteBuffer);
400 }
Type
Definition: Type.h:6
unsigned char * PUCHAR
Definition: retypes.h:3
#define ok_wstr_(x, y)
#define ok_hex_(expression, result)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define MAX_PATH
Definition: compat.h:26
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2339
#define ok_ptr_(expression, result)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2725
base of all file and directory entries
Definition: entries.h:82

Referenced by START_TEST().

Variable Documentation

◆ Path

_In_ PCWSTR Path

Definition at line 10 of file RtlNtPathNameToDosPathName.c.

Referenced by _tmain(), AcpiDsLoad1BeginOp(), AcpiInstallMethod(), AcpiNsLookup(), AcpiPsGetNextNamepath(), AcpiRsGetMethodData(), AcpiUtEvaluateObject(), AcpiUtMethodError(), AddSubst(), AllowPermLayer(), ArcOpen(), ArmDiskGetBootPath(), BasepGetComputerNameFromNtPath(), BasepLoadLibraryAsDatafile(), BeautifyPath(), BlImgLoadBootApplication(), BlImgLoadPEImageEx(), BtrFsOpen(), CabinetNormalizePath(), CmpWalkPath(), ConnectRegistry(), ConstructDeviceName(), CCabinet::ConvertPath(), ConvertPathCharacters(), CreateShortcut(), Dde_OnExecute(), DiskOpen(), DoEntry(), DosChangeDirectory(), DosKRNLInitialize(), EfiInitpCreateApplicationEntry(), Execute(), ExpandSymbolicLink(), Ext2Open(), FatOpen(), FileQueryFiles(), filesys_BuildPath(), filesys_GetAbsolutePathName(), filesys_GetBaseName(), filesys_GetFileName(), filesys_GetParentFolderName(), FindLFNorSFN_U(), FltpOpenFilterServicesKey(), FsGetFirstNameFromPath(), FsGetNumPathParts(), GetAutostartEntriesFromRegistry(), GetConnectionType(), CCabinet::GetFileName(), GetFileName(), GetGinaPath(), GetLongPathNameW(), GetOptUlong(), GetOwnerModuleFromPidEntry(), GetPathCase(), GetShortPathNameW(), InstallDefaultSystemSoundScheme(), InstallOneInterface(), InternetExplorer_get_Path(), IsoOpen(), KsCacheMedium(), KsOpenDefaultDevice(), KspReadMediaCategory(), LoadModule(), MainWndDropFiles(), CCabinet::NormalizePath(), NtfsOpen(), NtPathToDiskPartComponents(), OFNHookProc(), ok_keys_(), CZipExtract::CCompleteSettingsPage::OnSetActive(), OpenNt4KernelSoundDevice(), PopulateCustomPathCombo(), ProcessDirectories(), ProcessFiles(), PxeOpen(), query_typelib_path(), CCabinet::RemoveFileName(), RemoveFileName(), RtlCheckRegistryKey(), RtlCreateRegistryKey(), RtlDeleteRegistryValue(), RtlDetermineDosPathNameType_U(), RtlDetermineDosPathNameType_Ustr(), RtlDosSearchPath_U(), RtlIsDosDeviceName_U(), RtlNtPathNameToDosPathName(), RtlpCollapsePath(), RtlpGetRegistryHandle(), RtlQueryRegistryValues(), RtlSetCurrentDirectory_U(), RtlWriteRegistryValue(), RxFcbTableLookupFcb(), ScanFoldersForDriver(), SdbpIsPathOnRemovableMedia(), SearchDriverRecursive(), CDFParser::SetFileRelativePath(), SetOptUlong(), SetupDiOpenDeviceInterfaceRegKey(), SHRegOpenUSKeyA(), SHRegOpenUSKeyW(), SkipPathTypeIndicator_U(), SmpInitializeKnownDllsInternal(), START_TEST(), StartChild(), StartProcess(), Test_ProtectedFiles(), TestIoCreateFile(), TestMessageHandler(), CDownloadManager::ThreadFunc(), VideoPortIsNoVesa(), ViLoadImagesFromRegistry(), WebBrowser_get_Path(), WshShortcut_get_TargetPath(), WshShortcut_put_TargetPath(), and WspiapiLoad().

◆ test_data

Definition at line 43 of file RtlNtPathNameToDosPathName.c.

◆ Type

◆ Unknown4