Author: amunger
Date: Fri Jun 2 17:49:04 2006
New Revision: 22176
URL:
http://svn.reactos.ru/svn/reactos?rev=22176&view=rev
Log:
Merge miscellaneous bugfixes from trunk.
Revisions: 21904, 21916, 21984, 22126
Modified:
branches/ros-branch-0_3_0/reactos/dll/win32/user32/windows/message.c
branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/elf.inc.h
branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/process.c
branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/include/dc.h
branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/main/dllmain.c
branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/ntuser/input.c
branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/objects/dc.c
Modified: branches/ros-branch-0_3_0/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/dll/win…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/dll/win32/user32/windows/message.c (original)
+++ branches/ros-branch-0_3_0/reactos/dll/win32/user32/windows/message.c Fri Jun 2
17:49:04 2006
@@ -471,12 +471,12 @@
return FALSE;
}
xs->cs = *(CREATESTRUCTW *)AnsiMsg->lParam;
- if (HIWORD(xs->cs.lpszName))
+ if (!IS_INTRESOURCE(xs->cs.lpszName))
{
RtlCreateUnicodeStringFromAsciiz(&UnicodeBuffer,
(LPSTR)xs->cs.lpszName);
xs->lpszName = xs->cs.lpszName = UnicodeBuffer.Buffer;
}
- if (HIWORD(xs->cs.lpszClass))
+ if (!IS_ATOM(xs->cs.lpszClass))
{
RtlCreateUnicodeStringFromAsciiz(&UnicodeBuffer,
(LPSTR)xs->cs.lpszClass);
xs->lpszClass = xs->cs.lpszClass = UnicodeBuffer.Buffer;
@@ -498,7 +498,7 @@
*cs = *(MDICREATESTRUCTW *)AnsiMsg->lParam;
- if (HIWORD(cs->szClass))
+ if (!IS_ATOM(cs->szClass))
{
RtlCreateUnicodeStringFromAsciiz(&UnicodeBuffer, (LPSTR)cs->szClass);
cs->szClass = UnicodeBuffer.Buffer;
@@ -607,12 +607,9 @@
{
UNICODE_STRING UnicodeString;
MDICREATESTRUCTW *cs = (MDICREATESTRUCTW *)UnicodeMsg->lParam;
- if (HIWORD(cs->szTitle))
- {
- RtlInitUnicodeString(&UnicodeString, (PCWSTR)cs->szTitle);
- RtlFreeUnicodeString(&UnicodeString);
- }
- if (HIWORD(cs->szClass))
+ RtlInitUnicodeString(&UnicodeString, (PCWSTR)cs->szTitle);
+ RtlFreeUnicodeString(&UnicodeString);
+ if (!IS_ATOM(cs->szClass))
{
RtlInitUnicodeString(&UnicodeString, (PCWSTR)cs->szClass);
RtlFreeUnicodeString(&UnicodeString);
@@ -762,7 +759,51 @@
}
break;
}
- }
+
+ case WM_MDICREATE:
+ {
+ ANSI_STRING AnsiBuffer;
+ UNICODE_STRING UnicodeString;
+ MDICREATESTRUCTA *cs =
+ (MDICREATESTRUCTA *)HeapAlloc(GetProcessHeap(), 0, sizeof(*cs));
+
+ if (!cs)
+ {
+ return FALSE;
+ }
+
+ *cs = *(MDICREATESTRUCTA *)UnicodeMsg->lParam;
+
+ if (!IS_ATOM(cs->szClass))
+ {
+ RtlInitUnicodeString(&UnicodeString, (LPCWSTR)cs->szClass);
+ if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiBuffer,
+ &UnicodeString,
+ TRUE)))
+ {
+ return FALSE;
+ }
+ cs->szClass = AnsiBuffer.Buffer;
+ }
+
+ RtlInitUnicodeString(&UnicodeString, (LPCWSTR)cs->szTitle);
+ if (! NT_SUCCESS(RtlUnicodeStringToAnsiString(&AnsiBuffer,
+ &UnicodeString,
+ TRUE)))
+ {
+ if (!IS_ATOM(cs->szClass))
+ {
+ RtlInitAnsiString(&AnsiBuffer, cs->szClass);
+ RtlFreeAnsiString(&AnsiBuffer);
+ }
+ return FALSE;
+ }
+ cs->szTitle = AnsiBuffer.Buffer;
+
+ AnsiMsg->lParam = (LPARAM)cs;
+ break;
+ }
+ }
return TRUE;
}
@@ -835,6 +876,21 @@
RtlInitAnsiString(&AString, (PSTR) AnsiMsg->lParam);
RtlFreeAnsiString(&AString);
}
+ break;
+ }
+
+ case WM_MDICREATE:
+ {
+ ANSI_STRING AnsiString;
+ MDICREATESTRUCTA *cs = (MDICREATESTRUCTA *)AnsiMsg->lParam;
+ RtlInitAnsiString(&AnsiString, (PCSTR)cs->szTitle);
+ RtlFreeAnsiString(&AnsiString);
+ if (!IS_ATOM(cs->szClass))
+ {
+ RtlInitAnsiString(&AnsiString, (PCSTR)cs->szClass);
+ RtlFreeAnsiString(&AnsiString);
+ }
+ HeapFree(GetProcessHeap(), 0, cs);
break;
}
Modified: branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/elf.inc.h
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/ntoskrn…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/elf.inc.h (original)
+++ branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/elf.inc.h Fri Jun 2 17:49:04 2006
@@ -294,10 +294,7 @@
if(Number == 0)
return FALSE;
- while((Number % 2) == 0)
- Number /= 2;
-
- return Number == 1;
+ return (Number & (Number - 1)) == 0;
}
static __inline Elf_Addr ElfFmtpModPow2
Modified: branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/process.c
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/ntoskrn…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/process.c (original)
+++ branches/ros-branch-0_3_0/reactos/ntoskrnl/mm/process.c Fri Jun 2 17:49:04 2006
@@ -297,12 +297,6 @@
/* Image Data */
if ((NtHeaders = RtlImageNtHeader(Peb->ImageBaseAddress)))
{
- /* Get the Image Config Data too */
- ImageConfigData = RtlImageDirectoryEntryToData(Peb->ImageBaseAddress,
- TRUE,
-
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG,
- &ViewSize);
-
/* Write subsystem data */
Peb->ImageSubSystem = NtHeaders->OptionalHeader.Subsystem;
Peb->ImageSubSystemMajorVersion =
NtHeaders->OptionalHeader.MajorSubsystemVersion;
@@ -315,22 +309,10 @@
Peb->OSMinorVersion = (NtHeaders->OptionalHeader.Win32VersionValue
>> 8) & 0xFF;
Peb->OSBuildNumber = (NtHeaders->OptionalHeader.Win32VersionValue
>> 16) & 0x3FFF;
- /* Lie about the version if requested */
- if (ImageConfigData && ImageConfigData->CSDVersion)
- {
- Peb->OSCSDVersion = ImageConfigData->CSDVersion;
- }
-
/* Set the Platform ID */
Peb->OSPlatformId = (NtHeaders->OptionalHeader.Win32VersionValue
>> 30) ^ 2;
}
- /* Check for affinity override */
- if (ImageConfigData && ImageConfigData->ProcessAffinityMask)
- {
- ProcessAffinityMask = ImageConfigData->ProcessAffinityMask;
- }
-
/* Check if the image is not safe for SMP */
if (NtHeaders->FileHeader.Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY)
{
@@ -342,6 +324,37 @@
/* Use affinity from Image Header */
Peb->ImageProcessAffinityMask = ProcessAffinityMask;
}
+
+ _SEH_TRY
+ {
+ /* Get the Image Config Data too */
+ ImageConfigData = RtlImageDirectoryEntryToData(Peb->ImageBaseAddress,
+ TRUE,
+
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG,
+ &ViewSize);
+
+ ProbeForRead(ImageConfigData,
+ sizeof(IMAGE_LOAD_CONFIG_DIRECTORY),
+ sizeof(ULONG));
+
+ /* Process the image config data overrides if specfied. */
+ if (ImageConfigData != NULL)
+ {
+ if (ImageConfigData->CSDVersion)
+ {
+ Peb->OSCSDVersion = ImageConfigData->CSDVersion;
+ }
+ if (ImageConfigData->ProcessAffinityMask)
+ {
+ ProcessAffinityMask = ImageConfigData->ProcessAffinityMask;
+ }
+ }
+ }
+ _SEH_HANDLE
+ {
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
}
/* Misc data */
@@ -352,7 +365,7 @@
KeDetachProcess();
DPRINT("MmCreatePeb: Peb created at %p\n", Peb);
- return STATUS_SUCCESS;
+ return Status;
}
PTEB
Modified: branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/subsyst…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/include/dc.h (original)
+++ branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/include/dc.h Fri Jun 2
17:49:04 2006
@@ -170,6 +170,7 @@
#define DC_UnlockDc(pDC) \
GDIOBJ_UnlockObjByPtr (GdiHandleTable, pDC)
+NTSTATUS FASTCALL InitDcImpl(VOID);
HDC FASTCALL RetrieveDisplayHDC(VOID);
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_InitDC(HDC DCToInit);
Modified: branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/subsyst…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/main/dllmain.c (original)
+++ branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/main/dllmain.c Fri Jun 2
17:49:04 2006
@@ -502,6 +502,13 @@
return STATUS_UNSUCCESSFUL;
}
+ Status = InitDcImpl();
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to initialize Device context implementation!\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
/* Initialize FreeType library */
if (! InitFontSupport())
{
Modified: branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/ntuser/input.c
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/subsyst…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/ntuser/input.c (original)
+++ branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/ntuser/input.c Fri Jun 2
17:49:04 2006
@@ -176,6 +176,9 @@
FILE_SYNCHRONOUS_IO_ALERT);
} while (!NT_SUCCESS(Status));
+ KeSetPriorityThread(&PsGetCurrentThread()->Tcb,
+ LOW_REALTIME_PRIORITY + 3);
+
for(;;)
{
/*
@@ -454,6 +457,9 @@
DPRINT1("Win32K: Failed making keyboard thread a win32 thread.\n");
return; //(Status);
}
+
+ KeSetPriorityThread(&PsGetCurrentThread()->Tcb,
+ LOW_REALTIME_PRIORITY + 3);
IntKeyboardGetIndicatorTrans(KeyboardDeviceHandle,
&IndicatorTrans);
Modified: branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.ru/svn/reactos/branches/ros-branch-0_3_0/reactos/subsyst…
==============================================================================
--- branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/objects/dc.c (original)
+++ branches/ros-branch-0_3_0/reactos/subsystems/win32/win32k/objects/dc.c Fri Jun 2
17:49:04 2006
@@ -33,6 +33,17 @@
#endif
static GDIDEVICE PrimarySurface;
+static KEVENT VideoDriverNeedsPreparation;
+static KEVENT VideoDriverPrepared;
+
+
+NTSTATUS FASTCALL
+InitDcImpl(VOID)
+{
+ KeInitializeEvent(&VideoDriverNeedsPreparation, SynchronizationEvent, TRUE);
+ KeInitializeEvent(&VideoDriverPrepared, NotificationEvent, FALSE);
+ return STATUS_SUCCESS;
+}
/* FIXME: DCs should probably be thread safe */
@@ -481,6 +492,17 @@
BOOL GotDriver;
BOOL DoDefault;
ULONG DisplayNumber;
+ LARGE_INTEGER Zero;
+ BOOLEAN ret = FALSE;
+
+ Zero.QuadPart = 0;
+ if (STATUS_SUCCESS != KeWaitForSingleObject(&VideoDriverNeedsPreparation,
Executive, KernelMode, TRUE, &Zero))
+ {
+ /* Concurrent access. Wait for VideoDriverPrepared event */
+ if (STATUS_SUCCESS == KeWaitForSingleObject(&VideoDriverPrepared, Executive,
KernelMode, TRUE, NULL))
+ ret = PrimarySurface.PreparedDriver;
+ goto cleanup;
+ }
for (DisplayNumber = 0; ; DisplayNumber++)
{
@@ -494,7 +516,7 @@
if (PrimarySurface.VideoFileObject == NULL)
{
DPRINT1("FindMPDriver failed\n");
- return FALSE;
+ goto cleanup;
}
/* Retrieve DDI driver names from registry */
@@ -568,7 +590,7 @@
{
ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("BuildDDIFunctions failed\n");
- return FALSE;
+ goto cleanup;
}
/* Allocate a phyical device handle from the driver */
@@ -651,10 +673,13 @@
PrimarySurface.PreparedDriver = TRUE;
PrimarySurface.DisplayNumber = DisplayNumber;
- return TRUE;
+ ret = TRUE;
+ goto cleanup;
}
- return FALSE;
+cleanup:
+ KeSetEvent(&VideoDriverPrepared, 1, FALSE);
+ return ret;
}
static BOOL FASTCALL