From 5efa33af967c16c92e2c52db6b3aa40af1c61d74 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sun, 7 Dec 2003 12:59:34 +0000 Subject: [PATCH] 2003-12-07 Casper S. Hornstrup * subsys/win32k/include/accelerator.h: New file. * subsys/win32k/ntuser/accelerator.c: Ditto. * include/win32k/ntuser.h (NtUserDestroyAcceleratorTable): Make returntype BOOLEAN. * subsys/win32k/makefile (NTUSER_OBJECTS): Add ntuser/accelerator.o. * subsys/win32k/include/object.h (USER_OBJECT_TYPE): Add otAcceleratorTable. * subsys/win32k/main/dllmain.c (DllMain): Call InitAcceleratorImpl(). * subsys/win32k/ntuser/stubs.c (NtUserCopyAcceleratorTable, NtUserCreateAcceleratorTable, NtUserDestroyAcceleratorTable, NtUserTranslateAccelerator): Move to accelerator.c. svn path=/trunk/; revision=6892 --- reactos/ChangeLog | 13 ++ reactos/include/win32k/ntuser.h | 4 +- reactos/subsys/win32k/include/accelerator.h | 24 +++ reactos/subsys/win32k/include/object.h | 3 +- reactos/subsys/win32k/main/dllmain.c | 10 +- reactos/subsys/win32k/makefile | 4 +- reactos/subsys/win32k/ntuser/accelerator.c | 210 ++++++++++++++++++++ reactos/subsys/win32k/ntuser/stubs.c | 49 +---- 8 files changed, 263 insertions(+), 54 deletions(-) create mode 100644 reactos/subsys/win32k/include/accelerator.h create mode 100644 reactos/subsys/win32k/ntuser/accelerator.c diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 360799e0a38..d6c9f85f7bb 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,16 @@ +2003-12-07 Casper S. Hornstrup + + * subsys/win32k/include/accelerator.h: New file. + * subsys/win32k/ntuser/accelerator.c: Ditto. + * include/win32k/ntuser.h (NtUserDestroyAcceleratorTable): Make returntype + BOOLEAN. + * subsys/win32k/makefile (NTUSER_OBJECTS): Add ntuser/accelerator.o. + * subsys/win32k/include/object.h (USER_OBJECT_TYPE): Add otAcceleratorTable. + * subsys/win32k/main/dllmain.c (DllMain): Call InitAcceleratorImpl(). + * subsys/win32k/ntuser/stubs.c (NtUserCopyAcceleratorTable, + NtUserCreateAcceleratorTable, NtUserDestroyAcceleratorTable, + NtUserTranslateAccelerator): Move to accelerator.c. + 2003-12-07 Casper S. Hornstrup * apps/tests/accelerator: New directory. diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index f10f3987f1a..55843095b2e 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -265,7 +265,7 @@ NtUserCountClipboardFormats(VOID); HACCEL STDCALL NtUserCreateAcceleratorTable( - LPACCEL Entries, + LPACCEL Entries, SIZE_T EntriesCount); BOOL @@ -373,7 +373,7 @@ NtUserDeleteMenu( UINT uPosition, UINT uFlags); -BOOL +BOOLEAN STDCALL NtUserDestroyAcceleratorTable( HACCEL Table); diff --git a/reactos/subsys/win32k/include/accelerator.h b/reactos/subsys/win32k/include/accelerator.h new file mode 100644 index 00000000000..13fff1fde46 --- /dev/null +++ b/reactos/subsys/win32k/include/accelerator.h @@ -0,0 +1,24 @@ +#ifndef _WIN32K_ACCELERATOR_H +#define _WIN32K_ACCELERATOR_H + +#include +#include +#include +#include + +typedef struct _ACCELERATOR_TABLE +{ + int Count; + LPACCEL Table; +} ACCELERATOR_TABLE, *PACCELERATOR_TABLE; + +NTSTATUS FASTCALL +InitAcceleratorImpl(); + +NTSTATUS FASTCALL +CleanupAcceleratorImpl(); + +VOID +RegisterThreadAcceleratorTable(struct _ETHREAD *Thread); + +#endif /* _WIN32K_ACCELERATOR_H */ diff --git a/reactos/subsys/win32k/include/object.h b/reactos/subsys/win32k/include/object.h index 063d7f3557a..9adf7009ba1 100644 --- a/reactos/subsys/win32k/include/object.h +++ b/reactos/subsys/win32k/include/object.h @@ -10,7 +10,8 @@ typedef enum { otUnknown = 0, otClass, otWindow, - otMenu + otMenu, + otAcceleratorTable, } USER_OBJECT_TYPE; typedef struct _USER_OBJECT_HEADER diff --git a/reactos/subsys/win32k/main/dllmain.c b/reactos/subsys/win32k/main/dllmain.c index 71e8a49e6a5..1ffd9c846e1 100644 --- a/reactos/subsys/win32k/main/dllmain.c +++ b/reactos/subsys/win32k/main/dllmain.c @@ -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: dllmain.c,v 1.56 2003/12/03 21:50:50 gvg Exp $ +/* $Id: dllmain.c,v 1.57 2003/12/07 12:59:34 chorns Exp $ * * Entry Point for win32k.sys */ @@ -40,6 +40,7 @@ #include #include #include +#include #include #define NDEBUG @@ -271,6 +272,13 @@ DllMain ( return(Status); } + Status = InitAcceleratorImpl(); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to initialize accelerator implementation.\n"); + return(Status); + } + InitGdiObjectHandleTable (); /* Initialize FreeType library */ diff --git a/reactos/subsys/win32k/makefile b/reactos/subsys/win32k/makefile index 638b737a222..05faed30dd5 100644 --- a/reactos/subsys/win32k/makefile +++ b/reactos/subsys/win32k/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.85 2003/12/06 23:10:50 mf Exp $ +# $Id: makefile,v 1.86 2003/12/07 12:59:34 chorns Exp $ PATH_TO_TOP = ../.. @@ -48,7 +48,7 @@ MISC_OBJECTS = misc/driver.o misc/error.o misc/math.o misc/object.o LDR_OBJECTS = ldr/loader.o -NTUSER_OBJECTS = ntuser/callback.o ntuser/caret.o ntuser/class.o ntuser/focus.o \ +NTUSER_OBJECTS = ntuser/accelerator.o ntuser/callback.o ntuser/caret.o ntuser/class.o ntuser/focus.o \ ntuser/guicheck.o ntuser/hook.o ntuser/hotkey.o ntuser/input.o \ ntuser/keyboard.o ntuser/menu.o ntuser/message.o ntuser/metric.o \ ntuser/misc.o ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o \ diff --git a/reactos/subsys/win32k/ntuser/accelerator.c b/reactos/subsys/win32k/ntuser/accelerator.c new file mode 100644 index 00000000000..608eb5c6dbd --- /dev/null +++ b/reactos/subsys/win32k/ntuser/accelerator.c @@ -0,0 +1,210 @@ +/* + * ReactOS W32 Subsystem + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: accelerator.c,v 1.1 2003/12/07 12:59:34 chorns Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: Window classes + * FILE: subsys/win32k/ntuser/class.c + * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) + * REVISION HISTORY: + * 06-06-2001 CSH Created + */ +/* INCLUDES ******************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS FASTCALL +InitAcceleratorImpl(VOID) +{ + return(STATUS_SUCCESS); +} + +NTSTATUS FASTCALL +CleanupAcceleratorImpl(VOID) +{ + return(STATUS_SUCCESS); +} + +int +STDCALL +NtUserCopyAcceleratorTable( + HACCEL Table, + LPACCEL Entries, + int EntriesCount) +{ + UNIMPLEMENTED + + return 0; +} + +HACCEL +STDCALL +NtUserCreateAcceleratorTable( + LPACCEL Entries, + SIZE_T EntriesCount) +{ + PWINSTATION_OBJECT WindowStation; + PACCELERATOR_TABLE AcceleratorTable; + NTSTATUS Status; + HACCEL Handle; + + DbgPrint("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", + Entries, EntriesCount); + + Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + UserMode, + 0, + &WindowStation); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(STATUS_ACCESS_DENIED); + DbgPrint("E1\n"); + return FALSE; + } + + AcceleratorTable = ObmCreateObject( + WindowStation->HandleTable, + (PHANDLE)&Handle, + otAcceleratorTable, + sizeof(ACCELERATOR_TABLE)); + if (AcceleratorTable == NULL) + { + ObDereferenceObject(WindowStation); + SetLastNtError(STATUS_NO_MEMORY); + DbgPrint("E2\n"); + return (HACCEL) 0; + } + + AcceleratorTable->Count = EntriesCount; + if (AcceleratorTable->Count > 0) + { + AcceleratorTable->Table = ExAllocatePool(PagedPool, EntriesCount * sizeof(ACCEL)); + if (AcceleratorTable->Table == NULL) + { + ObmCloseHandle(WindowStation->HandleTable, Handle); + ObDereferenceObject(WindowStation); + SetLastNtError(Status); + DbgPrint("E3\n"); + return (HACCEL) 0; + } + + Status = MmCopyFromCaller(AcceleratorTable->Table, Entries, EntriesCount * sizeof(ACCEL)); + if (!NT_SUCCESS(Status)) + { + ExFreePool(AcceleratorTable->Table); + ObmCloseHandle(WindowStation->HandleTable, Handle); + ObDereferenceObject(WindowStation); + SetLastNtError(Status); + DbgPrint("E4\n"); + return (HACCEL) 0; + } + } + + ObDereferenceObject(WindowStation); + + /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */ + + DbgPrint("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x end\n", + Entries, EntriesCount, Handle); + + return (HACCEL) Handle; +} + +BOOLEAN +STDCALL +NtUserDestroyAcceleratorTable( + HACCEL Table) +{ + PWINSTATION_OBJECT WindowStation; + PACCELERATOR_TABLE AcceleratorTable; + NTSTATUS Status; + HACCEL Handle; + + /* FIXME: If the handle table is from a call to LoadAcceleratorTable, decrement it's + usage count (and return TRUE). + FIXME: Destroy only tables created using CreateAcceleratorTable. + */ + + DbgPrint("NtUserDestroyAcceleratorTable(Table %x)\n", + Table); + + Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + UserMode, + 0, + &WindowStation); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(STATUS_ACCESS_DENIED); + DbgPrint("E1\n"); + return FALSE; + } + + Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, + Table, + otAcceleratorTable, + (PVOID*)&AcceleratorTable); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(STATUS_INVALID_HANDLE); + ObDereferenceObject(WindowStation); + DbgPrint("E2\n"); + return FALSE; + } + + if (AcceleratorTable->Table != NULL) + { + ExFreePool(AcceleratorTable->Table); + } + + ObmCloseHandle(WindowStation->HandleTable, Handle); + + ObDereferenceObject(WindowStation); + + DbgPrint("NtUserDestroyAcceleratorTable(Table %x)\n", + Table); + + return TRUE; +} + +int +STDCALL +NtUserTranslateAccelerator( + HWND Window, + HACCEL Table, + LPMSG Message) +{ + UNIMPLEMENTED + + return 0; +} diff --git a/reactos/subsys/win32k/ntuser/stubs.c b/reactos/subsys/win32k/ntuser/stubs.c index b14128cb4bf..b441ad29f8b 100644 --- a/reactos/subsys/win32k/ntuser/stubs.c +++ b/reactos/subsys/win32k/ntuser/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.40 2003/11/30 20:03:47 navaraf Exp $ +/* $Id: stubs.c,v 1.41 2003/12/07 12:59:34 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -156,18 +156,6 @@ NtUserConvertMemHandle( return 0; } -DWORD -STDCALL -NtUserCopyAcceleratorTable( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2) -{ - UNIMPLEMENTED - - return 0; -} - DWORD STDCALL NtUserCountClipboardFormats(VOID) @@ -177,18 +165,6 @@ NtUserCountClipboardFormats(VOID) return 0; } -DWORD -STDCALL -NtUserCreateAcceleratorTable( - DWORD Unknown0, - DWORD Unknown1) -{ -/* UNIMPLEMENTED */ - DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); - - return 0; -} - DWORD STDCALL NtUserCreateLocalMemHandle( @@ -240,17 +216,6 @@ NtUserDdeSetQualityOfService( return 0; } -DWORD -STDCALL -NtUserDestroyAcceleratorTable( - DWORD Unknown0) -{ - UNIMPLEMENTED - - return 0; -} - - DWORD STDCALL NtUserDragObject( @@ -892,18 +857,6 @@ NtUserTrackMouseEvent( return 0; } -DWORD -STDCALL -NtUserTranslateAccelerator( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2) -{ - UNIMPLEMENTED - - return 0; -} - DWORD STDCALL NtUserUnloadKeyboardLayout(