Author: aandrejevic
Date: Sun May 3 01:45:57 2015
New Revision: 67526
URL:
http://svn.reactos.org/svn/reactos?rev=67526&view=rev
Log:
[FAST486]
Update the copyright year (better late than never).
Push the error code inside Fast486InterruptInternal, to make the size of the
pushed value on the stack correct.
Update the CPL in Fast486TaskSwitch.
Modified:
trunk/reactos/include/reactos/libs/fast486/fast486.h
trunk/reactos/lib/fast486/common.c
trunk/reactos/lib/fast486/common.h
trunk/reactos/lib/fast486/common.inl
trunk/reactos/lib/fast486/debug.c
trunk/reactos/lib/fast486/extraops.c
trunk/reactos/lib/fast486/extraops.h
trunk/reactos/lib/fast486/fast486.c
trunk/reactos/lib/fast486/fpu.c
trunk/reactos/lib/fast486/fpu.h
trunk/reactos/lib/fast486/opcodes.c
trunk/reactos/lib/fast486/opcodes.h
trunk/reactos/lib/fast486/opgroups.c
trunk/reactos/lib/fast486/opgroups.h
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
Modified: trunk/reactos/include/reactos/libs/fast486/fast486.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/fast4…
==============================================================================
--- trunk/reactos/include/reactos/libs/fast486/fast486.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/libs/fast486/fast486.h [iso-8859-1] Sun May 3 01:45:57
2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fast486.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/common.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.c?rev=6…
==============================================================================
--- trunk/reactos/lib/fast486/common.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -264,7 +264,9 @@
static inline BOOLEAN
FASTCALL
Fast486InterruptInternal(PFAST486_STATE State,
- PFAST486_IDT_ENTRY IdtEntry)
+ PFAST486_IDT_ENTRY IdtEntry,
+ BOOLEAN PushErrorCode,
+ ULONG ErrorCode)
{
USHORT SegmentSelector = IdtEntry->Selector;
ULONG Offset = MAKELONG(IdtEntry->Offset, IdtEntry->OffsetHigh);
@@ -400,6 +402,16 @@
/* Push the instruction pointer */
if (!Fast486StackPush(State, State->InstPtr.Long)) goto Cleanup;
+ if (PushErrorCode)
+ {
+ /* Push the error code */
+ if (!Fast486StackPush(State, ErrorCode))
+ {
+ /* An exception occurred */
+ goto Cleanup;
+ }
+ }
+
if ((GateType == FAST486_IDT_INT_GATE) || (GateType == FAST486_IDT_INT_GATE_32))
{
/* Disable interrupts after a jump to an interrupt gate handler */
@@ -448,7 +460,7 @@
}
/* Perform the interrupt */
- if (!Fast486InterruptInternal(State, &IdtEntry))
+ if (!Fast486InterruptInternal(State, &IdtEntry, FALSE, 0))
{
/* Exception occurred */
return FALSE;
@@ -463,6 +475,8 @@
FAST486_EXCEPTIONS ExceptionCode,
ULONG ErrorCode)
{
+ FAST486_IDT_ENTRY IdtEntry;
+
/* Increment the exception count */
State->ExceptionCount++;
@@ -491,8 +505,8 @@
/* Restore the IP to the saved IP */
State->InstPtr = State->SavedInstPtr;
- /* Perform the interrupt */
- if (!Fast486PerformInterrupt(State, ExceptionCode))
+ /* Get the interrupt vector */
+ if (!Fast486GetIntVector(State, ExceptionCode, &IdtEntry))
{
/*
* If this function failed, that means Fast486Exception
@@ -501,18 +515,18 @@
return;
}
- if (EXCEPTION_HAS_ERROR_CODE(ExceptionCode)
- && (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE))
- {
- /* Push the error code */
- if (!Fast486StackPush(State, ErrorCode))
- {
- /*
- * If this function failed, that means Fast486Exception
- * was called again, so just return in this case.
- */
- return;
- }
+ /* Perform the interrupt */
+ if (!Fast486InterruptInternal(State,
+ &IdtEntry,
+ EXCEPTION_HAS_ERROR_CODE(ExceptionCode)
+ && (State->ControlRegisters[FAST486_REG_CR0]
& FAST486_CR0_PE),
+ ErrorCode))
+ {
+ /*
+ * If this function failed, that means Fast486Exception
+ * was called again, so just return in this case.
+ */
+ return;
}
/* Reset the exception count */
@@ -702,10 +716,16 @@
/* Flush the TLB */
if (State->Tlb) RtlZeroMemory(State->Tlb, NUM_TLB_ENTRIES * sizeof(ULONG));
+ /* Update the CPL */
+ State->Cpl = GET_SEGMENT_RPL(NewTss.Cs);
+
#ifndef FAST486_NO_PREFETCH
/* Context switching invalidates the prefetch */
State->PrefetchValid = FALSE;
#endif
+
+ /* Update the CPL */
+ State->Cpl = GET_SEGMENT_RPL(NewTss.Cs);
/* Load the registers */
State->InstPtr.Long = State->SavedInstPtr.Long = NewTss.Eip;
Modified: trunk/reactos/lib/fast486/common.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.h?rev=6…
==============================================================================
--- trunk/reactos/lib/fast486/common.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.h [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/common.inl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
==============================================================================
--- trunk/reactos/lib/fast486/common.inl [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/common.inl [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* common.inl
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -782,6 +782,9 @@
{
// TODO: NOT IMPLEMENTED
UNIMPLEMENTED;
+
+ Fast486Exception(State, FAST486_EXCEPTION_UD);
+ return FALSE;
}
default:
Modified: trunk/reactos/lib/fast486/debug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/debug.c?rev=67…
==============================================================================
--- trunk/reactos/lib/fast486/debug.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/debug.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fast486dbg.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/extraops.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/extraops.c?rev…
==============================================================================
--- trunk/reactos/lib/fast486/extraops.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/extraops.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* extraops.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/extraops.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/extraops.h?rev…
==============================================================================
--- trunk/reactos/lib/fast486/extraops.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/extraops.h [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* extraops.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/fast486.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fast486.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/fast486.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fast486.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fast486.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/fpu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fpu.c?rev=6752…
==============================================================================
--- trunk/reactos/lib/fast486/fpu.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fpu.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fpu.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/fpu.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/fpu.h?rev=6752…
==============================================================================
--- trunk/reactos/lib/fast486/fpu.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/fpu.h [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* fpu.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/opcodes.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* opcodes.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/opcodes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.h?rev=…
==============================================================================
--- trunk/reactos/lib/fast486/opcodes.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opcodes.h [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* opcodes.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/opgroups.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opgroups.c?rev…
==============================================================================
--- trunk/reactos/lib/fast486/opgroups.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opgroups.c [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* opgroups.c
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/lib/fast486/opgroups.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opgroups.h?rev…
==============================================================================
--- trunk/reactos/lib/fast486/opgroups.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fast486/opgroups.h [iso-8859-1] Sun May 3 01:45:57 2015
@@ -2,7 +2,7 @@
* Fast486 386/486 CPU Emulation Library
* opgroups.h
*
- * Copyright (C) 2014 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
+ * Copyright (C) 2015 Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Sun May 3
01:45:57 2015
@@ -146,6 +146,7 @@
{
WORD LastError;
HANDLE FileHandle;
+ PDOS_DEVICE_NODE Node;
WORD DosHandle;
ACCESS_MASK AccessMode = 0;
DWORD ShareMode = 0;
@@ -163,185 +164,193 @@
// explains what those AccessShareModes are (see the uStyle flag).
//
- /* Parse the access mode */
- switch (AccessShareModes & 0x03)
- {
- /* Read-only */
- case 0:
- AccessMode = GENERIC_READ;
- break;
-
- /* Write only */
- case 1:
- AccessMode = GENERIC_WRITE;
- break;
-
- /* Read and write */
- case 2:
- AccessMode = GENERIC_READ | GENERIC_WRITE;
- break;
-
- /* Invalid */
- default:
- return ERROR_INVALID_PARAMETER;
- }
-
- /* Parse the share mode */
- switch ((AccessShareModes >> 4) & 0x07)
- {
- /* Compatibility mode */
- case 0:
- ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
- break;
-
- /* No sharing "DenyAll" */
- case 1:
- ShareMode = 0;
- break;
-
- /* No write share "DenyWrite" */
- case 2:
- ShareMode = FILE_SHARE_READ;
- break;
-
- /* No read share "DenyRead" */
- case 3:
- ShareMode = FILE_SHARE_WRITE;
- break;
-
- /* Full share "DenyNone" */
- case 4:
- ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
- break;
-
- /* Invalid */
- default:
- return ERROR_INVALID_PARAMETER;
- }
-
- /*
- * Parse the creation action flags:
- *
- * Bitfields for action:
- * Bit(s) Description
- *
- * 7-4 Action if file does not exist.
- * 0000 Fail
- * 0001 Create
- *
- * 3-0 Action if file exists.
- * 0000 Fail
- * 0001 Open
- * 0010 Replace/open
- */
- switch (CreateActionFlags)
- {
- /* If the file exists, fail, otherwise, fail also */
- case 0x00:
- // A special case is used after the call to CreateFileA if it succeeds,
- // in order to close the opened handle and return an adequate error.
- CreationDisposition = OPEN_EXISTING;
- break;
-
- /* If the file exists, open it, otherwise, fail */
- case 0x01:
- CreationDisposition = OPEN_EXISTING;
- break;
-
- /* If the file exists, replace it, otherwise, fail */
- case 0x02:
- CreationDisposition = TRUNCATE_EXISTING;
- break;
-
- /* If the file exists, fail, otherwise, create it */
- case 0x10:
- CreationDisposition = CREATE_NEW;
- break;
-
- /* If the file exists, open it, otherwise, create it */
- case 0x11:
- CreationDisposition = OPEN_ALWAYS;
- break;
-
- /* If the file exists, replace it, otherwise, create it */
- case 0x12:
- CreationDisposition = CREATE_ALWAYS;
- break;
-
- /* Invalid */
- default:
- return ERROR_INVALID_PARAMETER;
- }
-
- /* Check for inheritance */
- InheritableFile = ((AccessShareModes & 0x80) == 0);
-
- /* Assign default security attributes to the file, and set the inheritance flag */
- SecurityAttributes.nLength = sizeof(SecurityAttributes);
- SecurityAttributes.lpSecurityDescriptor = NULL;
- SecurityAttributes.bInheritHandle = InheritableFile;
-
- /* Open the file */
- FileHandle = CreateFileA(FilePath,
- AccessMode,
- ShareMode,
- &SecurityAttributes,
- CreationDisposition,
- Attributes,
- NULL);
-
- LastError = (WORD)GetLastError();
-
- if (FileHandle == INVALID_HANDLE_VALUE)
- {
- /* Return the error code */
- return LastError;
- }
-
- /*
- * Special case: CreateActionFlags == 0, we must fail because
- * the file exists (if it didn't exist we already failed).
- */
- if (CreateActionFlags == 0)
- {
- /* Close the file and return the error code */
- CloseHandle(FileHandle);
- return ERROR_FILE_EXISTS;
- }
-
- /* Set the creation status */
- switch (CreateActionFlags)
- {
- case 0x01:
- *CreationStatus = 0x01; // The file was opened
- break;
-
- case 0x02:
- *CreationStatus = 0x03; // The file was replaced
- break;
-
- case 0x10:
- *CreationStatus = 0x02; // The file was created
- break;
-
- case 0x11:
- {
- if (LastError == ERROR_ALREADY_EXISTS)
+ Node = DosGetDevice(FilePath);
+ if (Node != NULL)
+ {
+ if (Node->OpenRoutine) Node->OpenRoutine(Node);
+ }
+ else
+ {
+ /* Parse the access mode */
+ switch (AccessShareModes & 0x03)
+ {
+ /* Read-only */
+ case 0:
+ AccessMode = GENERIC_READ;
+ break;
+
+ /* Write only */
+ case 1:
+ AccessMode = GENERIC_WRITE;
+ break;
+
+ /* Read and write */
+ case 2:
+ AccessMode = GENERIC_READ | GENERIC_WRITE;
+ break;
+
+ /* Invalid */
+ default:
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* Parse the share mode */
+ switch ((AccessShareModes >> 4) & 0x07)
+ {
+ /* Compatibility mode */
+ case 0:
+ ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ break;
+
+ /* No sharing "DenyAll" */
+ case 1:
+ ShareMode = 0;
+ break;
+
+ /* No write share "DenyWrite" */
+ case 2:
+ ShareMode = FILE_SHARE_READ;
+ break;
+
+ /* No read share "DenyRead" */
+ case 3:
+ ShareMode = FILE_SHARE_WRITE;
+ break;
+
+ /* Full share "DenyNone" */
+ case 4:
+ ShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ break;
+
+ /* Invalid */
+ default:
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /*
+ * Parse the creation action flags:
+ *
+ * Bitfields for action:
+ * Bit(s) Description
+ *
+ * 7-4 Action if file does not exist.
+ * 0000 Fail
+ * 0001 Create
+ *
+ * 3-0 Action if file exists.
+ * 0000 Fail
+ * 0001 Open
+ * 0010 Replace/open
+ */
+ switch (CreateActionFlags)
+ {
+ /* If the file exists, fail, otherwise, fail also */
+ case 0x00:
+ // A special case is used after the call to CreateFileA if it succeeds,
+ // in order to close the opened handle and return an adequate error.
+ CreationDisposition = OPEN_EXISTING;
+ break;
+
+ /* If the file exists, open it, otherwise, fail */
+ case 0x01:
+ CreationDisposition = OPEN_EXISTING;
+ break;
+
+ /* If the file exists, replace it, otherwise, fail */
+ case 0x02:
+ CreationDisposition = TRUNCATE_EXISTING;
+ break;
+
+ /* If the file exists, fail, otherwise, create it */
+ case 0x10:
+ CreationDisposition = CREATE_NEW;
+ break;
+
+ /* If the file exists, open it, otherwise, create it */
+ case 0x11:
+ CreationDisposition = OPEN_ALWAYS;
+ break;
+
+ /* If the file exists, replace it, otherwise, create it */
+ case 0x12:
+ CreationDisposition = CREATE_ALWAYS;
+ break;
+
+ /* Invalid */
+ default:
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* Check for inheritance */
+ InheritableFile = ((AccessShareModes & 0x80) == 0);
+
+ /* Assign default security attributes to the file, and set the inheritance flag
*/
+ SecurityAttributes.nLength = sizeof(SecurityAttributes);
+ SecurityAttributes.lpSecurityDescriptor = NULL;
+ SecurityAttributes.bInheritHandle = InheritableFile;
+
+ /* Open the file */
+ FileHandle = CreateFileA(FilePath,
+ AccessMode,
+ ShareMode,
+ &SecurityAttributes,
+ CreationDisposition,
+ Attributes,
+ NULL);
+
+ LastError = (WORD)GetLastError();
+
+ if (FileHandle == INVALID_HANDLE_VALUE)
+ {
+ /* Return the error code */
+ return LastError;
+ }
+
+ /*
+ * Special case: CreateActionFlags == 0, we must fail because
+ * the file exists (if it didn't exist we already failed).
+ */
+ if (CreateActionFlags == 0)
+ {
+ /* Close the file and return the error code */
+ CloseHandle(FileHandle);
+ return ERROR_FILE_EXISTS;
+ }
+
+ /* Set the creation status */
+ switch (CreateActionFlags)
+ {
+ case 0x01:
*CreationStatus = 0x01; // The file was opened
- else
+ break;
+
+ case 0x02:
+ *CreationStatus = 0x03; // The file was replaced
+ break;
+
+ case 0x10:
*CreationStatus = 0x02; // The file was created
-
- break;
- }
-
- case 0x12:
- {
- if (LastError == ERROR_ALREADY_EXISTS)
- *CreationStatus = 0x03; // The file was replaced
- else
- *CreationStatus = 0x02; // The file was created
-
- break;
+ break;
+
+ case 0x11:
+ {
+ if (LastError == ERROR_ALREADY_EXISTS)
+ *CreationStatus = 0x01; // The file was opened
+ else
+ *CreationStatus = 0x02; // The file was created
+
+ break;
+ }
+
+ case 0x12:
+ {
+ if (LastError == ERROR_ALREADY_EXISTS)
+ *CreationStatus = 0x03; // The file was replaced
+ else
+ *CreationStatus = 0x02; // The file was created
+
+ break;
+ }
}
}
@@ -357,11 +366,19 @@
Descriptor = DosGetFileDescriptor(DescriptorId);
RtlZeroMemory(Descriptor, sizeof(*Descriptor));
- Descriptor->OpenMode = AccessShareModes;
- Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
- Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = CurrentPsp;
- Descriptor->Win32Handle = FileHandle;
+ if (Node != NULL)
+ {
+ Descriptor->DevicePointer = Node->Driver;
+ Descriptor->DeviceInfo = Node->DeviceAttributes | (1 << 7);
+ }
+ else
+ {
+ Descriptor->OpenMode = AccessShareModes;
+ Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
+ Descriptor->Size = GetFileSize(FileHandle, NULL);
+ Descriptor->OwnerPsp = CurrentPsp;
+ Descriptor->Win32Handle = FileHandle;
+ }
/* Open the DOS handle */
DosHandle = DosOpenHandle(DescriptorId);
@@ -383,6 +400,7 @@
WORD Attributes)
{
HANDLE FileHandle;
+ PDOS_DEVICE_NODE Node;
WORD DosHandle;
BYTE DescriptorId;
PDOS_FILE_DESCRIPTOR Descriptor;
@@ -390,18 +408,26 @@
DPRINT("DosCreateFile: FilePath \"%s\", CreationDisposition 0x%04X,
Attributes 0x%04X\n",
FilePath, CreationDisposition, Attributes);
- /* Create the file */
- FileHandle = CreateFileA(FilePath,
- GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- NULL,
- CreationDisposition,
- Attributes,
- NULL);
- if (FileHandle == INVALID_HANDLE_VALUE)
- {
- /* Return the error code */
- return (WORD)GetLastError();
+ Node = DosGetDevice(FilePath);
+ if (Node != NULL)
+ {
+ if (Node->OpenRoutine) Node->OpenRoutine(Node);
+ }
+ else
+ {
+ /* Create the file */
+ FileHandle = CreateFileA(FilePath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ CreationDisposition,
+ Attributes,
+ NULL);
+ if (FileHandle == INVALID_HANDLE_VALUE)
+ {
+ /* Return the error code */
+ return (WORD)GetLastError();
+ }
}
DescriptorId = DosFindFreeDescriptor();
@@ -416,10 +442,18 @@
Descriptor = DosGetFileDescriptor(DescriptorId);
RtlZeroMemory(Descriptor, sizeof(*Descriptor));
- Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
- Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = CurrentPsp;
- Descriptor->Win32Handle = FileHandle;
+ if (Node != NULL)
+ {
+ Descriptor->DevicePointer = Node->Driver;
+ Descriptor->DeviceInfo = Node->DeviceAttributes | (1 << 7);
+ }
+ else
+ {
+ Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
+ Descriptor->Size = GetFileSize(FileHandle, NULL);
+ Descriptor->OwnerPsp = CurrentPsp;
+ Descriptor->Win32Handle = FileHandle;
+ }
/* Open the DOS handle */
DosHandle = DosOpenHandle(DescriptorId);