ReactOS 0.4.15-dev-8100-g1887773
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_hex2(expression, result)
 
#define ok_ptr2(expression, result)
 
#define ok_wstr2(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_hex2

#define ok_hex2 (   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_ptr2

#define ok_ptr2 (   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)

Definition at line 20 of file RtlNtPathNameToDosPathName.c.

◆ ok_wstr2

#define ok_wstr2 (   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{
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}
static void test_table(struct test_entry *Entry)
static void test_specialhandling()
PRTL_UNICODE_STRING_BUFFER PULONG Type
Type
Definition: Type.h:7
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
Definition: bufpool.h:45
Definition: File.h:16
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
GLdouble n
Definition: glext.h:7729
#define RTL_UNCHANGED_UNK_PATH
Definition: rtlfuncs.h:2971
#define L(x)
Definition: ntvdm.h:50
void winetest_set_location(const char *file, int line)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:70
Definition: ncftp.h:79
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ 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}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_ptr(expression, result)
Definition: atltest.h:108
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define RTL_UNCHANGED_DOS_PATH
Definition: rtlfuncs.h:2974
#define RTL_CONVERTED_NT_PATH
Definition: rtlfuncs.h:2973
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
#define memset(x, y, z)
Definition: compat.h:39
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30
unsigned char * PUCHAR
Definition: typedefs.h:53
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_table()

static void test_table ( struct test_entry Entry)
static

Definition at line 360 of file RtlNtPathNameToDosPathName.c.

361{
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_hex2(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
373
374 ok_hex2(Type, Entry->Type);
375 ok_wstr2(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_ptr2(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_wstr2((const WCHAR *)Buffer.ByteBuffer.Buffer, Entry->OutputPath);
389
390 ok_hex2(Buffer.MinimumStaticBufferForTerminalNul, 0);
391
392 /* For none of our tests should we exceed the StaticBuffer size! */
393 ok_ptr2(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
394 ok_hex2(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
395
396 ok_hex2(Buffer.ByteBuffer.ReservedForAllocatedSize, 0);
397 ok_ptr2(Buffer.ByteBuffer.ReservedForIMalloc, NULL);
398
399 RtlFreeBuffer(&Buffer.ByteBuffer);
400}
#define ok_hex2(expression, result)
#define ok_ptr2(expression, result)
#define ok_wstr2(x, y)
#define MAX_PATH
Definition: compat.h:34
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2451
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
base of all file and directory entries
Definition: entries.h:83

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(), AddInstallationSource(), AddSubst(), AllowPermLayer(), ArcOpen(), BasepGetComputerNameFromNtPath(), BasepLoadLibraryAsDatafile(), BeautifyPath(), BlImgLoadBootApplication(), BlImgLoadPEImageEx(), BtrFsOpen(), CabinetNormalizePath(), CheckForGlobalDriveLetter(), CmpWalkPath(), ConnectRegistry(), ConstructDeviceName(), CCabinet::ConvertPath(), ConvertPathCharacters(), CreateFreeLoaderIniForReactOSAndBootSector(), CreateObjectsFromPersistFolder(), CreateShellItemFromParse(), Dde_OnExecute(), DiskOpen(), DissectArcPath(), DllRegisterServer(), DoEntry(), DosChangeDirectory(), DosKRNLInitialize(), EfiInitpCreateApplicationEntry(), ExpandSymbolicLink(), Ext2Open(), FatOpen(), FileQueryFiles(), filesys_BuildPath(), filesys_GetAbsolutePathName(), filesys_GetBaseName(), filesys_GetFileName(), filesys_GetParentFolderName(), FindLFNorSFN_U(), FltpOpenFilterServicesKey(), FsGetFirstNameFromPath(), FsGetNumPathParts(), GetAdapterFriendlyName(), GetAssocClass(), GetAutostartEntriesFromRegistry(), GetCustomIconPath(), CCabinet::GetFileName(), GetFileName(), GetGinaPath(), GetInterfaceFriendlyName(), GetKnownPath(), GetLongPathNameW(), GetNameFromPath(), GetOptUlong(), GetOwnerModuleFromPidEntry(), GetPathCase(), GetProgramFilesPath(), GetShortPathNameW(), GetSpecialPath(), Initialize(), InitOurDirectory(), InstallDefaultSystemSoundScheme(), InstallOneInterface(), InternetExplorer_get_Path(), IntLoadRegistryParameters(), IsoOpen(), KsCacheMedium(), KsOpenDefaultDevice(), KspReadMediaCategory(), LoadModule(), MainWndDropFiles(), CCabinet::NormalizePath(), NtfsOpen(), NtPathToDiskPartComponents(), OFNHookProc(), ok_keys_(), CZipExtract::CCompleteSettingsPage::OnSetActive(), OpenNt4KernelSoundDevice(), OurDirectoryPath(), OurInstallationPath(), PopulateCustomPathCombo(), PxeOpen(), query_typelib_path(), RegKeyHasValues(), RemoveFileName(), CAvailableApplicationInfo::RetrieveIcon(), CInstalledApplicationInfo::RetrieveIcon(), CAvailableApplicationInfo::RetrieveScreenshot(), RtlCheckRegistryKey(), RtlCreateRegistryKey(), RtlDeleteRegistryValue(), RtlDetermineDosPathNameType_U(), RtlDetermineDosPathNameType_Ustr(), RtlDosSearchPath_U(), RtlGetLengthWithoutLastFullDosOrNtPathElement(), RtlIsDosDeviceName_U(), RtlNtPathNameToDosPathName(), RtlpCollapsePath(), RtlpGetRegistryHandle(), RtlQueryRegistryValues(), RtlSetCurrentDirectory_U(), RtlWriteRegistryValue(), RunFontViewer(), RxFcbTableLookupFcb(), ScanFoldersForDriver(), SdbpIsPathOnRemovableMedia(), SearchDriverRecursive(), CDFParser::SetFileRelativePath(), CFontCache::SetFontDir(), SetOptUlong(), SetupDiOpenDeviceInterfaceRegKey(), SHGFI(), SHRegOpenUSKeyA(), SHRegOpenUSKeyW(), SkipPathTypeIndicator_U(), SmpInitializeKnownDllsInternal(), START_TEST(), StartChild(), StartProcess(), Test_ProtectedFiles(), TestIoCreateFile(), TestMessageHandler(), CDownloadManager::ThreadFunc(), UefiDiskOpen(), ViLoadImagesFromRegistry(), WebBrowser_get_Path(), WshShortcut_get_TargetPath(), WshShortcut_put_TargetPath(), and WspiapiLoad().

◆ test_data

Definition at line 43 of file RtlNtPathNameToDosPathName.c.

◆ Type

◆ Unknown4