diff --git a/reactos/lib/kernel32/file/curdir.c b/reactos/lib/kernel32/file/curdir.c index 2e0c613ee9b..0f4698ddbbe 100644 --- a/reactos/lib/kernel32/file/curdir.c +++ b/reactos/lib/kernel32/file/curdir.c @@ -16,7 +16,7 @@ /* GLOBALS *******************************************************************/ -static unsigned short CurrentDirectoryW[MAX_PATH]; +static unsigned short CurrentDirectoryW[MAX_PATH] = {0,}; static unsigned short SystemDirectoryW[MAX_PATH]; @@ -24,9 +24,7 @@ static unsigned short WindowsDirectoryW[MAX_PATH]; /* FUNCTIONS *****************************************************************/ -DWORD -STDCALL -GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) +DWORD STDCALL GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) { UINT uSize,i; if ( lpBuffer == NULL ) @@ -44,32 +42,32 @@ GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer) return uSize; } -DWORD -STDCALL -GetCurrentDirectoryW( - DWORD nBufferLength, - LPWSTR lpBuffer - ) +DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer) { UINT uSize; + + dprintf("CurrentDirectoryW %w\n",CurrentDirectoryW); + if ( lpBuffer == NULL ) return 0; uSize = lstrlenW(CurrentDirectoryW); if ( nBufferLength > uSize ) lstrcpynW(lpBuffer,CurrentDirectoryW,uSize); + dprintf("GetCurrentDirectoryW() = %w\n",lpBuffer); + return uSize; } -BOOL -STDCALL -SetCurrentDirectoryA(LPCSTR lpPathName) +BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName) { UINT i; - if ( lpPathName == NULL ); + dprintf("SetCurrentDirectoryA(lpPathName %s)\n",lpPathName); + + if ( lpPathName == NULL ) return FALSE; - if ( lstrlenA(lpPathName) > MAX_PATH ); + if ( lstrlenA(lpPathName) > MAX_PATH ) return FALSE; i = 0; while ((lpPathName[i])!=0 && i < MAX_PATH) @@ -78,7 +76,9 @@ SetCurrentDirectoryA(LPCSTR lpPathName) i++; } CurrentDirectoryW[i] = 0; - + + dprintf("CurrentDirectoryW = '%w'\n",CurrentDirectoryW); + return(TRUE); } @@ -89,9 +89,9 @@ SetCurrentDirectoryW( LPCWSTR lpPathName ) { - if ( lpPathName == NULL ); + if ( lpPathName == NULL ) return FALSE; - if ( lstrlenW(lpPathName) > MAX_PATH ); + if ( lstrlenW(lpPathName) > MAX_PATH ) return FALSE; lstrcpyW(CurrentDirectoryW,lpPathName); return(TRUE); @@ -220,4 +220,4 @@ GetWindowsDirectoryW( lstrcpynW(lpBuffer,WindowsDirectoryW,uPathSize); return uPathSize; -} \ No newline at end of file +} diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index 5b1be11ed53..fc51db2cffb 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -59,114 +59,6 @@ SetFileApisToOEM(VOID) return; } -HANDLE STDCALL CreateFileA(LPCSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile) -{ - - WCHAR FileNameW[MAX_PATH]; - ULONG i = 0; - - OutputDebugStringA("CreateFileA\n"); - - while ((*lpFileName)!=0 && i < MAX_PATH) - { - FileNameW[i] = *lpFileName; - lpFileName++; - i++; - } - FileNameW[i] = 0; - - return CreateFileW(FileNameW,dwDesiredAccess,dwShareMode, lpSecurityAttributes, - dwCreationDisposition,dwFlagsAndAttributes, hTemplateFile); -} - - -HANDLE STDCALL CreateFileW(LPCWSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile) -{ - HANDLE FileHandle; - NTSTATUS Status; - - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING FileNameString; - ULONG Flags = 0; - WCHAR PathNameW[MAX_PATH]; - WCHAR *FilePart; - UINT Len = 0; - - OutputDebugStringA("CreateFileW\n"); - - if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED)) - { - Flags |= FILE_SYNCHRONOUS_IO_ALERT; - } - - #if 0 - - if ( ( ( dwCreationDisposition & OPEN_EXISTING ) == OPEN_EXISTING ) || - ( ( dwCreationDisposition & TRUNCATE_EXISTING ) == TRUNCATE_EXISTING ) ) - Len = SearchPathW(NULL,lpFileName,NULL,MAX_PATH,PathNameW,&FilePart); - if ( Len == 0 ) - return NULL; - else { - Len = GetCurrentDirectoryW(MAX_PATH,PathNameW); - if ( Len == 0 ) - return NULL; - if ( PathNameW[Len-1] != L'\\' ) { - PathNameW[Len] = L'\\'; - PathNameW[Len+1] = 0; - } - lstrcatW(PathNameW,lpFileName); - } - FileNameString.Length = lstrlenW( PathNameW)*sizeof(WCHAR); - - if ( FileNameString.Length == 0 ) - return NULL; - - if ( FileNameString.Length > MAX_PATH ) - return NULL; - - FileNameString.Buffer = (WCHAR *)PathNameW; - FileNameString.MaximumLength = FileNameString.Length; - #endif - - FileNameString.Buffer = lpFileName; - FileNameString.Length = - FileNameString.MaximumLength = lstrlenW(lpFileName) * sizeof(WCHAR); - - ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); - ObjectAttributes.RootDirectory = NULL; - ObjectAttributes.ObjectName = &FileNameString; - ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE; - ObjectAttributes.SecurityDescriptor = NULL; - ObjectAttributes.SecurityQualityOfService = NULL; - - Status = NtCreateFile(&FileHandle, - dwDesiredAccess, - &ObjectAttributes, - &IoStatusBlock, - NULL, - dwFlagsAndAttributes, - dwShareMode, - dwCreationDisposition, - Flags, - NULL, - 0); - return(FileHandle); -} - - WINBASEAPI VOID WINAPI @@ -230,16 +122,18 @@ WINBOOL STDCALL ReadFile(HANDLE hFile, { HANDLE hEvent = NULL; - LARGE_INTEGER Offset; + PLARGE_INTEGER Offset; + LARGE_INTEGER ByteOffset; NTSTATUS errCode; PIO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IIosb; - if ( lpOverLapped != NULL ) + if ( lpOverLapped != NULL ) { - Offset.LowPart = lpOverLapped->Offset; - Offset.HighPart = lpOverLapped->OffsetHigh; + ByteOffset.LowPart = lpOverLapped->Offset; + ByteOffset.HighPart = lpOverLapped->OffsetHigh; + Offset = &ByteOffset; lpOverLapped->Internal = STATUS_PENDING; hEvent = lpOverLapped->hEvent; IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped; @@ -247,6 +141,7 @@ WINBOOL STDCALL ReadFile(HANDLE hFile, else { IoStatusBlock = &IIosb; + Offset = NULL; } errCode = NtReadFile(hFile, @@ -256,8 +151,8 @@ WINBOOL STDCALL ReadFile(HANDLE hFile, IoStatusBlock, lpBuffer, nNumberOfBytesToRead, - &Offset, - NULL); + Offset, + NULL); if ( !NT_SUCCESS(errCode) ) { SetLastError(RtlNtStatusToDosError(errCode));