Fixed bug with cygwin1.dll (still doesn't work)

svn path=/trunk/; revision=2469
This commit is contained in:
David Welch 2002-01-01 03:29:16 +00:00
parent e5a34ef337
commit 3273c93173
7 changed files with 145 additions and 51 deletions

View file

@ -526,11 +526,11 @@ KeyboardHandler(PKINTERRUPT Interrupt,
// DbgPrint("Key: %c\n",VirtualToAscii(ScanToVirtual(thisKey),isDown));
// DbgPrint("Key: %x\n",ScanToVirtual(thisKey));
if (ScanToVirtual(thisKey) == VK_PRINT && isDown)
if (ScanToVirtual(thisKey) == VK_TAB && isDown)
{
InSysRq = TRUE;
}
else if (ScanToVirtual(thisKey) == VK_PRINT && !isDown)
else if (ScanToVirtual(thisKey) == VK_TAB && !isDown)
{
InSysRq = FALSE;
}

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.41 2001/08/07 14:11:41 ekohl Exp $
/* $Id: create.c,v 1.42 2002/01/01 03:29:15 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -66,6 +66,7 @@ CreateProcessA (LPCSTR lpApplicationName,
ANSI_STRING CurrentDirectory;
ANSI_STRING CommandLine;
WINBOOL Result;
CHAR TempCurrentDirectoryA[256];
DPRINT("CreateProcessA\n");
@ -73,8 +74,17 @@ CreateProcessA (LPCSTR lpApplicationName,
lpCommandLine);
RtlInitAnsiString (&ApplicationName,
(LPSTR)lpApplicationName);
RtlInitAnsiString (&CurrentDirectory,
(LPSTR)lpCurrentDirectory);
if (lpCurrentDirectory != NULL)
{
RtlInitAnsiString (&CurrentDirectory,
(LPSTR)lpCurrentDirectory);
}
else
{
GetCurrentDirectoryA(256, TempCurrentDirectoryA);
RtlInitAnsiString (&CurrentDirectory,
TempCurrentDirectoryA);
}
/* convert ansi (or oem) strings to unicode */
if (bIsFileApiAnsi)
@ -473,6 +483,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
ANSI_STRING ProcedureName;
UNICODE_STRING CurrentDirectoryW;
SECTION_IMAGE_INFORMATION Sii;
CHAR TempCurrentDirectoryW[256];
DPRINT("CreateProcessW(lpApplicationName '%S', lpCommandLine '%S')\n",
lpApplicationName,lpCommandLine);
@ -521,8 +532,17 @@ CreateProcessW(LPCWSTR lpApplicationName,
}
/* Initialize the current directory string */
RtlInitUnicodeString(&CurrentDirectoryW,
lpCurrentDirectory);
if (lpCurrentDirectory != NULL)
{
RtlInitUnicodeString(&CurrentDirectoryW,
lpCurrentDirectory);
}
else
{
GetCurrentDirectoryW(256, TempCurrentDirectoryW);
RtlInitUnicodeString(&CurrentDirectoryW,
TempCurrentDirectoryW);
}
/*
* Create the PPB

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.68 2001/11/21 22:30:57 ekohl Exp $
# $Id: makefile,v 1.69 2002/01/01 03:29:15 dwelch Exp $
PATH_TO_TOP = ../..
@ -6,7 +6,7 @@ TARGET_TYPE = dynlink
TARGET_NAME = ntdll
TARGET_CFLAGS = -D__NTDLL__
TARGET_CFLAGS = -g -D__NTDLL__
TARGET_LFLAGS = -Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \

View file

@ -88,6 +88,7 @@ typedef struct _MM_SECTION_SEGMENT
ULONG Flags;
PVOID VirtualAddress;
ULONG Characteristics;
BOOLEAN WriteCopy;
} MM_SECTION_SEGMENT, *PMM_SECTION_SEGMENT;
typedef struct
@ -127,18 +128,19 @@ typedef struct
struct _EPROCESS* Process;
union
{
struct
{
SECTION_OBJECT* Section;
ULONG ViewOffset;
LIST_ENTRY ViewListEntry;
PMM_SECTION_SEGMENT Segment;
} SectionData;
struct
{
LIST_ENTRY SegmentListHead;
} VirtualMemoryData;
} Data;
struct
{
SECTION_OBJECT* Section;
ULONG ViewOffset;
LIST_ENTRY ViewListEntry;
PMM_SECTION_SEGMENT Segment;
BOOLEAN WriteCopyView;
} SectionData;
struct
{
LIST_ENTRY SegmentListHead;
} VirtualMemoryData;
} Data;
} MEMORY_AREA, *PMEMORY_AREA;
typedef struct _MADDRESS_SPACE

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: page.c,v 1.32 2002/01/01 00:21:57 dwelch Exp $
/* $Id: page.c,v 1.33 2002/01/01 03:29:15 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/i386/page.c
@ -81,28 +81,33 @@ ProtectToPTE(ULONG flProtect)
{
Attributes = 0;
}
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
{
Attributes = PA_PRESENT | PA_READWRITE;
}
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
flProtect & PAGE_EXECUTE_READ)
{
Attributes = PA_PRESENT;
}
if (!(flProtect & PAGE_SYSTEM))
{
Attributes = Attributes | PA_USER;
}
if (flProtect & PAGE_NOCACHE)
{
Attributes = Attributes | PA_CD;
}
if (flProtect & PAGE_WRITETHROUGH)
{
Attributes = Attributes | PA_WT;
}
return(Attributes);
else if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
{
Attributes = PA_PRESENT | PA_READWRITE;
}
else if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
flProtect & PAGE_EXECUTE_READ)
{
Attributes = PA_PRESENT;
}
else
{
DPRINT1("Unknown main protection type.\n");
KeBugCheck(0);
}
if (!(flProtect & PAGE_SYSTEM))
{
Attributes = Attributes | PA_USER;
}
if (flProtect & PAGE_NOCACHE)
{
Attributes = Attributes | PA_CD;
}
if (flProtect & PAGE_WRITETHROUGH)
{
Attributes = Attributes | PA_WT;
}
return(Attributes);
}
#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (4 * 1024 * 1024))
@ -944,6 +949,12 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
MmMarkPageMapped((PVOID)PhysicalAddress);
Attributes = ProtectToPTE(flProtect);
if (!(Attributes & PA_PRESENT) && PhysicalAddress != 0)
{
DPRINT1("Setting physical address but not allowing access at address 0x%.8X "
"with attributes %x/%x.\n", Address, Attributes, flProtect);
KeBugCheck(0);
}
if (Process != NULL && Process != CurrentProcess)
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: rmap.c,v 1.1 2001/12/31 01:53:45 dwelch Exp $
/* $Id: rmap.c,v 1.2 2002/01/01 03:29:15 dwelch Exp $
*
* COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel
@ -167,6 +167,9 @@ MmInsertRmap(PVOID PhysicalAddress, PEPROCESS Process, PVOID Address)
if (MmGetPhysicalAddressForProcess(Process, Address)!= (ULONG)PhysicalAddress)
{
DPRINT1("Insert rmap (%d, 0x%.8X) 0x%.8X which doesn't match physical address 0x%.8X\n",
Process->UniqueProcessId, Address,
MmGetPhysicalAddressForProcess(Process, Address), PhysicalAddress)
KeBugCheck(0);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: section.c,v 1.72 2002/01/01 00:21:56 dwelch Exp $
/* $Id: section.c,v 1.73 2002/01/01 03:29:15 dwelch Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/section.c
@ -685,7 +685,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
/*
* Check if this page needs to be mapped COW
*/
if (Segment->Characteristics & IMAGE_SECTION_CHAR_DATA)
if (Segment->WriteCopy || MemoryArea->Data.SectionData.WriteCopyView)
{
Attributes = PAGE_READONLY;
}
@ -769,7 +769,25 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
Attributes,
(ULONG)Page,
FALSE);
MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
MmUnlockSectionSegment(Segment);
MmUnlockSection(Section);
MmUnlockAddressSpace(AddressSpace);
Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
Address,
Attributes,
(ULONG)Page,
TRUE);
if (!NT_SUCCESS(Status))
{
KeBugCheck(0);
}
MmLockAddressSpace(AddressSpace);
MmLockSection(Section);
MmLockSectionSegment(Segment);
}
MmInsertRmap(Page, PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
if (!NT_SUCCESS(Status))
{
DbgPrint("Unable to create virtual mapping\n");
@ -942,7 +960,7 @@ MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
/*
* Check if we are doing COW
*/
if (!(Segment->Characteristics & IMAGE_SECTION_CHAR_DATA))
if (!(Segment->WriteCopy || MemoryArea->Data.SectionData.WriteCopyView))
{
MmUnlockSection(Section);
MmUnlockSectionSegment(Segment);
@ -1568,6 +1586,7 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
Segment->Attributes = AllocationAttributes;
Segment->Length = MaximumSize.u.LowPart;
Segment->Flags = MM_PAGEFILE_SECTION;
Segment->WriteCopy = FALSE;
return(STATUS_SUCCESS);
}
@ -1749,6 +1768,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
Segment->Attributes = 0;
Segment->Flags = 0;
Segment->Characteristics = 0;
Segment->WriteCopy = FALSE;
if (AllocationAttributes & SEC_RESERVE)
{
Segment->Length = 0;
@ -1798,6 +1818,26 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
return(STATUS_SUCCESS);
}
static ULONG SectionCharacteristicsToProtect[16] =
{
PAGE_NOACCESS, // 0 = NONE
PAGE_NOACCESS, // 1 = SHARED
PAGE_EXECUTE, // 2 = EXECUTABLE
PAGE_EXECUTE, // 3 = EXECUTABLE, SHARED
PAGE_READONLY, // 4 = READABLE
PAGE_READONLY, // 5 = READABLE, SHARED
PAGE_EXECUTE_READ, // 6 = READABLE, EXECUTABLE
PAGE_EXECUTE_READ, // 7 = READABLE, EXECUTABLE, SHARED
PAGE_READWRITE, // 8 = WRITABLE
PAGE_READWRITE, // 9 = WRITABLE, SHARED
PAGE_EXECUTE_READWRITE, // 10 = WRITABLE, EXECUTABLE
PAGE_EXECUTE_READWRITE, // 11 = WRITABLE, EXECUTABLE, SHARED
PAGE_READWRITE, // 12 = WRITABLE, READABLE
PAGE_READWRITE, // 13 = WRITABLE, READABLE, SHARED
PAGE_EXECUTE_READWRITE, // 14 = WRITABLE, READABLE, EXECUTABLE,
PAGE_EXECUTE_READWRITE, // 15 = WRITABLE, READABLE, EXECUTABLE, SHARED
};
NTSTATUS
MmCreateImageSection(PHANDLE SectionHandle,
ACCESS_MASK DesiredAccess,
@ -2059,6 +2099,7 @@ MmCreateImageSection(PHANDLE SectionHandle,
SectionSegments[0].Flags = 0;
SectionSegments[0].ReferenceCount = 1;
SectionSegments[0].VirtualAddress = 0;
SectionSegments[0].WriteCopy = TRUE;
KeInitializeMutex(&SectionSegments[0].Lock, 0);
for (i = 1; i < NrSegments; i++)
@ -2067,21 +2108,32 @@ MmCreateImageSection(PHANDLE SectionHandle,
ImageSections[i-1].PointerToRawData;
SectionSegments[i].Characteristics =
ImageSections[i-1].Characteristics;
if (ImageSections[i-1].Characteristics & IMAGE_SECTION_CHAR_CODE)
if (ImageSections[i-1].Characteristics & IMAGE_SECTION_CHAR_CODE)
{
SectionSegments[i].Protection = PAGE_EXECUTE_READ;
SectionSegments[i].Attributes = 0;
SectionSegments[i].WriteCopy = TRUE;
}
else if (ImageSections[i-1].Characteristics &
IMAGE_SECTION_CHAR_DATA)
IMAGE_SECTION_CHAR_DATA)
{
SectionSegments[i].Protection = PAGE_READWRITE;
SectionSegments[i].Attributes = 0;
SectionSegments[i].WriteCopy = TRUE;
}
else if (ImageSections[i-1].Characteristics & IMAGE_SECTION_CHAR_BSS)
{
SectionSegments[i].Protection = PAGE_READWRITE;
SectionSegments[i].Attributes = MM_SECTION_SEGMENT_BSS;
SectionSegments[i].WriteCopy = TRUE;
}
else
{
SectionSegments[i].Protection =
SectionCharacteristicsToProtect[ImageSections[i-1].Characteristics >> 28];
SectionSegments[i].Attributes = 0;
SectionSegments[i].WriteCopy =
!(ImageSections[i - 1].Characteristics & IMAGE_SECTION_CHAR_SHARED);
}
SectionSegments[i].RawLength = ImageSections[i-1].SizeOfRawData;
SectionSegments[i].Length =
@ -2216,6 +2268,11 @@ MmMapViewOfSegment(PEPROCESS Process,
KIRQL oldIrql;
MmLockAddressSpace(&Process->AddressSpace);
if (Protect == PAGE_NOACCESS || Protect == PAGE_GUARD)
{
DPRINT1("Mapping inaccessible region between 0x%.8X and 0x%.8X\n",
(*BaseAddress), (*BaseAddress) + ViewSize);
}
Status = MmCreateMemoryArea(Process,
&Process->AddressSpace,
MEMORY_AREA_SECTION_VIEW_COMMIT,
@ -2244,6 +2301,7 @@ MmMapViewOfSegment(PEPROCESS Process,
MArea->Data.SectionData.Segment = Segment;
MArea->Data.SectionData.Section = Section;
MArea->Data.SectionData.ViewOffset = ViewOffset;
MArea->Data.SectionData.WriteCopyView = FALSE;
return(STATUS_SUCCESS);
}