ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
April 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
11 participants
156 discussions
Start a n
N
ew thread
[tfaber] 56414: [KERNEL32] - Do not use Zw functions from user mode
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 25 10:17:29 2012 New Revision: 56414 URL:
http://svn.reactos.org/svn/reactos?rev=56414&view=rev
Log: [KERNEL32] - Do not use Zw functions from user mode Modified: trunk/reactos/dll/win32/kernel32/client/compname.c trunk/reactos/dll/win32/kernel32/client/dllmain.c trunk/reactos/dll/win32/kernel32/client/file/filemap.c trunk/reactos/dll/win32/kernel32/client/proc.c trunk/reactos/dll/win32/kernel32/client/time.c trunk/reactos/dll/win32/kernel32/client/utils.c Modified: trunk/reactos/dll/win32/kernel32/client/compname.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/compname.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/compname.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -57,7 +57,7 @@ NULL, NULL); - Status = ZwOpenKey(&KeyHandle, + Status = NtOpenKey(&KeyHandle, KEY_READ, &ObjectAttributes); if (!NT_SUCCESS(Status)) @@ -70,21 +70,21 @@ KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, KeyInfoSize); if (KeyInfo == NULL) { - ZwClose(KeyHandle); + NtClose(KeyHandle); SetLastError(ERROR_OUTOFMEMORY); return FALSE; } RtlInitUnicodeString(&ValueName, ValueNameStr); - Status = ZwQueryValueKey(KeyHandle, + Status = NtQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, KeyInfo, KeyInfoSize, &ReturnSize); - ZwClose(KeyHandle); + NtClose(KeyHandle); if (!NT_SUCCESS(Status)) { @@ -396,13 +396,13 @@ (wcslen (lpBuffer) + 1) * sizeof(WCHAR)); if (!NT_SUCCESS(Status)) { - ZwClose(KeyHandle); + NtClose(KeyHandle); BaseSetLastNTError(Status); return FALSE; } NtFlushKey(KeyHandle); - ZwClose(KeyHandle); + NtClose(KeyHandle); return TRUE; } Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -322,7 +322,7 @@ if (!NT_SUCCESS(Status)) { DPRINT1("Failed to connect to CSR (Status %lx)\n", Status); - ZwTerminateProcess(NtCurrentProcess(), Status); + NtTerminateProcess(NtCurrentProcess(), Status); return FALSE; } Modified: trunk/reactos/dll/win32/kernel32/client/file/filemap.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/file/filemap.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -195,7 +195,7 @@ } /* Map the section */ - Status = ZwMapViewOfSection(hFileMappingObject, + Status = NtMapViewOfSection(hFileMappingObject, NtCurrentProcess(), &ViewBase, 0, @@ -326,7 +326,7 @@ } /* Open the section */ - Status = ZwOpenSection(&SectionHandle, dwDesiredAccess, &ObjectAttributes); + Status = NtOpenSection(&SectionHandle, dwDesiredAccess, &ObjectAttributes); if (!NT_SUCCESS(Status)) { /* We failed */ Modified: trunk/reactos/dll/win32/kernel32/client/proc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/proc.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -889,7 +889,7 @@ /* Allocate and Initialize new Environment Block */ Size = EnviroSize; ProcessParameters->Environment = NULL; - Status = ZwAllocateVirtualMemory(ProcessHandle, + Status = NtAllocateVirtualMemory(ProcessHandle, (PVOID*)&ProcessParameters->Environment, 0, &Size, @@ -898,7 +898,7 @@ if (!NT_SUCCESS(Status)) goto FailPath; /* Write the Environment Block */ - Status = ZwWriteVirtualMemory(ProcessHandle, + Status = NtWriteVirtualMemory(ProcessHandle, ProcessParameters->Environment, lpEnvironment, EnviroSize, @@ -2947,7 +2947,7 @@ /* FIXME: Allow CREATE_SEPARATE only for WOW Apps, once we have that. */ /* Get some information about the executable */ - Status = ZwQuerySection(hSection, + Status = NtQuerySection(hSection, SectionImageInformation, &SectionImageInfo, sizeof(SectionImageInfo), Modified: trunk/reactos/dll/win32/kernel32/client/time.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/time.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/time.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -549,7 +549,7 @@ return FALSE; } - Status = ZwQuerySystemInformation(SystemProcessorPerformanceInformation, + Status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, ProcPerfInfo, BufferSize, &ReturnLength); Modified: trunk/reactos/dll/win32/kernel32/client/utils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/utils.c [iso-8859-1] Wed Apr 25 10:17:29 2012 @@ -408,7 +408,7 @@ /* Reserve memory for the stack */ Stack = 0; - Status = ZwAllocateVirtualMemory(hProcess, + Status = NtAllocateVirtualMemory(hProcess, (PVOID*)&Stack, 0, &StackReserve, @@ -442,7 +442,7 @@ } /* Allocate memory for the stack */ - Status = ZwAllocateVirtualMemory(hProcess, + Status = NtAllocateVirtualMemory(hProcess, (PVOID*)&Stack, 0, &StackCommit, @@ -452,7 +452,7 @@ { DPRINT1("Failure to allocate stack\n"); GuardPageSize = 0; - ZwFreeVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, MEM_RELEASE); + NtFreeVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, MEM_RELEASE); return Status; } @@ -464,7 +464,7 @@ { /* Set the guard page */ GuardPageSize = PAGE_SIZE; - Status = ZwProtectVirtualMemory(hProcess, + Status = NtProtectVirtualMemory(hProcess, (PVOID*)&Stack, &GuardPageSize, PAGE_GUARD | PAGE_READWRITE,
12 years, 8 months
1
0
0
0
[tfaber] 56413: [NTDLL_APITEST] - Add a test for RtlGetFullPathName_Ustr (requires the function address to be known) - Various improvements to the other path tests
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 25 09:52:38 2012 New Revision: 56413 URL:
http://svn.reactos.org/svn/reactos?rev=56413&view=rev
Log: [NTDLL_APITEST] - Add a test for RtlGetFullPathName_Ustr (requires the function address to be known) - Various improvements to the other path tests Added: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c (with props) Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c trunk/rostests/apitests/ntdll/testlist.c Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -4,6 +4,7 @@ NtFreeVirtualMemory.c RtlDetermineDosPathNameType.c RtlGetFullPathName_U.c + RtlGetFullPathName_Ustr.c RtlGetFullPathName_UstrEx.c RtlGetLongestNtPathLength.c RtlInitializeBitMap.c Modified: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlDetermi…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -66,6 +66,28 @@ StartOfBuffer += Size - SizeRequested; return StartOfBuffer; +} + +static +VOID +MakeReadOnly( + PVOID Pointer, + SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested); + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + + if (Size) + { + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + Size = 0; + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + } + } } static @@ -159,7 +181,7 @@ USHORT Length; if (!RtlDetermineDosPathNameType_Ustr) - skip(0, "RtlDetermineDosPathNameType_Ustr unavailable\n"); + skip("RtlDetermineDosPathNameType_Ustr unavailable\n"); StartSeh() RtlDetermineDosPathNameType_U(NULL); EndSeh(STATUS_ACCESS_VIOLATION); @@ -178,6 +200,7 @@ Length = (USHORT)wcslen(Tests[i].FileName) * sizeof(WCHAR); FileName = AllocateGuarded(Length + sizeof(UNICODE_NULL)); RtlCopyMemory(FileName, Tests[i].FileName, Length + sizeof(UNICODE_NULL)); + MakeReadOnly(FileName, Length + sizeof(UNICODE_NULL)); StartSeh() PathType = RtlDetermineDosPathNameType_U(FileName); ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); @@ -190,6 +213,7 @@ FileName = AllocateGuarded(Length); RtlCopyMemory(FileName, Tests[i].FileName, Length); + MakeReadOnly(FileName, Length); PathString.Buffer = FileName; PathString.Length = Length; PathString.MaximumLength = MAXUSHORT; Modified: trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFull…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_U.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -56,16 +56,16 @@ Result = FALSE; } - /* the function nulls the rest of the buffer! */ + /* The function nulls the rest of the buffer! */ for (i = Length + sizeof(UNICODE_NULL); i < MaximumLength; i++) { UCHAR Char = ((PUCHAR)Buffer)[i]; if (Char != 0) { ok(0, "Found 0x%x at offset %lu, expected 0x%x\n", Char, (ULONG)i, 0); - /* don't count this as a failure unless the string was actually wrong */ + /* Don't count this as a failure unless the string was actually wrong */ //Result = FALSE; - /* don't flood the log */ + /* Don't flood the log */ break; } } @@ -73,7 +73,7 @@ return Result; } -#define InvalidPointer ((PVOID)0x1234) +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL) /* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ #undef broken @@ -172,11 +172,8 @@ &ShortName); EndSeh(STATUS_SUCCESS); - /* TODO: remove SEH here */ - StartSeh() - ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), - "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName); - EndSeh(STATUS_SUCCESS); + ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), + "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName); if (!ShortName) FilePartSize = 0; @@ -278,6 +275,6 @@ ok(ShortName == InvalidPointer || broken(ShortName == NULL) /* Win7 */, "ShortName = %p\n", ShortName); - /* check the actual functionality with different paths */ + /* Check the actual functionality with different paths */ RunTestCases(); } Added: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFull…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c (added) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -1,0 +1,392 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for RtlGetFullPathName_Ustr + * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> + */ + +#define WIN32_NO_STATUS +#include <wine/test.h> +#include <pseh/pseh2.h> +#include <ndk/rtlfuncs.h> + +/* +ULONG +NTAPI +RtlGetFullPathName_Ustr( + IN PCUNICODE_STRING FileName, + IN ULONG Size, + IN PWSTR Buffer, + OUT PCWSTR *ShortName, + OUT PBOOLEAN InvalidName, + OUT RTL_PATH_TYPE* PathType +); +*/ + +/* This seems to be a struct of some kind in Windows 7... returns 0 or 32 in the second member */ +typedef struct _PATH_TYPE_AND_UNKNOWN +{ + RTL_PATH_TYPE Type; + ULONG Unknown; +} PATH_TYPE_AND_UNKNOWN; + +static +ULONG +(NTAPI +*RtlGetFullPathName_Ustr)( + IN PCUNICODE_STRING FileName, + IN ULONG Size, + IN PWSTR Buffer, + OUT PCWSTR *ShortName, + OUT PBOOLEAN InvalidName, + OUT PATH_TYPE_AND_UNKNOWN* PathType +) +//= (PVOID)0x7c83086c // 2003 sp1 x86 +//= (PVOID)0x7769a3dd // win7 sp1 wow64 +; + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +#define ok_eq_ustr(str1, str2) do { \ + ok((str1)->Buffer == (str2)->Buffer, "Buffer modified\n"); \ + ok((str1)->Length == (str2)->Length, "Length modified\n"); \ + ok((str1)->MaximumLength == (str2)->MaximumLength, "MaximumLength modified\n"); \ + } while (0) + +static +BOOLEAN +CheckStringBuffer( + PCWSTR Buffer, + ULONG Length, + SIZE_T MaximumLength, + PCWSTR Expected) +{ + USHORT ExpectedLength = wcslen(Expected) * sizeof(WCHAR); + SIZE_T EqualLength; + BOOLEAN Result = TRUE; + SIZE_T i; + + if (Length != ExpectedLength) + { + ok(0, "String length is %u, expected %u\n", Length, ExpectedLength); + Result = FALSE; + } + + EqualLength = RtlCompareMemory(Buffer, Expected, Length); + if (EqualLength != Length) + { + ok(0, "String is '%S', expected '%S'\n", Buffer, Expected); + Result = FALSE; + } + + if (Buffer[Length / sizeof(WCHAR)] != UNICODE_NULL) + { + ok(0, "Not null terminated\n"); + Result = FALSE; + } + + /* The function nulls the rest of the buffer! */ + for (i = Length + sizeof(UNICODE_NULL); i < MaximumLength; i++) + { + UCHAR Char = ((PUCHAR)Buffer)[i]; + if (Char != 0) + { + ok(0, "Found 0x%x at offset %lu, expected 0x%x\n", Char, (ULONG)i, 0); + /* Don't count this as a failure unless the string was actually wrong */ + //Result = FALSE; + /* Don't flood the log */ + break; + } + } + + return Result; +} + +#define RtlPathTypeNotSet 123 +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL) + +/* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ +#undef broken +#define broken(x) 0 + +typedef enum +{ + PrefixNone, + PrefixCurrentDrive, + PrefixCurrentPath, + PrefixCurrentPathWithoutLastPart +} PREFIX_TYPE; + +static +VOID +RunTestCases(VOID) +{ + /* TODO: don't duplicate this here and in the RtlGetFullPathName_U test */ + struct + { + PCWSTR FileName; + PREFIX_TYPE PrefixType; + PCWSTR FullPathName; + RTL_PATH_TYPE PathType; + PREFIX_TYPE FilePartPrefixType; + SIZE_T FilePartSize; + } TestCases[] = + { + { L"C:", PrefixCurrentPath, L"", RtlPathTypeDriveRelative, PrefixCurrentPathWithoutLastPart }, + { L"C:\\", PrefixNone, L"C:\\", RtlPathTypeDriveAbsolute }, + { L"C:\\test", PrefixNone, L"C:\\test", RtlPathTypeDriveAbsolute, PrefixCurrentDrive }, + { L"C:\\test\\", PrefixNone, L"C:\\test\\", RtlPathTypeDriveAbsolute }, + { L"C:/test/", PrefixNone, L"C:\\test\\", RtlPathTypeDriveAbsolute }, + + { L"C:\\\\test", PrefixNone, L"C:\\test", RtlPathTypeDriveAbsolute, PrefixCurrentDrive }, + { L"test", PrefixCurrentPath, L"\\test", RtlPathTypeRelative, PrefixCurrentPath, sizeof(WCHAR) }, + { L"\\test", PrefixCurrentDrive, L"test", RtlPathTypeRooted, PrefixCurrentDrive }, + { L"/test", PrefixCurrentDrive, L"test", RtlPathTypeRooted, PrefixCurrentDrive }, + { L".\\test", PrefixCurrentPath, L"\\test", RtlPathTypeRelative, PrefixCurrentPath, sizeof(WCHAR) }, + + { L"\\.", PrefixCurrentDrive, L"", RtlPathTypeRooted }, + { L"\\.\\", PrefixCurrentDrive, L"", RtlPathTypeRooted }, + { L"\\\\.", PrefixNone, L"\\\\.\\", RtlPathTypeRootLocalDevice }, + { L"\\\\.\\", PrefixNone, L"\\\\.\\", RtlPathTypeLocalDevice }, + { L"\\\\.\\Something\\", PrefixNone, L"\\\\.\\Something\\", RtlPathTypeLocalDevice }, + + { L"\\??\\", PrefixCurrentDrive, L"??\\", RtlPathTypeRooted }, + { L"\\??\\C:", PrefixCurrentDrive, L"??\\C:", RtlPathTypeRooted, PrefixCurrentDrive, 3 * sizeof(WCHAR) }, + { L"\\??\\C:\\", PrefixCurrentDrive, L"??\\C:\\", RtlPathTypeRooted }, + { L"\\??\\C:\\test", PrefixCurrentDrive, L"??\\C:\\test", RtlPathTypeRooted, PrefixCurrentDrive, 6 * sizeof(WCHAR) }, + { L"\\??\\C:\\test\\", PrefixCurrentDrive, L"??\\C:\\test\\", RtlPathTypeRooted }, + + { L"\\\\??\\", PrefixNone, L"\\\\??\\", RtlPathTypeUncAbsolute }, + { L"\\\\??\\C:", PrefixNone, L"\\\\??\\C:", RtlPathTypeUncAbsolute }, + { L"\\\\??\\C:\\", PrefixNone, L"\\\\??\\C:\\", RtlPathTypeUncAbsolute }, + { L"\\\\??\\C:\\test", PrefixNone, L"\\\\??\\C:\\test", RtlPathTypeUncAbsolute, PrefixNone, sizeof(L"\\\\??\\C:\\") }, + { L"\\\\??\\C:\\test\\", PrefixNone, L"\\\\??\\C:\\test\\", RtlPathTypeUncAbsolute }, + }; + NTSTATUS ExceptionStatus; + ULONG Length; + UNICODE_STRING FileName; + WCHAR FullPathNameBuffer[MAX_PATH]; + UNICODE_STRING TempString; + const WCHAR *ShortName; + BOOLEAN NameInvalid; + PATH_TYPE_AND_UNKNOWN PathType; + WCHAR ExpectedPathName[MAX_PATH]; + SIZE_T ExpectedFilePartSize; + const WCHAR *ExpectedShortName; + const INT TestCount = sizeof(TestCases) / sizeof(TestCases[0]); + INT i; + + for (i = 0; i < TestCount; i++) + { + trace("i = %d\n", i); + switch (TestCases[i].PrefixType) + { + case PrefixNone: + ExpectedPathName[0] = UNICODE_NULL; + break; + case PrefixCurrentDrive: + GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName); + ExpectedPathName[3] = UNICODE_NULL; + break; + case PrefixCurrentPath: + { + ULONG Length; + Length = GetCurrentDirectoryW(sizeof(ExpectedPathName) / sizeof(WCHAR), ExpectedPathName); + if (Length == 3 && TestCases[i].FullPathName[0]) + ExpectedPathName[2] = UNICODE_NULL; + break; + } + default: + skip(0, "Invalid test!\n"); + continue; + } + wcscat(ExpectedPathName, TestCases[i].FullPathName); + RtlInitUnicodeString(&FileName, TestCases[i].FileName); + RtlFillMemory(FullPathNameBuffer, sizeof(FullPathNameBuffer), 0xAA); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + Length = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, + sizeof(FullPathNameBuffer), + FullPathNameBuffer, + &ShortName, + &NameInvalid, + &PathType); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(CheckStringBuffer(FullPathNameBuffer, Length, sizeof(FullPathNameBuffer), ExpectedPathName), + "Wrong path name '%S', expected '%S'\n", FullPathNameBuffer, ExpectedPathName); + switch (TestCases[i].FilePartPrefixType) + { + case PrefixNone: + ExpectedFilePartSize = 0; + break; + case PrefixCurrentDrive: + ExpectedFilePartSize = sizeof(L"C:\\"); + break; + case PrefixCurrentPath: + ExpectedFilePartSize = GetCurrentDirectoryW(0, NULL) * sizeof(WCHAR); + if (ExpectedFilePartSize == sizeof(L"C:\\")) + ExpectedFilePartSize -= sizeof(WCHAR); + break; + case PrefixCurrentPathWithoutLastPart: + { + WCHAR CurrentPath[MAX_PATH]; + PCWSTR BackSlash; + ExpectedFilePartSize = GetCurrentDirectoryW(sizeof(CurrentPath) / sizeof(WCHAR), CurrentPath) * sizeof(WCHAR) + sizeof(UNICODE_NULL); + if (ExpectedFilePartSize == sizeof(L"C:\\")) + ExpectedFilePartSize = 0; + else + { + BackSlash = wcsrchr(CurrentPath, L'\\'); + if (BackSlash) + ExpectedFilePartSize -= wcslen(BackSlash + 1) * sizeof(WCHAR); + else + ok(0, "GetCurrentDirectory returned %S\n", CurrentPath); + } + break; + } + default: + skip(0, "Invalid test!\n"); + continue; + } + ExpectedFilePartSize += TestCases[i].FilePartSize; + if (ExpectedFilePartSize == 0) + { + ExpectedShortName = NULL; + } + else + { + ExpectedFilePartSize = (ExpectedFilePartSize - sizeof(UNICODE_NULL)) / sizeof(WCHAR); + ExpectedShortName = FullPathNameBuffer + ExpectedFilePartSize; + } + ok(ShortName == ExpectedShortName, + "ShortName = %p, expected %p\n", ShortName, ExpectedShortName); + ok(NameInvalid == FALSE, "NameInvalid = %u\n", NameInvalid); + ok(PathType.Type == TestCases[i].PathType, "PathType = %d, expected %d\n", PathType.Type, TestCases[i].PathType); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) || + broken(PathType.Unknown == 32), "Unknown = %d\n", PathType.Unknown); + } +} + +START_TEST(RtlGetFullPathName_Ustr) +{ + NTSTATUS ExceptionStatus; + ULONG Length; + UNICODE_STRING FileName; + UNICODE_STRING TempString; + PCWSTR ShortName; + BOOLEAN NameInvalid; + PATH_TYPE_AND_UNKNOWN PathType; + + if (!RtlGetFullPathName_Ustr) + return; + + /* NULL parameters */ + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + + RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, NULL, NULL, &PathType); + EndSeh(STATUS_ACCESS_VIOLATION); + ok(PathType.Type == RtlPathTypeUnknown || + broken(PathType.Type == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* check what else is initialized before it crashes */ + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + StartSeh() + RtlGetFullPathName_Ustr(NULL, 0, NULL, &ShortName, &NameInvalid, &PathType); + EndSeh(STATUS_ACCESS_VIOLATION); + ok(NameInvalid == FALSE, "NameInvalid = %u\n", NameInvalid); + ok(ShortName == InvalidPointer || + broken(ShortName == NULL), "ShortName = %p\n", ShortName); + ok(PathType.Type == RtlPathTypeUnknown || + broken(PathType.Type == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + ShortName = InvalidPointer; + NameInvalid = (BOOLEAN)-1; + StartSeh() + RtlGetFullPathName_Ustr(&FileName, 0, NULL, &ShortName, &NameInvalid, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + ok(ShortName == InvalidPointer || + broken(ShortName == NULL), "ShortName = %p\n", ShortName); + ok(NameInvalid == FALSE || + broken(NameInvalid == (BOOLEAN)-1) /* Win7 */, "NameInvalid = %u\n", NameInvalid); + + /* This is the first one that doesn't crash. FileName and PathType cannot be NULL */ + RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == 0, "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeUnknown, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == 0, "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeUnknown, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* Give it a valid path */ + RtlInitUnicodeString(&FileName, L"C:\\test"); + TempString = FileName; + PathType.Type = RtlPathTypeNotSet; + PathType.Unknown = 1234; + StartSeh() + Length = RtlGetFullPathName_Ustr(&FileName, 0, NULL, NULL, NULL, &PathType); + ok(Length == sizeof(L"C:\\test"), "Length = %lu\n", Length); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType.Type == RtlPathTypeDriveAbsolute, "PathType = %d\n", PathType.Type); + ok(PathType.Unknown == 1234 || + broken(PathType.Unknown == 0) /* Win7 */, "Unknown = %d\n", PathType.Unknown); + + /* check the actual functionality with different paths */ + RunTestCases(); +} Propchange: trunk/rostests/apitests/ntdll/RtlGetFullPathName_Ustr.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetFull…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlGetFullPathName_UstrEx.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -13,14 +13,16 @@ /* NTSTATUS NTAPI -RtlGetFullPathName_UstrEx(IN PUNICODE_STRING FileName, - IN PUNICODE_STRING StaticString, - IN PUNICODE_STRING DynamicString, - IN PUNICODE_STRING *StringUsed, - IN PSIZE_T FilePartSize OPTIONAL, - OUT PBOOLEAN NameInvalid, - OUT RTL_PATH_TYPE* PathType, - OUT PSIZE_T LengthNeeded OPTIONAL); +RtlGetFullPathName_UstrEx( + IN PUNICODE_STRING FileName, + IN PUNICODE_STRING StaticString, + IN PUNICODE_STRING DynamicString, + IN PUNICODE_STRING *StringUsed, + IN PSIZE_T FilePartSize OPTIONAL, + OUT PBOOLEAN NameInvalid, + OUT RTL_PATH_TYPE* PathType, + OUT PSIZE_T LengthNeeded OPTIONAL +); */ #define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { @@ -80,7 +82,7 @@ } #define RtlPathTypeNotSet 123 -#define InvalidPointer ((PVOID)0x1234) +#define InvalidPointer ((PVOID)0x0123456789ABCDEFULL) /* winetest_platform is "windows" for us, so broken() doesn't do what it should :( */ #undef broken @@ -202,11 +204,8 @@ ok_eq_ustr(&FileName, &TempString); ok(FullPathName.Buffer == FullPathNameBuffer, "Buffer modified\n"); ok(FullPathName.MaximumLength == sizeof(FullPathNameBuffer), "MaximumLength modified\n"); - /* TODO: remove SEH here */ - StartSeh() - ok(CheckStringBuffer(&FullPathName, ExpectedPathName), - "Wrong path name '%wZ', expected '%S'\n", &FullPathName, ExpectedPathName); - EndSeh(STATUS_SUCCESS); + ok(CheckStringBuffer(&FullPathName, ExpectedPathName), + "Wrong path name '%wZ', expected '%S'\n", &FullPathName, ExpectedPathName); ok(StringUsed == &FullPathName, "StringUsed = %p, expected %p\n", StringUsed, &FullPathName); switch (TestCases[i].FilePartPrefixType) { @@ -270,6 +269,13 @@ RtlGetFullPathName_UstrEx(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EndSeh(STATUS_ACCESS_VIOLATION); + RtlInitUnicodeString(&FileName, NULL); + TempString = FileName; + StartSeh() + RtlGetFullPathName_UstrEx(&FileName, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + EndSeh(STATUS_ACCESS_VIOLATION); + ok_eq_ustr(&FileName, &TempString); + RtlInitUnicodeString(&FileName, L""); TempString = FileName; StartSeh() @@ -284,7 +290,7 @@ ok(PathType == RtlPathTypeUnknown || broken(PathType == RtlPathTypeNotSet) /* Win7 */, "PathType = %d\n", PathType); - /* check what else is initialized before it crashes */ + /* Check what else is initialized before it crashes */ PathType = RtlPathTypeNotSet; StringUsed = InvalidPointer; FilePartSize = 1234; @@ -317,7 +323,7 @@ ok(LengthNeeded == 0, "LengthNeeded = %lu\n", (ULONG)LengthNeeded); /* This is the first one that doesn't crash. FileName and PathType cannot be NULL */ - RtlInitUnicodeString(&FileName, L""); + RtlInitUnicodeString(&FileName, NULL); TempString = FileName; PathType = RtlPathTypeNotSet; StartSeh() @@ -327,6 +333,16 @@ ok_eq_ustr(&FileName, &TempString); ok(PathType == RtlPathTypeUnknown, "PathType = %d\n", PathType); + RtlInitUnicodeString(&FileName, L""); + TempString = FileName; + PathType = RtlPathTypeNotSet; + StartSeh() + Status = RtlGetFullPathName_UstrEx(&FileName, NULL, NULL, NULL, NULL, NULL, &PathType, NULL); + ok(Status == STATUS_OBJECT_NAME_INVALID, "status = %lx\n", Status); + EndSeh(STATUS_SUCCESS); + ok_eq_ustr(&FileName, &TempString); + ok(PathType == RtlPathTypeUnknown, "PathType = %d\n", PathType); + /* Give it a valid path */ RtlInitUnicodeString(&FileName, L"C:\\test"); TempString = FileName; @@ -352,6 +368,6 @@ /* TODO: play around with StaticString and DynamicString */ - /* check the actual functionality with different paths */ + /* Check the actual functionality with different paths */ RunTestCases(); } Modified: trunk/rostests/apitests/ntdll/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Wed Apr 25 09:52:38 2012 @@ -10,6 +10,7 @@ extern void func_NtSystemInformation(void); extern void func_RtlDetermineDosPathNameType(void); extern void func_RtlGetFullPathName_U(void); +extern void func_RtlGetFullPathName_Ustr(void); extern void func_RtlGetFullPathName_UstrEx(void); extern void func_RtlGetLongestNtPathLength(void); extern void func_RtlInitializeBitMap(void); @@ -22,6 +23,7 @@ { "NtSystemInformation", func_NtSystemInformation }, { "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType }, { "RtlGetFullPathName_U", func_RtlGetFullPathName_U }, + { "RtlGetFullPathName_Ustr", func_RtlGetFullPathName_Ustr }, { "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx }, { "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength }, { "RtlInitializeBitMap", func_RtlInitializeBitMap },
12 years, 8 months
1
0
0
0
[tfaber] 56412: [NTDLL_APITEST] - Fix GCC build
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 25 07:57:50 2012 New Revision: 56412 URL:
http://svn.reactos.org/svn/reactos?rev=56412&view=rev
Log: [NTDLL_APITEST] - Fix GCC build Modified: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c Modified: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlDetermi…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] Wed Apr 25 07:57:50 2012 @@ -146,8 +146,8 @@ { L"/\\?", RtlPathTypeRootLocalDevice }, { L"\\/?", RtlPathTypeRootLocalDevice }, { L"//??", RtlPathTypeUncAbsolute }, - { L"//??/", RtlPathTypeUncAbsolute }, - { L"//??/C:/", RtlPathTypeUncAbsolute }, + { L"//?" L"?/", RtlPathTypeUncAbsolute }, + { L"//?" L"?/C:/", RtlPathTypeUncAbsolute }, { L"//.", RtlPathTypeRootLocalDevice }, { L"\\/.", RtlPathTypeRootLocalDevice }, { L"/\\.", RtlPathTypeRootLocalDevice }, @@ -180,8 +180,8 @@ RtlCopyMemory(FileName, Tests[i].FileName, Length + sizeof(UNICODE_NULL)); StartSeh() PathType = RtlDetermineDosPathNameType_U(FileName); + ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); EndSeh(STATUS_SUCCESS); - ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); FreeGuarded(FileName); if (RtlDetermineDosPathNameType_Ustr) @@ -195,8 +195,8 @@ PathString.MaximumLength = MAXUSHORT; StartSeh() PathType = RtlDetermineDosPathNameType_Ustr(&PathString); + ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); EndSeh(STATUS_SUCCESS); - ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); FreeGuarded(FileName); } }
12 years, 8 months
1
0
0
0
[tfaber] 56411: [NTDLL_APITEST] - Add test for RtlGetLongestNtPathLength - Add test for RtlDetermineDosPathNameType_U (and RtlDetermineDosPathNameType_Ustr, if address is known)
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 25 07:43:33 2012 New Revision: 56411 URL:
http://svn.reactos.org/svn/reactos?rev=56411&view=rev
Log: [NTDLL_APITEST] - Add test for RtlGetLongestNtPathLength - Add test for RtlDetermineDosPathNameType_U (and RtlDetermineDosPathNameType_Ustr, if address is known) Added: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c (with props) trunk/rostests/apitests/ntdll/RtlGetLongestNtPathLength.c (with props) Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt trunk/rostests/apitests/ntdll/testlist.c Modified: trunk/rostests/apitests/ntdll/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/CMakeLists…
============================================================================== --- trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/CMakeLists.txt [iso-8859-1] Wed Apr 25 07:43:33 2012 @@ -2,8 +2,10 @@ list(APPEND SOURCE NtAllocateVirtualMemory.c NtFreeVirtualMemory.c + RtlDetermineDosPathNameType.c RtlGetFullPathName_U.c RtlGetFullPathName_UstrEx.c + RtlGetLongestNtPathLength.c RtlInitializeBitMap.c SystemInfo.c ZwContinue.c Added: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlDetermi…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c (added) +++ trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c [iso-8859-1] Wed Apr 25 07:43:33 2012 @@ -1,0 +1,203 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for RtlDetermineDosPathNameType_U/RtlDetermineDosPathNameType_Ustr + * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> + */ + +#define WIN32_NO_STATUS +#include <wine/test.h> +#include <pseh/pseh2.h> +#include <ndk/mmfuncs.h> +#include <ndk/rtlfuncs.h> + +/* +ULONG +NTAPI +RtlDetermineDosPathNameType_U( + IN PCWSTR Path +); + +ULONG +NTAPI +RtlDetermineDosPathNameType_Ustr( + IN PCUNICODE_STRING Path +); +*/ + +static +ULONG +(NTAPI +*RtlDetermineDosPathNameType_Ustr)( + IN PCUNICODE_STRING Path +) +//= (PVOID)0x7c830669; +; + +static +PVOID +AllocateGuarded( + SIZE_T SizeRequested) +{ + NTSTATUS Status; + SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE); + PVOID VirtualMemory = NULL; + PCHAR StartOfBuffer; + + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS); + + if (!NT_SUCCESS(Status)) + return NULL; + + Size -= PAGE_SIZE; + if (Size) + { + Status = NtAllocateVirtualMemory(NtCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE); + if (!NT_SUCCESS(Status)) + { + Size = 0; + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); + return NULL; + } + } + + StartOfBuffer = VirtualMemory; + StartOfBuffer += Size - SizeRequested; + + return StartOfBuffer; +} + +static +VOID +FreeGuarded( + PVOID Pointer) +{ + NTSTATUS Status; + PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer); + SIZE_T Size = 0; + + Status = NtFreeVirtualMemory(NtCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE); + ok(Status == STATUS_SUCCESS, "Status = %lx\n", Status); +} + +#define StartSeh() ExceptionStatus = STATUS_SUCCESS; _SEH2_TRY { +#define EndSeh(ExpectedStatus) } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { ExceptionStatus = _SEH2_GetExceptionCode(); } _SEH2_END; ok(ExceptionStatus == ExpectedStatus, "Exception %lx, expected %lx\n", ExceptionStatus, ExpectedStatus) + +START_TEST(RtlDetermineDosPathNameType) +{ + NTSTATUS ExceptionStatus; + RTL_PATH_TYPE PathType; + struct + { + PCWSTR FileName; + RTL_PATH_TYPE PathType; + } Tests[] = + { + { L"", RtlPathTypeRelative }, + { L"xyz", RtlPathTypeRelative }, + { L"CON", RtlPathTypeRelative }, + { L"NUL", RtlPathTypeRelative }, + { L":", RtlPathTypeRelative }, + { L"::", RtlPathTypeDriveRelative }, + { L":::", RtlPathTypeDriveRelative }, + { L"::::", RtlPathTypeDriveRelative }, + { L"\\", RtlPathTypeRooted }, + { L"\\:", RtlPathTypeRooted }, + { L"\\C:", RtlPathTypeRooted }, + { L"\\C:\\", RtlPathTypeRooted }, + { L"/", RtlPathTypeRooted }, + { L"/:", RtlPathTypeRooted }, + { L"/C:", RtlPathTypeRooted }, + { L"/C:/", RtlPathTypeRooted }, + { L"C", RtlPathTypeRelative }, + { L"C:", RtlPathTypeDriveRelative }, + { L"C:a", RtlPathTypeDriveRelative }, + { L"C:a\\", RtlPathTypeDriveRelative }, + { L"C:\\", RtlPathTypeDriveAbsolute }, + { L"C:/", RtlPathTypeDriveAbsolute }, + { L"C:\\a", RtlPathTypeDriveAbsolute }, + { L"C:/a", RtlPathTypeDriveAbsolute }, + { L"C:\\\\", RtlPathTypeDriveAbsolute }, + { L"\\\\", RtlPathTypeUncAbsolute }, + { L"\\\\\\", RtlPathTypeUncAbsolute }, + { L"\\\\;", RtlPathTypeUncAbsolute }, + { L"\\??\\", RtlPathTypeRooted }, + { L"\\??\\UNC", RtlPathTypeRooted }, + { L"\\??\\UNC\\", RtlPathTypeRooted }, + { L"\\?", RtlPathTypeRooted }, + { L"\\?\\", RtlPathTypeRooted }, + { L"\\?\\UNC", RtlPathTypeRooted }, + { L"\\?\\UNC\\", RtlPathTypeRooted }, + { L"\\\\?\\UNC\\", RtlPathTypeLocalDevice }, + { L"\\\\?", RtlPathTypeRootLocalDevice }, + { L"\\\\??", RtlPathTypeUncAbsolute }, + { L"\\\\??\\", RtlPathTypeUncAbsolute }, + { L"\\\\??\\C:\\", RtlPathTypeUncAbsolute }, + { L"\\\\.", RtlPathTypeRootLocalDevice }, + { L"\\\\.\\", RtlPathTypeLocalDevice }, + { L"\\\\.\\C:\\", RtlPathTypeLocalDevice }, + { L"\\/", RtlPathTypeUncAbsolute }, + { L"/\\", RtlPathTypeUncAbsolute }, + { L"//", RtlPathTypeUncAbsolute }, + { L"///", RtlPathTypeUncAbsolute }, + { L"//;", RtlPathTypeUncAbsolute }, + { L"//?", RtlPathTypeRootLocalDevice }, + { L"/\\?", RtlPathTypeRootLocalDevice }, + { L"\\/?", RtlPathTypeRootLocalDevice }, + { L"//??", RtlPathTypeUncAbsolute }, + { L"//??/", RtlPathTypeUncAbsolute }, + { L"//??/C:/", RtlPathTypeUncAbsolute }, + { L"//.", RtlPathTypeRootLocalDevice }, + { L"\\/.", RtlPathTypeRootLocalDevice }, + { L"/\\.", RtlPathTypeRootLocalDevice }, + { L"//./", RtlPathTypeLocalDevice }, + { L"//./C:/", RtlPathTypeLocalDevice }, + }; + ULONG i; + PWSTR FileName; + USHORT Length; + + if (!RtlDetermineDosPathNameType_Ustr) + skip(0, "RtlDetermineDosPathNameType_Ustr unavailable\n"); + + StartSeh() RtlDetermineDosPathNameType_U(NULL); EndSeh(STATUS_ACCESS_VIOLATION); + + if (RtlDetermineDosPathNameType_Ustr) + { + UNICODE_STRING PathString; + StartSeh() RtlDetermineDosPathNameType_Ustr(NULL); EndSeh(STATUS_ACCESS_VIOLATION); + + RtlInitEmptyUnicodeString(&PathString, NULL, MAXUSHORT); + PathType = RtlDetermineDosPathNameType_Ustr(&PathString); + ok(PathType == RtlPathTypeRelative, "PathType = %d\n", PathType); + } + + for (i = 0; i < sizeof(Tests) / sizeof(Tests[0]); i++) + { + Length = (USHORT)wcslen(Tests[i].FileName) * sizeof(WCHAR); + FileName = AllocateGuarded(Length + sizeof(UNICODE_NULL)); + RtlCopyMemory(FileName, Tests[i].FileName, Length + sizeof(UNICODE_NULL)); + StartSeh() + PathType = RtlDetermineDosPathNameType_U(FileName); + EndSeh(STATUS_SUCCESS); + ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); + FreeGuarded(FileName); + + if (RtlDetermineDosPathNameType_Ustr) + { + UNICODE_STRING PathString; + + FileName = AllocateGuarded(Length); + RtlCopyMemory(FileName, Tests[i].FileName, Length); + PathString.Buffer = FileName; + PathString.Length = Length; + PathString.MaximumLength = MAXUSHORT; + StartSeh() + PathType = RtlDetermineDosPathNameType_Ustr(&PathString); + EndSeh(STATUS_SUCCESS); + ok(PathType == Tests[i].PathType, "PathType is %d, expected %d for '%S'\n", PathType, Tests[i].PathType, Tests[i].FileName); + FreeGuarded(FileName); + } + } +} Propchange: trunk/rostests/apitests/ntdll/RtlDetermineDosPathNameType.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/apitests/ntdll/RtlGetLongestNtPathLength.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/RtlGetLong…
============================================================================== --- trunk/rostests/apitests/ntdll/RtlGetLongestNtPathLength.c (added) +++ trunk/rostests/apitests/ntdll/RtlGetLongestNtPathLength.c [iso-8859-1] Wed Apr 25 07:43:33 2012 @@ -1,0 +1,24 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for RtlGetLongestNtPathLength + * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de> + */ + +#define WIN32_NO_STATUS +#include <wine/test.h> +#include <ndk/rtlfuncs.h> + +/* +ULONG +NTAPI +RtlGetLongestNtPathLength(VOID); +*/ + +START_TEST(RtlGetLongestNtPathLength) +{ + ULONG Length; + + Length = RtlGetLongestNtPathLength(); + ok(Length == 269, "Length = %lu\n", Length); +} Propchange: trunk/rostests/apitests/ntdll/RtlGetLongestNtPathLength.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/ntdll/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/testlist.c…
============================================================================== --- trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/testlist.c [iso-8859-1] Wed Apr 25 07:43:33 2012 @@ -8,20 +8,24 @@ extern void func_NtAllocateVirtualMemory(void); extern void func_NtFreeVirtualMemory(void); extern void func_NtSystemInformation(void); +extern void func_RtlDetermineDosPathNameType(void); extern void func_RtlGetFullPathName_U(void); extern void func_RtlGetFullPathName_UstrEx(void); +extern void func_RtlGetLongestNtPathLength(void); extern void func_RtlInitializeBitMap(void); extern void func_ZwContinue(void); const struct test winetest_testlist[] = { - { "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory }, - { "NtFreeVirtualMemory", func_NtFreeVirtualMemory }, - { "NtSystemInformation", func_NtSystemInformation }, - { "RtlGetFullPathName_U", func_RtlGetFullPathName_U }, - { "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx }, - { "RtlInitializeBitMap", func_RtlInitializeBitMap }, - { "ZwContinue", func_ZwContinue }, + { "NtAllocateVirtualMemory", func_NtAllocateVirtualMemory }, + { "NtFreeVirtualMemory", func_NtFreeVirtualMemory }, + { "NtSystemInformation", func_NtSystemInformation }, + { "RtlDetermineDosPathNameType", func_RtlDetermineDosPathNameType }, + { "RtlGetFullPathName_U", func_RtlGetFullPathName_U }, + { "RtlGetFullPathName_UstrEx", func_RtlGetFullPathName_UstrEx }, + { "RtlGetLongestNtPathLength", func_RtlGetLongestNtPathLength }, + { "RtlInitializeBitMap", func_RtlInitializeBitMap }, + { "ZwContinue", func_ZwContinue }, { 0, 0 } };
12 years, 8 months
1
0
0
0
[tfaber] 56410: [RTL/NDK] - Add missing mmtypes.h include in mmfuncs.h - Remove RtlDetermineDosPathNameType_Ustr from rtlfuncs.h, move it up in path.c - Add RtlGetLongestNtPathLength to rtlfuncs.h
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Apr 25 07:24:17 2012 New Revision: 56410 URL:
http://svn.reactos.org/svn/reactos?rev=56410&view=rev
Log: [RTL/NDK] - Add missing mmtypes.h include in mmfuncs.h - Remove RtlDetermineDosPathNameType_Ustr from rtlfuncs.h, move it up in path.c - Add RtlGetLongestNtPathLength to rtlfuncs.h Modified: trunk/reactos/include/ndk/mmfuncs.h trunk/reactos/include/ndk/rtlfuncs.h trunk/reactos/lib/rtl/path.c Modified: trunk/reactos/include/ndk/mmfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/mmfuncs.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/mmfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/mmfuncs.h [iso-8859-1] Wed Apr 25 07:24:17 2012 @@ -23,6 +23,7 @@ // Dependencies // #include <umtypes.h> +#include <mmtypes.h> #ifndef NTOS_MODE_USER Modified: trunk/reactos/include/ndk/rtlfuncs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtlfuncs.h?rev…
============================================================================== --- trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/rtlfuncs.h [iso-8859-1] Wed Apr 25 07:24:17 2012 @@ -2513,13 +2513,6 @@ ); NTSYSAPI -RTL_PATH_TYPE -NTAPI -RtlDetermineDosPathNameType_Ustr( - IN PCUNICODE_STRING Path -); - -NTSYSAPI ULONG NTAPI RtlDosSearchPath_U( @@ -2617,6 +2610,13 @@ OUT PBOOLEAN NameInvalid, OUT RTL_PATH_TYPE* PathType, OUT PSIZE_T LengthNeeded +); + +NTSYSAPI +ULONG +NTAPI +RtlGetLongestNtPathLength( + VOID ); NTSYSAPI Modified: trunk/reactos/lib/rtl/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/path.c?rev=56410&r…
============================================================================== --- trunk/reactos/lib/rtl/path.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/path.c [iso-8859-1] Wed Apr 25 07:24:17 2012 @@ -50,6 +50,42 @@ /* PRIVATE FUNCTIONS **********************************************************/ +RTL_PATH_TYPE +NTAPI +RtlDetermineDosPathNameType_Ustr(IN PCUNICODE_STRING PathString) +{ + PWCHAR Path; + ULONG Chars; + + /* Validate the input */ + if (!PathString) return RtlPathTypeUnknown; + + Path = PathString->Buffer; + Chars = PathString->Length / sizeof(WCHAR); + + /* Return if there are no characters */ + if (!Chars) return RtlPathTypeUnknown; + + /* + * The algorithm is similar to RtlDetermineDosPathNameType_U but here we + * actually check for the path length before touching the characters + */ + if ((Chars < 1) || (IS_PATH_SEPARATOR(Path[0]))) + { + if ((Chars < 2) || !(IS_PATH_SEPARATOR(Path[1]))) return RtlPathTypeRooted; /* \x */ + if ((Chars < 3) || ((Path[2] != L'.') && (Path[2] != L'?'))) return RtlPathTypeUncAbsolute;/* \\x */ + if ((Chars >= 4) && (IS_PATH_SEPARATOR(Path[3]))) return RtlPathTypeLocalDevice; /* \\.\x or \\?\x */ + if (Chars != 3) return RtlPathTypeUncAbsolute; /* \\.x or \\?x */ + return RtlPathTypeRootLocalDevice; /* \\. or \\? */ + } + else + { + if ((Chars < 2) || (!(Path[0]) || (Path[1] != L':'))) return RtlPathTypeRelative; /* x */ + if ((Chars < 3) || (IS_PATH_SEPARATOR(Path[2]))) return RtlPathTypeDriveAbsolute; /* x:\ */ + return RtlPathTypeDriveRelative; /* x: */ + } +} + ULONG NTAPI RtlIsDosDeviceName_Ustr(IN PCUNICODE_STRING PathString) @@ -209,42 +245,6 @@ /* Otherwise, this is not a valid DOS device */ return 0; -} - -RTL_PATH_TYPE -NTAPI -RtlDetermineDosPathNameType_Ustr(IN PCUNICODE_STRING PathString) -{ - PWCHAR Path; - ULONG Chars; - - /* Validate the input */ - if (!PathString) return RtlPathTypeUnknown; - - Path = PathString->Buffer; - Chars = PathString->Length / sizeof(WCHAR); - - /* Return if there are no characters */ - if (!Chars) return RtlPathTypeUnknown; - - /* - * The algorithm is similar to RtlDetermineDosPathNameType_U but here we - * actually check for the path length before touching the characters - */ - if ((Chars < 1) || (IS_PATH_SEPARATOR(Path[0]))) - { - if ((Chars < 2) || !(IS_PATH_SEPARATOR(Path[1]))) return RtlPathTypeRooted; /* \x */ - if ((Chars < 3) || ((Path[2] != L'.') && (Path[2] != L'?'))) return RtlPathTypeUncAbsolute;/* \\x */ - if ((Chars >= 4) && (IS_PATH_SEPARATOR(Path[3]))) return RtlPathTypeLocalDevice; /* \\.\x or \\?\x */ - if (Chars != 3) return RtlPathTypeUncAbsolute; /* \\.x or \\?x */ - return RtlPathTypeRootLocalDevice; /* \\. or \\? */ - } - else - { - if ((Chars < 2) || (!(Path[0]) || (Path[1] != L':'))) return RtlPathTypeRelative; /* x */ - if ((Chars < 3) || (IS_PATH_SEPARATOR(Path[2]))) return RtlPathTypeDriveAbsolute; /* x:\ */ - return RtlPathTypeDriveRelative; /* x: */ - } } NTSTATUS
12 years, 8 months
1
0
0
0
[tkreuzer] 56409: [WIN32K] - Fix a bug in the region code that could cause allocating 0 bytes - Remove SetLastError() - "flatten" IntGdiCombineRgn making it more readable
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Tue Apr 24 18:35:50 2012 New Revision: 56409 URL:
http://svn.reactos.org/svn/reactos?rev=56409&view=rev
Log: [WIN32K] - Fix a bug in the region code that could cause allocating 0 bytes - Remove SetLastError() - "flatten" IntGdiCombineRgn making it more readable Modified: trunk/reactos/win32ss/gdi/ntgdi/region.c Modified: trunk/reactos/win32ss/gdi/ntgdi/region.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/region.c…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/region.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/region.c [iso-8859-1] Tue Apr 24 18:35:50 2012 @@ -960,9 +960,10 @@ * have to worry about using too much memory. I hope to be able to * nuke the Xrealloc() at the end of this function eventually. */ - newReg->rdh.nRgnSize = max(reg1->rdh.nCount,reg2->rdh.nCount) * 2 * sizeof(RECT); - - if (! (newReg->Buffer = ExAllocatePoolWithTag(PagedPool, newReg->rdh.nRgnSize, TAG_REGION))) + newReg->rdh.nRgnSize = max(reg1->rdh.nCount + 1,reg2->rdh.nCount) * 2 * sizeof(RECT); + + newReg->Buffer = ExAllocatePoolWithTag(PagedPool, newReg->rdh.nRgnSize, TAG_REGION); + if (!newReg->Buffer) { newReg->rdh.nRgnSize = 0; return; @@ -2379,64 +2380,56 @@ INT FASTCALL -IntGdiCombineRgn(PROSRGNDATA destRgn, - PROSRGNDATA src1Rgn, - PROSRGNDATA src2Rgn, - INT CombineMode) -{ - INT result = ERROR; - - if (destRgn) - { - if (src1Rgn) - { - if (CombineMode == RGN_COPY) - { - if ( !REGION_CopyRegion(destRgn, src1Rgn) ) - return ERROR; - result = REGION_Complexity(destRgn); - } - else - { - if (src2Rgn) - { - switch (CombineMode) - { - case RGN_AND: - REGION_IntersectRegion(destRgn, src1Rgn, src2Rgn); - break; - case RGN_OR: - REGION_UnionRegion(destRgn, src1Rgn, src2Rgn); - break; - case RGN_XOR: - REGION_XorRegion(destRgn, src1Rgn, src2Rgn); - break; - case RGN_DIFF: - REGION_SubtractRegion(destRgn, src1Rgn, src2Rgn); - break; - } - result = REGION_Complexity(destRgn); - } - else if (src2Rgn == NULL) - { - DPRINT1("IntGdiCombineRgn requires hSrc2 != NULL for combine mode %d!\n", CombineMode); - EngSetLastError(ERROR_INVALID_HANDLE); - ASSERT(FALSE); - } - } - } - else - { +IntGdiCombineRgn( + PROSRGNDATA prgnDest, + PROSRGNDATA prgnSrc1, + PROSRGNDATA prgnSrc2, + INT iCombineMode) +{ + + if (!prgnDest) + { + DPRINT("IntGdiCombineRgn: hDest unavailable\n"); + return ERROR; + } + + if (!prgnSrc1) + { DPRINT("IntGdiCombineRgn: hSrc1 unavailable\n"); - EngSetLastError(ERROR_INVALID_HANDLE); - } - } - else - { - DPRINT("IntGdiCombineRgn: hDest unavailable\n"); - EngSetLastError(ERROR_INVALID_HANDLE); - } - return result; + return ERROR; + } + + if (iCombineMode == RGN_COPY) + { + if (!REGION_CopyRegion(prgnDest, prgnSrc1)) + return ERROR; + return REGION_Complexity(prgnDest); + } + + if (!prgnSrc2) + { + DPRINT1("IntGdiCombineRgn requires hSrc2 != NULL for combine mode %d!\n", iCombineMode); + ASSERT(FALSE); + return ERROR; + } + + switch (iCombineMode) + { + case RGN_AND: + REGION_IntersectRegion(prgnDest, prgnSrc1, prgnSrc2); + break; + case RGN_OR: + REGION_UnionRegion(prgnDest, prgnSrc1, prgnSrc2); + break; + case RGN_XOR: + REGION_XorRegion(prgnDest, prgnSrc1, prgnSrc2); + break; + case RGN_DIFF: + REGION_SubtractRegion(prgnDest, prgnSrc1, prgnSrc2); + break; + } + + return REGION_Complexity(prgnDest); } INT FASTCALL @@ -3339,7 +3332,6 @@ if (iMode < RGN_AND || iMode > RGN_COPY) { - EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } @@ -3347,7 +3339,6 @@ { DPRINT1("NtGdiCombineRgn: %p, %p, %p, %d\n", hrgnDst, hrgnSrc1, hrgnSrc2, iMode); - EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; } @@ -3359,7 +3350,6 @@ { DPRINT1("NtGdiCombineRgn: %p, %p, %p, %d\n", hrgnDst, hrgnSrc1, hrgnSrc2, iMode); - EngSetLastError(ERROR_INVALID_PARAMETER); return ERROR; }
12 years, 8 months
1
0
0
0
[tkreuzer] 56408: [GDI32_APITEST] - Add tests for CombineRgn
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Tue Apr 24 17:11:08 2012 New Revision: 56408 URL:
http://svn.reactos.org/svn/reactos?rev=56408&view=rev
Log: [GDI32_APITEST] - Add tests for CombineRgn Added: trunk/rostests/apitests/gdi32/CombineRgn.c (with props) Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt trunk/rostests/apitests/gdi32/testlist.c Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists…
============================================================================== --- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Tue Apr 24 17:11:08 2012 @@ -6,6 +6,7 @@ AddFontResource.c AddFontResourceEx.c BeginPath.c + CombineRgn.c CombineTransform.c CreateBitmap.c CreateBitmapIndirect.c Added: trunk/rostests/apitests/gdi32/CombineRgn.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CombineRgn…
============================================================================== --- trunk/rostests/apitests/gdi32/CombineRgn.c (added) +++ trunk/rostests/apitests/gdi32/CombineRgn.c [iso-8859-1] Tue Apr 24 17:11:08 2012 @@ -1,0 +1,198 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ... + * PROGRAMMERS: Timo Kreuzer + */ + +#include <stdio.h> +#include <wine/test.h> +#include <windows.h> + +#define ok_long(expression, result) \ + { \ + int _value = (expression); \ + ok(_value == (result), "Wrong value for %s, expected " #result " (0x%x), got 0x%x\n", \ + #expression, (int)(result), _value); \ + } + + +void Test_CombineRgn_COPY() +{ + HRGN hrgn1, hrgn2, hrgn3; + + hrgn1 = CreateRectRgn(0, 0, 0, 0); + hrgn2 = CreateRectRgn(0, 0, 10, 10); + hrgn3 = CreateRectRgn(5, 5, 20, 20); + + SetLastError(0xbadbabe); + ok_long(CombineRgn(NULL, NULL, NULL, RGN_COPY), ERROR); + ok_long(CombineRgn(NULL, hrgn1, NULL, RGN_COPY), ERROR); + ok_long(CombineRgn(NULL, NULL, hrgn1, RGN_COPY), ERROR); + ok_long(CombineRgn(NULL, hrgn1, hrgn2, RGN_COPY), ERROR); + ok_long(GetLastError(), 0xbadbabe); + + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_COPY), SIMPLEREGION); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, hrgn1, NULL, RGN_COPY), SIMPLEREGION); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, hrgn3, GetStockObject(BLACK_PEN), RGN_COPY), SIMPLEREGION); + ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_COPY), ERROR); + ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_COPY), ERROR); + ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_COPY), ERROR); + ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n"); + + ok_long(GetLastError(), 0xbadbabe); + +} + +void Test_CombineRgn_AND() +{ + HRGN hrgn1, hrgn2, hrgn3; + + hrgn1 = CreateRectRgn(0, 0, 0, 0); + hrgn2 = CreateRectRgn(0, 0, 10, 10); + hrgn3 = CreateRectRgn(5, 5, 20, 20); + + SetLastError(0xbadbabe); + ok_long(CombineRgn(NULL, NULL, NULL, RGN_AND), ERROR); + ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_AND), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_AND), ERROR); + ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_AND), ERROR); + ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_AND), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_AND), ERROR); + ok_long(GetLastError(), 0xbadbabe); + + + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION); + SetRectRgn(hrgn2, 5, 5, 10, 10); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + SetRectRgn(hrgn2, 0, 0, 5, 5); + SetRectRgn(hrgn3, 5, 0, 10, 5); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), NULLREGION); + SetRectRgn(hrgn2, 0, 0, 0, 0); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + SetRectRgn(hrgn2, 0, 0, 20, 20); + SetRectRgn(hrgn3, 5, 5, 10, 10); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION); + SetRectRgn(hrgn2, 5, 5, 10, 10); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + + SetRectRgn(hrgn2, 0, 0, 30, 10); + SetRectRgn(hrgn3, 10, 10, 20, 30); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION); + SetRectRgn(hrgn2, 10, 0, 30, 30); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), COMPLEXREGION); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), COMPLEXREGION); + SetRectRgn(hrgn2, 10, 10, 30, 30); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), SIMPLEREGION); + SetRectRgn(hrgn2, 0, 0, 10, 10); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), NULLREGION); + + SetRectRgn(hrgn1, 0, 0, 30, 10); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), SIMPLEREGION); + +} + +void Test_CombineRgn_OR() +{ + HRGN hrgn1, hrgn2, hrgn3; + + hrgn1 = CreateRectRgn(0, 0, 0, 0); + hrgn2 = CreateRectRgn(0, 0, 5, 5); + hrgn3 = CreateRectRgn(5, 0, 10, 5); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), SIMPLEREGION); + SetRectRgn(hrgn2, 0, 0, 10, 5); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + + SetRectRgn(hrgn2, 0, 0, 10, 10); + SetRectRgn(hrgn3, 10, 10, 20, 20); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION); + SetRectRgn(hrgn2, 10, 0, 20, 10); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_OR), COMPLEXREGION); + SetRectRgn(hrgn2, 0, 10, 10, 20); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), SIMPLEREGION); + SetRectRgn(hrgn2, 0, 0, 20, 20); + ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n"); + +} + +void Test_CombineRgn_DIFF() +{ + HRGN hrgn1, hrgn2, hrgn3; + + hrgn1 = CreateRectRgn(0, 0, 0, 0); + hrgn2 = CreateRectRgn(0, 0, 10, 10); + hrgn3 = CreateRectRgn(5, 0, 10, 5); + + SetLastError(0xbadbabe); + ok_long(CombineRgn(NULL, NULL, NULL, RGN_DIFF), ERROR); + ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_DIFF), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_DIFF), ERROR); + ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_DIFF), ERROR); + ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_DIFF), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_DIFF), ERROR); + ok_long(GetLastError(), 0xbadbabe); + + ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_DIFF), NULLREGION); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn2, RGN_DIFF), NULLREGION); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION); + + ok_long(CombineRgn(hrgn1, hrgn2, hrgn1, RGN_DIFF), SIMPLEREGION); + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_DIFF), COMPLEXREGION); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_DIFF), COMPLEXREGION); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION); + + +} + +void Test_CombineRgn_XOR() +{ + HRGN hrgn1, hrgn2, hrgn3, hrgn4; + + hrgn1 = CreateRectRgn(0, 0, 0, 0); + hrgn2 = CreateRectRgn(0, 0, 5, 5); + hrgn3 = CreateRectRgn(5, 5, 10, 10); + hrgn4 = CreateRectRgn(0, 0, 0, 0); + + SetLastError(0xbadbabe); + ok_long(CombineRgn(NULL, NULL, NULL, RGN_XOR), ERROR); + ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_XOR), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_XOR), ERROR); + ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_XOR), ERROR); + ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_XOR), ERROR); + ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_XOR), ERROR); + ok_long(GetLastError(), 0xbadbabe); + + ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_XOR), COMPLEXREGION); + ok_long(CombineRgn(hrgn4, hrgn2, hrgn3, RGN_OR), COMPLEXREGION); + ok(EqualRgn(hrgn1, hrgn4), "Region is not correct\n"); + + ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION); + ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n"); + ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_XOR), NULLREGION); + + +} + +START_TEST(CombineRgn) +{ + Test_CombineRgn_COPY(); + Test_CombineRgn_AND(); + Test_CombineRgn_OR(); + Test_CombineRgn_DIFF(); + Test_CombineRgn_XOR(); +} + Propchange: trunk/rostests/apitests/gdi32/CombineRgn.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/gdi32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c…
============================================================================== --- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Tue Apr 24 17:11:08 2012 @@ -8,6 +8,7 @@ extern void func_AddFontResource(void); extern void func_AddFontResourceEx(void); extern void func_BeginPath(void); +extern void func_CombineRgn(void); extern void func_CombineTransform(void); extern void func_CreateBitmap(void); extern void func_CreateBitmapIndirect(void); @@ -61,6 +62,7 @@ { "AddFontResource", func_AddFontResource }, { "AddFontResourceEx", func_AddFontResourceEx }, { "BeginPath", func_BeginPath }, + { "CombineRgn", func_CombineRgn }, { "CombineTransform", func_CombineTransform }, { "CreateBitmap", func_CreateBitmap }, { "CreateBitmapIndirect", func_CreateBitmapIndirect },
12 years, 8 months
1
0
0
0
[tkreuzer] 56407: [WIN32K/GDI32] - rewrite GetObject again :) - simplify and fix FontGetObject - remove some pointless code
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Tue Apr 24 14:49:09 2012 New Revision: 56407 URL:
http://svn.reactos.org/svn/reactos?rev=56407&view=rev
Log: [WIN32K/GDI32] - rewrite GetObject again :) - simplify and fix FontGetObject - remove some pointless code Modified: trunk/reactos/win32ss/gdi/gdi32/objects/dc.c trunk/reactos/win32ss/gdi/ntgdi/font.c trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c trunk/reactos/win32ss/gdi/ntgdi/text.h Modified: trunk/reactos/win32ss/gdi/gdi32/objects/dc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
============================================================================== --- trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/gdi32/objects/dc.c [iso-8859-1] Tue Apr 24 14:49:09 2012 @@ -422,7 +422,7 @@ _In_ HDC hdc, _In_ UINT uObjectType) { - PDC_ATTR pdcattr; + PDC_ATTR pdcattr = NULL; /* Check if this is a user mode object */ if ((uObjectType == OBJ_PEN) || @@ -762,86 +762,6 @@ return(MAKELONG(Pt.x, Pt.y)); } -ULONG -WINAPI -GetFontObjectW(HGDIOBJ hfont, ULONG cbSize, LPVOID lpBuffer) -{ - ENUMLOGFONTEXDVW elfedvW; - ULONG cbResult, cbMaxSize; - - /* Check if size only is requested */ - if (!lpBuffer) return sizeof(LOGFONTW); - - /* Check for size 0 */ - if (cbSize == 0) - { - /* Windows does not SetLastError() */ - return 0; - } - - /* Call win32k to get the logfont (widechar) */ - cbResult = NtGdiExtGetObjectW(hfont, sizeof(ENUMLOGFONTEXDVW), &elfedvW); - if (cbResult == 0) - { - return 0; - } - - /* Calculate the maximum size according to number of axes */ - cbMaxSize = FIELD_OFFSET(ENUMLOGFONTEXDVW, - elfDesignVector.dvValues[elfedvW.elfDesignVector.dvNumAxes]); - - /* Don't copy more than the maximum */ - if (cbSize > cbMaxSize) cbSize = cbMaxSize; - if (cbSize > cbResult) cbSize = cbResult; - - /* Copy the number of bytes requested */ - memcpy(lpBuffer, &elfedvW, cbSize); - - /* Return the number of bytes copied */ - return cbSize; -} - -ULONG -WINAPI -GetFontObjectA(HGDIOBJ hfont, ULONG cbSize, LPVOID lpBuffer) -{ - ENUMLOGFONTEXDVW elfedvW; - ENUMLOGFONTEXDVA elfedvA; - ULONG cbResult; - - /* Check if size only is requested */ - if (!lpBuffer) return sizeof(LOGFONTA); - - /* Check for size 0 */ - if (cbSize == 0) - { - /* Windows does not SetLastError() */ - return 0; - } - - /* Windows does this ... */ - if (cbSize == sizeof(LOGFONTW)) cbSize = sizeof(LOGFONTA); - - /* Call win32k to get the logfont (widechar) */ - cbResult = NtGdiExtGetObjectW(hfont, sizeof(ENUMLOGFONTEXDVW), &elfedvW); - if (cbResult == 0) - { - return 0; - } - - /* Convert the logfont from widechar to ansi */ - EnumLogFontExW2A(&elfedvA.elfEnumLogfontEx, &elfedvW.elfEnumLogfontEx); - elfedvA.elfDesignVector = elfedvW.elfDesignVector; - - /* Don't copy more than maximum */ - if (cbSize > sizeof(ENUMLOGFONTEXDVA)) cbSize = sizeof(ENUMLOGFONTEXDVA); - - /* Copy the number of bytes requested */ - memcpy(lpBuffer, &elfedvA, cbSize); - - /* Return the number of bytes copied */ - return cbSize; -} /* * @implemented @@ -853,50 +773,38 @@ DWORD dwType; INT cbResult = 0; + /* Fixup handles with upper 16 bits masked */ hGdiObj = GdiFixUpHandle(hGdiObj); /* Get the object type */ dwType = GDI_HANDLE_GET_TYPE(hGdiObj); /* Check what kind of object we have */ - switch(dwType) + switch (dwType) { case GDI_OBJECT_TYPE_PEN: if (!lpBuffer) return sizeof(LOGPEN); - cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); - if (cbResult == 0) - SetLastError(ERROR_INVALID_PARAMETER); - return cbResult; + break; case GDI_OBJECT_TYPE_BRUSH: - if (!lpBuffer) return sizeof(LOGBRUSH); - cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); - if (cbResult == 0) - SetLastError(ERROR_INVALID_PARAMETER); - return cbResult; + if (!lpBuffer || !cbSize) return sizeof(LOGBRUSH); + break; case GDI_OBJECT_TYPE_BITMAP: if (!lpBuffer) return sizeof(BITMAP); - return NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); + break; case GDI_OBJECT_TYPE_PALETTE: if (!lpBuffer) return sizeof(WORD); - return NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); + break; case GDI_OBJECT_TYPE_FONT: - return GetFontObjectW(hGdiObj, cbSize, lpBuffer); + if (!lpBuffer) return sizeof(LOGFONTW); + break; case GDI_OBJECT_TYPE_EXTPEN: /* we don't know the size, ask win32k */ - cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); - if (cbResult == 0) - { - if (!GdiIsHandleValid(hGdiObj)) - SetLastError(ERROR_INVALID_PARAMETER); - else if (cbSize == 0) - SetLastError(ERROR_NOACCESS); - } - return cbResult; + break; case GDI_OBJECT_TYPE_COLORSPACE: if ((cbSize < 328) || !lpBuffer) @@ -904,10 +812,7 @@ SetLastError(ERROR_INSUFFICIENT_BUFFER); return 0; } - cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); - if (cbResult == 0) - SetLastError(ERROR_INVALID_PARAMETER); - return cbResult; + break; case GDI_OBJECT_TYPE_DC: case GDI_OBJECT_TYPE_REGION: @@ -919,8 +824,82 @@ return 0; } - return 0; -} + /* Call win32k */ + cbResult = NtGdiExtGetObjectW(hGdiObj, cbSize, lpBuffer); + + /* Handle error */ + if (cbResult == 0) + { + if (!GdiIsHandleValid(hGdiObj)) + { + if ((dwType == GDI_OBJECT_TYPE_PEN) || + (dwType == GDI_OBJECT_TYPE_EXTPEN) || + (dwType == GDI_OBJECT_TYPE_BRUSH) || + (dwType == GDI_OBJECT_TYPE_COLORSPACE)) + { + SetLastError(ERROR_INVALID_PARAMETER); + } + } + else + { + if ((dwType == GDI_OBJECT_TYPE_PEN) || + (dwType == GDI_OBJECT_TYPE_BRUSH) || + (dwType == GDI_OBJECT_TYPE_COLORSPACE) || + ( (dwType == GDI_OBJECT_TYPE_EXTPEN) && + ( (cbSize >= sizeof(EXTLOGPEN)) || (cbSize == 0) ) ) || + ( (dwType == GDI_OBJECT_TYPE_BITMAP) && (cbSize >= sizeof(BITMAP)) )) + { + SetLastError(ERROR_NOACCESS); + } + } + } + + return cbResult; +} + + +ULONG +WINAPI +GetFontObjectA(HGDIOBJ hfont, ULONG cbSize, LPVOID lpBuffer) +{ + ENUMLOGFONTEXDVW elfedvW; + ENUMLOGFONTEXDVA elfedvA; + ULONG cbResult; + + /* Check if size only is requested */ + if (!lpBuffer) return sizeof(LOGFONTA); + + /* Check for size 0 */ + if (cbSize == 0) + { + /* Windows does not SetLastError() */ + return 0; + } + + /* Windows does this ... */ + if (cbSize == sizeof(LOGFONTW)) cbSize = sizeof(LOGFONTA); + + /* Call win32k to get the logfont (widechar) */ + cbResult = NtGdiExtGetObjectW(hfont, sizeof(ENUMLOGFONTEXDVW), &elfedvW); + if (cbResult == 0) + { + return 0; + } + + /* Convert the logfont from widechar to ansi */ + EnumLogFontExW2A(&elfedvA.elfEnumLogfontEx, &elfedvW.elfEnumLogfontEx); + elfedvA.elfDesignVector = elfedvW.elfDesignVector; + + /* Don't copy more than maximum */ + if (cbSize > sizeof(ENUMLOGFONTEXDVA)) cbSize = sizeof(ENUMLOGFONTEXDVA); + + /* Copy the number of bytes requested */ + memcpy(lpBuffer, &elfedvA, cbSize); + + /* Return the number of bytes copied */ + return cbSize; +} + /* * @implemented Modified: trunk/reactos/win32ss/gdi/ntgdi/font.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/font.c?r…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/font.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/font.c [iso-8859-1] Tue Apr 24 14:49:09 2012 @@ -260,43 +260,23 @@ } #endif -INT +ULONG FASTCALL -FontGetObject(PTEXTOBJ TFont, INT cjBuffer, PVOID pvBuffer) -{ +FontGetObject(PTEXTOBJ plfont, ULONG cjBuffer, PVOID pvBuffer) +{ + ULONG cjMaxSize; + ENUMLOGFONTEXDVW *plf = &plfont->logfont; + + /* If buffer is NULL, only the size is requested */ if (pvBuffer == NULL) return sizeof(LOGFONTW); - switch (cjBuffer) - { - case sizeof(ENUMLOGFONTEXDVW): - RtlCopyMemory(pvBuffer, - &TFont->logfont, - sizeof(ENUMLOGFONTEXDVW)); - break; - - case sizeof(ENUMLOGFONTEXW): - RtlCopyMemory(pvBuffer, - &TFont->logfont.elfEnumLogfontEx, - sizeof(ENUMLOGFONTEXW)); - break; - - case sizeof(EXTLOGFONTW): - case sizeof(ENUMLOGFONTW): - RtlCopyMemory((LPENUMLOGFONTW) pvBuffer, - &TFont->logfont.elfEnumLogfontEx.elfLogFont, - sizeof(ENUMLOGFONTW)); - break; - - case sizeof(LOGFONTW): - RtlCopyMemory((LPLOGFONTW) pvBuffer, - &TFont->logfont.elfEnumLogfontEx.elfLogFont, - sizeof(LOGFONTW)); - break; - - default: - EngSetLastError(ERROR_BUFFER_OVERFLOW); - return 0; - } + /* Calculate the maximum size according to number of axes */ + cjMaxSize = FIELD_OFFSET(ENUMLOGFONTEXDVW, + elfDesignVector.dvValues[plf->elfDesignVector.dvNumAxes]); + + if (cjBuffer > cjMaxSize) cjBuffer = cjMaxSize; + + RtlCopyMemory(pvBuffer, plf, cjBuffer); return cjBuffer; } Modified: trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] Tue Apr 24 14:49:09 2012 @@ -1038,15 +1038,9 @@ case GDILoObjType_LO_BITMAP_TYPE: iResult = BITMAP_GetObject(pvObj, cbCount, pvBuffer); break; + case GDILoObjType_LO_FONT_TYPE: iResult = FontGetObject(pvObj, cbCount, pvBuffer); -#if 0 - // Fix the LOGFONT structure for the stock fonts - if (FIRST_STOCK_HANDLE <= hobj && hobj <= LAST_STOCK_HANDLE) - { - FixStockFontSizeW(hobj, cbCount, pvBuffer); - } -#endif break; case GDILoObjType_LO_PALETTE_TYPE: @@ -1096,7 +1090,7 @@ /* Enter SEH for buffer transfer */ _SEH2_TRY { - // Probe the buffer and copy it + /* Probe the buffer and copy it */ ProbeForWrite(lpBuffer, cbCopyCount, sizeof(WORD)); RtlCopyMemory(lpBuffer, &object, cbCopyCount); } Modified: trunk/reactos/win32ss/gdi/ntgdi/text.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/text.h?r…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/text.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/text.h [iso-8859-1] Tue Apr 24 14:49:09 2012 @@ -88,7 +88,7 @@ BOOL FASTCALL IntIsFontRenderingEnabled(VOID); BOOL FASTCALL IntIsFontRenderingEnabled(VOID); VOID FASTCALL IntEnableFontRendering(BOOL Enable); -INT FASTCALL FontGetObject(PTEXTOBJ TextObj, INT Count, PVOID Buffer); +ULONG FASTCALL FontGetObject(PTEXTOBJ TextObj, ULONG Count, PVOID Buffer); VOID FASTCALL IntLoadSystemFonts(VOID); INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics); ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL);
12 years, 8 months
1
0
0
0
[cgutman] 56406: [USBSTOR] - Add forgotten storage of the LUN in the PDO extension which not only broke units beyond LUN 0 but also caused a BSOD due to reporting duplicate devices to the PnP manag...
by cgutman@svn.reactos.org
Author: cgutman Date: Tue Apr 24 14:47:15 2012 New Revision: 56406 URL:
http://svn.reactos.org/svn/reactos?rev=56406&view=rev
Log: [USBSTOR] - Add forgotten storage of the LUN in the PDO extension which not only broke units beyond LUN 0 but also caused a BSOD due to reporting duplicate devices to the PnP manager - Thanks to tower for reporting Modified: trunk/reactos/drivers/usb/usbstor/fdo.c trunk/reactos/drivers/usb/usbstor/pdo.c trunk/reactos/drivers/usb/usbstor/usbstor.h Modified: trunk/reactos/drivers/usb/usbstor/fdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbstor/fdo.c?…
============================================================================== --- trunk/reactos/drivers/usb/usbstor/fdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbstor/fdo.c [iso-8859-1] Tue Apr 24 14:47:15 2012 @@ -264,7 +264,7 @@ // // create pdo // - Status = USBSTOR_CreatePDO(DeviceObject, &DeviceExtension->ChildPDO[Index]); + Status = USBSTOR_CreatePDO(DeviceObject, Index, &DeviceExtension->ChildPDO[Index]); // // check for failure Modified: trunk/reactos/drivers/usb/usbstor/pdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbstor/pdo.c?…
============================================================================== --- trunk/reactos/drivers/usb/usbstor/pdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbstor/pdo.c [iso-8859-1] Tue Apr 24 14:47:15 2012 @@ -1256,6 +1256,7 @@ NTSTATUS USBSTOR_CreatePDO( IN PDEVICE_OBJECT DeviceObject, + IN UCHAR LUN, OUT PDEVICE_OBJECT *ChildDeviceObject) { PDEVICE_OBJECT PDO; @@ -1293,6 +1294,7 @@ PDODeviceExtension->LowerDeviceObject = DeviceObject; PDODeviceExtension->PDODeviceObject = ChildDeviceObject; PDODeviceExtension->Self = PDO; + PDODeviceExtension->LUN = LUN; // // set device flags Modified: trunk/reactos/drivers/usb/usbstor/usbstor.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbstor/usbsto…
============================================================================== --- trunk/reactos/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbstor/usbstor.h [iso-8859-1] Tue Apr 24 14:47:15 2012 @@ -364,6 +364,7 @@ NTSTATUS USBSTOR_CreatePDO( IN PDEVICE_OBJECT DeviceObject, + IN UCHAR LUN, OUT PDEVICE_OBJECT *ChildDeviceObject); //---------------------------------------------------------------------
12 years, 8 months
1
0
0
0
[tkreuzer] 56405: [GDI32_APITEST] - Add more tests for GetObject
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Tue Apr 24 14:45:12 2012 New Revision: 56405 URL:
http://svn.reactos.org/svn/reactos?rev=56405&view=rev
Log: [GDI32_APITEST] - Add more tests for GetObject Modified: trunk/rostests/apitests/gdi32/GetObject.c Modified: trunk/rostests/apitests/gdi32/GetObject.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetObject.…
============================================================================== --- trunk/rostests/apitests/gdi32/GetObject.c [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/GetObject.c [iso-8859-1] Tue Apr 24 14:45:12 2012 @@ -18,7 +18,7 @@ struct { LOGBRUSH logbrush; - BYTE additional[5]; + BYTE additional[600]; } TestStruct; PLOGBRUSH plogbrush; HBRUSH hBrush; @@ -28,11 +28,12 @@ SetLastError(ERROR_SUCCESS); ok(GetObjectA(0, 0, NULL) == 0, "\n"); ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n"); + + /* Test invalid habdles of different types */ ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n"); ok(GetLastError() == ERROR_SUCCESS, "\n"); ok(GetObjectA((HANDLE)0x00380000, 10, &TestStruct) == 0, "\n"); ok(GetLastError() == ERROR_SUCCESS, "\n"); - SetLastError(ERROR_SUCCESS); ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n"); ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); @@ -84,7 +85,6 @@ SetLastError(ERROR_SUCCESS); ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n"); ok(GetLastError() == ERROR_SUCCESS, "\n"); - SetLastError(ERROR_SUCCESS); ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n"); ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); @@ -126,10 +126,19 @@ plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1); //ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); // fails on win7 - /* Test invalid buffer */ - SetLastError(ERROR_SUCCESS); - ok(GetObjectA(hBrush, sizeof(LOGBRUSH), (PVOID)0xc0000000) == 0, "\n"); + /* Test invalid buffer */ + SetLastError(ERROR_SUCCESS); + ok(GetObjectA(GetStockObject(WHITE_BRUSH), sizeof(LOGBRUSH), (PVOID)0xc0000000) == 0, "\n"); ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %ld\n", GetLastError()); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(GetStockObject(BLACK_PEN), sizeof(LOGPEN), (PVOID)0xc0000000) == 0, "\n"); + ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %ld\n", GetLastError()); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(GetStockObject(21), sizeof(BITMAP), (PVOID)0xc0000000) == 0, "\n"); + ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %ld\n", GetLastError()); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); SetLastError(ERROR_SUCCESS); _SEH2_TRY { @@ -140,13 +149,25 @@ ret = -1; } _SEH2_END - ok(ret == -1, "should have got an exception\n"); - SetLastError(ERROR_SUCCESS); - ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), (PVOID)0xc0000000) == 0, "\n"); + ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0x50000000, &TestStruct) == 356, "\n"); + ok(GetObjectW(GetStockObject(WHITE_BRUSH), 0x50000000, &TestStruct) == sizeof(LOGBRUSH), "\n"); + + + /* Test buffer size of 0 */ + SetLastError(ERROR_SUCCESS); + ok(GetObjectA(GetStockObject(WHITE_BRUSH), 0, &TestStruct) == sizeof(LOGBRUSH), "\n"); ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); - + SetLastError(ERROR_SUCCESS); + ok(GetObjectA(GetStockObject(BLACK_PEN), 0, &TestStruct) == 0, "\n"); + ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %ld\n", GetLastError()); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0, &TestStruct) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); } @@ -446,6 +467,7 @@ ENUMLOGFONTW enumlogfontw; BYTE bData[270]; } u; + int ret; FillMemory(&u, sizeof(u), 0x77); hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, @@ -531,13 +553,15 @@ ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348 ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419 + ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 + ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD); + ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw); + ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); + ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356! - - ok(GetObjectW(hFont, 356, &u.bData) == 356, "\n"); - ok(GetObjectW(hFont, 357, &u.bData) == 356, "\n"); ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError()); DeleteObject(hFont);
12 years, 8 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
16
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results per page:
10
25
50
100
200