Author: rharabien
Date: Thu Sep 8 14:13:19 2011
New Revision: 53642
URL:
http://svn.reactos.org/svn/reactos?rev=53642&view=rev
Log:
[WIN32K]
- Simplify accelerators code a bit
- Set last error in NtUserCopyAcceleratorTable
- Fix user32:resource winetest regression
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 Sep 8
14:13:19 2011
@@ -291,19 +291,25 @@
{
PACCELERATOR_TABLE Accel;
int Ret;
- BOOL Done = FALSE;
DECLARE_RETURN(int);
TRACE("Enter NtUserCopyAcceleratorTable\n");
UserEnterShared();
Accel = UserGetAccelObject(hAccel);
-
- if ((Entries && (EntriesCount < 1)) || ((hAccel == NULL) || (!Accel)))
- {
- RETURN(0);
- }
-
+ if (!Accel)
+ {
+ EngSetLastError(ERROR_INVALID_ACCEL_HANDLE);
+ RETURN(0);
+ }
+
+ /* If Entries is NULL return table size */
+ if (!Entries)
+ {
+ RETURN(Accel->Count);
+ }
+
+ /* Don't overrun */
if (Accel->Count < EntriesCount)
EntriesCount = Accel->Count;
@@ -313,20 +319,11 @@
{
ProbeForWrite(Entries, EntriesCount*sizeof(Entries[0]), 4);
- while (!Done)
+ for (Ret = 0; Ret < EntriesCount; Ret++)
{
- 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++;
+ Entries[Ret].fVirt = Accel->Table[Ret].fVirt;
+ Entries[Ret].key = Accel->Table[Ret].key;
+ Entries[Ret].cmd = Accel->Table[Ret].cmd;
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -360,7 +357,7 @@
Entries, EntriesCount);
UserEnterExclusive();
- if (!Entries || EntriesCount < 1)
+ if (!Entries || EntriesCount <= 0)
{
SetLastNtError(STATUS_INVALID_PARAMETER);
RETURN( (HACCEL) NULL );
@@ -375,57 +372,51 @@
}
Accel->Count = EntriesCount;
- if (Accel->Count > 0)
- {
- Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL),
USERTAG_ACCEL);
- if (Accel->Table == NULL)
- {
- UserDereferenceObject(Accel);
- UserDeleteObject(hAccel, otAccel);
- SetLastNtError(STATUS_NO_MEMORY);
- RETURN( (HACCEL) NULL);
- }
-
- _SEH2_TRY
- {
- ProbeForRead(Entries, EntriesCount * sizeof(ACCEL), 4);
-
- 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;
- }
- else
- {
- RtlMultiByteToUnicodeN(&Accel->Table[Index].key,
- sizeof(WCHAR),
- NULL,
- (PCSTR)&Entries[Index].key,
- sizeof(CHAR));
- }
-
- Accel->Table[Index].cmd = Entries[Index].cmd;
- }
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- Status = _SEH2_GetExceptionCode();
- }
- _SEH2_END;
-
- if (!NT_SUCCESS(Status))
- {
- ExFreePoolWithTag(Accel->Table, USERTAG_ACCEL);
- UserDereferenceObject(Accel);
- UserDeleteObject(hAccel, otAccel);
- SetLastNtError(Status);
- RETURN( (HACCEL) NULL);
- }
-
- /* Set the end-of-table terminator. */
- Accel->Table[EntriesCount - 1].fVirt |= 0x80;
+ Accel->Table = ExAllocatePoolWithTag(PagedPool, EntriesCount * sizeof(ACCEL),
USERTAG_ACCEL);
+ if (Accel->Table == NULL)
+ {
+ UserDereferenceObject(Accel);
+ UserDeleteObject(hAccel, otAccel);
+ SetLastNtError(STATUS_NO_MEMORY);
+ RETURN( (HACCEL) NULL);
+ }
+
+ _SEH2_TRY
+ {
+ ProbeForRead(Entries, EntriesCount * sizeof(ACCEL), 4);
+
+ 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;
+ }
+ else
+ {
+ RtlMultiByteToUnicodeN(&Accel->Table[Index].key,
+ sizeof(WCHAR),
+ NULL,
+ (PCSTR)&Entries[Index].key,
+ sizeof(CHAR));
+ }
+
+ Accel->Table[Index].cmd = Entries[Index].cmd;
+ }
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePoolWithTag(Accel->Table, USERTAG_ACCEL);
+ UserDereferenceObject(Accel);
+ UserDeleteObject(hAccel, otAccel);
+ SetLastNtError(Status);
+ RETURN( (HACCEL) NULL);
}
/* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
@@ -546,10 +537,6 @@
hWnd, hAccel, pUnsafeMessage, 1);
RETURN( 1);
}
- if (((Accel->Table[i].fVirt & 0x80) > 0))
- {
- break;
- }
}
RETURN( 0);