Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- In Windows the last hexadecimal component of an IPv6 address may start with 0x and have an arbitrary number of digits, and in that case the address can be longer than 64 characters. --- dlls/ntdll/rtl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 6134a5e702..bccf26d7d6 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -1269,7 +1269,7 @@ NTSTATUS WINAPI RtlIpv6StringToAddressW(const WCHAR *str, const WCHAR **terminat */ NTSTATUS WINAPI RtlIpv6StringToAddressExA(const char *str, IN6_ADDR *address, ULONG *scope, USHORT *port) { - WCHAR wstr[64]; + WCHAR wstr[128];
TRACE("(%s, %p, %p, %p)\n", debugstr_a(str), address, scope, port);
@@ -1286,7 +1286,7 @@ NTSTATUS WINAPI RtlIpv6StringToAddressExA(const char *str, IN6_ADDR *address, UL */ NTSTATUS WINAPI RtlIpv6StringToAddressA(const char *str, const char **terminator, IN6_ADDR *address) { - WCHAR wstr[64]; + WCHAR wstr[128]; const WCHAR *wterminator = NULL; NTSTATUS ret;
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- include/ip2string.h | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/include/ip2string.h b/include/ip2string.h index 0753ee82a9..4c5f36c15f 100644 --- a/include/ip2string.h +++ b/include/ip2string.h @@ -23,6 +23,13 @@ extern "C" { #endif
+char * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *address, char *str); +WCHAR * WINAPI RtlIpv4AddressToStringW(const IN_ADDR *address, WCHAR *str); +#define RtlIpv4AddressToString WINELIB_NAME_AW(RtlIpv4AddressToString) +NTSTATUS WINAPI RtlIpv4AddressToStringExA(const IN_ADDR *address, USHORT port, char *str, ULONG *size); +NTSTATUS WINAPI RtlIpv4AddressToStringExW(const IN_ADDR *address, USHORT port, WCHAR *str, ULONG *size); +#define RtlIpv4AddressToStringEx WINELIB_NAME_AW(RtlIpv4AddressToStringEx) + NTSTATUS WINAPI RtlIpv4StringToAddressA(const char *str, BOOLEAN strict, const char **terminator, IN_ADDR *address); NTSTATUS WINAPI RtlIpv4StringToAddressW(const WCHAR *str, BOOLEAN strict, const WCHAR **terminator, IN_ADDR *address); #define RtlIpv4StringToAddress WINELIB_NAME_AW(RtlIpv4StringToAddress)
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/rtl.c | 4 ++-- include/winnt.h | 1 + include/winternl.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index bccf26d7d6..003e4a1b3b 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -546,10 +546,10 @@ SIZE_T WINAPI RtlCompareMemory( const VOID *Source1, const VOID *Source2, SIZE_T * RETURNS * The byte position of the first byte at which Source1 is not dwVal. */ -SIZE_T WINAPI RtlCompareMemoryUlong(const ULONG *Source1, SIZE_T Length, ULONG dwVal) +SIZE_T WINAPI RtlCompareMemoryUlong(VOID *Source1, SIZE_T Length, ULONG dwVal) { SIZE_T i; - for(i = 0; i < Length/sizeof(ULONG) && Source1[i] == dwVal; i++); + for(i = 0; i < Length/sizeof(ULONG) && ((ULONG *)Source1)[i] == dwVal; i++); return i * sizeof(ULONG); }
diff --git a/include/winnt.h b/include/winnt.h index 3e3ac338bc..ae9177842b 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -6034,6 +6034,7 @@ typedef enum _CM_ERROR_CONTROL_TYPE } SERVICE_ERROR_TYPE;
NTSYSAPI SIZE_T WINAPI RtlCompareMemory(const VOID*, const VOID*, SIZE_T); +NTSYSAPI SIZE_T WINAPI RtlCompareMemoryUlong(VOID*, SIZE_T, ULONG);
#define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length))) #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length)) diff --git a/include/winternl.h b/include/winternl.h index e197a55a27..b70460f314 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2727,6 +2727,7 @@ NTSYSAPI NTSTATUS WINAPI NtWriteRequestData(HANDLE,PLPC_MESSAGE,ULONG,PVOID,ULO NTSYSAPI NTSTATUS WINAPI NtWriteVirtualMemory(HANDLE,void*,const void*,SIZE_T,SIZE_T*); NTSYSAPI NTSTATUS WINAPI NtYieldExecution(void);
+NTSYSAPI NTSTATUS WINAPI RtlAbsoluteToSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,PULONG); NTSYSAPI void WINAPI RtlAcquirePebLock(void); NTSYSAPI BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK,BYTE); NTSYSAPI BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK,BYTE); @@ -2800,6 +2801,7 @@ NTSYSAPI NTSTATUS WINAPI RtlCustomCPToUnicodeN(CPTABLEINFO*,WCHAR*,DWORD,DWORD* NTSYSAPI void WINAPI RtlDeactivateActivationContext(DWORD,ULONG_PTR); NTSYSAPI PVOID WINAPI RtlDecodePointer(PVOID); NTSYSAPI NTSTATUS WINAPI RtlDecompressBuffer(USHORT,PUCHAR,ULONG,PUCHAR,ULONG,PULONG); +NTSYSAPI NTSTATUS WINAPI RtlDecompressFragment(USHORT,PUCHAR,ULONG,PUCHAR,ULONG,ULONG,PULONG,PVOID); NTSYSAPI NTSTATUS WINAPI RtlDeleteAce(PACL,DWORD); NTSYSAPI NTSTATUS WINAPI RtlDeleteAtomFromAtomTable(RTL_ATOM_TABLE,RTL_ATOM); NTSYSAPI NTSTATUS WINAPI RtlDeleteCriticalSection(RTL_CRITICAL_SECTION *);
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/tests/rtl.c | 459 ++++++++++++----------------------------- 1 file changed, 133 insertions(+), 326 deletions(-)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 9d6db9d08d..0cbf0b33ff 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -26,6 +26,7 @@ #include "ntdll_test.h" #include "in6addr.h" #include "inaddr.h" +#include "ip2string.h"
#ifndef __WINE_WINTERNL_H
@@ -63,53 +64,23 @@ static inline USHORT __my_ushort_swap(USHORT s)
/* Function ptrs for ntdll calls */ static HMODULE hntdll = 0; -static SIZE_T (WINAPI *pRtlCompareMemory)(LPCVOID,LPCVOID,SIZE_T); -static SIZE_T (WINAPI *pRtlCompareMemoryUlong)(PULONG, SIZE_T, ULONG); -static NTSTATUS (WINAPI *pRtlDeleteTimer)(HANDLE, HANDLE, HANDLE); static VOID (WINAPI *pRtlMoveMemory)(LPVOID,LPCVOID,SIZE_T); static VOID (WINAPI *pRtlFillMemory)(LPVOID,SIZE_T,BYTE); static VOID (WINAPI *pRtlFillMemoryUlong)(LPVOID,SIZE_T,ULONG); static VOID (WINAPI *pRtlZeroMemory)(LPVOID,SIZE_T); static ULONGLONG (WINAPIV *pRtlUlonglongByteSwap)(ULONGLONG source); -static ULONG (WINAPI *pRtlUniform)(PULONG); -static ULONG (WINAPI *pRtlRandom)(PULONG); -static BOOLEAN (WINAPI *pRtlAreAllAccessesGranted)(ACCESS_MASK, ACCESS_MASK); -static BOOLEAN (WINAPI *pRtlAreAnyAccessesGranted)(ACCESS_MASK, ACCESS_MASK); -static DWORD (WINAPI *pRtlComputeCrc32)(DWORD,const BYTE*,INT); -static void (WINAPI * pRtlInitializeHandleTable)(ULONG, ULONG, RTL_HANDLE_TABLE *); -static BOOLEAN (WINAPI * pRtlIsValidIndexHandle)(const RTL_HANDLE_TABLE *, ULONG, RTL_HANDLE **); -static NTSTATUS (WINAPI * pRtlDestroyHandleTable)(RTL_HANDLE_TABLE *); -static RTL_HANDLE * (WINAPI * pRtlAllocateHandle)(RTL_HANDLE_TABLE *, ULONG *); -static BOOLEAN (WINAPI * pRtlFreeHandle)(RTL_HANDLE_TABLE *, RTL_HANDLE *); -static NTSTATUS (WINAPI *pRtlAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID*); -static NTSTATUS (WINAPI *pRtlFreeSid)(PSID); static DWORD (WINAPI *pRtlGetThreadErrorMode)(void); static NTSTATUS (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD); -static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,USHORT*,INT_PTR); -static CHAR * (WINAPI *pRtlIpv4AddressToStringA)(const IN_ADDR *, LPSTR); static NTSTATUS (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG); -static NTSTATUS (WINAPI *pRtlIpv4StringToAddressA)(PCSTR, BOOLEAN, PCSTR *, IN_ADDR *); static NTSTATUS (WINAPI *pRtlIpv4StringToAddressExA)(PCSTR, BOOLEAN, IN_ADDR *, PUSHORT); static CHAR * (WINAPI *pRtlIpv6AddressToStringA)(struct in6_addr *, PSTR); static NTSTATUS (WINAPI *pRtlIpv6AddressToStringExA)(struct in6_addr *, ULONG, USHORT, PCHAR, PULONG); -static NTSTATUS (WINAPI *pRtlIpv6StringToAddressA)(PCSTR, PCSTR *, struct in6_addr *); -static NTSTATUS (WINAPI *pRtlIpv6StringToAddressW)(PCWSTR, PCWSTR *, struct in6_addr *); static NTSTATUS (WINAPI *pRtlIpv6StringToAddressExA)(PCSTR, struct in6_addr *, PULONG, PUSHORT); static NTSTATUS (WINAPI *pRtlIpv6StringToAddressExW)(PCWSTR, struct in6_addr *, PULONG, PUSHORT); -static NTSTATUS (WINAPI *pLdrAddRefDll)(ULONG, HMODULE); -static NTSTATUS (WINAPI *pLdrLockLoaderLock)(ULONG, ULONG*, ULONG_PTR*); -static NTSTATUS (WINAPI *pLdrUnlockLoaderLock)(ULONG, ULONG_PTR); -static NTSTATUS (WINAPI *pRtlMultiByteToUnicodeN)(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD); -static NTSTATUS (WINAPI *pRtlGetCompressionWorkSpaceSize)(USHORT, PULONG, PULONG); -static NTSTATUS (WINAPI *pRtlDecompressBuffer)(USHORT, PUCHAR, ULONG, const UCHAR*, ULONG, PULONG); -static NTSTATUS (WINAPI *pRtlDecompressFragment)(USHORT, PUCHAR, ULONG, const UCHAR*, ULONG, ULONG, PULONG, PVOID); -static NTSTATUS (WINAPI *pRtlCompressBuffer)(USHORT, const UCHAR*, ULONG, PUCHAR, ULONG, ULONG, PULONG, PVOID); static BOOL (WINAPI *pRtlIsCriticalSectionLocked)(CRITICAL_SECTION *); static BOOL (WINAPI *pRtlIsCriticalSectionLockedByThread)(CRITICAL_SECTION *); static NTSTATUS (WINAPI *pRtlInitializeCriticalSectionEx)(CRITICAL_SECTION *, ULONG, ULONG); static NTSTATUS (WINAPI *pLdrEnumerateLoadedModules)(void *, void *, void *); -static NTSTATUS (WINAPI *pRtlMakeSelfRelativeSD)(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD); -static NTSTATUS (WINAPI *pRtlAbsoluteToSelfRelativeSD)(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,PULONG); static NTSTATUS (WINAPI *pLdrRegisterDllNotification)(ULONG, PLDR_DLL_NOTIFICATION_FUNCTION, void *, void **); static NTSTATUS (WINAPI *pLdrUnregisterDllNotification)(void *);
@@ -134,53 +105,23 @@ static void InitFunctionPtrs(void) hntdll = LoadLibraryA("ntdll.dll"); ok(hntdll != 0, "LoadLibrary failed\n"); if (hntdll) { - pRtlCompareMemory = (void *)GetProcAddress(hntdll, "RtlCompareMemory"); - pRtlCompareMemoryUlong = (void *)GetProcAddress(hntdll, "RtlCompareMemoryUlong"); - pRtlDeleteTimer = (void *)GetProcAddress(hntdll, "RtlDeleteTimer"); pRtlMoveMemory = (void *)GetProcAddress(hntdll, "RtlMoveMemory"); pRtlFillMemory = (void *)GetProcAddress(hntdll, "RtlFillMemory"); pRtlFillMemoryUlong = (void *)GetProcAddress(hntdll, "RtlFillMemoryUlong"); pRtlZeroMemory = (void *)GetProcAddress(hntdll, "RtlZeroMemory"); pRtlUlonglongByteSwap = (void *)GetProcAddress(hntdll, "RtlUlonglongByteSwap"); - pRtlUniform = (void *)GetProcAddress(hntdll, "RtlUniform"); - pRtlRandom = (void *)GetProcAddress(hntdll, "RtlRandom"); - pRtlAreAllAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAllAccessesGranted"); - pRtlAreAnyAccessesGranted = (void *)GetProcAddress(hntdll, "RtlAreAnyAccessesGranted"); - pRtlComputeCrc32 = (void *)GetProcAddress(hntdll, "RtlComputeCrc32"); - pRtlInitializeHandleTable = (void *)GetProcAddress(hntdll, "RtlInitializeHandleTable"); - pRtlIsValidIndexHandle = (void *)GetProcAddress(hntdll, "RtlIsValidIndexHandle"); - pRtlDestroyHandleTable = (void *)GetProcAddress(hntdll, "RtlDestroyHandleTable"); - pRtlAllocateHandle = (void *)GetProcAddress(hntdll, "RtlAllocateHandle"); - pRtlFreeHandle = (void *)GetProcAddress(hntdll, "RtlFreeHandle"); - pRtlAllocateAndInitializeSid = (void *)GetProcAddress(hntdll, "RtlAllocateAndInitializeSid"); - pRtlFreeSid = (void *)GetProcAddress(hntdll, "RtlFreeSid"); pRtlGetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlGetThreadErrorMode"); pRtlSetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlSetThreadErrorMode"); - pLdrProcessRelocationBlock = (void *)GetProcAddress(hntdll, "LdrProcessRelocationBlock"); - pRtlIpv4AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringA"); pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA"); - pRtlIpv4StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressA"); pRtlIpv4StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressExA"); pRtlIpv6AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringA"); pRtlIpv6AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringExA"); - pRtlIpv6StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressA"); - pRtlIpv6StringToAddressW = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressW"); pRtlIpv6StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressExA"); pRtlIpv6StringToAddressExW = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressExW"); - pLdrAddRefDll = (void *)GetProcAddress(hntdll, "LdrAddRefDll"); - pLdrLockLoaderLock = (void *)GetProcAddress(hntdll, "LdrLockLoaderLock"); - pLdrUnlockLoaderLock = (void *)GetProcAddress(hntdll, "LdrUnlockLoaderLock"); - pRtlMultiByteToUnicodeN = (void *)GetProcAddress(hntdll, "RtlMultiByteToUnicodeN"); - pRtlGetCompressionWorkSpaceSize = (void *)GetProcAddress(hntdll, "RtlGetCompressionWorkSpaceSize"); - pRtlDecompressBuffer = (void *)GetProcAddress(hntdll, "RtlDecompressBuffer"); - pRtlDecompressFragment = (void *)GetProcAddress(hntdll, "RtlDecompressFragment"); - pRtlCompressBuffer = (void *)GetProcAddress(hntdll, "RtlCompressBuffer"); pRtlIsCriticalSectionLocked = (void *)GetProcAddress(hntdll, "RtlIsCriticalSectionLocked"); pRtlIsCriticalSectionLockedByThread = (void *)GetProcAddress(hntdll, "RtlIsCriticalSectionLockedByThread"); pRtlInitializeCriticalSectionEx = (void *)GetProcAddress(hntdll, "RtlInitializeCriticalSectionEx"); pLdrEnumerateLoadedModules = (void *)GetProcAddress(hntdll, "LdrEnumerateLoadedModules"); - pRtlMakeSelfRelativeSD = (void *)GetProcAddress(hntdll, "RtlMakeSelfRelativeSD"); - pRtlAbsoluteToSelfRelativeSD = (void *)GetProcAddress(hntdll, "RtlAbsoluteToSelfRelativeSD"); pLdrRegisterDllNotification = (void *)GetProcAddress(hntdll, "LdrRegisterDllNotification"); pLdrUnregisterDllNotification = (void *)GetProcAddress(hntdll, "LdrUnregisterDllNotification"); } @@ -193,19 +134,13 @@ static void InitFunctionPtrs(void) ok(strlen(src) == 15, "Source must be 16 bytes long!\n"); }
-#define COMP(str1,str2,cmplen,len) size = pRtlCompareMemory(str1, str2, cmplen); \ +#define COMP(str1,str2,cmplen,len) size = RtlCompareMemory(str1, str2, cmplen); \ ok(size == len, "Expected %ld, got %ld\n", size, (SIZE_T)len)
static void test_RtlCompareMemory(void) { SIZE_T size;
- if (!pRtlCompareMemory) - { - win_skip("RtlCompareMemory is not available\n"); - return; - } - strcpy(dest, src);
COMP(src,src,0,0); @@ -219,49 +154,43 @@ static void test_RtlCompareMemoryUlong(void) ULONG a[10]; ULONG result;
- if (!pRtlCompareMemoryUlong) - { - win_skip("RtlCompareMemoryUlong is not available\n"); - return; - } - a[0]= 0x0123; a[1]= 0x4567; a[2]= 0x89ab; a[3]= 0xcdef; - result = pRtlCompareMemoryUlong(a, 0, 0x0123); + result = RtlCompareMemoryUlong(a, 0, 0x0123); ok(result == 0, "RtlCompareMemoryUlong(%p, 0, 0x0123) returns %u, expected 0\n", a, result); - result = pRtlCompareMemoryUlong(a, 3, 0x0123); + result = RtlCompareMemoryUlong(a, 3, 0x0123); ok(result == 0, "RtlCompareMemoryUlong(%p, 3, 0x0123) returns %u, expected 0\n", a, result); - result = pRtlCompareMemoryUlong(a, 4, 0x0123); + result = RtlCompareMemoryUlong(a, 4, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 4, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 5, 0x0123); + result = RtlCompareMemoryUlong(a, 5, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 5, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 7, 0x0123); + result = RtlCompareMemoryUlong(a, 7, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 7, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 8, 0x0123); + result = RtlCompareMemoryUlong(a, 8, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 8, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 9, 0x0123); + result = RtlCompareMemoryUlong(a, 9, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 9, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 4, 0x0127); + result = RtlCompareMemoryUlong(a, 4, 0x0127); ok(result == 0, "RtlCompareMemoryUlong(%p, 4, 0x0127) returns %u, expected 0\n", a, result); - result = pRtlCompareMemoryUlong(a, 4, 0x7123); + result = RtlCompareMemoryUlong(a, 4, 0x7123); ok(result == 0, "RtlCompareMemoryUlong(%p, 4, 0x7123) returns %u, expected 0\n", a, result); - result = pRtlCompareMemoryUlong(a, 16, 0x4567); + result = RtlCompareMemoryUlong(a, 16, 0x4567); ok(result == 0, "RtlCompareMemoryUlong(%p, 16, 0x4567) returns %u, expected 0\n", a, result);
a[1]= 0x0123; - result = pRtlCompareMemoryUlong(a, 3, 0x0123); + result = RtlCompareMemoryUlong(a, 3, 0x0123); ok(result == 0, "RtlCompareMemoryUlong(%p, 3, 0x0123) returns %u, expected 0\n", a, result); - result = pRtlCompareMemoryUlong(a, 4, 0x0123); + result = RtlCompareMemoryUlong(a, 4, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 4, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 5, 0x0123); + result = RtlCompareMemoryUlong(a, 5, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 5, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 7, 0x0123); + result = RtlCompareMemoryUlong(a, 7, 0x0123); ok(result == 4, "RtlCompareMemoryUlong(%p, 7, 0x0123) returns %u, expected 4\n", a, result); - result = pRtlCompareMemoryUlong(a, 8, 0x0123); + result = RtlCompareMemoryUlong(a, 8, 0x0123); ok(result == 8, "RtlCompareMemoryUlong(%p, 8, 0x0123) returns %u, expected 8\n", a, result); - result = pRtlCompareMemoryUlong(a, 9, 0x0123); + result = RtlCompareMemoryUlong(a, 9, 0x0123); ok(result == 8, "RtlCompareMemoryUlong(%p, 9, 0x0123) returns %u, expected 8\n", a, result); }
@@ -382,12 +311,6 @@ static void test_RtlUlonglongByteSwap(void) return; }
- if ( pRtlUlonglongByteSwap( 0 ) != 0 ) - { - win_skip("Broken RtlUlonglongByteSwap in win2k\n"); - return; - } - result = pRtlUlonglongByteSwap( ((ULONGLONG)0x76543210 << 32) | 0x87654321 ); ok( (((ULONGLONG)0x21436587 << 32) | 0x10325476) == result, "RtlUlonglongByteSwap(0x7654321087654321) returns 0x%s, expected 0x2143658710325476\n", @@ -403,12 +326,6 @@ static void test_RtlUniform(void) ULONG expected; ULONG result;
- if (!pRtlUniform) - { - win_skip("RtlUniform is not available\n"); - return; - } - /* * According to the documentation RtlUniform is using D.H. Lehmer's 1948 * algorithm. This algorithm is: @@ -429,7 +346,7 @@ static void test_RtlUniform(void) */ seed = 0; expected = 0x7fffffc3; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0)) returns %x, expected %x\n", result, expected); @@ -450,7 +367,7 @@ static void test_RtlUniform(void) */ seed = 1; expected = seed * 0xffffffed + 0x7fffffc3 + 1; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 1)) returns %x, expected %x\n", result, expected); @@ -459,7 +376,7 @@ static void test_RtlUniform(void) */ seed = 2; expected = seed * 0xffffffed + 0x7fffffc3; - result = pRtlUniform(&seed); + result = RtlUniform(&seed);
/* * Windows Vista uses different algorithms, so skip the rest of the tests @@ -480,21 +397,21 @@ static void test_RtlUniform(void) */ seed = 3; expected = seed * 0xffffffed + 0x7fffffc3 + (seed & 1); - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 3)) returns %x, expected %x\n", result, expected);
seed = 0x6bca1aa; expected = seed * 0xffffffed + 0x7fffffc3; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0x6bca1aa)) returns %x, expected %x\n", result, expected);
seed = 0x6bca1ab; expected = seed * 0xffffffed + 0x7fffffc3 + 1; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0x6bca1ab)) returns %x, expected %x\n", result, expected); @@ -503,7 +420,7 @@ static void test_RtlUniform(void) */ seed = 0x6bca1ac; expected = seed * 0xffffffed + 0x7fffffc3 + 2; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0x6bca1ac)) returns %x, expected %x\n", result, expected); @@ -515,14 +432,14 @@ static void test_RtlUniform(void) */ seed = 0x6bca1ad; expected = (seed * 0xffffffed + 0x7fffffc3) & MAXLONG; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0x6bca1ad)) returns %x, expected %x\n", result, expected);
seed = 0x6bca1ae; expected = (seed * 0xffffffed + 0x7fffffc3 + 1) & MAXLONG; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "RtlUniform(&seed (seed == 0x6bca1ae)) returns %x, expected %x\n", result, expected); @@ -630,7 +547,7 @@ static void test_RtlUniform(void) expected = expected + (seed & 1); } /* if */ seed_bak = seed; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "test: 0x%s RtlUniform(&seed (seed == %x)) returns %x, expected %x\n", wine_dbgstr_longlong(num), seed_bak, result, expected); @@ -677,7 +594,7 @@ static void test_RtlUniform(void) for (num = 0; num <= 100000; num++) { expected = (seed * 0x7fffffed + 0x7fffffc3) % 0x7fffffff; seed_bak = seed; - result = pRtlUniform(&seed); + result = RtlUniform(&seed); ok(result == expected, "test: 0x%s RtlUniform(&seed (seed == %x)) returns %x, expected %x\n", wine_dbgstr_longlong(num), seed_bak, result, expected); @@ -699,16 +616,10 @@ static void test_RtlRandom(void) ULONG seed; ULONG res[512];
- if (!pRtlRandom) - { - win_skip("RtlRandom is not available\n"); - return; - } - seed = 0; for (i = 0; i < ARRAY_SIZE(res); i++) { - res[i] = pRtlRandom(&seed); + res[i] = RtlRandom(&seed); ok(seed != res[i], "%i: seed is same as res %x\n", i, seed); for (j = 0; j < i; j++) ok(res[i] != res[j], "res[%i] (%x) is same as res[%i] (%x)\n", j, res[j], i, res[i]); @@ -741,15 +652,9 @@ static void test_RtlAreAllAccessesGranted(void) unsigned int test_num; BOOLEAN result;
- if (!pRtlAreAllAccessesGranted) - { - win_skip("RtlAreAllAccessesGranted is not available\n"); - return; - } - for (test_num = 0; test_num < ARRAY_SIZE(all_accesses); test_num++) { - result = pRtlAreAllAccessesGranted(all_accesses[test_num].GrantedAccess, - all_accesses[test_num].DesiredAccess); + result = RtlAreAllAccessesGranted(all_accesses[test_num].GrantedAccess, + all_accesses[test_num].DesiredAccess); ok(all_accesses[test_num].result == result, "(test %d): RtlAreAllAccessesGranted(%08x, %08x) returns %d, expected %d\n", test_num, all_accesses[test_num].GrantedAccess, @@ -783,15 +688,9 @@ static void test_RtlAreAnyAccessesGranted(void) unsigned int test_num; BOOLEAN result;
- if (!pRtlAreAnyAccessesGranted) - { - win_skip("RtlAreAnyAccessesGranted is not available\n"); - return; - } - for (test_num = 0; test_num < ARRAY_SIZE(any_accesses); test_num++) { - result = pRtlAreAnyAccessesGranted(any_accesses[test_num].GrantedAccess, - any_accesses[test_num].DesiredAccess); + result = RtlAreAnyAccessesGranted(any_accesses[test_num].GrantedAccess, + any_accesses[test_num].DesiredAccess); ok(any_accesses[test_num].result == result, "(test %d): RtlAreAnyAccessesGranted(%08x, %08x) returns %d, expected %d\n", test_num, any_accesses[test_num].GrantedAccess, @@ -804,13 +703,7 @@ static void test_RtlComputeCrc32(void) { DWORD crc = 0;
- if (!pRtlComputeCrc32) - { - win_skip("RtlComputeCrc32 is not available\n"); - return; - } - - crc = pRtlComputeCrc32(crc, (const BYTE *)src, LEN); + crc = RtlComputeCrc32(crc, (const BYTE *)src, LEN); ok(crc == 0x40861dc2,"Expected 0x40861dc2, got %8x\n", crc); }
@@ -835,22 +728,16 @@ static void test_HandleTables(void) MY_HANDLE * MyHandle; RTL_HANDLE_TABLE HandleTable;
- if (!pRtlInitializeHandleTable) - { - win_skip("RtlInitializeHandleTable is not available\n"); - return; - } - - pRtlInitializeHandleTable(0x3FFF, sizeof(MY_HANDLE), &HandleTable); - MyHandle = (MY_HANDLE *)pRtlAllocateHandle(&HandleTable, &Index); + RtlInitializeHandleTable(0x3FFF, sizeof(MY_HANDLE), &HandleTable); + MyHandle = (MY_HANDLE *)RtlAllocateHandle(&HandleTable, &Index); ok(MyHandle != NULL, "RtlAllocateHandle failed\n"); RtlpMakeHandleAllocated(&MyHandle->RtlHandle); MyHandle = NULL; - result = pRtlIsValidIndexHandle(&HandleTable, Index, (RTL_HANDLE **)&MyHandle); + result = RtlIsValidIndexHandle(&HandleTable, Index, (RTL_HANDLE **)&MyHandle); ok(result, "Handle %p wasn't valid\n", MyHandle); - result = pRtlFreeHandle(&HandleTable, &MyHandle->RtlHandle); + result = RtlFreeHandle(&HandleTable, &MyHandle->RtlHandle); ok(result, "Couldn't free handle %p\n", MyHandle); - status = pRtlDestroyHandleTable(&HandleTable); + status = RtlDestroyHandleTable(&HandleTable); ok(status == STATUS_SUCCESS, "RtlDestroyHandleTable failed with error 0x%08x\n", status); }
@@ -860,25 +747,19 @@ static void test_RtlAllocateAndInitializeSid(void) SID_IDENTIFIER_AUTHORITY sia = {{ 1, 2, 3, 4, 5, 6 }}; PSID psid;
- if (!pRtlAllocateAndInitializeSid) - { - win_skip("RtlAllocateAndInitializeSid is not available\n"); - return; - } - - ret = pRtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid); + ret = RtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid); ok(!ret, "RtlAllocateAndInitializeSid error %08x\n", ret); - ret = pRtlFreeSid(psid); + ret = RtlFreeSid(psid); ok(!ret, "RtlFreeSid error %08x\n", ret);
/* these tests crash on XP */ if (0) { - pRtlAllocateAndInitializeSid(NULL, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid); - pRtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, NULL); + RtlAllocateAndInitializeSid(NULL, 0, 1, 2, 3, 4, 5, 6, 7, 8, &psid); + RtlAllocateAndInitializeSid(&sia, 0, 1, 2, 3, 4, 5, 6, 7, 8, NULL); }
- ret = pRtlAllocateAndInitializeSid(&sia, 9, 1, 2, 3, 4, 5, 6, 7, 8, &psid); + ret = RtlAllocateAndInitializeSid(&sia, 9, 1, 2, 3, 4, 5, 6, 7, 8, &psid); ok(ret == STATUS_INVALID_SID, "wrong error %08x\n", ret); }
@@ -886,13 +767,7 @@ static void test_RtlDeleteTimer(void) { NTSTATUS ret;
- if (!pRtlDeleteTimer) - { - win_skip("RtlDeleteTimer is not available\n"); - return; - } - - ret = pRtlDeleteTimer(NULL, NULL, NULL); + ret = RtlDeleteTimer(NULL, NULL, NULL); ok(ret == STATUS_INVALID_PARAMETER_1 || ret == STATUS_INVALID_PARAMETER, /* W2K */ "expected STATUS_INVALID_PARAMETER_1 or STATUS_INVALID_PARAMETER, got %x\n", ret); @@ -973,26 +848,21 @@ static void test_LdrProcessRelocationBlock(void) DWORD addr32; SHORT addr16;
- if(!pLdrProcessRelocationBlock) { - win_skip("LdrProcessRelocationBlock not available\n"); - return; - } - addr32 = 0x50005; reloc = IMAGE_REL_BASED_HIGHLOW<<12; - ret = pLdrProcessRelocationBlock(&addr32, 1, &reloc, 0x500050); + ret = LdrProcessRelocationBlock(&addr32, 1, &reloc, 0x500050); ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1); ok(addr32 == 0x550055, "addr32 = %x, expected 0x550055\n", addr32);
addr16 = 0x505; reloc = IMAGE_REL_BASED_HIGH<<12; - ret = pLdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060); + ret = LdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060); ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1); ok(addr16 == 0x555, "addr16 = %x, expected 0x555\n", addr16);
addr16 = 0x505; reloc = IMAGE_REL_BASED_LOW<<12; - ret = pLdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060); + ret = LdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060); ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1); ok(addr16 == 0x565, "addr16 = %x, expected 0x565\n", addr16); } @@ -1004,12 +874,6 @@ static void test_RtlIpv4AddressToString(void) IN_ADDR ip; DWORD_PTR len;
- if (!pRtlIpv4AddressToStringA) - { - win_skip("RtlIpv4AddressToStringA not available\n"); - return; - } - ip.S_un.S_un_b.s_b1 = 1; ip.S_un.S_un_b.s_b2 = 2; ip.S_un.S_un_b.s_b3 = 3; @@ -1017,11 +881,11 @@ static void test_RtlIpv4AddressToString(void)
memset(buffer, '#', sizeof(buffer) - 1); buffer[sizeof(buffer) -1] = 0; - res = pRtlIpv4AddressToStringA(&ip, buffer); + res = RtlIpv4AddressToStringA(&ip, buffer); len = strlen(buffer); ok(res == (buffer + len), "got %p with '%s' (expected %p)\n", res, buffer, buffer + len);
- res = pRtlIpv4AddressToStringA(&ip, NULL); + res = RtlIpv4AddressToStringA(&ip, NULL); ok( (res == (char *)~0) || broken(res == (char *)len), /* XP and w2003 */ "got %p (expected ~0)\n", res); @@ -1030,13 +894,13 @@ static void test_RtlIpv4AddressToString(void) /* this crashes in windows */ memset(buffer, '#', sizeof(buffer) - 1); buffer[sizeof(buffer) -1] = 0; - res = pRtlIpv4AddressToStringA(NULL, buffer); + res = RtlIpv4AddressToStringA(NULL, buffer); trace("got %p with '%s'\n", res, buffer); }
if (0) { /* this crashes in windows */ - res = pRtlIpv4AddressToStringA(NULL, NULL); + res = RtlIpv4AddressToStringA(NULL, NULL); trace("got %p\n", res); } } @@ -1292,23 +1156,17 @@ static void test_RtlIpv4StringToAddress(void) CHAR dummy; int i;
- if (!pRtlIpv4StringToAddressA) - { - skip("RtlIpv4StringToAddress not available\n"); - return; - } - if (0) { /* leaving either parameter NULL crashes on Windows */ - res = pRtlIpv4StringToAddressA(NULL, FALSE, &terminator, &ip); - res = pRtlIpv4StringToAddressA("1.1.1.1", FALSE, NULL, &ip); - res = pRtlIpv4StringToAddressA("1.1.1.1", FALSE, &terminator, NULL); + res = RtlIpv4StringToAddressA(NULL, FALSE, &terminator, &ip); + res = RtlIpv4StringToAddressA("1.1.1.1", FALSE, NULL, &ip); + res = RtlIpv4StringToAddressA("1.1.1.1", FALSE, &terminator, NULL); /* same for the wide char version */ /* - res = pRtlIpv4StringToAddressW(NULL, FALSE, &terminatorW, &ip); - res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, NULL, &ip); - res = pRtlIpv4StringToAddressW(L"1.1.1.1", FALSE, &terminatorW, NULL); + res = RtlIpv4StringToAddressW(NULL, FALSE, &terminatorW, &ip); + res = RtlIpv4StringToAddressW(L"1.1.1.1", FALSE, NULL, &ip); + res = RtlIpv4StringToAddressW(L"1.1.1.1", FALSE, &terminatorW, NULL); */ }
@@ -1317,7 +1175,7 @@ static void test_RtlIpv4StringToAddress(void) /* non-strict */ terminator = &dummy; ip.S_un.S_addr = 0xabababab; - res = pRtlIpv4StringToAddressA(ipv4_tests[i].address, FALSE, &terminator, &ip); + res = RtlIpv4StringToAddressA(ipv4_tests[i].address, FALSE, &terminator, &ip); ok(res == ipv4_tests[i].res, "[%s] res = 0x%08x, expected 0x%08x\n", ipv4_tests[i].address, res, ipv4_tests[i].res); @@ -1342,7 +1200,7 @@ static void test_RtlIpv4StringToAddress(void) /* strict */ terminator = &dummy; ip.S_un.S_addr = 0xabababab; - res = pRtlIpv4StringToAddressA(ipv4_tests[i].address, TRUE, &terminator, &ip); + res = RtlIpv4StringToAddressA(ipv4_tests[i].address, TRUE, &terminator, &ip); ok(res == ipv4_tests[i].res_strict, "[%s] res = 0x%08x, expected 0x%08x\n", ipv4_tests[i].address, res, ipv4_tests[i].res_strict); @@ -2095,14 +1953,11 @@ static void compare_RtlIpv6StringToAddressW(PCSTR name_a, int terminator_offset_ IN6_ADDR ip; PCWSTR terminator;
- if (!pRtlIpv6StringToAddressW) - return; - - pRtlMultiByteToUnicodeN(name, sizeof(name), NULL, name_a, strlen(name_a) + 1); + RtlMultiByteToUnicodeN(name, sizeof(name), NULL, name_a, strlen(name_a) + 1);
init_ip6(&ip, NULL); terminator = (void *)0xdeadbeef; - res = pRtlIpv6StringToAddressW(name, &terminator, &ip); + res = RtlIpv6StringToAddressW(name, &terminator, &ip); ok(res == res_a, "[W:%s] res = 0x%08x, expected 0x%08x\n", name_a, res, res_a);
if (terminator_offset_a < 0) @@ -2134,28 +1989,16 @@ static void test_RtlIpv6StringToAddress(void) PCSTR terminator; unsigned int i;
- if (!pRtlIpv6StringToAddressW) - { - skip("RtlIpv6StringToAddressW not available\n"); - /* we can continue, just not test W */ - } - - if (!pRtlIpv6StringToAddressA) - { - skip("RtlIpv6StringToAddressA not available\n"); - return; /* all tests are centered around A, we cannot continue */ - } - - res = pRtlIpv6StringToAddressA("::", &terminator, &ip); + res = RtlIpv6StringToAddressA("::", &terminator, &ip); ok(res == STATUS_SUCCESS, "[validate] res = 0x%08x, expected STATUS_SUCCESS\n", res); if (0) { /* any of these crash */ - res = pRtlIpv6StringToAddressA(NULL, &terminator, &ip); + res = RtlIpv6StringToAddressA(NULL, &terminator, &ip); ok(res == STATUS_INVALID_PARAMETER, "[null string] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res); - res = pRtlIpv6StringToAddressA("::", NULL, &ip); + res = RtlIpv6StringToAddressA("::", NULL, &ip); ok(res == STATUS_INVALID_PARAMETER, "[null terminator] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res); - res = pRtlIpv6StringToAddressA("::", &terminator, NULL); + res = RtlIpv6StringToAddressA("::", &terminator, NULL); ok(res == STATUS_INVALID_PARAMETER, "[null result] res = 0x%08x, expected STATUS_INVALID_PARAMETER\n", res); }
@@ -2166,7 +2009,7 @@ static void test_RtlIpv6StringToAddress(void) { init_ip6(&ip, NULL); terminator = (void *)0xdeadbeef; - res = pRtlIpv6StringToAddressA(ipv6_tests[i].address, &terminator, &ip); + res = RtlIpv6StringToAddressA(ipv6_tests[i].address, &terminator, &ip); compare_RtlIpv6StringToAddressW(ipv6_tests[i].address, (terminator != (void *)0xdeadbeef) ? (terminator - ipv6_tests[i].address) : -1, &ip, res);
@@ -2221,7 +2064,7 @@ static void compare_RtlIpv6StringToAddressExW(PCSTR name_a, const struct in6_add if (!pRtlIpv6StringToAddressExW) return;
- pRtlMultiByteToUnicodeN(name, sizeof(name), NULL, name_a, strlen(name_a) + 1); + RtlMultiByteToUnicodeN(name, sizeof(name), NULL, name_a, strlen(name_a) + 1);
init_ip6(&ip, NULL); res = pRtlIpv6StringToAddressExW(name, &ip, &scope, &port); @@ -2478,12 +2321,6 @@ static void test_LdrAddRefDll(void) NTSTATUS status; BOOL ret;
- if (!pLdrAddRefDll) - { - win_skip( "LdrAddRefDll not supported\n" ); - return; - } - mod = LoadLibraryA("comctl32.dll"); ok(mod != NULL, "got %p\n", mod); ret = FreeLibrary(mod); @@ -2495,7 +2332,7 @@ static void test_LdrAddRefDll(void) /* load, addref and release 2 times */ mod = LoadLibraryA("comctl32.dll"); ok(mod != NULL, "got %p\n", mod); - status = pLdrAddRefDll(0, mod); + status = LdrAddRefDll(0, mod); ok(status == STATUS_SUCCESS, "got 0x%08x\n", status); ret = FreeLibrary(mod); ok(ret, "got %d\n", ret); @@ -2511,7 +2348,7 @@ static void test_LdrAddRefDll(void) /* pin refcount */ mod = LoadLibraryA("comctl32.dll"); ok(mod != NULL, "got %p\n", mod); - status = pLdrAddRefDll(LDR_ADDREF_DLL_PIN, mod); + status = LdrAddRefDll(LDR_ADDREF_DLL_PIN, mod); ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
ret = FreeLibrary(mod); @@ -2533,70 +2370,58 @@ static void test_LdrLockLoaderLock(void) ULONG result; NTSTATUS status;
- if (!pLdrLockLoaderLock) - { - win_skip("LdrLockLoaderLock() is not available\n"); - return; - } - /* invalid flags */ result = 10; magic = 0xdeadbeef; - status = pLdrLockLoaderLock(0x10, &result, &magic); + status = LdrLockLoaderLock(0x10, &result, &magic); ok(status == STATUS_INVALID_PARAMETER_1, "got 0x%08x\n", status); ok(result == 0, "got %d\n", result); ok(magic == 0, "got %lx\n", magic);
magic = 0xdeadbeef; - status = pLdrLockLoaderLock(0x10, NULL, &magic); + status = LdrLockLoaderLock(0x10, NULL, &magic); ok(status == STATUS_INVALID_PARAMETER_1, "got 0x%08x\n", status); ok(magic == 0, "got %lx\n", magic);
result = 10; - status = pLdrLockLoaderLock(0x10, &result, NULL); + status = LdrLockLoaderLock(0x10, &result, NULL); ok(status == STATUS_INVALID_PARAMETER_1, "got 0x%08x\n", status); ok(result == 0, "got %d\n", result);
/* non-blocking mode, result is null */ magic = 0xdeadbeef; - status = pLdrLockLoaderLock(0x2, NULL, &magic); + status = LdrLockLoaderLock(0x2, NULL, &magic); ok(status == STATUS_INVALID_PARAMETER_2, "got 0x%08x\n", status); ok(magic == 0, "got %lx\n", magic);
/* magic pointer is null */ result = 10; - status = pLdrLockLoaderLock(0, &result, NULL); + status = LdrLockLoaderLock(0, &result, NULL); ok(status == STATUS_INVALID_PARAMETER_3, "got 0x%08x\n", status); ok(result == 0, "got %d\n", result);
/* lock in non-blocking mode */ result = 0; magic = 0; - status = pLdrLockLoaderLock(0x2, &result, &magic); + status = LdrLockLoaderLock(0x2, &result, &magic); ok(status == STATUS_SUCCESS, "got 0x%08x\n", status); ok(result == 1, "got %d\n", result); ok(magic != 0, "got %lx\n", magic); - pLdrUnlockLoaderLock(0, magic); + LdrUnlockLoaderLock(0, magic); }
static void test_RtlCompressBuffer(void) { ULONG compress_workspace, decompress_workspace; - static const UCHAR test_buffer[] = "WineWineWine"; + static UCHAR test_buffer[] = "WineWineWine"; static UCHAR buf1[0x1000], buf2[0x1000]; ULONG final_size, buf_size; UCHAR *workspace = NULL; NTSTATUS status;
- if (!pRtlCompressBuffer || !pRtlDecompressBuffer || !pRtlGetCompressionWorkSpaceSize) - { - win_skip("skipping RtlCompressBuffer tests, required functions not available\n"); - return; - } - compress_workspace = decompress_workspace = 0xdeadbeef; - status = pRtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1, &compress_workspace, - &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1, &compress_workspace, + &decompress_workspace); ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status); ok(compress_workspace != 0, "got wrong compress_workspace %u\n", compress_workspace); workspace = HeapAlloc(GetProcessHeap(), 0, compress_workspace); @@ -2604,28 +2429,28 @@ static void test_RtlCompressBuffer(void)
/* test compression format / engine */ final_size = 0xdeadbeef; - status = pRtlCompressBuffer(COMPRESSION_FORMAT_NONE, test_buffer, sizeof(test_buffer), - buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); + status = RtlCompressBuffer(COMPRESSION_FORMAT_NONE, test_buffer, sizeof(test_buffer), + buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
final_size = 0xdeadbeef; - status = pRtlCompressBuffer(COMPRESSION_FORMAT_DEFAULT, test_buffer, sizeof(test_buffer), - buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); + status = RtlCompressBuffer(COMPRESSION_FORMAT_DEFAULT, test_buffer, sizeof(test_buffer), + buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
final_size = 0xdeadbeef; - status = pRtlCompressBuffer(0xFF, test_buffer, sizeof(test_buffer), - buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); + status = RtlCompressBuffer(0xFF, test_buffer, sizeof(test_buffer), + buf1, sizeof(buf1) - 1, 4096, &final_size, workspace); ok(status == STATUS_UNSUPPORTED_COMPRESSION, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
/* test compression */ final_size = 0xdeadbeef; memset(buf1, 0x11, sizeof(buf1)); - status = pRtlCompressBuffer(COMPRESSION_FORMAT_LZNT1, test_buffer, sizeof(test_buffer), - buf1, sizeof(buf1), 4096, &final_size, workspace); + status = RtlCompressBuffer(COMPRESSION_FORMAT_LZNT1, test_buffer, sizeof(test_buffer), + buf1, sizeof(buf1), 4096, &final_size, workspace); ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status); ok((*(WORD *)buf1 & 0x7000) == 0x3000, "no chunk signature found %04x\n", *(WORD *)buf1); todo_wine @@ -2635,8 +2460,8 @@ static void test_RtlCompressBuffer(void) buf_size = final_size; final_size = 0xdeadbeef; memset(buf2, 0x11, sizeof(buf2)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf2, sizeof(buf2), - buf1, buf_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf2, sizeof(buf2), + buf1, buf_size, &final_size); ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status); ok(final_size == sizeof(test_buffer), "got wrong final_size %u\n", final_size); ok(!memcmp(buf2, test_buffer, sizeof(test_buffer)), "got wrong decoded data\n"); @@ -2645,8 +2470,8 @@ static void test_RtlCompressBuffer(void) /* buffer too small */ final_size = 0xdeadbeef; memset(buf1, 0x11, sizeof(buf1)); - status = pRtlCompressBuffer(COMPRESSION_FORMAT_LZNT1, test_buffer, sizeof(test_buffer), - buf1, 4, 4096, &final_size, workspace); + status = RtlCompressBuffer(COMPRESSION_FORMAT_LZNT1, test_buffer, sizeof(test_buffer), + buf1, 4, 4096, &final_size, workspace); ok(status == STATUS_BUFFER_TOO_SMALL, "got wrong status 0x%08x\n", status);
HeapFree(GetProcessHeap(), 0, workspace); @@ -2657,35 +2482,29 @@ static void test_RtlGetCompressionWorkSpaceSize(void) ULONG compress_workspace, decompress_workspace; NTSTATUS status;
- if (!pRtlGetCompressionWorkSpaceSize) - { - win_skip("RtlGetCompressionWorkSpaceSize is not available\n"); - return; - } - /* test invalid format / engine */ - status = pRtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_NONE, &compress_workspace, - &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_NONE, &compress_workspace, + &decompress_workspace); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status);
- status = pRtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_DEFAULT, &compress_workspace, - &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_DEFAULT, &compress_workspace, + &decompress_workspace); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status);
- status = pRtlGetCompressionWorkSpaceSize(0xFF, &compress_workspace, &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(0xFF, &compress_workspace, &decompress_workspace); ok(status == STATUS_UNSUPPORTED_COMPRESSION, "got wrong status 0x%08x\n", status);
/* test LZNT1 with normal and maximum compression */ compress_workspace = decompress_workspace = 0xdeadbeef; - status = pRtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1, &compress_workspace, - &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1, &compress_workspace, + &decompress_workspace); ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status); ok(compress_workspace != 0, "got wrong compress_workspace %u\n", compress_workspace); ok(decompress_workspace == 0x1000, "got wrong decompress_workspace %u\n", decompress_workspace);
compress_workspace = decompress_workspace = 0xdeadbeef; - status = pRtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, - &compress_workspace, &decompress_workspace); + status = RtlGetCompressionWorkSpaceSize(COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, + &compress_workspace, &decompress_workspace); ok(status == STATUS_SUCCESS, "got wrong status 0x%08x\n", status); ok(compress_workspace != 0, "got wrong compress_workspace %u\n", compress_workspace); ok(decompress_workspace == 0x1000, "got wrong decompress_workspace %u\n", decompress_workspace); @@ -2718,7 +2537,7 @@ static BOOL is_incomplete_chunk(const UCHAR *compressed, ULONG compressed_size,
static void test_RtlDecompressBuffer(void) { - static const struct + static struct { UCHAR compressed[32]; ULONG compressed_size; @@ -2925,28 +2744,22 @@ static void test_RtlDecompressBuffer(void) ULONG final_size; int i;
- if (!pRtlDecompressBuffer || !pRtlDecompressFragment) - { - win_skip("RtlDecompressBuffer or RtlDecompressFragment is not available\n"); - return; - } - /* test compression format / engine */ final_size = 0xdeadbeef; - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_NONE, buf, sizeof(buf), test_lznt[0].compressed, - test_lznt[0].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_NONE, buf, sizeof(buf), test_lznt[0].compressed, + test_lznt[0].compressed_size, &final_size); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
final_size = 0xdeadbeef; - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_DEFAULT, buf, sizeof(buf), test_lznt[0].compressed, - test_lznt[0].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_DEFAULT, buf, sizeof(buf), test_lznt[0].compressed, + test_lznt[0].compressed_size, &final_size); ok(status == STATUS_INVALID_PARAMETER, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
final_size = 0xdeadbeef; - status = pRtlDecompressBuffer(0xFF, buf, sizeof(buf), test_lznt[0].compressed, - test_lznt[0].compressed_size, &final_size); + status = RtlDecompressBuffer(0xFF, buf, sizeof(buf), test_lznt[0].compressed, + test_lznt[0].compressed_size, &final_size); ok(status == STATUS_UNSUPPORTED_COMPRESSION, "got wrong status 0x%08x\n", status); ok(final_size == 0xdeadbeef, "got wrong final_size %u\n", final_size);
@@ -2959,8 +2772,8 @@ static void test_RtlDecompressBuffer(void) /* test with very big buffer */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, - test_lznt[i].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, + test_lznt[i].compressed_size, &final_size); ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER && (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status); if (!status) @@ -2976,8 +2789,8 @@ static void test_RtlDecompressBuffer(void) /* test that modifier for compression engine is ignored */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, buf, sizeof(buf), - test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1 | COMPRESSION_ENGINE_MAXIMUM, buf, sizeof(buf), + test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); ok(status == test_lznt[i].status || broken(status == STATUS_BAD_COMPRESSION_BUFFER && (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT)), "%d: got wrong status 0x%08x\n", i, status); if (!status) @@ -2995,8 +2808,8 @@ static void test_RtlDecompressBuffer(void) { final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, test_lznt[i].uncompressed_size, - test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, test_lznt[i].uncompressed_size, + test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); ok(status == test_lznt[i].status, "%d: got wrong status 0x%08x\n", i, status); if (!status) { @@ -3014,8 +2827,8 @@ static void test_RtlDecompressBuffer(void) { final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, test_lznt[i].uncompressed_size - 1, - test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, test_lznt[i].uncompressed_size - 1, + test_lznt[i].compressed, test_lznt[i].compressed_size, &final_size); if (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_TRUNCATED) todo_wine ok(status == STATUS_BAD_COMPRESSION_BUFFER, "%d: got wrong status 0x%08x\n", i, status); @@ -3035,8 +2848,8 @@ static void test_RtlDecompressBuffer(void) /* test with zero output size */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, 0, test_lznt[i].compressed, - test_lznt[i].compressed_size, &final_size); + status = RtlDecompressBuffer(COMPRESSION_FORMAT_LZNT1, buf, 0, test_lznt[i].compressed, + test_lznt[i].compressed_size, &final_size); if (is_incomplete_chunk(test_lznt[i].compressed, test_lznt[i].compressed_size, FALSE)) ok(status == STATUS_BAD_COMPRESSION_BUFFER, "%d: got wrong status 0x%08x\n", i, status); else @@ -3049,8 +2862,8 @@ static void test_RtlDecompressBuffer(void) /* test RtlDecompressFragment with offset = 0 */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, - test_lznt[i].compressed_size, 0, &final_size, workspace); + status = RtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, + test_lznt[i].compressed_size, 0, &final_size, workspace); if (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT) todo_wine ok(status == STATUS_BAD_COMPRESSION_BUFFER, "%d: got wrong status 0x%08x\n", i, status); @@ -3069,8 +2882,8 @@ static void test_RtlDecompressBuffer(void) /* test RtlDecompressFragment with offset = 1 */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, - test_lznt[i].compressed_size, 1, &final_size, workspace); + status = RtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, + test_lznt[i].compressed_size, 1, &final_size, workspace); if (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT) todo_wine ok(status == STATUS_BAD_COMPRESSION_BUFFER, "%d: got wrong status 0x%08x\n", i, status); @@ -3099,8 +2912,8 @@ static void test_RtlDecompressBuffer(void) /* test RtlDecompressFragment with offset = 4095 */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, - test_lznt[i].compressed_size, 4095, &final_size, workspace); + status = RtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, + test_lznt[i].compressed_size, 4095, &final_size, workspace); if (test_lznt[i].broken_flags & DECOMPRESS_BROKEN_FRAGMENT) todo_wine ok(status == STATUS_BAD_COMPRESSION_BUFFER, "%d: got wrong status 0x%08x\n", i, status); @@ -3118,8 +2931,8 @@ static void test_RtlDecompressBuffer(void) /* test RtlDecompressFragment with offset = 4096 */ final_size = 0xdeadbeef; memset(buf, 0x11, sizeof(buf)); - status = pRtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, - test_lznt[i].compressed_size, 4096, &final_size, workspace); + status = RtlDecompressFragment(COMPRESSION_FORMAT_LZNT1, buf, sizeof(buf), test_lznt[i].compressed, + test_lznt[i].compressed_size, 4096, &final_size, workspace); expected_status = is_incomplete_chunk(test_lznt[i].compressed, test_lznt[i].compressed_size, TRUE) ? test_lznt[i].status : STATUS_SUCCESS; ok(status == expected_status, "%d: got wrong status 0x%08x, expected 0x%08x\n", i, status, expected_status); @@ -3384,41 +3197,35 @@ static void test_RtlMakeSelfRelativeSD(void) NTSTATUS status; DWORD len;
- if (!pRtlMakeSelfRelativeSD || !pRtlAbsoluteToSelfRelativeSD) - { - win_skip( "RtlMakeSelfRelativeSD/RtlAbsoluteToSelfRelativeSD not available\n" ); - return; - } - memset( &sd, 0, sizeof(sd) ); sd.Revision = SECURITY_DESCRIPTOR_REVISION;
len = 0; - status = pRtlMakeSelfRelativeSD( &sd, NULL, &len ); + status = RtlMakeSelfRelativeSD( &sd, NULL, &len ); ok( status == STATUS_BUFFER_TOO_SMALL, "got %08x\n", status ); ok( len == sizeof(*sd_rel), "got %u\n", len );
len += 4; - status = pRtlMakeSelfRelativeSD( &sd, sd_rel, &len ); + status = RtlMakeSelfRelativeSD( &sd, sd_rel, &len ); ok( status == STATUS_SUCCESS, "got %08x\n", status ); ok( len == sizeof(*sd_rel) + 4, "got %u\n", len );
len = 0; - status = pRtlAbsoluteToSelfRelativeSD( &sd, NULL, &len ); + status = RtlAbsoluteToSelfRelativeSD( &sd, NULL, &len ); ok( status == STATUS_BUFFER_TOO_SMALL, "got %08x\n", status ); ok( len == sizeof(*sd_rel), "got %u\n", len );
len += 4; - status = pRtlAbsoluteToSelfRelativeSD( &sd, sd_rel, &len ); + status = RtlAbsoluteToSelfRelativeSD( &sd, sd_rel, &len ); ok( status == STATUS_SUCCESS, "got %08x\n", status ); ok( len == sizeof(*sd_rel) + 4, "got %u\n", len );
sd.Control = SE_SELF_RELATIVE; - status = pRtlMakeSelfRelativeSD( &sd, sd_rel, &len ); + status = RtlMakeSelfRelativeSD( &sd, sd_rel, &len ); ok( status == STATUS_SUCCESS, "got %08x\n", status ); ok( len == sizeof(*sd_rel) + 4, "got %u\n", len );
- status = pRtlAbsoluteToSelfRelativeSD( &sd, sd_rel, &len ); + status = RtlAbsoluteToSelfRelativeSD( &sd, sd_rel, &len ); ok( status == STATUS_BAD_DESCRIPTOR_FORMAT, "got %08x\n", status ); }
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- I needed a little more information about when the last 32 bits are represented in dot-decimal notation. --- dlls/ntdll/tests/rtl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index 0cbf0b33ff..f83031b490 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -1721,28 +1721,40 @@ static void test_RtlIpv6AddressToString(void) { /* ipv4 addresses & ISATAP addresses */ { "::13.1.68.3", { 0, 0, 0, 0, 0, 0, 0x10d, 0x344 } }, + { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } }, + { "::ffff", { 0, 0, 0, 0, 0, 0, 0, 0xffff } }, + { "::0.1.0.0", { 0, 0, 0, 0, 0, 0, 0x100, 0 } }, { "::ffff:13.1.68.3", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0x344 } }, { "::feff:d01:4403", { 0, 0, 0, 0, 0, 0xfffe, 0x10d, 0x344 } }, { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 } }, { "::100:d01:4403", { 0, 0, 0, 0, 0, 1, 0x10d, 0x344 } }, { "::1:d01:4403", { 0, 0, 0, 0, 0, 0x100, 0x10d, 0x344 } }, + { "::1:0:d01:4403", { 0, 0, 0, 0, 0x100, 0, 0x10d, 0x344 } }, + { "::fffe:d01:4403", { 0, 0, 0, 0, 0, 0xfeff, 0x10d, 0x344 } }, + { "::fffe:0:d01:4403", { 0, 0, 0, 0, 0xfeff, 0, 0x10d, 0x344 } }, { "::ffff:0:4403", { 0, 0, 0, 0, 0, 0xffff, 0, 0x344 } }, + { "::ffff:0.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x100, 0 } }, { "::ffff:13.1.0.0", { 0, 0, 0, 0, 0, 0xffff, 0x10d, 0 } }, { "::ffff:0:0", { 0, 0, 0, 0, 0, 0xffff, 0, 0 } }, + { "::ffff:0:ffff", { 0, 0, 0, 0, 0, 0xffff, 0, 0xffff } }, + { "::ffff:0:0.1.0.0", { 0, 0, 0, 0, 0xffff, 0, 0x100, 0 } }, { "::ffff:0:13.1.68.3", { 0, 0, 0, 0, 0xffff, 0, 0x10d, 0x344 } }, { "::ffff:ffff:d01:4403", { 0, 0, 0, 0, 0xffff, 0xffff, 0x10d, 0x344 } }, { "::ffff:0:0:d01:4403", { 0, 0, 0, 0xffff, 0, 0, 0x10d, 0x344 } }, { "::ffff:255.255.255.255", { 0, 0, 0, 0, 0, 0xffff, 0xffff, 0xffff } }, { "::ffff:129.144.52.38", { 0, 0, 0, 0, 0, 0xffff, 0x9081, 0x2634 } }, + { "::5efe:0.0.0.0", { 0, 0, 0, 0, 0, 0xfe5e, 0, 0 } }, { "::5efe:129.144.52.38", { 0, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } }, { "1111:2222:3333:4444:0:5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0xfe5e, 0x9081, 0x2634 } }, { "1111:2222:3333::5efe:129.144.52.38", { 0x1111, 0x2222, 0x3333, 0, 0, 0xfe5e, 0x9081, 0x2634 } }, { "1111:2222::5efe:129.144.52.38", { 0x1111, 0x2222, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } }, { "1111::5efe:129.144.52.38", { 0x1111, 0, 0, 0, 0, 0xfe5e, 0x9081, 0x2634 } }, + { "::300:5efe:8190:3426", { 0, 0, 0, 0, 3, 0xfe5e, 0x9081, 0x2634 } }, { "::200:5efe:129.144.52.38", { 0, 0, 0, 0, 2, 0xfe5e, 0x9081, 0x2634 } }, { "::100:5efe:8190:3426", { 0, 0, 0, 0, 1, 0xfe5e, 0x9081, 0x2634 } }, /* 'normal' addresses */ { "::1", { 0, 0, 0, 0, 0, 0, 0, 0x100 } }, + { "::2", { 0, 0, 0, 0, 0, 0, 0, 0x200 } }, { "0:1:2:3:4:5:6:7", { 0, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700 } }, { "1080::8:800:200c:417a", { 0x8010, 0, 0, 0, 0x800, 0x8, 0x0c20, 0x7a41 } }, { "1111:2222:3333:4444:5555:6666:7b7b:7b7b", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7b7b, 0x7b7b } }, @@ -1777,7 +1789,6 @@ static void test_RtlIpv6AddressToString(void) { "2001:db8:85a3::8a2e:370:7334", { 0x120, 0xb80d, 0xa385, 0, 0, 0x2e8a, 0x7003, 0x3473 } }, { "3ffe:b00::1:0:0:a", { 0xfe3f, 0xb, 0, 0, 0x100, 0, 0, 0xa00 } }, { "::a:b:c:d:e", { 0, 0, 0, 0xa00, 0xb00, 0xc00, 0xd00, 0xe00 } }, - { "::123.123.123.123", { 0, 0, 0, 0, 0, 0, 0x7b7b, 0x7b7b } }, { "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff } }, { "1111:2222:3333:4444:5555:6666:7777:1", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x100 } }, { "1111:2222:3333:4444:5555:6666:7777:8888", { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888 } },
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46788 Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/ntdll/ntdll.spec | 8 +-- dlls/ntdll/rtl.c | 129 +++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/tests/rtl.c | 14 +---- include/ip2string.h | 7 +++ 4 files changed, 143 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 7ae8a6071d..6bd0a599a9 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -784,10 +784,10 @@ @ stdcall RtlIpv4StringToAddressExA(str long ptr ptr) @ stdcall RtlIpv4StringToAddressExW(wstr long ptr ptr) @ stdcall RtlIpv4StringToAddressW(wstr long ptr ptr) -# @ stub RtlIpv6AddressToStringA -# @ stub RtlIpv6AddressToStringExA -# @ stub RtlIpv6AddressToStringExW -# @ stub RtlIpv6AddressToStringW +@ stdcall RtlIpv6AddressToStringA(ptr ptr) +@ stdcall RtlIpv6AddressToStringExA(ptr long long ptr ptr) +@ stdcall RtlIpv6AddressToStringExW(ptr long long ptr ptr) +@ stdcall RtlIpv6AddressToStringW(ptr ptr) @ stdcall RtlIpv6StringToAddressA(str ptr ptr) @ stdcall RtlIpv6StringToAddressExA(str ptr ptr ptr) @ stdcall RtlIpv6StringToAddressExW(wstr ptr ptr ptr) diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 003e4a1b3b..bf91423eba 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -1412,6 +1412,135 @@ CHAR * WINAPI RtlIpv4AddressToStringA(const IN_ADDR *pin, LPSTR buffer) return buffer + size - 1; }
+static BOOL is_ipv4_in_ipv6(const IN6_ADDR *address) +{ + if (address->s6_words[5] == htons(0x5efe) && (address->s6_words[4] & ~htons(0x200)) == 0) + return TRUE; + if (*(UINT64 *)address != 0) + return FALSE; + if (address->s6_words[4] != 0 && address->s6_words[4] != 0xffff) + return FALSE; + if (address->s6_words[4] == 0 && address->s6_words[5] != 0 && address->s6_words[5] != 0xffff) + return FALSE; + if (address->s6_words[4] == 0xffff && address->s6_words[5] != 0) + return FALSE; + if (address->s6_words[6] == 0) + return FALSE; + return TRUE; +} + +/*********************************************************************** + * RtlIpv6AddressToStringExA [NTDLL.@] + */ +NTSTATUS WINAPI RtlIpv6AddressToStringExA(const IN6_ADDR *address, ULONG scope, USHORT port, char *str, ULONG *size) +{ + char buffer[64], *p = buffer; + int i, len, gap = -1, gap_len = 1, ipv6_end = 8; + ULONG needed; + NTSTATUS ret; + + TRACE("(%p %u %u %p %p)\n", address, scope, port, str, size); + + if (!address || !str || !size) + return STATUS_INVALID_PARAMETER; + + if (is_ipv4_in_ipv6(address)) + ipv6_end = 6; + + for (i = 0; i < ipv6_end; i++) + { + len = 0; + while (!address->s6_words[i] && i < ipv6_end) + { + i++; + len++; + } + if (len > gap_len) + { + gap = i - len; + gap_len = len; + } + } + + if (port) p += sprintf(p, "["); + + i = 0; + while (i < ipv6_end) + { + if (i == gap) + { + p += sprintf(p, ":"); + i += gap_len; + if (i == ipv6_end) p += sprintf(p, ":"); + continue; + } + if (i > 0) p += sprintf(p, ":"); + p += sprintf(p, "%x", ntohs(address->s6_words[i])); + i++; + } + + if (ipv6_end == 6) + { + if (p[-1] != ':') p += sprintf(p, ":"); + p = RtlIpv4AddressToStringA((IN_ADDR *)(address->s6_words + 6), p); + } + + if (scope) p += sprintf(p, "%%%u", scope); + + if (port) p += sprintf(p, "]:%u", ntohs(port)); + + needed = p - buffer + 1; + + if (*size >= needed) + { + strcpy(str, buffer); + ret = STATUS_SUCCESS; + } + else + { + ret = STATUS_INVALID_PARAMETER; + } + + *size = needed; + return ret; +} + +/*********************************************************************** + * RtlIpv6AddressToStringA [NTDLL.@] + */ +char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str) +{ + ULONG size = 46; + if (!address || !str) return str - 1; + str[45] = 0; /* this byte is set even though the string is always shorter */ + RtlIpv6AddressToStringExA(address, 0, 0, str, &size); + return str + size - 1; +} + +/*********************************************************************** + * RtlIpv6AddressToStringExW [NTDLL.@] + */ +NTSTATUS WINAPI RtlIpv6AddressToStringExW(const IN6_ADDR *address, ULONG scope, USHORT port, WCHAR *str, ULONG *size) +{ + char cstr[64]; + NTSTATUS ret = RtlIpv6AddressToStringExA(address, scope, port, cstr, size); + if (ret == STATUS_SUCCESS) RtlMultiByteToUnicodeN(str, *size * sizeof(WCHAR), NULL, cstr, *size); + return ret; +} + +/*********************************************************************** + * RtlIpv6AddressToStringW [NTDLL.@] + */ +WCHAR * WINAPI RtlIpv6AddressToStringW(const IN6_ADDR *address, WCHAR *str) +{ + ULONG size = 46; + if (!address || !str) return str; + str[45] = 0; /* this word is set even though the string is always shorter */ + if (RtlIpv6AddressToStringExW(address, 0, 0, str, &size) != STATUS_SUCCESS) + return str; + return str + size - 1; +} + /*********************************************************************** * get_pointer_obfuscator (internal) */ diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c index f83031b490..94c6b582f3 100644 --- a/dlls/ntdll/tests/rtl.c +++ b/dlls/ntdll/tests/rtl.c @@ -73,7 +73,6 @@ static DWORD (WINAPI *pRtlGetThreadErrorMode)(void); static NTSTATUS (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD); static NTSTATUS (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG); static NTSTATUS (WINAPI *pRtlIpv4StringToAddressExA)(PCSTR, BOOLEAN, IN_ADDR *, PUSHORT); -static CHAR * (WINAPI *pRtlIpv6AddressToStringA)(struct in6_addr *, PSTR); static NTSTATUS (WINAPI *pRtlIpv6AddressToStringExA)(struct in6_addr *, ULONG, USHORT, PCHAR, PULONG); static NTSTATUS (WINAPI *pRtlIpv6StringToAddressExA)(PCSTR, struct in6_addr *, PULONG, PUSHORT); static NTSTATUS (WINAPI *pRtlIpv6StringToAddressExW)(PCWSTR, struct in6_addr *, PULONG, PUSHORT); @@ -114,7 +113,6 @@ static void InitFunctionPtrs(void) pRtlSetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlSetThreadErrorMode"); pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA"); pRtlIpv4StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressExA"); - pRtlIpv6AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringA"); pRtlIpv6AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv6AddressToStringExA"); pRtlIpv6StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressExA"); pRtlIpv6StringToAddressExW = (void *)GetProcAddress(hntdll, "RtlIpv6StringToAddressExW"); @@ -1801,22 +1799,16 @@ static void test_RtlIpv6AddressToString(void) }; unsigned int i;
- if (!pRtlIpv6AddressToStringA) - { - skip("RtlIpv6AddressToStringA not available\n"); - return; - } - memset(buffer, '#', sizeof(buffer)); buffer[sizeof(buffer)-1] = 0; memset(&ip, 0, sizeof(ip)); - result = pRtlIpv6AddressToStringA(&ip, buffer); + result = RtlIpv6AddressToStringA(&ip, buffer);
len = strlen(buffer); ok(result == (buffer + len) && !strcmp(buffer, "::"), "got %p with '%s' (expected %p with '::')\n", result, buffer, buffer + len);
- result = pRtlIpv6AddressToStringA(&ip, NULL); + result = RtlIpv6AddressToStringA(&ip, NULL); ok(result == (LPCSTR)~0 || broken(result == (LPCSTR)len) /* WinXP / Win2k3 */, "got %p, expected %p\n", result, (LPCSTR)~0);
@@ -1826,7 +1818,7 @@ static void test_RtlIpv6AddressToString(void) memset(buffer, '#', sizeof(buffer)); buffer[sizeof(buffer)-1] = 0;
- result = pRtlIpv6AddressToStringA(&ip, buffer); + result = RtlIpv6AddressToStringA(&ip, buffer); len = strlen(buffer); ok(result == (buffer + len) && !strcmp(buffer, tests[i].address), "got %p with '%s' (expected %p with '%s')\n", result, buffer, buffer + len, tests[i].address); diff --git a/include/ip2string.h b/include/ip2string.h index 4c5f36c15f..84835d4593 100644 --- a/include/ip2string.h +++ b/include/ip2string.h @@ -30,6 +30,13 @@ NTSTATUS WINAPI RtlIpv4AddressToStringExA(const IN_ADDR *address, USHORT port, c NTSTATUS WINAPI RtlIpv4AddressToStringExW(const IN_ADDR *address, USHORT port, WCHAR *str, ULONG *size); #define RtlIpv4AddressToStringEx WINELIB_NAME_AW(RtlIpv4AddressToStringEx)
+char * WINAPI RtlIpv6AddressToStringA(const IN6_ADDR *address, char *str); +WCHAR * WINAPI RtlIpv6AddressToStringW(const IN6_ADDR *address, WCHAR *str); +#define RtlIpv6AddressToString WINELIB_NAME_AW(RtlIpv6AddressToString) +NTSTATUS WINAPI RtlIpv6AddressToStringExA(const IN6_ADDR *address, LONG scope, USHORT port, char *str, ULONG *size); +NTSTATUS WINAPI RtlIpv6AddressToStringExW(const IN6_ADDR *address, LONG scope, USHORT port, WCHAR *str, ULONG *size); +#define RtlIpv6AddressToStringEx WINELIB_NAME_AW(RtlIpv6AddressToStringEx) + NTSTATUS WINAPI RtlIpv4StringToAddressA(const char *str, BOOLEAN strict, const char **terminator, IN_ADDR *address); NTSTATUS WINAPI RtlIpv4StringToAddressW(const WCHAR *str, BOOLEAN strict, const WCHAR **terminator, IN_ADDR *address); #define RtlIpv4StringToAddress WINELIB_NAME_AW(RtlIpv4StringToAddress)
And add a couple of tests for IPv6 addresses that Windows represents using dot-decimal notation for the last 32 bits but GNU/Linux does not.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- configure.ac | 1 - dlls/ws2_32/socket.c | 20 ++++++-------------- dlls/ws2_32/tests/sock.c | 6 ++++++ 3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/configure.ac b/configure.ac index d81f5cc88c..7ebe73ff35 100644 --- a/configure.ac +++ b/configure.ac @@ -2251,7 +2251,6 @@ AC_CHECK_FUNCS(\ getservbyport \ inet_addr \ inet_network \ - inet_ntop \ )
dnl Check for clock_gettime which may be in -lrt diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index bdfe63ee19..199b7187a8 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -8351,10 +8351,8 @@ int WINAPI WSARemoveServiceClass(LPGUID info) */ PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len ) { -#ifdef HAVE_INET_NTOP - struct WS_in6_addr *in6; - struct WS_in_addr *in; - PCSTR pdst; + NTSTATUS status; + ULONG size = min( len, (ULONG)-1 );
TRACE("family %d, addr (%p), buffer (%p), len %ld\n", family, addr, buffer, len); if (!buffer) @@ -8367,14 +8365,12 @@ PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len ) { case WS_AF_INET: { - in = addr; - pdst = inet_ntop( AF_INET, &in->WS_s_addr, buffer, len ); + status = RtlIpv4AddressToStringExA( (IN_ADDR *)addr, 0, buffer, &size ); break; } case WS_AF_INET6: { - in6 = addr; - pdst = inet_ntop( AF_INET6, in6->WS_s6_addr, buffer, len ); + status = RtlIpv6AddressToStringExA( (IN6_ADDR *)addr, 0, 0, buffer, &size ); break; } default: @@ -8382,13 +8378,9 @@ PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len ) return NULL; }
- if (!pdst) SetLastError( STATUS_INVALID_PARAMETER ); - return pdst; -#else - FIXME( "not supported on this platform\n" ); - SetLastError( WSAEAFNOSUPPORT ); + if (status == STATUS_SUCCESS) return buffer; + SetLastError( STATUS_INVALID_PARAMETER ); return NULL; -#endif }
/*********************************************************************** diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index c72dc7a77a..cd9a13937c 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5008,6 +5008,12 @@ static void test_inet_pton(void) "0x12345678", NULL, NULL}, {AF_INET6, 0, 0, /* windows bug */ "::1:2:3:4:5:6:7", NULL, NULL}, + {AF_INET6, 1, 0, /* Test 30 */ + "::5efe:1.2.3.4", "::5efe:1.2.3.4", + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x5e\xfe\x01\x02\x03\x04"}, + {AF_INET6, 1, 0, + "::ffff:0:1.2.3.4", "::ffff:0:1.2.3.4", + "\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x01\x02\x03\x04"}, }; int i, ret; DWORD err;