mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 19:26:32 +00:00
[WIN32K]
- Simplify NtUserInitialize: we can check whether gpepCSRSS is != NULL to see if we are initialized or not (instead of using gbInitialized). - The UserInitialize helper doesn't need to take parameters. The two event handles (power and media, used when we receive a power event -- for sleep, etc... -- and a media event -- like USB key insertion and such --) just need to be used in the not-yet-implemented "Initialize Power Request List" and "Initialize Media Change" steps. - Something that should be done is to bugcheck if the USER version reported is != 5.0 (as windows does). [WINSRV] - Collapse common inclusions from usersrv and consrv into the common header winsrv.h. [USERSRV] - _UserSoundSentry is NTAPI - Stub UserClientConnect (Timo's patch contains more involved code. I will commit it later). - Our NtUserInitialize(0, NULL, NULL); call (that made Windows BSOD) is wrong. It should be done with its first parameter correctly set to the USER version (5.0) and the two other parameters are handles to power and media events (see above). We should create them before. This is part of patch by Timo Kreuzer. CORE-7505 #comment UserClientConnect stubbed (it should be better implemented, I will commit the code from the patch later on); power&media events initialized; NtUserInitialize corrected. svn path=/trunk/; revision=65696
This commit is contained in:
@@ -1030,6 +1030,9 @@ typedef struct _USERCONNECT
|
||||
SHAREDINFO siClient;
|
||||
} USERCONNECT, *PUSERCONNECT;
|
||||
|
||||
// WinNT 5.0 compatible user32 / win32k
|
||||
#define USER_VERSION MAKELONG(0x0000, 0x0005)
|
||||
|
||||
typedef struct tagGETCLIPBDATA
|
||||
{
|
||||
UINT uFmtRet;
|
||||
|
||||
@@ -697,7 +697,7 @@ UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
|
||||
{
|
||||
/* Make sure that the first syscall is NtUserInitialize */
|
||||
/* too bad this fails */
|
||||
//ASSERT(gbInitialized);
|
||||
// ASSERT(gpepCSRSS);
|
||||
|
||||
UserDbgAssertThreadInfo(TRUE);
|
||||
|
||||
|
||||
@@ -890,7 +890,6 @@ NtUserSetInformationThread(IN HANDLE ThreadHandle,
|
||||
IN USERTHREADINFOCLASS ThreadInformationClass,
|
||||
IN PVOID ThreadInformation,
|
||||
IN ULONG ThreadInformationLength)
|
||||
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PETHREAD Thread;
|
||||
|
||||
@@ -17,7 +17,6 @@ ATOM AtomMessage; // Window Message atom.
|
||||
ATOM AtomWndObj; // Window Object atom.
|
||||
ATOM AtomLayer; // Window Layer atom.
|
||||
ATOM AtomFlashWndState; // Window Flash State atom.
|
||||
BOOL gbInitialized;
|
||||
HINSTANCE hModClient = NULL;
|
||||
BOOL ClientPfnInit = FALSE;
|
||||
PEPROCESS gpepCSRSS = NULL;
|
||||
@@ -98,9 +97,7 @@ InitVideo();
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
UserInitialize(
|
||||
HANDLE hPowerRequestEvent,
|
||||
HANDLE hMediaRequestEvent)
|
||||
UserInitialize(VOID)
|
||||
{
|
||||
static const DWORD wPattern55AA[] = /* 32 bit aligned */
|
||||
{ 0x55555555, 0xaaaaaaaa, 0x55555555, 0xaaaaaaaa,
|
||||
@@ -153,7 +150,7 @@ UserInitialize(
|
||||
}
|
||||
|
||||
/*
|
||||
Called from win32csr.
|
||||
* Called from usersrv.
|
||||
*/
|
||||
NTSTATUS
|
||||
APIENTRY
|
||||
@@ -167,27 +164,26 @@ NtUserInitialize(
|
||||
TRACE("Enter NtUserInitialize(%lx, %p, %p)\n",
|
||||
dwWinVersion, hPowerRequestEvent, hMediaRequestEvent);
|
||||
|
||||
/* Check the Windows version */
|
||||
if (dwWinVersion != 0)
|
||||
/* Check if we are already initialized */
|
||||
if (gpepCSRSS)
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
|
||||
/* Check Windows USER subsystem version */
|
||||
if (dwWinVersion != USER_VERSION)
|
||||
{
|
||||
// FIXME: Should bugcheck!
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
/* Acquire exclusive lock */
|
||||
UserEnterExclusive();
|
||||
|
||||
/* Check if we are already initialized */
|
||||
if (gbInitialized)
|
||||
{
|
||||
UserLeave();
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
/* Save EPROCESS of CSRSS */
|
||||
/* Save the EPROCESS of CSRSS */
|
||||
gpepCSRSS = PsGetCurrentProcess();
|
||||
|
||||
// Initialize Power Request List.
|
||||
// Initialize Media Change.
|
||||
// Initialize Power Request List (use hPowerRequestEvent).
|
||||
// Initialize Media Change (use hMediaRequestEvent).
|
||||
|
||||
// InitializeGreCSRSS();
|
||||
// {
|
||||
// Startup DxGraphics.
|
||||
@@ -196,10 +192,7 @@ NtUserInitialize(
|
||||
// }
|
||||
|
||||
/* Initialize USER */
|
||||
Status = UserInitialize(hPowerRequestEvent, hMediaRequestEvent);
|
||||
|
||||
/* Set us as initialized */
|
||||
gbInitialized = TRUE;
|
||||
Status = UserInitialize();
|
||||
|
||||
/* Return */
|
||||
UserLeave();
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#define UserEnterCo UserEnterExclusive
|
||||
#define UserLeaveCo UserLeave
|
||||
|
||||
extern BOOL gbInitialized;
|
||||
extern PSERVERINFO gpsi;
|
||||
extern PTHREADINFO gptiCurrent;
|
||||
extern PPROCESSINFO gppiList;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <wincon.h>
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/exfuncs.h>
|
||||
#include <ndk/mmfuncs.h>
|
||||
|
||||
/* CONSOLE Headers */
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
/* init.c */
|
||||
BOOL WINAPI _UserSoundSentry(VOID);
|
||||
BOOL NTAPI _UserSoundSentry(VOID);
|
||||
CSR_API(SrvCreateSystemThreads);
|
||||
CSR_API(SrvActivateDebugger);
|
||||
CSR_API(SrvGetThreadConsoleDesktop);
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
|
||||
HINSTANCE UserServerDllInstance = NULL;
|
||||
|
||||
/* Handles for Power and Media events. Used by both usersrv and win32k. */
|
||||
HANDLE ghPowerRequestEvent;
|
||||
HANDLE ghMediaRequestEvent;
|
||||
|
||||
/* Memory */
|
||||
HANDLE UserServerHeap = NULL; // Our own heap.
|
||||
|
||||
@@ -84,7 +88,7 @@ PCHAR UserServerApiNameTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER] =
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
// PUSER_SOUND_SENTRY. Used in basesrv.dll
|
||||
BOOL WINAPI _UserSoundSentry(VOID)
|
||||
BOOL NTAPI _UserSoundSentry(VOID)
|
||||
{
|
||||
// TODO: Do something.
|
||||
return TRUE;
|
||||
@@ -130,6 +134,35 @@ CSR_API(SrvDeviceEvent)
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
UserClientConnect(IN PCSR_PROCESS CsrProcess,
|
||||
IN OUT PVOID ConnectionInfo,
|
||||
IN OUT PULONG ConnectionInfoLength)
|
||||
{
|
||||
DPRINT1("UserClientConnect\n");
|
||||
|
||||
#if 0
|
||||
// NTSTATUS Status = STATUS_SUCCESS;
|
||||
PBASESRV_API_CONNECTINFO ConnectInfo = (PBASESRV_API_CONNECTINFO)ConnectionInfo;
|
||||
|
||||
if ( ConnectionInfo == NULL ||
|
||||
ConnectionInfoLength == NULL ||
|
||||
*ConnectionInfoLength != sizeof(*ConnectInfo) )
|
||||
{
|
||||
DPRINT1("BASESRV: Connection failed - ConnectionInfo = 0x%p ; ConnectionInfoLength = 0x%p (%lu), expected %lu\n",
|
||||
ConnectionInfo,
|
||||
ConnectionInfoLength,
|
||||
ConnectionInfoLength ? *ConnectionInfoLength : (ULONG)-1,
|
||||
sizeof(*ConnectInfo));
|
||||
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
#else
|
||||
return STATUS_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
CSR_SERVER_DLL_INIT(UserServerDllInitialization)
|
||||
{
|
||||
/*** From win32csr... ***/
|
||||
@@ -142,9 +175,6 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
|
||||
/* Initialize the memory */
|
||||
UserServerHeap = RtlGetProcessHeap();
|
||||
|
||||
/* Initialize the video */
|
||||
NtUserInitialize(0, NULL, NULL);
|
||||
|
||||
/* Setup the DLL Object */
|
||||
LoadedServerDll->ApiBase = USERSRV_FIRST_API_NUMBER;
|
||||
LoadedServerDll->HighestApiSupported = UserpMaxApiNumber;
|
||||
@@ -154,7 +184,7 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
|
||||
LoadedServerDll->NameTable = UserServerApiNameTable;
|
||||
#endif
|
||||
LoadedServerDll->SizeOfProcessData = 0;
|
||||
LoadedServerDll->ConnectCallback = NULL;
|
||||
LoadedServerDll->ConnectCallback = UserClientConnect;
|
||||
LoadedServerDll->DisconnectCallback = NULL;
|
||||
LoadedServerDll->HardErrorCallback = UserServerHardError;
|
||||
LoadedServerDll->ShutdownProcessCallback = UserClientShutdown;
|
||||
@@ -175,10 +205,46 @@ CSR_SERVER_DLL_INIT(UserServerDllInitialization)
|
||||
NtClose(ServerThread);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("Cannot start Raw Input Thread!\n");
|
||||
}
|
||||
}
|
||||
/*** END - From win32csr... ***/
|
||||
|
||||
/* Create the power request event */
|
||||
Status = NtCreateEvent(&ghPowerRequestEvent,
|
||||
EVENT_ALL_ACCESS,
|
||||
NULL,
|
||||
SynchronizationEvent,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Power request event creation failed with Status 0x%08x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Create the media request event */
|
||||
Status = NtCreateEvent(&ghMediaRequestEvent,
|
||||
EVENT_ALL_ACCESS,
|
||||
NULL,
|
||||
SynchronizationEvent,
|
||||
FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Media request event creation failed with Status 0x%08x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Initialize the kernel mode subsystem */
|
||||
Status = NtUserInitialize(USER_VERSION,
|
||||
ghPowerRequestEvent,
|
||||
ghMediaRequestEvent);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtUserInitialize failed with Status 0x%08x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* All done */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#ifndef __USERSRV_H__
|
||||
#define __USERSRV_H__
|
||||
|
||||
/* Main header */
|
||||
#include "../winsrv.h"
|
||||
|
||||
/* PSDK/NDK Headers */
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -16,21 +19,7 @@
|
||||
#define _INC_WINDOWS
|
||||
#define COM_NO_WINDOWS_H
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <wingdi.h>
|
||||
#include <winuser.h>
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/obfuncs.h>
|
||||
#include <ndk/psfuncs.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
/* Public Win32K Headers */
|
||||
#include <ntuser.h>
|
||||
|
||||
/* CSRSS Header */
|
||||
#include <csr/csrsrv.h>
|
||||
// #define NTOS_MODE_USER
|
||||
|
||||
/* USER Headers */
|
||||
#include <win/winmsg.h>
|
||||
|
||||
@@ -21,11 +21,13 @@
|
||||
#include <winbase.h>
|
||||
#include <wingdi.h>
|
||||
#include <winuser.h>
|
||||
|
||||
/* Undocumented user definitions */
|
||||
#include <undocuser.h>
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/cmfuncs.h>
|
||||
#include <ndk/exfuncs.h>
|
||||
#include <ndk/obfuncs.h>
|
||||
#include <ndk/psfuncs.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
|
||||
Reference in New Issue
Block a user