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
September 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
17 participants
236 discussions
Start a n
N
ew thread
[hbelusca] 57407: [KERNEL32] - Reworking the Find* APIs in kernel32. Fixes some kernel32_winetest:file failures. - The FindExInfoBasic information level for FindFirstFileEx, is also implemented. - ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 27 22:07:06 2012 New Revision: 57407 URL:
http://svn.reactos.org/svn/reactos?rev=57407&view=rev
Log: [KERNEL32] - Reworking the Find* APIs in kernel32. Fixes some kernel32_winetest:file failures. - The FindExInfoBasic information level for FindFirstFileEx, is also implemented. - Update ndk and psdk headers regarding to this work. CORE-6623 #comment Committed in rev.57407. #resolve Modified: trunk/reactos/dll/win32/kernel32/client/file/find.c trunk/reactos/include/ndk/iotypes.h trunk/reactos/include/psdk/winbase.h Modified: trunk/reactos/dll/win32/kernel32/client/file/find.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
============================================================================== --- trunk/reactos/dll/win32/kernel32/client/file/find.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/file/find.c [iso-8859-1] Thu Sep 27 22:07:06 2012 @@ -1,452 +1,256 @@ -/* $Id: find.c 53068 2011-08-04 22:18:01Z ion $ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/kernel32/file/find.c + * FILE: dll/win32/kernel32/client/file/find.c * PURPOSE: Find functions - * PROGRAMMER: Ariadne ( ariadne(a)xs4all.nl) + * PROGRAMMERS: Ariadne (ariadne(a)xs4all.nl) * Pierre Schweitzer (pierre.schweitzer(a)reactos.org) - * UPDATE HISTORY: - * Created 01/11/98 + * Hermes BELUSCA - MAITO (hermes.belusca(a)sfr.fr) */ -/* INCLUDES *****************************************************************/ +/* INCLUDES *******************************************************************/ #include <k32.h> #define NDEBUG #include <debug.h> DEBUG_CHANNEL(kernel32file); -/* TYPES ********************************************************************/ - -#define FIND_DATA_SIZE 0x4000 - -#define FIND_DEVICE_HANDLE ((HANDLE)0x1) - -typedef struct _KERNEL32_FIND_FILE_DATA -{ - HANDLE DirectoryHandle; - RTL_CRITICAL_SECTION Lock; - PFILE_BOTH_DIR_INFORMATION pFileInfo; - BOOLEAN DirectoryOnly; - BOOLEAN HasMoreData; - BOOLEAN HasData; - BOOLEAN LockInitialized; -} KERNEL32_FIND_FILE_DATA, *PKERNEL32_FIND_FILE_DATA; - -typedef struct _KERNEL32_FIND_STREAM_DATA + +/* TYPES **********************************************************************/ + +#define FIND_DATA_SIZE 0x4000 +#define FIND_DEVICE_HANDLE ((HANDLE)0x1) + +typedef enum _FIND_DATA_TYPE +{ + FindFile = 1, + FindStream = 2 +} FIND_DATA_TYPE; + +/* + * FILE_FULL_DIR_INFORMATION and FILE_BOTH_DIR_INFORMATION structures layout. + * + * + * struct FILE_FULL_DIR_INFORMATION | struct FILE_BOTH_DIR_INFORMATION + * ------------------------------------+--------------------------------------- + * ULONG NextEntryOffset; | ULONG NextEntryOffset; + * ULONG FileIndex; | ULONG FileIndex; + * LARGE_INTEGER CreationTime; | LARGE_INTEGER CreationTime; + * LARGE_INTEGER LastAccessTime; | LARGE_INTEGER LastAccessTime; + * LARGE_INTEGER LastWriteTime; | LARGE_INTEGER LastWriteTime; + * LARGE_INTEGER ChangeTime; | LARGE_INTEGER ChangeTime; + * LARGE_INTEGER EndOfFile; | LARGE_INTEGER EndOfFile; + * LARGE_INTEGER AllocationSize; | LARGE_INTEGER AllocationSize; + * ULONG FileAttributes; | ULONG FileAttributes; + * ULONG FileNameLength; | ULONG FileNameLength; + * ULONG EaSize; | ULONG EaSize; + * ------------------------------------+--------------------------------------- + * WCHAR FileName[1]; | CCHAR ShortNameLength; + * | WCHAR ShortName[12]; + * | WCHAR FileName[1]; + * + * Therefore we can use pointers to FILE_FULL_DIR_INFORMATION when one doesn't + * want to refer to the ShortName* fields and FileName (useful for implementing + * the FindExInfoBasic functionality for FindFirstFileEx), however a cast to + * FILE_BOTH_DIR_INFORMATION is required when one wants to use FileName and + * ShortName* fields (needed for the FindExInfoStandard functionality). + * + */ +typedef union _DIR_INFORMATION +{ + PVOID DirInfo; + PFILE_FULL_DIR_INFORMATION FullDirInfo; + PFILE_BOTH_DIR_INFORMATION BothDirInfo; +} DIR_INFORMATION; + +typedef struct _FIND_FILE_DATA +{ + HANDLE Handle; + FINDEX_INFO_LEVELS InfoLevel; + FINDEX_SEARCH_OPS SearchOp; + + /* + * For handling STATUS_BUFFER_OVERFLOW errors emitted by + * NtQueryDirectoryFile in the FildNextFile function. + */ + BOOLEAN HasMoreData; + + /* + * "Pointer" to the next file info structure in the buffer. + * The type is defined by the 'InfoLevel' parameter. + */ + DIR_INFORMATION NextDirInfo; + + BYTE Buffer[FIND_DATA_SIZE]; +} FIND_FILE_DATA, *PFIND_FILE_DATA; + +typedef struct _FIND_STREAM_DATA { STREAM_INFO_LEVELS InfoLevel; - PFILE_STREAM_INFORMATION pFileStreamInfo; - PFILE_STREAM_INFORMATION pCurrent; -} KERNEL32_FIND_STREAM_DATA, *PKERNEL32_FIND_STREAM_DATA; - -typedef enum _KERNEL32_FIND_DATA_TYPE -{ - FileFind, - StreamFind -} KERNEL32_FIND_DATA_TYPE; - -typedef struct _KERNEL32_FIND_DATA_HEADER -{ - KERNEL32_FIND_DATA_TYPE Type; -} KERNEL32_FIND_DATA_HEADER, *PKERNEL32_FIND_DATA_HEADER; - - -/* FUNCTIONS ****************************************************************/ + PFILE_STREAM_INFORMATION FileStreamInfo; + PFILE_STREAM_INFORMATION CurrentInfo; +} FIND_STREAM_DATA, *PFIND_STREAM_DATA; + +typedef struct _FIND_DATA_HANDLE +{ + FIND_DATA_TYPE Type; + RTL_CRITICAL_SECTION Lock; + + /* + * Pointer to the following finding data, located at + * (this + 1). The type is defined by the 'Type' parameter. + */ + union + { + PFIND_FILE_DATA FindFileData; + PFIND_STREAM_DATA FindStreamData; + } u; + +} FIND_DATA_HANDLE, *PFIND_DATA_HANDLE; + + +/* PRIVATE FUNCTIONS **********************************************************/ static VOID -InternalCopyDeviceFindDataW(LPWIN32_FIND_DATAW lpFindFileData, - LPCWSTR lpFileName, - ULONG DeviceNameInfo) +CopyDeviceFindData(OUT LPWIN32_FIND_DATAW lpFindFileData, + IN LPCWSTR lpFileName, + IN ULONG DeviceNameInfo) { UNICODE_STRING DeviceName; - DeviceName.Length = DeviceName.MaximumLength = (USHORT)(DeviceNameInfo & 0xFFFF); - DeviceName.Buffer = (LPWSTR)((ULONG_PTR)lpFileName + (DeviceNameInfo >> 16)); - - /* Return the data */ - RtlZeroMemory(lpFindFileData, - sizeof(*lpFindFileData)); - lpFindFileData->dwFileAttributes = FILE_ATTRIBUTE_ARCHIVE; - RtlCopyMemory(lpFindFileData->cFileName, - DeviceName.Buffer, - DeviceName.Length); + _SEH2_TRY + { + /* DeviceNameInfo == { USHORT Offset; USHORT Length } */ + DeviceName.Length = DeviceName.MaximumLength = (USHORT)(DeviceNameInfo & 0xFFFF); + DeviceName.Buffer = (LPWSTR)((ULONG_PTR)lpFileName + ((DeviceNameInfo >> 16) & 0xFFFF)); + + /* Return the data */ + RtlZeroMemory(lpFindFileData, sizeof(*lpFindFileData)); + lpFindFileData->dwFileAttributes = FILE_ATTRIBUTE_ARCHIVE; + RtlCopyMemory(lpFindFileData->cFileName, + DeviceName.Buffer, + DeviceName.Length); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END; + + return; } static VOID -InternalCopyFindDataW(LPWIN32_FIND_DATAW lpFindFileData, - PFILE_BOTH_DIR_INFORMATION lpFileInfo) -{ - lpFindFileData->dwFileAttributes = lpFileInfo->FileAttributes; - - lpFindFileData->ftCreationTime.dwHighDateTime = lpFileInfo->CreationTime.u.HighPart; - lpFindFileData->ftCreationTime.dwLowDateTime = lpFileInfo->CreationTime.u.LowPart; - - lpFindFileData->ftLastAccessTime.dwHighDateTime = lpFileInfo->LastAccessTime.u.HighPart; - lpFindFileData->ftLastAccessTime.dwLowDateTime = lpFileInfo->LastAccessTime.u.LowPart; - - lpFindFileData->ftLastWriteTime.dwHighDateTime = lpFileInfo->LastWriteTime.u.HighPart; - lpFindFileData->ftLastWriteTime.dwLowDateTime = lpFileInfo->LastWriteTime.u.LowPart; - - lpFindFileData->nFileSizeHigh = lpFileInfo->EndOfFile.u.HighPart; - lpFindFileData->nFileSizeLow = lpFileInfo->EndOfFile.u.LowPart; - - memcpy (lpFindFileData->cFileName, lpFileInfo->FileName, lpFileInfo->FileNameLength); - lpFindFileData->cFileName[lpFileInfo->FileNameLength / sizeof(WCHAR)] = 0; - - memcpy (lpFindFileData->cAlternateFileName, lpFileInfo->ShortName, lpFileInfo->ShortNameLength); - lpFindFileData->cAlternateFileName[lpFileInfo->ShortNameLength / sizeof(WCHAR)] = 0; -} - - -/* - * @implemented - */ -BOOL -WINAPI -InternalFindNextFile ( - HANDLE hFindFile, - PUNICODE_STRING SearchPattern, - PVOID lpFindFileData - ) -{ - PKERNEL32_FIND_DATA_HEADER IHeader; - PKERNEL32_FIND_FILE_DATA IData; - IO_STATUS_BLOCK IoStatusBlock; - BOOLEAN Locked = FALSE; - PFILE_BOTH_DIR_INFORMATION Buffer, FoundFile = NULL; - NTSTATUS Status = STATUS_SUCCESS; - - TRACE("InternalFindNextFile(%lx, %wZ)\n", hFindFile, SearchPattern); - - if (hFindFile != FIND_DEVICE_HANDLE) - { - IHeader = (PKERNEL32_FIND_DATA_HEADER)hFindFile; - if (hFindFile == NULL || hFindFile == INVALID_HANDLE_VALUE || - IHeader->Type != FileFind) - { - SetLastError (ERROR_INVALID_HANDLE); - return FALSE; - } - - IData = (PKERNEL32_FIND_FILE_DATA)(IHeader + 1); - Buffer = (PFILE_BOTH_DIR_INFORMATION)((ULONG_PTR)IData + sizeof(KERNEL32_FIND_FILE_DATA)); - - if (SearchPattern == NULL) - { - RtlEnterCriticalSection(&IData->Lock); - Locked = TRUE; - } - - do - { - if (IData->HasData) - { - if (!IData->DirectoryOnly || (IData->pFileInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - FoundFile = IData->pFileInfo; - } - - if (IData->pFileInfo->NextEntryOffset != 0) - { - ULONG_PTR BufferEnd; - - IData->pFileInfo = (PFILE_BOTH_DIR_INFORMATION)((ULONG_PTR)IData->pFileInfo + IData->pFileInfo->NextEntryOffset); - - /* Be paranoid and make sure that the next entry is completely there */ - BufferEnd = (ULONG_PTR)Buffer + FIND_DATA_SIZE; - if (BufferEnd < (ULONG_PTR)IData->pFileInfo || - BufferEnd < (ULONG_PTR)&IData->pFileInfo->FileNameLength + sizeof(IData->pFileInfo->FileNameLength) || - BufferEnd <= (ULONG_PTR)&IData->pFileInfo->FileName[IData->pFileInfo->FileNameLength]) - { - goto NeedMoreData; - } - } - else - { -NeedMoreData: - IData->HasData = FALSE; - - if (!IData->HasMoreData) - break; - } - } - else - { - IData->pFileInfo = Buffer; - IData->pFileInfo->NextEntryOffset = 0; - Status = NtQueryDirectoryFile (IData->DirectoryHandle, - NULL, - NULL, - NULL, - &IoStatusBlock, - (PVOID)IData->pFileInfo, - FIND_DATA_SIZE, - FileBothDirectoryInformation, - FALSE, - SearchPattern, - SearchPattern != NULL); - - if (Status == STATUS_BUFFER_OVERFLOW) - { - IData->HasMoreData = TRUE; - Status = STATUS_SUCCESS; - } - else - { - if (!NT_SUCCESS(Status)) - break; - - IData->HasMoreData = FALSE; - } - - IData->HasData = TRUE; - SearchPattern = NULL; - } - - } while (FoundFile == NULL); - - if (FoundFile != NULL) - { - _SEH2_TRY - { - InternalCopyFindDataW(lpFindFileData, - FoundFile); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - } - _SEH2_END; - } - - if (Locked) - RtlLeaveCriticalSection(&IData->Lock); - } - - if (!NT_SUCCESS(Status)) - { - BaseSetLastNTError (Status); - return FALSE; - } - else if (FoundFile == NULL) - { - SetLastError (ERROR_NO_MORE_FILES); - return FALSE; - } - - return TRUE; -} - - -/* - * @implemented - */ -HANDLE -WINAPI -InternalFindFirstFile ( - LPCWSTR lpFileName, - BOOLEAN DirectoryOnly, - PVOID lpFindFileData - ) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - PKERNEL32_FIND_DATA_HEADER IHeader; - PKERNEL32_FIND_FILE_DATA IData; - IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING NtPathU, FileName, PathFileName; - NTSTATUS Status; - PWSTR NtPathBuffer; - BOOLEAN RemovedLastChar = FALSE; - BOOL bResult; - RTL_RELATIVE_NAME_U DirInfo; - ULONG DeviceNameInfo; - HANDLE hDirectory = NULL; - - TRACE("FindFirstFileW(lpFileName %S)\n", - lpFileName); - - RtlZeroMemory(&PathFileName, - sizeof(PathFileName)); - RtlInitUnicodeString(&FileName, - lpFileName); - - bResult = RtlDosPathNameToNtPathName_U (lpFileName, - &NtPathU, - (PCWSTR *)((ULONG_PTR)&PathFileName.Buffer), - &DirInfo); - if (FALSE == bResult) - { - SetLastError(ERROR_PATH_NOT_FOUND); - return INVALID_HANDLE_VALUE; - } - - /* Save the buffer pointer for later, we need to free it! */ - NtPathBuffer = NtPathU.Buffer; - - /* If there is a file name/pattern then determine it's length */ - if (PathFileName.Buffer != NULL) - { - PathFileName.Length = NtPathU.Length - - (USHORT)((ULONG_PTR)PathFileName.Buffer - (ULONG_PTR)NtPathU.Buffer); - } - PathFileName.MaximumLength = PathFileName.Length; - - if (DirInfo.RelativeName.Length != 0 && DirInfo.RelativeName.Buffer != PathFileName.Buffer) - { - if (PathFileName.Buffer != NULL) - { - /* This is a relative path to DirInfo.ContainingDirectory, adjust NtPathU! */ - NtPathU.Length = NtPathU.MaximumLength = - (USHORT)((ULONG_PTR)PathFileName.Buffer - (ULONG_PTR)DirInfo.RelativeName.Buffer); - NtPathU.Buffer = DirInfo.RelativeName.Buffer; - } - } - else - { - /* This is an absolute path, NtPathU receives the full path */ - DirInfo.ContainingDirectory = NULL; - if (PathFileName.Buffer != NULL) - { - NtPathU.Length = NtPathU.MaximumLength = - (USHORT)((ULONG_PTR)PathFileName.Buffer - (ULONG_PTR)NtPathU.Buffer); - } - } - - /* Remove the last character of the path (Unless the path is a drive and - ends with ":\"). If the caller however supplies a path to a device, such - as "C:\NUL" then the last character gets cut off, which later results in - NtOpenFile to return STATUS_OBJECT_NAME_NOT_FOUND, which in turn triggers - a fake DOS device check with RtlIsDosDeviceName_U. However, if there is a - real device with a name eg. "NU" in the system, FindFirstFile will succeed, - rendering the fake DOS device check useless... Why would they invent such a - stupid and broken behavior?! */ - if (NtPathU.Length >= 2 * sizeof(WCHAR) && - NtPathU.Buffer[(NtPathU.Length / sizeof(WCHAR)) - 1] != L'\\' && - NtPathU.Buffer[(NtPathU.Length / sizeof(WCHAR)) - 2] != L':') - { - NtPathU.Length -= sizeof(WCHAR); - RemovedLastChar = TRUE; - } - - TRACE("lpFileName: \"%ws\"\n", lpFileName); - TRACE("NtPathU: \"%wZ\"\n", &NtPathU); - TRACE("PathFileName: \"%wZ\"\n", &PathFileName); - TRACE("RelativeTo: 0x%p\n", DirInfo.ContainingDirectory); - - InitializeObjectAttributes (&ObjectAttributes, - &NtPathU, - OBJ_CASE_INSENSITIVE, - DirInfo.ContainingDirectory, - NULL); - - Status = NtOpenFile (&hDirectory, - FILE_LIST_DIRECTORY | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT); - - if (Status == STATUS_NOT_A_DIRECTORY && RemovedLastChar) - { - /* Try again, this time with the last character ... */ - NtPathU.Length += sizeof(WCHAR); - - Status = NtOpenFile (&hDirectory, - FILE_LIST_DIRECTORY | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT); - - NtPathU.Length += sizeof(WCHAR); - } - - if (!NT_SUCCESS(Status)) - { - RtlFreeHeap (RtlGetProcessHeap(), - 0, - NtPathBuffer); - - /* See if the application tries to look for a DOS device */ - DeviceNameInfo = RtlIsDosDeviceName_U((PWSTR)((ULONG_PTR)lpFileName)); - if (DeviceNameInfo != 0) - { - InternalCopyDeviceFindDataW(lpFindFileData, - lpFileName, - DeviceNameInfo); - - return FIND_DEVICE_HANDLE; - } - - BaseSetLastNTError (Status); - return INVALID_HANDLE_VALUE; - } - - if (PathFileName.Length == 0) - { - /* No file part?! */ - NtClose(hDirectory); - RtlFreeHeap (RtlGetProcessHeap(), - 0, - NtPathBuffer); - SetLastError(ERROR_FILE_NOT_FOUND); - return INVALID_HANDLE_VALUE; - } - - IHeader = RtlAllocateHeap (RtlGetProcessHeap(), - HEAP_ZERO_MEMORY, - sizeof(KERNEL32_FIND_DATA_HEADER) + - sizeof(KERNEL32_FIND_FILE_DATA) + FIND_DATA_SIZE); - if (NULL == IHeader) - { - RtlFreeHeap (RtlGetProcessHeap(), - 0, - NtPathBuffer); - NtClose(hDirectory); - - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return INVALID_HANDLE_VALUE; - } - - IHeader->Type = FileFind; - IData = (PKERNEL32_FIND_FILE_DATA)(IHeader + 1); - IData->DirectoryHandle = hDirectory; - IData->HasMoreData = TRUE; - - /* change pattern: "*.*" --> "*" */ - if (PathFileName.Length == 6 && - RtlCompareMemory(PathFileName.Buffer, - L"*.*", - 6) == 6) - { - PathFileName.Length = 2; - } - - IData->pFileInfo = (PVOID)((ULONG_PTR)IData + sizeof(KERNEL32_FIND_FILE_DATA)); - IData->pFileInfo->FileIndex = 0; - IData->DirectoryOnly = DirectoryOnly; - - bResult = InternalFindNextFile((HANDLE)IHeader, - &PathFileName, - lpFindFileData); - - RtlFreeHeap (RtlGetProcessHeap(), - 0, - NtPathBuffer); - - if (!bResult) - { - FindClose((HANDLE)IHeader); - return INVALID_HANDLE_VALUE; - } - - RtlInitializeCriticalSection(&IData->Lock); - IData->LockInitialized = TRUE; - - return (HANDLE)IHeader; -} - +CopyFindData(OUT LPWIN32_FIND_DATAW lpFindFileData, + IN FINDEX_INFO_LEVELS fInfoLevelId, + IN DIR_INFORMATION DirInfo) +{ +#define ULARGE_INTEGER_2_FILETIME(ft, ul) \ +do { \ + (ft).dwHighDateTime = (ul).u.HighPart; \ + (ft).dwLowDateTime = (ul).u.LowPart ; \ +} while(0) + + _SEH2_TRY + { + RtlZeroMemory(lpFindFileData, sizeof(*lpFindFileData)); + + lpFindFileData->dwFileAttributes = DirInfo.FullDirInfo->FileAttributes; + + ULARGE_INTEGER_2_FILETIME(lpFindFileData->ftCreationTime, DirInfo.FullDirInfo->CreationTime); + ULARGE_INTEGER_2_FILETIME(lpFindFileData->ftLastAccessTime, DirInfo.FullDirInfo->LastAccessTime); + ULARGE_INTEGER_2_FILETIME(lpFindFileData->ftLastWriteTime, DirInfo.FullDirInfo->LastWriteTime); + + lpFindFileData->nFileSizeHigh = DirInfo.FullDirInfo->EndOfFile.u.HighPart; + lpFindFileData->nFileSizeLow = DirInfo.FullDirInfo->EndOfFile.u.LowPart; + + /* dwReserved0 contains the NTFS reparse point tag, if any. */ + if (DirInfo.FullDirInfo->FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) + lpFindFileData->dwReserved0 = DirInfo.FullDirInfo->EaSize; + else + lpFindFileData->dwReserved0 = 0; + + /* Unused dwReserved1 field */ + lpFindFileData->dwReserved1 = 0; + + if (fInfoLevelId == FindExInfoStandard) + { + RtlCopyMemory(lpFindFileData->cFileName, + DirInfo.BothDirInfo->FileName, + DirInfo.BothDirInfo->FileNameLength); + lpFindFileData->cFileName[DirInfo.BothDirInfo->FileNameLength / sizeof(WCHAR)] = UNICODE_NULL; + + RtlCopyMemory(lpFindFileData->cAlternateFileName, + DirInfo.BothDirInfo->ShortName, + DirInfo.BothDirInfo->ShortNameLength); + lpFindFileData->cAlternateFileName[DirInfo.BothDirInfo->ShortNameLength / sizeof(WCHAR)] = UNICODE_NULL; + } + else if (fInfoLevelId == FindExInfoBasic) + { + RtlCopyMemory(lpFindFileData->cFileName, + DirInfo.FullDirInfo->FileName, + DirInfo.FullDirInfo->FileNameLength); + lpFindFileData->cFileName[DirInfo.FullDirInfo->FileNameLength / sizeof(WCHAR)] = UNICODE_NULL; + + lpFindFileData->cAlternateFileName[0] = UNICODE_NULL; + } + else + { + /* Invalid InfoLevelId */ + ASSERT(FALSE); + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END; + + return; +} + +static VOID +CopyStreamData(IN OUT PFIND_STREAM_DATA FindStreamData, + OUT PWIN32_FIND_STREAM_DATA lpFindStreamData) +{ + _SEH2_TRY + { + ASSERT(FindStreamData->CurrentInfo); + + switch (FindStreamData->InfoLevel) + { + case FindStreamInfoStandard: + { + ULONG StreamNameLen = min(FindStreamData->CurrentInfo->StreamNameLength, + sizeof(lpFindStreamData->cStreamName) - sizeof(WCHAR)); + + RtlZeroMemory(lpFindStreamData, sizeof(*lpFindStreamData)); + + lpFindStreamData->StreamSize.QuadPart = FindStreamData->CurrentInfo->StreamSize.QuadPart; + RtlCopyMemory(lpFindStreamData->cStreamName, + FindStreamData->CurrentInfo->StreamName, + StreamNameLen); + lpFindStreamData->cStreamName[StreamNameLen / sizeof(WCHAR)] = UNICODE_NULL; + + break; + } + + default: + { + /* Invalid InfoLevel */ + ASSERT(FALSE); + break; + } + } + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + } + _SEH2_END; + + return; +} + + +/* PUBLIC FUNCTIONS ***********************************************************/ /* * @implemented @@ -464,27 +268,23 @@ WIN32_FIND_DATAW FindFileDataW; lpFileNameW = Basep8BitStringToStaticUnicodeString(lpFileName); - if (!lpFileNameW) - { - return INVALID_HANDLE_VALUE; - } + if (!lpFileNameW) return INVALID_HANDLE_VALUE; hSearch = FindFirstFileExW(lpFileNameW->Buffer, FindExInfoStandard, &FindFileDataW, FindExSearchNameMatch, NULL, 0); - if (hSearch == INVALID_HANDLE_VALUE) - { - return INVALID_HANDLE_VALUE; - } - - memcpy(lpFindFileData, &FindFileDataW, FIELD_OFFSET(WIN32_FIND_DATA, cFileName)); + if (hSearch == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE; + + RtlCopyMemory(lpFindFileData, + &FindFileDataW, + FIELD_OFFSET(WIN32_FIND_DATAA, cFileName)); RtlInitUnicodeString(&UTF8, FindFileDataW.cFileName); Ansi.Buffer = lpFindFileData->cFileName; Ansi.Length = 0; - Ansi.MaximumLength = MAX_PATH; + Ansi.MaximumLength = sizeof(lpFindFileData->cFileName); Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); if (!NT_SUCCESS(Status)) { @@ -496,7 +296,7 @@ RtlInitUnicodeString(&UTF8, FindFileDataW.cAlternateFileName); Ansi.Buffer = lpFindFileData->cAlternateFileName; Ansi.Length = 0; - Ansi.MaximumLength = 14; + Ansi.MaximumLength = sizeof(lpFindFileData->cAlternateFileName); Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); if (!NT_SUCCESS(Status)) { @@ -506,6 +306,22 @@ } return hSearch; +} + + +/* + * @implemented + */ +HANDLE +WINAPI +FindFirstFileW(IN LPCWSTR lpFileName, + OUT LPWIN32_FIND_DATAW lpFindFileData) +{ + return FindFirstFileExW(lpFileName, + FindExInfoStandard, + lpFindFileData, + FindExSearchNameMatch, + NULL, 0); } @@ -523,16 +339,16 @@ WIN32_FIND_DATAW FindFileDataW; if (!FindNextFileW(hFindFile, &FindFileDataW)) - { return FALSE; - } - - memcpy(lpFindFileData, &FindFileDataW, FIELD_OFFSET(WIN32_FIND_DATA, cFileName)); + + RtlCopyMemory(lpFindFileData, + &FindFileDataW, + FIELD_OFFSET(WIN32_FIND_DATAA, cFileName)); RtlInitUnicodeString(&UTF8, FindFileDataW.cFileName); Ansi.Buffer = lpFindFileData->cFileName; Ansi.Length = 0; - Ansi.MaximumLength = MAX_PATH; + Ansi.MaximumLength = sizeof(lpFindFileData->cFileName); Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); if (!NT_SUCCESS(Status)) { @@ -543,7 +359,7 @@ RtlInitUnicodeString(&UTF8, FindFileDataW.cAlternateFileName); Ansi.Buffer = lpFindFileData->cAlternateFileName; Ansi.Length = 0; - Ansi.MaximumLength = 14; + Ansi.MaximumLength = sizeof(lpFindFileData->cAlternateFileName); Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); if (!NT_SUCCESS(Status)) { @@ -554,79 +370,6 @@ return TRUE; } - -/* - * @implemented - */ -BOOL -WINAPI -FindClose ( - HANDLE hFindFile - ) -{ - PKERNEL32_FIND_DATA_HEADER IHeader; - - TRACE("FindClose(hFindFile %x)\n",hFindFile); - - if (hFindFile == FIND_DEVICE_HANDLE) - return TRUE; - - if (!hFindFile || hFindFile == INVALID_HANDLE_VALUE) - { - SetLastError (ERROR_INVALID_HANDLE); - return FALSE; - } - - IHeader = (PKERNEL32_FIND_DATA_HEADER)hFindFile; - - switch (IHeader->Type) - { - case FileFind: - { - PKERNEL32_FIND_FILE_DATA IData = (PKERNEL32_FIND_FILE_DATA)(IHeader + 1); - CloseHandle (IData->DirectoryHandle); - if (IData->LockInitialized) - RtlDeleteCriticalSection(&IData->Lock); - IData->LockInitialized = FALSE; - break; - } - - case StreamFind: - { - PKERNEL32_FIND_STREAM_DATA IData = (PKERNEL32_FIND_STREAM_DATA)(IHeader + 1); - if (IData->pFileStreamInfo != NULL) - { - RtlFreeHeap (RtlGetProcessHeap(), 0, IData->pFileStreamInfo); - } - break; - } - - default: - SetLastError (ERROR_INVALID_HANDLE); - return FALSE; - } - - RtlFreeHeap (RtlGetProcessHeap(), 0, IHeader); - - return TRUE; -} - - -/* - * @implemented - */ -HANDLE -WINAPI -FindFirstFileW(IN LPCWSTR lpFileName, - OUT LPWIN32_FIND_DATAW lpFindFileData) -{ - return FindFirstFileExW(lpFileName, - FindExInfoStandard, - lpFindFileData, - FindExSearchNameMatch, - NULL, - 0); -} /* * @implemented @@ -636,9 +379,261 @@ FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData) { - return InternalFindNextFile(hFindFile, - NULL, - lpFindFileData); + NTSTATUS Status = STATUS_SUCCESS; + DIR_INFORMATION FoundFile = {NULL}; + + TRACE("FindNextFileW(%lx, 0x%p)\n", hFindFile, lpFindFileData); + + if (hFindFile != FIND_DEVICE_HANDLE) + { + PFIND_DATA_HANDLE FindDataHandle = (PFIND_DATA_HANDLE)hFindFile; + PFIND_FILE_DATA FindFileData; + FINDEX_INFO_LEVELS InfoLevel; + IO_STATUS_BLOCK IoStatusBlock; + DIR_INFORMATION DirInfo = {NULL}, NextDirInfo = {NULL}; + + if (hFindFile == NULL || hFindFile == INVALID_HANDLE_VALUE || + FindDataHandle->Type != FindFile) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + RtlEnterCriticalSection(&FindDataHandle->Lock); + + FindFileData = FindDataHandle->u.FindFileData; + InfoLevel = FindFileData->InfoLevel; + + do + { + if (FindFileData->NextDirInfo.DirInfo == NULL) + { + Status = NtQueryDirectoryFile(FindFileData->Handle, + NULL, NULL, NULL, + &IoStatusBlock, + &FindFileData->Buffer, + sizeof(FindFileData->Buffer), + (InfoLevel == FindExInfoStandard + ? FileBothDirectoryInformation + : FileFullDirectoryInformation), + FALSE, + NULL, /* Use the file pattern from the first call */ + FALSE); + if (Status == STATUS_BUFFER_OVERFLOW) + { + FindFileData->HasMoreData = TRUE; + Status = STATUS_SUCCESS; + } + else + { + if (!NT_SUCCESS(Status)) break; + FindFileData->HasMoreData = FALSE; + } + + FindFileData->NextDirInfo.DirInfo = &FindFileData->Buffer; + } + + DirInfo = FindFileData->NextDirInfo; + + if (DirInfo.FullDirInfo->NextEntryOffset != 0) + { + ULONG_PTR BufferEnd = (ULONG_PTR)&FindFileData->Buffer + sizeof(FindFileData->Buffer); + PWSTR pFileName; + + NextDirInfo.DirInfo = FindFileData->NextDirInfo.DirInfo = + (PVOID)((ULONG_PTR)DirInfo.DirInfo + DirInfo.FullDirInfo->NextEntryOffset); + + pFileName = (InfoLevel == FindExInfoStandard + ? NextDirInfo.BothDirInfo->FileName + : NextDirInfo.FullDirInfo->FileName); + + /* Be paranoid and make sure that the next entry is completely there */ + if (BufferEnd < (ULONG_PTR)NextDirInfo.DirInfo || + BufferEnd < (ULONG_PTR)&NextDirInfo.FullDirInfo->FileNameLength + sizeof(NextDirInfo.FullDirInfo->FileNameLength) || + BufferEnd <= (ULONG_PTR)((ULONG_PTR)pFileName + NextDirInfo.FullDirInfo->FileNameLength)) + { + FindFileData->NextDirInfo.DirInfo = NULL; + } + } + else + { + FindFileData->NextDirInfo.DirInfo = NULL; + } + + if ((FindFileData->SearchOp != FindExSearchLimitToDirectories) || + (DirInfo.FullDirInfo->FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + FoundFile = DirInfo; + } + } while ( FoundFile.DirInfo == NULL && (FindFileData->NextDirInfo.DirInfo || FindFileData->HasMoreData) ); + + if (FoundFile.DirInfo != NULL) + { + /* Return the information */ + CopyFindData(lpFindFileData, InfoLevel, FoundFile); + } + + RtlLeaveCriticalSection(&FindDataHandle->Lock); + } + + if (!NT_SUCCESS(Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + else if (FoundFile.DirInfo == NULL) + { + SetLastError(ERROR_NO_MORE_FILES); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +FindClose(HANDLE hFindFile) +{ + TRACE("FindClose(hFindFile %x)\n", hFindFile); + + if (hFindFile == FIND_DEVICE_HANDLE) + return TRUE; + + if (!hFindFile || hFindFile == INVALID_HANDLE_VALUE) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + /* Protect with SEH against closing attempts on invalid handles. */ + _SEH2_TRY + { + PFIND_DATA_HANDLE FindDataHandle = (PFIND_DATA_HANDLE)hFindFile; + + switch (FindDataHandle->Type) + { + case FindFile: + { + RtlEnterCriticalSection(&FindDataHandle->Lock); + NtClose(FindDataHandle->u.FindFileData->Handle); + RtlLeaveCriticalSection(&FindDataHandle->Lock); + RtlDeleteCriticalSection(&FindDataHandle->Lock); + break; + } + + case FindStream: + { + RtlEnterCriticalSection(&FindDataHandle->Lock); + if (FindDataHandle->u.FindStreamData->FileStreamInfo != NULL) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, + FindDataHandle->u.FindStreamData->FileStreamInfo); + } + RtlLeaveCriticalSection(&FindDataHandle->Lock); + RtlDeleteCriticalSection(&FindDataHandle->Lock); + break; + } + + default: + { + SetLastError(ERROR_INVALID_HANDLE); + _SEH2_YIELD(return FALSE); + } + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, FindDataHandle); + _SEH2_YIELD(return TRUE); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + BaseSetLastNTError(_SEH2_GetExceptionCode()); + _SEH2_YIELD(return FALSE); + } + _SEH2_END; +} + + +/* + * @unimplemented + */ +HANDLE +WINAPI +FindFirstFileExA(IN LPCSTR lpFileName, + IN FINDEX_INFO_LEVELS fInfoLevelId, + OUT LPVOID lpFindFileData, + IN FINDEX_SEARCH_OPS fSearchOp, + LPVOID lpSearchFilter, + IN DWORD dwAdditionalFlags) +{ + HANDLE hSearch; + NTSTATUS Status; + ANSI_STRING Ansi; + UNICODE_STRING UTF8; + PUNICODE_STRING lpFileNameW; + WIN32_FIND_DATAW FindFileDataW; + LPWIN32_FIND_DATAA lpFindFileDataA = (LPWIN32_FIND_DATAA)lpFindFileData; + + if ((fInfoLevelId != FindExInfoStandard && fInfoLevelId != FindExInfoBasic) || + fSearchOp == FindExSearchLimitToDevices || + dwAdditionalFlags & ~FIND_FIRST_EX_CASE_SENSITIVE /* only supported flag for now */) + { + SetLastError(fSearchOp == FindExSearchLimitToDevices + ? ERROR_NOT_SUPPORTED + : ERROR_INVALID_PARAMETER); + return INVALID_HANDLE_VALUE; + } + + lpFileNameW = Basep8BitStringToStaticUnicodeString(lpFileName); + if (!lpFileNameW) return INVALID_HANDLE_VALUE; + + hSearch = FindFirstFileExW(lpFileNameW->Buffer, + fInfoLevelId, + &FindFileDataW, + fSearchOp, + lpSearchFilter, + dwAdditionalFlags); + if (hSearch == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE; + + RtlCopyMemory(lpFindFileDataA, + &FindFileDataW, + FIELD_OFFSET(WIN32_FIND_DATAA, cFileName)); + + RtlInitUnicodeString(&UTF8, FindFileDataW.cFileName); + Ansi.Buffer = lpFindFileDataA->cFileName; + Ansi.Length = 0; + Ansi.MaximumLength = sizeof(lpFindFileDataA->cFileName); + Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); + if (!NT_SUCCESS(Status)) + { + FindClose(hSearch); + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + + if (fInfoLevelId != FindExInfoBasic) + { + RtlInitUnicodeString(&UTF8, FindFileDataW.cAlternateFileName); + Ansi.Buffer = lpFindFileDataA->cAlternateFileName; + Ansi.Length = 0; + Ansi.MaximumLength = sizeof(lpFindFileDataA->cAlternateFileName); + Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); + if (!NT_SUCCESS(Status)) + { + FindClose(hSearch); + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + } + else + { + lpFindFileDataA->cAlternateFileName[0] = ANSI_NULL; + } + + return hSearch; } @@ -654,123 +649,241 @@ LPVOID lpSearchFilter, IN DWORD dwAdditionalFlags) { - if (fInfoLevelId != FindExInfoStandard) - { - SetLastError(ERROR_INVALID_PARAMETER); + TRACE("FindFirstFileExW(lpFileName %S)\n", lpFileName); + + if ((fInfoLevelId != FindExInfoStandard && fInfoLevelId != FindExInfoBasic) || + fSearchOp == FindExSearchLimitToDevices || + dwAdditionalFlags & ~FIND_FIRST_EX_CASE_SENSITIVE /* only supported flag for now */) + { + SetLastError(fSearchOp == FindExSearchLimitToDevices + ? ERROR_NOT_SUPPORTED + : ERROR_INVALID_PARAMETER); return INVALID_HANDLE_VALUE; } - if (fSearchOp == FindExSearchNameMatch || fSearchOp == FindExSearchLimitToDirectories) - { + if (fSearchOp == FindExSearchNameMatch || + fSearchOp == FindExSearchLimitToDirectories) + { + LPWIN32_FIND_DATAW Win32FindData = (LPWIN32_FIND_DATAW)lpFindFileData; + PFIND_DATA_HANDLE FindDataHandle; + PFIND_FILE_DATA FindFileData; + + UNICODE_STRING NtPath, FilePattern; + PWSTR NtPathBuffer; + RTL_RELATIVE_NAME_U RelativePath; + ULONG DeviceNameInfo = 0; + + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + HANDLE hDirectory = NULL; + + /* + * May represent many FILE_BOTH_DIR_INFORMATION + * or many FILE_FULL_DIR_INFORMATION structures. + */ + BYTE DirectoryInfo[FIND_DATA_SIZE]; + DIR_INFORMATION DirInfo = {&DirectoryInfo}; + + /* The search filter is always unused */ if (lpSearchFilter) { SetLastError(ERROR_INVALID_PARAMETER); return INVALID_HANDLE_VALUE; } - return InternalFindFirstFile (lpFileName, - fSearchOp == FindExSearchLimitToDirectories, - lpFindFileData); - } - - SetLastError(ERROR_INVALID_PARAMETER); - return INVALID_HANDLE_VALUE; -} - -/* - * @unimplemented - */ -HANDLE -WINAPI -FindFirstFileExA(IN LPCSTR lpFileName, - IN FINDEX_INFO_LEVELS fInfoLevelId, - OUT LPVOID lpFindFileData, - IN FINDEX_SEARCH_OPS fSearchOp, - LPVOID lpSearchFilter, - IN DWORD dwAdditionalFlags) -{ - HANDLE hSearch; - NTSTATUS Status; - ANSI_STRING Ansi; - UNICODE_STRING UTF8; - PUNICODE_STRING lpFileNameW; - WIN32_FIND_DATAW FindFileDataW; - - lpFileNameW = Basep8BitStringToStaticUnicodeString(lpFileName); - if (!lpFileNameW) - { + if (!RtlDosPathNameToNtPathName_U(lpFileName, + &NtPath, + (PCWSTR*)&FilePattern.Buffer, + &RelativePath)) + { + SetLastError(ERROR_PATH_NOT_FOUND); + return INVALID_HANDLE_VALUE; + } + + DPRINT("lpFileName = '%S'\n", lpFileName); + DPRINT("FilePattern.Buffer = '%S'\n", FilePattern.Buffer); + DPRINT("RelativePath.RelativeName = '%wZ'\n", &RelativePath.RelativeName); + DPRINT("NtPath.Buffer = '%S'\n", NtPath.Buffer); + DPRINT("NtPath - Before = '%wZ'\n", &NtPath); + + /* Save the buffer pointer for later, we need to free it! */ + NtPathBuffer = NtPath.Buffer; + + /* + * Contrary to what Windows does, check NOW whether or not + * lpFileName is a DOS driver. Therefore we don't have to + * write broken code to check that. + */ + if (!FilePattern.Buffer || !*FilePattern.Buffer) + { + /* No file pattern specified, or DOS device */ + + DeviceNameInfo = RtlIsDosDeviceName_U(lpFileName); + if (DeviceNameInfo != 0) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); + + /* OK, it's really a DOS device */ + CopyDeviceFindData(Win32FindData, lpFileName, DeviceNameInfo); + return FIND_DEVICE_HANDLE; + } + } + + /* A file pattern was specified, or it was not a DOS device */ + + /* If there is a file pattern then determine its length */ + if (FilePattern.Buffer != NULL) + { + FilePattern.Length = NtPath.Length - + (USHORT)((ULONG_PTR)FilePattern.Buffer - (ULONG_PTR)NtPath.Buffer); + } + else + { + FilePattern.Length = 0; + } + FilePattern.MaximumLength = FilePattern.Length; + + if (RelativePath.RelativeName.Length != 0 && + RelativePath.RelativeName.Buffer != FilePattern.Buffer) + { + if (FilePattern.Buffer != NULL) + { + /* This is a relative path to RelativePath.ContainingDirectory, adjust NtPath! */ + NtPath.Length = NtPath.MaximumLength = + (USHORT)((ULONG_PTR)FilePattern.Buffer - (ULONG_PTR)RelativePath.RelativeName.Buffer); + NtPath.Buffer = RelativePath.RelativeName.Buffer; + } + } + else + { + /* This is an absolute path, NtPath receives the full path */ + RelativePath.ContainingDirectory = NULL; + if (FilePattern.Buffer != NULL) + { + NtPath.Length = NtPath.MaximumLength = + (USHORT)((ULONG_PTR)FilePattern.Buffer - (ULONG_PTR)NtPath.Buffer); + } + } + + DPRINT("NtPath - After = '%wZ'\n", &NtPath); + DPRINT("FilePattern = '%wZ'\n", &FilePattern); + DPRINT("RelativeTo = 0x%p\n", RelativePath.ContainingDirectory); + + InitializeObjectAttributes(&ObjectAttributes, + &NtPath, + (dwAdditionalFlags & FIND_FIRST_EX_CASE_SENSITIVE) ? 0 : OBJ_CASE_INSENSITIVE, + RelativePath.ContainingDirectory, + NULL); + + Status = NtOpenFile(&hDirectory, + FILE_LIST_DIRECTORY | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT); + + if (!NT_SUCCESS(Status)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); + + /* Adjust the last error codes */ + if (Status == STATUS_OBJECT_NAME_NOT_FOUND) + Status = STATUS_OBJECT_PATH_NOT_FOUND; + else if (Status == STATUS_OBJECT_TYPE_MISMATCH) + Status = STATUS_OBJECT_PATH_NOT_FOUND; + + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + + /* + * Fail if there is not any file pattern, + * since we are not looking for a device. + */ + if (FilePattern.Length == 0) + { + NtClose(hDirectory); + RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); + + SetLastError(ERROR_FILE_NOT_FOUND); + return INVALID_HANDLE_VALUE; + } + + /* Change pattern: "*.*" --> "*" */ + if (FilePattern.Length == 6 && + RtlCompareMemory(FilePattern.Buffer, L"*.*", 6) == 6) + { + FilePattern.Length = 2; + } + + Status = NtQueryDirectoryFile(hDirectory, + NULL, NULL, NULL, + &IoStatusBlock, + DirInfo.DirInfo, // == &DirectoryInfo + sizeof(DirectoryInfo), + (fInfoLevelId == FindExInfoStandard + ? FileBothDirectoryInformation + : FileFullDirectoryInformation), + TRUE, /* Return a single entry */ + &FilePattern, + TRUE); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathBuffer); + + if (!NT_SUCCESS(Status)) + { + NtClose(hDirectory); + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + + ASSERT(DirInfo.FullDirInfo->NextEntryOffset == 0); + + /* Return the information */ + CopyFindData(Win32FindData, fInfoLevelId, DirInfo); + + /* + * Initialization of the search handle. + */ + FindDataHandle = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(FIND_DATA_HANDLE) + + sizeof(FIND_FILE_DATA)); + if (!FindDataHandle) + { + NtClose(hDirectory); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return INVALID_HANDLE_VALUE; + } + + FindDataHandle->Type = FindFile; + FindDataHandle->u.FindFileData = (PFIND_FILE_DATA)(FindDataHandle + 1); + FindFileData = FindDataHandle->u.FindFileData; + + FindFileData->Handle = hDirectory; + FindFileData->InfoLevel = fInfoLevelId; + FindFileData->SearchOp = fSearchOp; + FindFileData->HasMoreData = FALSE; + FindFileData->NextDirInfo.DirInfo = NULL; + + /* The critical section must always be initialized */ + Status = RtlInitializeCriticalSection(&FindDataHandle->Lock); + if (!NT_SUCCESS(Status)) + { + NtClose(hDirectory); + RtlFreeHeap(RtlGetProcessHeap(), 0, FindDataHandle); + + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + + return (HANDLE)FindDataHandle; + } + else + { + SetLastError(ERROR_NOT_SUPPORTED); return INVALID_HANDLE_VALUE; - } - - hSearch = FindFirstFileExW(lpFileNameW->Buffer, - fInfoLevelId, - &FindFileDataW, - fSearchOp, - lpSearchFilter, - dwAdditionalFlags); - if (hSearch == INVALID_HANDLE_VALUE) - { - return INVALID_HANDLE_VALUE; - } - - memcpy(lpFindFileData, &FindFileDataW, FIELD_OFFSET(WIN32_FIND_DATA, cFileName)); - - RtlInitUnicodeString(&UTF8, FindFileDataW.cFileName); - Ansi.Buffer = ((LPWIN32_FIND_DATAA)lpFindFileData)->cFileName; - Ansi.Length = 0; - Ansi.MaximumLength = MAX_PATH; - Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); - if (!NT_SUCCESS(Status)) - { - FindClose(hSearch); - BaseSetLastNTError(Status); - return INVALID_HANDLE_VALUE; - } - - RtlInitUnicodeString(&UTF8, FindFileDataW.cAlternateFileName); - Ansi.Buffer = ((LPWIN32_FIND_DATAA)lpFindFileData)->cAlternateFileName; - Ansi.Length = 0; - Ansi.MaximumLength = 14; - Status = BasepUnicodeStringTo8BitString(&Ansi, &UTF8, FALSE); - if (!NT_SUCCESS(Status)) - { - FindClose(hSearch); - BaseSetLastNTError(Status); - return INVALID_HANDLE_VALUE; - } - - return hSearch; -} - - -static VOID -InternalCopyStreamInfo(IN OUT PKERNEL32_FIND_STREAM_DATA IData, - OUT LPVOID lpFindStreamData) -{ - ASSERT(IData->pCurrent); - - switch (IData->InfoLevel) - { - case FindStreamInfoStandard: - { - ULONG StreamNameLen; - WIN32_FIND_STREAM_DATA *StreamData = (WIN32_FIND_STREAM_DATA*)lpFindStreamData; - - StreamNameLen = IData->pCurrent->StreamNameLength; - if (StreamNameLen > sizeof(StreamData->cStreamName) - sizeof(WCHAR)) - StreamNameLen = sizeof(StreamData->cStreamName) - sizeof(WCHAR); - - StreamData->StreamSize.QuadPart = IData->pCurrent->StreamSize.QuadPart; - RtlCopyMemory(StreamData->cStreamName, - IData->pCurrent->StreamName, - StreamNameLen); - StreamData->cStreamName[StreamNameLen / sizeof(WCHAR)] = L'\0'; - break; - } - - default: - ASSERT(FALSE); - break; } } @@ -785,11 +898,11 @@ OUT LPVOID lpFindStreamData, IN DWORD dwFlags) { - PKERNEL32_FIND_DATA_HEADER IHeader = NULL; - PKERNEL32_FIND_STREAM_DATA IData = NULL; + PFIND_DATA_HANDLE FindDataHandle = NULL; + PFIND_STREAM_DATA FindStreamData; OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING NtPathU; + UNICODE_STRING NtFilePath; HANDLE FileHandle = NULL; NTSTATUS Status; ULONG BufferSize = 0; @@ -801,19 +914,18 @@ return INVALID_HANDLE_VALUE; } - /* validate & translate the filename */ + /* Validate and translate the filename */ if (!RtlDosPathNameToNtPathName_U(lpFileName, - &NtPathU, - NULL, - NULL)) + &NtFilePath, + NULL, NULL)) { SetLastError(ERROR_PATH_NOT_FOUND); return INVALID_HANDLE_VALUE; } - /* open the file */ + /* Open the file */ InitializeObjectAttributes(&ObjectAttributes, - &NtPathU, + &NtFilePath, OBJ_CASE_INSENSITIVE, NULL, NULL); @@ -822,47 +934,52 @@ 0, &ObjectAttributes, &IoStatusBlock, - NULL, - 0, + NULL, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, - 0, - NULL, - 0); - if (!NT_SUCCESS(Status)) - { - goto Cleanup; - } - - /* create the search context */ - IHeader = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - sizeof(KERNEL32_FIND_DATA_HEADER) + - sizeof(KERNEL32_FIND_STREAM_DATA)); - if (IHeader == NULL) + 0, NULL, 0); + if (!NT_SUCCESS(Status)) goto Cleanup; + + /* + * Initialization of the search handle. + */ + FindDataHandle = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(FIND_DATA_HANDLE) + + sizeof(FIND_STREAM_DATA)); + if (!FindDataHandle) { Status = STATUS_NO_MEMORY; goto Cleanup; } - IHeader->Type = StreamFind; - IData = (PKERNEL32_FIND_STREAM_DATA)(IHeader + 1); - - /* capture all information about the streams */ - IData->InfoLevel = InfoLevel; - IData->pCurrent = NULL; - IData->pFileStreamInfo = NULL; - + FindDataHandle->Type = FindStream; + FindDataHandle->u.FindStreamData = (PFIND_STREAM_DATA)(FindDataHandle + 1); + FindStreamData = FindDataHandle->u.FindStreamData; + + FindStreamData->InfoLevel = InfoLevel; + FindStreamData->FileStreamInfo = NULL; + FindStreamData->CurrentInfo = NULL; + + /* The critical section must always be initialized */ + Status = RtlInitializeCriticalSection(&FindDataHandle->Lock); + if (!NT_SUCCESS(Status)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, FindDataHandle); + goto Cleanup; + } + + /* Capture all information about the streams */ do { BufferSize += 0x1000; - if (IData->pFileStreamInfo == NULL) - { - IData->pFileStreamInfo = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - BufferSize); - if (IData->pFileStreamInfo == NULL) + if (FindStreamData->FileStreamInfo == NULL) + { + FindStreamData->FileStreamInfo = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + BufferSize); + if (FindStreamData->FileStreamInfo == NULL) { Status = STATUS_NO_MEMORY; break; @@ -873,8 +990,8 @@ PFILE_STREAM_INFORMATION pfsi; pfsi = RtlReAllocateHeap(RtlGetProcessHeap(), - 0, - IData->pFileStreamInfo, + 0, // HEAP_ZERO_MEMORY, + FindStreamData->FileStreamInfo, BufferSize); if (pfsi == NULL) { @@ -882,12 +999,12 @@ break; } - IData->pFileStreamInfo = pfsi; + FindStreamData->FileStreamInfo = pfsi; } Status = NtQueryInformationFile(FileHandle, &IoStatusBlock, - IData->pFileStreamInfo, + FindStreamData->FileStreamInfo, BufferSize, FileStreamInformation); @@ -895,49 +1012,37 @@ if (NT_SUCCESS(Status)) { - NtClose(FileHandle); - FileHandle = NULL; - - /* select the first stream and return the information */ - IData->pCurrent = IData->pFileStreamInfo; - InternalCopyStreamInfo(IData, - lpFindStreamData); - - /* all done */ + /* Select the first stream and return the information */ + FindStreamData->CurrentInfo = FindStreamData->FileStreamInfo; + CopyStreamData(FindStreamData, lpFindStreamData); + + /* All done */ Status = STATUS_SUCCESS; } + else + { + if (FindStreamData->FileStreamInfo) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, FindStreamData->FileStreamInfo); + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, FindDataHandle); + } Cleanup: - if (FileHandle != NULL) - { - NtClose(FileHandle); - } - - RtlFreeHeap(RtlGetProcessHeap(), - 0, - NtPathU.Buffer); - - if (!NT_SUCCESS(Status)) - { - if (IHeader != NULL) - { - if (IData->pFileStreamInfo != NULL) - { - RtlFreeHeap(RtlGetProcessHeap(), - 0, - IData->pFileStreamInfo); - } - - RtlFreeHeap(RtlGetProcessHeap(), - 0, - IHeader); - } - + if (FileHandle) NtClose(FileHandle); + + RtlFreeHeap(RtlGetProcessHeap(), 0, NtFilePath.Buffer); + + if (NT_SUCCESS(Status)) + { + return (HANDLE)FindDataHandle; + } + else + { BaseSetLastNTError(Status); return INVALID_HANDLE_VALUE; } - - return (HANDLE)IHeader; } @@ -949,37 +1054,39 @@ FindNextStreamW(IN HANDLE hFindStream, OUT LPVOID lpFindStreamData) { - PKERNEL32_FIND_DATA_HEADER IHeader; - PKERNEL32_FIND_STREAM_DATA IData; - - IHeader = (PKERNEL32_FIND_DATA_HEADER)hFindStream; + PFIND_DATA_HANDLE FindDataHandle = (PFIND_DATA_HANDLE)hFindStream; + PFIND_STREAM_DATA FindStreamData; + if (hFindStream == NULL || hFindStream == INVALID_HANDLE_VALUE || - IHeader->Type != StreamFind) - { - SetLastError (ERROR_INVALID_HANDLE); + FindDataHandle->Type != FindStream) + { + SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - IData = (PKERNEL32_FIND_STREAM_DATA)(IHeader + 1); - - /* select next stream if possible */ - if (IData->pCurrent->NextEntryOffset != 0) - { - IData->pCurrent = (PFILE_STREAM_INFORMATION)((ULONG_PTR)IData->pFileStreamInfo + - IData->pCurrent->NextEntryOffset); + RtlEnterCriticalSection(&FindDataHandle->Lock); + + FindStreamData = FindDataHandle->u.FindStreamData; + + /* Select next stream if possible */ + if (FindStreamData->CurrentInfo->NextEntryOffset != 0) + { + FindStreamData->CurrentInfo = (PFILE_STREAM_INFORMATION)((ULONG_PTR)FindStreamData->FileStreamInfo + + FindStreamData->CurrentInfo->NextEntryOffset); + + /* Return the information */ + CopyStreamData(FindStreamData, lpFindStreamData); + + RtlLeaveCriticalSection(&FindDataHandle->Lock); + return TRUE; } else { + RtlLeaveCriticalSection(&FindDataHandle->Lock); + SetLastError(ERROR_HANDLE_EOF); return FALSE; } - - /* return the information */ - InternalCopyStreamInfo(IData, - lpFindStreamData); - - return TRUE; -} - +} /* EOF */ Modified: trunk/reactos/include/ndk/iotypes.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/iotypes.h?rev=…
============================================================================== --- trunk/reactos/include/ndk/iotypes.h [iso-8859-1] (original) +++ trunk/reactos/include/ndk/iotypes.h [iso-8859-1] Thu Sep 27 22:07:06 2012 @@ -523,6 +523,22 @@ { PLARGE_INTEGER ReadTimeout; } FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION; + +typedef struct _FILE_FULL_DIR_INFORMATION +{ + ULONG NextEntryOffset; + ULONG FileIndex; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER EndOfFile; + LARGE_INTEGER AllocationSize; + ULONG FileAttributes; + ULONG FileNameLength; + ULONG EaSize; + WCHAR FileName[1]; +} FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION; typedef struct _FILE_BOTH_DIR_INFORMATION { Modified: trunk/reactos/include/psdk/winbase.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winbase.h?rev…
============================================================================== --- trunk/reactos/include/psdk/winbase.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winbase.h [iso-8859-1] Thu Sep 27 22:07:06 2012 @@ -228,6 +228,7 @@ #define CLRBREAK 9 #define STILL_ACTIVE 0x103 #define FIND_FIRST_EX_CASE_SENSITIVE 1 +#define FIND_FIRST_EX_LARGE_FETCH 2 #define SCS_32BIT_BINARY 0 #define SCS_64BIT_BINARY 6 #define SCS_DOS_BINARY 1 @@ -923,6 +924,7 @@ typedef enum _FINDEX_INFO_LEVELS { FindExInfoStandard, + FindExInfoBasic, FindExInfoMaxInfoLevel } FINDEX_INFO_LEVELS;
12 years, 2 months
1
0
0
0
[tkreuzer] 57406: Fix build
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Sep 27 22:01:26 2012 New Revision: 57406 URL:
http://svn.reactos.org/svn/reactos?rev=57406&view=rev
Log: Fix build Modified: trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c Modified: trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/mbstowc…
============================================================================== --- trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] Thu Sep 27 22:01:26 2012 @@ -96,7 +96,7 @@ else { /* Get the length of the string, plus 0 terminator */ - cwcWritten = _mbsnlen(pmbstr, count) + 1; + cwcWritten = _mbsnlen((const unsigned char *)pmbstr, count) + 1; } } else
12 years, 2 months
1
0
0
0
[tkreuzer] 57405: [CRT] Implement wcstombs_s
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Sep 27 21:56:13 2012 New Revision: 57405 URL:
http://svn.reactos.org/svn/reactos?rev=57405&view=rev
Log: [CRT] Implement wcstombs_s Added: trunk/reactos/lib/sdk/crt/string/wcstombs_s.c (with props) Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec trunk/reactos/lib/sdk/crt/crt.cmake trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/msvcrt.sp…
============================================================================== --- trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] Thu Sep 27 21:56:13 2012 @@ -435,7 +435,7 @@ # stub _get_fmode # @ cdecl _get_heap_handle() @ cdecl _get_osfhandle(long) -@ cdecl _get_osplatform(ptr) +@ cdecl _get_osplatform(ptr) # stub _get_osver @ cdecl _get_output_format() @ cdecl _get_pgmptr(ptr) @@ -477,9 +477,9 @@ @ cdecl _heapwalk(ptr) @ cdecl _hypot(double double) @ cdecl _i64toa(long long ptr long) -@ cdecl _i64toa_s(long long ptr long long) +@ cdecl _i64toa_s(long long ptr long long) @ cdecl _i64tow(long long ptr long) -@ cdecl _i64tow_s(long long ptr long long) +@ cdecl _i64tow_s(long long ptr long long) @ cdecl _initterm(ptr ptr) @ cdecl _initterm_e(ptr ptr) @ cdecl -arch=i386 _inp(long) MSVCRT__inp @@ -1396,7 +1396,7 @@ @ cdecl wcsncmp(wstr wstr long) @ cdecl wcsncpy(ptr wstr long) @ cdecl wcsncpy_s(ptr long wstr long) -# stub wcsnlen +@ cdecl wcsnlen(wstr long) @ cdecl wcspbrk(wstr wstr) @ cdecl wcsrchr(wstr long) # stub wcsrtombs @@ -1408,7 +1408,7 @@ @ cdecl wcstok_s(ptr wstr ptr) @ cdecl wcstol(wstr ptr long) @ cdecl wcstombs(ptr ptr long) -# @ cdecl wcstombs_s(ptr ptr long wstr long) +@ cdecl wcstombs_s(ptr ptr long wstr long) @ cdecl wcstoul(wstr ptr long) @ cdecl wcsxfrm(ptr wstr long) # stub wctob Modified: trunk/reactos/lib/sdk/crt/crt.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.cmake?rev=…
============================================================================== --- trunk/reactos/lib/sdk/crt/crt.cmake [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/crt.cmake [iso-8859-1] Thu Sep 27 21:56:13 2012 @@ -247,6 +247,8 @@ stdlib/wsenv.c stdlib/wmakpath.c stdlib/wmakpath_s.c + string/_mbsnlen.c + string/_mbstrnlen.c string/atof.c string/atoi.c string/atoi64.c @@ -283,6 +285,7 @@ string/strxfrm.c string/wcs.c string/wcstol.c + string/wcstombs_s.c string/wcstoul.c string/wctype.c string/wsplitp.c Modified: trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/mbstowc…
============================================================================== --- trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/string/mbstowcs_s.c [iso-8859-1] Thu Sep 27 21:56:13 2012 @@ -7,17 +7,15 @@ */ #include <precomp.h> -#include <specstrings.h> - -#define _mbsnlen strnlen +#include <mbstring.h> _CRTIMP _Check_return_opt_ errno_t __cdecl mbstowcs_s( - _Out_opt_ size_t *pReturnValue, - _Out_writes_to_opt_(sizeInWords, *pReturnValue) wchar_t *pwcstr, + _Out_opt_ size_t *pcchConverted, + _Out_writes_to_opt_(sizeInWords, *pcchConverted) wchar_t *pwcstr, _In_ size_t sizeInWords, _In_reads_or_z_(count) const char *pmbstr, _In_ size_t count) @@ -34,10 +32,10 @@ } /* Check if we have a return value pointer */ - if (pReturnValue) + if (pcchConverted) { /* Default to 0 bytes written */ - *pReturnValue = 0; + *pcchConverted = 0; } if (!MSVCRT_CHECK_PMT((count == 0) || (pmbstr != 0))) @@ -107,10 +105,10 @@ } /* Check if we have a return value pointer */ - if (pReturnValue) + if (pcchConverted) { /* Default to 0 bytes written */ - *pReturnValue = cwcWritten; + *pcchConverted = cwcWritten; } return retval; Added: trunk/reactos/lib/sdk/crt/string/wcstombs_s.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wcstomb…
============================================================================== --- trunk/reactos/lib/sdk/crt/string/wcstombs_s.c (added) +++ trunk/reactos/lib/sdk/crt/string/wcstombs_s.c [iso-8859-1] Thu Sep 27 21:56:13 2012 @@ -1,0 +1,115 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT + * PURPOSE: Implementation of mbstowcs_s + * FILE: lib/sdk/crt/stdlib/mbstowcs_s.c + * PROGRAMMER: Timo Kreuzer + */ + +#include <precomp.h> + +_Check_return_wat_ +_CRTIMP +errno_t +__cdecl +wcstombs_s( + _Out_opt_ size_t * pcchConverted, + _Out_writes_bytes_to_opt_(cjDstSize, *pcchConverted) + char * pmbstrDst, + _In_ size_t cjDstSize, + _In_z_ const wchar_t * pwszSrc, + _In_ size_t cjMaxCount) +{ + size_t cchMax, cchConverted; + errno_t retval = 0; + + /* Make sure, either we have a target buffer > 0 bytes, or no buffer */ + if (!MSVCRT_CHECK_PMT( ((cjDstSize != 0) && (pmbstrDst != 0)) || + ((cjDstSize == 0) && (pmbstrDst == 0)) )) + { + _set_errno(EINVAL); + return EINVAL; + } + + /* Check if we have a return value pointer */ + if (pcchConverted) + { + /* Default to 0 bytes written */ + *pcchConverted = 0; + } + + if (!MSVCRT_CHECK_PMT((cjMaxCount == 0) || (pwszSrc != 0))) + { + _set_errno(EINVAL); + return EINVAL; + } + + /* Check if there is anything to do */ + if ((pmbstrDst == 0) && (pwszSrc == 0)) + { + _set_errno(EINVAL); + return EINVAL; + } + + /* Check if we have a wchar string */ + if (pwszSrc) + { + /* Check if we also have a multibyte buffer */ + if (pmbstrDst) + { + /* Calculate the maximum that we can write */ + cchMax = (cjMaxCount < cjDstSize) ? cjMaxCount + 1 : cjDstSize; + + /* Now do the conversion */ + cchConverted = wcstombs(pmbstrDst, pwszSrc, cchMax); + + /* Check if the buffer was not zero terminated */ + if (cchConverted == cchMax) + { + /* Check if we reached the max size of the dest buffer */ + if (cchConverted == cjDstSize) + { + /* Does the caller allow this? */ + if (cjMaxCount != _TRUNCATE) + { + /* Not allowed, truncate to 0 length */ + pmbstrDst[0] = L'\0'; + + /* Return error */ + _set_errno(ERANGE); + return ERANGE; + } + + /* Inform the caller about truncation */ + retval = STRUNCATE; + } + + /* zero teminate the buffer */ + pmbstrDst[cchConverted - 1] = L'\0'; + } + else + { + /* The buffer is zero terminated, count the terminating char */ + cchConverted++; + } + } + else + { + /* Get the length of the string, plus 0 terminator */ + cchConverted = wcsnlen(pwszSrc, cjMaxCount) + 1; + } + } + else + { + cchConverted = cjMaxCount + 1; + } + + /* Check if we have a return value pointer */ + if (pcchConverted) + { + /* Default to 0 bytes written */ + *pcchConverted = cchConverted; + } + + return retval; +} Propchange: trunk/reactos/lib/sdk/crt/string/wcstombs_s.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 2 months
1
0
0
0
[tkreuzer] 57404: [CRT] Implement _mbsnlen, _mbstrnlen
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Sep 27 21:53:25 2012 New Revision: 57404 URL:
http://svn.reactos.org/svn/reactos?rev=57404&view=rev
Log: [CRT] Implement _mbsnlen, _mbstrnlen Added: trunk/reactos/lib/sdk/crt/string/_mbsnlen.c (with props) trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c (with props) Added: trunk/reactos/lib/sdk/crt/string/_mbsnlen.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_mbsnle…
============================================================================== --- trunk/reactos/lib/sdk/crt/string/_mbsnlen.c (added) +++ trunk/reactos/lib/sdk/crt/string/_mbsnlen.c [iso-8859-1] Thu Sep 27 21:53:25 2012 @@ -1,0 +1,36 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT + * PURPOSE: Implementation of _mbsnlen + * FILE: lib/sdk/crt/string/_mbsnlen.c + * PROGRAMMER: Timo Kreuzer + */ + +#include <mbstring.h> + +_Check_return_ +_CRTIMP +size_t +__cdecl +_mbsnlen( + _In_z_ const unsigned char *pmbstr, + _In_ size_t cjMaxLen) +{ + size_t cchCount = 0; + unsigned char jMbsByte; + + /* Loop while we have bytes to process */ + while (cjMaxLen-- > 0) + { + /* Get next mb byte */ + jMbsByte = *pmbstr++; + + /* If this is 0, we're done */ + if (jMbsByte == 0) break; + + /* Don't count lead bytes */ + if (!_ismbblead(jMbsByte)) cchCount++; + } + + return cchCount; +} Propchange: trunk/reactos/lib/sdk/crt/string/_mbsnlen.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_mbstrn…
============================================================================== --- trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c (added) +++ trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c [iso-8859-1] Thu Sep 27 21:53:25 2012 @@ -1,0 +1,53 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS CRT + * PURPOSE: Implementation of _mbstrnlen + * FILE: lib/sdk/crt/string/_mbstrnlen.c + * PROGRAMMER: Timo Kreuzer + */ + +#include <precomp.h> +#include <mbctype.h> +#include <specstrings.h> + +_Check_return_ +_CRTIMP +size_t +__cdecl +_mbstrnlen( + _In_z_ const char *pmbstr, + _In_ size_t cjMaxLen) +{ + size_t cchCount = 0; + unsigned char jMbsByte; + + /* Check parameters */ + if (!MSVCRT_CHECK_PMT((pmbstr != 0)) && (cjMaxLen <= INT_MAX)) + { + _set_errno(EINVAL); + return -1; + } + + /* Loop while we have bytes to process */ + while (cjMaxLen-- > 0) + { + /* Get next mb byte */ + jMbsByte = *pmbstr++; + + /* If this is 0, we're done */ + if (jMbsByte == 0) break; + + /* if this is a lead byte, continue with next char */ + if (_ismbblead(jMbsByte)) + { + // FIXME: check if this is a valid char. + continue; + } + + /* Count this character */ + cchCount++; + } + + return cchCount; +} + Propchange: trunk/reactos/lib/sdk/crt/string/_mbstrnlen.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 2 months
1
0
0
0
[tkreuzer] 57403: [CRT_APITEST] - Add tests for wcstombs_s - Improve tests for mbstowcs_s
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Thu Sep 27 21:46:39 2012 New Revision: 57403 URL:
http://svn.reactos.org/svn/reactos?rev=57403&view=rev
Log: [CRT_APITEST] - Add tests for wcstombs_s - Improve tests for mbstowcs_s Added: trunk/rostests/apitests/crt/wcstombs_s.c (with props) Modified: trunk/rostests/apitests/crt/mbstowcs_s.c trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake trunk/rostests/apitests/crt/testlist.c Modified: trunk/rostests/apitests/crt/mbstowcs_s.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/mbstowcs_s.c…
============================================================================== --- trunk/rostests/apitests/crt/mbstowcs_s.c [iso-8859-1] (original) +++ trunk/rostests/apitests/crt/mbstowcs_s.c [iso-8859-1] Thu Sep 27 21:46:39 2012 @@ -11,141 +11,18 @@ #include <specstrings.h> #define ok_errno(x) ok_hex(errno, (x)) +#define ok_wchar(x,y) ok_int(x,y) errno_t mbstowcs_s( - size_t *returnval, + size_t *cchConverted, wchar_t *widechar, size_t charoutct, const char *multibyte, size_t count); -void -_invalid_parameter( - const wchar_t * expression, - const wchar_t * function, - const wchar_t * file, - unsigned int line, - uintptr_t pReserved); - -void -_invalid_parameterA( - const char * expression, - const char * function, - const char * file, - unsigned int line, - uintptr_t pReserved) -{ - // call _invalid_parameter -} - #define MSVCRT_INVALID_PMT(x) _invalid_parameterA(#x, __FUNCTION__, __FILE__, __LINE__, 0) #define MSVCRT_CHECK_PMT(x) ((x) || (MSVCRT_INVALID_PMT(x),0)) - -#define _mbsnlen strnlen - -errno_t -mbstowcs_s( - _Out_opt_ size_t *pReturnValue, - _Out_ wchar_t *pwcstr, - _In_ size_t sizeInWords, - _In_ const char *pmbstr, - _In_ size_t count) -{ - size_t cchMax, cwcWritten; - errno_t retval = 0; - - if (!MSVCRT_CHECK_PMT( ((sizeInWords != 0) && (pwcstr != 0)) || - ((sizeInWords == 0) && (pwcstr == 0)) )) - { - _set_errno(EINVAL); - return EINVAL; - } - - /* Check if we have a return value pointer */ - if (pReturnValue) - { - /* Default to 0 bytes written */ - *pReturnValue = 0; - } - - if (!MSVCRT_CHECK_PMT((count == 0) || (pmbstr != 0))) - { - _set_errno(EINVAL); - return EINVAL; - } - - /* Check if there is anything to do */ - if ((pwcstr == 0) && (pmbstr == 0)) - { - _set_errno(EINVAL); - return EINVAL; - } - - /* Check if we have a source string */ - if (pmbstr) - { - /* Check if we also have a wchar buffer */ - if (pwcstr) - { - /* Calculate the maximum the we can write */ - cchMax = (count < sizeInWords) ? count + 1 : sizeInWords; - - /* Now do the conversion */ - cwcWritten = mbstowcs(pwcstr, pmbstr, cchMax); - - /* Check if the buffer was not zero terminated */ - if (cwcWritten == cchMax) - { - /* Check if we reached the max size of the dest buffer */ - if (cwcWritten == sizeInWords) - { - /* Does the caller allow this? */ - if (count != _TRUNCATE) - { - /* Not allowed, truncate to 0 length */ - pwcstr[0] = L'\0'; - - /* Return error */ - _set_errno(ERANGE); - return ERANGE; - } - - /* Inform the caller about truncation */ - retval = STRUNCATE; - } - - /* zero teminate the buffer */ - pwcstr[cwcWritten - 1] = L'\0'; - } - else - { - /* The buffer is zero terminated, count the terminating char */ - cwcWritten++; - } - } - else - { - /* Get the length of the string, plus 0 terminator */ - cwcWritten = _mbsnlen(pmbstr, count) + 1; - } - } - else - { - cwcWritten = count + 1; - } - - /* Check if we have a return value pointer */ - if (pReturnValue) - { - /* Default to 0 bytes written */ - *pReturnValue = cwcWritten; - } - - return retval; -} - - wchar_t g_expression[64]; wchar_t g_function[64]; @@ -173,64 +50,64 @@ // _set_invalid_parameter_handler(_test_invalid_parameter); errno_t ret; - size_t returnval; + size_t cchConverted; wchar_t widechar[10]; -#if 1 - _set_errno(0); - returnval = 0xf00bac; + + _set_errno(0); + cchConverted = 0xf00bac; widechar[5] = 0xFF; - ret = mbstowcs_s(&returnval, widechar, 6, "hallo", 5); - ok_long(ret, 0); - ok_size_t(returnval, 6); - ok_char(widechar[5], 0); + ret = mbstowcs_s(&cchConverted, widechar, 6, "hallo", 5); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_wchar(widechar[5], 0); ok_wstr(widechar, L"hallo"); ok_errno(0); _set_errno(0); - returnval = 0xf00bac; + cchConverted = 0xf00bac; widechar[0] = 0xFF; - ret = mbstowcs_s(&returnval, widechar, 1, "", 0); - ok_long(ret, 0); - ok_size_t(returnval, 1); - ok_char(widechar[0], 0); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 1, "", 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_wchar(widechar[0], 0); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; widechar[0] = 0xFF; widechar[1] = 0xFF; widechar[2] = 0xFF; widechar[3] = 0xFF; widechar[4] = 0xFF; widechar[5] = 0xFF; - ret = mbstowcs_s(&returnval, widechar, 5, "hallo", 5); + ret = mbstowcs_s(&cchConverted, widechar, 5, "hallo", 5); ok_long(ret, ERANGE); - ok_size_t(returnval, 0); - ok_char(widechar[5], 0xFF); - ok_char(widechar[4], L'o'); - ok_char(widechar[3], L'l'); - ok_char(widechar[2], L'l'); - ok_char(widechar[1], L'a'); - ok_char(widechar[0], 0); + ok_size_t(cchConverted, 0); + ok_wchar(widechar[5], 0xFF); + ok_wchar(widechar[4], L'o'); + ok_wchar(widechar[3], L'l'); + ok_wchar(widechar[2], L'l'); + ok_wchar(widechar[1], L'a'); + ok_wchar(widechar[0], 0); ok_errno(ERANGE); _set_errno(0); - returnval = 0xf00bac; + cchConverted = 0xf00bac; widechar[0] = 0xFF; widechar[1] = 0xFF; widechar[2] = 0xFF; widechar[3] = 0xFF; widechar[4] = 0xFF; widechar[5] = 0xFF; - ret = mbstowcs_s(&returnval, widechar, 3, "hallo", 5); + ret = mbstowcs_s(&cchConverted, widechar, 3, "hallo", 5); ok_long(ret, ERANGE); - ok_size_t(returnval, 0); - ok_char(widechar[5], 0xFF); - ok_char(widechar[4], 0xFF); - ok_char(widechar[3], 0xFF); - ok_char(widechar[2], L'l'); - ok_char(widechar[1], L'a'); - ok_char(widechar[0], 0); + ok_size_t(cchConverted, 0); + ok_wchar(widechar[5], 0xFF); + ok_wchar(widechar[4], 0xFF); + ok_wchar(widechar[3], 0xFF); + ok_wchar(widechar[2], L'l'); + ok_wchar(widechar[1], L'a'); + ok_wchar(widechar[0], 0); ok_errno(ERANGE); _set_errno(0); @@ -239,17 +116,17 @@ ok_errno(EINVAL); _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, 0, 0, 0, 0); - ok_long(ret, EINVAL); - ok_size_t(returnval, 0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, 0, 0, 0, 0); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0); ok_errno(EINVAL); _set_errno(0); widechar[0] = L'x'; ret = mbstowcs_s(0, widechar, 0, 0, 0); ok_long(ret, EINVAL); - ok_char(widechar[0], L'x'); + ok_wchar(widechar[0], L'x'); ok_errno(EINVAL); _set_errno(0); @@ -263,98 +140,96 @@ ok_errno(EINVAL); _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, 0, 10, "hallo", 5); - ok_long(ret, EINVAL); - ok_size_t(returnval, 0xf00bac); - ok_errno(EINVAL); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, 0, 0, "hallo", 5); - ok_long(ret, 0); - ok_size_t(returnval, 6); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, widechar, 10, 0, 5); - ok_long(ret, EINVAL); - ok_size_t(returnval, 0); - ok_errno(EINVAL); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, widechar, 10, "hallo", 0); - ok_long(ret, 0); - ok_size_t(returnval, 1); - ok_errno(0); -#endif - _set_errno(0); - returnval = 0xf00bac; + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, 0, 10, "hallo", 5); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0xf00bac); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, 0, 0, "hallo", 5); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, 0, 5); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, "hallo", 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; widechar[0] = 0xABCD; widechar[1] = 0xABCD; widechar[2] = 0xABCD; widechar[3] = 0xABCD; widechar[4] = 0xABCD; widechar[5] = 0xABCD; - ret = mbstowcs_s(&returnval, widechar, 10, "hallo", 2); - ok_long(ret, 0); - ok_size_t(returnval, 3); - ok_char(widechar[5], 0xABCD); - ok_char(widechar[4], 0xABCD); - ok_char(widechar[3], 0xABCD); - ok_char(widechar[2], 0); - ok_char(widechar[1], L'a'); - ok_char(widechar[0], L'h'); - ok_errno(0); -#if 1 - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, widechar, 10, 0, 0); - ok_long(ret, 0); - ok_size_t(returnval, 1); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, widechar, 10, "hallo", 7); - ok_long(ret, 0); - ok_size_t(returnval, 6); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, 0, 0, "hallo", 7); - ok_long(ret, 0); - ok_size_t(returnval, 6); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, "hallo", 2); + ok_long(ret, 0); + ok_size_t(cchConverted, 3); + ok_wchar(widechar[5], 0xABCD); + ok_wchar(widechar[4], 0xABCD); + ok_wchar(widechar[3], 0xABCD); + ok_wchar(widechar[2], 0); + ok_wchar(widechar[1], L'a'); + ok_wchar(widechar[0], L'h'); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, 0, 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, "hallo", 7); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, 0, 0, "hallo", 7); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; widechar[0] = 0xABCD; widechar[1] = 0xABCD; widechar[2] = 0xABCD; widechar[3] = 0xABCD; widechar[4] = 0xABCD; widechar[5] = 0xABCD; - ret = mbstowcs_s(&returnval, widechar, 5, "hallo", _TRUNCATE); + ret = mbstowcs_s(&cchConverted, widechar, 5, "hallo", _TRUNCATE); ok_long(ret, STRUNCATE); - ok_size_t(returnval, 5); - ok_char(widechar[5], 0xABCD); - ok_char(widechar[4], 0); - ok_char(widechar[3], L'l'); - ok_char(widechar[2], L'l'); - ok_char(widechar[1], L'a'); - ok_char(widechar[0], L'h'); - ok_errno(0); - - _set_errno(0); - returnval = 0xf00bac; - ret = mbstowcs_s(&returnval, widechar, 10, "hallo", -1); - ok_long(ret, 0); - ok_size_t(returnval, 6); - ok_errno(0); -#endif - + ok_size_t(cchConverted, 5); + ok_wchar(widechar[5], 0xABCD); + ok_wchar(widechar[4], 0); + ok_wchar(widechar[3], L'l'); + ok_wchar(widechar[2], L'l'); + ok_wchar(widechar[1], L'a'); + ok_wchar(widechar[0], L'h'); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = mbstowcs_s(&cchConverted, widechar, 10, "hallo", -1); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); } Modified: trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/msvcrt_crt_a…
============================================================================== --- trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] (original) +++ trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] Thu Sep 27 21:46:39 2012 @@ -1251,7 +1251,7 @@ # wcstok_s.c # wcstol.c # wcstombs.c -# wcstombs_s.c + wcstombs_s.c # wcstoul.c # wcsxfrm.c # wctob Modified: trunk/rostests/apitests/crt/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/testlist.c?r…
============================================================================== --- trunk/rostests/apitests/crt/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/crt/testlist.c [iso-8859-1] Thu Sep 27 21:46:39 2012 @@ -7,6 +7,7 @@ #if defined(TEST_MSVCRT) extern void func_mbstowcs_s(void); +extern void func_wcstombs_s(void); extern void func__vscprintf(void); extern void func__vscwprintf(void); #endif @@ -33,6 +34,7 @@ #if defined(TEST_STATIC_CRT) #elif defined(TEST_MSVCRT) { "mbstowcs_s", func_mbstowcs_s }, + { "wcstombs_s", func_wcstombs_s }, { "_vscprintf", func__vscprintf }, { "_vscwprintf", func__vscwprintf }, #elif defined(TEST_NTDLL) Added: trunk/rostests/apitests/crt/wcstombs_s.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/wcstombs_s.c…
============================================================================== --- trunk/rostests/apitests/crt/wcstombs_s.c (added) +++ trunk/rostests/apitests/crt/wcstombs_s.c [iso-8859-1] Thu Sep 27 21:46:39 2012 @@ -1,0 +1,218 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for wcstombs_s + */ + +#define WIN32_NO_STATUS +#include <stdio.h> +#include <stdlib.h> +#include <wine/test.h> +#include <specstrings.h> + +#define ok_errno(x) ok_hex(errno, (x)) + +#undef ok_char +#define ok_char(x,y) ok_int((unsigned)(unsigned char)(x),(unsigned)(unsigned char)(y)) +#define ok_wchar(x,y) ok_int((unsigned)(unsigned short)(x),(unsigned)(unsigned short)(y)) + +_Check_return_wat_ +_CRTIMP +errno_t +__cdecl +wcstombs_s( + _Out_opt_ size_t * pcchConverted, + _Out_writes_bytes_to_opt_(cjDstSize, *pcchConverted) + char * pmbsDst, + _In_ size_t cjDstSize, + _In_z_ const wchar_t * pwszSrc, + _In_ size_t cjMaxCount); + + +START_TEST(wcstombs_s) +{ + errno_t ret; + size_t cchConverted; + char mbsbuffer[10]; + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[5] = 0xFF; + ret = wcstombs_s(&cchConverted, mbsbuffer, 6, L"hallo", 5); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_char(mbsbuffer[5], 0); + ok_str(mbsbuffer, "hallo"); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[0] = 0xFF; + ret = wcstombs_s(&cchConverted, mbsbuffer, 1, L"", 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_wchar(mbsbuffer[0], 0); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[0] = 0xFF; + mbsbuffer[1] = 0xFF; + mbsbuffer[2] = 0xFF; + mbsbuffer[3] = 0xFF; + mbsbuffer[4] = 0xFF; + mbsbuffer[5] = 0xFF; + ret = wcstombs_s(&cchConverted, mbsbuffer, 5, L"hallo", 5); + ok_long(ret, ERANGE); + ok_size_t(cchConverted, 0); + ok_char(mbsbuffer[5], 0xFF); + ok_char(mbsbuffer[4], L'o'); + ok_char(mbsbuffer[3], L'l'); + ok_char(mbsbuffer[2], L'l'); + ok_char(mbsbuffer[1], L'a'); + ok_char(mbsbuffer[0], 0); + ok_errno(ERANGE); + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[0] = 0xFF; + mbsbuffer[1] = 0xFF; + mbsbuffer[2] = 0xFF; + mbsbuffer[3] = 0xFF; + mbsbuffer[4] = 0xFF; + mbsbuffer[5] = 0xFF; + ret = wcstombs_s(&cchConverted, mbsbuffer, 3, L"hallo", 5); + ok_long(ret, ERANGE); + ok_size_t(cchConverted, 0); + ok_char(mbsbuffer[5], 0xFF); + ok_char(mbsbuffer[4], 0xFF); + ok_char(mbsbuffer[3], 0xFF); + ok_char(mbsbuffer[2], L'l'); + ok_char(mbsbuffer[1], L'a'); + ok_char(mbsbuffer[0], 0); + ok_errno(ERANGE); + + _set_errno(0); + ret = wcstombs_s(0, 0, 0, 0, 0); + ok_long(ret, EINVAL); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, 0, 0, 0, 0); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0); + ok_errno(EINVAL); + + _set_errno(0); + mbsbuffer[0] = L'x'; + ret = wcstombs_s(0, mbsbuffer, 0, 0, 0); + ok_long(ret, EINVAL); + ok_char(mbsbuffer[0], L'x'); + ok_errno(EINVAL); + + _set_errno(0); + ret = wcstombs_s(0, mbsbuffer, 10, L"hallo", 5); + ok_long(ret, 0); + ok_errno(0); + + _set_errno(0); + ret = wcstombs_s(0, mbsbuffer, 0, L"hallo", 5); + ok_long(ret, EINVAL); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, 0, 10, L"hallo", 5); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0xf00bac); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, 0, 0, L"hallo", 5); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, 0, 5); + ok_long(ret, EINVAL); + ok_size_t(cchConverted, 0); + ok_errno(EINVAL); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, L"hallo", 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[0] = 0xAB; + mbsbuffer[1] = 0xCD; + mbsbuffer[2] = 0xAB; + mbsbuffer[3] = 0xCD; + mbsbuffer[4] = 0xAB; + mbsbuffer[5] = 0xCD; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, L"hallo", 2); + ok_long(ret, 0); + ok_size_t(cchConverted, 3); + ok_char(mbsbuffer[5], 0xCD); + ok_char(mbsbuffer[4], 0xAB); + ok_char(mbsbuffer[3], 0xCD); + ok_char(mbsbuffer[2], 0); + ok_char(mbsbuffer[1], L'a'); + ok_char(mbsbuffer[0], L'h'); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, 0, 0); + ok_long(ret, 0); + ok_size_t(cchConverted, 1); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, L"hallo", 7); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, 0, 0, L"hallo", 7); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + mbsbuffer[0] = 0xAB; + mbsbuffer[1] = 0xCD; + mbsbuffer[2] = 0xAB; + mbsbuffer[3] = 0xCD; + mbsbuffer[4] = 0xAB; + mbsbuffer[5] = 0xCD; + ret = wcstombs_s(&cchConverted, mbsbuffer, 5, L"hallo", _TRUNCATE); + ok_long(ret, STRUNCATE); + ok_size_t(cchConverted, 5); + ok_char(mbsbuffer[5], 0xCD); + ok_char(mbsbuffer[4], 0); + ok_char(mbsbuffer[3], L'l'); + ok_char(mbsbuffer[2], L'l'); + ok_char(mbsbuffer[1], L'a'); + ok_char(mbsbuffer[0], L'h'); + ok_errno(0); + + _set_errno(0); + cchConverted = 0xf00bac; + ret = wcstombs_s(&cchConverted, mbsbuffer, 10, L"hallo", -1); + ok_long(ret, 0); + ok_size_t(cchConverted, 6); + ok_errno(0); + +} Propchange: trunk/rostests/apitests/crt/wcstombs_s.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 2 months
1
0
0
0
[hbelusca] 57402: [CSRSS/CSRSRV] - Do not compile anymore the old CSRSS. - Update some headers and resource files. - Add header guards in srv.h
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 27 18:44:50 2012 New Revision: 57402 URL:
http://svn.reactos.org/svn/reactos?rev=57402&view=rev
Log: [CSRSS/CSRSRV] - Do not compile anymore the old CSRSS. - Update some headers and resource files. - Add header guards in srv.h Modified: trunk/reactos/subsystems/CMakeLists.txt trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc trunk/reactos/subsystems/win32/csrss/csrsrv/server.c trunk/reactos/subsystems/win32/csrss/csrsrv/session.c trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h trunk/reactos/subsystems/win32/csrss/csrsrv/wait.c trunk/reactos/subsystems/win32/csrss/csrss.rc Modified: trunk/reactos/subsystems/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/CMakeLists.txt?…
============================================================================== --- trunk/reactos/subsystems/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/subsystems/CMakeLists.txt [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,5 +1,4 @@ if(ARCH STREQUAL "i386") add_subdirectory(ntvdm) endif() -add_subdirectory(csr) add_subdirectory(win32) Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,5 +1,5 @@ #define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "ReactOS CSR Core Server\0" +#define REACTOS_STR_FILE_DESCRIPTION "Client/Server Runtime SubSystem Process\0" #define REACTOS_STR_INTERNAL_NAME "csrsrv\0" #define REACTOS_STR_ORIGINAL_FILENAME "csrsrv.dll\0" #include <reactos/version.rc> Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/server.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/server.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/server.c [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS CSR Sub System - * FILE: subsys/csr/csrsrv/server.c + * FILE: subsystems/win32/csrss/csrsrv/server.c * PURPOSE: CSR Server DLL Server Functions * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) */ Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/session.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/session.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/session.c [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS CSR Sub System - * FILE: subsys/csr/csrsrv/session.c + * FILE: subsystems/win32/csrss/csrsrv/session.c * PURPOSE: CSR Server DLL Session Implementation * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net) */ Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,3 +1,6 @@ +#ifndef _SRV_H +#define _SRV_H + /* PSDK/NDK Headers */ #define NTOS_MODE_USER #include <stdio.h> @@ -35,3 +38,5 @@ /* Defines */ #define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align)) #define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l)) + +#endif Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/wait.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrsrv/wait.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrsrv/wait.c [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,7 +1,7 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS CSR Sub System - * FILE: subsys/csr/csrsrv/wait.c + * FILE: subsystems/win32/csrss/csrsrv/wait.c * PURPOSE: CSR Server DLL Wait Implementation * PROGRAMMERS: Emanuele Aliberti * Alex Ionescu (alex(a)relsoft.net) Modified: trunk/reactos/subsystems/win32/csrss/csrss.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/csrss.rc [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/csrss.rc [iso-8859-1] Thu Sep 27 18:44:50 2012 @@ -1,4 +1,4 @@ -#define REACTOS_STR_FILE_DESCRIPTION "Client/Server Runtime Process\0" -#define REACTOS_STR_INTERNAL_NAME "CSRSs and CSRSrv\0" -#define REACTOS_STR_ORIGINAL_FILENAME "CSRSs.exe and CSRSrv.dll\0" +#define REACTOS_STR_FILE_DESCRIPTION "Client/Server Runtime SubSystem Process\0" +#define REACTOS_STR_INTERNAL_NAME "csrss\0" +#define REACTOS_STR_ORIGINAL_FILENAME "csrss.exe\0" #include <reactos/version.rc>
12 years, 2 months
1
0
0
0
[hbelusca] 57401: [BOOTDATA] - Correct the version signature of some inf files. CORE-6549 #comment Committed in rev.57401 #resolved
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 27 18:18:36 2012 New Revision: 57401 URL:
http://svn.reactos.org/svn/reactos?rev=57401&view=rev
Log: [BOOTDATA] - Correct the version signature of some inf files. CORE-6549 #comment Committed in rev.57401 #resolved Modified: trunk/reactos/boot/bootdata/hivecls_amd64.inf trunk/reactos/boot/bootdata/hivecls_arm.inf trunk/reactos/boot/bootdata/hivecls_i386.inf trunk/reactos/boot/bootdata/hivedef_amd64.inf trunk/reactos/boot/bootdata/hivedef_arm.inf trunk/reactos/boot/bootdata/hivedef_i386.inf trunk/reactos/boot/bootdata/hivesft_amd64.inf trunk/reactos/boot/bootdata/hivesft_arm.inf trunk/reactos/boot/bootdata/hivesft_i386.inf Modified: trunk/reactos/boot/bootdata/hivecls_amd64.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivecls_amd6…
============================================================================== --- trunk/reactos/boot/bootdata/hivecls_amd64.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivecls_amd64.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] HKLM,"SOFTWARE\Classes",,0x00000010 Modified: trunk/reactos/boot/bootdata/hivecls_arm.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivecls_arm.…
============================================================================== --- trunk/reactos/boot/bootdata/hivecls_arm.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivecls_arm.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] HKLM,"SOFTWARE\Classes",,0x00000010 Modified: trunk/reactos/boot/bootdata/hivecls_i386.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivecls_i386…
============================================================================== --- trunk/reactos/boot/bootdata/hivecls_i386.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivecls_i386.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] HKLM,"SOFTWARE\Classes",,0x00000010 Modified: trunk/reactos/boot/bootdata/hivedef_amd64.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivedef_amd6…
============================================================================== --- trunk/reactos/boot/bootdata/hivedef_amd64.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivedef_amd64.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] Modified: trunk/reactos/boot/bootdata/hivedef_arm.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivedef_arm.…
============================================================================== --- trunk/reactos/boot/bootdata/hivedef_arm.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivedef_arm.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] Modified: trunk/reactos/boot/bootdata/hivedef_i386.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivedef_i386…
============================================================================== Binary files - no diff available. Modified: trunk/reactos/boot/bootdata/hivesft_amd64.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft_amd6…
============================================================================== --- trunk/reactos/boot/bootdata/hivesft_amd64.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivesft_amd64.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] Modified: trunk/reactos/boot/bootdata/hivesft_arm.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft_arm.…
============================================================================== --- trunk/reactos/boot/bootdata/hivesft_arm.inf [iso-8859-1] (original) +++ trunk/reactos/boot/bootdata/hivesft_arm.inf [iso-8859-1] Thu Sep 27 18:18:36 2012 @@ -1,5 +1,5 @@ [Version] -Signature="$ReactOS$ +Signature="$ReactOS$" [AddReg] Modified: trunk/reactos/boot/bootdata/hivesft_i386.inf URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft_i386…
============================================================================== Binary files - no diff available.
12 years, 2 months
1
0
0
0
[hbelusca] 57400: [NTOSKRNL] Coverity code defects fixes : - Cache: CID 701441 - Config: CIDs 716570, 716669, 716760 - Dbgk: Kdbg: CIDs 716571, 515128/9, 500432 - Ex: CIDs 500156/7, 515122, 716200/...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 27 17:16:31 2012 New Revision: 57400 URL:
http://svn.reactos.org/svn/reactos?rev=57400&view=rev
Log: [NTOSKRNL] Coverity code defects fixes : - Cache: CID 701441 - Config: CIDs 716570, 716669, 716760 - Dbgk: Kdbg: CIDs 716571, 515128/9, 500432 - Ex: CIDs 500156/7, 515122, 716200/67, 701301, 514669 - Fsrtl: Fstub: CIDs 701341/2, 701288, 716770, 701302, and CIDs 716576/7/8 + 514636 + 716805 thanks to Thomas Faber - Io: CIDs 514576, 514643, 514672/3, 716203, 716269, 716581, 716591, 716713 - Ke: CIDs 515125, 716592 - Ps: CIDs 716603/4, 701422 - Ob: Po: CIDs 514671/680, 701419/420/421, 716763, 716601/2 All the details are given in the different bug reports. CORE-6677 CORE-6679 CORE-6680 CORE-6683 CORE-6686 CORE-6692 CORE-6693 CORE-6694 CORE-6695 CORE-6696 #comment Committed in rev.57400 #resolve #close Modified: trunk/reactos/lib/rtl/atom.c trunk/reactos/ntoskrnl/cache/section/swapout.c trunk/reactos/ntoskrnl/config/cminit.c trunk/reactos/ntoskrnl/config/cmparse.c trunk/reactos/ntoskrnl/config/cmsysini.c trunk/reactos/ntoskrnl/dbgk/dbgkobj.c trunk/reactos/ntoskrnl/ex/init.c trunk/reactos/ntoskrnl/ex/sysinfo.c trunk/reactos/ntoskrnl/fsrtl/filelock.c trunk/reactos/ntoskrnl/fsrtl/notify.c trunk/reactos/ntoskrnl/fstub/disksup.c trunk/reactos/ntoskrnl/fstub/fstubex.c trunk/reactos/ntoskrnl/include/internal/cm.h trunk/reactos/ntoskrnl/io/iomgr/device.c trunk/reactos/ntoskrnl/io/iomgr/driver.c trunk/reactos/ntoskrnl/io/iomgr/ioevent.c trunk/reactos/ntoskrnl/io/iomgr/iofunc.c trunk/reactos/ntoskrnl/io/iomgr/iorsrce.c trunk/reactos/ntoskrnl/io/iomgr/ramdisk.c trunk/reactos/ntoskrnl/io/iomgr/volume.c trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c trunk/reactos/ntoskrnl/kdbg/kdb_cli.c trunk/reactos/ntoskrnl/ke/i386/cpu.c trunk/reactos/ntoskrnl/ke/profobj.c trunk/reactos/ntoskrnl/ob/oblife.c trunk/reactos/ntoskrnl/ob/oblink.c trunk/reactos/ntoskrnl/ob/obsdcach.c trunk/reactos/ntoskrnl/ob/obsecure.c trunk/reactos/ntoskrnl/po/power.c trunk/reactos/ntoskrnl/ps/kill.c trunk/reactos/ntoskrnl/ps/security.c Modified: trunk/reactos/lib/rtl/atom.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/atom.c?rev=57400&r…
============================================================================== --- trunk/reactos/lib/rtl/atom.c [iso-8859-1] (original) +++ trunk/reactos/lib/rtl/atom.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -102,6 +102,12 @@ return TRUE; } + + /* + * AtomName cannot be NULL because this + * case was caught by the previous test. + */ + ASSERT(AtomName != NULL); if (*AtomName != L'#') return FALSE; Modified: trunk/reactos/ntoskrnl/cache/section/swapout.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/swa…
============================================================================== --- trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -348,7 +348,7 @@ PMM_SECTION_SEGMENT Segment = NULL; LARGE_INTEGER FileOffset; PMEMORY_AREA MemoryArea; - PMMSUPPORT AddressSpace = MmGetKernelAddressSpace(); + PMMSUPPORT AddressSpace = NULL; BOOLEAN Dirty = FALSE; PVOID Address = NULL; PEPROCESS Process = NULL; @@ -385,7 +385,6 @@ DPRINT("No segment association for %x\n", Page); } - Dirty = MmIsDirtyPageRmap(Page); DPRINTC("Trying to unmap all instances of %x\n", Page); @@ -409,7 +408,8 @@ DPRINTC("Process %x Address %x Page %x\n", Process, Address, Page); - if (RMAP_IS_SEGMENT(Address)) { + if (RMAP_IS_SEGMENT(Address)) + { entry = entry->Next; continue; } @@ -440,10 +440,10 @@ KeBugCheck(MEMORY_MANAGEMENT); } - MmLockAddressSpace(AddressSpace); - do { + MmLockAddressSpace(AddressSpace); + MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, Address); if (MemoryArea == NULL || MemoryArea->DeleteInProgress) { @@ -505,14 +505,13 @@ DPRINT1("bail\n"); goto bail; } - else Status = STATUS_MM_RESTART_OPERATION; + else + { + Status = STATUS_MM_RESTART_OPERATION; + } } - - MmLockAddressSpace(AddressSpace); } while (Status == STATUS_MM_RESTART_OPERATION); - - MmUnlockAddressSpace(AddressSpace); if (ProcRef) { Modified: trunk/reactos/ntoskrnl/config/cminit.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cminit.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/config/cminit.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cminit.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -116,13 +116,24 @@ Hive->ViewLock = ExAllocatePoolWithTag(NonPagedPool, sizeof(KGUARDED_MUTEX), TAG_CM); - if (!Hive->ViewLock) return STATUS_INSUFFICIENT_RESOURCES; + if (!Hive->ViewLock) + { + /* Cleanup allocation and fail */ + ExFreePoolWithTag(Hive, TAG_CM); + return STATUS_INSUFFICIENT_RESOURCES; + } /* Allocate the flush lock */ Hive->FlusherLock = ExAllocatePoolWithTag(NonPagedPool, sizeof(ERESOURCE), TAG_CM); - if (!Hive->FlusherLock) return STATUS_INSUFFICIENT_RESOURCES; + if (!Hive->FlusherLock) + { + /* Cleanup allocations and fail */ + ExFreePoolWithTag(Hive->ViewLock, TAG_CM); + ExFreePoolWithTag(Hive, TAG_CM); + return STATUS_INSUFFICIENT_RESOURCES; + } /* Setup the handles */ Hive->FileHandles[HFILE_TYPE_PRIMARY] = Primary; @@ -189,10 +200,10 @@ (PUNICODE_STRING)FileName); if (!NT_SUCCESS(Status)) { - /* Clear allocations and fail */ - ExFreePool(Hive->ViewLock); - ExFreePool(Hive->FlusherLock); - ExFreePool(Hive); + /* Cleanup allocations and fail */ + ExFreePoolWithTag(Hive->FlusherLock, TAG_CM); + ExFreePoolWithTag(Hive->ViewLock, TAG_CM); + ExFreePoolWithTag(Hive, TAG_CM); return Status; } @@ -205,10 +216,10 @@ /* Verify integrity */ if (CmCheckRegistry((PCMHIVE)Hive, TRUE)) { - /* Free all alocations */ - ExFreePool(Hive->ViewLock); - ExFreePool(Hive->FlusherLock); - ExFreePool(Hive); + /* Cleanup allocations and fail */ + ExFreePoolWithTag(Hive->FlusherLock, TAG_CM); + ExFreePoolWithTag(Hive->ViewLock, TAG_CM); + ExFreePoolWithTag(Hive, TAG_CM); return STATUS_REGISTRY_CORRUPT; } } @@ -231,10 +242,10 @@ NTAPI CmpOpenHiveFiles(IN PCUNICODE_STRING BaseName, IN PCWSTR Extension OPTIONAL, - IN PHANDLE Primary, - IN PHANDLE Log, - IN PULONG PrimaryDisposition, - IN PULONG LogDisposition, + OUT PHANDLE Primary, + OUT PHANDLE Log, + OUT PULONG PrimaryDisposition, + OUT PULONG LogDisposition, IN BOOLEAN CreateAllowed, IN BOOLEAN MarkAsSystemHive, IN BOOLEAN NoBuffering, Modified: trunk/reactos/ntoskrnl/config/cmparse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmparse.c?…
============================================================================== --- trunk/reactos/ntoskrnl/config/cmparse.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmparse.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -136,7 +136,7 @@ if (Length > 0xFFFF) goto Exit; /* Check if we need a new buffer */ - if (Length > ObjectName->MaximumLength) + if (Length > ObjectName->MaximumLength) { /* We do -- allocate one */ NewBuffer = ExAllocatePoolWithTag(PagedPool, Length, TAG_CM); @@ -334,7 +334,7 @@ KeyNode->MaxClassLen = 0; KeyNode->NameLength = CmpCopyName(Hive, KeyNode->Name, Name); if (KeyNode->NameLength < Name->Length) KeyNode->Flags |= KEY_COMP_NAME; - + /* Create the KCB */ Kcb = CmpCreateKeyControlBlock(Hive, *KeyCell, @@ -349,7 +349,7 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Quickie; } - + /* Sanity check */ ASSERT(Kcb->RefCount == 1); @@ -357,7 +357,7 @@ KeyBody->NotifyBlock = NULL; KeyBody->ProcessID = PsGetCurrentProcessId(); KeyBody->KeyControlBlock = Kcb; - + /* Link it with the KCB */ EnlistKeyBodyWithKCB(KeyBody, 0); @@ -745,7 +745,7 @@ DPRINT1("Invalid link node attempt\n"); return STATUS_ACCESS_DENIED; } - + /* Check if the parent is being deleted */ if (ParentKcb->Delete) { @@ -754,7 +754,7 @@ Status = STATUS_OBJECT_NAME_NOT_FOUND; goto Exit; } - + /* Allocate a link node */ LinkCell = HvAllocateCell(Hive, FIELD_OFFSET(CM_KEY_NODE, Name) + @@ -767,14 +767,14 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Get the key cell */ KeyCell = Context->ChildHive.KeyCell; if (KeyCell != HCELL_NIL) { /* Hive exists! */ ChildCell = KeyCell; - + /* Get the node data */ KeyNode = (PCM_KEY_NODE)HvGetCell(Context->ChildHive.KeyHive, ChildCell); if (!KeyNode) @@ -784,12 +784,12 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Fill out the data */ KeyNode->Parent = LinkCell; KeyNode->Flags |= KEY_HIVE_ENTRY | KEY_NO_DELETE; HvReleaseCell(Context->ChildHive.KeyHive, ChildCell); - + /* Now open the key cell */ KeyNode = (PCM_KEY_NODE)HvGetCell(Context->ChildHive.KeyHive, KeyCell); if (!KeyNode) @@ -799,7 +799,7 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Open the parent */ Status = CmpDoOpen(Context->ChildHive.KeyHive, KeyCell, @@ -834,13 +834,13 @@ Context->ChildHive.KeyHive->BaseBlock->RootCell = ChildCell; } } - + /* Check if open or create suceeded */ if (NT_SUCCESS(Status)) { /* Mark the cell dirty */ HvMarkCellDirty(Context->ChildHive.KeyHive, ChildCell, FALSE); - + /* Get the key node */ KeyNode = HvGetCell(Context->ChildHive.KeyHive, ChildCell); if (!KeyNode) @@ -850,14 +850,14 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Release it */ HvReleaseCell(Context->ChildHive.KeyHive, ChildCell); - + /* Set the parent and flags */ KeyNode->Parent = LinkCell; KeyNode->Flags |= KEY_HIVE_ENTRY | KEY_NO_DELETE; - + /* Get the link node */ KeyNode = HvGetCell(Hive, LinkCell); if (!KeyNode) @@ -867,7 +867,7 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Set it up */ KeyNode->Signature = CM_LINK_NODE_SIGNATURE; KeyNode->Flags = KEY_HIVE_EXIT | KEY_NO_DELETE; @@ -876,7 +876,7 @@ if (KeyNode->NameLength < Name.Length) KeyNode->Flags |= KEY_COMP_NAME; KeQuerySystemTime(&TimeStamp); KeyNode->LastWriteTime = TimeStamp; - + /* Clear out the rest */ KeyNode->SubKeyCounts[Stable] = 0; KeyNode->SubKeyCounts[Volatile] = 0; @@ -885,12 +885,12 @@ KeyNode->ValueList.Count = 0; KeyNode->ValueList.List = HCELL_NIL; KeyNode->ClassLength = 0; - + /* Reference the root node */ KeyNode->ChildHiveReference.KeyHive = Context->ChildHive.KeyHive; KeyNode->ChildHiveReference.KeyCell = ChildCell; HvReleaseCell(Hive, LinkCell); - + /* Get the parent node */ KeyNode = HvGetCell(Hive, Cell); if (!KeyNode) @@ -900,14 +900,14 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto Exit; } - + /* Now add the subkey */ if (!CmpAddSubKey(Hive, Cell, LinkCell)) { /* Failure! We don't handle this yet! */ ASSERT(FALSE); } - + /* Get the key body */ KeyBody = (PCM_KEY_BODY)*Object; @@ -915,12 +915,12 @@ ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyCell == Cell); ASSERT(KeyBody->KeyControlBlock->ParentKcb->KeyHive == Hive); ASSERT(KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen == KeyNode->MaxNameLen); - + /* Update the timestamp */ KeQuerySystemTime(&TimeStamp); KeyNode->LastWriteTime = TimeStamp; KeyBody->KeyControlBlock->ParentKcb->KcbLastWriteTime = TimeStamp; - + /* Check if we need to update name maximum */ if (KeyNode->MaxNameLen < Name.Length) { @@ -928,14 +928,14 @@ KeyNode->MaxNameLen = Name.Length; KeyBody->KeyControlBlock->ParentKcb->KcbMaxNameLen = Name.Length; } - + /* Check if we need toupdate class length maximum */ if (KeyNode->MaxClassLen < Context->Class.Length) { /* Update it */ KeyNode->MaxClassLen = Context->Class.Length; } - + /* Release the cell */ HvReleaseCell(Hive, Cell); } @@ -944,7 +944,7 @@ /* Release the link cell */ HvReleaseCell(Hive, LinkCell); } - + Exit: /* Release the flusher locks and return status */ return Status; @@ -965,11 +965,11 @@ ASSERT(*ReleaseHive != NULL); HvReleaseCell((*ReleaseHive), *ReleaseCell); } - + /* Get the link references */ *Hive = (*KeyNode)->ChildHiveReference.KeyHive; *Cell = (*KeyNode)->ChildHiveReference.KeyCell; - + /* Get the new node */ *KeyNode = (PCM_KEY_NODE)HvGetCell((*Hive), *Cell); if (*KeyNode) @@ -1004,10 +1004,10 @@ /* Calculate hash values */ *TotalRemainingSubkeys = 0xBAADF00D; - + /* Lock the registry */ CmpLockRegistry(); - + /* Return hive and cell data */ *Hive = (*Kcb)->KeyHive; *Cell = (*Kcb)->KeyCell; @@ -1060,7 +1060,7 @@ /* Fail if this isn't a key object */ if (ObjectType != CmpKeyObjectType) return STATUS_OBJECT_TYPE_MISMATCH; - + /* Copy the remaining name */ Current = *RemainingName; @@ -1070,9 +1070,12 @@ /* It isn't, so no context */ ParseContext = NULL; } - + /* Grab the KCB */ Kcb = ((PCM_KEY_BODY)ParseObject)->KeyControlBlock; + + /* Sanity check */ + ASSERT(Kcb != NULL); /* Fail if the key was marked as deleted */ if (Kcb->Delete) @@ -1089,10 +1092,13 @@ &TotalSubkeys, NULL, &LockedKcbs); - + /* This is now the parent */ ParentKcb = Kcb; - + + /* Sanity check */ + ASSERT(ParentKcb != NULL); + /* Check if everything was found cached */ if (!TotalRemainingSubkeys) ASSERTMSG("Caching not implemented", FALSE); @@ -1127,7 +1133,7 @@ goto Quickie; } Current.MaximumLength += NextName.MaximumLength; - + /* Parse the symlink */ if (CmpGetSymbolicLink(Hive, CompleteName, @@ -1146,7 +1152,7 @@ /* We're done */ goto Quickie; } - + /* Get the key node */ Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!Node) @@ -1174,7 +1180,7 @@ Cell = NextCell; Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell); if (!Node) ASSERT(FALSE); - + /* Check if this was the last key */ if (Last) { @@ -1189,7 +1195,7 @@ &CellToRelease); if (!Node) ASSERT(FALSE); } - + /* Do the open */ Status = CmpDoOpen(Hive, Cell, @@ -1214,11 +1220,11 @@ Status = STATUS_OBJECT_NAME_NOT_FOUND; } } - + /* We are done */ break; } - + /* Is this an exit node */ if (Node->Flags & KEY_HIVE_EXIT) { @@ -1239,7 +1245,7 @@ 0, &NextName); if (!Kcb) ASSERT(FALSE); - + /* Dereference the parent and set the new one */ CmpDereferenceKeyControlBlock(ParentKcb); ParentKcb = Kcb; @@ -1275,7 +1281,7 @@ ParentKcb, Object); } - + /* Check for reparse (in this case, someone beat us) */ if (Status == STATUS_REPARSE) break; @@ -1295,7 +1301,7 @@ { /* Save the next name */ Current.Buffer = NextName.Buffer; - + /* Validate the current name string length */ if (Current.Length + NextName.Length > MAXUSHORT) { @@ -1304,7 +1310,7 @@ break; } Current.Length += NextName.Length; - + /* Validate the current name string maximum length */ if (Current.MaximumLength + NextName.MaximumLength > MAXUSHORT) { @@ -1313,7 +1319,7 @@ break; } Current.MaximumLength += NextName.MaximumLength; - + /* Parse the symlink */ if (CmpGetSymbolicLink(Hive, CompleteName, @@ -1363,7 +1369,7 @@ { /* Nothing to do */ } - + /* We're done */ break; } @@ -1378,7 +1384,7 @@ /* Dereference the parent if it exists */ Quickie: if (ParentKcb) CmpDereferenceKeyControlBlock(ParentKcb); - + /* Unlock the registry */ CmpUnlockRegistry(); return Status; Modified: trunk/reactos/ntoskrnl/config/cmsysini.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c…
============================================================================== --- trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/config/cmsysini.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -1104,7 +1104,7 @@ //ULONG RegStart; ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize; PCMHIVE CmHive; - HANDLE PrimaryHandle, LogHandle; + HANDLE PrimaryHandle = NULL, LogHandle = NULL; NTSTATUS Status = STATUS_SUCCESS; PVOID ErrorParameters; PAGED_CODE(); Modified: trunk/reactos/ntoskrnl/dbgk/dbgkobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/dbgkobj.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/dbgk/dbgkobj.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/dbgk/dbgkobj.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -192,7 +192,7 @@ ObDereferenceObject(Process); /* Free the debug event */ - ExFreePool(DebugEvent); + ExFreePoolWithTag(DebugEvent, 'EgbD'); } } @@ -418,7 +418,7 @@ /* Dereference process and thread and free the event */ ObDereferenceObject(DebugEvent->Process); ObDereferenceObject(DebugEvent->Thread); - ExFreePool(DebugEvent); + ExFreePoolWithTag(DebugEvent, 'EgbD'); } VOID Modified: trunk/reactos/ntoskrnl/ex/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=574…
============================================================================== --- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -211,7 +211,7 @@ PLIST_ENTRY ListHead, NextEntry; PMEMORY_ALLOCATION_DESCRIPTOR MdBlock; ULONG NlsTablesEncountered = 0; - SIZE_T NlsTableSizes[3]; /* 3 NLS tables */ + SIZE_T NlsTableSizes[3] = {0, 0, 0}; /* 3 NLS tables */ /* Check if this is boot-time phase 0 initialization */ if (!ExpInitializationPhase) @@ -405,12 +405,11 @@ if (!NT_SUCCESS(Status)) { /* Failed, display error */ - p = InitBuffer->DebugBuffer; - _snwprintf(p, - 256 * sizeof(WCHAR), + _snwprintf(InitBuffer->DebugBuffer, + sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR), L"INIT: Unable to allocate Process Parameters. 0x%lx", Status); - RtlInitUnicodeString(&DebugString, p); + RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer); ZwDisplayString(&DebugString); /* Bugcheck the system */ @@ -434,12 +433,11 @@ if (!NT_SUCCESS(Status)) { /* Failed, display error */ - p = InitBuffer->DebugBuffer; - _snwprintf(p, - 256 * sizeof(WCHAR), + _snwprintf(InitBuffer->DebugBuffer, + sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR), L"INIT: Unable to allocate Process Environment. 0x%lx", Status); - RtlInitUnicodeString(&DebugString, p); + RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer); ZwDisplayString(&DebugString); /* Bugcheck the system */ @@ -560,12 +558,11 @@ if (!NT_SUCCESS(Status)) { /* Failed, display error */ - p = InitBuffer->DebugBuffer; - _snwprintf(p, - 256 * sizeof(WCHAR), + _snwprintf(InitBuffer->DebugBuffer, + sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR), L"INIT: Unable to create Session Manager. 0x%lx", Status); - RtlInitUnicodeString(&DebugString, p); + RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer); ZwDisplayString(&DebugString); /* Bugcheck the system */ @@ -577,12 +574,11 @@ if (!NT_SUCCESS(Status)) { /* Failed, display error */ - p = InitBuffer->DebugBuffer; - _snwprintf(p, - 256 * sizeof(WCHAR), + _snwprintf(InitBuffer->DebugBuffer, + sizeof(InitBuffer->DebugBuffer)/sizeof(WCHAR), L"INIT: Unable to resume Session Manager. 0x%lx", Status); - RtlInitUnicodeString(&DebugString, p); + RtlInitUnicodeString(&DebugString, InitBuffer->DebugBuffer); ZwDisplayString(&DebugString); /* Bugcheck the system */ Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -150,7 +150,7 @@ Prcb = KeGetCurrentPrcb(); - ScaledIdle = Prcb->IdleThread->KernelTime * 100; + ScaledIdle = (ULONGLONG)Prcb->IdleThread->KernelTime * 100; TotalTime = Prcb->KernelTime + Prcb->UserTime; if (TotalTime != 0) *CpuUsage = (ULONG)(100 - (ScaledIdle / TotalTime)); @@ -785,7 +785,7 @@ } } } - if (!ImageNameLength && Process != PsIdleProcess && Process->ImageFileName) + if (!ImageNameLength && Process != PsIdleProcess) { ImageNameLength = (USHORT)strlen(Process->ImageFileName) * sizeof(WCHAR); } @@ -824,7 +824,7 @@ /* Release the memory allocated by SeLocateProcessImageName */ ExFreePool(ProcessImageName); } - else if (Process->ImageFileName) + else { RtlInitAnsiString(&ImageName, Process->ImageFileName); RtlAnsiStringToUnicodeString(&SpiCurrent->ImageName, &ImageName, FALSE); Modified: trunk/reactos/ntoskrnl/fsrtl/filelock.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/filelock.c?…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/filelock.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/filelock.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -380,12 +380,13 @@ if (!FileLock->LockInformation) { LockInfo = ExAllocatePoolWithTag(NonPagedPool, sizeof(LOCK_INFORMATION), 'FLCK'); - FileLock->LockInformation = LockInfo; - if (!FileLock) { + if (!LockInfo) + { IoStatus->Status = STATUS_NO_MEMORY; return FALSE; } - + FileLock->LockInformation = LockInfo; + LockInfo->BelongsTo = FileLock; InitializeListHead(&LockInfo->SharedLocks); @@ -416,13 +417,13 @@ ToInsert.Exclusive.FileLock.ProcessId = Process->UniqueProcessId; ToInsert.Exclusive.FileLock.Key = Key; ToInsert.Exclusive.FileLock.ExclusiveLock = ExclusiveLock; - + Conflict = RtlInsertElementGenericTable (FileLock->LockInformation, &ToInsert, sizeof(ToInsert), &InsertedNew); - + if (Conflict && !InsertedNew) { if (Conflict->Exclusive.FileLock.ExclusiveLock || ExclusiveLock) @@ -475,8 +476,9 @@ for (i = 0; i < RtlNumberGenericTableElements(&LockInfo->RangeTable); i++) { Conflict = RtlGetElementGenericTable(&LockInfo->RangeTable, i); + /* The first argument will be inserted as a shared range */ - if (LockCompare(&LockInfo->RangeTable, Conflict, &ToInsert) == GenericEqual) + if (Conflict && (LockCompare(&LockInfo->RangeTable, Conflict, &ToInsert) == GenericEqual)) { if (Conflict->Exclusive.FileLock.ExclusiveLock) { @@ -520,8 +522,9 @@ Conflict->Exclusive.FileLock.StartingByte.LowPart, Conflict->Exclusive.FileLock.EndingByte.HighPart, Conflict->Exclusive.FileLock.EndingByte.LowPart); - Conflict = FsRtlpRebuildSharedLockRange - (FileLock, LockInfo, &ToInsert); + Conflict = FsRtlpRebuildSharedLockRange(FileLock, + LockInfo, + &ToInsert); if (!Conflict) { IoStatus->Status = STATUS_NO_MEMORY; @@ -918,7 +921,6 @@ PLIST_ENTRY SharedRangeEntry; PLOCK_SHARED_RANGE WatchSharedRange; COMBINED_LOCK_ELEMENT RemadeElement; - PCOMBINED_LOCK_ELEMENT RemadeElementInserted = NULL; Find.Exclusive.FileLock.StartingByte = SharedRange->Start; Find.Exclusive.FileLock.EndingByte = SharedRange->End; SharedEntry = SharedRange->Entry.Flink; @@ -939,30 +941,28 @@ SharedRangeEntry != &InternalInfo->SharedLocks; SharedRangeEntry = SharedRangeEntry->Flink) { - COMBINED_LOCK_ELEMENT Find; + COMBINED_LOCK_ELEMENT LockElement; WatchSharedRange = CONTAINING_RECORD(SharedRangeEntry, LOCK_SHARED_RANGE, Entry); - Find.Exclusive.FileLock.StartingByte = WatchSharedRange->Start; - Find.Exclusive.FileLock.EndingByte = WatchSharedRange->End; - if (LockCompare(&InternalInfo->RangeTable, &RemadeElement, &Find) != GenericEqual) + LockElement.Exclusive.FileLock.StartingByte = WatchSharedRange->Start; + LockElement.Exclusive.FileLock.EndingByte = WatchSharedRange->End; + if (LockCompare(&InternalInfo->RangeTable, &RemadeElement, &LockElement) != GenericEqual) { DPRINT("Skipping range %08x%08x:%08x%08x\n", - Find.Exclusive.FileLock.StartingByte.HighPart, - Find.Exclusive.FileLock.StartingByte.LowPart, - Find.Exclusive.FileLock.EndingByte.HighPart, - Find.Exclusive.FileLock.EndingByte.LowPart); + LockElement.Exclusive.FileLock.StartingByte.HighPart, + LockElement.Exclusive.FileLock.StartingByte.LowPart, + LockElement.Exclusive.FileLock.EndingByte.HighPart, + LockElement.Exclusive.FileLock.EndingByte.LowPart); continue; } DPRINT("Re-creating range %08x%08x:%08x%08x\n", - Find.Exclusive.FileLock.StartingByte.HighPart, - Find.Exclusive.FileLock.StartingByte.LowPart, - Find.Exclusive.FileLock.EndingByte.HighPart, - Find.Exclusive.FileLock.EndingByte.LowPart); + LockElement.Exclusive.FileLock.StartingByte.HighPart, + LockElement.Exclusive.FileLock.StartingByte.LowPart, + LockElement.Exclusive.FileLock.EndingByte.HighPart, + LockElement.Exclusive.FileLock.EndingByte.LowPart); RtlZeroMemory(&RemadeElement, sizeof(RemadeElement)); RemadeElement.Exclusive.FileLock.StartingByte = WatchSharedRange->Start; RemadeElement.Exclusive.FileLock.EndingByte = WatchSharedRange->End; - RemadeElementInserted = - FsRtlpRebuildSharedLockRange - (FileLock, InternalInfo, &RemadeElement); + FsRtlpRebuildSharedLockRange(FileLock, InternalInfo, &RemadeElement); } } else Modified: trunk/reactos/ntoskrnl/fsrtl/notify.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/notify.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/fsrtl/notify.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fsrtl/notify.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -586,6 +586,13 @@ /* Allocate new notification */ NotifyChange = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE, sizeof(NOTIFY_CHANGE), 'FSrN'); + + /* + * If NotifyChange == NULL then an + * exception was already raised. + */ + ASSERT(NotifyChange != NULL); + RtlZeroMemory(NotifyChange, sizeof(NOTIFY_CHANGE)); /* Set basic information */ Modified: trunk/reactos/ntoskrnl/fstub/disksup.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/disksup.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/fstub/disksup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fstub/disksup.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -446,38 +446,46 @@ DPRINT("RDiskCount %d\n", RDiskCount); - Buffer1 = (PWSTR)ExAllocatePoolWithTag(PagedPool, - 64 * sizeof(WCHAR), TAG_FILE_SYSTEM); - Buffer2 = (PWSTR)ExAllocatePoolWithTag(PagedPool, - 32 * sizeof(WCHAR), TAG_FILE_SYSTEM); - - PartialInformation = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePoolWithTag(PagedPool, - sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(REG_DISK_MOUNT_INFO), TAG_FILE_SYSTEM); - - if (!Buffer1 || !Buffer2 || !PartialInformation) return; + Buffer1 = ExAllocatePoolWithTag(PagedPool, + 64 * sizeof(WCHAR), + TAG_FILE_SYSTEM); + if (!Buffer1) return; + + Buffer2 = ExAllocatePoolWithTag(PagedPool, + 32 * sizeof(WCHAR), + TAG_FILE_SYSTEM); + if (!Buffer2) + { + ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM); + return; + } + + PartialInformation = ExAllocatePoolWithTag(PagedPool, + sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(REG_DISK_MOUNT_INFO), + TAG_FILE_SYSTEM); + if (!PartialInformation) + { + ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM); + ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM); + return; + } DiskMountInfo = (PREG_DISK_MOUNT_INFO) PartialInformation->Data; - /* Open or Create the 'MountedDevices' key */ + /* Create or open the 'MountedDevices' key */ RtlInitUnicodeString(&UnicodeString1, L"\\Registry\\Machine\\SYSTEM\\MountedDevices"); InitializeObjectAttributes(&ObjectAttributes, &UnicodeString1, - OBJ_CASE_INSENSITIVE, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); - Status = ZwOpenKey(&hKey, + Status = ZwCreateKey(&hKey, KEY_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - Status = ZwCreateKey(&hKey, - KEY_ALL_ACCESS, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - NULL); - } + &ObjectAttributes, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + NULL); if (!NT_SUCCESS(Status)) { hKey = NULL; @@ -535,7 +543,8 @@ ExFreePoolWithTag(PartialInformation, TAG_FILE_SYSTEM); ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM); ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM); - if (hKey) ZwClose(hKey); + if (hKey) ObCloseHandle(hKey, KernelMode); + return; } RtlZeroMemory(LayoutArray, @@ -951,10 +960,7 @@ ExFreePoolWithTag(PartialInformation, TAG_FILE_SYSTEM); ExFreePoolWithTag(Buffer2, TAG_FILE_SYSTEM); ExFreePoolWithTag(Buffer1, TAG_FILE_SYSTEM); - if (hKey) - { - ZwClose(hKey); - } + if (hKey) ObCloseHandle(hKey, KernelMode); } #endif Modified: trunk/reactos/ntoskrnl/fstub/fstubex.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fstub/fstubex.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/fstub/fstubex.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/fstub/fstubex.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -985,7 +985,7 @@ if ((Disk->SectorCount - 1ULL) != EfiHeader.AlternateLBA) { /* We'll update it. First, count number of sectors needed to store partitions */ - SectorsForPartitions = (EfiHeader.NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize; + SectorsForPartitions = ((ULONGLONG)EfiHeader.NumberOfEntries * PARTITION_ENTRY_SIZE) / Disk->SectorSize; /* Then set first usable LBA: Legacy MBR + GPT header + Partitions entries */ EfiHeader.FirstUsableLBA = SectorsForPartitions + 2; /* Then set last usable LBA: Last sector - GPT header - Partitions entries */ Modified: trunk/reactos/ntoskrnl/include/internal/cm.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/cm.h [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -801,10 +801,10 @@ CmpOpenHiveFiles( IN PCUNICODE_STRING BaseName, IN PCWSTR Extension OPTIONAL, - IN PHANDLE Primary, - IN PHANDLE Log, - IN PULONG PrimaryDisposition, - IN PULONG LogDisposition, + OUT PHANDLE Primary, + OUT PHANDLE Log, + OUT PULONG PrimaryDisposition, + OUT PULONG LogDisposition, IN BOOLEAN CreateAllowed, IN BOOLEAN MarkAsSystemHive, IN BOOLEAN NoBuffering, Modified: trunk/reactos/ntoskrnl/io/iomgr/device.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/device.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/device.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -227,11 +227,14 @@ NULL, &Event, &StatusBlock); - Status = IoCallDriver(DeviceObject, Irp); - if (Status == STATUS_PENDING) + if (Irp) { - /* Wait on the driver */ - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } } /* Remove the flag */ Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -795,6 +795,11 @@ &MissingApiName, &MissingDriverName, &LoadedImports); + + /* Free the temporary buffer */ + ExFreePoolWithTag(Buffer, TAG_LDR_WSTR); + + /* Check the result of the imports resolution */ if (!NT_SUCCESS(Status)) return Status; /* Return */ Modified: trunk/reactos/ntoskrnl/io/iomgr/ioevent.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/ioevent.…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/ioevent.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/ioevent.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -42,12 +42,17 @@ if (!NT_SUCCESS(Status)) return NULL; /* Get a handle to it */ - ObReferenceObjectByHandle(Handle, - 0, - ExEventObjectType, - KernelMode, - (PVOID*)&Event, - NULL); + Status = ObReferenceObjectByHandle(Handle, + 0, + ExEventObjectType, + KernelMode, + (PVOID*)&Event, + NULL); + if (!NT_SUCCESS(Status)) + { + ZwClose(Handle); + return NULL; + } /* Dereference the extra count, and return the handle */ ObDereferenceObject(Event); Modified: trunk/reactos/ntoskrnl/io/iomgr/iofunc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iofunc.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iofunc.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -119,7 +119,7 @@ { NTSTATUS Status; PKNORMAL_ROUTINE NormalRoutine; - PVOID NormalContext; + PVOID NormalContext = NULL; KIRQL OldIrql; PAGED_CODE(); IOTRACE(IO_API_DEBUG, "IRP: %p. DO: %p. FO: %p \n", Modified: trunk/reactos/ntoskrnl/io/iomgr/iorsrce.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iorsrce.…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iorsrce.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iorsrce.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -701,7 +701,7 @@ UNICODE_STRING LinkTarget, KeyName; OBJECT_ATTRIBUTES ObjectAttributes; HANDLE LinkHandle, RegistryHandle, KeyHandle; - WCHAR LinkTargetBuffer[256], KeyNameBuffer[sizeof(L"SystemPartition") / sizeof(WCHAR)]; + WCHAR LinkTargetBuffer[256]; UNICODE_STRING CmRegistryMachineSystemName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM"); ASSERT(NtSystemPartitionDeviceName->MaximumLength >= NtSystemPartitionDeviceName->Length + sizeof(WCHAR)); @@ -760,13 +760,9 @@ return; } - /* We'll store in Setup subkey, and as we love fun, we use only one buffer for three writings... */ - wcscpy(KeyNameBuffer, L"Setup"); - KeyName.Length = sizeof(L"Setup") - sizeof(UNICODE_NULL); - KeyName.MaximumLength = sizeof(L"Setup"); - KeyName.Buffer = KeyNameBuffer; - - /* So, open or create the subkey */ + /* Open or create the Setup subkey where we'll store in */ + RtlInitUnicodeString(&KeyName, L"Setup"); + Status = IopCreateRegistryKeyEx(&KeyHandle, RegistryHandle, &KeyName, @@ -784,9 +780,7 @@ } /* Prepare first data writing... */ - wcscpy(KeyNameBuffer, L"SystemPartition"); - KeyName.Length = sizeof(L"SystemPartition") - sizeof(UNICODE_NULL); - KeyName.MaximumLength = sizeof(L"SystemPartition"); + RtlInitUnicodeString(&KeyName, L"SystemPartition"); /* Write SystemPartition value which is the target of the symbolic link */ Status = ZwSetValueKey(KeyHandle, @@ -800,10 +794,8 @@ DPRINT("Failed writing SystemPartition value!\n"); } - /* Prepare for second data writing... */ - wcscpy(KeyName.Buffer, L"OsLoaderPath"); - KeyName.Length = sizeof(L"OsLoaderPath") - sizeof(UNICODE_NULL); - KeyName.MaximumLength = sizeof(L"OsLoaderPath"); + /* Prepare for second data writing... */ + RtlInitUnicodeString(&KeyName, L"OsLoaderPath"); /* Remove trailing slash if any (one slash only excepted) */ if (OsLoaderPathName->Length > sizeof(WCHAR) && Modified: trunk/reactos/ntoskrnl/io/iomgr/ramdisk.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/ramdisk.…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/ramdisk.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/ramdisk.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -224,7 +224,7 @@ // Build the symbolic link name and target // _snwprintf(SourceString, - sizeof(SourceString), + sizeof(SourceString)/sizeof(WCHAR), L"\\Device\\Ramdisk%wZ", &GuidString); SymbolicLinkName.Length = 38; Modified: trunk/reactos/ntoskrnl/io/iomgr/volume.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/volume.c…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/volume.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/volume.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -377,11 +377,14 @@ NULL, &Event, &StatusBlock); - Status = IoCallDriver(DeviceObject, Irp); - if (Status == STATUS_PENDING) - { - /* Wait on the driver */ - KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + if (Irp) + { + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait on the driver */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } } /* Reset the event */ Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpnoti…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpnotify.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -80,7 +80,7 @@ if (!NT_SUCCESS(Status)) { KeReleaseGuardedMutex(&PnpNotifyListLock); - ExFreePool(NotificationStructure); + ExFreePoolWithTag(NotificationStructure, TAG_PNP_NOTIFY); return; } break; @@ -177,21 +177,22 @@ case EventCategoryTargetDeviceChange: { Status = IoGetRelatedTargetDevice(ChangeEntry->FileObject, &EntryDeviceObject); - if (NT_SUCCESS(Status)) - { - if (DeviceObject == EntryDeviceObject) - { - if (Event == &GUID_PNP_CUSTOM_NOTIFICATION) - { - ((PTARGET_DEVICE_CUSTOM_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; - } - else - { - ((PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; - } - CallCurrentEntry = TRUE; - } + if (NT_SUCCESS(Status)) + { + if (DeviceObject == EntryDeviceObject) + { + if (Event == &GUID_PNP_CUSTOM_NOTIFICATION) + { + ((PTARGET_DEVICE_CUSTOM_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; + } + else + { + ((PTARGET_DEVICE_REMOVAL_NOTIFICATION)NotificationStructure)->FileObject = ChangeEntry->FileObject; + } + CallCurrentEntry = TRUE; + } } + break; } default: { Modified: trunk/reactos/ntoskrnl/kdbg/kdb_cli.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kdbg/kdb_cli.c?re…
============================================================================== --- trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/kdbg/kdb_cli.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -864,7 +864,7 @@ else if (Argv[0][0] == 'c') /* cregs */ { ULONG Cr0, Cr2, Cr3, Cr4; - KDESCRIPTOR Gdtr, Idtr; + KDESCRIPTOR Gdtr = {0, 0, 0}, Idtr = {0, 0, 0}; USHORT Ldtr; static const PCHAR Cr0Bits[32] = { " PE", " MP", " EM", " TS", " ET", " NE", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, Modified: trunk/reactos/ntoskrnl/ke/i386/cpu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/cpu.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/cpu.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -1137,7 +1137,7 @@ INIT_FUNCTION KiI386PentiumLockErrataFixup(VOID) { - KDESCRIPTOR IdtDescriptor; + KDESCRIPTOR IdtDescriptor = {0, 0, 0}; PKIDTENTRY NewIdt, NewIdt2; /* Allocate memory for a new IDT */ Modified: trunk/reactos/ntoskrnl/ke/profobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/profobj.c?rev=…
============================================================================== --- trunk/reactos/ntoskrnl/ke/profobj.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/profobj.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -142,7 +142,7 @@ KeLowerIrql(OldIrql); /* Free the pool */ - if (FreeBuffer) ExFreePool(SourceBuffer); + if (FreeBuffer) ExFreePoolWithTag(SourceBuffer, 'forP'); /* Return whether we could start the profile */ return StartedProfile; Modified: trunk/reactos/ntoskrnl/ob/oblife.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblife.c?rev=5…
============================================================================== --- trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/oblife.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -1429,7 +1429,7 @@ POBJECT_HEADER ObjectHeader = NULL; POBJECT_HANDLE_ATTRIBUTE_INFORMATION HandleFlags; POBJECT_BASIC_INFORMATION BasicInfo; - ULONG InfoLength; + ULONG InfoLength = 0; PVOID Object = NULL; NTSTATUS Status; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); Modified: trunk/reactos/ntoskrnl/ob/oblink.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/oblink.c?rev=5…
============================================================================== --- trunk/reactos/ntoskrnl/ob/oblink.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/oblink.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -595,7 +595,12 @@ ExAllocatePoolWithTag(PagedPool, CapturedLinkTarget.MaximumLength, TAG_SYMLINK_TARGET); - if (!SymbolicLink->LinkTarget.Buffer) return STATUS_NO_MEMORY; + if (!SymbolicLink->LinkTarget.Buffer) + { + /* Dereference the symbolic link object and fail */ + ObDereferenceObject(SymbolicLink); + return STATUS_NO_MEMORY; + } /* Copy it */ RtlCopyMemory(SymbolicLink->LinkTarget.Buffer, Modified: trunk/reactos/ntoskrnl/ob/obsdcach.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obsdcach.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ob/obsdcach.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/obsdcach.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -427,7 +427,7 @@ *OutputSecurityDescriptor = &SdHeader->SecurityDescriptor; /* Free anything that we may have had to create */ - if (NewHeader) ExFreePool(NewHeader); + if (NewHeader) ExFreePoolWithTag(NewHeader, TAG_OB_SD_CACHE); return STATUS_SUCCESS; } Modified: trunk/reactos/ntoskrnl/ob/obsecure.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ob/obsecure.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ob/obsecure.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ob/obsecure.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -217,7 +217,7 @@ { POBJECT_HEADER ObjectHeader; POBJECT_TYPE ObjectType; - PSECURITY_DESCRIPTOR SecurityDescriptor; + PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; BOOLEAN SdAllocated; BOOLEAN Result = TRUE; ACCESS_MASK GrantedAccess = 0; @@ -280,7 +280,7 @@ { POBJECT_HEADER ObjectHeader; POBJECT_TYPE ObjectType; - PSECURITY_DESCRIPTOR SecurityDescriptor; + PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; BOOLEAN SdAllocated; BOOLEAN Result; ACCESS_MASK GrantedAccess = 0; @@ -338,7 +338,7 @@ { POBJECT_HEADER ObjectHeader; POBJECT_TYPE ObjectType; - PSECURITY_DESCRIPTOR SecurityDescriptor; + PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; BOOLEAN SdAllocated; BOOLEAN Result; ACCESS_MASK GrantedAccess = 0; Modified: trunk/reactos/ntoskrnl/po/power.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/po/power.c?rev=57…
============================================================================== --- trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/po/power.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -79,11 +79,11 @@ PIO_STACK_LOCATION IrpSp; PIRP Irp; NTSTATUS Status; - + KeInitializeEvent(&Event, NotificationEvent, FALSE); - + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER, DeviceObject, NULL, @@ -91,13 +91,14 @@ NULL, &Event, &IoStatusBlock); - + if (!Irp) return STATUS_INSUFFICIENT_RESOURCES; + IrpSp = IoGetNextIrpStackLocation(Irp); IrpSp->MinorFunction = IRP_MN_QUERY_POWER; IrpSp->Parameters.Power.Type = SystemPowerState; IrpSp->Parameters.Power.State.SystemState = SystemState; IrpSp->Parameters.Power.ShutdownType = PowerAction; - + Status = PoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) { @@ -108,7 +109,7 @@ NULL); Status = IoStatusBlock.Status; } - + return Status; } @@ -120,11 +121,11 @@ PIO_STACK_LOCATION IrpSp; PIRP Irp; NTSTATUS Status; - + KeInitializeEvent(&Event, NotificationEvent, FALSE); - + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_POWER, DeviceObject, NULL, @@ -132,13 +133,14 @@ NULL, &Event, &IoStatusBlock); - + if (!Irp) return STATUS_INSUFFICIENT_RESOURCES; + IrpSp = IoGetNextIrpStackLocation(Irp); IrpSp->MinorFunction = IRP_MN_SET_POWER; IrpSp->Parameters.Power.Type = SystemPowerState; IrpSp->Parameters.Power.State.SystemState = SystemState; IrpSp->Parameters.Power.ShutdownType = PowerAction; - + Status = PoCallDriver(DeviceObject, Irp); if (Status == STATUS_PENDING) { @@ -149,7 +151,7 @@ NULL); Status = IoStatusBlock.Status; } - + return Status; } Modified: trunk/reactos/ntoskrnl/ps/kill.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/kill.c?rev=574…
============================================================================== --- trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/kill.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -1006,7 +1006,7 @@ } /* We failed, free the APC */ - ExFreePool(Apc); + ExFreePoolWithTag(Apc, TAG_TERMINATE_APC); /* Return Status */ return Status; Modified: trunk/reactos/ntoskrnl/ps/security.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/security.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ps/security.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ps/security.c [iso-8859-1] Thu Sep 27 17:16:31 2012 @@ -221,7 +221,7 @@ PACCESS_TOKEN NewToken = Token; NTSTATUS Status, AccessStatus; BOOLEAN Result, SdAllocated; - PSECURITY_DESCRIPTOR SecurityDescriptor; + PSECURITY_DESCRIPTOR SecurityDescriptor = NULL; SECURITY_SUBJECT_CONTEXT SubjectContext; PSTRACE(PS_SECURITY_DEBUG, "Process: %p Token: %p\n", Process, Token); @@ -638,7 +638,7 @@ if (OldData) { /* Someone beat us to it, free our copy */ - ExFreePool(Impersonation); + ExFreePoolWithTag(Impersonation, TAG_PS_IMPERSONATION); Impersonation = OldData; } }
12 years, 2 months
1
0
0
0
[hbelusca] 57399: [NTOSKRNL] - Code formatting - It's my first commit \o/ CORE-6687 #comment Committed. #resolve
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Sep 27 13:39:14 2012 New Revision: 57399 URL:
http://svn.reactos.org/svn/reactos?rev=57399&view=rev
Log: [NTOSKRNL] - Code formatting - It's my first commit \o/ CORE-6687 #comment Committed. #resolve Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnproot…
============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnproot.c [iso-8859-1] Thu Sep 27 13:39:14 2012 @@ -543,10 +543,8 @@ /* Terminate the string */ SubKeyInfo->Name[SubKeyInfo->NameLength / sizeof(WCHAR)] = 0; - _snwprintf( - DevicePath, - sizeof(DevicePath) / sizeof(WCHAR), - L"%s\\%s", REGSTR_KEY_ROOTENUM, KeyInfo->Name); + _snwprintf(DevicePath, sizeof(DevicePath) / sizeof(WCHAR), + L"%s\\%s", REGSTR_KEY_ROOTENUM, KeyInfo->Name); DPRINT("Found device %S\\%s!\n", DevicePath, SubKeyInfo->Name); if (LocateChildDevice(DeviceExtension, DevicePath, SubKeyInfo->Name, &Device) == STATUS_NO_SUCH_DEVICE) {
12 years, 2 months
1
0
0
0
[ekohl] 57398: [ADVAPI32] Implement LsaQuerySecurityObject and LsaSetSecurityObject.
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Sep 27 09:57:43 2012 New Revision: 57398 URL:
http://svn.reactos.org/svn/reactos?rev=57398&view=rev
Log: [ADVAPI32] Implement LsaQuerySecurityObject and LsaSetSecurityObject. Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec trunk/reactos/dll/win32/advapi32/sec/lsa.c trunk/reactos/include/psdk/ntsecapi.h Modified: trunk/reactos/dll/win32/advapi32/advapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/advapi3…
============================================================================== --- trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/advapi32.spec [iso-8859-1] Thu Sep 27 09:57:43 2012 @@ -388,7 +388,7 @@ @ stdcall LsaQueryInfoTrustedDomain(long long long) @ stdcall LsaQueryInformationPolicy(ptr long ptr) @ stdcall LsaQuerySecret(ptr ptr ptr ptr ptr) -@ stub LsaQuerySecurityObject +@ stdcall LsaQuerySecurityObject(ptr long ptr) @ stdcall LsaQueryTrustedDomainInfo(ptr ptr long ptr) @ stdcall LsaQueryTrustedDomainInfoByName(ptr ptr long ptr) @ stdcall LsaRegisterPolicyChangeNotification(long long) @@ -401,7 +401,7 @@ @ stub LsaSetInformationTrustedDomain @ stdcall LsaSetQuotasForAccount(ptr ptr) @ stdcall LsaSetSecret(ptr ptr ptr) -@ stub LsaSetSecurityObject +@ stdcall LsaSetSecurityObject(ptr long ptr) @ stdcall LsaSetSystemAccessAccount(ptr long) @ stdcall LsaSetTrustedDomainInfoByName(ptr ptr long ptr) @ stdcall LsaSetTrustedDomainInformation(ptr ptr long ptr) Modified: trunk/reactos/dll/win32/advapi32/sec/lsa.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/sec/lsa…
============================================================================== --- trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] Thu Sep 27 09:57:43 2012 @@ -1381,6 +1381,51 @@ /* + * @implemented + */ +NTSTATUS +WINAPI +LsaQuerySecurityObject(IN LSA_HANDLE ObjectHandle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR *SecurityDescriptor) +{ + LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer; + PLSAPR_SR_SECURITY_DESCRIPTOR SdPointer; + NTSTATUS Status; + + TRACE("LsaQuerySecurityObject(%p %lx %p)\n", + ObjectHandle, SecurityInformation, SecurityDescriptor); + + SdBuffer.Length = 0; + SdBuffer.SecurityDescriptor = NULL; + + SdPointer = &SdBuffer; + + RpcTryExcept + { + Status = LsarQuerySecurityObject((LSAPR_HANDLE)ObjectHandle, + SecurityInformation, + &SdPointer); + if (NT_SUCCESS(Status)) + { + *SecurityDescriptor = SdBuffer.SecurityDescriptor; + } + else + { + *SecurityDescriptor = NULL; + } + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + + return Status; +} + + +/* * @unimplemented */ NTSTATUS @@ -1666,6 +1711,60 @@ */ NTSTATUS WINAPI +LsaSetSecurityObject(IN LSA_HANDLE ObjectHandle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor) +{ + LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer = {0, NULL}; + ULONG SdLength = 0; + NTSTATUS Status; + + TRACE("LsaSetSecurityObject(%p %lx %p)\n", + ObjectHandle, SecurityInformation, SecurityDescriptor); + + Status = RtlMakeSelfRelativeSD(SecurityDescriptor, + NULL, + &SdLength); + if (Status != STATUS_BUFFER_TOO_SMALL) + return STATUS_INVALID_PARAMETER; + + SdBuffer.SecurityDescriptor = MIDL_user_allocate(SdLength); + if (SdBuffer.SecurityDescriptor == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Status = RtlMakeSelfRelativeSD(SecurityDescriptor, + (PSECURITY_DESCRIPTOR)SdBuffer.SecurityDescriptor, + &SdLength); + if (!NT_SUCCESS(Status)) + goto done; + + SdBuffer.Length = SdLength; + + RpcTryExcept + { + Status = LsarSetSecurityObject((LSAPR_HANDLE)ObjectHandle, + SecurityInformation, + &SdBuffer); + } + RpcExcept(EXCEPTION_EXECUTE_HANDLER) + { + Status = I_RpcMapWin32Status(RpcExceptionCode()); + } + RpcEndExcept; + +done: + if (SdBuffer.SecurityDescriptor != NULL) + MIDL_user_free(SdBuffer.SecurityDescriptor); + + return Status; +} + + +/* + * @implemented + */ +NTSTATUS +WINAPI LsaSetSystemAccessAccount(IN LSA_HANDLE AccountHandle, IN ULONG SystemAccess) { Modified: trunk/reactos/include/psdk/ntsecapi.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntsecapi.h?re…
============================================================================== --- trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/ntsecapi.h [iso-8859-1] Thu Sep 27 09:57:43 2012 @@ -709,6 +709,7 @@ NTSTATUS NTAPI LsaOpenPolicy(PLSA_UNICODE_STRING,PLSA_OBJECT_ATTRIBUTES, ACCESS_MASK,PLSA_HANDLE); NTSTATUS NTAPI LsaOpenSecret(LSA_HANDLE, PLSA_UNICODE_STRING, ACCESS_MASK, PLSA_HANDLE); +NTSTATUS NTAPI LsaQuerySecurityObject(LSA_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR*); NTSTATUS NTAPI LsaOpenTrustedDomain(LSA_HANDLE,PSID,ACCESS_MASK,PLSA_HANDLE); NTSTATUS NTAPI LsaOpenTrustedDomainByName(LSA_HANDLE,PLSA_UNICODE_STRING, ACCESS_MASK,PLSA_HANDLE); @@ -728,9 +729,10 @@ PLSA_UNICODE_STRING*); NTSTATUS NTAPI LsaSetDomainInformationPolicy(LSA_HANDLE, POLICY_DOMAIN_INFORMATION_CLASS,PVOID); -NTSTATUS NTAPI LsaSetInformationPolicy(LSA_HANDLE,POLICY_INFORMATION_CLASS, PVOID); +NTSTATUS NTAPI LsaSetInformationPolicy(LSA_HANDLE,POLICY_INFORMATION_CLASS,PVOID); NTSTATUS NTAPI LsaSetQuotasForAccount(LSA_HANDLE,PQUOTA_LIMITS); NTSTATUS NTAPI LsaSetSecret(LSA_HANDLE,PLSA_UNICODE_STRING,PLSA_UNICODE_STRING); +NTSTATUS NTAPI LsaSetSecurityObject(LSA_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR); NTSTATUS NTAPI LsaSetSystemAccessAccount(LSA_HANDLE,ULONG); NTSTATUS NTAPI LsaSetTrustedDomainInformation(LSA_HANDLE,PSID, TRUSTED_INFORMATION_CLASS,PVOID); @@ -740,7 +742,7 @@ PLSA_UNICODE_STRING); typedef NTSTATUS (NTAPI *PSAM_PASSWORD_NOTIFICATION_ROUTINE)(PUNICODE_STRING, ULONG,PUNICODE_STRING); -typedef BOOLEAN (NTAPI *PSAM_INIT_NOTIFICATION_ROUTINE)(void); +typedef BOOLEAN (NTAPI *PSAM_INIT_NOTIFICATION_ROUTINE)(VOID); typedef BOOLEAN (NTAPI *PSAM_PASSWORD_FILTER_ROUTINE)(PUNICODE_STRING,PUNICODE_STRING, PUNICODE_STRING,BOOLEAN); #ifdef __cplusplus
12 years, 2 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
24
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Results per page:
10
25
50
100
200