--- trunk/reactos/subsys/win32k/ntuser/accelerator.c 2005-09-18 15:25:34 UTC (rev 17913)
+++ trunk/reactos/subsys/win32k/ntuser/accelerator.c 2005-09-18 16:56:33 UTC (rev 17914)
@@ -91,194 +91,6 @@
}
-
-
-int
-STDCALL
-NtUserCopyAcceleratorTable(
- HACCEL hAccel,
- LPACCEL Entries,
- int EntriesCount)
-{
- PWINSTATION_OBJECT WindowStation;
- PACCELERATOR_TABLE Accel;
- NTSTATUS Status;
- int Ret;
- DECLARE_RETURN(int);
-
- DPRINT("Enter NtUserCopyAcceleratorTable\n");
- UserEnterShared();
-
- Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
- UserMode,
- 0,
- &WindowStation);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(STATUS_ACCESS_DENIED);
- RETURN(0);
- }
-
- if (!(Accel = UserGetAccelObject(hAccel)))
- {
- ObDereferenceObject(WindowStation);
- RETURN(0);
- }
-
- if(Entries)
- {
- Ret = min(EntriesCount, Accel->Count);
- Status = MmCopyToCaller(Entries, Accel->Table, Ret * sizeof(ACCEL));
- if (!NT_SUCCESS(Status))
- {
- ObDereferenceObject(WindowStation);
- SetLastNtError(Status);
- RETURN(0);
- }
- }
- else
- {
- Ret = Accel->Count;
- }
-
- ObDereferenceObject(WindowStation);
-
- RETURN(Ret);
-
-CLEANUP:
- DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-HACCEL
-STDCALL
-NtUserCreateAcceleratorTable(
- LPACCEL Entries,
- SIZE_T EntriesCount)
-{
- PWINSTATION_OBJECT WindowStation;
- PACCELERATOR_TABLE Accel;
- NTSTATUS Status;
- HACCEL hAccel;
- DECLARE_RETURN(HACCEL);
-
- DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
- Entries, EntriesCount);
- UserEnterExclusive();
-
- Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
- UserMode,
- 0,
- &WindowStation);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(STATUS_ACCESS_DENIED);
- RETURN( FALSE );
- }
-
- Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
-
- if (Accel == NULL)
- {
- ObDereferenceObject(WindowStation);
- SetLastNtError(STATUS_NO_MEMORY);
- RETURN( (HACCEL) 0 );
- }
-
- Accel->Count = EntriesCount;
- if (Accel->Count > 0)
- {
- Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
- if (Accel->Table == NULL)
- {
- ObmDeleteObject(hAccel, otAccel);
- ObDereferenceObject(WindowStation);
- SetLastNtError(Status);
- RETURN( (HACCEL) 0);
- }
-
- Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
- if (!NT_SUCCESS(Status))
- {
- ExFreePool(Accel->Table);
- ObmDeleteObject(hAccel, otAccel);
- ObDereferenceObject(WindowStation);
- SetLastNtError(Status);
- RETURN((HACCEL) 0);
- }
- }
-
- ObDereferenceObject(WindowStation);
-
- /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
-
- RETURN(hAccel);
-
-CLEANUP:
- DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
- Entries, EntriesCount,_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
-
-
-BOOLEAN
-STDCALL
-NtUserDestroyAcceleratorTable(
- HACCEL hAccel)
-{
- PWINSTATION_OBJECT WindowStation;
- PACCELERATOR_TABLE Accel;
- NTSTATUS Status;
- DECLARE_RETURN(BOOLEAN);
-
- /* 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.
- */
-
- DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", hAccel);
- UserEnterExclusive();
-
- Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
- UserMode,
- 0,
- &WindowStation);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(STATUS_ACCESS_DENIED);
- DPRINT1("E1\n");
- RETURN( FALSE);
- }
-
- if (!(Accel = UserGetAccelObject(hAccel)))
- {
- ObDereferenceObject(WindowStation);
- RETURN( FALSE);
- }
-
- ObmDeleteObject(hAccel, otAccel);
-
- if (Accel->Table != NULL)
- {
- ExFreePool(Accel->Table);
- }
-
- ObDereferenceObject(WindowStation);
-
- RETURN( TRUE);
-
-CLEANUP:
- DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
- UserLeave();
- END_CLEANUP;
-}
-
static
BOOLEAN FASTCALL
co_IntTranslateAccelerator(
@@ -299,7 +111,6 @@
if (wParam != key)
{
- DPRINT("T0\n");
return FALSE;
}
@@ -469,17 +280,156 @@
return TRUE;
}
+
+/* SYSCALLS *****************************************************************/
+
+
int
STDCALL
+NtUserCopyAcceleratorTable(
+ HACCEL hAccel,
+ LPACCEL Entries,
+ int EntriesCount)
+{
+ PACCELERATOR_TABLE Accel;
+ NTSTATUS Status;
+ int Ret;
+ DECLARE_RETURN(int);
+
+ DPRINT("Enter NtUserCopyAcceleratorTable\n");
+ UserEnterShared();
+
+ if (!(Accel = UserGetAccelObject(hAccel)))
+ {
+ RETURN(0);
+ }
+
+ if(Entries)
+ {
+ Ret = min(EntriesCount, Accel->Count);
+ Status = MmCopyToCaller(Entries, Accel->Table, Ret * sizeof(ACCEL));
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastNtError(Status);
+ RETURN(0);
+ }
+ }
+ else
+ {
+ Ret = Accel->Count;
+ }
+
+ RETURN(Ret);
+
+CLEANUP:
+ DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+HACCEL
+STDCALL
+NtUserCreateAcceleratorTable(
+ LPACCEL Entries,
+ SIZE_T EntriesCount)
+{
+ PACCELERATOR_TABLE Accel;
+ NTSTATUS Status;
+ HACCEL hAccel;
+ DECLARE_RETURN(HACCEL);
+
+ DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
+ Entries, EntriesCount);
+ UserEnterExclusive();
+
+ Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
+
+ if (Accel == NULL)
+ {
+ SetLastNtError(STATUS_NO_MEMORY);
+ RETURN( (HACCEL) 0 );
+ }
+
+ Accel->Count = EntriesCount;
+ if (Accel->Count > 0)
+ {
+ Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL), TAG_ACCEL);
+ if (Accel->Table == NULL)
+ {
+ ObmDeleteObject(hAccel, otAccel);
+ SetLastNtError(Status);
+ RETURN( (HACCEL) 0);
+ }
+
+ Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePool(Accel->Table);
+ ObmDeleteObject(hAccel, otAccel);
+ SetLastNtError(Status);
+ RETURN((HACCEL) 0);
+ }
+ }
+
+ /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
+
+ RETURN(hAccel);
+
+CLEANUP:
+ DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
+ Entries, EntriesCount,_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+
+
+BOOLEAN
+STDCALL
+NtUserDestroyAcceleratorTable(
+ HACCEL hAccel)
+{
+ PACCELERATOR_TABLE Accel;
+ DECLARE_RETURN(BOOLEAN);
+
+ /* 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.
+ */
+
+ DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", hAccel);
+ UserEnterExclusive();
+
+ if (!(Accel = UserGetAccelObject(hAccel)))
+ {
+ RETURN( FALSE);
+ }
+
+ ObmDeleteObject(hAccel, otAccel);
+
+ if (Accel->Table != NULL)
+ {
+ ExFreePool(Accel->Table);
+ }
+
+ RETURN( TRUE);
+
+CLEANUP:
+ DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
+ UserLeave();
+ END_CLEANUP;
+}
+
+
+int
+STDCALL
NtUserTranslateAccelerator(
HWND hWnd,
HACCEL hAccel,
LPMSG Message)
{
- PWINSTATION_OBJECT WindowStation = NULL;
PWINDOW_OBJECT Window = NULL;
PACCELERATOR_TABLE Accel = NULL;
- NTSTATUS Status;
ULONG i;
DECLARE_RETURN(int);
@@ -501,17 +451,6 @@
RETURN( 0);
}
- Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
- UserMode,
- 0,
- &WindowStation);
-
- if (!NT_SUCCESS(Status))
- {
- SetLastNtError(STATUS_ACCESS_DENIED);
- RETURN( 0);
- }
-
if (!(Accel = UserGetAccelObject(hAccel)))
{
RETURN( 0);
@@ -548,15 +487,9 @@
RETURN( 0);
CLEANUP:
+ if (Window) UserDerefObjectCo(Window);
+ if (Accel) UserDerefObjectCo(Accel);
- if (Window)
- UserDerefObjectCo(Window);
- if (Accel)
- UserDerefObjectCo(Accel);
-
- if (WindowStation)
- ObDereferenceObject(WindowStation);
-
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
hWnd, hAccel, Message, 0);
UserLeave();