Author: dchapyshev
Date: Thu Jan 8 13:35:29 2009
New Revision: 38651
URL:
http://svn.reactos.org/svn/reactos?rev=38651&view=rev
Log:
- Fix NtUserCopyAcceleratorTable and NtUserCreateAcceleratorTable (ported from Wine). This
is fixed 5 wine resources tests
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/accelerator.c [iso-8859-1] Thu Jan 8
13:35:29 2009
@@ -293,31 +293,39 @@
int EntriesCount)
{
PACCELERATOR_TABLE Accel;
- NTSTATUS Status;
int Ret;
+ BOOL Done = FALSE;
DECLARE_RETURN(int);
DPRINT("Enter NtUserCopyAcceleratorTable\n");
UserEnterShared();
- if (!(Accel = UserGetAccelObject(hAccel)))
+ Accel = UserGetAccelObject(hAccel);
+
+ if ((Entries && (EntriesCount < 1)) || ((hAccel == NULL) || (!Accel)))
{
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;
+ if (Accel->Count < EntriesCount)
+ EntriesCount = Accel->Count;
+
+ Ret = 0;
+
+ while (!Done)
+ {
+ if (Entries)
+ {
+ Entries[Ret].fVirt = Accel->Table[Ret].fVirt & 0x7f;
+ Entries[Ret].key = Accel->Table[Ret].key;
+ Entries[Ret].cmd = Accel->Table[Ret].cmd;
+
+ if(Ret + 1 == EntriesCount) Done = TRUE;
+ }
+
+ if((Accel->Table[Ret].fVirt & 0x80) != 0) Done = TRUE;
+
+ Ret++;
}
RETURN(Ret);
@@ -335,17 +343,18 @@
SIZE_T EntriesCount)
{
PACCELERATOR_TABLE Accel;
- NTSTATUS Status;
HACCEL hAccel;
+ INT Index;
DECLARE_RETURN(HACCEL);
DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
Entries, EntriesCount);
UserEnterExclusive();
- if (!Entries || !EntriesCount)
- {
- RETURN( (HACCEL) 0 );
+ if (!Entries || EntriesCount < 1)
+ {
+ SetLastNtError(STATUS_INVALID_PARAMETER);
+ RETURN( (HACCEL) NULL );
}
Accel = UserCreateObject(gHandleTable, (PHANDLE)&hAccel, otAccel,
sizeof(ACCELERATOR_TABLE));
@@ -353,7 +362,7 @@
if (Accel == NULL)
{
SetLastNtError(STATUS_NO_MEMORY);
- RETURN( (HACCEL) 0 );
+ RETURN( (HACCEL) NULL );
}
Accel->Count = EntriesCount;
@@ -365,18 +374,21 @@
UserDereferenceObject(Accel);
UserDeleteObject(hAccel, otAccel);
SetLastNtError(STATUS_NO_MEMORY);
- RETURN( (HACCEL) 0);
- }
-
- Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
- if (!NT_SUCCESS(Status))
- {
- ExFreePoolWithTag(Accel->Table, TAG_ACCEL);
- UserDereferenceObject(Accel);
- UserDeleteObject(hAccel, otAccel);
- SetLastNtError(Status);
- RETURN((HACCEL) 0);
- }
+ RETURN( (HACCEL) NULL);
+ }
+
+ for (Index = 0; Index < EntriesCount; Index++)
+ {
+ Accel->Table[Index].fVirt = Entries[Index].fVirt&0x7f;
+ if(Accel->Table[Index].fVirt & FVIRTKEY)
+ {
+ Accel->Table[Index].key = Entries[Index].key;
+ }
+ Accel->Table[Index].cmd = Entries[Index].cmd;
+ }
+
+ /* Set the end-of-table terminator. */
+ Accel->Table[EntriesCount - 1].fVirt |= 0x80;
}
/* FIXME: Save HandleTable in a list somewhere so we can clean it up again */