reactos/modules/rostests/kmtests/rtl/RtlStrSafe.c

186 lines
6.2 KiB
C
Raw Normal View History

[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
/*
* PROJECT: ReactOS kernel-mode tests
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
* PURPOSE: Test for ntstrsafe.h functions
* COPYRIGHT: Copyright 2018 Hern<EFBFBD>n Di Pietro <hernan.di.pietro@gmail.com>
* Copyright 2019 Colin Finck <colin@reactos.org>
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
*/
#define KMT_EMULATE_KERNEL
#include <kmt_test.h>
#include <ntstrsafe.h>
#include <ntdef.h>
#include <ndk/rtlfuncs.h>
#define TESTAPI static void
static const WCHAR FormatStringInts[] = L"%d %d %d";
static const WCHAR FormatStringIntsResult[] = L"1 2 3";
static const WCHAR FormatStringStrs[] = L"%s %s %s";
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
TESTAPI
Test_RtlUnicodeStringPrintf()
{
NTSTATUS Status;
PWSTR pBuffer = NULL;
USHORT BufferSize;
size_t EqualBytes;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
UNICODE_STRING UsString;
KmtStartSeh();
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
/* STATUS_SUCCESS test */
BufferSize = 6 * sizeof(WCHAR);
pBuffer = KmtAllocateGuarded(BufferSize);
if (!pBuffer)
goto Cleanup;
RtlFillMemory(pBuffer, BufferSize, 0xAA);
RtlInitEmptyUnicodeString(&UsString, pBuffer, BufferSize);
Status = RtlUnicodeStringPrintf(&UsString, FormatStringInts, 1, 2, 3);
EqualBytes = RtlCompareMemory(UsString.Buffer, FormatStringIntsResult, sizeof(FormatStringIntsResult));
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_size(EqualBytes, sizeof(FormatStringIntsResult));
ok_eq_uint(UsString.Length, sizeof(FormatStringIntsResult) - sizeof(WCHAR));
ok_eq_uint(UsString.MaximumLength, BufferSize);
KmtFreeGuarded(pBuffer);
pBuffer = NULL;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
/* STATUS_BUFFER_OVERFLOW tests */
BufferSize = 2 * sizeof(WCHAR);
pBuffer = KmtAllocateGuarded(BufferSize);
if (!pBuffer)
goto Cleanup;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
RtlInitEmptyUnicodeString(&UsString, pBuffer, BufferSize);
Status = RtlUnicodeStringPrintf(&UsString, FormatStringStrs, L"AAA", L"BBB", L"CCC");
EqualBytes = RtlCompareMemory(UsString.Buffer, L"AA", BufferSize);
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
ok_eq_size(EqualBytes, BufferSize);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
ok_eq_uint(UsString.Length, UsString.MaximumLength);
KmtFreeGuarded(pBuffer);
pBuffer = NULL;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
BufferSize = 7 * sizeof(WCHAR);
pBuffer = KmtAllocateGuarded(BufferSize);
if (!pBuffer)
goto Cleanup;
RtlInitEmptyUnicodeString(&UsString, pBuffer, BufferSize);
Status = RtlUnicodeStringPrintf(&UsString, FormatStringStrs, L"0123", L"4567", L"89AB");
EqualBytes = RtlCompareMemory(UsString.Buffer, L"0123 45", BufferSize);
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
ok_eq_size(EqualBytes, BufferSize);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
ok_eq_uint(UsString.Length, UsString.MaximumLength);
KmtFreeGuarded(pBuffer);
pBuffer = NULL;
// Note: RtlUnicodeStringPrintf returns STATUS_BUFFER_OVERFLOW here while RtlUnicodeStringPrintfEx returns STATUS_INVALID_PARAMETER!
// Documented on MSDN and verified with the Win10 version of ntstrsafe.h
RtlInitEmptyUnicodeString(&UsString, NULL, 0);
Status = RtlUnicodeStringPrintf(&UsString, FormatStringStrs, L"AAA", L"BBB", L"CCC");
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
Cleanup:
if (pBuffer)
KmtFreeGuarded(pBuffer);
// None of these functions should have crashed.
KmtEndSeh(STATUS_SUCCESS);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
}
TESTAPI
Test_RtlUnicodeStringPrintfEx()
{
NTSTATUS Status;
PWSTR pBuffer = NULL;
USHORT BufferSize;
size_t EqualBytes;
UNICODE_STRING RemString;
UNICODE_STRING UsString;
WCHAR FillResult[10];
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
RtlFillMemory(FillResult, sizeof(FillResult), 0xAA);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
KmtStartSeh();
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
/* STATUS_SUCCESS test, fill behind flag: low-byte as fill character */
BufferSize = sizeof(FormatStringIntsResult) - sizeof(UNICODE_NULL) + sizeof(FillResult);
pBuffer = KmtAllocateGuarded(BufferSize);
if (!pBuffer)
goto Cleanup;
RtlInitEmptyUnicodeString(&UsString, pBuffer, BufferSize);
RtlInitEmptyUnicodeString(&RemString, NULL, 0);
Status = RtlUnicodeStringPrintfEx(&UsString, &RemString, STRSAFE_FILL_BEHIND | 0xAA, FormatStringInts, 1, 2, 3);
EqualBytes = RtlCompareMemory(UsString.Buffer, FormatStringIntsResult, sizeof(FormatStringIntsResult) - sizeof(WCHAR));
ok_eq_hex(Status, STATUS_SUCCESS);
ok_eq_size(EqualBytes, sizeof(FormatStringIntsResult) - sizeof(WCHAR));
ok_eq_uint(UsString.Length, sizeof(FormatStringIntsResult) - sizeof(WCHAR));
ok_eq_uint(UsString.MaximumLength, BufferSize);
ok_eq_pointer(RemString.Buffer, &UsString.Buffer[UsString.Length / sizeof(WCHAR)]);
ok_eq_uint(RemString.Length, 0);
ok_eq_uint(RemString.MaximumLength, UsString.MaximumLength - UsString.Length);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
EqualBytes = RtlCompareMemory(RemString.Buffer, FillResult, RemString.MaximumLength);
ok_eq_size(EqualBytes, sizeof(FillResult));
KmtFreeGuarded(pBuffer);
pBuffer = NULL;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
/* STATUS_BUFFER_OVERFLOW test */
BufferSize = 8 * sizeof(WCHAR);
pBuffer = KmtAllocateGuarded(BufferSize);
if (!pBuffer)
goto Cleanup;
RtlInitEmptyUnicodeString(&UsString, pBuffer, BufferSize);
RtlInitEmptyUnicodeString(&RemString, NULL, 0);
Status = RtlUnicodeStringPrintfEx(&UsString, &RemString, 0, FormatStringStrs, L"AAA", L"BBB", L"CCC");
EqualBytes = RtlCompareMemory(UsString.Buffer, L"AAA BBB ", UsString.Length);
ok_eq_hex(Status, STATUS_BUFFER_OVERFLOW);
ok_eq_size(EqualBytes, UsString.Length);
ok_eq_uint(UsString.Length, UsString.MaximumLength);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
ok_eq_pointer(RemString.Buffer, &UsString.Buffer[UsString.Length / sizeof(WCHAR)]);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
ok_eq_uint(RemString.Length, 0);
ok_eq_uint(RemString.MaximumLength, 0);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
KmtFreeGuarded(pBuffer);
pBuffer = NULL;
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
// Note: RtlUnicodeStringPrintf returns STATUS_BUFFER_OVERFLOW here while RtlUnicodeStringPrintfEx returns STATUS_INVALID_PARAMETER!
// Documented on MSDN and verified with the Win10 version of ntstrsafe.h
RtlInitEmptyUnicodeString(&UsString, NULL, 0);
Status = RtlUnicodeStringPrintfEx(&UsString, NULL, 0, FormatStringStrs, L"AAA", L"BBB", L"CCC");
ok_eq_hex(Status, STATUS_INVALID_PARAMETER);
Cleanup:
if (pBuffer)
KmtFreeGuarded(pBuffer);
// None of these functions should have crashed.
KmtEndSeh(STATUS_SUCCESS);
[DDK] RtlUnicodeStringPrintf(Ex) implementations and ntstrsafe.h tests (#522, #523) [KMTESTS:RTL] (CORE-14565) + Added buffer overrun tests. + New style header. + ISO C90 compatibility [DDK] (CORE-9819): RtlUnicodeStringPrintf(Ex) and RtlUnicodeStringValidate(Ex) fixes plus formatting. [DDK]: Cosmetic changes (NTSTATUS variable naming and tabs) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [DDK] First implementation of Unicode functions for NtStrSafe (CORE-9819) + This implementation does not modify the interface of previous functions. + Since we need length returned for the destination UNICODE_STRING.Length field: - an intermediate "Len" postfixed function was added with optional argument to return the _vsnwprintf character count. - Wide Printf(Ex) functions already existent work now call new Rtlp private worker functions. + For several UnicodeStringPrintf(Ex) tests, see work going on CORE-14565 NOTES: + MSDN says they won't insert NULL characters on formatted strings. But seems this is incorrect at MSDN (interpret this as DONT ASSUME NULL-termination). We return zero-terminated strings, and MS functions seems to do the same. (XP DDK 7.1) [KMTESTS:RTL] Tests for new RtlUnicodePrintf(Ex) functions (CORE-14565) + 45 Tests working. + Lacks remaining non-Unicode functions in NtStrSafe.h for now. + Used for first tests on CORE-9819 [KMTESTS/RTL] Fixed test not taking care of null (CORE-14565) [DDK] Fixed bad NtStrSafe.h va_start call (CORE-9819) [KMTESTS:RTL] First Test. Update on RtlUnicodeStringPrintfEx plus cosmetic changes. [KMTESTS] Added NtStrSafe to test lists (CORE-14565) First commit: Skeleton for test implementation + Addition to COMMON SOURCES in kmtests Cmake lists. WIP. +Implementation of RtlStringVPrintfWorkerLenW, RtlStringVPrintfExWorkerLenW to avoid changing existing public functions. This is required as existent functions did not return vsnprintf result, so we didn't have any return info to update UNICODE_STRING.Length. +Additional implementation of RtlUnicodeStringValidate for checking purposes. +Former RtlStringVPrintfWorker(ex) refactored to RtlInternalStringVPrintf(Ex)WorkerW. +No ANSI functions affected as we didn't need them for Unicode printf's. WIP: RtlUnicodeStringPrintf
2018-04-21 06:56:12 +00:00
}
START_TEST(RtlStrSafe)
{
Test_RtlUnicodeStringPrintf();
Test_RtlUnicodeStringPrintfEx();
}