indent with astyle v1.15.3: --style=ansi -c -s3 -S --convert-tabs

svn path=/trunk/; revision=17730
This commit is contained in:
Gunnar Dalsnes 2005-09-07 21:25:42 +00:00
parent 5d8ed11b10
commit 7c6de62098
34 changed files with 16907 additions and 16601 deletions

View file

@ -59,13 +59,13 @@
NTSTATUS FASTCALL
InitAcceleratorImpl(VOID)
{
return(STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
NTSTATUS FASTCALL
CleanupAcceleratorImpl(VOID)
{
return(STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
@ -73,7 +73,7 @@ static
PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
{
PACCELERATOR_TABLE Accel= UserGetObject(&gHandleTable, hAccel, otAccel);
if (Accel)
{
ASSERT(USER_BODY_TO_HEADER(Accel)->RefCount >= 0);
@ -92,132 +92,132 @@ PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
int
STDCALL
NtUserCopyAcceleratorTable(
HACCEL hAccel,
LPACCEL Entries,
int EntriesCount)
HACCEL hAccel,
LPACCEL Entries,
int EntriesCount)
{
PWINSTATION_OBJECT WindowStation;
PACCELERATOR_TABLE Accel;
NTSTATUS Status;
int Ret;
DECLARE_RETURN(int);
PWINSTATION_OBJECT WindowStation;
PACCELERATOR_TABLE Accel;
NTSTATUS Status;
int Ret;
DECLARE_RETURN(int);
DPRINT("Enter NtUserCopyAcceleratorTable\n");
UserEnterShared();
DPRINT("Enter NtUserCopyAcceleratorTable\n");
UserEnterShared();
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN(0);
}
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
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);
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN(0);
}
}
else
{
Ret = Accel->Count;
}
}
ObDereferenceObject(WindowStation);
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);
RETURN(Ret);
CLEANUP:
DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
HACCEL
STDCALL
NtUserCreateAcceleratorTable(
LPACCEL Entries,
SIZE_T EntriesCount)
LPACCEL Entries,
SIZE_T EntriesCount)
{
PWINSTATION_OBJECT WindowStation;
PACCELERATOR_TABLE Accel;
NTSTATUS Status;
HACCEL hAccel;
DECLARE_RETURN(HACCEL);
PWINSTATION_OBJECT WindowStation;
PACCELERATOR_TABLE Accel;
NTSTATUS Status;
HACCEL hAccel;
DECLARE_RETURN(HACCEL);
DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n",
Entries, EntriesCount);
UserEnterExclusive();
UserEnterExclusive();
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN( FALSE );
}
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
if (Accel == NULL)
{
ObDereferenceObject(WindowStation);
SetLastNtError(STATUS_NO_MEMORY);
RETURN( (HACCEL) 0 );
}
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN( FALSE );
}
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);
}
Accel = ObmCreateObject(&gHandleTable, (PHANDLE)&hAccel, otAccel, sizeof(ACCELERATOR_TABLE));
Status = MmCopyFromCaller(Accel->Table, Entries, EntriesCount * sizeof(ACCEL));
if (!NT_SUCCESS(Status))
{
ExFreePool(Accel->Table);
ObmDeleteObject(hAccel, otAccel);
if (Accel == NULL)
{
ObDereferenceObject(WindowStation);
SetLastNtError(Status);
RETURN((HACCEL) 0);
}
}
SetLastNtError(STATUS_NO_MEMORY);
RETURN( (HACCEL) 0 );
}
ObDereferenceObject(WindowStation);
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);
}
/* FIXME: Save HandleTable in a list somewhere so we can clean it up again */
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);
RETURN(hAccel);
CLEANUP:
DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
Entries, EntriesCount,_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n",
Entries, EntriesCount,_ret_);
UserLeave();
END_CLEANUP;
}
@ -225,219 +225,224 @@ CLEANUP:
BOOLEAN
STDCALL
NtUserDestroyAcceleratorTable(
HACCEL hAccel)
HACCEL hAccel)
{
PWINSTATION_OBJECT WindowStation;
PACCELERATOR_TABLE Accel;
NTSTATUS Status;
DECLARE_RETURN(BOOLEAN);
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.
*/
/* 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();
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);
}
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
if (!(Accel = UserGetAccelObject(hAccel)))
{
ObDereferenceObject(WindowStation);
RETURN( FALSE);
}
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
DPRINT1("E1\n");
RETURN( FALSE);
}
ObmDeleteObject(hAccel, otAccel);
if (!(Accel = UserGetAccelObject(hAccel)))
{
ObDereferenceObject(WindowStation);
RETURN( FALSE);
}
if (Accel->Table != NULL)
{
ExFreePool(Accel->Table);
}
ObmDeleteObject(hAccel, otAccel);
ObDereferenceObject(WindowStation);
if (Accel->Table != NULL)
{
ExFreePool(Accel->Table);
}
ObDereferenceObject(WindowStation);
RETURN( TRUE);
RETURN( TRUE);
CLEANUP:
DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", hAccel,_ret_);
UserLeave();
END_CLEANUP;
}
static
static
BOOLEAN FASTCALL
co_IntTranslateAccelerator(
PWINDOW_OBJECT Window,
UINT message,
WPARAM wParam,
LPARAM lParam,
BYTE fVirt,
WORD key,
WORD cmd)
PWINDOW_OBJECT Window,
UINT message,
WPARAM wParam,
LPARAM lParam,
BYTE fVirt,
WORD key,
WORD cmd)
{
UINT mesg = 0;
UINT mesg = 0;
ASSERT_REFS_CO(Window);
ASSERT_REFS_CO(Window);
DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
if (wParam != key)
{
if (wParam != key)
{
DPRINT("T0\n");
return FALSE;
}
}
if (message == WM_CHAR)
{
if (message == WM_CHAR)
{
if (!(fVirt & FALT) && !(fVirt & FVIRTKEY))
{
DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
goto found;
}
}
else
{
{
DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff);
goto found;
}
}
else
{
if ((fVirt & FVIRTKEY) > 0)
{
INT mask = 0;
DPRINT("found accel for virt_key %04x (scan %04x)\n",
wParam, 0xff & HIWORD(lParam));
{
INT mask = 0;
DPRINT("found accel for virt_key %04x (scan %04x)\n",
wParam, 0xff & HIWORD(lParam));
DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n",
UserGetKeyState(VK_SHIFT));
DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n",
UserGetKeyState(VK_CONTROL));
DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n",
UserGetKeyState(VK_MENU));
DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n",
UserGetKeyState(VK_SHIFT));
DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n",
UserGetKeyState(VK_CONTROL));
DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n",
UserGetKeyState(VK_MENU));
if (UserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
if (UserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
if (UserGetKeyState(VK_MENU) & 0x8000) mask |= FALT;
if (mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found;
DPRINT("but incorrect SHIFT/CTRL/ALT-state\n");
}
if (UserGetKeyState(VK_SHIFT) & 0x8000)
mask |= FSHIFT;
if (UserGetKeyState(VK_CONTROL) & 0x8000)
mask |= FCONTROL;
if (UserGetKeyState(VK_MENU) & 0x8000)
mask |= FALT;
if (mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
goto found;
DPRINT("but incorrect SHIFT/CTRL/ALT-state\n");
}
else
{
if (!(lParam & 0x01000000)) /* no special_key */
{
if ((fVirt & FALT) && (lParam & 0x20000000))
{ /* ^^ ALT pressed */
DPRINT("found accel for Alt-%c\n", wParam & 0xff);
goto found;
}
{
if (!(lParam & 0x01000000)) /* no special_key */
{
if ((fVirt & FALT) && (lParam & 0x20000000))
{ /* ^^ ALT pressed */
DPRINT("found accel for Alt-%c\n", wParam & 0xff);
goto found;
}
}
}
}
}
}
DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
DPRINT("IntTranslateAccelerator(hwnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
return FALSE;
return FALSE;
found:
if (message == WM_KEYUP || message == WM_SYSKEYUP)
mesg = 1;
else if (IntGetCaptureWindow())
mesg = 2;
else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
mesg = 3;
else
{
found:
if (message == WM_KEYUP || message == WM_SYSKEYUP)
mesg = 1;
else if (IntGetCaptureWindow())
mesg = 2;
else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
mesg = 3;
else
{
#if 0
HMENU hMenu, hSubMenu, hSysMenu;
UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos;
HMENU hMenu, hSubMenu, hSysMenu;
UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos;
hMenu = (UserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd);
hSysMenu = get_win_sys_menu(hWnd);
hMenu = (UserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd);
hSysMenu = get_win_sys_menu(hWnd);
/* find menu item and ask application to initialize it */
/* 1. in the system menu */
hSubMenu = hSysMenu;
nPos = cmd;
if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
{
co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
if(hSubMenu != hSysMenu)
/* find menu item and ask application to initialize it */
/* 1. in the system menu */
hSubMenu = hSysMenu;
nPos = cmd;
if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
{
co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
if(hSubMenu != hSysMenu)
{
nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
}
uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
}
else /* 2. in the window's menu */
{
hSubMenu = hMenu;
nPos = cmd;
if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
{
co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
if(hSubMenu != hMenu)
{
nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos);
co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
}
uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
}
else /* 2. in the window's menu */
{
hSubMenu = hMenu;
nPos = cmd;
if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
{
co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
if(hSubMenu != hMenu)
{
nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos);
co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
}
uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
}
}
uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
}
}
if (uSysStat != (UINT)-1)
{
if (uSysStat & (MF_DISABLED|MF_GRAYED))
mesg=4;
if (uSysStat != (UINT)-1)
{
if (uSysStat & (MF_DISABLED|MF_GRAYED))
mesg=4;
else
mesg=WM_SYSCOMMAND;
}
else
{
if (uStat != (UINT)-1)
{
if (IsIconic(hWnd))
mesg=5;
else
mesg=WM_SYSCOMMAND;
}
else
{
if (uStat != (UINT)-1)
{
if (IsIconic(hWnd))
mesg=5;
else
{
if (uStat & (MF_DISABLED|MF_GRAYED))
mesg=6;
else
mesg=WM_COMMAND;
}
if (uStat & (MF_DISABLED|MF_GRAYED))
mesg=6;
else
mesg=WM_COMMAND;
}
else
{
mesg=WM_COMMAND;
}
}
}
else
{
mesg=WM_COMMAND;
}
}
#else
DPRINT1("menu search not implemented");
mesg = WM_COMMAND;
#endif
}
if (mesg == WM_COMMAND)
{
}
if (mesg == WM_COMMAND)
{
DPRINT(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd);
co_IntSendMessage(Window->hSelf, mesg, 0x10000 | cmd, 0L);
}
else if (mesg == WM_SYSCOMMAND)
{
}
else if (mesg == WM_SYSCOMMAND)
{
DPRINT(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd);
co_IntSendMessage(Window->hSelf, mesg, cmd, 0x00010000L);
}
else
{
}
else
{
/* some reasons for NOT sending the WM_{SYS}COMMAND message:
* #0: unknown (please report!)
* #1: for WM_KEYUP,WM_SYSKEYUP
@ -449,104 +454,107 @@ co_IntTranslateAccelerator(
*/
DPRINT(", but won't send WM_{SYS}COMMAND, reason is #%d\n", mesg);
if (mesg == 0)
{
DPRINT1(" unknown reason - please report!");
}
}
{
DPRINT1(" unknown reason - please report!");
}
}
DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n",
Window->hSelf, message, wParam, lParam, fVirt, key, cmd);
return TRUE;
return TRUE;
}
int
STDCALL
NtUserTranslateAccelerator(
HWND hWnd,
HACCEL hAccel,
LPMSG Message)
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);
PWINSTATION_OBJECT WindowStation = NULL;
PWINDOW_OBJECT Window = NULL;
PACCELERATOR_TABLE Accel = NULL;
NTSTATUS Status;
ULONG i;
DECLARE_RETURN(int);
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n",
hWnd, hAccel, Message);
UserEnterShared();
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n",
hWnd, hAccel, Message);
UserEnterShared();
if (Message == NULL)
{
SetLastNtError(STATUS_INVALID_PARAMETER);
if (Message == NULL)
{
SetLastNtError(STATUS_INVALID_PARAMETER);
RETURN( 0);
}
}
if ((Message->message != WM_KEYDOWN) &&
(Message->message != WM_SYSKEYDOWN) &&
(Message->message != WM_SYSCHAR) &&
(Message->message != WM_CHAR))
{
RETURN( 0);
}
if ((Message->message != WM_KEYDOWN) &&
(Message->message != WM_SYSKEYDOWN) &&
(Message->message != WM_SYSCHAR) &&
(Message->message != WM_CHAR))
{
RETURN( 0);
}
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN( 0);
}
Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(),
UserMode,
0,
&WindowStation);
if (!(Accel = UserGetAccelObject(hAccel)))
{
RETURN( 0);
}
if (!NT_SUCCESS(Status))
{
SetLastNtError(STATUS_ACCESS_DENIED);
RETURN( 0);
}
UserRefObjectCo(Accel);
if (!(Accel = UserGetAccelObject(hAccel)))
{
RETURN( 0);
}
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( 0);
}
UserRefObjectCo(Accel);
UserRefObjectCo(Window);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( 0);
}
/* FIXME: Associate AcceleratorTable with the current thread */
UserRefObjectCo(Window);
for (i = 0; i < Accel->Count; i++)
{
/* FIXME: Associate AcceleratorTable with the current thread */
for (i = 0; i < Accel->Count; i++)
{
if (co_IntTranslateAccelerator(Window, Message->message, Message->wParam, Message->lParam,
Accel->Table[i].fVirt, Accel->Table[i].key,
Accel->Table[i].cmd))
{
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
hWnd, hAccel, Message, 1);
RETURN( 1);
}
Accel->Table[i].fVirt, Accel->Table[i].key,
Accel->Table[i].cmd))
{
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
hWnd, hAccel, Message, 1);
RETURN( 1);
}
if (((Accel->Table[i].fVirt & 0x80) > 0))
{
break;
}
}
{
break;
}
}
RETURN( 0);
RETURN( 0);
CLEANUP:
if (Window) UserDerefObjectCo(Window);
if (Accel) UserDerefObjectCo(Accel);
if (WindowStation) ObDereferenceObject(WindowStation);
if (Window)
UserDerefObjectCo(Window);
if (Accel)
UserDerefObjectCo(Accel);
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
hWnd, hAccel, Message, 0);
UserLeave();
END_CLEANUP;
if (WindowStation)
ObDereferenceObject(WindowStation);
DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n",
hWnd, hAccel, Message, 0);
UserLeave();
END_CLEANUP;
}

View file

@ -42,368 +42,369 @@
typedef struct _INT_CALLBACK_HEADER
{
/* list entry in the W32THREAD structure */
LIST_ENTRY ListEntry;
} INT_CALLBACK_HEADER, *PINT_CALLBACK_HEADER;
/* list entry in the W32THREAD structure */
LIST_ENTRY ListEntry;
}
INT_CALLBACK_HEADER, *PINT_CALLBACK_HEADER;
PVOID FASTCALL
IntCbAllocateMemory(ULONG Size)
{
PINT_CALLBACK_HEADER Mem;
PW32THREAD W32Thread;
PINT_CALLBACK_HEADER Mem;
PW32THREAD W32Thread;
if(!(Mem = ExAllocatePoolWithTag(PagedPool, Size + sizeof(INT_CALLBACK_HEADER),
TAG_CALLBACK)))
{
return NULL;
}
if(!(Mem = ExAllocatePoolWithTag(PagedPool, Size + sizeof(INT_CALLBACK_HEADER),
TAG_CALLBACK)))
{
return NULL;
}
W32Thread = PsGetWin32Thread();
ASSERT(W32Thread);
W32Thread = PsGetWin32Thread();
ASSERT(W32Thread);
/* insert the callback memory into the thread's callback list */
/* insert the callback memory into the thread's callback list */
InsertTailList(&W32Thread->W32CallbackListHead, &Mem->ListEntry);
InsertTailList(&W32Thread->W32CallbackListHead, &Mem->ListEntry);
return (Mem + 1);
return (Mem + 1);
}
VOID FASTCALL
IntCbFreeMemory(PVOID Data)
{
PINT_CALLBACK_HEADER Mem;
PW32THREAD W32Thread;
PINT_CALLBACK_HEADER Mem;
PW32THREAD W32Thread;
ASSERT(Data);
ASSERT(Data);
Mem = ((PINT_CALLBACK_HEADER)Data - 1);
Mem = ((PINT_CALLBACK_HEADER)Data - 1);
W32Thread = PsGetWin32Thread();
ASSERT(W32Thread);
W32Thread = PsGetWin32Thread();
ASSERT(W32Thread);
/* remove the memory block from the thread's callback list */
RemoveEntryList(&Mem->ListEntry);
/* remove the memory block from the thread's callback list */
RemoveEntryList(&Mem->ListEntry);
/* free memory */
ExFreePool(Mem);
/* free memory */
ExFreePool(Mem);
}
VOID FASTCALL
IntCleanupThreadCallbacks(PW32THREAD W32Thread)
{
PLIST_ENTRY CurrentEntry;
PINT_CALLBACK_HEADER Mem;
PLIST_ENTRY CurrentEntry;
PINT_CALLBACK_HEADER Mem;
while (!IsListEmpty(&W32Thread->W32CallbackListHead))
{
CurrentEntry = RemoveHeadList(&W32Thread->W32CallbackListHead);
Mem = CONTAINING_RECORD(CurrentEntry, INT_CALLBACK_HEADER,
ListEntry);
while (!IsListEmpty(&W32Thread->W32CallbackListHead))
{
CurrentEntry = RemoveHeadList(&W32Thread->W32CallbackListHead);
Mem = CONTAINING_RECORD(CurrentEntry, INT_CALLBACK_HEADER,
ListEntry);
/* free memory */
ExFreePool(Mem);
}
/* free memory */
ExFreePool(Mem);
}
}
/* FUNCTIONS *****************************************************************/
VOID STDCALL
co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
HWND hWnd,
UINT Msg,
ULONG_PTR CompletionCallbackContext,
LRESULT Result)
HWND hWnd,
UINT Msg,
ULONG_PTR CompletionCallbackContext,
LRESULT Result)
{
SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
NTSTATUS Status;
SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
NTSTATUS Status;
Arguments.Callback = CompletionCallback;
Arguments.Wnd = hWnd;
Arguments.Msg = Msg;
Arguments.Context = CompletionCallbackContext;
Arguments.Result = Result;
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
&Arguments,
sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
NULL,
NULL);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
Arguments.Callback = CompletionCallback;
Arguments.Wnd = hWnd;
Arguments.Msg = Msg;
Arguments.Context = CompletionCallbackContext;
Arguments.Result = Result;
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
&Arguments,
sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
NULL,
NULL);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
return;
}
return;
}
return;
}
LRESULT STDCALL
co_IntCallWindowProc(WNDPROC Proc,
BOOLEAN IsAnsiProc,
HWND Wnd,
UINT Message,
WPARAM wParam,
LPARAM lParam,
INT lParamBufferSize)
BOOLEAN IsAnsiProc,
HWND Wnd,
UINT Message,
WPARAM wParam,
LPARAM lParam,
INT lParamBufferSize)
{
WINDOWPROC_CALLBACK_ARGUMENTS StackArguments;
PWINDOWPROC_CALLBACK_ARGUMENTS Arguments;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
ULONG ArgumentLength;
LRESULT Result;
WINDOWPROC_CALLBACK_ARGUMENTS StackArguments;
PWINDOWPROC_CALLBACK_ARGUMENTS Arguments;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
ULONG ArgumentLength;
LRESULT Result;
if (0 < lParamBufferSize)
{
if (0 < lParamBufferSize)
{
ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS) + lParamBufferSize;
Arguments = IntCbAllocateMemory(ArgumentLength);
if (NULL == Arguments)
{
DPRINT1("Unable to allocate buffer for window proc callback\n");
return -1;
}
{
DPRINT1("Unable to allocate buffer for window proc callback\n");
return -1;
}
RtlMoveMemory((PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
(PVOID) lParam, lParamBufferSize);
}
else
{
}
else
{
Arguments = &StackArguments;
ArgumentLength = sizeof(WINDOWPROC_CALLBACK_ARGUMENTS);
}
Arguments->Proc = Proc;
Arguments->IsAnsiProc = IsAnsiProc;
Arguments->Wnd = Wnd;
Arguments->Msg = Message;
Arguments->wParam = wParam;
Arguments->lParam = lParam;
Arguments->lParamBufferSize = lParamBufferSize;
ResultPointer = Arguments;
ResultLength = ArgumentLength;
}
Arguments->Proc = Proc;
Arguments->IsAnsiProc = IsAnsiProc;
Arguments->Wnd = Wnd;
Arguments->Msg = Message;
Arguments->wParam = wParam;
Arguments->lParam = lParam;
Arguments->lParamBufferSize = lParamBufferSize;
ResultPointer = Arguments;
ResultLength = ArgumentLength;
UserLeaveCo();
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
Arguments,
ArgumentLength,
&ResultPointer,
&ResultLength);
Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
Arguments,
ArgumentLength,
&ResultPointer,
&ResultLength);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
UserEnterCo();
if (!NT_SUCCESS(Status))
{
if (0 < lParamBufferSize)
{
IntCbFreeMemory(Arguments);
}
{
IntCbFreeMemory(Arguments);
}
return -1;
}
Result = Arguments->Result;
}
Result = Arguments->Result;
if (0 < lParamBufferSize)
{
if (0 < lParamBufferSize)
{
RtlMoveMemory((PVOID) lParam,
(PVOID) ((char *) Arguments + sizeof(WINDOWPROC_CALLBACK_ARGUMENTS)),
lParamBufferSize);
IntCbFreeMemory(Arguments);
}
}
return Result;
return Result;
}
HMENU STDCALL
co_IntLoadSysMenuTemplate()
{
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
NULL,
0,
&ResultPointer,
&ResultLength);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
NULL,
0,
&ResultPointer,
&ResultLength);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
return(0);
}
return (HMENU)Result;
}
return (HMENU)Result;
}
BOOL STDCALL
co_IntLoadDefaultCursors(VOID)
{
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
BOOL DefaultCursor = TRUE;
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
BOOL DefaultCursor = TRUE;
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
&DefaultCursor,
sizeof(BOOL),
&ResultPointer,
&ResultLength);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
&DefaultCursor,
sizeof(BOOL),
&ResultPointer,
&ResultLength);
UserEnterCo();
if (!NT_SUCCESS(Status))
{
return FALSE;
}
return TRUE;
}
return TRUE;
}
LRESULT STDCALL
co_IntCallHookProc(INT HookId,
INT Code,
WPARAM wParam,
LPARAM lParam,
HOOKPROC Proc,
BOOLEAN Ansi,
PUNICODE_STRING ModuleName)
INT Code,
WPARAM wParam,
LPARAM lParam,
HOOKPROC Proc,
BOOLEAN Ansi,
PUNICODE_STRING ModuleName)
{
ULONG ArgumentLength;
PVOID Argument;
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
PHOOKPROC_CALLBACK_ARGUMENTS Common;
CBT_CREATEWNDW *CbtCreateWnd =NULL;
PCHAR Extra;
PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra ;
PUNICODE_STRING WindowName = NULL;
PUNICODE_STRING ClassName = NULL;
ULONG ArgumentLength;
PVOID Argument;
LRESULT Result;
NTSTATUS Status;
PVOID ResultPointer;
ULONG ResultLength;
PHOOKPROC_CALLBACK_ARGUMENTS Common;
CBT_CREATEWNDW *CbtCreateWnd =NULL;
PCHAR Extra;
PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS CbtCreatewndExtra ;
PUNICODE_STRING WindowName = NULL;
PUNICODE_STRING ClassName = NULL;
ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
+ ModuleName->Length;
switch(HookId)
{
case WH_CBT:
switch(Code)
{
case HCBT_CREATEWND:
CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
WindowName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszName);
ArgumentLength += WindowName->Length + sizeof(WCHAR);
ClassName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszClass);
if (! IS_ATOM(ClassName->Buffer))
{
ArgumentLength += ClassName->Length + sizeof(WCHAR);
}
break;
default:
DPRINT1("Trying to call unsupported CBT hook %d\n", Code);
return 0;
}
break;
case WH_KEYBOARD_LL:
ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
break;
case WH_MOUSE_LL:
ArgumentLength += sizeof(MSLLHOOKSTRUCT);
break;
default:
DPRINT1("Trying to call unsupported window hook %d\n", HookId);
return 0;
}
ArgumentLength = sizeof(HOOKPROC_CALLBACK_ARGUMENTS) - sizeof(WCHAR)
+ ModuleName->Length;
switch(HookId)
{
case WH_CBT:
switch(Code)
{
case HCBT_CREATEWND:
CbtCreateWnd = (CBT_CREATEWNDW *) lParam;
ArgumentLength += sizeof(HOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS);
WindowName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszName);
ArgumentLength += WindowName->Length + sizeof(WCHAR);
ClassName = (PUNICODE_STRING) (CbtCreateWnd->lpcs->lpszClass);
if (! IS_ATOM(ClassName->Buffer))
{
ArgumentLength += ClassName->Length + sizeof(WCHAR);
}
break;
default:
DPRINT1("Trying to call unsupported CBT hook %d\n", Code);
return 0;
}
break;
case WH_KEYBOARD_LL:
ArgumentLength += sizeof(KBDLLHOOKSTRUCT);
break;
case WH_MOUSE_LL:
ArgumentLength += sizeof(MSLLHOOKSTRUCT);
break;
default:
DPRINT1("Trying to call unsupported window hook %d\n", HookId);
return 0;
}
Argument = IntCbAllocateMemory(ArgumentLength);
if (NULL == Argument)
{
Argument = IntCbAllocateMemory(ArgumentLength);
if (NULL == Argument)
{
DPRINT1("HookProc callback failed: out of memory\n");
return 0;
}
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Argument;
Common->HookId = HookId;
Common->Code = Code;
Common->wParam = wParam;
Common->lParam = lParam;
Common->Proc = Proc;
Common->Ansi = Ansi;
Common->ModuleNameLength = ModuleName->Length;
memcpy(Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
Extra = (PCHAR) Common->ModuleName + Common->ModuleNameLength;
}
Common = (PHOOKPROC_CALLBACK_ARGUMENTS) Argument;
Common->HookId = HookId;
Common->Code = Code;
Common->wParam = wParam;
Common->lParam = lParam;
Common->Proc = Proc;
Common->Ansi = Ansi;
Common->ModuleNameLength = ModuleName->Length;
memcpy(Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
Extra = (PCHAR) Common->ModuleName + Common->ModuleNameLength;
switch(HookId)
{
case WH_CBT:
switch(Code)
{
case HCBT_CREATEWND:
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
CbtCreatewndExtra->Cs = *(CbtCreateWnd->lpcs);
CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
Extra = (PCHAR) (CbtCreatewndExtra + 1);
RtlCopyMemory(Extra, WindowName->Buffer, WindowName->Length);
CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
CbtCreatewndExtra->Cs.lpszClass = ClassName->Buffer;
Extra += WindowName->Length;
*((WCHAR *) Extra) = L'\0';
Extra += sizeof(WCHAR);
if (! IS_ATOM(ClassName->Buffer))
{
RtlCopyMemory(Extra, ClassName->Buffer, ClassName->Length);
CbtCreatewndExtra->Cs.lpszClass =
(LPCWSTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
Extra += ClassName->Length;
*((WCHAR *) Extra) = L'\0';
}
break;
}
break;
case WH_KEYBOARD_LL:
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
break;
case WH_MOUSE_LL:
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
break;
}
switch(HookId)
{
case WH_CBT:
switch(Code)
{
case HCBT_CREATEWND:
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
CbtCreatewndExtra = (PHOOKPROC_CBT_CREATEWND_EXTRA_ARGUMENTS) Extra;
CbtCreatewndExtra->Cs = *(CbtCreateWnd->lpcs);
CbtCreatewndExtra->WndInsertAfter = CbtCreateWnd->hwndInsertAfter;
Extra = (PCHAR) (CbtCreatewndExtra + 1);
RtlCopyMemory(Extra, WindowName->Buffer, WindowName->Length);
CbtCreatewndExtra->Cs.lpszName = (LPCWSTR) (Extra - (PCHAR) CbtCreatewndExtra);
CbtCreatewndExtra->Cs.lpszClass = ClassName->Buffer;
Extra += WindowName->Length;
*((WCHAR *) Extra) = L'\0';
Extra += sizeof(WCHAR);
if (! IS_ATOM(ClassName->Buffer))
{
RtlCopyMemory(Extra, ClassName->Buffer, ClassName->Length);
CbtCreatewndExtra->Cs.lpszClass =
(LPCWSTR) MAKELONG(Extra - (PCHAR) CbtCreatewndExtra, 1);
Extra += ClassName->Length;
*((WCHAR *) Extra) = L'\0';
}
break;
}
break;
case WH_KEYBOARD_LL:
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(KBDLLHOOKSTRUCT));
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
break;
case WH_MOUSE_LL:
RtlCopyMemory(Extra, (PVOID) lParam, sizeof(MSLLHOOKSTRUCT));
Common->lParam = (LPARAM) (Extra - (PCHAR) Common);
break;
}
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
ResultPointer = &Result;
ResultLength = sizeof(LRESULT);
UserLeaveCo();
UserLeaveCo();
Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
Argument,
ArgumentLength,
&ResultPointer,
&ResultLength);
Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
Argument,
ArgumentLength,
&ResultPointer,
&ResultLength);
UserEnterCo();
UserEnterCo();
IntCbFreeMemory(Argument);
IntCbFreeMemory(Argument);
if (!NT_SUCCESS(Status))
{
if (!NT_SUCCESS(Status))
{
return 0;
}
}
return Result;
return Result;
}
/* EOF */

View file

@ -23,192 +23,192 @@
BOOL FASTCALL
co_IntHideCaret(PTHRDCARETINFO CaretInfo)
{
if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
{
co_IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
CaretInfo->Showing = 0;
return TRUE;
}
return FALSE;
if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
{
co_IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
CaretInfo->Showing = 0;
return TRUE;
}
return FALSE;
}
BOOL FASTCALL
co_IntDestroyCaret(PW32THREAD Win32Thread)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
if(!ThreadQueue || !ThreadQueue->CaretInfo)
return FALSE;
if(!ThreadQueue || !ThreadQueue->CaretInfo)
return FALSE;
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
ThreadQueue->CaretInfo->hWnd = (HWND)0;
ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->Visible = 0;
return TRUE;
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
ThreadQueue->CaretInfo->hWnd = (HWND)0;
ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->Visible = 0;
return TRUE;
}
BOOL FASTCALL
IntSetCaretBlinkTime(UINT uMSeconds)
{
/* Don't save the new value to the registry! */
PWINSTATION_OBJECT WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
/* Don't save the new value to the registry! */
PWINSTATION_OBJECT WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
/* windows doesn't do this check */
if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
ObDereferenceObject(WinStaObject);
return FALSE;
}
/* windows doesn't do this check */
if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE))
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
ObDereferenceObject(WinStaObject);
return FALSE;
}
WinStaObject->CaretBlinkRate = uMSeconds;
WinStaObject->CaretBlinkRate = uMSeconds;
return TRUE;
return TRUE;
}
UINT FASTCALL
IntQueryCaretBlinkRate(VOID)
{
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(CARET_REGKEY);
UNICODE_STRING ValueName = RTL_CONSTANT_STRING(CARET_VALUENAME);
NTSTATUS Status;
HANDLE KeyHandle = NULL;
OBJECT_ATTRIBUTES KeyAttributes;
PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
ULONG Length = 0;
ULONG ResLength = 0;
ULONG Val = 0;
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(CARET_REGKEY);
UNICODE_STRING ValueName = RTL_CONSTANT_STRING(CARET_VALUENAME);
NTSTATUS Status;
HANDLE KeyHandle = NULL;
OBJECT_ATTRIBUTES KeyAttributes;
PKEY_VALUE_PARTIAL_INFORMATION KeyValuePartialInfo;
ULONG Length = 0;
ULONG ResLength = 0;
ULONG Val = 0;
InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
NULL, NULL);
InitializeObjectAttributes(&KeyAttributes, &KeyName, OBJ_CASE_INSENSITIVE,
NULL, NULL);
Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
if(!NT_SUCCESS(Status))
{
return 0;
}
Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
if(!NT_SUCCESS(Status))
{
return 0;
}
Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
0, 0, &ResLength);
if((Status != STATUS_BUFFER_TOO_SMALL))
{
NtClose(KeyHandle);
return 0;
}
Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
0, 0, &ResLength);
if((Status != STATUS_BUFFER_TOO_SMALL))
{
NtClose(KeyHandle);
return 0;
}
ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
Length = ResLength;
ResLength += sizeof(KEY_VALUE_PARTIAL_INFORMATION);
KeyValuePartialInfo = ExAllocatePoolWithTag(PagedPool, ResLength, TAG_STRING);
Length = ResLength;
if(!KeyValuePartialInfo)
{
NtClose(KeyHandle);
return 0;
}
if(!KeyValuePartialInfo)
{
NtClose(KeyHandle);
return 0;
}
Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
(PVOID)KeyValuePartialInfo, Length, &ResLength);
if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
{
NtClose(KeyHandle);
ExFreePool(KeyValuePartialInfo);
return 0;
}
Status = ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation,
(PVOID)KeyValuePartialInfo, Length, &ResLength);
if(!NT_SUCCESS(Status) || (KeyValuePartialInfo->Type != REG_SZ))
{
NtClose(KeyHandle);
ExFreePool(KeyValuePartialInfo);
return 0;
}
ValueName.Length = KeyValuePartialInfo->DataLength;
ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
ValueName.Length = KeyValuePartialInfo->DataLength;
ValueName.MaximumLength = KeyValuePartialInfo->DataLength;
ValueName.Buffer = (PWSTR)KeyValuePartialInfo->Data;
Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
if(!NT_SUCCESS(Status))
{
Val = 0;
}
Status = RtlUnicodeStringToInteger(&ValueName, 0, &Val);
if(!NT_SUCCESS(Status))
{
Val = 0;
}
ExFreePool(KeyValuePartialInfo);
NtClose(KeyHandle);
ExFreePool(KeyValuePartialInfo);
NtClose(KeyHandle);
return (UINT)Val;
return (UINT)Val;
}
UINT FASTCALL
IntGetCaretBlinkTime(VOID)
{
PWINSTATION_OBJECT WinStaObject;
UINT Ret;
PWINSTATION_OBJECT WinStaObject;
UINT Ret;
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
Ret = WinStaObject->CaretBlinkRate;
if(!Ret)
{
/* load it from the registry the first call only! */
Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
}
Ret = WinStaObject->CaretBlinkRate;
if(!Ret)
{
/* load it from the registry the first call only! */
Ret = WinStaObject->CaretBlinkRate = IntQueryCaretBlinkRate();
}
/* windows doesn't do this check */
if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
{
Ret = DEFAULT_CARETBLINKRATE;
}
/* windows doesn't do this check */
if((Ret < MIN_CARETBLINKRATE) || (Ret > MAX_CARETBLINKRATE))
{
Ret = DEFAULT_CARETBLINKRATE;
}
return Ret;
return Ret;
}
BOOL FASTCALL
co_IntSetCaretPos(int X, int Y)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(ThreadQueue->CaretInfo->hWnd)
{
if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
{
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->Pos.x = X;
ThreadQueue->CaretInfo->Pos.y = Y;
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
}
return TRUE;
}
if(ThreadQueue->CaretInfo->hWnd)
{
if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
{
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->Pos.x = X;
ThreadQueue->CaretInfo->Pos.y = Y;
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
}
return TRUE;
}
return FALSE;
return FALSE;
}
BOOL FASTCALL
IntSwitchCaretShowing(PVOID Info)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(ThreadQueue->CaretInfo->hWnd)
{
ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
return TRUE;
}
if(ThreadQueue->CaretInfo->hWnd)
{
ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
return TRUE;
}
return FALSE;
return FALSE;
}
VOID FASTCALL
co_IntDrawCaret(HWND hWnd)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible &&
ThreadQueue->CaretInfo->Showing)
{
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
ThreadQueue->CaretInfo->Showing = 1;
}
if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible &&
ThreadQueue->CaretInfo->Showing)
{
co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
ThreadQueue->CaretInfo->Showing = 1;
}
}
@ -216,63 +216,63 @@ co_IntDrawCaret(HWND hWnd)
BOOL
STDCALL
NtUserCreateCaret(
HWND hWnd,
HBITMAP hBitmap,
int nWidth,
int nHeight)
HWND hWnd,
HBITMAP hBitmap,
int nWidth,
int nHeight)
{
PWINDOW_OBJECT WindowObject;
PUSER_MESSAGE_QUEUE ThreadQueue;
DECLARE_RETURN(BOOL);
PWINDOW_OBJECT WindowObject;
PUSER_MESSAGE_QUEUE ThreadQueue;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserCreateCaret\n");
UserEnterExclusive();
DPRINT("Enter NtUserCreateCaret\n");
UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
RETURN(FALSE);
}
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
RETURN(FALSE);
}
if(WindowObject->OwnerThread != PsGetCurrentThread())
{
IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_ACCESS_DENIED);
RETURN(FALSE);
}
if(WindowObject->OwnerThread != PsGetCurrentThread())
{
IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_ACCESS_DENIED);
RETURN(FALSE);
}
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if (ThreadQueue->CaretInfo->Visible)
{
IntKillTimer(hWnd, IDCARETTIMER, TRUE);
co_IntHideCaret(ThreadQueue->CaretInfo);
}
if (ThreadQueue->CaretInfo->Visible)
{
IntKillTimer(hWnd, IDCARETTIMER, TRUE);
co_IntHideCaret(ThreadQueue->CaretInfo);
}
ThreadQueue->CaretInfo->hWnd = hWnd;
if(hBitmap)
{
ThreadQueue->CaretInfo->Bitmap = hBitmap;
ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
}
else
{
ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
ThreadQueue->CaretInfo->Size.cx = nWidth;
ThreadQueue->CaretInfo->Size.cy = nHeight;
}
ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->hWnd = hWnd;
if(hBitmap)
{
ThreadQueue->CaretInfo->Bitmap = hBitmap;
ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
}
else
{
ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
ThreadQueue->CaretInfo->Size.cx = nWidth;
ThreadQueue->CaretInfo->Size.cy = nHeight;
}
ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0;
IntReleaseWindowObject(WindowObject);
IntReleaseWindowObject(WindowObject);
RETURN(TRUE);
RETURN(TRUE);
CLEANUP:
DPRINT("Leave NtUserCreateCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserCreateCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
UINT
@ -283,9 +283,9 @@ NtUserGetCaretBlinkTime(VOID)
DPRINT("Enter NtUserGetCaretBlinkTime\n");
UserEnterExclusive();
RETURN(IntGetCaretBlinkTime());
CLEANUP:
DPRINT("Leave NtUserGetCaretBlinkTime, ret=%i\n",_ret_);
UserLeave();
@ -295,99 +295,99 @@ CLEANUP:
BOOL
STDCALL
NtUserGetCaretPos(
LPPOINT lpPoint)
LPPOINT lpPoint)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
PUSER_MESSAGE_QUEUE ThreadQueue;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserGetCaretPos\n");
UserEnterShared();
DPRINT("Enter NtUserGetCaretPos\n");
UserEnterShared();
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
}
Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
}
RETURN(TRUE);
RETURN(TRUE);
CLEANUP:
DPRINT("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
if(WindowObject->OwnerThread != PsGetCurrentThread())
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(WindowObject->OwnerThread != PsGetCurrentThread())
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf)
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(ThreadQueue->CaretInfo->Visible)
{
IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE);
if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf)
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0;
}
return TRUE;
}
if(ThreadQueue->CaretInfo->Visible)
{
IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE);
co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0;
}
return TRUE;
}
BOOL
STDCALL
NtUserHideCaret(
HWND hWnd)
HWND hWnd)
{
PWINDOW_OBJECT WindowObject;
DECLARE_RETURN(BOOL);
BOOL ret;
PWINDOW_OBJECT WindowObject;
DECLARE_RETURN(BOOL);
BOOL ret;
DPRINT("Enter NtUserHideCaret\n");
UserEnterExclusive();
DPRINT("Enter NtUserHideCaret\n");
UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE);
}
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE);
}
ret = co_UserHideCaret(WindowObject);
IntReleaseWindowObject(WindowObject);
ret = co_UserHideCaret(WindowObject);
IntReleaseWindowObject(WindowObject);
RETURN(ret);
RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
{
PUSER_MESSAGE_QUEUE ThreadQueue;
if(Window->OwnerThread != PsGetCurrentThread())
{
SetLastWin32Error(ERROR_ACCESS_DENIED);
@ -411,7 +411,7 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
}
IntSetTimer(Window->hSelf, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
}
return TRUE;
}
@ -419,28 +419,28 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window)
BOOL
STDCALL
NtUserShowCaret(
HWND hWnd)
HWND hWnd)
{
PWINDOW_OBJECT WindowObject;
DECLARE_RETURN(BOOL);
BOOL ret;
PWINDOW_OBJECT WindowObject;
DECLARE_RETURN(BOOL);
BOOL ret;
DPRINT("Enter NtUserShowCaret\n");
UserEnterExclusive();
DPRINT("Enter NtUserShowCaret\n");
UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE);
}
WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE);
}
ret = co_UserShowCaret(WindowObject);
IntReleaseWindowObject(WindowObject);
RETURN(ret);
ret = co_UserShowCaret(WindowObject);
IntReleaseWindowObject(WindowObject);
RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserShowCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserShowCaret, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}

View file

@ -38,13 +38,13 @@
NTSTATUS FASTCALL
InitClassImpl(VOID)
{
return(STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
NTSTATUS FASTCALL
CleanupClassImpl(VOID)
{
return(STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
BOOL FASTCALL
@ -102,9 +102,9 @@ ClassReferenceClassByName(
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
Status = RtlLookupAtomInAtomTable(
WinStaObject->AtomTable,
(LPWSTR)ClassName,
&ClassAtom);
WinStaObject->AtomTable,
(LPWSTR)ClassName,
&ClassAtom);
if (!NT_SUCCESS(Status))
{
@ -144,14 +144,14 @@ NtUserGetClassInfo(
PWNDCLASS_OBJECT Class;
RTL_ATOM Atom;
DECLARE_RETURN(DWORD);
if (IS_ATOM(lpClassName))
DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance);
else
DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance);
UserEnterExclusive();
if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance))
{
SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST);
@ -182,7 +182,7 @@ NtUserGetClassInfo(
ObmDereferenceObject(Class);
RETURN(Atom);
CLEANUP:
DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_);
UserLeave();
@ -191,7 +191,7 @@ CLEANUP:
ULONG FASTCALL
IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
ULONG nMaxCount)
ULONG nMaxCount)
{
ULONG Length;
LPWSTR Name;
@ -207,10 +207,10 @@ IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
Length = 0;
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
WindowObject->Class->Atom, NULL, NULL, NULL, &Length);
Name = ExAllocatePoolWithTag(PagedPool, Length + sizeof(UNICODE_NULL), TAG_STRING);
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
WindowObject->Class->Atom, NULL, NULL, Name, &Length);
WindowObject->Class->Atom, NULL, NULL, Name, &Length);
if (!NT_SUCCESS(Status))
{
DPRINT("IntGetClassName: RtlQueryAtomInAtomTable failed\n");
@ -231,16 +231,16 @@ IntGetClassName(struct _WINDOW_OBJECT *WindowObject, LPWSTR lpClassName,
DWORD STDCALL
NtUserGetClassName (
HWND hWnd,
LPWSTR lpClassName,
ULONG nMaxCount)
HWND hWnd,
LPWSTR lpClassName,
ULONG nMaxCount)
{
PWINDOW_OBJECT WindowObject;
LONG Length;
DECLARE_RETURN(DWORD);
UserEnterShared();
WindowObject = IntGetWindowObject(hWnd);
if (WindowObject == NULL)
{
@ -250,7 +250,7 @@ NtUserGetClassName (
Length = IntGetClassName(WindowObject, lpClassName, nMaxCount);
IntReleaseWindowObject(WindowObject);
RETURN(Length);
CLEANUP:
DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_);
UserLeave();
@ -259,10 +259,10 @@ CLEANUP:
DWORD STDCALL
NtUserGetWOWClass(DWORD Unknown0,
DWORD Unknown1)
DWORD Unknown1)
{
UNIMPLEMENTED;
return(0);
UNIMPLEMENTED;
return(0);
}
PWNDCLASS_OBJECT FASTCALL
@ -273,101 +273,104 @@ IntCreateClass(
PUNICODE_STRING MenuName,
RTL_ATOM Atom)
{
PWNDCLASS_OBJECT ClassObject;
ULONG objectSize;
BOOL Global;
PWNDCLASS_OBJECT ClassObject;
ULONG objectSize;
BOOL Global;
Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE;
Global = (Flags & REGISTERCLASS_SYSTEM) || (lpwcx->style & CS_GLOBALCLASS) ? TRUE : FALSE;
/* Check for double registration of the class. */
if (PsGetWin32Process() != NULL)
{
if (ClassReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
{
/*
* NOTE: We may also get a global class from
* ClassReferenceClassByAtom. This simple check
* prevents that we fail valid request.
*/
if (ClassObject->hInstance == lpwcx->hInstance)
{
SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS);
ObmDereferenceObject(ClassObject);
return(NULL);
}
}
}
/* Check for double registration of the class. */
if (PsGetWin32Process() != NULL)
{
if (ClassReferenceClassByAtom(&ClassObject, Atom, lpwcx->hInstance))
{
/*
* NOTE: We may also get a global class from
* ClassReferenceClassByAtom. This simple check
* prevents that we fail valid request.
*/
if (ClassObject->hInstance == lpwcx->hInstance)
{
SetLastWin32Error(ERROR_CLASS_ALREADY_EXISTS);
ObmDereferenceObject(ClassObject);
return(NULL);
}
}
}
objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra;
ClassObject = ObmCreateObject(&gHandleTable, NULL, otClass, objectSize);
if (ClassObject == 0)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return(NULL);
}
objectSize = sizeof(WNDCLASS_OBJECT) + lpwcx->cbClsExtra;
ClassObject = ObmCreateObject(&gHandleTable, NULL, otClass, objectSize);
if (ClassObject == 0)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return(NULL);
}
ClassObject->cbSize = lpwcx->cbSize;
ClassObject->style = lpwcx->style;
ClassObject->cbClsExtra = lpwcx->cbClsExtra;
ClassObject->cbWndExtra = lpwcx->cbWndExtra;
ClassObject->hInstance = lpwcx->hInstance;
ClassObject->hIcon = lpwcx->hIcon;
ClassObject->hCursor = lpwcx->hCursor;
ClassObject->hbrBackground = lpwcx->hbrBackground;
ClassObject->Unicode = !(Flags & REGISTERCLASS_ANSI);
ClassObject->Global = Global;
ClassObject->hIconSm = lpwcx->hIconSm;
ClassObject->Atom = Atom;
if (wpExtra == NULL) {
if (Flags & REGISTERCLASS_ANSI)
{
ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcW = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,FALSE);
}
else
{
ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcA = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,TRUE);
}
} else {
if (Flags & REGISTERCLASS_ANSI)
{
ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcW = wpExtra;
}
else
{
ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcA = wpExtra;
}
}
if (MenuName->Length == 0)
{
ClassObject->lpszMenuName.Length =
ClassObject->lpszMenuName.MaximumLength = 0;
ClassObject->lpszMenuName.Buffer = MenuName->Buffer;
}
else
{
ClassObject->lpszMenuName.Length =
ClassObject->lpszMenuName.MaximumLength = MenuName->MaximumLength;
ClassObject->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, ClassObject->lpszMenuName.MaximumLength, TAG_STRING);
RtlCopyUnicodeString(&ClassObject->lpszMenuName, MenuName);
}
/* Extra class data */
if (ClassObject->cbClsExtra != 0)
{
ClassObject->ExtraData = (PCHAR)(ClassObject + 1);
RtlZeroMemory(ClassObject->ExtraData, (ULONG)ClassObject->cbClsExtra);
}
else
{
ClassObject->ExtraData = NULL;
}
ClassObject->cbSize = lpwcx->cbSize;
ClassObject->style = lpwcx->style;
ClassObject->cbClsExtra = lpwcx->cbClsExtra;
ClassObject->cbWndExtra = lpwcx->cbWndExtra;
ClassObject->hInstance = lpwcx->hInstance;
ClassObject->hIcon = lpwcx->hIcon;
ClassObject->hCursor = lpwcx->hCursor;
ClassObject->hbrBackground = lpwcx->hbrBackground;
ClassObject->Unicode = !(Flags & REGISTERCLASS_ANSI);
ClassObject->Global = Global;
ClassObject->hIconSm = lpwcx->hIconSm;
ClassObject->Atom = Atom;
if (wpExtra == NULL)
{
if (Flags & REGISTERCLASS_ANSI)
{
ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcW = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,FALSE);
}
else
{
ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcA = (WNDPROC)IntAddWndProcHandle(lpwcx->lpfnWndProc,TRUE);
}
}
else
{
if (Flags & REGISTERCLASS_ANSI)
{
ClassObject->lpfnWndProcA = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcW = wpExtra;
}
else
{
ClassObject->lpfnWndProcW = lpwcx->lpfnWndProc;
ClassObject->lpfnWndProcA = wpExtra;
}
}
if (MenuName->Length == 0)
{
ClassObject->lpszMenuName.Length =
ClassObject->lpszMenuName.MaximumLength = 0;
ClassObject->lpszMenuName.Buffer = MenuName->Buffer;
}
else
{
ClassObject->lpszMenuName.Length =
ClassObject->lpszMenuName.MaximumLength = MenuName->MaximumLength;
ClassObject->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, ClassObject->lpszMenuName.MaximumLength, TAG_STRING);
RtlCopyUnicodeString(&ClassObject->lpszMenuName, MenuName);
}
/* Extra class data */
if (ClassObject->cbClsExtra != 0)
{
ClassObject->ExtraData = (PCHAR)(ClassObject + 1);
RtlZeroMemory(ClassObject->ExtraData, (ULONG)ClassObject->cbClsExtra);
}
else
{
ClassObject->ExtraData = NULL;
}
InitializeListHead(&ClassObject->ClassWindowsListHead);
InitializeListHead(&ClassObject->ClassWindowsListHead);
return(ClassObject);
return(ClassObject);
}
RTL_ATOM STDCALL
@ -428,279 +431,279 @@ NtUserRegisterClassExWOW(
RETURN( (RTL_ATOM)0);
}
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
if (ClassName->Length > 0)
{
DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer);
/* FIXME - Safely copy/verify the buffer first!!! */
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
ClassName->Buffer,
&Atom);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed adding class name (%S) to atom table\n",
ClassName->Buffer);
SetLastNtError(Status);
if (ClassName->Length > 0)
{
DPRINT("NtUserRegisterClassExWOW(%S)\n", ClassName->Buffer);
/* FIXME - Safely copy/verify the buffer first!!! */
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
ClassName->Buffer,
&Atom);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed adding class name (%S) to atom table\n",
ClassName->Buffer);
SetLastNtError(Status);
RETURN((RTL_ATOM)0);
}
}
else
{
Atom = (RTL_ATOM)(ULONG)ClassName->Buffer;
}
ClassObject = IntCreateClass(&SafeClass, Flags, wpExtra, MenuName, Atom);
if (ClassObject == NULL)
{
if (ClassName->Length)
{
RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
}
DPRINT("Failed creating window class object\n");
RETURN((RTL_ATOM)0);
}
}
else
{
Atom = (RTL_ATOM)(ULONG)ClassName->Buffer;
}
ClassObject = IntCreateClass(&SafeClass, Flags, wpExtra, MenuName, Atom);
if (ClassObject == NULL)
{
if (ClassName->Length)
{
RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom);
}
DPRINT("Failed creating window class object\n");
RETURN((RTL_ATOM)0);
}
}
InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry);
InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry);
RETURN(Atom);
RETURN(Atom);
CLEANUP:
DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
ULONG FASTCALL
IntGetClassLong(struct _WINDOW_OBJECT *Window, ULONG Offset, BOOL Ansi)
{
LONG Ret;
LONG Ret;
if ((int)Offset >= 0)
{
if ((int)Offset >= 0)
{
DPRINT("GetClassLong(%x, %d)\n", Window->hSelf, Offset);
if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
Ret = *((LONG *)(Window->Class->ExtraData + Offset));
DPRINT("Result: %x\n", Ret);
return Ret;
}
}
switch (Offset)
{
case GCL_CBWNDEXTRA:
Ret = Window->Class->cbWndExtra;
break;
case GCL_CBCLSEXTRA:
Ret = Window->Class->cbClsExtra;
break;
case GCL_HBRBACKGROUND:
Ret = (ULONG)Window->Class->hbrBackground;
break;
case GCL_HCURSOR:
Ret = (ULONG)Window->Class->hCursor;
break;
case GCL_HICON:
Ret = (ULONG)Window->Class->hIcon;
break;
case GCL_HICONSM:
Ret = (ULONG)Window->Class->hIconSm;
break;
case GCL_HMODULE:
Ret = (ULONG)Window->Class->hInstance;
break;
case GCL_MENUNAME:
Ret = (ULONG)Window->Class->lpszMenuName.Buffer;
break;
case GCL_STYLE:
Ret = Window->Class->style;
break;
case GCL_WNDPROC:
if (Ansi)
{
Ret = (ULONG)Window->Class->lpfnWndProcA;
}
else
{
Ret = (ULONG)Window->Class->lpfnWndProcW;
}
break;
default:
Ret = 0;
break;
}
return(Ret);
switch (Offset)
{
case GCL_CBWNDEXTRA:
Ret = Window->Class->cbWndExtra;
break;
case GCL_CBCLSEXTRA:
Ret = Window->Class->cbClsExtra;
break;
case GCL_HBRBACKGROUND:
Ret = (ULONG)Window->Class->hbrBackground;
break;
case GCL_HCURSOR:
Ret = (ULONG)Window->Class->hCursor;
break;
case GCL_HICON:
Ret = (ULONG)Window->Class->hIcon;
break;
case GCL_HICONSM:
Ret = (ULONG)Window->Class->hIconSm;
break;
case GCL_HMODULE:
Ret = (ULONG)Window->Class->hInstance;
break;
case GCL_MENUNAME:
Ret = (ULONG)Window->Class->lpszMenuName.Buffer;
break;
case GCL_STYLE:
Ret = Window->Class->style;
break;
case GCL_WNDPROC:
if (Ansi)
{
Ret = (ULONG)Window->Class->lpfnWndProcA;
}
else
{
Ret = (ULONG)Window->Class->lpfnWndProcW;
}
break;
default:
Ret = 0;
break;
}
return(Ret);
}
DWORD STDCALL
NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi)
{
PWINDOW_OBJECT Window;
DECLARE_RETURN(DWORD);
PWINDOW_OBJECT Window;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserGetClassLong\n");
UserEnterExclusive();
DPRINT("Enter NtUserGetClassLong\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(0);
}
RETURN(IntGetClassLong(Window, Offset, Ansi));
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(0);
}
RETURN(IntGetClassLong(Window, Offset, Ansi));
CLEANUP:
DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
void FASTCALL
co_IntSetClassLong(PWINDOW_OBJECT Window, ULONG Offset, LONG dwNewLong, BOOL Ansi)
{
PWINDOW_OBJECT Parent, Owner;
PWINDOW_OBJECT Parent, Owner;
ASSERT_REFS_CO(Window);
ASSERT_REFS_CO(Window);
if ((int)Offset >= 0)
{
if ((int)Offset >= 0)
{
DPRINT("SetClassLong(%x, %d, %x)\n", Window->hSelf, Offset, dwNewLong);
if ((Offset + sizeof(LONG)) > Window->Class->cbClsExtra)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return;
}
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return;
}
*((LONG *)(Window->Class->ExtraData + Offset)) = dwNewLong;
return;
}
}
switch (Offset)
{
case GCL_CBWNDEXTRA:
Window->Class->cbWndExtra = dwNewLong;
break;
case GCL_CBCLSEXTRA:
Window->Class->cbClsExtra = dwNewLong;
break;
case GCL_HBRBACKGROUND:
Window->Class->hbrBackground = (HBRUSH)dwNewLong;
break;
case GCL_HCURSOR:
Window->Class->hCursor = (HCURSOR)dwNewLong;
break;
case GCL_HICON:
Window->Class->hIcon = (HICON)dwNewLong;
Owner = IntGetOwner(Window);
Parent = IntGetParent(Window);
switch (Offset)
{
case GCL_CBWNDEXTRA:
Window->Class->cbWndExtra = dwNewLong;
break;
case GCL_CBCLSEXTRA:
Window->Class->cbClsExtra = dwNewLong;
break;
case GCL_HBRBACKGROUND:
Window->Class->hbrBackground = (HBRUSH)dwNewLong;
break;
case GCL_HCURSOR:
Window->Class->hCursor = (HCURSOR)dwNewLong;
break;
case GCL_HICON:
Window->Class->hIcon = (HICON)dwNewLong;
Owner = IntGetOwner(Window);
Parent = IntGetParent(Window);
if ((!Owner) && (!Parent))
{
co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf);
}
if ((!Owner) && (!Parent))
{
co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf);
}
if (Parent)
{
IntReleaseWindowObject(Parent);
}
if (Parent)
{
IntReleaseWindowObject(Parent);
}
if (Owner)
{
IntReleaseWindowObject(Owner);
}
if (Owner)
{
IntReleaseWindowObject(Owner);
}
break;
case GCL_HICONSM:
Window->Class->hIconSm = (HICON)dwNewLong;
break;
case GCL_HMODULE:
Window->Class->hInstance = (HINSTANCE)dwNewLong;
break;
case GCL_MENUNAME:
if (Window->Class->lpszMenuName.MaximumLength)
RtlFreeUnicodeString(&Window->Class->lpszMenuName);
if (!IS_INTRESOURCE(dwNewLong))
{
Window->Class->lpszMenuName.Length =
Window->Class->lpszMenuName.MaximumLength = ((PUNICODE_STRING)dwNewLong)->MaximumLength;
Window->Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Window->Class->lpszMenuName.MaximumLength, TAG_STRING);
RtlCopyUnicodeString(&Window->Class->lpszMenuName, (PUNICODE_STRING)dwNewLong);
}
else
{
Window->Class->lpszMenuName.Length =
Window->Class->lpszMenuName.MaximumLength = 0;
Window->Class->lpszMenuName.Buffer = (LPWSTR)dwNewLong;
}
break;
case GCL_STYLE:
Window->Class->style = dwNewLong;
break;
case GCL_WNDPROC:
if (Ansi)
{
Window->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
Window->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
Window->Class->Unicode = FALSE;
}
else
{
Window->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
Window->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
Window->Class->Unicode = TRUE;
}
break;
}
break;
case GCL_HICONSM:
Window->Class->hIconSm = (HICON)dwNewLong;
break;
case GCL_HMODULE:
Window->Class->hInstance = (HINSTANCE)dwNewLong;
break;
case GCL_MENUNAME:
if (Window->Class->lpszMenuName.MaximumLength)
RtlFreeUnicodeString(&Window->Class->lpszMenuName);
if (!IS_INTRESOURCE(dwNewLong))
{
Window->Class->lpszMenuName.Length =
Window->Class->lpszMenuName.MaximumLength = ((PUNICODE_STRING)dwNewLong)->MaximumLength;
Window->Class->lpszMenuName.Buffer = ExAllocatePoolWithTag(PagedPool, Window->Class->lpszMenuName.MaximumLength, TAG_STRING);
RtlCopyUnicodeString(&Window->Class->lpszMenuName, (PUNICODE_STRING)dwNewLong);
}
else
{
Window->Class->lpszMenuName.Length =
Window->Class->lpszMenuName.MaximumLength = 0;
Window->Class->lpszMenuName.Buffer = (LPWSTR)dwNewLong;
}
break;
case GCL_STYLE:
Window->Class->style = dwNewLong;
break;
case GCL_WNDPROC:
if (Ansi)
{
Window->Class->lpfnWndProcA = (WNDPROC)dwNewLong;
Window->Class->lpfnWndProcW = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,FALSE);
Window->Class->Unicode = FALSE;
}
else
{
Window->Class->lpfnWndProcW = (WNDPROC)dwNewLong;
Window->Class->lpfnWndProcA = (WNDPROC) IntAddWndProcHandle((WNDPROC)dwNewLong,TRUE);
Window->Class->Unicode = TRUE;
}
break;
}
}
DWORD STDCALL
NtUserSetClassLong(HWND hWnd,
DWORD Offset,
LONG dwNewLong,
BOOL Ansi)
DWORD Offset,
LONG dwNewLong,
BOOL Ansi)
{
PWINDOW_OBJECT Window;
LONG Ret;
DECLARE_RETURN(DWORD);
PWINDOW_OBJECT Window;
LONG Ret;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserSetClassLong\n");
UserEnterExclusive();
DPRINT("Enter NtUserSetClassLong\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(0);
}
UserRefObjectCo(Window);
Ret = IntGetClassLong(Window, Offset, Ansi);
co_IntSetClassLong(Window, Offset, dwNewLong, Ansi);
UserDerefObjectCo(Window);
RETURN(Ret);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(0);
}
UserRefObjectCo(Window);
Ret = IntGetClassLong(Window, Offset, Ansi);
co_IntSetClassLong(Window, Offset, dwNewLong, Ansi);
UserDerefObjectCo(Window);
RETURN(Ret);
CLEANUP:
DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
DWORD STDCALL
NtUserSetClassWord(DWORD Unknown0,
DWORD Unknown1,
DWORD Unknown2)
DWORD Unknown1,
DWORD Unknown2)
{
UNIMPLEMENTED;
return(0);
UNIMPLEMENTED;
return(0);
}
BOOL STDCALL
NtUserUnregisterClass(
LPCWSTR ClassNameOrAtom,
HINSTANCE hInstance,
DWORD Unknown)
HINSTANCE hInstance,
DWORD Unknown)
{
PWNDCLASS_OBJECT Class;
PWINSTATION_OBJECT WinSta;
@ -749,7 +752,7 @@ NtUserUnregisterClass(
ClassDereferenceObject(Class);
RETURN( TRUE);
CLEANUP:
DPRINT("Leave NtUserUnregisterClass, ret=%i\n",_ret_);
UserLeave();

View file

@ -47,7 +47,7 @@ IntGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName)
{
return IntGetAtomName((RTL_ATOM)format, FormatName->Buffer,
FormatName->MaximumLength);
FormatName->MaximumLength);
}
UINT FASTCALL
@ -57,7 +57,7 @@ IntEnumClipboardFormats(UINT format)
CHECK_LOCK
if (!hCBData)
return FALSE;
return FALSE;
//UNIMPLEMENTED;
return 1;
}
@ -114,12 +114,12 @@ NtUserEmptyClipboard(VOID)
{
CHECK_LOCK
// if (!hCBData)
// return FALSE;
// if (!hCBData)
// return FALSE;
// FIXME!
// GlobalUnlock(hCBData);
// GlobalFree(hCBData);
// FIXME!
// GlobalUnlock(hCBData);
// GlobalFree(hCBData);
hCBData = NULL;
uCBFormat = 0;
ClipboardWindow = tempClipboardWindow;
@ -133,90 +133,90 @@ NtUserGetClipboardData(UINT uFormat, DWORD Unknown1)
CHECK_LOCK
if ((uFormat==1 && uCBFormat==13) || (uFormat==13 && uCBFormat==1))
uCBFormat = uFormat;
uCBFormat = uFormat;
if (uFormat != uCBFormat)
return FALSE;
return FALSE;
return hCBData;
}
INT STDCALL
NtUserGetClipboardFormatName(UINT format, PUNICODE_STRING FormatName,
INT cchMaxCount)
INT cchMaxCount)
{
NTSTATUS Status;
PWSTR Buf;
UNICODE_STRING SafeFormatName, BufFormatName;
ULONG Ret;
NTSTATUS Status;
PWSTR Buf;
UNICODE_STRING SafeFormatName, BufFormatName;
ULONG Ret;
if((cchMaxCount < 1) || !FormatName)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
if((cchMaxCount < 1) || !FormatName)
{
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
/* copy the FormatName UNICODE_STRING structure */
Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return 0;
}
/* copy the FormatName UNICODE_STRING structure */
Status = MmCopyFromCaller(&SafeFormatName, FormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return 0;
}
/* Allocate memory for the string */
Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
if(!Buf)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* Allocate memory for the string */
Buf = ExAllocatePoolWithTag(PagedPool, cchMaxCount * sizeof(WCHAR), TAG_STRING);
if(!Buf)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* Setup internal unicode string */
BufFormatName.Length = 0;
BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
BufFormatName.Buffer = Buf;
/* Setup internal unicode string */
BufFormatName.Length = 0;
BufFormatName.MaximumLength = min(cchMaxCount * sizeof(WCHAR), SafeFormatName.MaximumLength);
BufFormatName.Buffer = Buf;
if(BufFormatName.MaximumLength < sizeof(WCHAR))
{
ExFreePool(Buf);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
if(BufFormatName.MaximumLength < sizeof(WCHAR))
{
ExFreePool(Buf);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
if (format >= 0xC000)
{
Ret = IntGetClipboardFormatName(format, &BufFormatName);
}
else
{
SetLastNtError(NO_ERROR);
return 0;
}
if (format >= 0xC000)
{
Ret = IntGetClipboardFormatName(format, &BufFormatName);
}
else
{
SetLastNtError(NO_ERROR);
return 0;
}
/* copy the UNICODE_STRING buffer back to the user */
Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
if(!NT_SUCCESS(Status))
{
ExFreePool(Buf);
SetLastNtError(Status);
return 0;
}
/* copy the UNICODE_STRING buffer back to the user */
Status = MmCopyToCaller(SafeFormatName.Buffer, BufFormatName.Buffer, BufFormatName.MaximumLength);
if(!NT_SUCCESS(Status))
{
ExFreePool(Buf);
SetLastNtError(Status);
return 0;
}
BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
BufFormatName.Buffer = SafeFormatName.Buffer;
BufFormatName.MaximumLength = SafeFormatName.MaximumLength;
BufFormatName.Buffer = SafeFormatName.Buffer;
/* update the UNICODE_STRING structure (only the Length member should change) */
Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
{
ExFreePool(Buf);
SetLastNtError(Status);
return 0;
}
/* update the UNICODE_STRING structure (only the Length member should change) */
Status = MmCopyToCaller(FormatName, &BufFormatName, sizeof(UNICODE_STRING));
if(!NT_SUCCESS(Status))
{
ExFreePool(Buf);
SetLastNtError(Status);
return 0;
}
ExFreePool(Buf);
return Ret;
ExFreePool(Buf);
return Ret;
}
HWND STDCALL
@ -251,16 +251,17 @@ NtUserIsClipboardFormatAvailable(UINT format)
{
//UNIMPLEMENTED
if (format != 1 && format != 13) {
if (format != 1 && format != 13)
{
DbgPrint("Clipboard Format unavailable (%d)\n", format);
return FALSE;
}
if ((format==1 && uCBFormat==13) || (format==13 && uCBFormat==1))
uCBFormat = format;
uCBFormat = format;
if (format != uCBFormat)
return FALSE;
return FALSE;
return TRUE;
}
@ -269,48 +270,49 @@ NtUserIsClipboardFormatAvailable(UINT format)
HANDLE STDCALL
NtUserSetClipboardData(UINT uFormat, HANDLE hMem, DWORD Unknown2)
{
// LPVOID pMem;
CHECK_LOCK
// LPVOID pMem;
CHECK_LOCK
if (uFormat != 1 && uFormat != 13) {
if (uFormat != 1 && uFormat != 13)
{
DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
return FALSE;
}
if (hMem)
{
uCBFormat = uFormat;
hCBData = hMem;
//pMem = GlobalLock(hMem);
/*
switch (uFormat) {
default:
DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
return FALSE;
case CF_TEXT: // 1
break;
case CF_UNICODETEXT: // 13
break;
case CF_BITMAP: // 2
break;
case CF_OEMTEXT: // 7
break;
} */
}
else
{
//the window provides data in the specified format
}
return hMem;
if (hMem)
{
uCBFormat = uFormat;
hCBData = hMem;
//pMem = GlobalLock(hMem);
/*
switch (uFormat) {
default:
DbgPrint("Clipboard unsupported format (%d)\n", uFormat);
return FALSE;
case CF_TEXT: // 1
break;
case CF_UNICODETEXT: // 13
break;
case CF_BITMAP: // 2
break;
case CF_OEMTEXT: // 7
break;
} */
}
else
{
//the window provides data in the specified format
}
return hMem;
}
HWND STDCALL
NtUserSetClipboardViewer(HWND hWndNewViewer)
{
HWND hwndPrev = 0;
DbgPrint("NtUserSetClipboardViewer is UNIMPLEMENTED (%p): returning %p\n", hWndNewViewer, hwndPrev);
return hwndPrev;
HWND hwndPrev = 0;
DbgPrint("NtUserSetClipboardViewer is UNIMPLEMENTED (%p): returning %p\n", hWndNewViewer, hwndPrev);
return hwndPrev;
}
/* EOF */

View file

@ -14,75 +14,75 @@
static HANDLE WindowsApiPort = NULL;
PEPROCESS CsrProcess = NULL;
NTSTATUS FASTCALL
CsrInit(void)
{
NTSTATUS Status;
UNICODE_STRING PortName;
ULONG ConnectInfoLength;
NTSTATUS Status;
UNICODE_STRING PortName;
ULONG ConnectInfoLength;
RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
ConnectInfoLength = 0;
Status = ZwConnectPort(&WindowsApiPort,
&PortName,
NULL,
NULL,
NULL,
NULL,
NULL,
&ConnectInfoLength);
if (! NT_SUCCESS(Status))
{
RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
ConnectInfoLength = 0;
Status = ZwConnectPort(&WindowsApiPort,
&PortName,
NULL,
NULL,
NULL,
NULL,
NULL,
&ConnectInfoLength);
if (! NT_SUCCESS(Status))
{
return Status;
}
}
CsrProcess = PsGetCurrentProcess();
CsrProcess = PsGetCurrentProcess();
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS FASTCALL
co_CsrNotify(PCSR_API_MESSAGE Request)
{
NTSTATUS Status;
PEPROCESS OldProcess;
NTSTATUS Status;
PEPROCESS OldProcess;
if (NULL == CsrProcess)
{
if (NULL == CsrProcess)
{
return STATUS_INVALID_PORT_HANDLE;
}
}
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
/* Switch to the process in which the WindowsApiPort handle is valid */
OldProcess = PsGetCurrentProcess();
if (CsrProcess != OldProcess)
{
/* Switch to the process in which the WindowsApiPort handle is valid */
OldProcess = PsGetCurrentProcess();
if (CsrProcess != OldProcess)
{
KeAttachProcess(&CsrProcess->Pcb);
}
UserLeaveCo();
}
Status = ZwRequestWaitReplyPort(WindowsApiPort,
&Request->Header,
&Request->Header);
UserEnterCo();
if (CsrProcess != OldProcess)
{
UserLeaveCo();
Status = ZwRequestWaitReplyPort(WindowsApiPort,
&Request->Header,
&Request->Header);
UserEnterCo();
if (CsrProcess != OldProcess)
{
KeDetachProcess();
}
}
if (NT_SUCCESS(Status))
{
if (NT_SUCCESS(Status))
{
Status = Request->Status;
}
}
return Status;
return Status;
}
NTSTATUS
@ -91,30 +91,30 @@ CsrInsertObject(HANDLE ObjectHandle,
ACCESS_MASK DesiredAccess,
PHANDLE Handle)
{
NTSTATUS Status;
HANDLE CsrProcessHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
CLIENT_ID Cid;
/* Put CSR'S CID */
Cid.UniqueProcess = CsrProcess->UniqueProcessId;
Cid.UniqueThread = 0;
/* Empty Attributes */
InitializeObjectAttributes(&ObjectAttributes,
NULL,
0,
NULL,
NULL);
/* Get a Handle to Csrss */
Status = ZwOpenProcess(&CsrProcessHandle,
PROCESS_DUP_HANDLE,
&ObjectAttributes,
&Cid);
if ((NT_SUCCESS(Status)))
{
NTSTATUS Status;
HANDLE CsrProcessHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
CLIENT_ID Cid;
/* Put CSR'S CID */
Cid.UniqueProcess = CsrProcess->UniqueProcessId;
Cid.UniqueThread = 0;
/* Empty Attributes */
InitializeObjectAttributes(&ObjectAttributes,
NULL,
0,
NULL,
NULL);
/* Get a Handle to Csrss */
Status = ZwOpenProcess(&CsrProcessHandle,
PROCESS_DUP_HANDLE,
&ObjectAttributes,
&Cid);
if ((NT_SUCCESS(Status)))
{
/* Duplicate the Handle */
Status = ZwDuplicateObject(NtCurrentProcess(),
ObjectHandle,
@ -123,35 +123,35 @@ CsrInsertObject(HANDLE ObjectHandle,
DesiredAccess,
TRUE,
0);
/* Close our handle to CSRSS */
ZwClose(CsrProcessHandle);
}
}
return Status;
return Status;
}
NTSTATUS FASTCALL
CsrCloseHandle(HANDLE Handle)
{
NTSTATUS Status;
PEPROCESS OldProcess;
NTSTATUS Status;
PEPROCESS OldProcess;
/* Switch to the process in which the handle is valid */
OldProcess = PsGetCurrentProcess();
if (CsrProcess != OldProcess)
{
/* Switch to the process in which the handle is valid */
OldProcess = PsGetCurrentProcess();
if (CsrProcess != OldProcess)
{
KeAttachProcess(&CsrProcess->Pcb);
}
}
Status = ZwClose(Handle);
Status = ZwClose(Handle);
if (CsrProcess != OldProcess)
{
if (CsrProcess != OldProcess)
{
KeDetachProcess();
}
}
return Status;
return Status;
}
/* EOF */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -53,8 +53,8 @@ co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
{
co_IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
co_IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
(LPARAM)hWnd);
MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
(LPARAM)hWnd);
}
}
@ -69,24 +69,24 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
{
co_IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING,
(WPARAM)hWnd, 0);
(WPARAM)hWnd, 0);
}
if (UserGetWindow(hWnd, GW_HWNDPREV) != NULL)
co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
Owner = IntGetOwner(Window);
if (!Owner)
if (!Owner)
{
Parent = IntGetParent(Window);
if (!Parent)
co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd);
else
IntReleaseWindowObject(Parent);
}
else
}
else
{
IntReleaseWindowObject(Owner);
}
@ -98,9 +98,9 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0);
/* FIXME: WA_CLICKACTIVE */
co_IntPostOrSendMessage(hWnd, WM_ACTIVATE,
MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
(LPARAM)hWndPrev);
MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
(LPARAM)hWndPrev);
}
}
@ -125,25 +125,25 @@ co_IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd)
HWND FASTCALL
IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
{
HWND Ret;
PWINDOW_OBJECT Child, OwnerWnd;
HWND Ret;
PWINDOW_OBJECT Child, OwnerWnd;
for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
{
OwnerWnd = IntGetWindowObject(Child->hOwner);
if(!OwnerWnd)
continue;
for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
{
OwnerWnd = IntGetWindowObject(Child->hOwner);
if(!OwnerWnd)
continue;
if(OwnerWnd == Owner)
{
Ret = Child->hSelf;
if(OwnerWnd == Owner)
{
Ret = Child->hSelf;
IntReleaseWindowObject(OwnerWnd);
return Ret;
}
IntReleaseWindowObject(OwnerWnd);
return Ret;
}
IntReleaseWindowObject(OwnerWnd);
}
}
return NULL;
return NULL;
}
STATIC BOOL FASTCALL
@ -218,61 +218,61 @@ BOOL FASTCALL
co_IntSetForegroundWindow(PWINDOW_OBJECT Window)
{
ASSERT_REFS_CO(Window);
return co_IntSetForegroundAndFocusWindow(Window, Window, FALSE);
}
BOOL FASTCALL
co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
{
HWND Top;
PWINDOW_OBJECT TopWindow;
HWND Top;
PWINDOW_OBJECT TopWindow;
ASSERT_REFS_CO(Window);
ASSERT_REFS_CO(Window);
if(Window->Style & WS_DISABLED)
{
BOOL Ret;
PWINDOW_OBJECT TopWnd;
PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
if(DesktopWindow)
{
Top = IntFindChildWindowToOwner(DesktopWindow, Window);
if((TopWnd = IntGetWindowObject(Top)))
if(Window->Style & WS_DISABLED)
{
BOOL Ret;
PWINDOW_OBJECT TopWnd;
PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
if(DesktopWindow)
{
Ret = co_IntMouseActivateWindow(TopWnd);
IntReleaseWindowObject(TopWnd);
IntReleaseWindowObject(DesktopWindow);
return Ret;
Top = IntFindChildWindowToOwner(DesktopWindow, Window);
if((TopWnd = IntGetWindowObject(Top)))
{
Ret = co_IntMouseActivateWindow(TopWnd);
IntReleaseWindowObject(TopWnd);
IntReleaseWindowObject(DesktopWindow);
return Ret;
}
IntReleaseWindowObject(DesktopWindow);
}
IntReleaseWindowObject(DesktopWindow);
}
return FALSE;
}
return FALSE;
}
Top = UserGetAncestor(Window->hSelf, GA_ROOT);
if (Top != Window->hSelf)
{
Top = UserGetAncestor(Window->hSelf, GA_ROOT);
if (Top != Window->hSelf)
{
TopWindow = IntGetWindowObject(Top);
if (TopWindow == NULL)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
}
else
{
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
}
else
{
TopWindow = Window;
}
}
/* TMN: Check return valud from this function? */
co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
/* TMN: Check return valud from this function? */
co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
if (Top != Window->hSelf)
{
if (Top != Window->hSelf)
{
IntReleaseWindowObject(TopWindow);
}
return TRUE;
}
return TRUE;
}
HWND FASTCALL
@ -282,7 +282,8 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
HWND hWndPrev;
HWND hWnd = 0;
if (Window) ASSERT_REFS_CO(Window);
if (Window)
ASSERT_REFS_CO(Window);
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
ASSERT(ThreadQueue != 0);
@ -290,7 +291,7 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
if (Window != 0)
{
if (!(Window->Style & WS_VISIBLE) ||
(Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
(Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
{
return ThreadQueue ? 0 : ThreadQueue->ActiveWindow;
}
@ -310,8 +311,8 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
co_IntSendDeactivateMessages(hWndPrev, hWnd);
co_IntSendActivateMessages(hWndPrev, hWnd, FALSE);
/* FIXME */
/* return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
/* FIXME */
/* return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
return hWndPrev;
}
@ -346,7 +347,7 @@ HWND FASTCALL
UserGetForegroundWindow(VOID)
{
PUSER_MESSAGE_QUEUE ForegroundQueue;
ForegroundQueue = IntGetFocusMessageQueue();
return( ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0);
}
@ -359,12 +360,12 @@ HWND STDCALL
NtUserGetForegroundWindow(VOID)
{
DECLARE_RETURN(HWND);
DPRINT("Enter NtUserGetForegroundWindow\n");
UserEnterExclusive();
RETURN( UserGetForegroundWindow());
CLEANUP:
DPRINT("Leave NtUserGetForegroundWindow, ret=%i\n",_ret_);
UserLeave();
@ -387,12 +388,12 @@ HWND STDCALL
NtUserGetActiveWindow(VOID)
{
DECLARE_RETURN(HWND);
DPRINT("Enter NtUserGetActiveWindow\n");
UserEnterShared();
RETURN( UserGetActiveWindow());
CLEANUP:
DPRINT("Leave NtUserGetActiveWindow, ret=%i\n",_ret_);
UserLeave();
@ -438,7 +439,7 @@ NtUserSetActiveWindow(HWND hWnd)
{
RETURN( co_IntSetActiveWindow(0));
}
CLEANUP:
DPRINT("Leave NtUserSetActiveWindow, ret=%i\n",_ret_);
UserLeave();
@ -455,11 +456,11 @@ NtUserGetCapture(VOID)
DPRINT("Enter NtUserGetCapture\n");
UserEnterShared();
PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
RETURN( ThreadQueue ? ThreadQueue->CaptureWindow : 0);
CLEANUP:
DPRINT("Leave NtUserGetCapture, ret=%i\n",_ret_);
UserLeave();
@ -481,7 +482,7 @@ NtUserSetCapture(HWND hWnd)
UserEnterExclusive();
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if((Window = UserGetWindowObject(hWnd)))
{
if(Window->MessageQueue != ThreadQueue)
@ -489,21 +490,21 @@ NtUserSetCapture(HWND hWnd)
RETURN(NULL);
}
}
hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd);
/* also remove other windows if not capturing anymore */
if(hWnd == NULL)
{
MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL);
MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL);
MsqSetStateWindow(ThreadQueue, MSQ_STATE_MENUOWNER, NULL);
MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL);
}
co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
ThreadQueue->CaptureWindow = hWnd;
RETURN( hWndPrev);
CLEANUP:
DPRINT("Leave NtUserSetCapture, ret=%i\n",_ret_);
UserLeave();
@ -570,7 +571,7 @@ NtUserSetFocus(HWND hWnd)
UserEnterExclusive();
RETURN(UserSetFocus(hWnd));
CLEANUP:
DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);
UserLeave();

View file

@ -48,9 +48,9 @@ static FAST_MUTEX GuiSwitchLock;
static BOOL FASTCALL
co_AddGuiApp(PW32PROCESS W32Data)
{
W32Data->Flags |= W32PF_CREATEDWINORDC;
if (InterlockedIncrement(&NrGuiAppsRunning) == 1)
{
W32Data->Flags |= W32PF_CREATEDWINORDC;
if (InterlockedIncrement(&NrGuiAppsRunning) == 1)
{
BOOL Initialized;
ExAcquireFastMutex(&GuiSwitchLock);
@ -58,89 +58,89 @@ co_AddGuiApp(PW32PROCESS W32Data)
ExReleaseFastMutex(&GuiSwitchLock);
if (!Initialized)
{
W32Data->Flags &= ~W32PF_CREATEDWINORDC;
InterlockedDecrement(&NrGuiAppsRunning);
return FALSE;
}
}
return TRUE;
{
W32Data->Flags &= ~W32PF_CREATEDWINORDC;
InterlockedDecrement(&NrGuiAppsRunning);
return FALSE;
}
}
return TRUE;
}
static void FASTCALL
RemoveGuiApp(PW32PROCESS W32Data)
{
W32Data->Flags &= ~W32PF_CREATEDWINORDC;
if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
{
W32Data->Flags &= ~W32PF_CREATEDWINORDC;
if (InterlockedDecrement(&NrGuiAppsRunning) == 0)
{
ExAcquireFastMutex(&GuiSwitchLock);
IntEndDesktopGraphics();
ExReleaseFastMutex(&GuiSwitchLock);
}
}
}
BOOL FASTCALL
co_IntGraphicsCheck(BOOL Create)
{
PW32PROCESS W32Data;
PW32PROCESS W32Data;
W32Data = PsGetWin32Process();
if (Create)
{
W32Data = PsGetWin32Process();
if (Create)
{
if (! (W32Data->Flags & W32PF_CREATEDWINORDC) && ! (W32Data->Flags & W32PF_MANUALGUICHECK))
{
return co_AddGuiApp(W32Data);
}
}
else
{
{
return co_AddGuiApp(W32Data);
}
}
else
{
if ((W32Data->Flags & W32PF_CREATEDWINORDC) && ! (W32Data->Flags & W32PF_MANUALGUICHECK))
{
RemoveGuiApp(W32Data);
}
}
{
RemoveGuiApp(W32Data);
}
}
return TRUE;
return TRUE;
}
VOID STDCALL
NtUserManualGuiCheck(LONG Check)
{
PW32PROCESS W32Data;
DPRINT("Enter NtUserManualGuiCheck\n");
UserEnterExclusive();
PW32PROCESS W32Data;
W32Data = PsGetWin32Process();
if (0 == Check)
{
DPRINT("Enter NtUserManualGuiCheck\n");
UserEnterExclusive();
W32Data = PsGetWin32Process();
if (0 == Check)
{
W32Data->Flags |= W32PF_MANUALGUICHECK;
}
else if (0 < Check)
{
}
else if (0 < Check)
{
if (! (W32Data->Flags & W32PF_CREATEDWINORDC))
{
co_AddGuiApp(W32Data);
}
}
else
{
{
co_AddGuiApp(W32Data);
}
}
else
{
if (W32Data->Flags & W32PF_CREATEDWINORDC)
{
RemoveGuiApp(W32Data);
}
}
{
RemoveGuiApp(W32Data);
}
}
DPRINT("Leave NtUserManualGuiCheck\n");
UserLeave();
DPRINT("Leave NtUserManualGuiCheck\n");
UserLeave();
}
NTSTATUS FASTCALL
InitGuiCheckImpl (VOID)
{
ExInitializeFastMutex(&GuiSwitchLock);
return STATUS_SUCCESS;
ExInitializeFastMutex(&GuiSwitchLock);
return STATUS_SUCCESS;
}
/* EOF */

File diff suppressed because it is too large Load diff

View file

@ -41,10 +41,10 @@
NTSTATUS FASTCALL
InitHotKeys(PWINSTATION_OBJECT WinStaObject)
{
InitializeListHead(&WinStaObject->HotKeyListHead);
ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
InitializeListHead(&WinStaObject->HotKeyListHead);
ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
@ -52,289 +52,289 @@ NTSTATUS FASTCALL
CleanupHotKeys(PWINSTATION_OBJECT WinStaObject)
{
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
BOOL
GetHotKey (PWINSTATION_OBJECT WinStaObject,
UINT fsModifiers,
UINT vk,
struct _ETHREAD **Thread,
HWND *hWnd,
int *id)
UINT fsModifiers,
UINT vk,
struct _ETHREAD **Thread,
HWND *hWnd,
int *id)
{
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
if(!WinStaObject)
{
return FALSE;
}
if(!WinStaObject)
{
return FALSE;
}
IntLockHotKeys(WinStaObject);
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD(Entry,
HOT_KEY_ITEM,
ListEntry);
HOT_KEY_ITEM,
ListEntry);
if (HotKeyItem->fsModifiers == fsModifiers &&
HotKeyItem->vk == vk)
{
if (Thread != NULL)
*Thread = HotKeyItem->Thread;
HotKeyItem->vk == vk)
{
if (Thread != NULL)
*Thread = HotKeyItem->Thread;
if (hWnd != NULL)
*hWnd = HotKeyItem->hWnd;
if (hWnd != NULL)
*hWnd = HotKeyItem->hWnd;
if (id != NULL)
*id = HotKeyItem->id;
if (id != NULL)
*id = HotKeyItem->id;
IntUnLockHotKeys(WinStaObject);
IntUnLockHotKeys(WinStaObject);
return TRUE;
}
return TRUE;
}
Entry = Entry->Flink;
}
}
IntUnLockHotKeys(WinStaObject);
IntUnLockHotKeys(WinStaObject);
return FALSE;
return FALSE;
}
VOID
UnregisterWindowHotKeys(PWINDOW_OBJECT Window)
{
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINSTATION_OBJECT WinStaObject = NULL;
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINSTATION_OBJECT WinStaObject = NULL;
if(Window->OwnerThread && Window->OwnerThread->ThreadsProcess)
WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
if(Window->OwnerThread && Window->OwnerThread->ThreadsProcess)
WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
if(!WinStaObject)
return;
if(!WinStaObject)
return;
IntLockHotKeys(WinStaObject);
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
HOT_KEY_ITEM,
ListEntry);
HOT_KEY_ITEM,
ListEntry);
Entry = Entry->Flink;
if (HotKeyItem->hWnd == Window->hSelf)
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
}
}
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
}
}
IntUnLockHotKeys(WinStaObject);
IntUnLockHotKeys(WinStaObject);
}
VOID
UnregisterThreadHotKeys(struct _ETHREAD *Thread)
{
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINSTATION_OBJECT WinStaObject = NULL;
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINSTATION_OBJECT WinStaObject = NULL;
if(Thread->Tcb.Win32Thread && Thread->Tcb.Win32Thread->Desktop)
WinStaObject = Thread->Tcb.Win32Thread->Desktop->WindowStation;
if(Thread->Tcb.Win32Thread && Thread->Tcb.Win32Thread->Desktop)
WinStaObject = Thread->Tcb.Win32Thread->Desktop->WindowStation;
if(!WinStaObject)
return;
if(!WinStaObject)
return;
IntLockHotKeys(WinStaObject);
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
HOT_KEY_ITEM,
ListEntry);
HOT_KEY_ITEM,
ListEntry);
Entry = Entry->Flink;
if (HotKeyItem->Thread == Thread)
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
}
}
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
}
}
IntUnLockHotKeys(WinStaObject);
IntUnLockHotKeys(WinStaObject);
}
static BOOL
IsHotKey (PWINSTATION_OBJECT WinStaObject,
UINT fsModifiers,
UINT vk)
UINT fsModifiers,
UINT vk)
{
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
HOT_KEY_ITEM,
ListEntry);
HOT_KEY_ITEM,
ListEntry);
if (HotKeyItem->fsModifiers == fsModifiers &&
HotKeyItem->vk == vk)
{
return TRUE;
}
HotKeyItem->vk == vk)
{
return TRUE;
}
Entry = Entry->Flink;
}
}
return FALSE;
return FALSE;
}
BOOL STDCALL
NtUserRegisterHotKey(HWND hWnd,
int id,
UINT fsModifiers,
UINT vk)
int id,
UINT fsModifiers,
UINT vk)
{
PHOT_KEY_ITEM HotKeyItem;
PWINDOW_OBJECT Window;
PWINSTATION_OBJECT WinStaObject = NULL;
PETHREAD HotKeyThread;
DECLARE_RETURN(BOOL);
PHOT_KEY_ITEM HotKeyItem;
PWINDOW_OBJECT Window;
PWINSTATION_OBJECT WinStaObject = NULL;
PETHREAD HotKeyThread;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserRegisterHotKey\n");
UserEnterExclusive();
DPRINT("Enter NtUserRegisterHotKey\n");
UserEnterExclusive();
if (hWnd == NULL)
{
HotKeyThread = PsGetCurrentThread();
}
else
{
Window = IntGetWindowObject(hWnd);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
if (hWnd == NULL)
{
HotKeyThread = PsGetCurrentThread();
}
else
{
Window = IntGetWindowObject(hWnd);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
HotKeyThread = Window->OwnerThread;
IntReleaseWindowObject(Window);
}
if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
WinStaObject = HotKeyThread->Tcb.Win32Thread->Desktop->WindowStation;
if(!WinStaObject)
{
RETURN( FALSE);
}
HotKeyThread = Window->OwnerThread;
IntReleaseWindowObject(Window);
}
}
IntLockHotKeys(WinStaObject);
if(HotKeyThread->ThreadsProcess && HotKeyThread->ThreadsProcess->Win32Process)
WinStaObject = HotKeyThread->Tcb.Win32Thread->Desktop->WindowStation;
if(!WinStaObject)
{
RETURN( FALSE);
}
IntLockHotKeys(WinStaObject);
/* Check for existing hotkey */
if (IsHotKey (WinStaObject, fsModifiers, vk))
{
IntUnLockHotKeys(WinStaObject);
RETURN( FALSE);
}
HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
if (HotKeyItem == NULL)
{
/* Check for existing hotkey */
if (IsHotKey (WinStaObject, fsModifiers, vk))
{
IntUnLockHotKeys(WinStaObject);
RETURN( FALSE);
}
}
HotKeyItem->Thread = HotKeyThread;
HotKeyItem->hWnd = hWnd;
HotKeyItem->id = id;
HotKeyItem->fsModifiers = fsModifiers;
HotKeyItem->vk = vk;
HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
if (HotKeyItem == NULL)
{
IntUnLockHotKeys(WinStaObject);
RETURN( FALSE);
}
InsertHeadList (&WinStaObject->HotKeyListHead,
&HotKeyItem->ListEntry);
HotKeyItem->Thread = HotKeyThread;
HotKeyItem->hWnd = hWnd;
HotKeyItem->id = id;
HotKeyItem->fsModifiers = fsModifiers;
HotKeyItem->vk = vk;
IntUnLockHotKeys(WinStaObject);
InsertHeadList (&WinStaObject->HotKeyListHead,
&HotKeyItem->ListEntry);
IntUnLockHotKeys(WinStaObject);
RETURN( TRUE);
RETURN( TRUE);
CLEANUP:
DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
BOOL STDCALL
NtUserUnregisterHotKey(HWND hWnd,
int id)
int id)
{
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINDOW_OBJECT Window;
PWINSTATION_OBJECT WinStaObject = NULL;
DECLARE_RETURN(BOOL);
PLIST_ENTRY Entry;
PHOT_KEY_ITEM HotKeyItem;
PWINDOW_OBJECT Window;
PWINSTATION_OBJECT WinStaObject = NULL;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserUnregisterHotKey\n");
UserEnterExclusive();
DPRINT("Enter NtUserUnregisterHotKey\n");
UserEnterExclusive();
Window = IntGetWindowObject(hWnd);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Window = IntGetWindowObject(hWnd);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process)
WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process)
WinStaObject = Window->OwnerThread->Tcb.Win32Thread->Desktop->WindowStation;
if(!WinStaObject)
{
IntReleaseWindowObject(Window);
RETURN( FALSE);
}
if(!WinStaObject)
{
IntReleaseWindowObject(Window);
RETURN( FALSE);
}
IntLockHotKeys(WinStaObject);
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead)
{
HotKeyItem = (PHOT_KEY_ITEM) CONTAINING_RECORD (Entry,
HOT_KEY_ITEM,
ListEntry);
HOT_KEY_ITEM,
ListEntry);
if (HotKeyItem->hWnd == hWnd &&
HotKeyItem->id == id)
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
IntUnLockHotKeys(WinStaObject);
HotKeyItem->id == id)
{
RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem);
IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
RETURN( TRUE);
}
IntReleaseWindowObject(Window);
RETURN( TRUE);
}
Entry = Entry->Flink;
}
}
IntUnLockHotKeys(WinStaObject);
IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
RETURN( FALSE);
IntReleaseWindowObject(Window);
RETURN( FALSE);
CLEANUP:
DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
/* EOF */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -40,182 +40,182 @@
ULONG FASTCALL
UserGetSystemMetrics(ULONG Index)
{
NTSTATUS Status;
PWINSTATION_OBJECT WinStaObject;
ULONG Width, Height, Result;
NTSTATUS Status;
PWINSTATION_OBJECT WinStaObject;
ULONG Width, Height, Result;
Result = 0;
switch (Index)
{
case SM_ARRANGE:
return(8);
case SM_CLEANBOOT:
return(0);
case SM_CMOUSEBUTTONS:
return(2);
case SM_CXBORDER:
case SM_CYBORDER:
return(1);
case SM_CXCURSOR:
case SM_CYCURSOR:
return(32);
case SM_CXDLGFRAME:
case SM_CYDLGFRAME:
return(3);
case SM_CXDOUBLECLK:
case SM_CYDOUBLECLK:
case SM_SWAPBUTTON:
{
PSYSTEM_CURSORINFO CurInfo;
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObject);
if (!NT_SUCCESS(Status))
return 0xFFFFFFFF;
Result = 0;
switch (Index)
{
case SM_ARRANGE:
return(8);
case SM_CLEANBOOT:
return(0);
case SM_CMOUSEBUTTONS:
return(2);
case SM_CXBORDER:
case SM_CYBORDER:
return(1);
case SM_CXCURSOR:
case SM_CYCURSOR:
return(32);
case SM_CXDLGFRAME:
case SM_CYDLGFRAME:
return(3);
case SM_CXDOUBLECLK:
case SM_CYDOUBLECLK:
case SM_SWAPBUTTON:
{
PSYSTEM_CURSORINFO CurInfo;
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObject);
if (!NT_SUCCESS(Status))
return 0xFFFFFFFF;
CurInfo = IntGetSysCursorInfo(WinStaObject);
switch(Index)
{
case SM_CXDOUBLECLK:
Result = CurInfo->DblClickWidth;
break;
case SM_CYDOUBLECLK:
Result = CurInfo->DblClickWidth;
break;
case SM_SWAPBUTTON:
Result = (UINT)CurInfo->SwapButtons;
break;
}
CurInfo = IntGetSysCursorInfo(WinStaObject);
switch(Index)
{
case SM_CXDOUBLECLK:
Result = CurInfo->DblClickWidth;
break;
case SM_CYDOUBLECLK:
Result = CurInfo->DblClickWidth;
break;
case SM_SWAPBUTTON:
Result = (UINT)CurInfo->SwapButtons;
break;
}
ObDereferenceObject(WinStaObject);
return Result;
}
ObDereferenceObject(WinStaObject);
return Result;
}
case SM_CXDRAG:
case SM_CYDRAG:
return(2);
case SM_CXEDGE:
case SM_CYEDGE:
return(2);
case SM_CXFRAME:
case SM_CYFRAME:
return(4);
case SM_CXFULLSCREEN:
/* FIXME: shouldn't we take borders etc into account??? */
return UserGetSystemMetrics(SM_CXSCREEN);
case SM_CYFULLSCREEN:
return UserGetSystemMetrics(SM_CYSCREEN);
case SM_CXHSCROLL:
case SM_CYHSCROLL:
return(16);
case SM_CYVTHUMB:
case SM_CXHTHUMB:
return(16);
case SM_CXICON:
case SM_CYICON:
return(32);
case SM_CXICONSPACING:
case SM_CYICONSPACING:
return(64);
case SM_CXMAXIMIZED:
return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
pixels greater than
the screen width */
case SM_CYMAXIMIZED:
return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
pixels less than
the screen height,
taskbar maybe? */
case SM_CXMAXTRACK:
return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
case SM_CYMAXTRACK:
return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
case SM_CXMENUCHECK:
case SM_CYMENUCHECK:
return(13);
case SM_CXMENUSIZE:
case SM_CYMENUSIZE:
return(18);
case SM_CXMIN:
return(112);
case SM_CYMIN:
return(27);
case SM_CXMINIMIZED:
return(160);
case SM_CYMINIMIZED:
return(24);
case SM_CXMINSPACING:
return(160);
case SM_CYMINSPACING:
return(24);
case SM_CXMINTRACK:
return(112);
case SM_CYMINTRACK:
return(27);
case SM_CXSCREEN:
case SM_CYSCREEN:
{
HDC ScreenDCHandle;
PDC ScreenDC;
case SM_CXDRAG:
case SM_CYDRAG:
return(2);
case SM_CXEDGE:
case SM_CYEDGE:
return(2);
case SM_CXFRAME:
case SM_CYFRAME:
return(4);
case SM_CXFULLSCREEN:
/* FIXME: shouldn't we take borders etc into account??? */
return UserGetSystemMetrics(SM_CXSCREEN);
case SM_CYFULLSCREEN:
return UserGetSystemMetrics(SM_CYSCREEN);
case SM_CXHSCROLL:
case SM_CYHSCROLL:
return(16);
case SM_CYVTHUMB:
case SM_CXHTHUMB:
return(16);
case SM_CXICON:
case SM_CYICON:
return(32);
case SM_CXICONSPACING:
case SM_CYICONSPACING:
return(64);
case SM_CXMAXIMIZED:
return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8
pixels greater than
the screen width */
case SM_CYMAXIMIZED:
return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20
pixels less than
the screen height,
taskbar maybe? */
case SM_CXMAXTRACK:
return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
case SM_CYMAXTRACK:
return(UserGetSystemMetrics(SM_CYSCREEN) + 12);
case SM_CXMENUCHECK:
case SM_CYMENUCHECK:
return(13);
case SM_CXMENUSIZE:
case SM_CYMENUSIZE:
return(18);
case SM_CXMIN:
return(112);
case SM_CYMIN:
return(27);
case SM_CXMINIMIZED:
return(160);
case SM_CYMINIMIZED:
return(24);
case SM_CXMINSPACING:
return(160);
case SM_CYMINSPACING:
return(24);
case SM_CXMINTRACK:
return(112);
case SM_CYMINTRACK:
return(27);
case SM_CXSCREEN:
case SM_CYSCREEN:
{
HDC ScreenDCHandle;
PDC ScreenDC;
Width = 640;
Height = 480;
ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE);
if (NULL != ScreenDCHandle)
{
ScreenDC = DC_LockDc(ScreenDCHandle);
if (NULL != ScreenDC)
{
Width = ScreenDC->GDIInfo->ulHorzRes;
Height = ScreenDC->GDIInfo->ulVertRes;
DC_UnlockDc(ScreenDC);
}
NtGdiDeleteDC(ScreenDCHandle);
}
return SM_CXSCREEN == Index ? Width : Height;
}
case SM_CXSIZE:
case SM_CYSIZE:
return(18);
case SM_CXSMICON:
case SM_CYSMICON:
return(16);
case SM_CXSMSIZE:
return(12);
case SM_CYSMSIZE:
return(14);
case SM_CXVSCROLL:
case SM_CYVSCROLL:
return(16);
case SM_CYCAPTION:
return(19);
case SM_CYKANJIWINDOW:
return 0;
case SM_CYMENU:
return(19);
case SM_CYSMCAPTION:
return(15);
case SM_DBCSENABLED:
case SM_DEBUG:
case SM_MENUDROPALIGNMENT:
case SM_MIDEASTENABLED:
return(0);
case SM_MOUSEPRESENT:
return(1);
case SM_NETWORK:
return(3);
case SM_PENWINDOWS:
case SM_SECURE:
case SM_SHOWSOUNDS:
case SM_SLOWMACHINE:
return(0);
case SM_CMONITORS:
return(1);
Width = 640;
Height = 480;
ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE);
if (NULL != ScreenDCHandle)
{
ScreenDC = DC_LockDc(ScreenDCHandle);
if (NULL != ScreenDC)
{
Width = ScreenDC->GDIInfo->ulHorzRes;
Height = ScreenDC->GDIInfo->ulVertRes;
DC_UnlockDc(ScreenDC);
}
NtGdiDeleteDC(ScreenDCHandle);
}
return SM_CXSCREEN == Index ? Width : Height;
}
case SM_CXSIZE:
case SM_CYSIZE:
return(18);
case SM_CXSMICON:
case SM_CYSMICON:
return(16);
case SM_CXSMSIZE:
return(12);
case SM_CYSMSIZE:
return(14);
case SM_CXVSCROLL:
case SM_CYVSCROLL:
return(16);
case SM_CYCAPTION:
return(19);
case SM_CYKANJIWINDOW:
return 0;
case SM_CYMENU:
return(19);
case SM_CYSMCAPTION:
return(15);
case SM_DBCSENABLED:
case SM_DEBUG:
case SM_MENUDROPALIGNMENT:
case SM_MIDEASTENABLED:
return(0);
case SM_MOUSEPRESENT:
return(1);
case SM_NETWORK:
return(3);
case SM_PENWINDOWS:
case SM_SECURE:
case SM_SHOWSOUNDS:
case SM_SLOWMACHINE:
return(0);
case SM_CMONITORS:
return(1);
default:
return(0xFFFFFFFF);
}
default:
return(0xFFFFFFFF);
}
}
@ -224,16 +224,16 @@ UserGetSystemMetrics(ULONG Index)
ULONG STDCALL
NtUserGetSystemMetrics(ULONG Index)
{
DECLARE_RETURN(ULONG);
DECLARE_RETURN(ULONG);
DPRINT("Enter NtUserGetSystemMetrics\n");
UserEnterExclusive();
DPRINT("Enter NtUserGetSystemMetrics\n");
UserEnterExclusive();
RETURN(UserGetSystemMetrics(Index));
RETURN(UserGetSystemMetrics(Index));
CLEANUP:
DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
/* EOF */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -46,9 +46,9 @@ DWORD _locked=0;
NTSTATUS FASTCALL InitUserImpl(VOID)
{
//PVOID mem;
// DPRINT("Enter InitUserImpl\n");
// ExInitializeResourceLite(&UserLock);
// DPRINT("Enter InitUserImpl\n");
// ExInitializeResourceLite(&UserLock);
ExInitializeFastMutex(&UserLock);
@ -57,7 +57,7 @@ NTSTATUS FASTCALL InitUserImpl(VOID)
DPRINT1("Failed creating handle table\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
return STATUS_SUCCESS;
}
@ -73,35 +73,35 @@ BOOL FASTCALL UserIsEntered()
VOID FASTCALL CleanupUser(VOID)
{
// ExDeleteResourceLite(&UserLock);
// ExDeleteResourceLite(&UserLock);
}
VOID FASTCALL UUserEnterShared(VOID)
{
// DPRINT("Enter IntLockUserShared\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// KeEnterCriticalRegion();
// ExAcquireResourceSharedLite(&UserLock, TRUE);
// DPRINT("Enter IntLockUserShared\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// KeEnterCriticalRegion();
// ExAcquireResourceSharedLite(&UserLock, TRUE);
ExAcquireFastMutex(&UserLock);
}
VOID FASTCALL UUserEnterExclusive(VOID)
{
// DPRINT("Enter UserEnterExclusive\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// KeEnterCriticalRegion();
// ExAcquireResourceExclusiveLite(&UserLock, TRUE);
// DPRINT("Enter UserEnterExclusive\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// KeEnterCriticalRegion();
// ExAcquireResourceExclusiveLite(&UserLock, TRUE);
ExAcquireFastMutex(&UserLock);
}
VOID FASTCALL UUserLeave(VOID)
{
// DPRINT("Enter UserLeave\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// ExReleaseResourceLite(&UserLock);
// KeLeaveCriticalRegion();
// DPRINT("Enter UserLeave\n");
// KeDumpStackFrames((PULONG)__builtin_frame_address(0));
//DPRINT("%x\n",__builtin_return_address(0));
// ExReleaseResourceLite(&UserLock);
// KeLeaveCriticalRegion();
ExReleaseFastMutex(&UserLock);
}

View file

@ -33,167 +33,179 @@ USER_HANDLE_TABLE gHandleTable;
PUSER_HANDLE_ENTRY handle_to_entry(PUSER_HANDLE_TABLE ht, HANDLE handle )
{
unsigned short generation;
int index = (((unsigned int)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
if (index < 0 || index >= ht->nb_handles) return NULL;
if (!ht->handles[index].type) return NULL;
generation = (unsigned int)handle >> 16;
if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
return &ht->handles[index];
return NULL;
unsigned short generation;
int index = (((unsigned int)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
if (index < 0 || index >= ht->nb_handles)
return NULL;
if (!ht->handles[index].type)
return NULL;
generation = (unsigned int)handle >> 16;
if (generation == ht->handles[index].generation || !generation || generation == 0xffff)
return &ht->handles[index];
return NULL;
}
inline static HANDLE entry_to_handle(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY ptr )
{
int index = ptr - ht->handles;
return (HANDLE)(((index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
int index = ptr - ht->handles;
return (HANDLE)(((index << 1) + FIRST_USER_HANDLE) + (ptr->generation << 16));
}
inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
if (ht->freelist)
{
entry = ht->freelist;
ht->freelist = entry->ptr;
usedHandles++;
return entry;
}
if (ht->nb_handles >= ht->allocated_handles) /* need to grow the array */
{
DPRINT1("Out of user handles!\n");
return NULL;
if (ht->freelist)
{
entry = ht->freelist;
ht->freelist = entry->ptr;
usedHandles++;
return entry;
}
if (ht->nb_handles >= ht->allocated_handles) /* need to grow the array */
{
DPRINT1("Out of user handles!\n");
return NULL;
#if 0
struct user_handle *new_handles;
/* grow array by 50% (but at minimum 32 entries) */
int growth = max( 32, allocated_handles / 2 );
int new_size = min( allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 );
if (new_size <= allocated_handles) return NULL;
if (!(new_handles = realloc( handles, new_size * sizeof(*handles) )))
return NULL;
handles = new_handles;
allocated_handles = new_size;
#endif
}
entry = &ht->handles[ht->nb_handles++];
entry->generation = 1;
usedHandles++;
return entry;
struct user_handle *new_handles;
/* grow array by 50% (but at minimum 32 entries) */
int growth = max( 32, allocated_handles / 2 );
int new_size = min( allocated_handles + growth, (LAST_USER_HANDLE-FIRST_USER_HANDLE+1) >> 1 );
if (new_size <= allocated_handles)
return NULL;
if (!(new_handles = realloc( handles, new_size * sizeof(*handles) )))
return NULL;
handles = new_handles;
allocated_handles = new_size;
#endif
}
entry = &ht->handles[ht->nb_handles++];
entry->generation = 1;
usedHandles++;
return entry;
}
VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes)
{
ht->freelist = NULL;
ht->handles = mem;
ht->nb_handles = 0;
ht->nb_handles = 0;
ht->allocated_handles = bytes / sizeof(USER_HANDLE_ENTRY);
}
inline static void *free_user_entry(PUSER_HANDLE_TABLE ht, PUSER_HANDLE_ENTRY entry)
{
void *ret;
ret = entry->ptr;
entry->ptr = ht->freelist;
entry->type = 0;
ht->freelist = entry;
usedHandles--;
return ret;
void *ret;
ret = entry->ptr;
entry->ptr = ht->freelist;
entry->type = 0;
ht->freelist = entry;
usedHandles--;
return ret;
}
/* allocate a user handle for a given object */
HANDLE UserAllocHandle(PUSER_HANDLE_TABLE ht, PVOID object, USER_OBJECT_TYPE type )
{
PUSER_HANDLE_ENTRY entry = alloc_user_entry(ht);
if (!entry) return 0;
entry->ptr = object;
entry->type = type;
if (++entry->generation >= 0xffff) entry->generation = 1;
return entry_to_handle(ht, entry );
PUSER_HANDLE_ENTRY entry = alloc_user_entry(ht);
if (!entry)
return 0;
entry->ptr = object;
entry->type = type;
if (++entry->generation >= 0xffff)
entry->generation = 1;
return entry_to_handle(ht, entry );
}
/* return a pointer to a user object from its handle */
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, USER_OBJECT_TYPE type )
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
ASSERT(ht);
ASSERT(ht);
if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return NULL;
}
return entry->ptr;
if (!(entry = handle_to_entry(ht, handle )) || entry->type != type)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return NULL;
}
return entry->ptr;
}
/* get the full handle (32bit) for a possibly truncated (16bit) handle */
HANDLE get_user_full_handle(PUSER_HANDLE_TABLE ht, HANDLE handle )
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
if ((unsigned int)handle >> 16) return handle;
if (!(entry = handle_to_entry(ht, handle ))) return handle;
return entry_to_handle( ht, entry );
if ((unsigned int)handle >> 16)
return handle;
if (!(entry = handle_to_entry(ht, handle )))
return handle;
return entry_to_handle( ht, entry );
}
/* same as get_user_object plus set the handle to the full 32-bit value */
void *get_user_object_handle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE type )
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
if (!(entry = handle_to_entry(ht, *handle )) || entry->type != type) return NULL;
*handle = entry_to_handle( ht, entry );
return entry->ptr;
if (!(entry = handle_to_entry(ht, *handle )) || entry->type != type)
return NULL;
*handle = entry_to_handle( ht, entry );
return entry->ptr;
}
/* free a user handle and return a pointer to the object */
PVOID UserFreeHandle(PUSER_HANDLE_TABLE ht, HANDLE handle )
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
if (!(entry = handle_to_entry( ht, handle )))
{
SetLastNtError( STATUS_INVALID_HANDLE );
return NULL;
}
return free_user_entry(ht, entry );
if (!(entry = handle_to_entry( ht, handle )))
{
SetLastNtError( STATUS_INVALID_HANDLE );
return NULL;
}
return free_user_entry(ht, entry );
}
/* return the next user handle after 'handle' that is of a given type */
PVOID UserGetNextHandle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE type )
{
PUSER_HANDLE_ENTRY entry;
PUSER_HANDLE_ENTRY entry;
if (!*handle) entry = ht->handles;
else
{
int index = (((unsigned int)*handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
if (index < 0 || index >= ht->nb_handles) return NULL;
entry = ht->handles + index + 1; /* start from the next one */
}
while (entry < ht->handles + ht->nb_handles)
{
if (!type || entry->type == type)
{
*handle = entry_to_handle(ht, entry );
return entry->ptr;
}
entry++;
}
return NULL;
if (!*handle)
entry = ht->handles;
else
{
int index = (((unsigned int)*handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
if (index < 0 || index >= ht->nb_handles)
return NULL;
entry = ht->handles + index + 1; /* start from the next one */
}
while (entry < ht->handles + ht->nb_handles)
{
if (!type || entry->type == type)
{
*handle = entry_to_handle(ht, entry );
return entry->ptr;
}
entry++;
}
return NULL;
}
@ -201,14 +213,16 @@ PVOID UserGetNextHandle(PUSER_HANDLE_TABLE ht, HANDLE* handle, USER_OBJECT_TYPE
PVOID FASTCALL
ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG size)
{
HANDLE hi;
PUSER_OBJECT_HEADER hdr = ExAllocatePool(PagedPool, size + sizeof(USER_OBJECT_HEADER));
if (!hdr) return NULL;
if (!hdr)
return NULL;
hi = UserAllocHandle(ht, USER_HEADER_TO_BODY(hdr), type );
if (!hi){
if (!hi)
{
ExFreePool(hdr);
return NULL;
}
@ -216,33 +230,35 @@ ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG s
RtlZeroMemory(hdr, size + sizeof(USER_OBJECT_HEADER));
hdr->hSelf = hi;
hdr->RefCount++; //temp hack!
if (h) *h = hi;
if (h)
*h = hi;
return USER_HEADER_TO_BODY(hdr);
}
BOOL FASTCALL
BOOL FASTCALL
ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
{
PUSER_OBJECT_HEADER hdr;
PVOID body = UserGetObject(&gHandleTable, h, type);
if (!body) return FALSE;
if (!body)
return FALSE;
hdr = USER_BODY_TO_HEADER(body);
ASSERT(hdr->RefCount >= 0);
hdr->destroyed = TRUE;
if (hdr->RefCount == 0)
{
UserFreeHandle(&gHandleTable, h);
memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER));
ExFreePool(hdr);
return TRUE;
}
// DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles);
// DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles);
return FALSE;
}
@ -250,9 +266,9 @@ ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
VOID FASTCALL ObmReferenceObject(PVOID obj)
{
PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj);
ASSERT(hdr->RefCount >= 0);
hdr->RefCount++;
}
@ -260,24 +276,24 @@ VOID FASTCALL ObmReferenceObject(PVOID obj)
BOOL FASTCALL ObmDereferenceObject(PVOID obj)
{
PUSER_OBJECT_HEADER hdr = USER_BODY_TO_HEADER(obj);
ASSERT(hdr->RefCount >= 1);
hdr->RefCount--;
if (hdr->RefCount == 0 && hdr->destroyed)
{
// DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles);
// DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles);
UserFreeHandle(&gHandleTable, hdr->hSelf);
memset(hdr, 0x55, sizeof(USER_OBJECT_HEADER));
ExFreePool(hdr);
return TRUE;
}
return FALSE;
}
@ -285,7 +301,7 @@ BOOL FASTCALL ObmDereferenceObject(PVOID obj)
BOOL FASTCALL ObmCreateHandleTable()
{
PVOID mem;
//FIXME: dont alloc all at once! must be mapped into umode also...
@ -295,9 +311,9 @@ BOOL FASTCALL ObmCreateHandleTable()
DPRINT1("Failed creating handle table\n");
return FALSE;
}
//FIXME: make auto growable
UserInitHandleTable(&gHandleTable, mem, sizeof(USER_HANDLE_ENTRY) * 1024);
return TRUE;
}

View file

@ -60,7 +60,7 @@ IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
OffsetY = Child->WindowRect.top - ParentWindow->WindowRect.top;
NtGdiOffsetRgn(ValidRegion, OffsetX, OffsetY);
NtGdiCombineRgn(ParentWindow->UpdateRegion, ParentWindow->UpdateRegion,
ValidRegion, RGN_DIFF);
ValidRegion, RGN_DIFF);
/* FIXME: If the resulting region is empty, remove fake posted paint message */
NtGdiOffsetRgn(ValidRegion, -OffsetX, -OffsetY);
}
@ -79,101 +79,101 @@ IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion)
STATIC VOID FASTCALL
co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
{
HDC hDC;
HWND hWnd = Window->hSelf;
HRGN TempRegion;
HDC hDC;
HWND hWnd = Window->hSelf;
HRGN TempRegion;
if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
{
if (Flags & (RDW_ERASENOW | RDW_UPDATENOW))
{
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
{
if (Window->NCUpdateRegion)
{
IntValidateParent(Window, Window->NCUpdateRegion);
}
TempRegion = Window->NCUpdateRegion;
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
{
GDIOBJ_SetOwnership(TempRegion, PsGetCurrentProcess());
}
Window->NCUpdateRegion = NULL;
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
MsqDecPaintCountQueue(Window->MessageQueue);
co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
{
/* NOTE: The region can already be deleted! */
GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
}
}
{
if (Window->NCUpdateRegion)
{
IntValidateParent(Window, Window->NCUpdateRegion);
}
TempRegion = Window->NCUpdateRegion;
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
{
GDIOBJ_SetOwnership(TempRegion, PsGetCurrentProcess());
}
Window->NCUpdateRegion = NULL;
Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT;
MsqDecPaintCountQueue(Window->MessageQueue);
co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0);
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
{
/* NOTE: The region can already be deleted! */
GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
}
}
if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND)
{
if (Window->UpdateRegion)
{
if (Window->UpdateRegion)
{
/*
* This surely wrong! Why we would want to validate the parent?
* It breaks quite a few things including dummy WM_ERASEBKGND
* implementations that return only TRUE and have corresponding
* WM_PAINT that doesn't paint the whole client area.
* I left the code here so that no one will readd it again!
* - Filip
*/
/* IntValidateParent(Window, Window->UpdateRegion); */
hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE |
DCX_INTERSECTUPDATE);
if (hDC != NULL)
{
/*
* This surely wrong! Why we would want to validate the parent?
* It breaks quite a few things including dummy WM_ERASEBKGND
* implementations that return only TRUE and have corresponding
* WM_PAINT that doesn't paint the whole client area.
* I left the code here so that no one will readd it again!
* - Filip
*/
/* IntValidateParent(Window, Window->UpdateRegion); */
hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE |
DCX_INTERSECTUPDATE);
if (hDC != NULL)
{
if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
{
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
}
UserReleaseDC(Window, hDC);
}
if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0))
{
Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND;
}
UserReleaseDC(Window, hDC);
}
}
}
}
if (Flags & RDW_UPDATENOW)
{
if (Window->UpdateRegion != NULL ||
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
{
co_IntSendMessage(hWnd, WM_PAINT, 0, 0);
}
}
}
{
if (Window->UpdateRegion != NULL ||
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
{
co_IntSendMessage(hWnd, WM_PAINT, 0, 0);
}
}
}
/*
* Check that the window is still valid at this point
*/
/*
* Check that the window is still valid at this point
*/
if (! IntIsWindow(hWnd))
{
if (! IntIsWindow(hWnd))
{
return;
}
}
/*
* Paint child windows.
*/
if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
{
/*
* Paint child windows.
*/
if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
{
HWND *List, *phWnd;
if ((List = IntWinListChildren(Window)))
{
for (phWnd = List; *phWnd; ++phWnd)
{
for (phWnd = List; *phWnd; ++phWnd)
{
Window = IntGetWindowObject(*phWnd);
if (Window && (Window->Style & WS_VISIBLE))
{
Window = IntGetWindowObject(*phWnd);
if (Window && (Window->Style & WS_VISIBLE))
{
co_IntPaintWindows(Window, Flags);
IntReleaseWindowObject(Window);
}
co_IntPaintWindows(Window, Flags);
IntReleaseWindowObject(Window);
}
ExFreePool(List);
}
}
}
ExFreePool(List);
}
}
}
/*
@ -199,8 +199,8 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
NtGdiOffsetRgn(hRgnWindow,
-Window->WindowRect.left,
-Window->WindowRect.top);
-Window->WindowRect.left,
-Window->WindowRect.top);
RgnType = NtGdiCombineRgn(hRgn, hRgn, hRgnWindow, RGN_AND);
NtGdiDeleteObject(hRgnWindow);
}
@ -214,7 +214,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
*/
HadPaintMessage = Window->UpdateRegion != NULL ||
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
HadNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
/*
@ -230,7 +230,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
}
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgn, RGN_OR) == NULLREGION)
hRgn, RGN_OR) == NULLREGION)
{
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
@ -250,7 +250,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
if (Window->UpdateRegion != NULL)
{
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgn, RGN_DIFF) == NULLREGION)
hRgn, RGN_DIFF) == NULLREGION)
{
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
@ -286,12 +286,12 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
hRgnWindow = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
NtGdiOffsetRgn(hRgnWindow,
-Window->WindowRect.left,
-Window->WindowRect.top);
-Window->WindowRect.left,
-Window->WindowRect.top);
hRgnNonClient = NtGdiCreateRectRgn(0, 0, 0, 0);
if (NtGdiCombineRgn(hRgnNonClient, Window->UpdateRegion,
hRgnWindow, RGN_DIFF) == NULLREGION)
hRgnWindow, RGN_DIFF) == NULLREGION)
{
NtGdiDeleteObject(hRgnNonClient);
hRgnNonClient = NULL;
@ -305,7 +305,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
* Remove the nonclient region from the standard update region.
*/
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgnWindow, RGN_AND) == NULLREGION)
hRgnWindow, RGN_AND) == NULLREGION)
{
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
@ -320,10 +320,10 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
{
if(NULL != hRgnNonClient)
{
NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
hRgnNonClient, RGN_OR);
GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
NtGdiDeleteObject(hRgnNonClient);
NtGdiCombineRgn(Window->NCUpdateRegion, Window->NCUpdateRegion,
hRgnNonClient, RGN_OR);
GDIOBJ_SetOwnership(hRgnNonClient, PsGetCurrentProcess());
NtGdiDeleteObject(hRgnNonClient);
}
}
@ -335,7 +335,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
*/
if (!(Flags & RDW_NOCHILDREN) && !(Window->Style & WS_MINIMIZE) &&
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
((Flags & RDW_ALLCHILDREN) || !(Window->Style & WS_CLIPCHILDREN)))
{
HWND *List, *phWnd;
PWINDOW_OBJECT Child;
@ -347,7 +347,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
Child = IntGetWindowObject(*phWnd);
if(!Child)
{
continue;
continue;
}
if (Child->Style & WS_VISIBLE)
{
@ -357,8 +357,8 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
HRGN hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY);
NtGdiOffsetRgn(hRgnTemp,
Window->WindowRect.left - Child->WindowRect.left,
Window->WindowRect.top - Child->WindowRect.top);
Window->WindowRect.left - Child->WindowRect.left,
Window->WindowRect.top - Child->WindowRect.top);
IntInvalidateWindows(Child, hRgnTemp, Flags);
NtGdiDeleteObject(hRgnTemp);
}
@ -373,7 +373,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
*/
HasPaintMessage = Window->UpdateRegion != NULL ||
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT;
HasNCPaintMessage = Window->Flags & WINDOWOBJECT_NEED_NCPAINT;
if (HasPaintMessage != HadPaintMessage)
@ -410,14 +410,15 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window)
do
{
if (!(Wnd->Style & WS_VISIBLE) ||
((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
((Wnd->Style & WS_MINIMIZE) && (Wnd != Window)))
{
return FALSE;
}
Wnd = Wnd->Parent;
} while(Wnd);
}
while(Wnd);
return TRUE;
}
@ -431,7 +432,7 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window)
BOOL FASTCALL
co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn,
ULONG Flags)
ULONG Flags)
{
HRGN hRgn = NULL;
@ -441,8 +442,8 @@ co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRg
*/
if (!IntIsWindowDrawable(Window) ||
(Flags & (RDW_VALIDATE | RDW_INVALIDATE)) ==
(RDW_VALIDATE | RDW_INVALIDATE))
(Flags & (RDW_VALIDATE | RDW_INVALIDATE)) ==
(RDW_VALIDATE | RDW_INVALIDATE))
{
return FALSE;
}
@ -460,31 +461,33 @@ co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRg
hRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
NtGdiCombineRgn(hRgn, UpdateRgn, NULL, RGN_COPY);
NtGdiOffsetRgn(hRgn,
Window->ClientRect.left - Window->WindowRect.left,
Window->ClientRect.top - Window->WindowRect.top);
} else
if (UpdateRect != NULL)
{
hRgn = UnsafeIntCreateRectRgnIndirect((RECT *)UpdateRect);
NtGdiOffsetRgn(hRgn,
Window->ClientRect.left - Window->WindowRect.left,
Window->ClientRect.top - Window->WindowRect.top);
} else
if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME) ||
(Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE | RDW_NOFRAME))
{
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
NtGdiOffsetRgn(hRgn,
-Window->WindowRect.left,
-Window->WindowRect.top);
Window->ClientRect.left - Window->WindowRect.left,
Window->ClientRect.top - Window->WindowRect.top);
}
else
{
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
NtGdiOffsetRgn(hRgn,
-Window->WindowRect.left,
-Window->WindowRect.top);
}
if (UpdateRect != NULL)
{
hRgn = UnsafeIntCreateRectRgnIndirect((RECT *)UpdateRect);
NtGdiOffsetRgn(hRgn,
Window->ClientRect.left - Window->WindowRect.left,
Window->ClientRect.top - Window->WindowRect.top);
}
else
if ((Flags & (RDW_INVALIDATE | RDW_FRAME)) == (RDW_INVALIDATE | RDW_FRAME) ||
(Flags & (RDW_VALIDATE | RDW_NOFRAME)) == (RDW_VALIDATE | RDW_NOFRAME))
{
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
NtGdiOffsetRgn(hRgn,
-Window->WindowRect.left,
-Window->WindowRect.top);
}
else
{
hRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
NtGdiOffsetRgn(hRgn,
-Window->WindowRect.left,
-Window->WindowRect.top);
}
}
/*
@ -524,9 +527,9 @@ BOOL FASTCALL
IntIsWindowDirty(PWINDOW_OBJECT Window)
{
return (Window->Style & WS_VISIBLE) &&
((Window->UpdateRegion != NULL) ||
(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
(Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
((Window->UpdateRegion != NULL) ||
(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) ||
(Window->Flags & WINDOWOBJECT_NEED_NCPAINT));
}
HWND STDCALL
@ -541,7 +544,7 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
return NULL;
if (IntIsWindowDirty(Window) &&
IntWndBelongsToThread(Window, Thread))
IntWndBelongsToThread(Window, Thread))
{
IntReleaseWindowObject(Window);
return hWnd;
@ -550,7 +553,7 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
for (Child = Window->FirstChild; Child; Child = Child->NextSibling)
{
if (IntIsWindowDirty(Child) &&
IntWndBelongsToThread(Child, Thread))
IntWndBelongsToThread(Child, Thread))
{
hFoundWnd = Child->hSelf;
break;
@ -591,7 +594,7 @@ IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax,
return FALSE;
if ((MsgFilterMin != 0 || MsgFilterMax != 0) &&
(MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
(MsgFilterMin > WM_PAINT || MsgFilterMax < WM_PAINT))
return FALSE;
if (hWnd)
@ -631,17 +634,17 @@ co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
PTHRDCARETINFO CaretInfo;
HWND hWndCaret;
PWINDOW_OBJECT WndCaret;
ASSERT_REFS_CO(Window);
Desktop = PsGetCurrentThread()->Tcb.Win32Thread->Desktop;
CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo;
hWndCaret = CaretInfo->hWnd;
WndCaret = UserGetWindowObject(hWndCaret);
if (WndCaret == Window ||
((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window->hSelf, hWndCaret)))
((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window->hSelf, hWndCaret)))
{
POINT pt, FromOffset, ToOffset, Offset;
RECT rcCaret;
@ -702,7 +705,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
HRGN hRgn;
if (Window->NCUpdateRegion != (HANDLE)1 &&
Window->NCUpdateRegion != NULL)
Window->NCUpdateRegion != NULL)
{
GDIOBJ_SetOwnership(Window->NCUpdateRegion, PsGetCurrentProcess());
}
@ -720,7 +723,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
}
RtlZeroMemory(&Ps, sizeof(PAINTSTRUCT));
Ps.hdc = UserGetDCEx(Window, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | DCX_USESTYLE);
if (!Ps.hdc)
@ -778,12 +781,12 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
}
RETURN( Ps.hdc);
CLEANUP:
DPRINT("Leave NtUserBeginPaint, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
/*
@ -801,19 +804,19 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
DPRINT("Enter NtUserEndPaint\n");
UserEnterExclusive();
if (!(Window = IntGetWindowObject(hWnd)))
{
RETURN(FALSE);
}
UserReleaseDC(Window, lPs->hdc);
co_UserShowCaret(Window);
IntReleaseWindowObject(Window); //temp hack
RETURN(TRUE);
CLEANUP:
DPRINT("Leave NtUserEndPaint, ret=%i\n",_ret_);
UserLeave();
@ -927,18 +930,18 @@ NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
DPRINT("Enter NtUserGetUpdateRgn\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(ERROR);
}
UserRefObjectCo(Window);
ret = co_UserGetUpdateRgn(Window, hRgn, bErase);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_);
UserLeave();
@ -1020,7 +1023,7 @@ CLEANUP:
BOOL STDCALL
NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
UINT flags)
UINT flags)
{
RECT SafeUpdateRect;
NTSTATUS Status;
@ -1038,7 +1041,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
if (lprcUpdate != NULL)
{
Status = MmCopyFromCaller(&SafeUpdateRect, (PRECT)lprcUpdate,
sizeof(RECT));
sizeof(RECT));
if (!NT_SUCCESS(Status))
{
@ -1050,7 +1053,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
UserRefObjectCo(Wnd);
Status = co_UserRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect,
hrgnUpdate, flags);
hrgnUpdate, flags);
UserDerefObjectCo(Wnd);
@ -1062,7 +1065,7 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate,
}
RETURN( TRUE);
CLEANUP:
DPRINT("Leave NtUserRedrawWindow, ret=%i\n",_ret_);
UserLeave();
@ -1074,7 +1077,7 @@ CLEANUP:
static
DWORD FASTCALL
UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
{
RECT rSrc, rClipped_src, rClip, rDst, offset;
PDC DC;
@ -1085,9 +1088,9 @@ UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
DC = DC_LockDc(hDC);
if (NULL == DC)
{
return FALSE;
}
{
return FALSE;
}
if (lprcScroll)
rSrc = *lprcScroll;
else
@ -1182,20 +1185,20 @@ UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
DWORD STDCALL
NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll,
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
{
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserScrollDC\n");
UserEnterExclusive();
RETURN( UserScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate));
CLEANUP:
DPRINT("Leave NtUserScrollDC, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
/*
@ -1207,7 +1210,7 @@ CLEANUP:
DWORD STDCALL
NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
const RECT *UnsafeClipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
const RECT *UnsafeClipRect, HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags)
{
RECT rc, cliprc, caretrc, rect, clipRect;
INT Result;
@ -1229,10 +1232,10 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
Window = NULL; /* prevent deref at cleanup */
RETURN( ERROR);
}
UserRefObjectCo(Window);
UserRefObjectCo(Window);
IntGetClientRect(Window, &rc);
if (NULL != UnsafeRect)
{
Status = MmCopyFromCaller(&rect, UnsafeRect, sizeof(RECT));
@ -1258,7 +1261,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
cliprc = rc;
if (cliprc.right <= cliprc.left || cliprc.bottom <= cliprc.top ||
(dx == 0 && dy == 0))
(dx == 0 && dy == 0))
{
RETURN( NULLREGION);
}
@ -1293,7 +1296,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
co_UserRedrawWindow(Window, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE);
NtGdiDeleteObject(hrgnClip);
}
NtGdiDeleteObject(hrgnTemp);
if (flags & SW_SCROLLCHILDREN)
@ -1305,11 +1308,12 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
RECT r, dummy;
POINT ClientOrigin;
PWINDOW_OBJECT Wnd;
IntGetClientOrigin(Window, &ClientOrigin);
for (i = 0; List[i]; i++)
{
if (!(Wnd = UserGetWindowObject(List[i]))) continue;
if (!(Wnd = UserGetWindowObject(List[i])))
continue;
r = Wnd->WindowRect;
r.left -= ClientOrigin.x;
@ -1321,11 +1325,11 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
{
UserRefObjectCo(Wnd);
co_WinPosSetWindowPos(Wnd, 0, r.left + dx, r.top + dy, 0, 0,
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
SWP_NOREDRAW);
UserDerefObjectCo(Wnd);
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
SWP_NOREDRAW);
UserDerefObjectCo(Wnd);
}
}
ExFreePool(List);
}
@ -1333,8 +1337,8 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
if (flags & (SW_INVALIDATE | SW_ERASE))
co_UserRedrawWindow(Window, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
((flags & SW_ERASE) ? RDW_ERASENOW : 0) |
((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0));
if (bOwnRgn && hrgnUpdate)
NtGdiDeleteObject(hrgnUpdate);
@ -1342,17 +1346,18 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect,
if ((CaretWnd = UserGetWindowObject(hwndCaret)))
{
UserRefObjectCo(CaretWnd);
co_IntSetCaretPos(caretrc.left + dx, caretrc.top + dy);
co_UserShowCaret(CaretWnd);
UserDerefObjectCo(CaretWnd);
}
RETURN( Result);
CLEANUP:
if (Window) UserDerefObjectCo(Window);
if (Window)
UserDerefObjectCo(Window);
DPRINT("Leave NtUserScrollWindowEx, ret=%i\n",_ret_);
UserLeave();

View file

@ -35,9 +35,10 @@
typedef struct _PROPLISTITEM
{
ATOM Atom;
HANDLE Data;
} PROPLISTITEM, *PPROPLISTITEM;
ATOM Atom;
HANDLE Data;
}
PROPLISTITEM, *PPROPLISTITEM;
/* STATIC FUNCTIONS **********************************************************/
@ -48,205 +49,205 @@ static
PPROPERTY FASTCALL
IntGetProp(PWINDOW_OBJECT Window, ATOM Atom)
{
PLIST_ENTRY ListEntry;
PPROPERTY Property;
PLIST_ENTRY ListEntry;
PPROPERTY Property;
ListEntry = Window->PropListHead.Flink;
while (ListEntry != &Window->PropListHead)
{
ListEntry = Window->PropListHead.Flink;
while (ListEntry != &Window->PropListHead)
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
if (Property->Atom == Atom)
{
return(Property);
}
{
return(Property);
}
ListEntry = ListEntry->Flink;
}
return(NULL);
}
return(NULL);
}
NTSTATUS STDCALL
NtUserBuildPropList(HWND hWnd,
LPVOID Buffer,
DWORD BufferSize,
DWORD *Count)
LPVOID Buffer,
DWORD BufferSize,
DWORD *Count)
{
PWINDOW_OBJECT Window;
PPROPERTY Property;
PLIST_ENTRY ListEntry;
PROPLISTITEM listitem, *li;
NTSTATUS Status;
DWORD Cnt = 0;
DECLARE_RETURN(NTSTATUS);
DPRINT("Enter NtUserBuildPropList\n");
UserEnterShared();
PWINDOW_OBJECT Window;
PPROPERTY Property;
PLIST_ENTRY ListEntry;
PROPLISTITEM listitem, *li;
NTSTATUS Status;
DWORD Cnt = 0;
DECLARE_RETURN(NTSTATUS);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( STATUS_INVALID_HANDLE);
}
DPRINT("Enter NtUserBuildPropList\n");
UserEnterShared();
if(Buffer)
{
if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
{
RETURN( STATUS_INVALID_PARAMETER);
}
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( STATUS_INVALID_HANDLE);
}
/* copy list */
li = (PROPLISTITEM *)Buffer;
ListEntry = Window->PropListHead.Flink;
while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &Window->PropListHead))
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
listitem.Atom = Property->Atom;
listitem.Data = Property->Data;
Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
if(!NT_SUCCESS(Status))
if(Buffer)
{
if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0))
{
RETURN( Status);
RETURN( STATUS_INVALID_PARAMETER);
}
BufferSize -= sizeof(PROPLISTITEM);
Cnt++;
li++;
ListEntry = ListEntry->Flink;
}
/* copy list */
li = (PROPLISTITEM *)Buffer;
ListEntry = Window->PropListHead.Flink;
while((BufferSize >= sizeof(PROPLISTITEM)) && (ListEntry != &Window->PropListHead))
{
Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
listitem.Atom = Property->Atom;
listitem.Data = Property->Data;
}
else
{
Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
}
Status = MmCopyToCaller(li, &listitem, sizeof(PROPLISTITEM));
if(!NT_SUCCESS(Status))
{
RETURN( Status);
}
if(Count)
{
Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
if(!NT_SUCCESS(Status))
{
RETURN( Status);
}
}
BufferSize -= sizeof(PROPLISTITEM);
Cnt++;
li++;
ListEntry = ListEntry->Flink;
}
}
else
{
Cnt = Window->PropListItems * sizeof(PROPLISTITEM);
}
if(Count)
{
Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD));
if(!NT_SUCCESS(Status))
{
RETURN( Status);
}
}
RETURN( STATUS_SUCCESS);
RETURN( STATUS_SUCCESS);
CLEANUP:
DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
HANDLE STDCALL
NtUserRemoveProp(HWND hWnd, ATOM Atom)
{
PWINDOW_OBJECT Window;
PPROPERTY Prop;
HANDLE Data;
DECLARE_RETURN(HANDLE);
DPRINT("Enter NtUserRemoveProp\n");
UserEnterExclusive();
PWINDOW_OBJECT Window;
PPROPERTY Prop;
HANDLE Data;
DECLARE_RETURN(HANDLE);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( NULL);
}
DPRINT("Enter NtUserRemoveProp\n");
UserEnterExclusive();
Prop = IntGetProp(Window, Atom);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( NULL);
}
if (Prop == NULL)
{
Prop = IntGetProp(Window, Atom);
if (Prop == NULL)
{
RETURN(NULL);
}
Data = Prop->Data;
RemoveEntryList(&Prop->PropListEntry);
ExFreePool(Prop);
Window->PropListItems--;
}
Data = Prop->Data;
RemoveEntryList(&Prop->PropListEntry);
ExFreePool(Prop);
Window->PropListItems--;
RETURN(Data);
RETURN(Data);
CLEANUP:
DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
HANDLE STDCALL
NtUserGetProp(HWND hWnd, ATOM Atom)
{
PWINDOW_OBJECT Window;
PPROPERTY Prop;
HANDLE Data = NULL;
DECLARE_RETURN(HANDLE);
DPRINT("Enter NtUserGetProp\n");
UserEnterShared();
PWINDOW_OBJECT Window;
PPROPERTY Prop;
HANDLE Data = NULL;
DECLARE_RETURN(HANDLE);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( FALSE);
}
DPRINT("Enter NtUserGetProp\n");
UserEnterShared();
Prop = IntGetProp(Window, Atom);
if (Prop != NULL)
{
Data = Prop->Data;
}
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( FALSE);
}
Prop = IntGetProp(Window, Atom);
if (Prop != NULL)
{
Data = Prop->Data;
}
RETURN(Data);
RETURN(Data);
CLEANUP:
DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
static
BOOL FASTCALL
IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
{
PPROPERTY Prop;
PPROPERTY Prop;
Prop = IntGetProp(Wnd, Atom);
Prop = IntGetProp(Wnd, Atom);
if (Prop == NULL)
{
Prop = ExAllocatePoolWithTag(PagedPool, sizeof(PROPERTY), TAG_WNDPROP);
if (Prop == NULL)
{
return FALSE;
}
Prop->Atom = Atom;
InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
Wnd->PropListItems++;
}
if (Prop == NULL)
{
Prop = ExAllocatePoolWithTag(PagedPool, sizeof(PROPERTY), TAG_WNDPROP);
if (Prop == NULL)
{
return FALSE;
}
Prop->Atom = Atom;
InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
Wnd->PropListItems++;
}
Prop->Data = Data;
return TRUE;
Prop->Data = Data;
return TRUE;
}
BOOL STDCALL
NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
{
PWINDOW_OBJECT Window;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserSetProp\n");
UserEnterExclusive();
PWINDOW_OBJECT Window;
DECLARE_RETURN(BOOL);
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( FALSE);
}
DPRINT("Enter NtUserSetProp\n");
UserEnterExclusive();
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN( FALSE);
}
RETURN( IntSetProp(Window, Atom, Data));
RETURN( IntSetProp(Window, Atom, Data));
CLEANUP:
DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
/* EOF */

File diff suppressed because it is too large Load diff

View file

@ -39,82 +39,82 @@ NTSTATUS INTERNAL_CALL
IntUserCreateSharedSectionPool(IN ULONG MaximumPoolSize,
IN PSHARED_SECTION_POOL *SharedSectionPool)
{
PSHARED_SECTION_POOL Pool;
ULONG PoolStructSize;
PSHARED_SECTION_POOL Pool;
ULONG PoolStructSize;
ASSERT(SharedSectionPool);
ASSERT(SharedSectionPool);
PoolStructSize = ROUND_UP(sizeof(SHARED_SECTION_POOL), PAGE_SIZE);
Pool = ExAllocatePoolWithTag(NonPagedPool,
PoolStructSize,
TAG_SSECTPOOL);
if(Pool != NULL)
{
RtlZeroMemory(Pool, PoolStructSize);
PoolStructSize = ROUND_UP(sizeof(SHARED_SECTION_POOL), PAGE_SIZE);
Pool = ExAllocatePoolWithTag(NonPagedPool,
PoolStructSize,
TAG_SSECTPOOL);
if(Pool != NULL)
{
RtlZeroMemory(Pool, PoolStructSize);
/* initialize the session heap */
ExInitializeFastMutex(&Pool->Lock);
Pool->PoolSize = ROUND_UP(MaximumPoolSize, PAGE_SIZE);
Pool->PoolFree = Pool->PoolSize;
Pool->SharedSectionCount = 0;
Pool->SectionsArray.Next = NULL;
Pool->SectionsArray.nEntries = ((PoolStructSize - sizeof(SHARED_SECTION_POOL)) /
sizeof(SHARED_SECTION)) - 1;
/* initialize the session heap */
ExInitializeFastMutex(&Pool->Lock);
Pool->PoolSize = ROUND_UP(MaximumPoolSize, PAGE_SIZE);
Pool->PoolFree = Pool->PoolSize;
Pool->SharedSectionCount = 0;
Pool->SectionsArray.Next = NULL;
Pool->SectionsArray.nEntries = ((PoolStructSize - sizeof(SHARED_SECTION_POOL)) /
sizeof(SHARED_SECTION)) - 1;
ASSERT(Pool->SectionsArray.nEntries > 0);
ASSERT(Pool->SectionsArray.nEntries > 0);
*SharedSectionPool = Pool;
*SharedSectionPool = Pool;
return STATUS_SUCCESS;
}
return STATUS_SUCCESS;
}
return STATUS_INSUFFICIENT_RESOURCES;
return STATUS_INSUFFICIENT_RESOURCES;
}
VOID INTERNAL_CALL
IntUserFreeSharedSectionPool(IN PSHARED_SECTION_POOL SharedSectionPool)
{
PSHARED_SECTIONS_ARRAY Array, OldArray;
PSHARED_SECTION SharedSection, LastSharedSection;
PSHARED_SECTIONS_ARRAY Array, OldArray;
PSHARED_SECTION SharedSection, LastSharedSection;
ASSERT(SharedSectionPool);
ASSERT(SharedSectionPool);
Array = &SharedSectionPool->SectionsArray;
Array = &SharedSectionPool->SectionsArray;
ExAcquireFastMutex(&SharedSectionPool->Lock);
while(SharedSectionPool->SharedSectionCount > 0 && Array != NULL)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection && SharedSectionPool->SharedSectionCount > 0;
SharedSection++)
{
if(SharedSection->SectionObject != NULL)
ExAcquireFastMutex(&SharedSectionPool->Lock);
while(SharedSectionPool->SharedSectionCount > 0 && Array != NULL)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection && SharedSectionPool->SharedSectionCount > 0;
SharedSection++)
{
ASSERT(SharedSection->SystemMappedBase);
if(SharedSection->SectionObject != NULL)
{
ASSERT(SharedSection->SystemMappedBase);
/* FIXME - use MmUnmapViewInSessionSpace() once implemented! */
MmUnmapViewInSystemSpace(SharedSection->SystemMappedBase);
/* dereference the keep-alive reference so the section get's deleted */
ObDereferenceObject(SharedSection->SectionObject);
/* FIXME - use MmUnmapViewInSessionSpace() once implemented! */
MmUnmapViewInSystemSpace(SharedSection->SystemMappedBase);
/* dereference the keep-alive reference so the section get's deleted */
ObDereferenceObject(SharedSection->SectionObject);
SharedSectionPool->SharedSectionCount--;
SharedSectionPool->SharedSectionCount--;
}
}
}
OldArray = Array;
Array = Array->Next;
OldArray = Array;
Array = Array->Next;
/* all shared sections in this array were freed, link the following array to
the main session heap and free this array */
SharedSectionPool->SectionsArray.Next = Array;
ExFreePool(OldArray);
}
/* all shared sections in this array were freed, link the following array to
the main session heap and free this array */
SharedSectionPool->SectionsArray.Next = Array;
ExFreePool(OldArray);
}
ASSERT(SharedSectionPool->SectionsArray.Next == NULL);
ASSERT(SharedSectionPool->SharedSectionCount == 0);
ASSERT(SharedSectionPool->SectionsArray.Next == NULL);
ASSERT(SharedSectionPool->SharedSectionCount == 0);
ExReleaseFastMutex(&SharedSectionPool->Lock);
ExReleaseFastMutex(&SharedSectionPool->Lock);
}
@ -123,120 +123,120 @@ IntUserCreateSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
IN OUT PVOID *SystemMappedBase,
IN OUT ULONG *SharedSectionSize)
{
PSHARED_SECTIONS_ARRAY Array, LastArray;
PSHARED_SECTION FreeSharedSection, SharedSection, LastSharedSection;
LARGE_INTEGER SectionSize;
ULONG Size;
NTSTATUS Status;
PSHARED_SECTIONS_ARRAY Array, LastArray;
PSHARED_SECTION FreeSharedSection, SharedSection, LastSharedSection;
LARGE_INTEGER SectionSize;
ULONG Size;
NTSTATUS Status;
ASSERT(SharedSectionPool && SharedSectionSize && (*SharedSectionSize) > 0 && SystemMappedBase);
ASSERT(SharedSectionPool && SharedSectionSize && (*SharedSectionSize) > 0 && SystemMappedBase);
FreeSharedSection = NULL;
FreeSharedSection = NULL;
Size = ROUND_UP(*SharedSectionSize, PAGE_SIZE);
Size = ROUND_UP(*SharedSectionSize, PAGE_SIZE);
ExAcquireFastMutex(&SharedSectionPool->Lock);
ExAcquireFastMutex(&SharedSectionPool->Lock);
if(Size > SharedSectionPool->PoolFree)
{
ExReleaseFastMutex(&SharedSectionPool->Lock);
DPRINT1("Shared Section Pool limit (0x%x KB) reached, attempted to allocate a 0x%x KB shared section!\n",
SharedSectionPool->PoolSize / 1024, (*SharedSectionSize) / 1024);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* walk the array to find a free entry */
for(Array = &SharedSectionPool->SectionsArray, LastArray = Array;
Array != NULL && FreeSharedSection == NULL;
Array = Array->Next)
{
LastArray = Array;
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
if(SharedSection->SectionObject == NULL)
{
FreeSharedSection = SharedSection;
break;
}
}
if(Array->Next != NULL)
{
LastArray = Array;
}
}
ASSERT(LastArray);
if(FreeSharedSection == NULL)
{
ULONG nNewEntries;
PSHARED_SECTIONS_ARRAY NewArray;
ASSERT(LastArray->Next == NULL);
/* couldn't find a free entry in the array, extend the array */
nNewEntries = ((PAGE_SIZE - sizeof(SHARED_SECTIONS_ARRAY)) / sizeof(SHARED_SECTION)) + 1;
NewArray = ExAllocatePoolWithTag(NonPagedPool,
sizeof(SHARED_SECTIONS_ARRAY) + ((nNewEntries - 1) *
sizeof(SHARED_SECTION)),
TAG_SSECTPOOL);
if(NewArray == NULL)
{
if(Size > SharedSectionPool->PoolFree)
{
ExReleaseFastMutex(&SharedSectionPool->Lock);
DPRINT1("Failed to allocate new array for shared sections!\n");
DPRINT1("Shared Section Pool limit (0x%x KB) reached, attempted to allocate a 0x%x KB shared section!\n",
SharedSectionPool->PoolSize / 1024, (*SharedSectionSize) / 1024);
return STATUS_INSUFFICIENT_RESOURCES;
}
}
NewArray->nEntries = nNewEntries;
NewArray->Next = NULL;
LastArray->Next = NewArray;
/* walk the array to find a free entry */
for(Array = &SharedSectionPool->SectionsArray, LastArray = Array;
Array != NULL && FreeSharedSection == NULL;
Array = Array->Next)
{
LastArray = Array;
Array = NewArray;
FreeSharedSection = &Array->SharedSection[0];
}
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
if(SharedSection->SectionObject == NULL)
{
FreeSharedSection = SharedSection;
break;
}
}
ASSERT(FreeSharedSection);
if(Array->Next != NULL)
{
LastArray = Array;
}
}
/* now allocate a real section */
ASSERT(LastArray);
SectionSize.QuadPart = Size;
Status = MmCreateSection(&FreeSharedSection->SectionObject,
SECTION_ALL_ACCESS,
NULL,
&SectionSize,
PAGE_EXECUTE_READWRITE,
SEC_COMMIT,
NULL,
NULL);
if(NT_SUCCESS(Status))
{
Status = MmMapViewInSystemSpace(FreeSharedSection->SectionObject,
&FreeSharedSection->SystemMappedBase,
&FreeSharedSection->ViewSize);
if(NT_SUCCESS(Status))
{
(*SharedSectionSize) -= Size;
SharedSectionPool->SharedSectionCount++;
if(FreeSharedSection == NULL)
{
ULONG nNewEntries;
PSHARED_SECTIONS_ARRAY NewArray;
*SystemMappedBase = FreeSharedSection->SystemMappedBase;
*SharedSectionSize = FreeSharedSection->ViewSize;
}
else
{
ObDereferenceObject(FreeSharedSection->SectionObject);
FreeSharedSection->SectionObject = NULL;
DPRINT1("Failed to map the shared section into system space! Status 0x%x\n", Status);
}
}
ASSERT(LastArray->Next == NULL);
ExReleaseFastMutex(&SharedSectionPool->Lock);
/* couldn't find a free entry in the array, extend the array */
return Status;
nNewEntries = ((PAGE_SIZE - sizeof(SHARED_SECTIONS_ARRAY)) / sizeof(SHARED_SECTION)) + 1;
NewArray = ExAllocatePoolWithTag(NonPagedPool,
sizeof(SHARED_SECTIONS_ARRAY) + ((nNewEntries - 1) *
sizeof(SHARED_SECTION)),
TAG_SSECTPOOL);
if(NewArray == NULL)
{
ExReleaseFastMutex(&SharedSectionPool->Lock);
DPRINT1("Failed to allocate new array for shared sections!\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
NewArray->nEntries = nNewEntries;
NewArray->Next = NULL;
LastArray->Next = NewArray;
Array = NewArray;
FreeSharedSection = &Array->SharedSection[0];
}
ASSERT(FreeSharedSection);
/* now allocate a real section */
SectionSize.QuadPart = Size;
Status = MmCreateSection(&FreeSharedSection->SectionObject,
SECTION_ALL_ACCESS,
NULL,
&SectionSize,
PAGE_EXECUTE_READWRITE,
SEC_COMMIT,
NULL,
NULL);
if(NT_SUCCESS(Status))
{
Status = MmMapViewInSystemSpace(FreeSharedSection->SectionObject,
&FreeSharedSection->SystemMappedBase,
&FreeSharedSection->ViewSize);
if(NT_SUCCESS(Status))
{
(*SharedSectionSize) -= Size;
SharedSectionPool->SharedSectionCount++;
*SystemMappedBase = FreeSharedSection->SystemMappedBase;
*SharedSectionSize = FreeSharedSection->ViewSize;
}
else
{
ObDereferenceObject(FreeSharedSection->SectionObject);
FreeSharedSection->SectionObject = NULL;
DPRINT1("Failed to map the shared section into system space! Status 0x%x\n", Status);
}
}
ExReleaseFastMutex(&SharedSectionPool->Lock);
return Status;
}
@ -244,52 +244,52 @@ NTSTATUS INTERNAL_CALL
InUserDeleteSharedSection(PSHARED_SECTION_POOL SharedSectionPool,
PVOID SystemMappedBase)
{
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
ASSERT(SharedSectionPool && SystemMappedBase);
ASSERT(SharedSectionPool && SystemMappedBase);
SectionObject = NULL;
SectionObject = NULL;
ExAcquireFastMutex(&SharedSectionPool->Lock);
ExAcquireFastMutex(&SharedSectionPool->Lock);
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
if(SharedSection->SystemMappedBase == SystemMappedBase)
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
SectionObject = SharedSection->SectionObject;
SharedSection->SectionObject = NULL;
SharedSection->SystemMappedBase = NULL;
if(SharedSection->SystemMappedBase == SystemMappedBase)
{
SectionObject = SharedSection->SectionObject;
SharedSection->SectionObject = NULL;
SharedSection->SystemMappedBase = NULL;
ASSERT(SharedSectionPool->SharedSectionCount > 0);
SharedSectionPool->SharedSectionCount--;
break;
ASSERT(SharedSectionPool->SharedSectionCount > 0);
SharedSectionPool->SharedSectionCount--;
break;
}
}
}
}
}
ExReleaseFastMutex(&SharedSectionPool->Lock);
ExReleaseFastMutex(&SharedSectionPool->Lock);
if(SectionObject != NULL)
{
Status = MmUnmapViewInSystemSpace(SystemMappedBase);
ObDereferenceObject(SectionObject);
}
else
{
DPRINT1("Couldn't find and delete a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
if(SectionObject != NULL)
{
Status = MmUnmapViewInSystemSpace(SystemMappedBase);
ObDereferenceObject(SectionObject);
}
else
{
DPRINT1("Couldn't find and delete a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
return Status;
return Status;
}
@ -302,67 +302,67 @@ IntUserMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
IN PULONG ViewSize OPTIONAL,
IN BOOLEAN ReadOnly)
{
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
SectionObject = NULL;
SharedSection = NULL;
SectionObject = NULL;
SharedSection = NULL;
ExAcquireFastMutex(&SharedSectionPool->Lock);
ExAcquireFastMutex(&SharedSectionPool->Lock);
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
if(SharedSection->SystemMappedBase == SystemMappedBase)
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
SectionObject = SharedSection->SectionObject;
break;
if(SharedSection->SystemMappedBase == SystemMappedBase)
{
SectionObject = SharedSection->SectionObject;
break;
}
}
}
}
}
if(SectionObject != NULL)
{
ULONG RealViewSize = (ViewSize ? min(*ViewSize, SharedSection->ViewSize) : SharedSection->ViewSize);
if(SectionObject != NULL)
{
ULONG RealViewSize = (ViewSize ? min(*ViewSize, SharedSection->ViewSize) : SharedSection->ViewSize);
ObReferenceObjectByPointer(SectionObject,
(ReadOnly ? SECTION_MAP_READ : SECTION_MAP_READ | SECTION_MAP_WRITE),
NULL,
KernelMode);
ObReferenceObjectByPointer(SectionObject,
(ReadOnly ? SECTION_MAP_READ : SECTION_MAP_READ | SECTION_MAP_WRITE),
NULL,
KernelMode);
Status = MmMapViewOfSection(SectionObject,
Process,
UserMappedBase,
0,
0,
SectionOffset,
&RealViewSize,
ViewUnmap, /* not sure if we should inherit it... */
MEM_COMMIT,
(ReadOnly ? PAGE_READONLY : PAGE_READWRITE));
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to map shared section (readonly=%d) into user memory! Status: 0x%x\n", ReadOnly, Status);
}
}
else
{
DPRINT1("Couldn't find and map a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
Status = MmMapViewOfSection(SectionObject,
Process,
UserMappedBase,
0,
0,
SectionOffset,
&RealViewSize,
ViewUnmap, /* not sure if we should inherit it... */
MEM_COMMIT,
(ReadOnly ? PAGE_READONLY : PAGE_READWRITE));
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to map shared section (readonly=%d) into user memory! Status: 0x%x\n", ReadOnly, Status);
}
}
else
{
DPRINT1("Couldn't find and map a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
ExReleaseFastMutex(&SharedSectionPool->Lock);
ExReleaseFastMutex(&SharedSectionPool->Lock);
return Status;
return Status;
}
@ -372,50 +372,50 @@ IntUserUnMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
IN PVOID SystemMappedBase,
IN PVOID UserMappedBase)
{
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
PSHARED_SECTIONS_ARRAY Array;
PSECTION_OBJECT SectionObject;
PSHARED_SECTION SharedSection, LastSharedSection;
NTSTATUS Status;
ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
SectionObject = NULL;
SectionObject = NULL;
ExAcquireFastMutex(&SharedSectionPool->Lock);
ExAcquireFastMutex(&SharedSectionPool->Lock);
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
if(SharedSection->SystemMappedBase == SystemMappedBase)
for(Array = &SharedSectionPool->SectionsArray;
Array != NULL && SectionObject == NULL;
Array = Array->Next)
{
for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
SharedSection != LastSharedSection;
SharedSection++)
{
SectionObject = SharedSection->SectionObject;
break;
if(SharedSection->SystemMappedBase == SystemMappedBase)
{
SectionObject = SharedSection->SectionObject;
break;
}
}
}
}
}
ExReleaseFastMutex(&SharedSectionPool->Lock);
ExReleaseFastMutex(&SharedSectionPool->Lock);
if(SectionObject != NULL)
{
Status = MmUnmapViewOfSection(Process,
UserMappedBase);
ObDereferenceObject(SectionObject);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to unmap shared section UserMappedBase=0x%x! Status: 0x%x\n", UserMappedBase, Status);
}
}
else
{
DPRINT1("Couldn't find and unmap a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
if(SectionObject != NULL)
{
Status = MmUnmapViewOfSection(Process,
UserMappedBase);
ObDereferenceObject(SectionObject);
if(!NT_SUCCESS(Status))
{
DPRINT1("Failed to unmap shared section UserMappedBase=0x%x! Status: 0x%x\n", UserMappedBase, Status);
}
}
else
{
DPRINT1("Couldn't find and unmap a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
Status = STATUS_UNSUCCESSFUL;
}
return Status;
return Status;
}

File diff suppressed because it is too large Load diff

View file

@ -58,110 +58,110 @@ static ULONG HintIndex = 0;
UINT_PTR FASTCALL
IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer)
{
PWINDOW_OBJECT WindowObject;
UINT_PTR Ret = 0;
PWINDOW_OBJECT WindowObject;
UINT_PTR Ret = 0;
DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n",
Wnd, IDEvent, Elapse, TimerFunc, SystemTimer ? "TRUE" : "FALSE");
DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n",
Wnd, IDEvent, Elapse, TimerFunc, SystemTimer ? "TRUE" : "FALSE");
if ((Wnd == NULL) && ! SystemTimer)
{
if ((Wnd == NULL) && ! SystemTimer)
{
DPRINT("Window-less timer\n");
/* find a free, window-less timer id */
IntLockWindowlessTimerBitmap();
IDEvent = RtlFindClearBitsAndSet(&WindowLessTimersBitMap, 1, HintIndex);
if (IDEvent == (UINT_PTR) -1)
{
IntUnlockWindowlessTimerBitmap();
DPRINT1("Unable to find a free window-less timer id\n");
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
{
IntUnlockWindowlessTimerBitmap();
DPRINT1("Unable to find a free window-less timer id\n");
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
HintIndex = ++IDEvent;
IntUnlockWindowlessTimerBitmap();
Ret = IDEvent;
}
else
{
}
else
{
WindowObject = IntGetWindowObject(Wnd);
if (! WindowObject)
{
DPRINT1("Invalid window handle\n");
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return 0;
}
{
DPRINT1("Invalid window handle\n");
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return 0;
}
if (WindowObject->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
{
IntReleaseWindowObject(WindowObject);
DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0;
}
{
IntReleaseWindowObject(WindowObject);
DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0;
}
IntReleaseWindowObject(WindowObject);
Ret = IDEvent;
}
}
#if 1
#if 1
/* Win NT/2k/XP */
if (Elapse > 0x7fffffff)
{
/* Win NT/2k/XP */
if (Elapse > 0x7fffffff)
{
DPRINT("Adjusting uElapse\n");
Elapse = 1;
}
}
#else
#else
/* Win Server 2003 */
if (Elapse > 0x7fffffff)
{
/* Win Server 2003 */
if (Elapse > 0x7fffffff)
{
DPRINT("Adjusting uElapse\n");
Elapse = 0x7fffffff;
}
}
#endif
#endif
/* Win 2k/XP */
if (Elapse < 10)
{
/* Win 2k/XP */
if (Elapse < 10)
{
DPRINT("Adjusting uElapse\n");
Elapse = 10;
}
}
if (! MsqSetTimer(PsGetWin32Thread()->MessageQueue, Wnd,
IDEvent, Elapse, TimerFunc,
SystemTimer ? WM_SYSTIMER : WM_TIMER))
{
if (! MsqSetTimer(PsGetWin32Thread()->MessageQueue, Wnd,
IDEvent, Elapse, TimerFunc,
SystemTimer ? WM_SYSTIMER : WM_TIMER))
{
DPRINT1("Failed to set timer in message queue\n");
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
}
return Ret;
return Ret;
}
BOOL FASTCALL
IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer)
{
DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n",
Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE");
DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n",
Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE");
if (! MsqKillTimer(PsGetWin32Thread()->MessageQueue, Wnd,
IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))
{
if (! MsqKillTimer(PsGetWin32Thread()->MessageQueue, Wnd,
IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER))
{
DPRINT1("Unable to locate timer in message queue\n");
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
}
/* window-less timer? */
if ((Wnd == NULL) && ! SystemTimer)
{
/* window-less timer? */
if ((Wnd == NULL) && ! SystemTimer)
{
/* Release the id */
IntLockWindowlessTimerBitmap();
@ -169,28 +169,28 @@ IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer)
RtlClearBits(&WindowLessTimersBitMap, IDEvent - 1, 1);
IntUnlockWindowlessTimerBitmap();
}
}
return TRUE;
return TRUE;
}
NTSTATUS FASTCALL
InitTimerImpl(VOID)
{
ULONG BitmapBytes;
ULONG BitmapBytes;
ExInitializeFastMutex(&Mutex);
ExInitializeFastMutex(&Mutex);
BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8;
WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP);
RtlInitializeBitMap(&WindowLessTimersBitMap,
WindowLessTimersBitMapBuffer,
BitmapBytes * 8);
BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8;
WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP);
RtlInitializeBitMap(&WindowLessTimersBitMap,
WindowLessTimersBitMapBuffer,
BitmapBytes * 8);
/* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */
RtlClearAllBits(&WindowLessTimersBitMap);
/* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */
RtlClearAllBits(&WindowLessTimersBitMap);
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
@ -198,19 +198,19 @@ UINT_PTR
STDCALL
NtUserSetTimer
(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
)
{
DECLARE_RETURN(UINT_PTR);
DPRINT("Enter NtUserSetTimer\n");
UserEnterExclusive();
RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, FALSE));
CLEANUP:
DPRINT("Leave NtUserSetTimer, ret=%i\n", _ret_);
UserLeave();
@ -222,17 +222,17 @@ BOOL
STDCALL
NtUserKillTimer
(
HWND hWnd,
UINT_PTR uIDEvent
HWND hWnd,
UINT_PTR uIDEvent
)
{
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserKillTimer\n");
UserEnterExclusive();
RETURN(IntKillTimer(hWnd, uIDEvent, FALSE));
CLEANUP:
DPRINT("Leave NtUserKillTimer, ret=%i\n", _ret_);
UserLeave();
@ -243,19 +243,19 @@ CLEANUP:
UINT_PTR
STDCALL
NtUserSetSystemTimer(
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
)
{
DECLARE_RETURN(UINT_PTR);
DPRINT("Enter NtUserSetSystemTimer\n");
UserEnterExclusive();
RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE));
CLEANUP:
DPRINT("Leave NtUserSetSystemTimer, ret=%i\n", _ret_);
UserLeave();
@ -266,17 +266,17 @@ CLEANUP:
BOOL
STDCALL
NtUserKillSystemTimer(
HWND hWnd,
UINT_PTR uIDEvent
HWND hWnd,
UINT_PTR uIDEvent
)
{
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserKillSystemTimer\n");
UserEnterExclusive();
RETURN(IntKillTimer(hWnd, uIDEvent, TRUE));
CLEANUP:
DPRINT("Leave NtUserKillSystemTimer, ret=%i\n", _ret_);
UserLeave();

View file

@ -43,7 +43,7 @@ IntAddAtom(LPWSTR AtomName)
}
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
Status = RtlAddAtomToAtomTable(WinStaObject->AtomTable,
AtomName, &Atom);
AtomName, &Atom);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
@ -66,7 +66,7 @@ IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
}
WinStaObject = PsGetWin32Thread()->Desktop->WindowStation;
Status = RtlQueryAtomInAtomTable(WinStaObject->AtomTable,
nAtom, NULL, NULL, lpBuffer, &Size);
nAtom, NULL, NULL, lpBuffer, &Size);
if (Size < nSize)
*(lpBuffer + Size) = 0;
if (!NT_SUCCESS(Status))

View file

@ -50,12 +50,12 @@ VIS_ComputeVisibleRegion(
{
if(!(ClipRgn = VIS_ComputeVisibleRegion(Window, FALSE, ClipChildren, ClipSiblings)))
{
return NtGdiCreateRectRgn(0, 0, 0, 0);
return NtGdiCreateRectRgn(0, 0, 0, 0);
}
if(!(VisRgn = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect)))
{
NtGdiDeleteObject(VisRgn);
return NtGdiCreateRectRgn(0, 0, 0, 0);
NtGdiDeleteObject(VisRgn);
return NtGdiCreateRectRgn(0, 0, 0, 0);
}
LeftOffset = Window->ClientRect.left - Window->WindowRect.left;
TopOffset = Window->ClientRect.top - Window->WindowRect.top;
@ -90,7 +90,7 @@ VIS_ComputeVisibleRegion(
NtGdiDeleteObject(ClipRgn);
if ((PreviousWindow->Style & WS_CLIPSIBLINGS) ||
(PreviousWindow == Window && ClipSiblings))
(PreviousWindow == Window && ClipSiblings))
{
CurrentSibling = CurrentWindow->FirstChild;
while (CurrentSibling != NULL && CurrentSibling != PreviousWindow)
@ -101,9 +101,9 @@ VIS_ComputeVisibleRegion(
/* Combine it with the window region if available */
if(CurrentSibling->WindowRegion && !(CurrentSibling->Style & WS_MINIMIZE))
{
NtGdiOffsetRgn(ClipRgn, -CurrentSibling->WindowRect.left, -CurrentSibling->WindowRect.top);
NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentSibling->WindowRegion, RGN_AND);
NtGdiOffsetRgn(ClipRgn, CurrentSibling->WindowRect.left, CurrentSibling->WindowRect.top);
NtGdiOffsetRgn(ClipRgn, -CurrentSibling->WindowRect.left, -CurrentSibling->WindowRect.top);
NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentSibling->WindowRegion, RGN_AND);
NtGdiOffsetRgn(ClipRgn, CurrentSibling->WindowRect.left, CurrentSibling->WindowRect.top);
}
NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
NtGdiDeleteObject(ClipRgn);
@ -127,9 +127,9 @@ VIS_ComputeVisibleRegion(
/* Combine it with the window region if available */
if(CurrentWindow->WindowRegion && !(CurrentWindow->Style & WS_MINIMIZE))
{
NtGdiOffsetRgn(ClipRgn, -CurrentWindow->WindowRect.left, -CurrentWindow->WindowRect.top);
NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentWindow->WindowRegion, RGN_AND);
NtGdiOffsetRgn(ClipRgn, CurrentWindow->WindowRect.left, CurrentWindow->WindowRect.top);
NtGdiOffsetRgn(ClipRgn, -CurrentWindow->WindowRect.left, -CurrentWindow->WindowRect.top);
NtGdiCombineRgn(ClipRgn, ClipRgn, CurrentWindow->WindowRegion, RGN_AND);
NtGdiOffsetRgn(ClipRgn, CurrentWindow->WindowRect.left, CurrentWindow->WindowRect.top);
}
NtGdiCombineRgn(VisRgn, VisRgn, ClipRgn, RGN_DIFF);
NtGdiDeleteObject(ClipRgn);
@ -140,9 +140,9 @@ VIS_ComputeVisibleRegion(
if(Window->WindowRegion && !(Window->Style & WS_MINIMIZE))
{
NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
return VisRgn;
NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
NtGdiCombineRgn(VisRgn, VisRgn, Window->WindowRegion, RGN_AND);
return VisRgn;
}
NtGdiOffsetRgn(VisRgn, -LeftOffset, -TopOffset);
@ -169,11 +169,11 @@ co_VIS_WindowLayoutChanged(
NtGdiOffsetRgn(Temp,
Window->WindowRect.left - Parent->ClientRect.left,
Window->WindowRect.top - Parent->ClientRect.top);
UserRefObjectCo(Parent);
co_UserRedrawWindow(Parent, NULL, Temp,
RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
RDW_ALLCHILDREN);
RDW_FRAME | RDW_ERASE | RDW_INVALIDATE |
RDW_ALLCHILDREN);
UserDerefObjectCo(Parent);
}
NtGdiDeleteObject(Temp);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -48,14 +48,14 @@ PWINSTATION_OBJECT InputWindowStation = NULL;
/* INITALIZATION FUNCTIONS ****************************************************/
static GENERIC_MAPPING IntWindowStationMapping =
{
STANDARD_RIGHTS_READ | WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_READATTRIBUTES | WINSTA_READSCREEN,
STANDARD_RIGHTS_WRITE | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES,
STANDARD_RIGHTS_EXECUTE | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS,
STANDARD_RIGHTS_REQUIRED | WINSTA_ACCESSCLIPBOARD | WINSTA_ACCESSGLOBALATOMS | WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES | WINSTA_READSCREEN | WINSTA_WRITEATTRIBUTES
};
{
STANDARD_RIGHTS_READ | WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_READATTRIBUTES | WINSTA_READSCREEN,
STANDARD_RIGHTS_WRITE | WINSTA_ACCESSCLIPBOARD | WINSTA_CREATEDESKTOP | WINSTA_WRITEATTRIBUTES,
STANDARD_RIGHTS_EXECUTE | WINSTA_ACCESSGLOBALATOMS | WINSTA_EXITWINDOWS,
STANDARD_RIGHTS_REQUIRED | WINSTA_ACCESSCLIPBOARD | WINSTA_ACCESSGLOBALATOMS | WINSTA_CREATEDESKTOP |
WINSTA_ENUMDESKTOPS | WINSTA_ENUMERATE | WINSTA_EXITWINDOWS |
WINSTA_READATTRIBUTES | WINSTA_READSCREEN | WINSTA_WRITEATTRIBUTES
};
NTSTATUS FASTCALL
InitWindowStationImpl(VOID)
@ -71,20 +71,20 @@ InitWindowStationImpl(VOID)
RtlInitUnicodeString(&UnicodeString, WINSTA_ROOT_NAME);
InitializeObjectAttributes(&ObjectAttributes, &UnicodeString,
0, NULL, NULL);
0, NULL, NULL);
Status = ZwCreateDirectoryObject(&WindowStationsDirectory, 0,
&ObjectAttributes);
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("Could not create \\Windows\\WindowStations directory "
"(Status 0x%X)\n", Status);
"(Status 0x%X)\n", Status);
return Status;
}
/* Set Winsta Object Attributes */
ExWindowStationObjectType->TypeInfo.DefaultNonPagedPoolCharge = sizeof(WINSTATION_OBJECT);
ExWindowStationObjectType->TypeInfo.GenericMapping = IntWindowStationMapping;
return STATUS_SUCCESS;
}
@ -104,11 +104,11 @@ IntWinStaObjectOpen(OB_OPEN_REASON Reason,
ULONG HandleCount,
ACCESS_MASK GrantedAccess)
{
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
NTSTATUS Status;
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)ObjectBody;
NTSTATUS Status;
if (Reason == ObCreateHandle)
{
if (Reason == ObCreateHandle)
{
DPRINT("Creating window station (0x%X)\n", WinSta);
KeInitializeSpinLock(&WinSta->Lock);
@ -122,66 +122,66 @@ IntWinStaObjectOpen(OB_OPEN_REASON Reason,
WinSta->SystemMenuTemplate = (HANDLE)0;
DPRINT("Window station successfully created.\n");
}
}
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
VOID STDCALL
IntWinStaObjectDelete(PVOID DeletedObject)
{
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeletedObject;
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeletedObject;
DPRINT("Deleting window station (0x%X)\n", WinSta);
DPRINT("Deleting window station (0x%X)\n", WinSta);
RtlDestroyAtomTable(WinSta->AtomTable);
RtlDestroyAtomTable(WinSta->AtomTable);
RtlFreeUnicodeString(&WinSta->Name);
RtlFreeUnicodeString(&WinSta->Name);
}
PVOID STDCALL
IntWinStaObjectFind(PVOID Object,
PWSTR Name,
ULONG Attributes)
PWSTR Name,
ULONG Attributes)
{
PLIST_ENTRY Current;
PDESKTOP_OBJECT CurrentObject;
PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)Object;
PLIST_ENTRY Current;
PDESKTOP_OBJECT CurrentObject;
PWINSTATION_OBJECT WinStaObject = (PWINSTATION_OBJECT)Object;
DPRINT("WinStaObject (0x%X) Name (%wS)\n", WinStaObject, Name);
DPRINT("WinStaObject (0x%X) Name (%wS)\n", WinStaObject, Name);
if (Name[0] == 0)
{
return NULL;
}
if (Name[0] == 0)
{
return NULL;
}
Current = WinStaObject->DesktopListHead.Flink;
while (Current != &WinStaObject->DesktopListHead)
{
CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
if (Attributes & OBJ_CASE_INSENSITIVE)
{
if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
Current = WinStaObject->DesktopListHead.Flink;
while (Current != &WinStaObject->DesktopListHead)
{
CurrentObject = CONTAINING_RECORD(Current, DESKTOP_OBJECT, ListEntry);
DPRINT("Scanning %wZ for %wS\n", &CurrentObject->Name, Name);
if (Attributes & OBJ_CASE_INSENSITIVE)
{
DPRINT("Found desktop at (0x%X)\n", CurrentObject);
return CurrentObject;
if (_wcsicmp(CurrentObject->Name.Buffer, Name) == 0)
{
DPRINT("Found desktop at (0x%X)\n", CurrentObject);
return CurrentObject;
}
}
}
else
{
if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
else
{
DPRINT("Found desktop at (0x%X)\n", CurrentObject);
return CurrentObject;
if (wcscmp(CurrentObject->Name.Buffer, Name) == 0)
{
DPRINT("Found desktop at (0x%X)\n", CurrentObject);
return CurrentObject;
}
}
}
Current = Current->Flink;
}
Current = Current->Flink;
}
DPRINT("Returning NULL\n");
DPRINT("Returning NULL\n");
return NULL;
return NULL;
}
NTSTATUS
@ -192,43 +192,43 @@ IntWinStaObjectParse(PVOID Object,
PWSTR *Path,
ULONG Attributes)
{
PVOID FoundObject;
NTSTATUS Status;
PWSTR End;
PVOID FoundObject;
NTSTATUS Status;
PWSTR End;
DPRINT("Object (0x%X) Path (0x%X) *Path (%wS)\n", Object, Path, *Path);
DPRINT("Object (0x%X) Path (0x%X) *Path (%wS)\n", Object, Path, *Path);
*NextObject = NULL;
*NextObject = NULL;
if ((Path == NULL) || ((*Path) == NULL))
{
return STATUS_SUCCESS;
}
if ((Path == NULL) || ((*Path) == NULL))
{
return STATUS_SUCCESS;
}
End = wcschr((*Path) + 1, '\\');
if (End != NULL)
{
DPRINT("Name contains illegal characters\n");
return STATUS_UNSUCCESSFUL;
}
End = wcschr((*Path) + 1, '\\');
if (End != NULL)
{
DPRINT("Name contains illegal characters\n");
return STATUS_UNSUCCESSFUL;
}
FoundObject = IntWinStaObjectFind(Object, (*Path) + 1, Attributes);
if (FoundObject == NULL)
{
DPRINT("Name was not found\n");
return STATUS_UNSUCCESSFUL;
}
FoundObject = IntWinStaObjectFind(Object, (*Path) + 1, Attributes);
if (FoundObject == NULL)
{
DPRINT("Name was not found\n");
return STATUS_UNSUCCESSFUL;
}
Status = ObReferenceObjectByPointer(
FoundObject,
STANDARD_RIGHTS_REQUIRED,
NULL,
UserMode);
Status = ObReferenceObjectByPointer(
FoundObject,
STANDARD_RIGHTS_REQUIRED,
NULL,
UserMode);
*NextObject = FoundObject;
*Path = NULL;
*NextObject = FoundObject;
*Path = NULL;
return Status;
return Status;
}
/* PRIVATE FUNCTIONS **********************************************************/
@ -305,18 +305,18 @@ IntValidateWindowStationHandle(
if (WindowStation == NULL)
{
// DPRINT1("Invalid window station handle\n");
// DPRINT1("Invalid window station handle\n");
SetLastWin32Error(ERROR_INVALID_HANDLE);
return STATUS_INVALID_HANDLE;
}
Status = ObReferenceObjectByHandle(
WindowStation,
DesiredAccess,
ExWindowStationObjectType,
AccessMode,
(PVOID*)Object,
NULL);
WindowStation,
DesiredAccess,
ExWindowStationObjectType,
AccessMode,
(PVOID*)Object,
NULL);
if (!NT_SUCCESS(Status))
SetLastNtError(Status);
@ -330,10 +330,10 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object)
NTSTATUS Status;
Status = ObReferenceObjectByPointer(
Object,
KernelMode,
ExWindowStationObjectType,
0);
Object,
KernelMode,
ExWindowStationObjectType,
0);
return NT_SUCCESS(Status);
}
@ -341,40 +341,40 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object)
BOOL FASTCALL
co_IntInitializeDesktopGraphics(VOID)
{
UNICODE_STRING DriverName;
if (! IntCreatePrimarySurface())
{
UNICODE_STRING DriverName;
if (! IntCreatePrimarySurface())
{
return FALSE;
}
RtlInitUnicodeString(&DriverName, L"DISPLAY");
ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
if (NULL == ScreenDeviceContext)
{
}
RtlInitUnicodeString(&DriverName, L"DISPLAY");
ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
if (NULL == ScreenDeviceContext)
{
IntDestroyPrimarySurface();
return FALSE;
}
DC_SetOwnership(ScreenDeviceContext, NULL);
}
DC_SetOwnership(ScreenDeviceContext, NULL);
UserAcquireOrReleaseInputOwnership(FALSE);
UserAcquireOrReleaseInputOwnership(FALSE);
/* Setup the cursor */
co_IntLoadDefaultCursors();
/* Setup the cursor */
co_IntLoadDefaultCursors();
return TRUE;
return TRUE;
}
VOID FASTCALL
IntEndDesktopGraphics(VOID)
{
UserAcquireOrReleaseInputOwnership(TRUE);
if (NULL != ScreenDeviceContext)
{
UserAcquireOrReleaseInputOwnership(TRUE);
if (NULL != ScreenDeviceContext)
{
DC_SetOwnership(ScreenDeviceContext, PsGetCurrentProcess());
NtGdiDeleteDC(ScreenDeviceContext);
ScreenDeviceContext = NULL;
}
IntHideDesktop(IntGetActiveDesktop());
IntDestroyPrimarySurface();
}
IntHideDesktop(IntGetActiveDesktop());
IntDestroyPrimarySurface();
}
HDC FASTCALL
@ -442,7 +442,7 @@ NtUserCreateWindowStation(
*/
if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName,
NULL))
NULL))
{
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
@ -463,13 +463,13 @@ NtUserCreateWindowStation(
NULL);
Status = ObOpenObjectByName(
&ObjectAttributes,
ExWindowStationObjectType,
NULL,
KernelMode,
dwDesiredAccess,
NULL,
(PVOID*)&WindowStation);
&ObjectAttributes,
ExWindowStationObjectType,
NULL,
KernelMode,
dwDesiredAccess,
NULL,
(PVOID*)&WindowStation);
if (NT_SUCCESS(Status))
{
@ -485,15 +485,15 @@ NtUserCreateWindowStation(
DPRINT("Creating window station (%wZ)\n", &WindowStationName);
Status = ObCreateObject(
KernelMode,
ExWindowStationObjectType,
&ObjectAttributes,
ExGetPreviousMode(),
NULL,
sizeof(WINSTATION_OBJECT),
0,
0,
(PVOID*)&WindowStationObject);
KernelMode,
ExWindowStationObjectType,
&ObjectAttributes,
ExGetPreviousMode(),
NULL,
sizeof(WINSTATION_OBJECT),
0,
0,
(PVOID*)&WindowStationObject);
if (!NT_SUCCESS(Status))
{
@ -502,16 +502,16 @@ NtUserCreateWindowStation(
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
}
WindowStationObject->Name = *lpszWindowStationName;
Status = ObInsertObject(
(PVOID)WindowStationObject,
NULL,
STANDARD_RIGHTS_REQUIRED,
0,
NULL,
(PVOID*)&WindowStation);
(PVOID)WindowStationObject,
NULL,
STANDARD_RIGHTS_REQUIRED,
0,
NULL,
(PVOID*)&WindowStation);
if (!NT_SUCCESS(Status))
{
@ -528,11 +528,11 @@ NtUserCreateWindowStation(
if(!(CurInfo = ExAllocatePool(PagedPool, sizeof(SYSTEM_CURSORINFO))))
{
ExFreePool(WindowStationName.Buffer);
/* FIXME - Delete window station object */
ObDereferenceObject(WindowStationObject);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
ExFreePool(WindowStationName.Buffer);
/* FIXME - Delete window station object */
ObDereferenceObject(WindowStationObject);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
}
InitHotKeys(WindowStationObject);
@ -554,8 +554,8 @@ NtUserCreateWindowStation(
if (!IntSetupCurIconHandles(WindowStationObject))
{
DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
/* FIXME: Complain more loudly? */
DPRINT1("Setting up the Cursor/Icon Handle table failed!\n");
/* FIXME: Complain more loudly? */
}
DPRINT("Window station successfully created (%wZ)\n", lpszWindowStationName);
@ -602,7 +602,7 @@ NtUserOpenWindowStation(
*/
if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName,
NULL))
NULL))
{
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return 0;
@ -619,13 +619,13 @@ NtUserOpenWindowStation(
NULL);
Status = ObOpenObjectByName(
&ObjectAttributes,
ExWindowStationObjectType,
NULL,
UserMode,
dwDesiredAccess,
NULL,
(PVOID*)&WindowStation);
&ObjectAttributes,
ExWindowStationObjectType,
NULL,
UserMode,
dwDesiredAccess,
NULL,
(PVOID*)&WindowStation);
if (!NT_SUCCESS(Status))
{
@ -672,10 +672,10 @@ NtUserCloseWindowStation(
DPRINT("About to close window station handle (0x%X)\n", hWinSta);
Status = IntValidateWindowStationHandle(
hWinSta,
KernelMode,
0,
&Object);
hWinSta,
KernelMode,
0,
&Object);
if (!NT_SUCCESS(Status))
{
@ -683,11 +683,11 @@ NtUserCloseWindowStation(
return FALSE;
}
#if 0
#if 0
/* FIXME - free the cursor information when actually deleting the object!! */
ASSERT(Object->SystemCursor);
ExFreePool(Object->SystemCursor);
#endif
#endif
ObDereferenceObject(Object);
@ -760,10 +760,10 @@ NtUserGetObjectInformation(
/* try windowstation */
DPRINT("Trying to open window station 0x%x\n", hObject);
Status = IntValidateWindowStationHandle(
hObject,
UserMode,/*ExGetPreviousMode(),*/
GENERIC_READ, /* FIXME: is this ok? */
&WinStaObject);
hObject,
UserMode,/*ExGetPreviousMode(),*/
GENERIC_READ, /* FIXME: is this ok? */
&WinStaObject);
if (!NT_SUCCESS(Status) && Status != STATUS_OBJECT_TYPE_MISMATCH)
@ -778,10 +778,10 @@ NtUserGetObjectInformation(
/* try desktop */
DPRINT("Trying to open desktop 0x%x\n", hObject);
Status = IntValidateDesktopHandle(
hObject,
UserMode,/*ExGetPreviousMode(),*/
GENERIC_READ, /* FIXME: is this ok? */
&DesktopObject);
hObject,
UserMode,/*ExGetPreviousMode(),*/
GENERIC_READ, /* FIXME: is this ok? */
&DesktopObject);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed: 0x%x\n", Status);
@ -794,53 +794,53 @@ NtUserGetObjectInformation(
/* get data */
switch (nIndex)
{
case UOI_FLAGS:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("UOI_FLAGS unimplemented!\n");
break;
case UOI_FLAGS:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("UOI_FLAGS unimplemented!\n");
break;
case UOI_NAME:
if (WinStaObject != NULL)
{
pvData = WinStaObject->Name.Buffer;
nDataSize = WinStaObject->Name.Length+2;
Status = STATUS_SUCCESS;
}
else if (DesktopObject != NULL)
{
pvData = DesktopObject->Name.Buffer;
nDataSize = DesktopObject->Name.Length+2;
Status = STATUS_SUCCESS;
}
else
case UOI_NAME:
if (WinStaObject != NULL)
{
pvData = WinStaObject->Name.Buffer;
nDataSize = WinStaObject->Name.Length+2;
Status = STATUS_SUCCESS;
}
else if (DesktopObject != NULL)
{
pvData = DesktopObject->Name.Buffer;
nDataSize = DesktopObject->Name.Length+2;
Status = STATUS_SUCCESS;
}
else
Status = STATUS_INVALID_PARAMETER;
break;
case UOI_TYPE:
if (WinStaObject != NULL)
{
pvData = L"WindowStation";
nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
Status = STATUS_SUCCESS;
}
else if (DesktopObject != NULL)
{
pvData = L"Desktop";
nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
Status = STATUS_SUCCESS;
}
else
Status = STATUS_INVALID_PARAMETER;
break;
case UOI_USER_SID:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("UOI_USER_SID unimplemented!\n");
break;
default:
Status = STATUS_INVALID_PARAMETER;
break;
case UOI_TYPE:
if (WinStaObject != NULL)
{
pvData = L"WindowStation";
nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
Status = STATUS_SUCCESS;
}
else if (DesktopObject != NULL)
{
pvData = L"Desktop";
nDataSize = (wcslen(pvData) + 1) * sizeof(WCHAR);
Status = STATUS_SUCCESS;
}
else
Status = STATUS_INVALID_PARAMETER;
break;
case UOI_USER_SID:
Status = STATUS_NOT_IMPLEMENTED;
DPRINT1("UOI_USER_SID unimplemented!\n");
break;
default:
Status = STATUS_INVALID_PARAMETER;
break;
break;
}
/* try to copy data to caller */
@ -916,15 +916,15 @@ UserGetProcessWindowStation(VOID)
{
if(PsGetCurrentProcess() != CsrProcess)
{
return PsGetCurrentProcess()->Win32WindowStation;
return PsGetCurrentProcess()->Win32WindowStation;
}
else
{
/* FIXME - get the pointer to the window station by querying the parent of
the desktop of the calling thread (which is a window station),
then use ObFindHandleForObject() to find a suitable handle */
DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n");
return NULL;
/* FIXME - get the pointer to the window station by querying the parent of
the desktop of the calling thread (which is a window station),
then use ObFindHandleForObject() to find a suitable handle */
DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n");
return NULL;
}
}
@ -952,35 +952,35 @@ NtUserGetProcessWindowStation(VOID)
PWINSTATION_OBJECT FASTCALL
IntGetWinStaObj(VOID)
{
PWINSTATION_OBJECT WinStaObj;
PWINSTATION_OBJECT WinStaObj;
/*
* just a temporary hack, this will be gone soon
*/
/*
* just a temporary hack, this will be gone soon
*/
if(PsGetWin32Thread() != NULL && PsGetWin32Thread()->Desktop != NULL)
{
WinStaObj = PsGetWin32Thread()->Desktop->WindowStation;
ObReferenceObjectByPointer(WinStaObj, KernelMode, ExWindowStationObjectType, 0);
}
else if(PsGetCurrentProcess() != CsrProcess)
{
NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObj);
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return NULL;
}
}
else
{
WinStaObj = NULL;
}
if(PsGetWin32Thread() != NULL && PsGetWin32Thread()->Desktop != NULL)
{
WinStaObj = PsGetWin32Thread()->Desktop->WindowStation;
ObReferenceObjectByPointer(WinStaObj, KernelMode, ExWindowStationObjectType, 0);
}
else if(PsGetCurrentProcess() != CsrProcess)
{
NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObj);
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return NULL;
}
}
else
{
WinStaObj = NULL;
}
return WinStaObj;
return WinStaObj;
}
/*
@ -1007,25 +1007,25 @@ NtUserSetProcessWindowStation(HWINSTA hWindowStation)
NTSTATUS Status;
DPRINT("About to set process window station with handle (0x%X)\n",
hWindowStation);
hWindowStation);
if(PsGetCurrentProcess() == CsrProcess)
{
DPRINT1("CSRSS is not allowed to change it's window station!!!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
DPRINT1("CSRSS is not allowed to change it's window station!!!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
Status = IntValidateWindowStationHandle(
hWindowStation,
KernelMode,
0,
&NewWinSta);
hWindowStation,
KernelMode,
0,
&NewWinSta);
if (!NT_SUCCESS(Status))
{
DPRINT("Validation of window station handle (0x%X) failed\n",
hWindowStation);
hWindowStation);
SetLastNtError(Status);
return FALSE;
}
@ -1038,7 +1038,7 @@ NtUserSetProcessWindowStation(HWINSTA hWindowStation)
hOld = InterlockedExchangePointer(&PsGetCurrentProcess()->Win32WindowStation, hWindowStation);
DPRINT("PsGetCurrentProcess()->Win32WindowStation 0x%X\n",
PsGetCurrentProcess()->Win32WindowStation);
PsGetCurrentProcess()->Win32WindowStation);
return TRUE;
}
@ -1059,24 +1059,24 @@ NtUserLockWindowStation(HWINSTA hWindowStation)
NTSTATUS Status;
DPRINT("About to set process window station with handle (0x%X)\n",
hWindowStation);
hWindowStation);
if(PsGetWin32Process() != LogonProcess)
{
DPRINT1("Unauthorized process attempted to lock the window station!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
DPRINT1("Unauthorized process attempted to lock the window station!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
Status = IntValidateWindowStationHandle(
hWindowStation,
KernelMode,
0,
&Object);
hWindowStation,
KernelMode,
0,
&Object);
if (!NT_SUCCESS(Status))
{
DPRINT("Validation of window station handle (0x%X) failed\n",
hWindowStation);
hWindowStation);
SetLastNtError(Status);
return FALSE;
}
@ -1104,24 +1104,24 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation)
BOOL Ret;
DPRINT("About to set process window station with handle (0x%X)\n",
hWindowStation);
hWindowStation);
if(PsGetWin32Process() != LogonProcess)
{
DPRINT1("Unauthorized process attempted to unlock the window station!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
DPRINT1("Unauthorized process attempted to unlock the window station!\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE;
}
Status = IntValidateWindowStationHandle(
hWindowStation,
KernelMode,
0,
&Object);
hWindowStation,
KernelMode,
0,
&Object);
if (!NT_SUCCESS(Status))
{
DPRINT("Validation of window station handle (0x%X) failed\n",
hWindowStation);
hWindowStation);
SetLastNtError(Status);
return FALSE;
}
@ -1187,9 +1187,9 @@ BuildWindowStationNameList(
NULL);
Status = ZwOpenDirectoryObject(
&DirectoryHandle,
DIRECTORY_QUERY,
&ObjectAttributes);
&DirectoryHandle,
DIRECTORY_QUERY,
&ObjectAttributes);
ExFreePool(DirectoryName.Buffer);
@ -1206,7 +1206,7 @@ BuildWindowStationNameList(
if (NT_SUCCESS(Status))
{
if (STATUS_NO_MORE_ENTRIES == ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
FALSE, &Context, NULL))
FALSE, &Context, NULL))
{
/* Our fixed-size buffer is large enough */
Buffer = InitialBuffer;
@ -1233,8 +1233,8 @@ BuildWindowStationNameList(
Status = ZwQueryDirectoryObject(DirectoryHandle, Buffer, BufferSize,
FALSE, TRUE, &Context, &ReturnLength);
if (! NT_SUCCESS(Status) ||
STATUS_NO_MORE_ENTRIES != ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
FALSE, &Context, NULL))
STATUS_NO_MORE_ENTRIES != ZwQueryDirectoryObject(DirectoryHandle, NULL, 0, FALSE,
FALSE, &Context, NULL))
{
/* Something went wrong, maybe someone added a directory entry? Just give up. */
ExFreePool(Buffer);
@ -1252,7 +1252,7 @@ BuildWindowStationNameList(
ReturnLength = sizeof(DWORD);
EntryCount = 0;
for (DirEntry = (POBJECT_DIRECTORY_INFORMATION) Buffer; 0 != DirEntry->ObjectName.Length;
DirEntry++)
DirEntry++)
{
ReturnLength += DirEntry->ObjectName.Length + sizeof(WCHAR);
EntryCount++;
@ -1299,7 +1299,7 @@ BuildWindowStationNameList(
NullWchar = L'\0';
for (DirEntry = (POBJECT_DIRECTORY_INFORMATION) Buffer; 0 != DirEntry->ObjectName.Length;
DirEntry++)
DirEntry++)
{
Status = MmCopyToCaller(lpBuffer, DirEntry->ObjectName.Buffer, DirEntry->ObjectName.Length);
if (! NT_SUCCESS(Status))
@ -1367,8 +1367,8 @@ BuildDesktopNameList(
ReturnLength = sizeof(DWORD);
EntryCount = 0;
for (DesktopEntry = WindowStation->DesktopListHead.Flink;
DesktopEntry != &WindowStation->DesktopListHead;
DesktopEntry = DesktopEntry->Flink)
DesktopEntry != &WindowStation->DesktopListHead;
DesktopEntry = DesktopEntry->Flink)
{
DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
ReturnLength += DesktopObject->Name.Length + sizeof(WCHAR);
@ -1410,8 +1410,8 @@ BuildDesktopNameList(
NullWchar = L'\0';
for (DesktopEntry = WindowStation->DesktopListHead.Flink;
DesktopEntry != &WindowStation->DesktopListHead;
DesktopEntry = DesktopEntry->Flink)
DesktopEntry != &WindowStation->DesktopListHead;
DesktopEntry = DesktopEntry->Flink)
{
DesktopObject = CONTAINING_RECORD(DesktopEntry, DESKTOP_OBJECT, ListEntry);
Status = MmCopyToCaller(lpBuffer, DesktopObject->Name.Buffer, DesktopObject->Name.Length);
@ -1477,7 +1477,7 @@ NtUserBuildNameList(
/* The WindowStation name list and desktop name list are build in completely
different ways. Call the appropriate function */
return NULL == hWindowStation ? BuildWindowStationNameList(dwSize, lpBuffer, pRequiredSize) :
BuildDesktopNameList(hWindowStation, dwSize, lpBuffer, pRequiredSize);
BuildDesktopNameList(hWindowStation, dwSize, lpBuffer, pRequiredSize);
}
/* EOF */