Corrected some bugs in the system libraries

svn path=/trunk/; revision=125
This commit is contained in:
David Welch 1998-12-19 18:49:28 +00:00
parent 316713be6b
commit e017266cd0
2 changed files with 28 additions and 133 deletions

View file

@ -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)
@ -79,6 +77,8 @@ SetCurrentDirectoryA(LPCSTR lpPathName)
}
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);

View file

@ -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,7 +122,8 @@ 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;
@ -238,8 +131,9 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
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,7 +151,7 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
IoStatusBlock,
lpBuffer,
nNumberOfBytesToRead,
&Offset,
Offset,
NULL);
if ( !NT_SUCCESS(errCode) )
{