Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8716 lines
286 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: userk.h
  3. *
  4. * Copyright (c) 1985 - 2001, Microsoft Corporation
  5. *
  6. * Typedefs, defines, and prototypes that are used exclusively by the User
  7. * kernel-mode code.
  8. *
  9. * History:
  10. * 04-28-91 DarrinM Created from PROTO.H, MACRO.H, and STRTABLE.H
  11. * 01-25-95 JimA Prepped for kernel-mode
  12. \***************************************************************************/
  13. #ifndef _USERK_
  14. #define _USERK_
  15. #ifndef _WINBASE_
  16. #include <wbasek.h>
  17. #endif // _WINBASE_
  18. #include <csrmsg.h>
  19. #include <heap.h>
  20. /*
  21. * BltColor() flags.
  22. */
  23. #define BC_INVERT 0x00000001
  24. #define BC_NOMIRROR 0x00000002
  25. #define MIRRORED_HDC(hdc) (GreGetLayout(hdc) & LAYOUT_RTL)
  26. #define OEMRESOURCE 1
  27. #define CCACHEDCAPTIONS 5
  28. #define GETMOUSETRAILS() (IsRemoteConnection() ? 0 : gMouseTrails)
  29. #define MOUSE_TRAILS_FREQ 50
  30. #include <winnls.h>
  31. #include <wincon.h>
  32. #include <winuser.h>
  33. #include <winuserp.h>
  34. #include <wowuserp.h>
  35. #include "ntddvdeo.h"
  36. #ifdef GENERIC_INPUT
  37. #include <hidpddi.h>
  38. #include <hidpi.h>
  39. #include <hidclass.h>
  40. #endif
  41. #include <user.h>
  42. PTHREADINFO _ptiCrit(VOID);
  43. PTHREADINFO _ptiCritShared(VOID);
  44. extern PTHREADINFO gptiCurrent;
  45. #if DBG
  46. #define PtiCurrent() _ptiCrit()
  47. #define PtiCurrentShared() _ptiCritShared()
  48. #else // DBG
  49. #define PtiCurrent() (gptiCurrent)
  50. #define PtiCurrentShared() ((PTHREADINFO)(W32GetCurrentThread()))
  51. #endif // DBG
  52. extern HANDLE CsrApiPort;
  53. #if DBG
  54. VOID CheckPtiSysPeek(int where, PQ pq, ULONG_PTR newIdSysPeek);
  55. VOID CheckSysLock(int where, PQ pq, PTHREADINFO pti);
  56. #else
  57. #define CheckPtiSysPeek(where, pq, newIdSysPeek)
  58. #define CheckSysLock(where, pq, pti)
  59. #endif
  60. /*
  61. * ShutdownProcessRoutine return values
  62. */
  63. #define SHUTDOWN_KNOWN_PROCESS 1
  64. #define SHUTDOWN_UNKNOWN_PROCESS 2
  65. #define SHUTDOWN_CANCEL 3
  66. /*
  67. * Macros to get address of current thread and process information.
  68. */
  69. #define PpiCurrent() ((PPROCESSINFO)(W32GetCurrentProcess()))
  70. #define PtiFromThread(Thread) ((PTHREADINFO)(PsGetThreadWin32Thread(Thread)))
  71. #if DBG
  72. #define GetNestedCallsCounter() (PtiCurrentShared()->cNestedCalls)
  73. #else
  74. #define GetNestedCallsCounter()
  75. #endif
  76. #define PpiFromProcess(Process) \
  77. ((PPROCESSINFO)(PsGetProcessWin32Process(Process)))
  78. #define ISCSRSS() (PsGetCurrentProcess() == gpepCSRSS)
  79. BOOL CSTPush(UINT uThreadID, PVOID pParam, HANDLE UniqueProcessId, BOOL bRemoteThreadStack);
  80. VOID CSTCleanupStack(BOOL bRemoteThreadStack);
  81. __inline BOOL InitCreateSystemThreadsMsg(
  82. PUSER_API_MSG pMsg,
  83. UINT ThreadID,
  84. PVOID pVoid,
  85. HANDLE UniqueProcessId,
  86. BOOL bRemoteThread)
  87. {
  88. UserAssert(CsrApiPort != NULL);
  89. if (!CSTPush(ThreadID, pVoid, UniqueProcessId, bRemoteThread)) {
  90. return FALSE;
  91. }
  92. pMsg->h.u1.s1.DataLength = (USHORT)(sizeof(USER_API_MSG) - sizeof(PORT_MESSAGE));
  93. pMsg->h.u1.s1.TotalLength = (USHORT)sizeof(USER_API_MSG);
  94. pMsg->h.u2.ZeroInit = 0;
  95. pMsg->CaptureBuffer = NULL;
  96. pMsg->ApiNumber = CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpCreateSystemThreads);
  97. pMsg->u.CreateSystemThreads.bRemoteThread = bRemoteThread;
  98. return TRUE;
  99. }
  100. NTSTATUS OpenEffectiveToken(
  101. PHANDLE phToken);
  102. NTSTATUS GetProcessLuid(
  103. PETHREAD Thread OPTIONAL,
  104. PLUID LuidProcess);
  105. BOOLEAN IsRestricted(
  106. PETHREAD Thread);
  107. NTSTATUS InitSystemThread(
  108. PUNICODE_STRING pstrThreadName);
  109. #define INITCLIENTINFO(pti) \
  110. { \
  111. try { \
  112. pti->pClientInfo->dwExpWinVer = pti->dwExpWinVer; \
  113. pti->pClientInfo->dwTIFlags = pti->TIF_flags; \
  114. \
  115. pti->pClientInfo->lpClassesRegistered = NULL; \
  116. \
  117. if (pti->spklActive) { \
  118. pti->pClientInfo->CodePage = pti->spklActive->CodePage; \
  119. pti->pClientInfo->hKL = pti->spklActive->hkl; \
  120. } else { \
  121. pti->pClientInfo->CodePage = CP_ACP; \
  122. pti->pClientInfo->hKL = 0; \
  123. } \
  124. } except (W32ExceptionHandler(TRUE, RIP_WARNING)) { \
  125. Status = GetExceptionCode(); \
  126. goto Error; \
  127. } \
  128. }
  129. PKEVENT CreateKernelEvent(
  130. IN EVENT_TYPE Type,
  131. IN BOOLEAN State);
  132. NTSTATUS ProtectHandle(
  133. IN HANDLE Handle,
  134. IN POBJECT_TYPE pObjectType,
  135. IN BOOLEAN Protect);
  136. __inline VOID FreeKernelEvent(PVOID* pp)
  137. {
  138. UserFreePool(*pp);
  139. *pp = NULL;
  140. }
  141. extern BOOL gfSwitchInProgress;
  142. extern PKEVENT gpevtVideoportCallout;
  143. __inline VOID SetConsoleSwitchInProgress(BOOL fSwitchInProgress)
  144. {
  145. gfSwitchInProgress = fSwitchInProgress;
  146. if (fSwitchInProgress) {
  147. KeResetEvent(gpevtVideoportCallout);
  148. } else {
  149. KeSetEvent(gpevtVideoportCallout, EVENT_INCREMENT, FALSE);
  150. }
  151. }
  152. /*
  153. * Object types exported from the kernel.
  154. */
  155. extern POBJECT_TYPE *ExWindowStationObjectType;
  156. extern POBJECT_TYPE *ExDesktopObjectType;
  157. extern POBJECT_TYPE *ExEventObjectType;
  158. extern POBJECT_TYPE *IoDriverObjectType;
  159. #ifndef DWORD_ALIGN
  160. #define DWORD_ALIGN(x) ( ((x) + 3) & ~3)
  161. #endif // !DWORD_ALIGN
  162. /*
  163. * Private probing macros
  164. */
  165. #if defined(_X86_)
  166. #define DATAALIGN sizeof(BYTE)
  167. #define CHARALIGN sizeof(BYTE)
  168. #else
  169. #define DATAALIGN sizeof(DWORD)
  170. #define CHARALIGN sizeof(WCHAR)
  171. #endif
  172. #define ProbeForReadBuffer(Address, Count, Alignment) { \
  173. if ((ULONG)(Count) > (ULONG)(MAXULONG / sizeof(*(Address)))) { \
  174. ExRaiseAccessViolation(); \
  175. } \
  176. ProbeForRead(Address, (ULONG)(Count) * sizeof(*(Address)), Alignment); \
  177. }
  178. #define ProbeForWriteBuffer(Address, Count, Alignment) { \
  179. if ((ULONG)(Count) > (ULONG)(MAXULONG / sizeof(*(Address)))) { \
  180. ExRaiseAccessViolation(); \
  181. } \
  182. ProbeForWrite(Address, (ULONG)(Count) * sizeof(*(Address)), Alignment); \
  183. }
  184. #define ProbeAndReadSize(Address) \
  185. (((Address) >= (SIZE * const)MM_USER_PROBE_ADDRESS) ? \
  186. (*(volatile SIZE * const)MM_USER_PROBE_ADDRESS) : (*(volatile SIZE *)(Address)))
  187. #define ProbeAndReadBlendfunction(Address) \
  188. (((Address) >= (BLENDFUNCTION * const)MM_USER_PROBE_ADDRESS) ? \
  189. (*(volatile BLENDFUNCTION * const)MM_USER_PROBE_ADDRESS) : (*(volatile BLENDFUNCTION *)(Address)))
  190. //++
  191. //
  192. // BOOLEAN
  193. // ProbeAndReadPoint(
  194. // IN PPOINT Address
  195. // )
  196. //
  197. //--
  198. #define ProbePoint(Address) \
  199. (((Address) >= (POINT * const)MM_USER_PROBE_ADDRESS) ? \
  200. (*(volatile DWORD * const)MM_USER_PROBE_ADDRESS) : (*(volatile DWORD *)(Address)))
  201. #define ProbeAndReadPoint(Address) \
  202. (((Address) >= (POINT * const)MM_USER_PROBE_ADDRESS) ? \
  203. (*(volatile POINT * const)MM_USER_PROBE_ADDRESS) : (*(volatile POINT *)(Address)))
  204. //++
  205. //
  206. // BOOLEAN
  207. // ProbeAndReadRect(
  208. // IN PRECT Address
  209. // )
  210. //
  211. //--
  212. #define ProbeRect(Address) \
  213. (((Address) >= (RECT * const)MM_USER_PROBE_ADDRESS) ? \
  214. (*(volatile DWORD * const)MM_USER_PROBE_ADDRESS) : (*(volatile DWORD *)(Address)))
  215. #define ProbeAndReadRect(Address) \
  216. (((Address) >= (RECT * const)MM_USER_PROBE_ADDRESS) ? \
  217. (*(volatile RECT * const)MM_USER_PROBE_ADDRESS) : (*(volatile RECT *)(Address)))
  218. //++
  219. //
  220. // BOOLEAN
  221. // ProbeAndReadMessage(
  222. // IN PMSG Address
  223. // )
  224. //
  225. //--
  226. #define ProbeMessage(Address) \
  227. (((Address) >= (MSG * const)MM_USER_PROBE_ADDRESS) ? \
  228. (*(volatile DWORD * const)MM_USER_PROBE_ADDRESS) : (*(volatile DWORD *)(Address)))
  229. #define ProbeAndReadMessage(Address) \
  230. (((Address) >= (MSG * const)MM_USER_PROBE_ADDRESS) ? \
  231. (*(volatile MSG * const)MM_USER_PROBE_ADDRESS) : (*(volatile MSG *)(Address)))
  232. //++
  233. //
  234. // BOOLEAN
  235. // ProbeAndReadLargeString(
  236. // IN PLARGE_STRING Address
  237. // )
  238. //
  239. //--
  240. #define ProbeAndReadLargeString(Address) \
  241. (((Address) >= (LARGE_STRING * const)MM_USER_PROBE_ADDRESS) ? \
  242. (*(volatile LARGE_STRING * const)MM_USER_PROBE_ADDRESS) : (*(volatile LARGE_STRING *)(Address)))
  243. //++
  244. //
  245. // BOOLEAN
  246. // ProbeAndReadWindowPlacement(
  247. // IN PWINDOWPLACEMENT Address
  248. // )
  249. //
  250. //--
  251. #define ProbeAndReadWindowPlacement(Address) \
  252. (((Address) >= (WINDOWPLACEMENT * const)MM_USER_PROBE_ADDRESS) ? \
  253. (*(volatile WINDOWPLACEMENT * const)MM_USER_PROBE_ADDRESS) : (*(volatile WINDOWPLACEMENT *)(Address)))
  254. //++
  255. //
  256. // BOOLEAN
  257. // ProbeAndReadMenuItem(
  258. // IN PMENUITEMINFO Address
  259. // )
  260. //
  261. //--
  262. #define ProbeAndReadMenuItem(Address) \
  263. (((Address) >= (MENUITEMINFO * const)MM_USER_PROBE_ADDRESS) ? \
  264. (*(volatile MENUITEMINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile MENUITEMINFO *)(Address)))
  265. //++
  266. //
  267. // BOOLEAN
  268. // ProbeAndReadMenuInfo(
  269. // IN PMENUINFO Address
  270. // )
  271. //
  272. //--
  273. #define ProbeAndReadMenuInfo(Address) \
  274. (((Address) >= (MENUINFO * const)MM_USER_PROBE_ADDRESS) ? \
  275. (*(volatile MENUINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile MENUINFO *)(Address)))
  276. //++
  277. //
  278. // BOOLEAN
  279. // ProbeAndReadScrollInfo(
  280. // IN PSCROLLINFO Address
  281. // )
  282. //
  283. //--
  284. #define ProbeAndReadScrollInfo(Address) \
  285. (((Address) >= (SCROLLINFO * const)MM_USER_PROBE_ADDRESS) ? \
  286. (*(volatile SCROLLINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile SCROLLINFO *)(Address)))
  287. //++
  288. //
  289. // BOOLEAN
  290. // ProbeAndReadPopupParams(
  291. // IN PTPMPARAMS Address
  292. // )
  293. //
  294. //--
  295. #define ProbeAndReadPopupParams(Address) \
  296. (((Address) >= (TPMPARAMS * const)MM_USER_PROBE_ADDRESS) ? \
  297. (*(volatile TPMPARAMS * const)MM_USER_PROBE_ADDRESS) : (*(volatile TPMPARAMS *)(Address)))
  298. //++
  299. //
  300. // BOOLEAN
  301. // ProbeAndReadPaintStruct(
  302. // IN PPAINTSTRUCT Address
  303. // )
  304. //
  305. //--
  306. #define ProbeAndReadPaintStruct(Address) \
  307. (((Address) >= (PAINTSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  308. (*(volatile PAINTSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile PAINTSTRUCT *)(Address)))
  309. //++
  310. //
  311. // BOOLEAN
  312. // ProbeAndReadCreateStruct(
  313. // IN PCREATESTRUCTW Address
  314. // )
  315. //
  316. //--
  317. #define ProbeAndReadCreateStruct(Address) \
  318. (((Address) >= (CREATESTRUCTW * const)MM_USER_PROBE_ADDRESS) ? \
  319. (*(volatile CREATESTRUCTW * const)MM_USER_PROBE_ADDRESS) : (*(volatile CREATESTRUCTW *)(Address)))
  320. //++
  321. //
  322. // BOOLEAN
  323. // ProbeAndReadMDICreateStruct(
  324. // IN PMDICREATESTRUCT Address
  325. // )
  326. //
  327. //--
  328. #define ProbeAndReadMDICreateStruct(Address) \
  329. (((Address) >= (MDICREATESTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  330. (*(volatile MDICREATESTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile MDICREATESTRUCT *)(Address)))
  331. //++
  332. //
  333. // BOOLEAN
  334. // ProbeAndReadCopyDataStruct(
  335. // IN PCOPYDATASTRUCT Address
  336. // )
  337. //
  338. //--
  339. #define ProbeAndReadCopyDataStruct(Address) \
  340. (((Address) >= (COPYDATASTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  341. (*(volatile COPYDATASTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile COPYDATASTRUCT *)(Address)))
  342. //++
  343. //
  344. // BOOLEAN
  345. // ProbeAndReadCompareItemStruct(
  346. // IN PCOMPAREITEMSTRUCT Address
  347. // )
  348. //
  349. //--
  350. #define ProbeAndReadCompareItemStruct(Address) \
  351. (((Address) >= (COMPAREITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  352. (*(volatile COMPAREITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile COMPAREITEMSTRUCT *)(Address)))
  353. //++
  354. //
  355. // BOOLEAN
  356. // ProbeAndReadDeleteItemStruct(
  357. // IN PDELETEITEMSTRUCT Address
  358. // )
  359. //
  360. //--
  361. #define ProbeAndReadDeleteItemStruct(Address) \
  362. (((Address) >= (DELETEITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  363. (*(volatile DELETEITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile DELETEITEMSTRUCT *)(Address)))
  364. //++
  365. //
  366. // BOOLEAN
  367. // ProbeAndReadHelp(
  368. // IN PHLP Address
  369. // )
  370. //
  371. //--
  372. #define ProbeAndReadHelp(Address) \
  373. (((Address) >= (HLP * const)MM_USER_PROBE_ADDRESS) ? \
  374. (*(volatile HLP * const)MM_USER_PROBE_ADDRESS) : (*(volatile HLP *)(Address)))
  375. //++
  376. //
  377. // BOOLEAN
  378. // ProbeAndReadHelpInfo(
  379. // IN PHELPINFO Address
  380. // )
  381. //
  382. //--
  383. #define ProbeAndReadHelpInfo(Address) \
  384. (((Address) >= (HELPINFO * const)MM_USER_PROBE_ADDRESS) ? \
  385. (*(volatile HELPINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile HELPINFO *)(Address)))
  386. //++
  387. //
  388. // BOOLEAN
  389. // ProbeAndReadDrawItemStruct(
  390. // IN PDRAWITEMSTRUCT Address
  391. // )
  392. //
  393. //--
  394. #define ProbeAndReadDrawItemStruct(Address) \
  395. (((Address) >= (DRAWITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  396. (*(volatile DRAWITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile DRAWITEMSTRUCT *)(Address)))
  397. //++
  398. //
  399. // BOOLEAN
  400. // ProbeAndReadHookInfo(
  401. // IN PDEBUGHOOKINFO Address
  402. // )
  403. //
  404. //--
  405. #define ProbeAndReadHookInfo(Address) \
  406. (((Address) >= (DEBUGHOOKINFO * const)MM_USER_PROBE_ADDRESS) ? \
  407. (*(volatile DEBUGHOOKINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile DEBUGHOOKINFO *)(Address)))
  408. //++
  409. //
  410. // BOOLEAN
  411. // ProbeAndReadCBTActivateStruct(
  412. // IN PCBTACTIVATESTRUCT Address
  413. // )
  414. //
  415. //--
  416. #define ProbeAndReadCBTActivateStruct(Address) \
  417. (((Address) >= (CBTACTIVATESTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  418. (*(volatile CBTACTIVATESTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile CBTACTIVATESTRUCT *)(Address)))
  419. //++
  420. //
  421. // BOOLEAN
  422. // ProbeAndReadKbdHook(
  423. // IN PKBDHOOKSTRUCT Address
  424. // )
  425. //
  426. //--
  427. #define ProbeAndReadKbdHook(Address) \
  428. (((Address) >= (KBDLLHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  429. (*(volatile KBDLLHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile KBDLLHOOKSTRUCT *)(Address)))
  430. //++
  431. //
  432. // BOOLEAN
  433. // ProbeAndReadMsllHook(
  434. // IN PMSLLHOOKSTRUCT Address
  435. // )
  436. //
  437. //--
  438. #define ProbeAndReadMsllHook(Address) \
  439. (((Address) >= (MSLLHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  440. (*(volatile MSLLHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile MSLLHOOKSTRUCT *)(Address)))
  441. //++
  442. //
  443. // BOOLEAN
  444. // ProbeAndReadMouseHook(
  445. // IN PMOUSEHOOKSTRUCTEX Address
  446. // )
  447. //
  448. //--
  449. #define ProbeAndReadMouseHook(Address) \
  450. (((Address) >= (MOUSEHOOKSTRUCTEX * const)MM_USER_PROBE_ADDRESS) ? \
  451. (*(volatile MOUSEHOOKSTRUCTEX * const)MM_USER_PROBE_ADDRESS) : (*(volatile MOUSEHOOKSTRUCTEX *)(Address)))
  452. #ifdef REDIRECTION
  453. //++
  454. //
  455. // BOOLEAN
  456. // ProbeAndReadHTHook(
  457. // IN PHTHOOKSTRUCT Address
  458. // )
  459. //
  460. //--
  461. #define ProbeAndReadHTHook(Address) \
  462. (((Address) >= (HTHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) ? \
  463. (*(volatile HTHOOKSTRUCT * const)MM_USER_PROBE_ADDRESS) : (*(volatile HTHOOKSTRUCT *)(Address)))
  464. #endif // REDIRECTION
  465. //++
  466. //
  467. // BOOLEAN
  468. // ProbeAndReadCBTCreateStruct(
  469. // IN PCBT_CREATEWND Address
  470. // )
  471. //
  472. //--
  473. #define ProbeAndReadCBTCreateStruct(Address) \
  474. (((Address) >= (CBT_CREATEWND * const)MM_USER_PROBE_ADDRESS) ? \
  475. (*(volatile CBT_CREATEWND * const)MM_USER_PROBE_ADDRESS) : (*(volatile CBT_CREATEWND *)(Address)))
  476. //++
  477. //
  478. // BOOLEAN
  479. // ProbeAndReadTrackMouseEvent(
  480. // IN LPTRACKMOUSEEVENT Address
  481. // )
  482. //
  483. //--
  484. #define ProbeAndReadTrackMouseEvent(Address) \
  485. (((Address) >= (TRACKMOUSEEVENT * const)MM_USER_PROBE_ADDRESS) ? \
  486. (*(volatile TRACKMOUSEEVENT * const)MM_USER_PROBE_ADDRESS) : (*(volatile TRACKMOUSEEVENT *)(Address)))
  487. //++
  488. //
  489. // BOOLEAN
  490. // ProbeAndReadWindowPos(
  491. // IN PWINDOWPOS Address
  492. // )
  493. //
  494. //--
  495. #define ProbeAndReadWindowPos(Address) \
  496. (((Address) >= (WINDOWPOS * const)MM_USER_PROBE_ADDRESS) ? \
  497. (*(volatile WINDOWPOS * const)MM_USER_PROBE_ADDRESS) : (*(volatile WINDOWPOS *)(Address)))
  498. //++
  499. //
  500. // BOOLEAN
  501. // ProbeAndReadCursorFind(
  502. // IN PCURSORFIND Address
  503. // )
  504. //
  505. //--
  506. #define ProbeAndReadCursorFind(Address) \
  507. (((Address) >= (CURSORFIND * const)MM_USER_PROBE_ADDRESS) ? \
  508. (*(volatile CURSORFIND * const)MM_USER_PROBE_ADDRESS) : (*(volatile CURSORFIND *)(Address)))
  509. //++
  510. //
  511. // BOOLEAN
  512. // ProbeAndReadSetClipBData(
  513. // IN PSETCLIPBDATA Address
  514. // )
  515. //
  516. //--
  517. #define ProbeAndReadSetClipBData(Address) \
  518. (((Address) >= (SETCLIPBDATA * const)MM_USER_PROBE_ADDRESS) ? \
  519. (*(volatile SETCLIPBDATA * const)MM_USER_PROBE_ADDRESS) : (*(volatile SETCLIPBDATA *)(Address)))
  520. //++
  521. //
  522. // BOOLEAN
  523. // ProbeAndReadBroadcastSystemMsgParams(
  524. // IN LPBROADCASTSYSTEMMSGPARAMS Address
  525. // )
  526. //
  527. //--
  528. #define ProbeAndReadBroadcastSystemMsgParams(Address) \
  529. (((Address) >= (BROADCASTSYSTEMMSGPARAMS * const)MM_USER_PROBE_ADDRESS) ? \
  530. (*(volatile BROADCASTSYSTEMMSGPARAMS * const)MM_USER_PROBE_ADDRESS) : (*(volatile BROADCASTSYSTEMMSGPARAMS *)(Address)))
  531. //++
  532. //
  533. // BOOLEAN
  534. // ProbeAndReadCursorData(
  535. // IN PCURSORDATA Address
  536. // )
  537. //
  538. //--
  539. #define ProbeAndReadCursorData(Address) \
  540. (((Address) >= (CURSORDATA * const)MM_USER_PROBE_ADDRESS) ? \
  541. (*(volatile CURSORDATA * const)MM_USER_PROBE_ADDRESS) : (*(volatile CURSORDATA *)(Address)))
  542. //++
  543. //
  544. // BOOLEAN
  545. // ProbeForReadUnicodeStringBuffer(
  546. // IN UNICODE_STRING String
  547. // )
  548. //
  549. //--
  550. #if defined(_X86_)
  551. #define ProbeForReadUnicodeStringBuffer(String) \
  552. if (((ULONG_PTR)((String).Buffer) & (sizeof(BYTE) - 1)) != 0) { \
  553. ExRaiseDatatypeMisalignment(); \
  554. } else if ((((ULONG_PTR)((String).Buffer) + ((String).Length) + sizeof(UNICODE_NULL)) < (ULONG_PTR)((String).Buffer)) || \
  555. (((ULONG_PTR)((String).Buffer) + ((String).Length) + sizeof(UNICODE_NULL)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { \
  556. ExRaiseAccessViolation(); \
  557. } else if (((String).Length) > ((String).MaximumLength)) { \
  558. ExRaiseAccessViolation(); \
  559. }
  560. #else
  561. #define ProbeForReadUnicodeStringBuffer(String) \
  562. if (((ULONG_PTR)((String).Buffer) & (sizeof(WCHAR) - 1)) != 0) { \
  563. ExRaiseDatatypeMisalignment(); \
  564. } else if ((((ULONG_PTR)((String).Buffer) + ((String).Length) + sizeof(UNICODE_NULL)) < (ULONG_PTR)((String).Buffer)) || \
  565. (((ULONG_PTR)((String).Buffer) + ((String).Length) + sizeof(UNICODE_NULL)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { \
  566. ExRaiseAccessViolation(); \
  567. } else if (((String).Length) > ((String).MaximumLength)) { \
  568. ExRaiseAccessViolation(); \
  569. }
  570. #endif
  571. #if defined(_X86_)
  572. #define ProbeForReadUnicodeStringFullBuffer(String) \
  573. if (((ULONG_PTR)((String).Buffer) & (sizeof(BYTE) - 1)) != 0) { \
  574. ExRaiseDatatypeMisalignment(); \
  575. } else if ((((ULONG_PTR)((String).Buffer) + ((String).MaximumLength)) < (ULONG_PTR)((String).Buffer)) || \
  576. (((ULONG_PTR)((String).Buffer) + ((String).MaximumLength)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { \
  577. ExRaiseAccessViolation(); \
  578. } else if (((String).Length) > ((String).MaximumLength)) { \
  579. ExRaiseAccessViolation(); \
  580. }
  581. #else
  582. #define ProbeForReadUnicodeStringFullBuffer(String) \
  583. if (((ULONG_PTR)((String).Buffer) & (sizeof(WCHAR) - 1)) != 0) { \
  584. ExRaiseDatatypeMisalignment(); \
  585. } else if ((((ULONG_PTR)((String).Buffer) + ((String).MaximumLength)) < (ULONG_PTR)((String).Buffer)) || \
  586. (((ULONG_PTR)((String).Buffer) + ((String).MaximumLength)) > (ULONG_PTR)MM_USER_PROBE_ADDRESS)) { \
  587. ExRaiseAccessViolation(); \
  588. } else if (((String).Length) > ((String).MaximumLength)) { \
  589. ExRaiseAccessViolation(); \
  590. }
  591. #endif
  592. //++
  593. //
  594. // BOOLEAN
  595. // ProbeForReadUnicodeStringBufferOrId(
  596. // IN UNICODE_STRING String
  597. // )
  598. //
  599. //--
  600. #define ProbeForReadUnicodeStringBufferOrId(String) \
  601. if (IS_PTR((String).Buffer)) { \
  602. ProbeForReadUnicodeStringBuffer(String); \
  603. }
  604. //++
  605. //
  606. // BOOLEAN
  607. // ProbeAndReadCandidateForm(
  608. // IN PCANDIDATEFORM Address
  609. // )
  610. //
  611. //--
  612. #define ProbeAndReadCandidateForm(Address) \
  613. (((Address) >= (CANDIDATEFORM * const)MM_USER_PROBE_ADDRESS) ? \
  614. (*(volatile CANDIDATEFORM * const)MM_USER_PROBE_ADDRESS) : (*(volatile CANDIDATEFORM *)(Address)))
  615. //++
  616. //
  617. // BOOLEAN
  618. // ProbeAndReadCompositionForm(
  619. // IN PCANDIDATEFORM Address
  620. // )
  621. //
  622. //--
  623. #define ProbeAndReadCompositionForm(Address) \
  624. (((Address) >= (COMPOSITIONFORM * const)MM_USER_PROBE_ADDRESS) ? \
  625. (*(volatile COMPOSITIONFORM * const)MM_USER_PROBE_ADDRESS) : (*(volatile COMPOSITIONFORM *)(Address)))
  626. //++
  627. //
  628. // BOOLEAN
  629. // ProbeAndReadLogFontW(
  630. // IN PLOGFONTA Address
  631. // )
  632. //
  633. //--
  634. #define ProbeAndReadLogFontW(Address) \
  635. (((Address) >= (LOGFONTW * const)MM_USER_PROBE_ADDRESS) ? \
  636. (*(volatile LOGFONTW * const)MM_USER_PROBE_ADDRESS) : (*(volatile LOGFONTW *)(Address)))
  637. //++
  638. //
  639. // VOID
  640. // ProbeForWritePoint(
  641. // IN PPOINT Address
  642. // )
  643. //
  644. //--
  645. #define ProbeForWritePoint(Address) { \
  646. if ((Address) >= (POINT * const)MM_USER_PROBE_ADDRESS) { \
  647. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  648. } \
  649. \
  650. *(volatile POINT *)(Address) = *(volatile POINT *)(Address); \
  651. }
  652. //++
  653. //
  654. // VOID
  655. // ProbeForWriteRect(
  656. // IN PRECT Address
  657. // )
  658. //
  659. //--
  660. #define ProbeForWriteRect(Address) { \
  661. if ((Address) >= (RECT * const)MM_USER_PROBE_ADDRESS) { \
  662. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  663. } \
  664. \
  665. *(volatile RECT *)(Address) = *(volatile RECT *)(Address); \
  666. }
  667. //++
  668. //
  669. // VOID
  670. // ProbeForWriteMessage(
  671. // IN PMSG Address
  672. // )
  673. //
  674. //--
  675. #define ProbeForWriteMessage(Address) { \
  676. if ((Address) >= (MSG * const)MM_USER_PROBE_ADDRESS) { \
  677. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  678. } \
  679. \
  680. *(volatile MSG *)(Address) = *(volatile MSG *)(Address); \
  681. }
  682. //++
  683. //
  684. // VOID
  685. // ProbeForWritePaintStruct(
  686. // IN PPAINTSTRUCT Address
  687. // )
  688. //
  689. //--
  690. #define ProbeForWritePaintStruct(Address) { \
  691. if ((Address) >= (PAINTSTRUCT * const)MM_USER_PROBE_ADDRESS) { \
  692. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  693. } \
  694. \
  695. *(volatile PAINTSTRUCT *)(Address) = *(volatile PAINTSTRUCT *)(Address); \
  696. }
  697. //++
  698. //
  699. // VOID
  700. // ProbeForWriteDropStruct(
  701. // IN PDROPSTRUCT Address
  702. // )
  703. //
  704. //--
  705. #define ProbeForWriteDropStruct(Address) { \
  706. if ((Address) >= (DROPSTRUCT * const)MM_USER_PROBE_ADDRESS) { \
  707. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  708. } \
  709. \
  710. *(volatile DROPSTRUCT *)(Address) = *(volatile DROPSTRUCT *)(Address); \
  711. }
  712. //++
  713. //
  714. // VOID
  715. // ProbeForWriteScrollInfo(
  716. // IN PSCROLLINFO Address
  717. // )
  718. //
  719. //--
  720. #define ProbeForWriteScrollInfo(Address) { \
  721. if ((Address) >= (SCROLLINFO * const)MM_USER_PROBE_ADDRESS) { \
  722. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  723. } \
  724. \
  725. *(volatile SCROLLINFO *)(Address) = *(volatile SCROLLINFO *)(Address); \
  726. }
  727. //++
  728. //
  729. // VOID
  730. // ProbeForWriteStyleStruct(
  731. // IN PSTYLESTRUCT Address
  732. // )
  733. //
  734. //--
  735. #define ProbeForWriteStyleStruct(Address) { \
  736. if ((Address) >= (STYLESTRUCT * const)MM_USER_PROBE_ADDRESS) { \
  737. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  738. } \
  739. \
  740. *(volatile STYLESTRUCT *)(Address) = *(volatile STYLESTRUCT *)(Address); \
  741. }
  742. //++
  743. //
  744. // VOID
  745. // ProbeForWriteMeasureItemStruct(
  746. // IN PMEASUREITEMSTRUCT Address
  747. // )
  748. //
  749. //--
  750. #define ProbeForWriteMeasureItemStruct(Address) { \
  751. if ((Address) >= (MEASUREITEMSTRUCT * const)MM_USER_PROBE_ADDRESS) { \
  752. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  753. } \
  754. \
  755. *(volatile MEASUREITEMSTRUCT *)(Address) = *(volatile MEASUREITEMSTRUCT *)(Address);\
  756. }
  757. //++
  758. //
  759. // VOID
  760. // ProbeForWriteCreateStruct(
  761. // IN PCREATESTRUCTW Address
  762. // )
  763. //
  764. //--
  765. #define ProbeForWriteCreateStruct(Address) { \
  766. if ((Address) >= (CREATESTRUCTW * const)MM_USER_PROBE_ADDRESS) { \
  767. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  768. } \
  769. \
  770. *(volatile CREATESTRUCTW *)(Address) = *(volatile CREATESTRUCTW *)(Address);\
  771. }
  772. //++
  773. //
  774. // VOID
  775. // ProbeForWriteEvent(
  776. // IN PEVENTMSGMSG Address
  777. // )
  778. //
  779. //--
  780. #define ProbeForWriteEvent(Address) { \
  781. if ((Address) >= (EVENTMSG * const)MM_USER_PROBE_ADDRESS) { \
  782. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  783. } \
  784. \
  785. *(volatile EVENTMSG *)(Address) = *(volatile EVENTMSG *)(Address); \
  786. }
  787. //++
  788. //
  789. // VOID
  790. // ProbeForWriteWindowPlacement(
  791. // IN PWINDOWPLACEMENT Address
  792. // )
  793. //
  794. //--
  795. #define ProbeForWriteWindowPlacement(Address) { \
  796. if ((Address) >= (WINDOWPLACEMENT * const)MM_USER_PROBE_ADDRESS) { \
  797. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  798. } \
  799. \
  800. *(volatile WINDOWPLACEMENT *)(Address) = *(volatile WINDOWPLACEMENT *)(Address);\
  801. }
  802. //++
  803. //
  804. // VOID
  805. // ProbeForWriteGetClipData(
  806. // IN PGETCLIPBDATA Address
  807. // )
  808. //
  809. //--
  810. #define ProbeForWriteGetClipData(Address) { \
  811. if ((Address) >= (GETCLIPBDATA * const)MM_USER_PROBE_ADDRESS) { \
  812. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  813. } \
  814. \
  815. *(volatile GETCLIPBDATA *)(Address) = *(volatile GETCLIPBDATA *)(Address);\
  816. }
  817. //++
  818. //
  819. // VOUD
  820. // ProbeForWriteBroadcastSystemMsgParams(
  821. // IN LPBROADCASTSYSTEMMSGPARAMS Address
  822. // )
  823. //
  824. //--
  825. #define ProbeForWriteBroadcastSystemMsgParams(Address) { \
  826. if ((Address) >= (BROADCASTSYSTEMMSGPARAMS * const)MM_USER_PROBE_ADDRESS) { \
  827. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  828. } \
  829. \
  830. *(volatile BROADCASTSYSTEMMSGPARAMS *)(Address) = *(volatile BROADCASTSYSTEMMSGPARAMS *)(Address); \
  831. }
  832. //++
  833. //
  834. // VOID
  835. // ProbeForWriteMDINextMenu(
  836. // IN PMDINEXTMENU Address
  837. // )
  838. //
  839. //--
  840. #define ProbeForWriteMDINextMenu(Address) { \
  841. if ((Address) >= (MDINEXTMENU * const)MM_USER_PROBE_ADDRESS) { \
  842. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  843. } \
  844. \
  845. *(volatile MDINEXTMENU *)(Address) = *(volatile MDINEXTMENU *)(Address); \
  846. }
  847. //++
  848. //
  849. // VOID
  850. // ProbeForWritePoint5(
  851. // IN PPOINT5 Address
  852. // )
  853. //
  854. //--
  855. #define ProbeForWritePoint5(Address) { \
  856. if ((Address) >= (POINT5 * const)MM_USER_PROBE_ADDRESS) { \
  857. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  858. } \
  859. \
  860. *(volatile POINT5 *)(Address) = *(volatile POINT5 *)(Address);\
  861. }
  862. //++
  863. //
  864. // VOID
  865. // ProbeForWriteNCCalcSize(
  866. // IN PNCCALCSIZE_PARAMS Address
  867. // )
  868. //
  869. //--
  870. #define ProbeForWriteNCCalcSize(Address) { \
  871. if ((Address) >= (NCCALCSIZE_PARAMS * const)MM_USER_PROBE_ADDRESS) { \
  872. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  873. } \
  874. \
  875. *(volatile NCCALCSIZE_PARAMS *)(Address) = *(volatile NCCALCSIZE_PARAMS *)(Address);\
  876. }
  877. //++
  878. //
  879. // VOID
  880. // ProbeForWriteWindowPos(
  881. // IN PWINDOWPOS Address
  882. // )
  883. //
  884. //--
  885. #define ProbeForWriteWindowPos(Address) { \
  886. if ((Address) >= (WINDOWPOS * const)MM_USER_PROBE_ADDRESS) { \
  887. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  888. } \
  889. \
  890. *(volatile WINDOWPOS *)(Address) = *(volatile WINDOWPOS *)(Address);\
  891. }
  892. #define ProbeForWriteComboBoxInfo(Address) { \
  893. if ((Address) >= (COMBOBOXINFO * const)MM_USER_PROBE_ADDRESS) { \
  894. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  895. } \
  896. \
  897. *(volatile COMBOBOXINFO *)(Address) = *(volatile COMBOBOXINFO *)(Address); \
  898. }
  899. #define ProbeForWriteScrollBarInfo(Address) { \
  900. if ((Address) >= (SCROLLBARINFO * const)MM_USER_PROBE_ADDRESS) { \
  901. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  902. } \
  903. \
  904. *(volatile SCROLLBARINFO *)(Address) = *(volatile SCROLLBARINFO *)(Address); \
  905. }
  906. //++
  907. //
  908. // VOID
  909. // ProbeForWriteCandidateForm(
  910. // IN PCANDIDATEFORM Address
  911. // )
  912. //
  913. //--
  914. #define ProbeForWriteCandidateForm(Address) { \
  915. if ((Address) >= (CANDIDATEFORM * const)MM_USER_PROBE_ADDRESS) { \
  916. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  917. } \
  918. \
  919. *(volatile CANDIDATEFORM *)(Address) = *(volatile CANDIDATEFORM *)(Address); \
  920. }
  921. //++
  922. //
  923. // VOID
  924. // ProbeForWriteCompositionForm(
  925. // IN PCOMPOSITIONFORM Address
  926. // )
  927. //
  928. //--
  929. #define ProbeForWriteCompositionForm(Address) { \
  930. if ((Address) >= (COMPOSITIONFORM * const)MM_USER_PROBE_ADDRESS) { \
  931. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  932. } \
  933. \
  934. *(volatile COMPOSITIONFORM *)(Address) = *(volatile COMPOSITIONFORM *)(Address);\
  935. }
  936. //++
  937. //
  938. // VOID
  939. // ProbeForWriteLogFontW(
  940. // IN PLOGFONTW Address
  941. // )
  942. //
  943. //--
  944. #define ProbeForWriteLogFontW(Address) { \
  945. if ((Address) >= (LOGFONTW * const)MM_USER_PROBE_ADDRESS) { \
  946. *(volatile ULONG * const)MM_USER_PROBE_ADDRESS = 0; \
  947. } \
  948. \
  949. *(volatile LOGFONTW *)(Address) = *(volatile LOGFONTW *)(Address); \
  950. }
  951. //++
  952. //
  953. // VOID
  954. // ProbeForWriteReconvertString(IN PRECONVERTSTRING Address)
  955. //
  956. //--
  957. #define ProbeForWriteReconvertString(Address) { \
  958. if ((Address) >= (RECONVERTSTRING* const)MM_USER_PROBE_ADDRESS) { \
  959. *(volatile ULONG* const)MM_USER_PROBE_ADDRESS = 0; \
  960. } \
  961. \
  962. *(volatile RECONVERTSTRING*)(Address) = *(volatile RECONVERTSTRING*)(Address); \
  963. *((volatile BYTE*)(Address) + (Address)->dwSize) = *((volatile BYTE*)(Address) + (Address)->dwSize); \
  964. }
  965. #define ProbeForReadReconvertString(pReconv) \
  966. ProbeForRead((pReconv), (pReconv)->dwSize, 1)
  967. //++
  968. //
  969. // VOID
  970. // ProbeForWriteImeCharPosition(IN LPPrivateIMECHARPOSITION Address)
  971. //
  972. //--
  973. #define ProbeForWriteImeCharPosition(Address) { \
  974. if ((Address) >= (PrivateIMECHARPOSITION* const)MM_USER_PROBE_ADDRESS) { \
  975. *(volatile ULONG* const)MM_USER_PROBE_ADDRESS = 0; \
  976. } \
  977. \
  978. *(volatile PrivateIMECHARPOSITION*)(Address) = *(volatile PrivateIMECHARPOSITION*)(Address); \
  979. }
  980. //++
  981. //
  982. // VOID
  983. // ProbeAndReadMenuGetObjectInfo(
  984. // IN PMENUGETOBJECTINFO Address
  985. // )
  986. //
  987. //--
  988. #define ProbeAndReadMenuGetObjectInfo(Address) \
  989. (((Address) >= (MENUGETOBJECTINFO * const)MM_USER_PROBE_ADDRESS) ? \
  990. (*(volatile MENUGETOBJECTINFO * const)MM_USER_PROBE_ADDRESS) : (*(volatile MENUGETOBJECTINFO *)(Address)))
  991. /*
  992. * This macro makes sure an object is thread locked. DEBUG only.
  993. */
  994. #if DBG
  995. VOID CheckLock(PVOID pobj);
  996. #else // DBG
  997. #define CheckLock(p)
  998. #endif // DBG
  999. /*
  1000. * Debug macros
  1001. */
  1002. #if DBG
  1003. #define TRACE_INIT(str) { if (TraceInitialization > 0) { KdPrint(str); }}
  1004. #define TRACE_SWITCH(str) { if (TraceFullscreenSwitch > 0) { KdPrint(str); }}
  1005. extern PCSZ apszSimpleCallNames[];
  1006. #define TRACE(s) TAGMSG2(DBGTAG_StubReturn, "%s, retval = %x", (s), retval)
  1007. #define TRACEVOID(s) TAGMSG1(DBGTAG_StubReturn, "%s", (s))
  1008. #define TRACETHUNK(t) \
  1009. TAGMSG3(DBGTAG_StubThunk, \
  1010. "Thunk %s, %s(%s)", \
  1011. (t), \
  1012. (xpfnProc >= FNID_START && xpfnProc <= FNID_END ? \
  1013. gapszFNID[xpfnProc - FNID_START] : "Unknown"), \
  1014. (msg >= WM_USER ? "WM_USER" : gapszMessage[msg]))
  1015. #define TRACECALLBACK(s) TAGMSG2(DBGTAG_StubCallback, "%s, retval = %x", (s), retval)
  1016. #define TRACECALLBACKMSG(s) \
  1017. TAGMSG4(DBGTAG_StubCallback, \
  1018. "Callback %s, %s(%s), retval = %x", \
  1019. (s), \
  1020. (xpfnProc >= (PROC)FNID_START && xpfnProc <= (PROC)FNID_END ? \
  1021. gapszFNID[(ULONG_PTR)xpfnProc - FNID_START] : "Unknown"), \
  1022. (msg >= WM_USER ? "WM_USER" : gapszMessage[msg]), \
  1023. retval)
  1024. #else // DBG
  1025. #define TRACE_INIT(str) {}
  1026. #define TRACE_SWITCH(str) {}
  1027. #define TRACE(s)
  1028. #define TRACEVOID(s)
  1029. #define TRACETHUNK(t)
  1030. #define TRACECALLBACK(t)
  1031. #define TRACECALLBACKMSG(t)
  1032. #endif // DBG
  1033. /*
  1034. * Statistics for performance counter
  1035. */
  1036. typedef struct tagPERFINFO {
  1037. LONG lCount;
  1038. LONG lMaxCount;
  1039. LONG lTotalCount;
  1040. SIZE_T lSize;
  1041. } PERFHANDLEINFO, *PPERFHANDLEINFO;
  1042. typedef struct _HANDLEPAGE {
  1043. ULONG_PTR iheLimit; /* first handle index past the end of the page */
  1044. ULONG_PTR iheFreeEven; /* first even free handle in the page -- window objects */
  1045. ULONG_PTR iheFreeOdd; /* first even odd handle in the page */
  1046. } HANDLEPAGE, *PHANDLEPAGE;
  1047. #if DBG || FRE_LOCK_RECORD
  1048. VOID HMCleanUpHandleTable(VOID);
  1049. DWORD DbgDumpHandleTable(VOID);
  1050. #endif
  1051. BOOL HMInitHandleTable(PVOID pBase);
  1052. PVOID HMAllocObject(PTHREADINFO pti, PDESKTOP pdesk, BYTE btype, DWORD size);
  1053. BOOL HMFreeObject(PVOID pobj);
  1054. BOOL HMMarkObjectDestroy(PVOID pobj);
  1055. BOOL HMDestroyObject(PVOID pobj);
  1056. PVOID FASTCALL HMAssignmentLock(PVOID *ppobj, PVOID pobj);
  1057. PVOID FASTCALL HMAssignmentUnlock(PVOID *ppobj);
  1058. void HMDestroyUnlockedObject(PHE phe);
  1059. void HMCleanupGrantedHandle(HANDLE h);
  1060. /*
  1061. * Validation, handle mapping, etc.
  1062. */
  1063. #define RevalidateHwnd(hwnd) HMValidateHandleNoSecure(hwnd, TYPE_WINDOW)
  1064. #define RevalidateCatHwnd(hwnd) HMValidateCatHandleNoSecure(hwnd, TYPE_WINDOW)
  1065. #define HtoPq(h) ((PVOID)HMObjectFromHandle(h))
  1066. #define HtoPqCat(h) ((PVOID)HMCatObjectFromHandle(h))
  1067. #define HtoP(h) ((PVOID)HMObjectFromHandle(h))
  1068. #define HtoPCat(h) ((PVOID)HMCatObjectFromHandle(h))
  1069. #define PW(hwnd) ((PWND)HtoP(hwnd))
  1070. #define PWCat(hwnd) ((PWND)HtoPCat(hwnd))
  1071. #define TID(pti) HandleToUlong((pti) == NULL ? NULL : (PsGetThreadId((pti)->pEThread)))
  1072. #define TIDq(pti) HandleToUlong(PsGetThreadId((pti)->pEThread))
  1073. /*
  1074. * Assignment lock macro -> used for locking objects embedded in structures
  1075. * and globals. Threadlocks used for locking objects across callbacks.
  1076. */
  1077. #define Lock(ppobj, pobj) HMAssignmentLock((PVOID *)ppobj, (PVOID)pobj)
  1078. #define Unlock(ppobj) HMAssignmentUnlock((PVOID *)ppobj)
  1079. PVOID HMUnlockObjectInternal(PVOID pobj);
  1080. #define HMUnlockObject(pobj) \
  1081. ( (--((PHEAD)pobj)->cLockObj == 0) ? HMUnlockObjectInternal(pobj) : pobj )
  1082. VOID HMChangeOwnerThread(PVOID pobj, PTHREADINFO pti);
  1083. VOID HMChangeOwnerPheProcess(PHE phe, PTHREADINFO pti);
  1084. #define HMChangeOwnerProcess(pobj, pti) HMChangeOwnerPheProcess(HMPheFromObject(pobj), pti)
  1085. #if DBG
  1086. VOID HMLockObject(PVOID pobj);
  1087. BOOL HMRelocateLockRecord(PVOID ppobjOld, LONG_PTR cbDelta);
  1088. #else // DBG
  1089. #define HMLockObject(p) (((PHEAD)p)->cLockObj++)
  1090. #endif // DBG
  1091. #if DBG
  1092. VOID ThreadLock(PVOID pobj, PTL ptl);
  1093. #else // DBG
  1094. #define ThreadLock(_pobj_, _ptl_) \
  1095. { \
  1096. PTHREADINFO _pti_; \
  1097. PVOID __pobj_ = (_pobj_); \
  1098. \
  1099. _pti_ = PtiCurrent(); \
  1100. (_ptl_)->next = _pti_->ptl; \
  1101. _pti_->ptl = (_ptl_); \
  1102. (_ptl_)->pobj = __pobj_; \
  1103. if (__pobj_ != NULL) { \
  1104. HMLockObject(__pobj_); \
  1105. } \
  1106. }
  1107. #endif // DBG
  1108. #if DBG
  1109. #define ThreadLockAlways(_pobj_, _ptl_) \
  1110. { \
  1111. PVOID __pobj_ = (_pobj_); \
  1112. UserAssert(__pobj_ != NULL); \
  1113. ThreadLock(__pobj_, _ptl_); \
  1114. }
  1115. #else // DBG
  1116. #define ThreadLockAlways(_pobj_, _ptl_) \
  1117. { \
  1118. PTHREADINFO _pti_; \
  1119. PVOID __pobj_ = (_pobj_); \
  1120. \
  1121. _pti_ = PtiCurrent(); \
  1122. (_ptl_)->next = _pti_->ptl; \
  1123. _pti_->ptl = (_ptl_); \
  1124. (_ptl_)->pobj = __pobj_; \
  1125. HMLockObject(__pobj_); \
  1126. }
  1127. #endif // DBG
  1128. #if DBG
  1129. #define ThreadLockNever(_ptl_) \
  1130. { \
  1131. ThreadLock(NULL, _ptl_); \
  1132. }
  1133. #else // DBG
  1134. #define ThreadLockNever(_ptl_) \
  1135. { \
  1136. PTHREADINFO _pti_; \
  1137. \
  1138. _pti_ = PtiCurrent(); \
  1139. (_ptl_)->next = _pti_->ptl; \
  1140. _pti_->ptl = (_ptl_); \
  1141. (_ptl_)->pobj = NULL; \
  1142. }
  1143. #endif // DBG
  1144. #if DBG
  1145. #define ThreadLockAlwaysWithPti(_pti_, _pobj_, _ptl_) \
  1146. { \
  1147. PVOID __pobj_ = (_pobj_); \
  1148. UserAssert(_pti_ == PtiCurrentShared()); \
  1149. UserAssert(__pobj_ != NULL); \
  1150. ThreadLock(__pobj_, _ptl_); \
  1151. }
  1152. #else // DBG
  1153. #define ThreadLockAlwaysWithPti(_pti_, _pobj_, _ptl_) \
  1154. { \
  1155. PVOID __pobj_ = (_pobj_); \
  1156. (_ptl_)->next = _pti_->ptl; \
  1157. _pti_->ptl = (_ptl_); \
  1158. (_ptl_)->pobj = __pobj_; \
  1159. HMLockObject(__pobj_); \
  1160. }
  1161. #endif // DBG
  1162. #if DBG
  1163. #define ThreadLockNeverWithPti(_pti_, _ptl_) \
  1164. { \
  1165. UserAssert(_pti_ == PtiCurrentShared()); \
  1166. ThreadLock(NULL, _ptl_); \
  1167. }
  1168. #else // DBG
  1169. #define ThreadLockNeverWithPti(_pti_, _ptl_) \
  1170. { \
  1171. (_ptl_)->next = _pti_->ptl; \
  1172. _pti_->ptl = (_ptl_); \
  1173. (_ptl_)->pobj = NULL; \
  1174. }
  1175. #endif // DBG
  1176. #if DBG
  1177. #define ThreadLockWithPti(_pti_, _pobj_, _ptl_) \
  1178. { \
  1179. PVOID __pobj_ = (_pobj_); \
  1180. UserAssert(_pti_ == PtiCurrentShared()); \
  1181. ThreadLock(__pobj_, _ptl_); \
  1182. }
  1183. #else // DBG
  1184. #define ThreadLockWithPti(_pti_, _pobj_, _ptl_) \
  1185. { \
  1186. PVOID __pobj_ = (_pobj_); \
  1187. (_ptl_)->next = _pti_->ptl; \
  1188. _pti_->ptl = (_ptl_); \
  1189. (_ptl_)->pobj = __pobj_; \
  1190. if (__pobj_ != NULL) { \
  1191. HMLockObject(__pobj_); \
  1192. } \
  1193. }
  1194. #endif // DBG
  1195. #if DBG
  1196. PVOID ThreadLockExchange(PVOID pobj, PTL ptl);
  1197. #else // DBG
  1198. __inline PVOID ThreadLockExchange(PVOID pobj, PTL ptl)
  1199. {
  1200. PVOID pobjOld;
  1201. pobjOld = ptl->pobj;
  1202. ptl->pobj = pobj;
  1203. if (pobj) {
  1204. HMLockObject(pobj);
  1205. }
  1206. if (pobjOld) {
  1207. pobjOld = HMUnlockObject((PHEAD)pobjOld);
  1208. }
  1209. return pobjOld;
  1210. }
  1211. #endif // DBG
  1212. #if DBG
  1213. #define ThreadLockExchangeAlways(_pobj_, _ptl_) \
  1214. { \
  1215. PVOID __pobj_ = (_pobj_); \
  1216. UserAssert(__pobj_ != NULL); \
  1217. ThreadLockExchange(__pobj_, _ptl_); \
  1218. }
  1219. #else // DBG
  1220. __inline PVOID ThreadLockExchangeAlways(PVOID pobj, PTL ptl)
  1221. {
  1222. PVOID pobjOld;
  1223. pobjOld = ptl->pobj;
  1224. ptl->pobj = pobj;
  1225. HMLockObject(pobj);
  1226. if (pobjOld) {
  1227. pobjOld = HMUnlockObject((PHEAD)pobjOld);
  1228. }
  1229. return pobjOld;
  1230. }
  1231. #endif // DBG
  1232. #if DBG
  1233. PVOID ThreadUnlock1(PTL ptl);
  1234. #define ThreadUnlock(ptl) ThreadUnlock1(ptl)
  1235. #else // DBG
  1236. PVOID ThreadUnlock1(VOID);
  1237. #define ThreadUnlock(ptl) ThreadUnlock1()
  1238. #endif // DBG
  1239. /*
  1240. * Define this only if you want to track down lock/unlock mismatches
  1241. * for desktop objects.
  1242. */
  1243. #ifdef LOGDESKTOPLOCKS
  1244. /*
  1245. * This is the structure used by the desktop logging stuff.
  1246. */
  1247. typedef struct tagLogD {
  1248. WORD tag; // tag
  1249. WORD type; // lock | unlock
  1250. ULONG_PTR extra; // extra information to identify the lock/unlock
  1251. PVOID trace[6]; // stack trace
  1252. } LogD, *PLogD;
  1253. /*
  1254. * Tags for LOCK/UNLOCK REFERENCE/DEREFERENCE calls for desktop objects.
  1255. */
  1256. #define LDU_CLS_DESKPARENT1 1
  1257. #define LDL_CLS_DESKPARENT1 2
  1258. #define LDU_CLS_DESKPARENT2 3
  1259. #define LDL_CLS_DESKPARENT2 5
  1260. #define LDU_FN_DESTROYCLASS 6
  1261. #define LDL_FN_DESTROYCLASS 7
  1262. #define LDU_FN_DESTROYMENU 8
  1263. #define LDL_FN_DESTROYMENU 9
  1264. #define LDU_FN_DESTROYTHREADINFO 10
  1265. #define LDL_FN_DESTROYTHREADINFO 11
  1266. #define LDU_FN_DESTROYWINDOWSTATION 12
  1267. #define LDL_FN_DESTROYWINDOWSTATION 13
  1268. #define LDU_DESKDISCONNECT 14
  1269. #define LDL_DESKDISCONNECT 15
  1270. #define LDU_DESK_DESKNEXT 16
  1271. #define LDL_DESK_DESKNEXT1 17
  1272. #define LDU_OBJ_DESK 18
  1273. #define LDL_OBJ_DESK 19
  1274. #define LDL_MOTHERDESK_DESK1 20
  1275. #define LDL_PTI_DESK 21
  1276. #define LDL_DT_DESK 23
  1277. #define LDU_PTI_DESK 24
  1278. #define LDU_PPI_DESKSTARTUP1 26
  1279. #define LDU_PPI_DESKSTARTUP2 27
  1280. #define LDU_PPI_DESKSTARTUP3 28
  1281. #define LDL_PPI_DESKSTARTUP1 29
  1282. #define LDL_PPI_DESKSTARTUP2 30
  1283. #define LDU_DESKLOGON 31
  1284. #define LDL_DESKLOGON 32
  1285. #define LDUT_FN_FREEWINDOW 33
  1286. #define LDLT_FN_FREEWINDOW 34
  1287. #define LDUT_FN_DESKTOPTHREAD_DESK 35
  1288. #define LDLT_FN_DESKTOPTHREAD_DESK 36
  1289. #define LDUT_FN_DESKTOPTHREAD_DESKTEMP 37
  1290. #define LDLT_FN_DESKTOPTHREAD_DESKTEMP 38
  1291. #define LDUT_FN_SETDESKTOP 39
  1292. #define LDLT_FN_SETDESKTOP 40
  1293. #define LDUT_FN_NTUSERSWITCHDESKTOP 41
  1294. #define LDLT_FN_NTUSERSWITCHDESKTOP 42
  1295. #define LDUT_FN_SENDMESSAGEBSM1 43
  1296. #define LDUT_FN_SENDMESSAGEBSM2 44
  1297. #define LDLT_FN_SENDMESSAGEBSM 45
  1298. #define LDUT_FN_SYSTEMBROADCASTMESSAGE 46
  1299. #define LDLT_FN_SYSTEMBROADCASTMESSAGE 47
  1300. #define LDUT_FN_CTXREDRAWSCREEN 48
  1301. #define LDLT_FN_CTXREDRAWSCREEN 49
  1302. #define LDUT_FN_CTXDISABLESCREEN 50
  1303. #define LDLT_FN_CTXDISABLESCREEN 51
  1304. #define LD_DEREF_FN_CREATEDESKTOP1 52
  1305. #define LD_DEREF_FN_CREATEDESKTOP2 53
  1306. #define LD_DEREF_FN_CREATEDESKTOP3 54
  1307. #define LD_REF_FN_CREATEDESKTOP 55
  1308. #define LD_DEREF_FN_OPENDESKTOP 56
  1309. #define LD_REF_FN_OPENDESKTOP 57
  1310. #define LD_DEREF_FN_SETDESKTOP 58
  1311. #define LD_REF_FN_SETDESKTOP 59
  1312. #define LD_DEREF_FN_GETTHREADDESKTOP 60
  1313. #define LD_REF_FN_GETTHREADDESKTOP 61
  1314. #define LD_DEREF_FN_CLOSEDESKTOP1 62
  1315. #define LD_DEREF_FN_CLOSEDESKTOP2 63
  1316. #define LD_REF_FN_CLOSEDESKTOP 64
  1317. #define LD_DEREF_FN_RESOLVEDESKTOP 65
  1318. #define LD_REF_FN_RESOLVEDESKTOP 66
  1319. #define LD_DEREF_VALIDATE_HDESK1 67
  1320. #define LD_DEREF_VALIDATE_HDESK2 68
  1321. #define LD_DEREF_VALIDATE_HDESK3 69
  1322. #define LD_DEREF_VALIDATE_HDESK4 70
  1323. #define LDL_VALIDATE_HDESK 71
  1324. #define LDUT_FN_CREATETHREADINFO1 72
  1325. #define LDUT_FN_CREATETHREADINFO2 73
  1326. #define LDLT_FN_CREATETHREADINFO 74
  1327. #define LD_DEREF_FN_SETCSRSSTHREADDESKTOP1 75
  1328. #define LD_DEREF_FN_SETCSRSSTHREADDESKTOP2 76
  1329. #define LD_REF_FN_SETCSRSSTHREADDESKTOP 77
  1330. #define LD_DEREF_FN_CONSOLECONTROL1 78
  1331. #define LD_REF_FN_CONSOLECONTROL1 79
  1332. #define LD_DEREF_FN_CONSOLECONTROL2 80
  1333. #define LD_REF_FN_CONSOLECONTROL2 81
  1334. #define LD_DEREF_FN_GETUSEROBJECTINFORMATION 82
  1335. #define LD_REF_FN_GETUSEROBJECTINFORMATION 83
  1336. #define LD_DEREF_FN_SETUSEROBJECTINFORMATION 84
  1337. #define LD_REF_FN_SETUSEROBJECTINFORMATION 85
  1338. #define LD_DEREF_FN_CREATEWINDOWSTATION 86
  1339. #define LD_REF_FN_CREATEWINDOWSTATION 87
  1340. #define LDL_TERM_DESKDESTROY1 88
  1341. #define LDL_TERM_DESKDESTROY2 89
  1342. #define LDL_MOTHERDESK_DESK2 92
  1343. #define LDL_WINSTA_DESKLIST2 93
  1344. #define LDL_WINSTA_DESKLIST1 94
  1345. #define LDL_DESKRITINPUT 95
  1346. #define LDU_DESKRITINPUT 96
  1347. #define LD_DEREF_FN_2CREATEDESKTOP 97
  1348. #define LDL_DESK_DESKNEXT2 98
  1349. #define LDL_DESKSHOULDBEFOREGROUND1 99
  1350. #define LDL_DESKSHOULDBEFOREGROUND2 100
  1351. #define LDL_DESKSHOULDBEFOREGROUND3 101
  1352. #define LDL_HOOK_DESK 102
  1353. #define LDU_HOOK_DESK 103
  1354. #define LDU_DESKSHOULDBEFOREGROUND 105
  1355. #define LDU_MOTHERDESK_DESK 106
  1356. void LogDesktop(PDESKTOP pdesk, DWORD tag, BOOL bLock, ULONG_PTR extra);
  1357. #else
  1358. #define LogDesktop(pdesk, tag, bLock, extra)
  1359. #endif // LOGDESKTOPLOCKS
  1360. /*
  1361. * Routines for referencing and assigning kernel objects.
  1362. */
  1363. #ifdef LOGDESKTOPLOCKS
  1364. VOID LockObjectAssignment(PVOID*, PVOID, DWORD, ULONG_PTR);
  1365. VOID UnlockObjectAssignment(PVOID*, DWORD, ULONG_PTR);
  1366. #else
  1367. VOID LockObjectAssignment(PVOID*, PVOID);
  1368. VOID UnlockObjectAssignment(PVOID*);
  1369. #endif
  1370. VOID UserDereferenceObject(PVOID pobj);
  1371. #define ThreadLockObject(pobj, ptl) \
  1372. { \
  1373. UserAssert(!(PpiCurrent()->W32PF_Flags & W32PF_TERMINATED)); \
  1374. UserAssert(pobj == NULL || OBJECT_TO_OBJECT_HEADER(pobj)->PointerCount != 0); \
  1375. PushW32ThreadLock(pobj, ptl, UserDereferenceObject); \
  1376. if (pobj != NULL) { \
  1377. ObReferenceObject(pobj); \
  1378. } \
  1379. }
  1380. #define ThreadLockExchangeObject(pobj, ptl) \
  1381. { \
  1382. UserAssert(!(PpiCurrent()->W32PF_Flags & W32PF_TERMINATED)); \
  1383. UserAssert(pobj == NULL || OBJECT_TO_OBJECT_HEADER(pobj)->PointerCount != 0); \
  1384. if (pobj != NULL) { \
  1385. ObReferenceObject(pobj); \
  1386. } \
  1387. ExchangeW32ThreadLock(pobj, ptl); \
  1388. }
  1389. #define ThreadUnlockObject(ptl) \
  1390. { \
  1391. PopAndFreeW32ThreadLock(ptl); \
  1392. } \
  1393. #ifdef LOGDESKTOPLOCKS
  1394. #define UnlockWinSta(ppwinsta) \
  1395. UnlockObjectAssignment(ppwinsta, 0, 0)
  1396. #define LockWinSta(ppwinsta, pwinsta) \
  1397. { \
  1398. if (pwinsta != NULL) \
  1399. { \
  1400. UserAssert(OBJECT_TO_OBJECT_HEADER(pwinsta)->Type == *ExWindowStationObjectType); \
  1401. } \
  1402. LockObjectAssignment(ppwinsta, pwinsta, 0, 0); \
  1403. }
  1404. #define LockDesktop(ppdesk, pdesk, tag, extra) \
  1405. { \
  1406. if (pdesk != NULL) \
  1407. { \
  1408. UserAssert(OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType); \
  1409. } \
  1410. LockObjectAssignment(ppdesk, pdesk, tag, extra); \
  1411. }
  1412. #define UnlockDesktop(ppdesk, tag, extra) \
  1413. UnlockObjectAssignment(ppdesk, tag, extra)
  1414. #define ThreadLockDesktop(pti, pdesk, ptl, tag) \
  1415. { \
  1416. UserAssert(pdesk == NULL || OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType);\
  1417. ThreadLockObject(pdesk, ptl); \
  1418. LogDesktop(pdesk, tag, TRUE, (ULONG_PTR)PtiCurrent()); \
  1419. }
  1420. #define ThreadLockExchangeDesktop(pti, pdesk, ptl, tag) \
  1421. { \
  1422. UserAssert(pdesk == NULL || OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType);\
  1423. ThreadLockExchangeObject(pdesk, ptl); \
  1424. LogDesktop(pdesk, tag, TRUE, (ULONG_PTR)PtiCurrent()); \
  1425. }
  1426. #define ThreadUnlockDesktop(pti, ptl, tag) \
  1427. { \
  1428. LogDesktop((PDESKTOP)(((PTL)ptl)->pobj), tag, FALSE, (ULONG_PTR)PtiCurrent()); \
  1429. ThreadUnlockObject(ptl); \
  1430. }
  1431. #else
  1432. #define UnlockWinSta(ppwinsta) \
  1433. UnlockObjectAssignment(ppwinsta)
  1434. #define LockWinSta(ppwinsta, pwinsta) \
  1435. { \
  1436. if (pwinsta != NULL) \
  1437. { \
  1438. UserAssert(OBJECT_TO_OBJECT_HEADER(pwinsta)->Type == *ExWindowStationObjectType); \
  1439. } \
  1440. LockObjectAssignment(ppwinsta, pwinsta); \
  1441. }
  1442. #define LockDesktop(ppdesk, pdesk, tag, extra) \
  1443. { \
  1444. if (pdesk != NULL) \
  1445. { \
  1446. UserAssert(OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType); \
  1447. } \
  1448. LockObjectAssignment(ppdesk, pdesk); \
  1449. }
  1450. #define UnlockDesktop(ppdesk, tag, extra) \
  1451. UnlockObjectAssignment(ppdesk)
  1452. #define ThreadLockDesktop(pti, pdesk, ptl, tag) \
  1453. { \
  1454. UserAssert(pdesk == NULL || OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType);\
  1455. ThreadLockObject(pdesk, ptl); \
  1456. }
  1457. #define ThreadLockExchangeDesktop(pti, pdesk, ptl, tag) \
  1458. { \
  1459. UserAssert(pdesk == NULL || OBJECT_TO_OBJECT_HEADER(pdesk)->Type == *ExDesktopObjectType);\
  1460. ThreadLockExchangeObject(pdesk, ptl); \
  1461. }
  1462. #define ThreadUnlockDesktop(pti, ptl, tag) ThreadUnlockObject(ptl)
  1463. #endif // LOGDESKTOPLOCKS
  1464. #define ThreadLockWinSta(pti, pwinsta, ptl) \
  1465. { \
  1466. UserAssert(pwinsta == NULL || OBJECT_TO_OBJECT_HEADER(pwinsta)->Type == *ExWindowStationObjectType);\
  1467. ThreadLockObject(pwinsta, ptl); \
  1468. }
  1469. #define ThreadLockExchangeWinSta(pti, pwinsta, ptl) \
  1470. { \
  1471. UserAssert(pwinsta == NULL || OBJECT_TO_OBJECT_HEADER(pwinsta)->Type == *ExWindowStationObjectType);\
  1472. ThreadLockExchangeObject(pwinsta, ptl); \
  1473. }
  1474. #define _ThreadLockPti(pti, pobj, ptl) LockW32Thread((PW32THREAD)pobj, ptl)
  1475. #if DBG
  1476. #define ThreadLockPti(pti, pobj, ptl) \
  1477. { \
  1478. if ((pobj != NULL) \
  1479. && (pobj->TIF_flags & TIF_INCLEANUP) \
  1480. && (pobj != PtiCurrent())) { \
  1481. RIPMSG1(RIP_ERROR, "ThreadLockPti: dead thread %#p", pobj); \
  1482. } \
  1483. _ThreadLockPti(pti, pobj, ptl); \
  1484. }
  1485. #else
  1486. #define ThreadLockPti(pti, pobj, ptl) \
  1487. { \
  1488. _ThreadLockPti(pti, pobj, ptl); \
  1489. }
  1490. #endif
  1491. #define ThreadLockExchangePti(pobj, ptl) LockExchangeW32Thread((PW32THREAD)pobj, ptl)
  1492. #define ThreadUnlockWinSta(pti, ptl) ThreadUnlockObject(ptl)
  1493. #define ThreadUnlockPti(pti, ptl) UnlockW32Thread(ptl)
  1494. /*
  1495. * Macros for locking pool allocations
  1496. */
  1497. #define ThreadLockPool(_pti_, _ppool_, _ptl_) \
  1498. PushW32ThreadLock(_ppool_, _ptl_, UserFreePool)
  1499. #define ThreadUnlockPool(_pti_, _ptl_) \
  1500. PopW32ThreadLock(_ptl_)
  1501. #define ThreadUnlockAndFreePool(_pti_, _ptl_) \
  1502. PopAndFreeAlwaysW32ThreadLock(_ptl_)
  1503. #define ThreadLockPoolCleanup(_pti_, _ppool_, _ptl_, _pfn_) \
  1504. PushW32ThreadLock(_ppool_, _ptl_, _pfn_)
  1505. #define ThreadUnlockPoolCleanup(_pti_, _ptl_) \
  1506. PopW32ThreadLock(_ptl_)
  1507. #define ThreadUnlockAndCleanupPool(_pti_, _ptl_) \
  1508. PopAndFreeAlwaysW32ThreadLock(_ptl_)
  1509. #define ThreadLockDesktopHandle(_pti, _ptl_, _hdesk_) \
  1510. PushW32ThreadLock(_hdesk_, _ptl_, CloseProtectedHandle)
  1511. #define ThreadUnlockDesktopHandle(_ptl_) \
  1512. PopAndFreeAlwaysW32ThreadLock(_ptl_)
  1513. void CleanupDecSFWLockCount(PVOID pIgnore);
  1514. #define ThreadLockSFWLockCount(_ptl_) \
  1515. { \
  1516. IncSFWLockCount(); \
  1517. /* Pass a fake pObj or the cleanup function won't be called */ \
  1518. PushW32ThreadLock(&guSFWLockCount, _ptl_, CleanupDecSFWLockCount); \
  1519. }
  1520. #define ThreadUnlockSFWLockCount(_ptl_) \
  1521. { \
  1522. DecSFWLockCount(); \
  1523. PopW32ThreadLock(_ptl_); \
  1524. }
  1525. /*
  1526. * special handle that signifies we have a rle bitmap for the wallpaper
  1527. */
  1528. #define HBITMAP_RLE ((HBITMAP)0xffffffff)
  1529. typedef struct tagWPINFO {
  1530. int xsize, ysize;
  1531. PBITMAPINFO pbmi;
  1532. PBYTE pdata;
  1533. PBYTE pbmfh;
  1534. } WPINFO;
  1535. /*
  1536. * Defines used by GetMouseMovePointsEx API
  1537. */
  1538. #define MAX_MOUSEPOINTS 64
  1539. #define PREVPOINT(i) \
  1540. ((i == 0) ? (MAX_MOUSEPOINTS - 1) : ((i - 1) % MAX_MOUSEPOINTS))
  1541. #define NEXTPOINT(i) \
  1542. ((i + 1) % MAX_MOUSEPOINTS)
  1543. #define SAVEPOINT(xc, yc, _resX, _resY, t, e) \
  1544. { \
  1545. /* \
  1546. * (xc, yc) is the point and (resX, resY) is the resolution \
  1547. */ \
  1548. gaptMouse[gptInd].x = MAKELONG(LOWORD(xc), LOWORD(_resX)); \
  1549. gaptMouse[gptInd].y = MAKELONG(LOWORD(yc), LOWORD(_resY)); \
  1550. gaptMouse[gptInd].time = t; \
  1551. gaptMouse[gptInd].dwExtraInfo = e; \
  1552. \
  1553. gptInd = NEXTPOINT(gptInd); \
  1554. }
  1555. /*
  1556. * Structure used for getting the stack traces for user critical section.
  1557. */
  1558. #define MAX_STACK_CALLS 8
  1559. typedef struct tagCRITSTACK {
  1560. struct tagCRITSTACK* pNext;
  1561. PETHREAD thread;
  1562. int nFrames;
  1563. PVOID trace[MAX_STACK_CALLS];
  1564. } CRITSTACK, *PCRITSTACK;
  1565. /*
  1566. * Macros for User Server and Raw Input Thread critical sections.
  1567. */
  1568. #if DBG
  1569. #define KeUserModeCallback(api, pIn, cb, pOut, pcb) _KeUserModeCallback(api, pIn, cb, pOut, pcb);
  1570. #define CheckCritIn() _AssertCritIn()
  1571. #define CheckDeviceInfoListCritIn() _AssertDeviceInfoListCritIn()
  1572. #define CheckCritInShared() _AssertCritInShared()
  1573. #define CheckCritOut() _AssertCritOut()
  1574. #define CheckDeviceInfoListCritOut() _AssertDeviceInfoListCritOut()
  1575. void BeginAtomicCheck();
  1576. void BeginAtomicDeviceInfoListCheck();
  1577. void EndAtomicCheck();
  1578. void EndAtomicDeviceInfoListCheck();
  1579. #define BEGINATOMICCHECK() BeginAtomicCheck(); \
  1580. { DWORD dwCritSecUseSave = gdwCritSecUseCount;
  1581. #define ENDATOMICCHECK() UserAssert(dwCritSecUseSave == gdwCritSecUseCount); \
  1582. } EndAtomicCheck();
  1583. #define BEGINATOMICDEVICEINFOLISTCHECK() \
  1584. BeginAtomicDeviceInfoListCheck(); \
  1585. { DWORD dwDeviceInfoListCritSecUseSave = gdwDeviceInfoListCritSecUseCount;
  1586. #define ENDATOMICDEVICEINFOLISTCHECK() \
  1587. UserAssert(dwDeviceInfoListCritSecUseSave == gdwDeviceInfoListCritSecUseCount); \
  1588. } EndAtomicDeviceInfoListCheck();
  1589. // Use this to jump/return out of scope of dwCritSecUseSave (eg: error handling)
  1590. #define EXITATOMICCHECK() UserAssert(dwCritSecUseSave == gdwCritSecUseCount); \
  1591. EndAtomicCheck();
  1592. #define ISATOMICCHECK() (gdwInAtomicOperation != 0)
  1593. #define ISATOMICDEVICEINFOLISTCHECK() (gdwInAtomicDeviceInfoListOperation != 0)
  1594. #else // DBG
  1595. #define CheckCritIn()
  1596. #define CheckDeviceInfoListCritIn()
  1597. #define CheckCritInShared()
  1598. #define CheckCritOut()
  1599. #define CheckDeviceInfoListCritOut()
  1600. #define BEGINATOMICCHECK()
  1601. #define BEGINATOMICDEVICEINFOLISTCHECK()
  1602. #define BeginAtomicCheck()
  1603. #define BeginAtomicDeviceInfoListCheck()
  1604. #define ENDATOMICCHECK()
  1605. #define ENDATOMICDEVICEINFOLISTCHECK()
  1606. #define EndAtomicCheck()
  1607. #define EndAtomicDeviceInfoListCheck()
  1608. #define EXITATOMICCHECK()
  1609. #define ISATOMICCHECK()
  1610. #define ISATOMICDEVICEINFOLISTCHECK()
  1611. #endif // DBG
  1612. #define DIAGNOSE_IO 1
  1613. #ifdef DIAGNOSE_IO
  1614. ULONG MonotonicTick();
  1615. #define LOGTIME(gt) gt = MonotonicTick();
  1616. #else
  1617. #define LOGTIME(gt)
  1618. #endif
  1619. /*
  1620. * #defines used for mouse/keyboard read buffer
  1621. */
  1622. #define MAXIMUM_ITEMS_READ 10
  1623. #define NELEM_BUTTONQUEUE 16
  1624. /*
  1625. * Number of times to retry reading a device after a read attempt fails
  1626. */
  1627. #define MAXIMUM_READ_RETRIES 5
  1628. typedef struct tagGENERIC_DEVICE_INFO {
  1629. #ifdef GENERIC_INPUT
  1630. HEAD head;
  1631. #endif
  1632. struct tagDEVICEINFO *pNext;
  1633. BYTE type;
  1634. BYTE bFlags;
  1635. USHORT usActions;
  1636. BYTE nRetryRead;
  1637. UNICODE_STRING ustrName;
  1638. HANDLE handle;
  1639. PVOID NotificationEntry;
  1640. PKEVENT pkeHidChangeCompleted; // wake RequestDeviceChange()
  1641. IO_STATUS_BLOCK iosb;
  1642. NTSTATUS ReadStatus;
  1643. #ifdef DIAGNOSE_IO
  1644. HANDLE OpenerProcess;
  1645. NTSTATUS OpenStatus;
  1646. NTSTATUS AttrStatus;
  1647. ULONG timeStartRead; // tick before ZwReadFile
  1648. ULONG timeEndRead; // tick after ZwReadFile
  1649. int nReadsOutstanding; // ZwReadFile ++, consume data --
  1650. #endif
  1651. #ifdef PRERELEASE
  1652. UINT fForcedDetach : 1; // Set if the device is forced detached from TS
  1653. #endif
  1654. } GENERIC_DEVICE_INFO, *PGENERIC_DEVICE_INFO;
  1655. // valuse for GENERIC_DEVICE_INFO.type
  1656. #define DEVICE_TYPE_MOUSE 0
  1657. #define DEVICE_TYPE_KEYBOARD 1
  1658. #ifdef GENERIC_INPUT
  1659. #define DEVICE_TYPE_HID 2
  1660. #define DEVICE_TYPE_MAX 2
  1661. #else
  1662. #define DEVICE_TYPE_MAX 1
  1663. #endif
  1664. // values for GENERIC_DEVICE_INFO.usActions and SignalDeviceChange()
  1665. #define GDIAF_ARRIVED (USHORT)0x0001 // open & start reading
  1666. #define GDIAF_QUERYREMOVE (USHORT)0x0002 // close the device
  1667. #define GDIAF_REMOVECANCELLED (USHORT)0x0004 // reopen the device
  1668. #define GDIAF_DEPARTED (USHORT)0x0008 // close and free the device
  1669. #define GDIAF_IME_STATUS (USHORT)0x0010 // ???
  1670. #define GDIAF_REFRESH_MOUSE (USHORT)0x0020 // ???
  1671. #define GDIAF_FREEME (USHORT)0x0080 // Request to Free the DeviceInfo
  1672. #define GDIAF_PNPWAITING (USHORT)0x0100 // a PnP thread is waiting
  1673. #define GDIAF_RETRYREAD (USHORT)0x0200 // Retry the read
  1674. #define GDIAF_RECONNECT (USHORT)0x0400 // The session reconnected
  1675. #ifdef GENERIC_INPUT
  1676. #define GDIAF_STARTREAD (USHORT)0x0800 // The device needs to be started
  1677. #define GDIAF_STOPREAD (USHORT)0x1000 // The device needs to be stopped
  1678. #endif
  1679. // values for GENERIC_DEVICE_INFO.bFlags;
  1680. #define GDIF_NOTPNP 0x01 // Not a PnP device (eg: PS/2)
  1681. #define GDIF_READING 0x02 // Read may be pending (don't free DeviceInfo).
  1682. #if DIAGNOSE_IO
  1683. #define GDIF_READERMUSTFREE 0x04 // "Free Device" while read pending
  1684. #define GDIF_PNPMUSTFREE 0x08 // "Free Device" while PnP notification pending
  1685. #endif
  1686. #define GDIF_DBGREAD 0x10 // Verbose dbg output about this device
  1687. typedef struct tagMOUSE_DEVICE_INFO { // DEVICE_TYPE_MOUSE
  1688. MOUSE_ATTRIBUTES Attr;
  1689. MOUSE_INPUT_DATA Data[MAXIMUM_ITEMS_READ];
  1690. } MOUSE_DEVICE_INFO, *PMOUSE_DEVICE_INFO;
  1691. #ifdef GENERIC_INPUT
  1692. #define INVALID_UNIT_ID ((USHORT)0xffff)
  1693. #define INJECTED_UNIT_ID ((USHORT)0xfffe)
  1694. #endif
  1695. typedef struct tagKEYBOARD_DEVICE_INFO { // DEVICE_TYPE_KEYBOARD
  1696. KEYBOARD_ATTRIBUTES Attr;
  1697. KEYBOARD_ID_EX IdEx;
  1698. KEYBOARD_INPUT_DATA Data[MAXIMUM_ITEMS_READ];
  1699. } KEYBOARD_DEVICE_INFO, *PKEYBOARD_DEVICE_INFO;
  1700. #define GET_KEYBOARD_DEVINFO_ID(pDeviceInfo) ((pDeviceInfo)->keyboard.IdEx)
  1701. #define GET_KEYBOARD_DEVINFO_TYPE(pDeviceInfo) ((pDeviceInfo)->keyboard.IdEx.Type)
  1702. #define GET_KEYBOARD_DEVINFO_SUBTYPE(pDeviceInfo) ((pDeviceInfo)->keyboard.IdEx.Subtype)
  1703. #ifdef GENERIC_INPUT
  1704. /*
  1705. * HID Descriptor
  1706. * allocated as a handle, type == TAG_HIDDESC
  1707. */
  1708. typedef struct tagHIDDESC {
  1709. IO_STATUS_BLOCK iob;
  1710. PVOID pPreparsedData; // the size is in hidCollectionInfo.DescriptorSize
  1711. PVOID pInputBuffer; // the size is in hidpCaps.
  1712. HIDP_CAPS hidpCaps;
  1713. HID_COLLECTION_INFORMATION hidCollectionInfo;
  1714. } HIDDESC, *PHIDDESC;
  1715. /*
  1716. * HID Top Level Collection Information
  1717. */
  1718. typedef struct tagHID_TLC_INFO {
  1719. LIST_ENTRY link;
  1720. // Toplevel collection
  1721. USHORT usUsagePage;
  1722. USHORT usUsage;
  1723. /*
  1724. * Reference counters
  1725. */
  1726. UINT cDevices; // # of devices currently attached
  1727. UINT cDirectRequest; // Reference count of direct request to this device type (# of processes)
  1728. UINT cUsagePageRequest; // Reference count of UsagePage only request
  1729. UINT cExcludeRequest; // Reference count of Exclude request
  1730. UINT cExcludeOrphaned; // Orphaned count of Exclude request
  1731. #if defined(GI_SINK) && defined(LATER)
  1732. UINT cSinkable; // LATER...
  1733. #endif
  1734. } HID_TLC_INFO, *PHID_TLC_INFO;
  1735. /*
  1736. * HID global PageOnly request
  1737. */
  1738. typedef struct tagHID_PAGEONLY_REQUEST {
  1739. LIST_ENTRY link;
  1740. USHORT usUsagePage;
  1741. UINT cRefCount;
  1742. #if defined(GI_SINK) && defined(LATER)
  1743. UINT cSinkable;
  1744. #endif
  1745. } HID_PAGEONLY_REQUEST, *PHID_PAGEONLY_REQUEST;
  1746. /*
  1747. * Global HID Request
  1748. */
  1749. typedef struct tagHID_REQUEST_TABLE {
  1750. /*
  1751. * HID_TLC_INFO
  1752. */
  1753. LIST_ENTRY TLCInfoList;
  1754. /*
  1755. * HID_PAGEONLY_REQUEST
  1756. */
  1757. LIST_ENTRY UsagePageList;
  1758. #ifdef GI_SINK
  1759. /*
  1760. * PROCESS_HID_TABLE
  1761. */
  1762. LIST_ENTRY ProcessRequestList;
  1763. #endif
  1764. } HID_REQUEST_TABLE, *PHID_REQUEST_TABLE;
  1765. extern HID_REQUEST_TABLE gHidRequestTable;
  1766. extern int gnHidProcess;
  1767. /*
  1768. * Per process hid device request list
  1769. */
  1770. typedef struct tagPROCESS_HID_REQUEST {
  1771. LIST_ENTRY link;
  1772. // Toplevel collection
  1773. USHORT usUsagePage;
  1774. USHORT usUsage;
  1775. #ifdef GI_SINK
  1776. BOOL fSinkable : 1;
  1777. #endif
  1778. BOOL fExclusiveOrphaned : 1;
  1779. union {
  1780. PHID_TLC_INFO pTLCInfo;
  1781. PHID_PAGEONLY_REQUEST pPORequest;
  1782. LPVOID ptr;
  1783. };
  1784. PWND spwndTarget;
  1785. } PROCESS_HID_REQUEST, *PPROCESS_HID_REQUEST;
  1786. /*
  1787. * Per-process HID request table
  1788. */
  1789. typedef struct tagPROCESS_HID_TABLE {
  1790. /*
  1791. * Link to the next process HID table.
  1792. */
  1793. LIST_ENTRY link;
  1794. /*
  1795. * Those LIST_ENTRYs point PROCESS_HID_REQUEST
  1796. */
  1797. LIST_ENTRY InclusionList;
  1798. LIST_ENTRY UsagePageList;
  1799. LIST_ENTRY ExclusionList;
  1800. /*
  1801. * Target windows for the legacy devices
  1802. */
  1803. PWND spwndTargetMouse;
  1804. PWND spwndTargetKbd;
  1805. #ifdef GI_SINK
  1806. /*
  1807. * Number of Sinks in this process.
  1808. * N.b. this does not include the legacy device sinks to
  1809. * save clocks walking through the list, if sink requests
  1810. * are only for the legacy devices.
  1811. */
  1812. int nSinks;
  1813. #endif
  1814. /*
  1815. * Cache of the last matching request.
  1816. */
  1817. PPROCESS_HID_REQUEST pLastRequest;
  1818. USAGE UsagePageLast;
  1819. USAGE UsageLast;
  1820. /*
  1821. * Legacy Mode flags
  1822. */
  1823. BOOL fRawMouse : 1;
  1824. BOOL fNoLegacyMouse : 1;
  1825. #ifdef GI_SINK
  1826. BOOL fRawMouseSink : 1;
  1827. #endif
  1828. BOOL fRawKeyboard : 1;
  1829. BOOL fNoLegacyKeyboard : 1;
  1830. #ifdef GI_SINK
  1831. BOOL fRawKeyboardSink : 1;
  1832. #endif
  1833. BOOL fCaptureMouse : 1; // "Own" a mouse...
  1834. BOOL fNoHotKeys : 1;
  1835. BOOL fAppKeys: 1;
  1836. } PROCESS_HID_TABLE, *PPROCESS_HID_TABLE;
  1837. #define TestRawInputMode(pti, mode) \
  1838. ((pti) && (pti)->ppi && (pti)->ppi->pHidTable && (pti)->ppi->pHidTable->f##mode)
  1839. #define TestRawInputModeNoCheck(pti, mode) \
  1840. ((pti)->ppi->pHidTable->f##mode)
  1841. #ifdef GI_SINK
  1842. typedef struct tagHID_COUNTERS {
  1843. DWORD cKbdSinks;
  1844. DWORD cMouseSinks;
  1845. DWORD cHidSinks;
  1846. } HID_COUNTERS;
  1847. extern HID_COUNTERS gHidCounters;
  1848. #define IsKeyboardSinkPresent() (gHidCounters.cKbdSinks > 0)
  1849. #define IsMouseSinkPresent() (gHidCounters.cMouseSinks > 0)
  1850. #endif
  1851. #define HID_INCLUDE 0x01
  1852. #define HID_PAGEONLY 0x02
  1853. #define HID_EXCLUDE 0x03
  1854. /*
  1855. * HID Device info
  1856. */
  1857. typedef struct tagHID_DEVICE_INFO {
  1858. PHIDDESC pHidDesc;
  1859. PHID_TLC_INFO pTLCInfo;
  1860. } HID_DEVICE_INFO, *PHID_DEVICE_INFO;
  1861. #endif // GENERIC_INPUT
  1862. typedef struct tagDEVICEINFO {
  1863. GENERIC_DEVICE_INFO;
  1864. union {
  1865. MOUSE_DEVICE_INFO mouse;
  1866. KEYBOARD_DEVICE_INFO keyboard;
  1867. #ifdef GENERIC_INPUT
  1868. HID_DEVICE_INFO hid;
  1869. #endif
  1870. };
  1871. } DEVICEINFO, *PDEVICEINFO;
  1872. typedef struct tagDEVICE_TEMPLATE {
  1873. SIZE_T cbDeviceInfo; // bytes to allocate for DEVICEINFO
  1874. const GUID *pClassGUID; // GUID of the class
  1875. UINT uiRegistrySection; // Parameters for class (HKLM\SYSTEM\CurrentControlSet\Services\*\Parameters)
  1876. LPWSTR pwszClassName; // Class name (eg: L"mouclass")
  1877. LPWSTR pwszDefDevName; // Default Device Name
  1878. LPWSTR pwszLegacyDevName; // Legacy Device Name (eg: "PointerClassLegacy0")
  1879. ULONG IOCTL_Attr; // IOCTL_*_QUERY_ATTRIBUTES
  1880. UINT offAttr; // offset of *_ATTRIBUTES struct within DEVICEINFO
  1881. ULONG cbAttr; // sizeof *_ATTRIBUTES struct
  1882. UINT offData; // offset of *_INPUT_DATA buffer within DEVICEINFO
  1883. ULONG cbData; // sizeof *_INPUT_DATA buffer
  1884. VOID (*DeviceRead)(PDEVICEINFO); // routine to read the device
  1885. PKEVENT pkeHidChange; // event to signal changes to this sort of device
  1886. #ifdef GENERIC_INPUT
  1887. DWORD dwFlags; // Flags...
  1888. #endif
  1889. } DEVICE_TEMPLATE, *PDEVICE_TEMPLATE;
  1890. #ifdef GENERIC_INPUT
  1891. #define DT_HID 0x00000001
  1892. #endif
  1893. extern DEVICE_TEMPLATE aDeviceTemplate[]; // in pnp.c
  1894. typedef struct tagMOUSEEVENT {
  1895. USHORT ButtonFlags;
  1896. USHORT ButtonData;
  1897. ULONG_PTR ExtraInfo;
  1898. POINT ptPointer;
  1899. LONG time;
  1900. BOOL bInjected;
  1901. #ifdef GENERIC_INPUT
  1902. HANDLE hDevice;
  1903. /*
  1904. * The raw mouse information comes here.
  1905. */
  1906. MOUSE_INPUT_DATA rawData;
  1907. #endif
  1908. } MOUSEEVENT, *PMOUSEEVENT;
  1909. #ifdef GENERIC_INPUT
  1910. /*
  1911. * RawInput
  1912. */
  1913. typedef struct tagHIDDATA {
  1914. THROBJHEAD head;
  1915. PWND spwndTarget;
  1916. RAWINPUT rid; // raw input data, variable length
  1917. // rid needs to be the last member in HIDDATA
  1918. } HIDDATA, *PHIDDATA;
  1919. /*
  1920. * Global request list manipulation.
  1921. */
  1922. void InitializeHidRequestList();
  1923. void CleanupHidRequestList();
  1924. /*
  1925. * DeviceType request
  1926. */
  1927. VOID FreeHidTLCInfo(
  1928. PHID_TLC_INFO pHidRequest);
  1929. /*
  1930. * HID specific device info
  1931. */
  1932. PHIDDESC HidCreateDeviceInfo(PDEVICEINFO pDeviceInfo);
  1933. /*
  1934. * HID specific information (managed by HM),
  1935. * linked from DEVICEINFO
  1936. */
  1937. /* N.b. AllocateHidDesc is only called within hidevice.c */
  1938. void FreeHidDesc(PHIDDESC);
  1939. /*
  1940. * The handle in WM_INPUT
  1941. */
  1942. PHIDDATA AllocateHidData(HANDLE hDevice, DWORD dwType, DWORD dwSize, WPARAM wParam, PWND pwnd);
  1943. void FreeHidData(PHIDDATA pData);
  1944. #ifdef GI_SINK
  1945. #define GI_SINK_PARAM(x) ,x
  1946. #else
  1947. #define GI_SINK_PARAM(x)
  1948. #endif
  1949. void FreeHidProcessRequest(
  1950. PPROCESS_HID_REQUEST pHid,
  1951. DWORD dwFlags,
  1952. PPROCESS_HID_TABLE pHidTable);
  1953. /*
  1954. * HID specific read call back (called from InputApc)
  1955. */
  1956. VOID ProcessHidInput(PDEVICEINFO pDeviceInfo);
  1957. /*
  1958. * API helper
  1959. */
  1960. BOOL _RegisterRawInputDevices(PCRAWINPUTDEVICE, UINT uiNumDevices);
  1961. UINT _GetRegisteredRawInputDevices(PRAWINPUTDEVICE, PUINT puiNumDevices);
  1962. /*
  1963. * UserCriticalSection...
  1964. */
  1965. #define BESURE_IN_USERCRIT(cond) \
  1966. { \
  1967. BOOLEAN fHasToLeaveUserCrit = FALSE; \
  1968. if ((cond) && !ExIsResourceAcquiredExclusiveLite(gpresUser)) { \
  1969. CheckDeviceInfoListCritOut(); \
  1970. fHasToLeaveUserCrit = TRUE; \
  1971. EnterCrit(); \
  1972. TAGMSG0(DBGTAG_PNP, "BESURE_IN_USERCRIT: entering the user crit"); \
  1973. }
  1974. #define END_IN_USERCRIT() \
  1975. if (fHasToLeaveUserCrit) { \
  1976. CheckDeviceInfoListCritOut(); \
  1977. TAGMSG0(DBGTAG_PNP, "END_IN_USERCRIT: leaving the user crit"); \
  1978. LeaveCrit(); \
  1979. }\
  1980. }
  1981. /*
  1982. * Acquire input device lock while making sure there is no pending PnP callout
  1983. * requesting to process a device change.
  1984. */
  1985. #define PNP_SAFE_DEVICECRIT_IN() \
  1986. {\
  1987. CheckCritIn();\
  1988. CheckDeviceInfoListCritIn();\
  1989. while (TRUE) {\
  1990. if (gbPnPWaiting) {\
  1991. LeaveDeviceInfoListCrit();\
  1992. LeaveCrit(); \
  1993. Status = KeWaitForSingleObject(gpEventPnPWainting, Executive, KernelMode, FALSE, NULL); \
  1994. EnterCrit();\
  1995. EnterDeviceInfoListCrit();\
  1996. UserAssert(Status == STATUS_SUCCESS);\
  1997. continue;\
  1998. } else { \
  1999. break; \
  2000. } \
  2001. } \
  2002. }
  2003. /*
  2004. * Check if this device type is active to read
  2005. */
  2006. __inline DWORD HidValidExclusive(PHID_TLC_INFO pTLCInfo)
  2007. {
  2008. UserAssert(pTLCInfo);
  2009. UserAssert(pTLCInfo->cExcludeRequest >= pTLCInfo->cExcludeOrphaned);
  2010. return pTLCInfo->cExcludeRequest - pTLCInfo->cExcludeOrphaned;
  2011. }
  2012. __inline BOOL HidTLCActive(PHID_TLC_INFO pTLCInfo)
  2013. {
  2014. UserAssert(pTLCInfo);
  2015. return pTLCInfo->cDirectRequest > 0 || pTLCInfo->cUsagePageRequest > HidValidExclusive(pTLCInfo);
  2016. }
  2017. /*
  2018. * Allocate and free process device type request table.
  2019. */
  2020. PPROCESS_HID_TABLE AllocateProcessHidTable(void);
  2021. void FreeProcessHidTable(PPROCESS_HID_TABLE pHidTable);
  2022. void DestroyProcessHidRequests(PPROCESSINFO ppi);
  2023. void DestroyThreadHidObjects(PTHREADINFO pti);
  2024. #if DBG
  2025. void CheckupHidLeak(void);
  2026. #endif
  2027. #endif // GENERIC_INPUT
  2028. VOID ProcessKeyboardInput(PDEVICEINFO pDeviceInfo);
  2029. VOID ProcessMouseInput(PDEVICEINFO pDeviceInfo);
  2030. VOID RequestDeviceChange(
  2031. PDEVICEINFO pDeviceInfo,
  2032. USHORT usAction,
  2033. BOOL fInDeviceInfoListCrit);
  2034. VOID NTAPI InputApc(
  2035. IN PVOID ApcContext,
  2036. IN PIO_STATUS_BLOCK IoStatusBlock,
  2037. IN ULONG Reserved);
  2038. ULONG xxxGetDeviceChangeInfo(VOID);
  2039. NTSTATUS InitializeMediaChange(HANDLE hMediaRequestEvent);
  2040. VOID CleanupMediaChange(VOID);
  2041. /*
  2042. * Hard error information
  2043. */
  2044. typedef struct tagHARDERRORHANDLER {
  2045. PTHREADINFO pti;
  2046. PQ pqAttach;
  2047. } HARDERRORHANDLER, *PHARDERRORHANDLER;
  2048. /*
  2049. * Terminal Structure.
  2050. *
  2051. * This structure is only viewable from the kernel.
  2052. */
  2053. #define TEST_GTERMF(f) TEST_FLAG(gdwGTERMFlags, f)
  2054. #define TEST_BOOL_GTERMF(f) TEST_BOOL_FLAG(gdwGTERMFlags, f)
  2055. #define SET_GTERMF(f) SET_FLAG(gdwGTERMFlags, f)
  2056. #define CLEAR_GTERMF(f) CLEAR_FLAG(gdwGTERMFlags, f)
  2057. #define SET_OR_CLEAR_GTERMF(f, fSet) SET_OR_CLEAR_FLAG(gdwGTERMFlags, f, fSet)
  2058. #define TOGGLE_GTERMF(f) TOGGLE_FLAG(gdwGTERMFlags, f)
  2059. #define GTERMF_MOUSE 0x00000001
  2060. #define TERMF_INITIALIZED 0x00000001
  2061. #define TERMF_NOIO 0x00000002
  2062. #define TERMF_STOPINPUT 0x00000004
  2063. #define TERMF_DTINITSUCCESS 0x00000008
  2064. #define TERMF_DTINITFAILED 0x00000010
  2065. #define TERMF_DTDESTROYED 0x00000020
  2066. #define TERMF_MOTHERWND_CREATED 0x00000040
  2067. #define TERMF_MOTHERWND_DESTROYED 0x00000080
  2068. typedef struct tagTERMINAL {
  2069. DWORD dwTERMF_Flags; // terminal flags
  2070. /*
  2071. * System Information
  2072. */
  2073. PWND spwndDesktopOwner; // mother desktop
  2074. PTHREADINFO ptiDesktop;
  2075. PQ pqDesktop;
  2076. PKEVENT pEventTermInit;
  2077. PKEVENT pEventDestroyDesktop; // Used for destroying desktops
  2078. PDESKTOP rpdeskDestroy; // Desktop destroy list.
  2079. PKEVENT pEventInputReady; // input ready event. This is created in
  2080. // CreateTerminal. RIT and the desktop thread
  2081. // will wait for it. It will be set when the
  2082. // first desktop in that terminal will be created.
  2083. } TERMINAL, *PTERMINAL;
  2084. /*
  2085. * Pool allocation tags and macros
  2086. */
  2087. /*
  2088. * Define tags. To add tags, add them to ntuser\kernel\ptag.lst
  2089. */
  2090. #define DEFINE_POOLTAG(value, index) value
  2091. #define DECLARE_POOLTAG(name, value, index)
  2092. #include "ptag.h"
  2093. NTSTATUS UserCommitDesktopMemory(
  2094. PVOID pBase,
  2095. PVOID *ppCommit,
  2096. PSIZE_T pCommitSize);
  2097. NTSTATUS UserCommitSharedMemory(
  2098. PVOID pBase,
  2099. PVOID *ppCommit,
  2100. PSIZE_T pCommitSize);
  2101. PWIN32HEAP UserCreateHeap(
  2102. HANDLE hSection,
  2103. ULONG ulViewOffset,
  2104. PVOID pvBaseAddress,
  2105. DWORD dwSize,
  2106. PRTL_HEAP_COMMIT_ROUTINE pfnCommit);
  2107. #define RECORD_STACK_TRACE_SIZE 6
  2108. /*
  2109. * Pool allocation flags
  2110. */
  2111. #define POOL_HEAVY_ALLOCS 0x00000001 // use HeavyAllocPool
  2112. #define POOL_CAPTURE_STACK 0x00000002 // stack traces are captured
  2113. #define POOL_FAIL_ALLOCS 0x00000004 // fail pool allocations
  2114. #define POOL_FAIL_BY_INDEX 0x00000008 // fail allocations by index
  2115. #define POOL_TAIL_CHECK 0x00000010 // append tail string
  2116. #define POOL_KEEP_FREE_RECORD 0x00000020 // keep a list with last x frees
  2117. #define POOL_KEEP_FAIL_RECORD 0x00000040 // keep a list with last x failed allocations
  2118. #define POOL_BREAK_FOR_LEAKS 0x00000080 // break on pool leaks (remote sessions)
  2119. typedef struct tagWin32AllocStats {
  2120. SIZE_T dwMaxMem; // max pool memory allocated
  2121. SIZE_T dwCrtMem; // current pool memory used
  2122. DWORD dwMaxAlloc; // max number of pool allocations made
  2123. DWORD dwCrtAlloc; // current pool allocations
  2124. PWin32PoolHead pHead; // pointer to the link list with the allocations
  2125. } Win32AllocStats, *PWin32AllocStats;
  2126. typedef struct tagPOOLRECORD {
  2127. PVOID ExtraData; // the tag
  2128. SIZE_T size;
  2129. PVOID trace[RECORD_STACK_TRACE_SIZE];
  2130. } POOLRECORD, *PPOOLRECORD;
  2131. #ifdef POOL_INSTR_API
  2132. BOOL _Win32PoolAllocationStats(
  2133. LPDWORD parrTags,
  2134. SIZE_T tagsCount,
  2135. SIZE_T* lpdwMaxMem,
  2136. SIZE_T* lpdwCrtMem,
  2137. LPDWORD lpdwMaxAlloc,
  2138. LPDWORD lpdwCrtAlloc);
  2139. #endif // POOL_INSTR_API
  2140. #ifdef POOL_INSTR
  2141. VOID CleanupPoolAllocations(VOID);
  2142. NTSTATUS InitPoolLimitations(VOID);
  2143. VOID CleanUpPoolLimitations(VOID);
  2144. #else
  2145. #define CleanupPoolAllocations()
  2146. #define InitPoolLimitations() STATUS_SUCCESS
  2147. #define CleanUpPoolLimitations()
  2148. #endif // POOL_INSTR
  2149. #ifndef TRACE_MAP_VIEWS
  2150. #define InitSectionTrace() STATUS_SUCCESS
  2151. #define CleanUpSections()
  2152. #else
  2153. NTSTATUS InitSectionTrace(VOID);
  2154. VOID CleanUpSections(VOID);
  2155. #endif // TRACE_MAP_VIEWS
  2156. extern PWIN32HEAP gpvSharedAlloc;
  2157. __inline PVOID
  2158. SharedAlloc(ULONG cb)
  2159. {
  2160. return Win32HeapAlloc(gpvSharedAlloc, cb, 0, 0);
  2161. }
  2162. __inline BOOL
  2163. SharedFree(PVOID pv)
  2164. {
  2165. return Win32HeapFree(gpvSharedAlloc, pv);
  2166. }
  2167. NTSTATUS CommitReadOnlyMemory(HANDLE hSection, PSIZE_T pulCommit,
  2168. DWORD dwCommitOffset, int* pdCommit);
  2169. /*
  2170. * Height and Width of the desktop pattern bitmap.
  2171. */
  2172. #define CXYDESKPATTERN 8
  2173. /***************************************************************************\
  2174. * Typedefs and Macros
  2175. *
  2176. * Here are defined all types and macros that are shared across the User's
  2177. * server-side code modules. Types and macros that are unique to a single
  2178. * module should be defined at the head of that module, not in this file.
  2179. *
  2180. \***************************************************************************/
  2181. // Window Proc Window Validation macro
  2182. #define VALIDATECLASSANDSIZE(pwnd, message, wParam, lParam, inFNID, initmessage) \
  2183. if ((pwnd)->fnid != (inFNID)) { \
  2184. switch ((pwnd)->fnid) { \
  2185. DWORD cb; \
  2186. case 0: \
  2187. \
  2188. if ((cb = pwnd->cbwndExtra + sizeof(WND)) < (DWORD)(CBFNID(inFNID))) { \
  2189. RIPMSG3(RIP_WARNING, \
  2190. "(%#p %lX) needs at least (%ld) window words for this proc", \
  2191. pwnd, cb - sizeof(WND), \
  2192. (DWORD)(CBFNID(inFNID)) - sizeof(WND)); \
  2193. return 0; \
  2194. } \
  2195. /* \
  2196. * If this is not the initialization message, we cannot set the fnid; \
  2197. * otherwise, we'll probably fault working on this pwnd's private \
  2198. * uninitialized data \
  2199. */ \
  2200. if ((message) != (initmessage)) { \
  2201. if (((message) != WM_NCCREATE) && ((message) != WM_NCCALCSIZE) && ((message) != WM_GETMINMAXINFO)) { \
  2202. RIPMSG3(RIP_WARNING, \
  2203. "Default processing message %#lx for pwnd %#p. fnid %#lx not set",\
  2204. (message), (pwnd), (DWORD)(inFNID)); \
  2205. } \
  2206. return xxxDefWindowProc((pwnd), (message), (wParam), (lParam)); \
  2207. } \
  2208. \
  2209. /* \
  2210. * Remember what window class this window belongs to. Can't use \
  2211. * the real class because any app can call CallWindowProc() \
  2212. * directly no matter what the class is! \
  2213. */ \
  2214. (pwnd)->fnid = (WORD)(inFNID); \
  2215. break; \
  2216. \
  2217. default: \
  2218. RIPMSG3(RIP_WARNING, "Window (%#p) not of correct class; fnid = %lX not %lX", \
  2219. (pwnd), (DWORD)((pwnd)->fnid), (DWORD)(inFNID)); \
  2220. \
  2221. /* Fall through */ \
  2222. \
  2223. case (inFNID | FNID_CLEANEDUP_BIT): \
  2224. case (inFNID | FNID_DELETED_BIT): \
  2225. case (inFNID | FNID_STATUS_BITS): \
  2226. return 0; \
  2227. } \
  2228. }
  2229. /*
  2230. * Handy Region helper macros
  2231. */
  2232. #define CopyRgn(hrgnDst, hrgnSrc) \
  2233. GreCombineRgn(hrgnDst, hrgnSrc, NULL, RGN_COPY)
  2234. #define IntersectRgn(hrgnResult, hrgnA, hrgnB) \
  2235. GreCombineRgn(hrgnResult, hrgnA, hrgnB, RGN_AND)
  2236. #define SubtractRgn(hrgnResult, hrgnA, hrgnB) \
  2237. GreCombineRgn(hrgnResult, hrgnA, hrgnB, RGN_DIFF)
  2238. #define UnionRgn(hrgnResult, hrgnA, hrgnB) \
  2239. GreCombineRgn(hrgnResult, hrgnA, hrgnB, RGN_OR)
  2240. #define XorRgn(hrgnResult, hrgnA, hrgnB) \
  2241. GreCombineRgn(hrgnResult, hrgnA, hrgnB, RGN_XOR)
  2242. void DeleteMaybeSpecialRgn(HRGN hrgn);
  2243. BOOL zzzInvalidateDCCache(PWND pwndInvalid, DWORD flags);
  2244. #define IDC_DEFAULT 0x0001
  2245. #define IDC_CHILDRENONLY 0x0002
  2246. #define IDC_CLIENTONLY 0x0004
  2247. #define IDC_MOVEBLT 0x0008
  2248. #define IDC_NOMOUSE 0x0010
  2249. /*
  2250. * RestoreSpb return Flags
  2251. */
  2252. #define RSPB_NO_INVALIDATE 0 // nothing invalidated by restore
  2253. #define RSPB_INVALIDATE 1 // restore invalidate some area
  2254. #define RSPB_INVALIDATE_SSB 2 // restore called SaveScreenBits which invalidated
  2255. // Calls Proc directly without doing any messages translation
  2256. #define SCMS_FLAGS_ANSI 0x0001
  2257. #define SCMS_FLAGS_INONLY 0x0002 // Message should be one way (hooks)
  2258. #define CallClientProcA(pwnd, msg, wParam, lParam, xpfn) \
  2259. SfnDWORD(pwnd, msg, wParam, lParam, xpfn, \
  2260. ((PROC)(gpsi->apfnClientW.pfnDispatchMessage)), TRUE, NULL)
  2261. #define CallClientProcW(pwnd, msg, wParam, lParam, xpfn) \
  2262. SfnDWORD(pwnd, msg, wParam, lParam, xpfn, \
  2263. ((PROC)(gpsi->apfnClientW.pfnDispatchMessage)), TRUE, NULL)
  2264. #define CallClientWorkerProc(pwnd, msg, wParam, lParam, xpfn) \
  2265. SfnDWORD(pwnd, msg, wParam, lParam, 0, xpfn, TRUE, NULL)
  2266. #define ScSendMessageSMS(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms) \
  2267. (((msg) & ~MSGFLAG_MASK) >= WM_USER) ? \
  2268. SfnDWORD(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms) : \
  2269. gapfnScSendMessage[MessageTable[msg & 0xffff].iFunction](pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms)
  2270. #define ScSendMessage(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags) \
  2271. ScSendMessageSMS(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, NULL)
  2272. /*
  2273. * Server-side routines for loading cursors/icons/strings/menus from server.
  2274. */
  2275. #define SERVERSTRINGMAXSIZE 40
  2276. void RtlInitUnicodeStringOrId(PUNICODE_STRING pstrName, LPWSTR lpstrName);
  2277. int RtlLoadStringOrError(UINT, LPTSTR, int, WORD);
  2278. #define ServerLoadString(hmod, id, p, cch)\
  2279. RtlLoadStringOrError(id, p, cch, 0)
  2280. #define ServerLoadStringEx(hmod, id, p, cch, wLang)\
  2281. RtlLoadStringOrError(id, p, cch, wLang)
  2282. /*
  2283. * Callback routines for loading resources from client.
  2284. */
  2285. HANDLE xxxClientLoadImage(
  2286. PUNICODE_STRING pstrName,
  2287. ATOM atomModName,
  2288. WORD wImageType,
  2289. int cxSize,
  2290. int cySize,
  2291. UINT LR_flags,
  2292. BOOL fWallpaper);
  2293. HANDLE xxxClientCopyImage(
  2294. IN HANDLE hImage,
  2295. IN UINT uImageType,
  2296. IN int cxDesired,
  2297. IN int cyDesired,
  2298. IN UINT LR_flags);
  2299. PMENU xxxClientLoadMenu(
  2300. HANDLE hmod,
  2301. PUNICODE_STRING pstrName);
  2302. int xxxClientAddFontResourceW(PUNICODE_STRING, DWORD, DESIGNVECTOR*);
  2303. VOID ClientFontSweep(VOID);
  2304. VOID ClientLoadLocalT1Fonts();
  2305. VOID ClientLoadRemoteT1Fonts();
  2306. /*
  2307. * Server-side routine for thread initialization.
  2308. */
  2309. NTSTATUS InitializeClientPfnArrays(
  2310. CONST PFNCLIENT *ppfnClientA,
  2311. CONST PFNCLIENT *ppfnClientW,
  2312. CONST PFNCLIENTWORKER *ppfnClientWorker,
  2313. HANDLE hModUser);
  2314. VOID SetRipFlags(DWORD);
  2315. VOID SetDbgTag(int, DWORD);
  2316. /*
  2317. * xxxActivateWindow() commands
  2318. */
  2319. #define AW_USE 1
  2320. #define AW_TRY 2
  2321. #define AW_SKIP 3
  2322. #define AW_TRY2 4
  2323. #define AW_SKIP2 5 /* used internally in xxxActivateWindow() */
  2324. #define AW_USE2 6 /* nc mouse activation added by craigc */
  2325. /*
  2326. * Structure for WM_ACTIVATEAPP EnumWindows() callback.
  2327. */
  2328. typedef struct tagAAS {
  2329. PTHREADINFO ptiNotify;
  2330. DWORD tidActDeact;
  2331. UINT fActivating : 1;
  2332. UINT fQueueNotify : 1;
  2333. } AAS;
  2334. /*
  2335. * Declaration for EnumWindows() callback function.
  2336. */
  2337. BOOL xxxActivateApp(PWND pwnd, AAS *paas);
  2338. #define GETDESKINFO(pti) ((pti)->pDeskInfo)
  2339. #define SET_TIME_LAST_READ(pti) ((pti)->pcti->timeLastRead = NtGetTickCount())
  2340. #define GET_TIME_LAST_READ(pti) ((pti)->pcti->timeLastRead)
  2341. /*
  2342. * General purpose helper macros
  2343. */
  2344. #define abs(A) (((A) < 0)? -(A) : (A))
  2345. #define N_ELEM(a) (sizeof(a)/sizeof(a[0]))
  2346. /*
  2347. * General purpose access check macro
  2348. */
  2349. #define RETURN_IF_ACCESS_DENIED(amGranted, amRequested, r) \
  2350. if (!CheckGrantedAccess((amGranted), (amRequested))) return r
  2351. /*
  2352. * Lock record structure for tracking locks (debug only)
  2353. */
  2354. #define LOCKRECORD_STACK 8
  2355. #define LOCKRECORD_MARKDESTROY IntToPtr( 0xFFFFFFFF )
  2356. typedef struct _LOCKRECORD {
  2357. PLR plrNext;
  2358. DWORD cLockObj;
  2359. PVOID ppobj;
  2360. PVOID trace[LOCKRECORD_STACK];
  2361. } LOCKRECORD;
  2362. /*
  2363. * We limit recursion until we have only this much stack left.
  2364. * We have to leave room for kernel interupts.
  2365. */
  2366. #define KERNEL_STACK_MINIMUM_RESERVE (4*1024)
  2367. /*
  2368. * And this much of backing store in IA64.
  2369. */
  2370. #if defined(_IA64_)
  2371. #define KERNEL_BSTORE_MINIMUM_RESERVE (4*1024)
  2372. #define GET_CURRENT_BSTORE() ((ULONG_PTR)PsGetCurrentThreadStackBase() + KERNEL_LARGE_BSTORE_SIZE - __getReg(CV_IA64_RsBSP))
  2373. #endif // _IA64_
  2374. #if DBG
  2375. #if defined(_IA64_)
  2376. #define GET_USED_BSTORE_SIZE() (__getReg(CV_IA64_RsBSP) - (ULONG_PTR)PsGetCurrentThreadStackBase())
  2377. #define ASSERT_BSTORE() UserAssert(GET_CURRENT_BSTORE() > KERNEL_BSTORE_MINIMUM_RESERVE)
  2378. #else // _IA64_
  2379. #define ASSERT_BSTORE()
  2380. #endif // _IA64_
  2381. #define ASSERT_STACK() \
  2382. UserAssert(IoGetRemainingStackSize() > KERNEL_STACK_MINIMUM_RESERVE); \
  2383. ASSERT_BSTORE()
  2384. __inline ULONG_PTR GET_USED_STACK_SIZE(
  2385. VOID)
  2386. {
  2387. ULONG_PTR uLocVer;
  2388. return ((ULONG_PTR)PsGetCurrentThreadStackBase() - (ULONG_PTR)&uLocVer);
  2389. }
  2390. #endif // DBG
  2391. /*
  2392. * The following is a LOCK structure. This structure is recorded for
  2393. * each threadlock so unlocks can occur at cleanup time.
  2394. */
  2395. typedef struct _LOCK {
  2396. PTHREADINFO pti;
  2397. PVOID pobj;
  2398. PTL ptl;
  2399. #if DBG
  2400. PVOID pfn; // for debugging purposes only
  2401. int ilNext; // for debugging purposes only
  2402. int iilPrev; // for debugging purposes only
  2403. #endif // DBG
  2404. } LOCK, *PLOCK;
  2405. #define NEEDSSYNCPAINT(pwnd) TestWF(pwnd, WFSENDERASEBKGND | WFSENDNCPAINT)
  2406. typedef struct tagCVR // cvr
  2407. {
  2408. WINDOWPOS pos; // MUST be first field of CVR!
  2409. int xClientNew; // New client rectangle
  2410. int yClientNew;
  2411. int cxClientNew;
  2412. int cyClientNew;
  2413. RECT rcBlt;
  2414. int dxBlt; // Distance blt rectangle is moving
  2415. int dyBlt;
  2416. UINT fsRE; // RE_ flags: whether hrgnVisOld is empty or not
  2417. HRGN hrgnVisOld; // Previous visrgn
  2418. PTHREADINFO pti; // The thread this SWP should be processed on
  2419. HRGN hrgnClip; // Window clipping region
  2420. HRGN hrgnInterMonitor; // multimon support
  2421. } CVR, *PCVR;
  2422. /*
  2423. * CalcValidRects() "Region Empty" flag values
  2424. * A set bit indicates the corresponding region is empty.
  2425. */
  2426. #define RE_VISNEW 0x0001 // CVR "Region Empty" flag values
  2427. #define RE_VISOLD 0x0002 // A set bit indicates the
  2428. #define RE_VALID 0x0004 // corresponding region is empty.
  2429. #define RE_INVALID 0x0008
  2430. #define RE_SPB 0x0010
  2431. #define RE_VALIDSUM 0x0020
  2432. #define RE_INVALIDSUM 0x0040
  2433. typedef struct tagSMWP { // smwp
  2434. HEAD head;
  2435. UINT bShellNotify:1; // The acvr list contains shell notify flags
  2436. UINT bHandle:1; // This is an HM object allocation -- See -BeginDeferWindowPos
  2437. /*
  2438. * All fields AFTER ccvr are preserved when reusing the global SMWP structure.
  2439. */
  2440. int ccvr; // Number of CVRs in the SWMP
  2441. int ccvrAlloc; // Number of actual CVRs allocated in the SMWP
  2442. PCVR acvr; // Pointer to array of CVR structures
  2443. } SMWP, *PSMWP;
  2444. void DestroySMWP(PSMWP psmwp);
  2445. /*
  2446. * Clipboard data object definition
  2447. */
  2448. typedef struct tagCLIPDATA {
  2449. HEAD head;
  2450. DWORD cbData;
  2451. BYTE abData[0];
  2452. } CLIPDATA, *PCLIPDATA;
  2453. /*
  2454. * Private User Startupinfo
  2455. */
  2456. typedef struct tagUSERSTARTUPINFO {
  2457. DWORD cb;
  2458. DWORD dwX;
  2459. DWORD dwY;
  2460. DWORD dwXSize;
  2461. DWORD dwYSize;
  2462. DWORD dwFlags;
  2463. WORD wShowWindow;
  2464. WORD cbReserved2;
  2465. } USERSTARTUPINFO, *PUSERSTARTUPINFO;
  2466. /*
  2467. * TLBLOCK structure for multiple threads locking.
  2468. */
  2469. #define THREADS_PER_TLBLOCK 16
  2470. typedef struct tagTLBLOCK {
  2471. struct tagTLBLOCK *ptlBlockPrev;
  2472. struct {
  2473. PTHREADINFO pti;
  2474. TL tlpti;
  2475. DWORD dwFlags;
  2476. #if DBG
  2477. DWORD dwUnlockedCount;
  2478. #endif
  2479. } list[THREADS_PER_TLBLOCK];
  2480. } TLBLOCK, *PTLBLOCK;
  2481. /*
  2482. * Keyboard File object.
  2483. */
  2484. typedef struct tagKBDFILE {
  2485. HEAD head;
  2486. struct tagKBDFILE *pkfNext; // next keyboard file
  2487. HANDLE hBase; // base address of data
  2488. PKBDTABLES pKbdTbl; // pointer to kbd layout data.
  2489. ULONG Size; // Size of pKbdTbl
  2490. PKBDNLSTABLES pKbdNlsTbl; // pointer to kbd nls layout data.
  2491. WCHAR awchDllName[32];
  2492. #ifdef LATER
  2493. LANGID langId; // Default language ID of this layout
  2494. #endif
  2495. } KBDFILE, *PKBDFILE;
  2496. /*
  2497. * Keyboard Layout object.
  2498. */
  2499. typedef struct tagKL { /* kl */
  2500. HEAD head;
  2501. struct tagKL *pklNext; // next in layout cycle
  2502. struct tagKL *pklPrev; // prev in layout cycle
  2503. DWORD dwKL_Flags; // KL_* flags
  2504. HKL hkl; // (Layout ID | Base Language ID)
  2505. KBDFILE *spkf; // Keyboard Layout File
  2506. KBDFILE *spkfPrimary; // Primary keyboard layout file
  2507. DWORD dwFontSigs; // mask of FS_xxx bits - fonts that layout is good for
  2508. UINT iBaseCharset;// Charset value (Win95 compat) eg: ANSI_CHARSET
  2509. WORD CodePage; // Windows Codepage of kbd layout, eg: 1252, 1250
  2510. WCHAR wchDiacritic;// Dead key saved here until next keystroke
  2511. PIMEINFOEX piiex; // Extended information for IME based layout
  2512. UINT uNumTbl; // number of tables in pKbdTbl
  2513. PKBDFILE *pspkfExtra; // extra layout file in this
  2514. DWORD dwLastKbdType;
  2515. DWORD dwLastKbdSubType;
  2516. DWORD dwKLID; // base keyboard layout ID
  2517. } KL, *PKL;
  2518. /*
  2519. * Flag values for KL dwFlags
  2520. */
  2521. #define KL_UNLOADED 0x20000000
  2522. #define KL_RESET 0x40000000
  2523. PKL HKLtoPKL(PTHREADINFO pti, HKL hkl);
  2524. typedef struct tagKBDLANGTOGGLE
  2525. {
  2526. BYTE bVkey;
  2527. BYTE bScan;
  2528. int iBitPosition;
  2529. } KBDLANGTOGGLE;
  2530. /*
  2531. * These constants are derived from combinations of
  2532. * iBitPosition (refer to the LangToggle array defined
  2533. * in globals.c).
  2534. */
  2535. /*
  2536. * This bit is used for both control and alt keys
  2537. */
  2538. #define KLT_ALT 1
  2539. /*
  2540. * This bit is used for the left shift key
  2541. */
  2542. #define KLT_LEFTSHIFT 2
  2543. /*
  2544. * This combination denotes ctrl/alt and the left shift key
  2545. */
  2546. #define KLT_ALTLEFTSHIFT 3
  2547. /*
  2548. * This bit is used for the right shift key
  2549. */
  2550. #define KLT_RIGHTSHIFT 4
  2551. /*
  2552. * This combination denotes ctrl/alt and the right shift key
  2553. */
  2554. #define KLT_ALTRIGHTSHIFT 5
  2555. /*
  2556. * This combination denotes ctrl/alt and both the shift keys
  2557. */
  2558. #define KLT_ALTBOTHSHIFTS 7
  2559. /*
  2560. * This value is used to mark invalid toggle key sequence
  2561. */
  2562. #define KLT_NONE 8
  2563. /*
  2564. * Key Event (KE) structure
  2565. * Stores a Virtual Key event
  2566. */
  2567. typedef struct tagKE {
  2568. union {
  2569. BYTE bScanCode; // Virtual Scan Code (Set 1)
  2570. WCHAR wchInjected; // Unicode char from SendInput()
  2571. };
  2572. USHORT usFlaggedVk; // Vk | Flags
  2573. DWORD dwTime; // time in milliseconds
  2574. #ifdef GENERIC_INPUT
  2575. HANDLE hDevice;
  2576. KEYBOARD_INPUT_DATA data;
  2577. #endif
  2578. } KE, *PKE;
  2579. /*
  2580. * Misc. keyboard stuff moved from oak/inc/kbd.h
  2581. */
  2582. typedef BOOL (* KEPROC)(PKE pKe);
  2583. typedef BOOL (* NLSKEPROC)(PKE pKe, ULONG_PTR dwExtraInfo, ULONG dwParam);
  2584. typedef BOOL (* NLSVKFPROC)(PVK_F pVkToF, PKE pKe, ULONG_PTR dwExtraInfo);
  2585. /*
  2586. * OEM-specific special processing (keystroke simulators and filters)
  2587. */
  2588. extern KEPROC aKEProcOEM[];
  2589. /*
  2590. * Key message lParam bits
  2591. */
  2592. #define EXTENDED_BIT 0x01000000
  2593. #define DONTCARE_BIT 0x02000000
  2594. #define FAKE_KEYSTROKE 0x02000000
  2595. #define ALTNUMPAD_BIT 0x04000000 // copied from windows\inc\wincon.w
  2596. /*
  2597. * For handy diacritics
  2598. */
  2599. #define IDS_FROM_SCANCODE(prefix, base) \
  2600. (0xc000 + ((0x ## prefix) >= 0xE0 ? 0x100 : 0) + (0x ## base))
  2601. //
  2602. // NLS Keyboard functions
  2603. //
  2604. VOID NlsKbdInitializePerSystem(VOID);
  2605. VOID NlsKbdSendIMENotification(DWORD dwImeOpen, DWORD dwImeConversion);
  2606. /*
  2607. * Desktop flags.
  2608. */
  2609. #define DF_ACTIVEONDESTROY 0x00000001
  2610. #define DF_ZOMBIE 0x00000002
  2611. #define DF_NOTRITUNLOCK 0x00000004
  2612. #define DF_QUITUNLOCK 0x00000008
  2613. #define DF_USERMODE 0x00000010
  2614. #define DF_SKIPSWITCHDESKTOP 0x00000020
  2615. #define DF_DTNONEWDESKTOP 0x00000040
  2616. #define DF_REDIRECTED 0x00000080
  2617. #define DF_DESKCREATED 0x00000100
  2618. #define DF_NEWDISPLAYSETTINGS 0x00000200
  2619. #define DF_TRACKMOUSEHOVER 0x00000400
  2620. #define DF_TRACKMOUSELEAVE 0x00000800
  2621. #define DF_TOOLTIPACTIVE 0x00001000
  2622. #define DF_TOOLTIPSHOWING 0x00002000
  2623. #define DF_HOTTRACKING 0x00004000
  2624. #define DF_DESTROYED 0x00008000
  2625. #define DF_DESKWNDDESTROYED 0x00010000
  2626. #define DF_DYING 0x00020000
  2627. #define DF_TOOLTIP (DF_TOOLTIPACTIVE | DF_TOOLTIPSHOWING)
  2628. #define DF_TRACKMOUSEEVENT (DF_TRACKMOUSELEAVE | DF_TRACKMOUSEHOVER)
  2629. #define DF_MOUSEMOVETRK (DF_HOTTRACKING | DF_TOOLTIPACTIVE | DF_TRACKMOUSELEAVE | DF_TRACKMOUSEHOVER)
  2630. #define CAPTIONTOOLTIPLEN 100
  2631. /*
  2632. * Used to identify desktops uniquely for GDI
  2633. */
  2634. #define GW_DESKTOP_ID 1
  2635. #define DESKTOP_ALLOC_TRACE_SIZE 6
  2636. #if DBG
  2637. typedef struct tagDbgAllocHead {
  2638. DWORD mark;
  2639. DWORD tag;
  2640. PDESKTOP pdesk;
  2641. SIZE_T size; // the size of the allocation (doesn't include
  2642. // this structure
  2643. struct tagDbgAllocHead* pPrev; // pointer to the previous allocation of this tag
  2644. struct tagDbgAllocHead* pNext; // pointer to the next allocation of this tag
  2645. #ifdef DESKTOP_ALLOC_TRACE
  2646. PVOID trace[DESKTOP_ALLOC_TRACE_SIZE];
  2647. #endif // DESKTOP_ALLOC_TRACE
  2648. } DbgAllocHead, *PDbgAllocHead;
  2649. #endif // DBG
  2650. #define DTAG_CLASS 0x0001
  2651. #define DTAG_DESKTOPINFO 0x0002
  2652. #define DTAG_CLIENTTHREADINFO 0x0003
  2653. #define DTAG_TEXT 0x0004
  2654. #define DTAG_HANDTABL 0x0005
  2655. #define DTAG_SBINFO 0x0006
  2656. #define DTAG_MENUITEM 0x0007
  2657. #define DTAG_MENUTEXT 0x0008
  2658. #define DTAG_IMETEXT 0x0009
  2659. #define DTAG_PROPLIST 0x000A
  2660. /*
  2661. * Desktop Structure.
  2662. *
  2663. * This structure is only viewable from the kernel. If any desktop
  2664. * information is needed in the client, then they should reference off
  2665. * the pDeskInfo field (i.e. pti->pDeskInfo).
  2666. */
  2667. typedef struct tagDESKTOP {
  2668. DWORD dwSessionId; // Terminal Server SessionId. This has to be first field in the structure
  2669. PDESKTOPINFO pDeskInfo; // Desktop information
  2670. PDISPLAYINFO pDispInfo; //
  2671. PDESKTOP rpdeskNext; // Next desktop in list
  2672. PWINDOWSTATION rpwinstaParent; // Windowstation owner
  2673. DWORD dwDTFlags; // Desktop flags
  2674. ULONG dwDesktopId; // Needed by GDI to tag display devices
  2675. PMENU spmenuSys; //
  2676. PMENU spmenuDialogSys; //
  2677. PMENU spmenuHScroll;
  2678. PMENU spmenuVScroll;
  2679. PWND spwndForeground; //
  2680. PWND spwndTray;
  2681. PWND spwndMessage;
  2682. PWND spwndTooltip;
  2683. HANDLE hsectionDesktop; //
  2684. PWIN32HEAP pheapDesktop; //
  2685. DWORD dwConsoleThreadId; //
  2686. DWORD dwConsoleIMEThreadId;
  2687. CONSOLE_CARET_INFO cciConsole;
  2688. LIST_ENTRY PtiList; //
  2689. PWND spwndTrack; // xxxTrackMouseMove data
  2690. int htEx;
  2691. RECT rcMouseHover;
  2692. DWORD dwMouseHoverTime;
  2693. #ifdef LOGDESKTOPLOCKS
  2694. int nLockCount;
  2695. int nLogMax;
  2696. int nLogCrt;
  2697. PLogD pLog;
  2698. #endif // LOGDESKTOPLOCKS
  2699. } DESKTOP;
  2700. typedef struct tagDESKWND {
  2701. WND wnd;
  2702. DWORD idProcess;
  2703. DWORD idThread;
  2704. } DESKWND, *PDESKWND;
  2705. PVOID DesktopAlloc(PDESKTOP pdesk, UINT uSize,DWORD tag);
  2706. #define DesktopAllocAlways(pdesk, uSize, tag) \
  2707. Win32HeapAlloc(pdesk->pheapDesktop, uSize, tag, 0)
  2708. #define DesktopFree(pdesk, p) Win32HeapFree(pdesk->pheapDesktop, p)
  2709. /*
  2710. * Windowstation structure
  2711. */
  2712. #define WSF_SWITCHLOCK 0x0001
  2713. #define WSF_OPENLOCK 0x0002
  2714. #define WSF_NOIO 0x0004
  2715. #define WSF_SHUTDOWN 0x0008
  2716. #define WSF_DYING 0x0010
  2717. #define WSF_REALSHUTDOWN 0x0020
  2718. #define WSF_CLIPBOARDCHANGED 0x0040
  2719. #define WSF_INDELAYEDRENDERING 0x0080
  2720. typedef struct tagWINDOWSTATION {
  2721. /*
  2722. * TS SessionId. This has to be the first field in the structure.
  2723. */
  2724. DWORD dwSessionId;
  2725. PWINDOWSTATION rpwinstaNext;
  2726. PDESKTOP rpdeskList;
  2727. PTERMINAL pTerm;
  2728. DWORD dwWSF_Flags;
  2729. struct tagKL *spklList;
  2730. /*
  2731. * Clipboard variables.
  2732. */
  2733. PTHREADINFO ptiClipLock;
  2734. PTHREADINFO ptiDrawingClipboard;
  2735. PWND spwndClipOpen;
  2736. PWND spwndClipViewer;
  2737. PWND spwndClipOwner;
  2738. struct tagCLIP *pClipBase;
  2739. int cNumClipFormats;
  2740. UINT iClipSerialNumber;
  2741. UINT iClipSequenceNumber;
  2742. /*
  2743. * Global Atom table.
  2744. */
  2745. PVOID pGlobalAtomTable;
  2746. LUID luidEndSession;
  2747. LUID luidUser;
  2748. PSID psidUser;
  2749. /*
  2750. * Pointer to the currently active desktop for the window station.
  2751. */
  2752. #if DBG
  2753. PDESKTOP pdeskCurrent;
  2754. #endif
  2755. } WINDOWSTATION;
  2756. typedef struct tagCAPTIONCACHE {
  2757. PCURSOR spcursor;
  2758. POEMBITMAPINFO pOem;
  2759. #if DBG
  2760. HICON hico;
  2761. #endif
  2762. } CAPTIONCACHE;
  2763. /*
  2764. * Configurable icon and cursor stuff
  2765. */
  2766. typedef struct tagSYSCFGICO
  2767. {
  2768. WORD Id; // configurable id (OIC_ or OCR_ value)
  2769. WORD StrId; // String ID for registry key name
  2770. PCURSOR spcur; // perminant cursor/icon pointer
  2771. } SYSCFGICO;
  2772. #define SYSICO(name) (gasysico[OIC_##name##_DEFAULT - OIC_FIRST_DEFAULT].spcur)
  2773. #define SYSCUR(name) (gasyscur[OCR_##name##_DEFAULT - OCR_FIRST_DEFAULT].spcur)
  2774. /*
  2775. * Accelerator Table structure
  2776. */
  2777. typedef struct tagACCELTABLE {
  2778. PROCOBJHEAD head;
  2779. UINT cAccel;
  2780. ACCEL accel[1];
  2781. } ACCELTABLE, *LPACCELTABLE;
  2782. /*
  2783. * Besides the desktop window used by the current thread, we also
  2784. * need to get the desktop window of a window and the input desktop
  2785. * window.
  2786. */
  2787. #define PWNDDESKTOP(p) ((p)->head.rpdesk->pDeskInfo->spwnd)
  2788. #define PWNDMESSAGE(p) ((p)->head.rpdesk->spwndMessage)
  2789. #define PWNDTOOLTIP(p) ((p)->head.rpdesk->spwndTooltip)
  2790. /*
  2791. * During window destruction, even a locked window can have a
  2792. * NULL parent so use this macro where a NULL parent is a problem.
  2793. */
  2794. #define PWNDPARENT(p) (p->spwndParent ? p->spwndParent : PWNDDESKTOP(p))
  2795. #define ISAMENU(pwwnd) \
  2796. (GETFNID(pwnd) == FNID_MENU)
  2797. /* NEW MENU STUFF */
  2798. typedef struct tagPOPUPMENU
  2799. {
  2800. DWORD fIsMenuBar:1; /* This is a hacked struct which refers to the
  2801. * menu bar associated with a app. Only true if
  2802. * in the root ppopupMenuStruct.
  2803. */
  2804. DWORD fHasMenuBar:1; /* This popup is part of a series which has a
  2805. * menu bar (either a sys menu or top level menu
  2806. * bar)
  2807. */
  2808. DWORD fIsSysMenu:1; /* The system menu is here. */
  2809. DWORD fIsTrackPopup:1; /* Is TrackPopup popup menu */
  2810. DWORD fDroppedLeft:1;
  2811. DWORD fHierarchyDropped:1;/* If true, a submenu has been dropped off this popup */
  2812. DWORD fRightButton:1; /* Allow right button in menu */
  2813. DWORD fToggle:1; /* If TRUE, button up cancels the popup */
  2814. DWORD fSynchronous:1; /* For synchronous return value of cmd chosen */
  2815. DWORD fFirstClick:1; /* Keep track if this was the first click on the
  2816. * top level menu bar item. If the user down/up
  2817. * clicks on a top level menu bar item twice, we
  2818. * want to cancel menu mode.
  2819. */
  2820. DWORD fDropNextPopup:1; /* Should we drop hierarchy of next menu item w/ popup? */
  2821. DWORD fNoNotify:1; /* Don't send WM_ msgs to owner, except WM_COMMAND */
  2822. DWORD fAboutToHide:1; // Same purpose as fHideTimer?
  2823. DWORD fShowTimer:1; // TRUE if the IDSYS_MNSHOW timer is set
  2824. DWORD fHideTimer:1; // TRUE if the IDSYS_MNHIDE timer is set
  2825. DWORD fDestroyed:1; /* Set when the owner menu window has been destroyed
  2826. * so the popup can be freed once it's no longer needed
  2827. * Also set in root popupmenu when menu mode must end
  2828. */
  2829. DWORD fDelayedFree:1; /* Avoid freeing the popup when the owner menu
  2830. * window is destroyed.
  2831. * If set, it must be a root popupmenu or must
  2832. * be linked in ppmDelayedFree
  2833. * This is eventually set for all hierarchical popups
  2834. */
  2835. DWORD fFlushDelayedFree:1; /* Used in root popupmenus only.
  2836. * Set when a hierarchical popup marked as fDelayedFree
  2837. * has been destroyed.
  2838. */
  2839. DWORD fFreed:1; /* Popup has been freed. Used for debug only */
  2840. DWORD fInCancel:1; /* Popup has been passed to xxxMNCancel */
  2841. DWORD fTrackMouseEvent:1; /* TrackMouseEvent has been called */
  2842. DWORD fSendUninit:1; /* Send WM_UNINITMENUPOPUP */
  2843. DWORD fRtoL:1; /* For going backwards with the keys */
  2844. DWORD iDropDir:5; /* Animation direction */
  2845. PWND spwndNotify;
  2846. /* Window who gets the notification messages. If this
  2847. * is a window with a menu bar, then this is the same
  2848. * as hwndPopupMenu.
  2849. */
  2850. PWND spwndPopupMenu;
  2851. /* The window associated with this ppopupMenu struct.
  2852. * If this is a top level menubar, then hwndPopupMenu
  2853. * is the window the menu bar. ie. it isn't really a
  2854. * popup menu window.
  2855. */
  2856. PWND spwndNextPopup;
  2857. /* The next popup in the hierarchy. Null if the last
  2858. * in chain
  2859. */
  2860. PWND spwndPrevPopup;
  2861. /* The previous popup in the hierarchy. NULL if at top
  2862. */
  2863. PMENU spmenu;/* The PMENU displayed in this window
  2864. */
  2865. PMENU spmenuAlternate;
  2866. /* Alternate PMENU. If the system menu is displayed,
  2867. * and a menubar menu exists, this will contain the
  2868. * menubar menu. If menubar menu is displayed, this
  2869. * will contain the system menu. Use only on top level
  2870. * ppopupMenu structs so that we can handle windows
  2871. * with both a system menu and a menu bar menu. Only
  2872. * used in the root ppopupMenuStruct.
  2873. */
  2874. PWND spwndActivePopup; /* This is the popup the mouse/"keyboard focus" is on */
  2875. PPOPUPMENU ppopupmenuRoot;
  2876. PPOPUPMENU ppmDelayedFree; /* List of hierarchical popups marked
  2877. * as fDelayedFree.
  2878. */
  2879. UINT posSelectedItem; /* Position of the selected item in this menu */
  2880. UINT posDropped;
  2881. } POPUPMENU;
  2882. typedef struct tagMENUWND {
  2883. WND wnd;
  2884. PPOPUPMENU ppopupmenu;
  2885. } MENUWND, *PMENUWND;
  2886. /*
  2887. * CheckPoint structure
  2888. */
  2889. typedef struct tagCHECKPOINT {
  2890. RECT rcNormal;
  2891. POINT ptMin;
  2892. POINT ptMax;
  2893. DWORD fDragged:1;
  2894. DWORD fWasMaximizedBeforeMinimized:1;
  2895. DWORD fWasMinimizedBeforeMaximized:1;
  2896. DWORD fMinInitialized:1;
  2897. DWORD fMaxInitialized:1;
  2898. } CHECKPOINT, *PCHECKPOINT;
  2899. typedef struct tagCLIP {
  2900. UINT fmt;
  2901. HANDLE hData;
  2902. BOOL fGlobalHandle;
  2903. } CLIP, *PCLIP;
  2904. /*
  2905. * DDEML instance structure
  2906. */
  2907. typedef struct tagSVR_INSTANCE_INFO {
  2908. THROBJHEAD head;
  2909. struct tagSVR_INSTANCE_INFO *next;
  2910. struct tagSVR_INSTANCE_INFO *nextInThisThread;
  2911. DWORD afCmd;
  2912. PWND spwndEvent;
  2913. PVOID pcii;
  2914. } SVR_INSTANCE_INFO, *PSVR_INSTANCE_INFO;
  2915. typedef struct tagPUBOBJ {
  2916. struct tagPUBOBJ *next;
  2917. HANDLE hObj;
  2918. int count;
  2919. W32PID pid;
  2920. } PUBOBJ, *PPUBOBJ;
  2921. /*
  2922. * Defines for Menu focus
  2923. */
  2924. #define FREEHOLD 0
  2925. #define MOUSEHOLD -1 /* Mouse button held down and dragging */
  2926. #define KEYBDHOLD 1
  2927. /*
  2928. * Structure definition for messages as they exist on a Q. Same as MSG
  2929. * structure except for the link-pointer and flags at the end.
  2930. */
  2931. typedef struct tagQMSG {
  2932. PQMSG pqmsgNext;
  2933. PQMSG pqmsgPrev;
  2934. MSG msg;
  2935. LONG_PTR ExtraInfo;
  2936. DWORD dwQEvent;
  2937. PTHREADINFO pti;
  2938. } QMSG;
  2939. /*
  2940. * dwQEvent values for QMSG structure.
  2941. */
  2942. #define QEVENT_SHOWWINDOW 0x0001
  2943. #define QEVENT_CANCELMODE 0x0002
  2944. #define QEVENT_SETWINDOWPOS 0x0003
  2945. #define QEVENT_UPDATEKEYSTATE 0x0004
  2946. #define QEVENT_DEACTIVATE 0x0005
  2947. #define QEVENT_ACTIVATE 0x0006
  2948. #define QEVENT_POSTMESSAGE 0x0007
  2949. #define QEVENT_DESTROYWINDOW 0x0008
  2950. #define QEVENT_ASYNCSENDMSG 0x0009
  2951. #define QEVENT_HUNGTHREAD 0x000A
  2952. #define QEVENT_CANCELMOUSEMOVETRK 0x000B
  2953. #define QEVENT_NOTIFYWINEVENT 0x000C
  2954. #define QEVENT_RITACCESSIBILITY 0x000D
  2955. #define QEVENT_RITSOUND 0x000E
  2956. #define QEVENT_APPCOMMAND 0x000F
  2957. #define RITSOUND_UPSIREN 0x0000
  2958. #define RITSOUND_DOWNSIREN 0x0001
  2959. #define RITSOUND_LOWBEEP 0x0002
  2960. #define RITSOUND_HIGHBEEP 0x0003
  2961. #define RITSOUND_KEYCLICK 0x0004
  2962. #define RITSOUND_DOBEEP 0x0005
  2963. /*
  2964. * xxxProcessEventMessage flags
  2965. */
  2966. #define PEM_ACTIVATE_RESTORE 0x0001
  2967. #define PEM_ACTIVATE_NOZORDER 0x0002
  2968. typedef struct _MOVESIZEDATA {
  2969. PWND spwnd;
  2970. RECT rcDrag;
  2971. RECT rcDragCursor;
  2972. RECT rcParent;
  2973. POINT ptMinTrack;
  2974. POINT ptMaxTrack;
  2975. RECT rcWindow;
  2976. int dxMouse;
  2977. int dyMouse;
  2978. int cmd;
  2979. int impx;
  2980. int impy;
  2981. POINT ptRestore;
  2982. UINT fInitSize : 1; // should we initialize cursor pos
  2983. UINT fmsKbd : 1; // who knows
  2984. UINT fLockWindowUpdate : 1; // whether screen was locked ok
  2985. UINT fTrackCancelled : 1; // Set if tracking ended by other thread.
  2986. UINT fForeground : 1; // whether the tracking thread is foreground
  2987. // and if we should draw the drag-rect
  2988. UINT fDragFullWindows : 1;
  2989. UINT fOffScreen : 1;
  2990. } MOVESIZEDATA, *PMOVESIZEDATA;
  2991. /*
  2992. * DrawDragRect styles.
  2993. */
  2994. #define DDR_START 0 // - start drag.
  2995. #define DDR_ENDACCEPT 1 // - end and accept
  2996. #define DDR_ENDCANCEL 2 // - end and cancel.
  2997. /*
  2998. * Pseudo Event stuff. (fManualReset := TRUE, fInitState := FALSE)
  2999. */
  3000. DWORD WaitOnPseudoEvent(HANDLE *phE, DWORD dwMilliseconds);
  3001. #define PSEUDO_EVENT_ON ((HANDLE)IntToPtr( 0xFFFFFFFF ))
  3002. #define PSEUDO_EVENT_OFF ((HANDLE)IntToPtr( 0x00000000 ))
  3003. #define INIT_PSEUDO_EVENT(ph) *ph = PSEUDO_EVENT_OFF;
  3004. #define SET_PSEUDO_EVENT(phE) \
  3005. CheckCritIn(); \
  3006. if (*(phE) == PSEUDO_EVENT_OFF) *(phE) = PSEUDO_EVENT_ON; \
  3007. else if (*(phE) != PSEUDO_EVENT_ON) { \
  3008. KeSetEvent(*(phE), EVENT_INCREMENT, FALSE); \
  3009. ObDereferenceObject(*(phE)); \
  3010. *(phE) = PSEUDO_EVENT_ON; \
  3011. }
  3012. #define RESET_PSEUDO_EVENT(phE) \
  3013. CheckCritIn(); \
  3014. if (*(phE) == PSEUDO_EVENT_ON) *(phE) = PSEUDO_EVENT_OFF; \
  3015. else if (*(phE) != PSEUDO_EVENT_OFF) { \
  3016. KeClearEvent(*(phE)); \
  3017. }
  3018. #define CLOSE_PSEUDO_EVENT(phE) \
  3019. CheckCritIn(); \
  3020. if (*(phE) == PSEUDO_EVENT_ON) *(phE) = PSEUDO_EVENT_OFF; \
  3021. else if (*(phE) != PSEUDO_EVENT_OFF) { \
  3022. KeSetEvent(*(phE), EVENT_INCREMENT, FALSE); \
  3023. ObDereferenceObject(*(phE)); \
  3024. *(phE) = PSEUDO_EVENT_OFF; \
  3025. }
  3026. typedef struct tagMLIST {
  3027. PQMSG pqmsgRead; // next message to be read. This is a FIFO queue
  3028. PQMSG pqmsgWriteLast; // last message added to the queue. Used mainly for coalescing
  3029. DWORD cMsgs; // Count of messages. Used for optimizations and to enforce a max.
  3030. } MLIST, *PMLIST;
  3031. /*
  3032. * Message Queue structure.
  3033. *
  3034. * Note, if you need to add a WORD sized value,
  3035. * do so after xbtnDblClk.
  3036. */
  3037. typedef struct tagQ {
  3038. MLIST mlInput; // raw mouse and key message list.
  3039. PTHREADINFO ptiSysLock; // Thread currently allowed to process input
  3040. ULONG_PTR idSysLock; // Last message removed or to be removed before unlocking
  3041. ULONG_PTR idSysPeek; // Last message peeked
  3042. PTHREADINFO ptiMouse; // Last thread to get mouse msg.
  3043. PTHREADINFO ptiKeyboard;
  3044. PWND spwndCapture;
  3045. PWND spwndFocus;
  3046. PWND spwndActive;
  3047. PWND spwndActivePrev;
  3048. UINT codeCapture; // type of captue. See *_CAP* defines in this file
  3049. UINT msgDblClk; // last mouse down message removed
  3050. WORD xbtnDblClk; // last xbutton down
  3051. DWORD timeDblClk; // max time for next button down to be taken as double click
  3052. HWND hwndDblClk; // window that got last button down
  3053. POINT ptDblClk; // last button down position. See SYSMET(C?DOUBLECLK)
  3054. BYTE afKeyRecentDown[CBKEYSTATERECENTDOWN];
  3055. BYTE afKeyState[CBKEYSTATE];
  3056. CARET caret;
  3057. PCURSOR spcurCurrent;
  3058. int iCursorLevel; // show/hide count. < 0 if the cursor is not visible
  3059. DWORD QF_flags; // QF_ flags go here
  3060. USHORT cThreads; // Count of threads using this queue
  3061. USHORT cLockCount; // Count of threads that don't want this queue freed
  3062. UINT msgJournal; // See SetJournalTimer. Journal message to be delivered when timer goes off
  3063. LONG_PTR ExtraInfo; // Extra info for last qmsg read. See GetMessageExtraInfo
  3064. } Q;
  3065. /*
  3066. * Used for zzzAttachThreadInput()
  3067. */
  3068. typedef struct tagATTACHINFO {
  3069. struct tagATTACHINFO *paiNext;
  3070. PTHREADINFO pti1;
  3071. PTHREADINFO pti2;
  3072. } ATTACHINFO, *PATTACHINFO;
  3073. #define POLL_EVENT_CNT 5
  3074. #define IEV_IDLE 0
  3075. #define IEV_INPUT 1
  3076. #define IEV_EXEC 2
  3077. #define IEV_TASK 3
  3078. #define IEV_WOWEXEC 4
  3079. typedef struct tagWOWTHREADINFO {
  3080. struct tagWOWTHREADINFO *pwtiNext;
  3081. DWORD idTask; // WOW task id
  3082. ULONG_PTR idWaitObject; // pseudo handle returned to parent
  3083. DWORD idParentProcess; // process that called CreateProcess
  3084. PKEVENT pIdleEvent; // event that WaitForInputIdle will wait on
  3085. } WOWTHREADINFO, *PWOWTHREADINFO;
  3086. /*
  3087. * Task Data Block structure.
  3088. */
  3089. typedef struct tagTDB {
  3090. PTDB ptdbNext;
  3091. int nEvents;
  3092. int nPriority;
  3093. PTHREADINFO pti;
  3094. PWOWTHREADINFO pwti; // per thread info for shared Wow
  3095. WORD hTaskWow; // Wow cookie to find apps during shutdown
  3096. WORD TDB_Flags; // bit 0 means setup app
  3097. } TDB;
  3098. #define TDBF_SETUP 1
  3099. /*
  3100. * Hack message for shell to tell them a setup app is exiting.
  3101. * This message is defined in \nt\private\shell\inc, but I really
  3102. * don't want to introduce that dependency in the build. DavidDS
  3103. * has put a check in that file to make sure that the value does not
  3104. * change and refers to this usage. FritzS
  3105. */
  3106. #define DTM_SETUPAPPRAN (WM_USER+90)
  3107. /*
  3108. * Menu animation GDI objects.
  3109. */
  3110. typedef struct tagMENUANIDC
  3111. {
  3112. HDC hdcAni; // Scratch dc for animation
  3113. } MENUANIDC;
  3114. /*
  3115. * Menu Control Structure
  3116. */
  3117. typedef struct tagMENUSTATE {
  3118. PPOPUPMENU pGlobalPopupMenu;
  3119. DWORD fMenuStarted : 1;
  3120. DWORD fIsSysMenu : 1;
  3121. DWORD fInsideMenuLoop : 1;
  3122. DWORD fButtonDown:1;
  3123. DWORD fInEndMenu:1;
  3124. DWORD fUnderline:1; /* Shorcut key underlines are shown */
  3125. DWORD fButtonAlwaysDown:1; /* The mouse has always been down since the menu started */
  3126. DWORD fDragging:1; /* Dragging (in DoDragDrop) or about to */
  3127. DWORD fModelessMenu:1; /* No modal loop */
  3128. DWORD fInCallHandleMenuMessages:1;/* processing a msg from CallHandleMM */
  3129. DWORD fDragAndDrop:1; /* This menu can do drag and drop */
  3130. DWORD fAutoDismiss:1; /* This menu goes away on its own if mouse is off for certain time */
  3131. DWORD fAboutToAutoDismiss:1; /* Autodismiss will take place when timer goes off */
  3132. DWORD fIgnoreButtonUp:1; /* Eat next button up, i.e, cancel dragging */
  3133. DWORD fMouseOffMenu:1; /* Mouse is off the menu - modeless menus only */
  3134. DWORD fInDoDragDrop:1; /* in a WM_MENUDODRAGDROP callback */
  3135. DWORD fActiveNoForeground:1; /* A menu window is active but we're not in the foreground */
  3136. DWORD fNotifyByPos:1; /* Use WM_MENUCOMMAND */
  3137. DWORD fSetCapture:1; /* True if the menu mode set capture */
  3138. DWORD iAniDropDir:5; /* direction of animation */
  3139. POINT ptMouseLast;
  3140. int mnFocus;
  3141. int cmdLast;
  3142. PTHREADINFO ptiMenuStateOwner;
  3143. DWORD dwLockCount;
  3144. struct tagMENUSTATE *pmnsPrev; /* Previous menustate for nested/context menus */
  3145. POINT ptButtonDown; /* Mouse down position (begin drag position) */
  3146. ULONG_PTR uButtonDownHitArea; /* Return from xxxMNFindWindowFromPoint on button down */
  3147. UINT uButtonDownIndex; /* Index of the item being dragged */
  3148. int vkButtonDown; /* Mouse button being dragged */
  3149. ULONG_PTR uDraggingHitArea; /* Last hit area while InDoDragDrop */
  3150. UINT uDraggingIndex; /* Last index */
  3151. UINT uDraggingFlags; /* Gap flags */
  3152. HDC hdcWndAni; // window DC while animating
  3153. DWORD dwAniStartTime; // starting time of animation
  3154. int ixAni; // current x-step in animation
  3155. int iyAni; // current y-step in animation
  3156. int cxAni; // total x in animation
  3157. int cyAni; // total y in animation
  3158. HBITMAP hbmAni; // Scratch bmp for animation.
  3159. /*
  3160. * Important: The following structure must be the last
  3161. * thing in tagMENUSTATE. MNAllocMenuState doesn't NULL out
  3162. * this structure
  3163. */
  3164. MENUANIDC;
  3165. } MENUSTATE, *PMENUSTATE;
  3166. typedef struct tagLASTINPUT { /* linp */
  3167. DWORD timeLastInputMessage;
  3168. DWORD dwFlags;
  3169. PTHREADINFO ptiLastWoken; /* Last thread woken by key or click */
  3170. /* It can be NULL */
  3171. POINT ptLastClick; /* point of the last mouse click */
  3172. } LASTINPUT, PLASTINPUT;
  3173. #define LINP_KEYBOARD 0x00000001
  3174. #define LINP_SCREENSAVER 0x00000002
  3175. #define LINP_LOWPOWER 0x00000004
  3176. #define LINP_POWEROFF 0x00000008
  3177. #define LINP_JOURNALLING 0x00000010
  3178. #define LINP_INPUTSOURCES (LINP_KEYBOARD | LINP_JOURNALLING)
  3179. #define LINP_POWERTIMEOUTS (LINP_LOWPOWER | LINP_POWEROFF)
  3180. #define LINP_INPUTTIMEOUTS (LINP_SCREENSAVER | LINP_LOWPOWER | LINP_POWEROFF)
  3181. /*
  3182. * Menu data to be passed to xxxRealDrawMenuItem from xxxDrawState
  3183. */
  3184. typedef struct {
  3185. PMENU pMenu;
  3186. PITEM pItem;
  3187. } GRAYMENU, *PGRAYMENU;
  3188. #define IS_THREAD_RESTRICTED(pti, r) \
  3189. ((pti->TIF_flags & TIF_RESTRICTED) ? \
  3190. (pti->ppi->pW32Job->restrictions & (r)) : \
  3191. FALSE)
  3192. #define IS_CURRENT_THREAD_RESTRICTED(r) \
  3193. ((PtiCurrent()->TIF_flags & TIF_RESTRICTED) ? \
  3194. (PtiCurrent()->ppi->pW32Job->restrictions & (r)) : \
  3195. FALSE)
  3196. /*
  3197. * These types are needed before they are fully defined.
  3198. */
  3199. typedef struct tagSMS * KPTR_MODIFIER PSMS;
  3200. /*
  3201. * Make sure this structure matches up with W32THREAD, since they're
  3202. * really the same thing.
  3203. */
  3204. /*
  3205. * NOTE -- this structure has been sorted (roughly) in order of use
  3206. * of the fields. The x86 code set allows cheaper access to fields
  3207. * that are in the first 0x80 bytes of a structure. Please attempt
  3208. * to ensure that frequently-used fields are below this boundary.
  3209. * FritzS
  3210. */
  3211. typedef struct tagTHREADINFO {
  3212. W32THREAD;
  3213. //***************************************** begin: USER specific fields
  3214. PTL ptl; // Listhead for thread lock list
  3215. PPROCESSINFO ppi; // process info struct for this thread
  3216. PQ pq; // keyboard and mouse input queue
  3217. PKL spklActive; // active keyboard layout for this thread
  3218. PCLIENTTHREADINFO pcti; // Info that must be visible from client
  3219. PDESKTOP rpdesk;
  3220. PDESKTOPINFO pDeskInfo; // Desktop info visible to client
  3221. ULONG_PTR ulClientDelta; // Desktop heap client delta
  3222. PCLIENTINFO pClientInfo; // Client info stored in TEB
  3223. DWORD TIF_flags; // TIF_ flags go here.
  3224. PUNICODE_STRING pstrAppName; // Application module name.
  3225. PSMS psmsSent; // Most recent SMS this thread has sent
  3226. PSMS psmsCurrent; // Received SMS this thread is currently processing
  3227. PSMS psmsReceiveList; // SMSs to be processed
  3228. LONG timeLast; // Time and ID of last message
  3229. ULONG_PTR idLast;
  3230. int exitCode;
  3231. HDESK hdesk; // Desktop handle
  3232. int cPaintsReady;
  3233. UINT cTimersReady;
  3234. PMENUSTATE pMenuState;
  3235. union {
  3236. PTDB ptdb; // Win16Task Schedule data for WOW thread
  3237. PWINDOWSTATION pwinsta; // Window station for SYSTEM thread
  3238. };
  3239. PSVR_INSTANCE_INFO psiiList; // thread DDEML instance list
  3240. DWORD dwExpWinVer;
  3241. DWORD dwCompatFlags; // The Win 3.1 Compat flags
  3242. DWORD dwCompatFlags2; // new DWORD to extend compat flags for NT5+ features
  3243. PQ pqAttach; // calculation variabled used in
  3244. // zzzAttachThreadInput()
  3245. PTHREADINFO ptiSibling; // pointer to sibling thread info
  3246. PMOVESIZEDATA pmsd;
  3247. DWORD fsHooks; // WHF_ Flags for which hooks are installed
  3248. PHOOK sphkCurrent; // Hook this thread is currently processing
  3249. PSBTRACK pSBTrack;
  3250. HANDLE hEventQueueClient;
  3251. PKEVENT pEventQueueServer;
  3252. LIST_ENTRY PtiLink; // Link to other threads on desktop
  3253. int iCursorLevel; // keep track of each thread's level
  3254. POINT ptLast; // Position of last message
  3255. PWND spwndDefaultIme; // Default IME Window for this thread
  3256. PIMC spDefaultImc; // Default input context for this thread
  3257. HKL hklPrev; // Previous active keyboard layout
  3258. int cEnterCount;
  3259. MLIST mlPost; // posted message list.
  3260. USHORT fsChangeBitsRemoved;// Bits removed during PeekMessage
  3261. WCHAR wchInjected; // character from last VK_PACKET
  3262. DWORD fsReserveKeys; // Keys that must be sent to the active
  3263. // active console window.
  3264. PKEVENT *apEvent; // Wait array for xxxPollAndWaitForSingleObject
  3265. ACCESS_MASK amdesk; // Granted desktop access
  3266. UINT cWindows; // Number of windows owned by this thread
  3267. UINT cVisWindows; // Number of visible windows on this thread
  3268. PHOOK aphkStart[CWINHOOKS]; // Hooks registered for this thread
  3269. CLIENTTHREADINFO cti; // Use this when no desktop is available
  3270. #ifdef GENERIC_INPUT
  3271. HANDLE hPrevHidData;
  3272. #endif
  3273. #if DBG
  3274. UINT cNestedCalls;
  3275. #endif
  3276. } THREADINFO;
  3277. #define PWNDTOPSBTRACK(pwnd) (((GETPTI(pwnd)->pSBTrack)))
  3278. /*
  3279. * The number of library module handles we can store in the dependency
  3280. * tables. If this exceeds 32, the load mask implementation must be
  3281. * changed.
  3282. */
  3283. #define CLIBS 32
  3284. /*
  3285. * Process Info structure.
  3286. */
  3287. typedef struct tagWOWPROCESSINFO {
  3288. struct tagWOWPROCESSINFO *pwpiNext; // List of WOW ppi's, gppiFirstWow is head
  3289. PTHREADINFO ptiScheduled; // current thread in nonpreemptive scheduler
  3290. PTDB ptdbHead; // list of this process's WOW tasks
  3291. PVOID lpfnWowExitTask; // func addr for wow exittask callback
  3292. PKEVENT pEventWowExec; // WowExec Virt HWint scheduler event
  3293. HANDLE hEventWowExecClient; // client handle value for wowexec
  3294. DWORD nSendLock; // Send Scheduler inter process Send count
  3295. DWORD nRecvLock; // Send Scheduler inter process Receive count
  3296. PTHREADINFO CSOwningThread; // Pseudo Wow CritSect ClientThreadId
  3297. LONG CSLockCount; // Pseudo Wow CritSect LockCount
  3298. } WOWPROCESSINFO, *PWOWPROCESSINFO;
  3299. typedef struct tagDESKTOPVIEW {
  3300. struct tagDESKTOPVIEW *pdvNext;
  3301. PDESKTOP pdesk;
  3302. ULONG_PTR ulClientDelta;
  3303. } DESKTOPVIEW, *PDESKTOPVIEW;
  3304. /*
  3305. * number of DWORDs in ppi->pgh
  3306. */
  3307. #define GH_SIZE 8
  3308. /*
  3309. * The delta allocation for ppiTable array in W32JOB structure.
  3310. */
  3311. #define JP_DELTA 4
  3312. /*
  3313. * W32JOB structure
  3314. */
  3315. typedef struct tagW32JOB {
  3316. struct tagW32JOB* pNext; // next W32JOB structure
  3317. PEJOB Job; // pointer to the EJOB structure
  3318. PVOID pAtomTable; // the atom table for the job object
  3319. DWORD restrictions; // UI restrictions
  3320. UINT uProcessCount; // number of processes in ppiTable
  3321. UINT uMaxProcesses; // how much room is in ppiTable
  3322. PPROCESSINFO* ppiTable; // the array of processes contained in the job
  3323. UINT ughCrt; // crt number of handles in pgh
  3324. UINT ughMax; // number of handles pgh can store
  3325. PULONG_PTR pgh; // the granted handles table
  3326. } W32JOB, *PW32JOB;
  3327. #ifdef REDIRECTION
  3328. #define PF_REDIRECTED 0x00000001
  3329. #define PF_REDIRECTIONHOST 0x00000002
  3330. #endif // REDIRECTION
  3331. /*
  3332. * Make sure this structure matches up with W32PROCESS, since they're
  3333. * really the same thing.
  3334. */
  3335. /*
  3336. * NOTE -- this structure has been sorted (roughly) in order of use
  3337. * of the fields. The x86 code set allows cheaper access to fields
  3338. * that are in the first 0x80 bytes of a structure. Please attempt
  3339. * to ensure that frequently-used fields are below this boundary.
  3340. */
  3341. typedef struct tagPROCESSINFO {
  3342. W32PROCESS;
  3343. //***************************************** begin: USER specific fields
  3344. PTHREADINFO ptiList; // threads in this process
  3345. PTHREADINFO ptiMainThread; // pti of "main thread"
  3346. PDESKTOP rpdeskStartup; // initial desktop
  3347. PCLS pclsPrivateList; // this processes' private classes
  3348. PCLS pclsPublicList; // this processes' public classes
  3349. PWOWPROCESSINFO pwpi; // Wow PerProcess Info
  3350. PPROCESSINFO ppiNext; // next ppi structure in start list
  3351. PPROCESSINFO ppiNextRunning;
  3352. int cThreads; // count of threads using this process info
  3353. HDESK hdeskStartup; // initial desktop handle
  3354. UINT cSysExpunge; // sys expunge counter
  3355. DWORD dwhmodLibLoadedMask; // bits describing loaded hook dlls
  3356. HANDLE ahmodLibLoaded[CLIBS]; // process unique hmod array for hook dlls
  3357. struct tagWINDOWSTATION *rpwinsta; // process windowstation
  3358. HWINSTA hwinsta; // windowstation handle
  3359. ACCESS_MASK amwinsta; // windowstation accesses
  3360. DWORD dwHotkey; // hot key from progman
  3361. HMONITOR hMonitor; // monitor handle from CreateProcess
  3362. PDESKTOPVIEW pdvList; // list of desktop views
  3363. UINT iClipSerialNumber; // clipboard serial number
  3364. RTL_BITMAP bmHandleFlags; // per handle flags
  3365. PCURSOR pCursorCache; // process cursor/icon cache
  3366. PVOID pClientBase; // LEAVE THIS FOR HYDRA; offset to the shared section
  3367. DWORD dwLpkEntryPoints; // user mode language pack installed
  3368. PW32JOB pW32Job; // pointer to the W32JOB structure
  3369. DWORD dwImeCompatFlags; // per-process Ime Compatibility flags
  3370. LUID luidSession; // logon session id
  3371. USERSTARTUPINFO usi; // process startup info
  3372. #ifdef VALIDATEHANDLEQUOTA
  3373. LONG lHandles;
  3374. #endif
  3375. DWORD dwLayout; // the default Window orientation for this process
  3376. #ifdef GENERIC_INPUT
  3377. PPROCESS_HID_TABLE pHidTable; // per process device request list
  3378. #endif
  3379. #ifdef REDIRECTION
  3380. DWORD dwRedirection; // redirection mode for this process
  3381. #endif
  3382. } PROCESSINFO;
  3383. /*
  3384. * Bit definitions for dwLpkEntryPoints in the processinfo structure.
  3385. * These are passed from the client side when an lpk is registered.
  3386. * The kernel determines when to perform callbacks based on which
  3387. * entry points an lpk supports.
  3388. */
  3389. #define LPK_TABBEDTEXTOUT 0x01
  3390. #define LPK_PSMTEXTOUT 0x02
  3391. #define LPK_DRAWTEXTEX 0x04
  3392. #define LPK_EDITCONTROL 0x08
  3393. #define LPK_INSTALLED 0x0f
  3394. #define CALL_LPK(ptiCurrent) ((PpiCurrent()->dwLpkEntryPoints & LPK_INSTALLED) && \
  3395. !((ptiCurrent)->TIF_flags & TIF_INCLEANUP))
  3396. /*
  3397. * This is used to send cool switch windows information
  3398. * to the lpk
  3399. */
  3400. typedef struct _LPKDRAWSWITCHWND {
  3401. RECT rcRect;
  3402. LARGE_UNICODE_STRING strName;
  3403. } LPKDRAWSWITCHWND;
  3404. /*
  3405. * DC cache entry structure (DCE)
  3406. *
  3407. * This structure identifies an entry in the DCE cache. It is
  3408. * usually initialized at GetDCEx() and cleanded during RelaseCacheDC
  3409. * calls.
  3410. *
  3411. * Field
  3412. * -----
  3413. *
  3414. * pdceNext - Pointer to the next DCE entry.
  3415. *
  3416. *
  3417. * hdc - GDI DC handle for the dce entry. This will have
  3418. * the necessary clipping regions selected into it.
  3419. *
  3420. * pwndOrg - Identifies the window in the GetDCEx() call which owns
  3421. * the DCE Entry.
  3422. *
  3423. * pwndClip - Identifies the window by which the DC is clipped to.
  3424. * This is usually done for PARENTDC windows.
  3425. *
  3426. * hrgnClip - This region is set if the caller to GetDCEx() passes a
  3427. * clipping region in which to intersect with the visrgn.
  3428. * This is used when we need to recalc the visrgn for the
  3429. * DCE entry. This will be freed at ReleaseCacheDC()
  3430. * time if the flag doesn't have DCX_NODELETERGN set.
  3431. *
  3432. * hrgnClipPublic - This is a copy of the (hrgnClip) passed in above. We
  3433. * make a copy and set it as PUBLIC ownership so that
  3434. * we can use it in computations during the UserSetDCVisRgn
  3435. * call. This is necessary for Full-Hung-Draw where we
  3436. * are drawing from a different process then the one
  3437. * who created the (hrgnClip). This is always deleted
  3438. * in the ReleaseCacheDC() call.
  3439. *
  3440. * hrgnSavedVis - This is a copy of the saved visrgn for the DCE entry.
  3441. *
  3442. * flags - DCX_ flags.
  3443. *
  3444. * ptiOwner - Thread owner of the DCE entry.
  3445. *
  3446. */
  3447. typedef struct tagDCE {
  3448. PDCE pdceNext;
  3449. HDC hdc;
  3450. PWND pwndOrg;
  3451. PWND pwndClip;
  3452. HRGN hrgnClip;
  3453. HRGN hrgnClipPublic;
  3454. HRGN hrgnSavedVis;
  3455. DWORD DCX_flags;
  3456. PTHREADINFO ptiOwner;
  3457. PMONITOR pMonitor;
  3458. } DCE;
  3459. #define DCE_SIZE_CACHEINIT 5 // Initial number of DCEs in the cache.
  3460. #define DCE_SIZE_CACHETHRESHOLD 32 // Number of dce's as a threshold.
  3461. #define DCE_RELEASED 0 // ReleaseDC released
  3462. #define DCE_FREED 1 // ReleaseDC freed
  3463. #define DCE_NORELEASE 2 // ReleaseDC in-use.
  3464. /*
  3465. * CalcVisRgn DC type bits
  3466. */
  3467. #define DCUNUSED 0x00 /* Unused cache entry */
  3468. #define DCC 0x01 /* Client area */
  3469. #define DCW 0x02 /* Window area */
  3470. #define DCSAVEDVISRGN 0x04
  3471. #define DCCLIPRGN 0x08
  3472. #define DCNOCHILDCLIP 0x10 /* Nochildern clip */
  3473. #define DCSAVEVIS 0x20 /* Save visrgn before calculating */
  3474. #define DCCACHE 0x40
  3475. /*
  3476. * THREAD_CODEPAGE()
  3477. *
  3478. * Returns the CodePage based on the current keyboard layout.
  3479. */
  3480. #define _THREAD_CODEPAGE() (GetClientInfo()->CodePage)
  3481. _inline WORD THREAD_CODEPAGE() {
  3482. WORD CodePage;
  3483. try {
  3484. CodePage = _THREAD_CODEPAGE();
  3485. } except (W32ExceptionHandler(FALSE, RIP_WARNING)) {
  3486. CodePage = PtiCurrent()->spklActive ? PtiCurrent()->spklActive->CodePage : CP_ACP;
  3487. }
  3488. return CodePage;
  3489. }
  3490. /*
  3491. * Window List Structure
  3492. */
  3493. typedef struct tagBWL {
  3494. struct tagBWL *pbwlNext;
  3495. HWND *phwndNext;
  3496. HWND *phwndMax;
  3497. PTHREADINFO ptiOwner;
  3498. HWND rghwnd[1];
  3499. } BWL, *PBWL;
  3500. /*
  3501. * Numbers of HWND slots to to start with and to increase by.
  3502. */
  3503. #define BWL_CHWNDINIT 32 /* initial # slots pre-allocated */
  3504. #define BWL_CHWNDMORE 8 /* # slots to obtain when required */
  3505. #define BWL_ENUMCHILDREN 1
  3506. #define BWL_ENUMLIST 2
  3507. #define BWL_ENUMOWNERLIST 4
  3508. #define BWL_ENUMIMELAST 0x08
  3509. #define BWL_REMOVEIMECHILD 0x10
  3510. /*
  3511. * Saved Popup Bits structure
  3512. */
  3513. typedef struct tagSPB {
  3514. struct tagSPB *pspbNext;
  3515. PWND spwnd;
  3516. HBITMAP hbm;
  3517. RECT rc;
  3518. HRGN hrgn;
  3519. DWORD flags;
  3520. ULONG_PTR ulSaveId;
  3521. } SPB;
  3522. #define SPB_SAVESCREENBITS 0x0001 // GreSaveScreenBits() was called
  3523. #define SPB_LOCKUPDATE 0x0002 // LockWindowUpdate() SPB
  3524. #define SPB_DRAWBUFFER 0x0004 // BeginDrawBuffer() SPB
  3525. #define AnySpbs() (gpDispInfo->pspbFirst != NULL) // TRUE if there are any SPBs
  3526. /*
  3527. * Macro to check if the journal playback hook is installed.
  3528. */
  3529. #define FJOURNALRECORD() (GETDESKINFO(PtiCurrent())->aphkStart[WH_JOURNALRECORD + 1] != NULL)
  3530. #define FJOURNALPLAYBACK() (GETDESKINFO(PtiCurrent())->aphkStart[WH_JOURNALPLAYBACK + 1] != NULL)
  3531. #define TESTHMODLOADED(pti, x) ((pti)->ppi->dwhmodLibLoadedMask & (1 << (x)))
  3532. #define SETHMODLOADED(pti, x, hmod) ((pti)->ppi->ahmodLibLoaded[x] = hmod, \
  3533. (pti)->ppi->dwhmodLibLoadedMask |= (1 << (x)))
  3534. #define CLEARHMODLOADED(pti, x) ((pti)->ppi->ahmodLibLoaded[x] = NULL, \
  3535. (pti)->ppi->dwhmodLibLoadedMask &= ~(1 << (x)))
  3536. #define PFNHOOK(phk) (phk->ihmod == -1 ? (PROC)phk->offPfn : \
  3537. (PROC)(((ULONG_PTR)(PtiCurrent()->ppi->ahmodLibLoaded[phk->ihmod])) + \
  3538. ((ULONG_PTR)(phk->offPfn))))
  3539. /*
  3540. * Extended structures for message thunking.
  3541. */
  3542. typedef struct _CREATESTRUCTEX {
  3543. CREATESTRUCT cs;
  3544. LARGE_STRING strName;
  3545. LARGE_STRING strClass;
  3546. } CREATESTRUCTEX, *PCREATESTRUCTEX;
  3547. typedef struct _MDICREATESTRUCTEX {
  3548. MDICREATESTRUCT mdics;
  3549. LARGE_STRING strTitle;
  3550. LARGE_STRING strClass;
  3551. } MDICREATESTRUCTEX, *PMDICREATESTRUCTEX;
  3552. typedef struct _CWPSTRUCTEX {
  3553. struct tagCWPSTRUCT;
  3554. PSMS psmsSender;
  3555. } CWPSTRUCTEX, *PCWPSTRUCTEX;
  3556. typedef struct _CWPRETSTRUCTEX {
  3557. LRESULT lResult;
  3558. struct tagCWPSTRUCT;
  3559. PSMS psmsSender;
  3560. } CWPRETSTRUCTEX, *PCWPRETSTRUCTEX;
  3561. /*
  3562. * SendMessage structure and defines.
  3563. */
  3564. typedef struct tagSMS { /* sms */
  3565. PSMS psmsNext; // link in global psmsList
  3566. #if DBG
  3567. PSMS psmsSendList; // head of queue's SendMessage chain
  3568. PSMS psmsSendNext; // link in queue's SendMessage chain
  3569. #endif // DBG
  3570. PSMS psmsReceiveNext; // link in queue's ReceiveList
  3571. PTHREADINFO ptiSender; // sending thread
  3572. PTHREADINFO ptiReceiver; // receiving thread
  3573. SENDASYNCPROC lpResultCallBack; // function to receive the SendMessageCallback return value
  3574. ULONG_PTR dwData; // value to be passed back to the lpResultCallBack function
  3575. PTHREADINFO ptiCallBackSender; // sending thread
  3576. LRESULT lRet; // message return value
  3577. DWORD tSent; // time message was sent
  3578. UINT flags; // SMF_ flags
  3579. WPARAM wParam; // message fields...
  3580. LPARAM lParam;
  3581. UINT message;
  3582. PWND spwnd;
  3583. PVOID pvCapture; // captured argument data
  3584. } SMS;
  3585. #define SMF_REPLY 0x0001 // message has been replied to
  3586. #define SMF_RECEIVERDIED 0x0002 // receiver has died
  3587. #define SMF_SENDERDIED 0x0004 // sender has died
  3588. #define SMF_RECEIVERFREE 0x0008 // receiver should free sms when done
  3589. #define SMF_RECEIVEDMESSAGE 0x0010 // sms has been received
  3590. #define SMF_CB_REQUEST 0x0100 // SendMessageCallback requested
  3591. #define SMF_CB_REPLY 0x0200 // SendMessageCallback reply
  3592. #define SMF_CB_CLIENT 0x0400 // Client process request
  3593. #define SMF_CB_SERVER 0x0800 // Server process request
  3594. #define SMF_WOWRECEIVE 0x1000 // wow sched has incr recv count
  3595. #define SMF_WOWSEND 0x2000 // wow sched has incr send count
  3596. #define SMF_RECEIVERBUSY 0x4000 // reciver is processing this msg
  3597. /*
  3598. * InterSendMsgEx parameter used for SendMessageCallback and TimeOut
  3599. */
  3600. typedef struct tagINTERSENDMSGEX { /* ism */
  3601. UINT fuCall; // callback or timeout call
  3602. SENDASYNCPROC lpResultCallBack; // function to receive the send message value
  3603. ULONG_PTR dwData; // Value to be passed back to the SendResult call back function
  3604. LRESULT lRet; // return value from the send message
  3605. UINT fuSend; // how to send the message, SMTO_BLOCK, SMTO_ABORTIFHUNG
  3606. UINT uTimeout; // time-out duration
  3607. PULONG_PTR lpdwResult; // the return value for a syncornis call
  3608. } INTRSENDMSGEX, *PINTRSENDMSGEX;
  3609. #define ISM_CALLBACK 0x0001 // callback function request
  3610. #define ISM_TIMEOUT 0x0002 // timeout function request
  3611. #define ISM_REQUEST 0x0010 // callback function request message
  3612. #define ISM_REPLY 0x0020 // callback function reply message
  3613. #define ISM_CB_CLIENT 0x0100 // client process callback function
  3614. /*
  3615. * Event structure to handle broadcasts of notification messages.
  3616. */
  3617. typedef struct tagASYNCSENDMSG {
  3618. WPARAM wParam;
  3619. LPARAM lParam;
  3620. UINT message;
  3621. HWND hwnd;
  3622. } ASYNCSENDMSG, *PASYNCSENDMSG;
  3623. /*
  3624. * HkCallHook() structure
  3625. */
  3626. #define IsHooked(pti, fsHook) \
  3627. ((fsHook & (pti->fsHooks | pti->pDeskInfo->fsHooks)) != 0)
  3628. #define IsGlobalHooked(pti, fsHook) \
  3629. ((fsHook & pti->pDeskInfo->fsHooks) != 0)
  3630. typedef struct tagHOOKMSGSTRUCT { /* hch */
  3631. PHOOK phk;
  3632. int nCode;
  3633. LPARAM lParam;
  3634. } HOOKMSGSTRUCT, *PHOOKMSGSTRUCT;
  3635. /*
  3636. * BroadcastMessage() commands.
  3637. */
  3638. #define BMSG_SENDMSG 0x0000
  3639. #define BMSG_SENDNOTIFYMSG 0x0001
  3640. #define BMSG_POSTMSG 0x0002
  3641. #define BMSG_SENDMSGCALLBACK 0x0003
  3642. #define BMSG_SENDMSGTIMEOUT 0x0004
  3643. #define BMSG_SENDNOTIFYMSGPROCESS 0x0005
  3644. /*
  3645. * xxxBroadcastMessage parameter used for SendMessageCallback and TimeOut
  3646. */
  3647. typedef union tagBROADCASTMSG { /* bcm */
  3648. struct { // for callback broadcast
  3649. SENDASYNCPROC lpResultCallBack; // function to receive the send message value
  3650. ULONG_PTR dwData; // Value to be passed back to the SendResult call back function
  3651. BOOL bClientRequest; // if a cliet or server callback request
  3652. } cb;
  3653. struct { // for timeout broadcast
  3654. UINT fuFlags; // timeout type flags
  3655. UINT uTimeout; // timeout length
  3656. PULONG_PTR lpdwResult; // where to put the return value
  3657. } to;
  3658. } BROADCASTMSG, *PBROADCASTMSG;
  3659. /*
  3660. * Internal hotkey structures and defines.
  3661. */
  3662. typedef struct tagHOTKEY {
  3663. PTHREADINFO pti;
  3664. PWND spwnd;
  3665. WORD fsModifiers; // MOD_SHIFT, MOD_ALT, MOD_CONTROL, MOD_WIN
  3666. WORD wFlags; // MOD_SAS
  3667. UINT vk;
  3668. int id;
  3669. struct tagHOTKEY *phkNext;
  3670. } HOTKEY, *PHOTKEY;
  3671. #define PWND_INPUTOWNER (PWND)1 // Means send WM_HOTKEY to input owner.
  3672. #define PWND_FOCUS (PWND)NULL // Means send WM_HOTKEY to queue's pwndFocus.
  3673. #define PWND_TOP (PWND)0
  3674. #define PWND_BOTTOM (PWND)1
  3675. #define PWND_GROUPTOTOP ((PWND)-1)
  3676. #define PWND_TOPMOST ((PWND)-1)
  3677. #define PWND_NOTOPMOST ((PWND)-2)
  3678. #define PWND_BROADCAST ((PWND)-1)
  3679. #define IDHOT_DEBUG (-5)
  3680. #define IDHOT_DEBUGSERVER (-6)
  3681. #define IDHOT_WINDOWS (-7)
  3682. /*
  3683. * xPos, yPos for WM_CONTEXTMENU from keyboard
  3684. */
  3685. #define KEYBOARD_MENU ((LPARAM)-1) // Keyboard generated menu
  3686. /*
  3687. * Capture codes
  3688. */
  3689. #define NO_CAP_CLIENT 0 /* no capture; in client area */
  3690. #define NO_CAP_SYS 1 /* no capture; in sys area */
  3691. #define CLIENT_CAPTURE 2 /* client-relative capture */
  3692. #define WINDOW_CAPTURE 3 /* window-relative capture */
  3693. #define SCREEN_CAPTURE 4 /* screen-relative capture */
  3694. #define FULLSCREEN_CAPTURE 5 /* capture entire machine */
  3695. #define CLIENT_CAPTURE_INTERNAL 6 /* client-relative capture (Win 3.1 style; won't release) */
  3696. #define CH_HELPPREFIX 0x08
  3697. #ifdef KANJI
  3698. #define CH_KANJI1 0x1D
  3699. #define CH_KANJI2 0x1E
  3700. #define CH_KANJI3 0x1F
  3701. #endif // KANJI
  3702. #define xxxRedrawScreen() \
  3703. xxxInternalInvalidate(PtiCurrent()->rpdesk->pDeskInfo->spwnd, \
  3704. HRGN_FULL, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN)
  3705. /*
  3706. * Preallocated buffer for use during SetWindowPos to prevent memory
  3707. * allocation failures.
  3708. */
  3709. #define CCVR_WORKSPACE 4
  3710. /*
  3711. * DrawIconCallBack data, global only for state data in tmswitch.c
  3712. */
  3713. typedef struct tagDRAWICONCB { /* dicb */
  3714. PWND pwndTop; // Window being drawn
  3715. UINT cx; // x offset for icon
  3716. UINT cy; // y offset for icon
  3717. } DRAWICONCB, *PDRAWICONCB;
  3718. /*
  3719. * The following defines the components of nKeyboardSpeed
  3720. */
  3721. #define KSPEED_MASK 0x001F // Defines the key repeat speed.
  3722. #define KDELAY_MASK 0x0060 // Defines the keyboard delay.
  3723. #define KDELAY_SHIFT 5
  3724. /*
  3725. * Property list checkpoint int
  3726. */
  3727. #define PROP_CHECKPOINT MAKEINTATOM(atomCheckpointProp)
  3728. #define PROP_DDETRACK MAKEINTATOM(atomDDETrack)
  3729. #define PROP_QOS MAKEINTATOM(atomQOS)
  3730. #define PROP_DDEIMP MAKEINTATOM(atomDDEImp)
  3731. #define PROP_WNDOBJ MAKEINTATOM(atomWndObj)
  3732. #define PROP_IMELEVEL MAKEINTATOM(atomImeLevel)
  3733. #define PROP_LAYER MAKEINTATOM(atomLayer)
  3734. #define WinFlags ((WORD)(&__WinFlags))
  3735. /*
  3736. * ntinput.c
  3737. */
  3738. BOOL xxxInternalKeyEventDirect(
  3739. BYTE bVk,
  3740. WORD wScan,
  3741. DWORD dwFlags,
  3742. DWORD dwTime,
  3743. ULONG_PTR dwExtraInfo);
  3744. UINT xxxSendInput(
  3745. UINT nInputs,
  3746. LPINPUT pInputs);
  3747. BOOL _BlockInput(
  3748. BOOL fBlockIt);
  3749. int _GetMouseMovePointsEx(
  3750. CONST MOUSEMOVEPOINT* ppt,
  3751. MOUSEMOVEPOINT* pptBuf,
  3752. UINT nPoints,
  3753. DWORD resolution);
  3754. VOID xxxProcessKeyEvent(
  3755. PKE pke,
  3756. ULONG_PTR ExtraInformation,
  3757. BOOL bInjected);
  3758. VOID xxxButtonEvent(
  3759. DWORD ButtonNumber,
  3760. POINT ptPointer,
  3761. BOOL fBreak,
  3762. DWORD time,
  3763. ULONG_PTR ExtraInfo,
  3764. #ifdef GENERIC_INPUT
  3765. HANDLE hDevice,
  3766. PMOUSE_INPUT_DATA pmei,
  3767. #endif
  3768. BOOL bInjected,
  3769. BOOL fDblClk);
  3770. VOID xxxMoveEvent(
  3771. LONG dx,
  3772. LONG dy,
  3773. DWORD dwFlags,
  3774. ULONG_PTR dwExtraInfo,
  3775. #ifdef GENERIC_INPUT
  3776. HANDLE hDevice,
  3777. PMOUSE_INPUT_DATA pmei,
  3778. #endif
  3779. DWORD time,
  3780. BOOL bInjected
  3781. );
  3782. typedef struct _RIT_INIT {
  3783. PTERMINAL pTerm;
  3784. PKEVENT pRitReadyEvent;
  3785. } RIT_INIT, *PRIT_INIT;
  3786. PDEVICEINFO StartDeviceRead(PDEVICEINFO pDeviceInfo);
  3787. NTSTATUS DeviceNotify(
  3788. IN PPLUGPLAY_NOTIFY_HDR pNotification,
  3789. IN PDEVICEINFO pDeviceInfo);
  3790. #define MOUSE_SENSITIVITY_MIN 1
  3791. #define MOUSE_SENSITIVITY_DEFAULT 10
  3792. #define MOUSE_SENSITIVITY_MAX 20
  3793. LONG CalculateMouseSensitivity(LONG lSens);
  3794. PDEVICEINFO FreeDeviceInfo(PDEVICEINFO pMouseInfo);
  3795. __inline PTHREADINFO PtiKbdFromQ(PQ pq)
  3796. {
  3797. if (pq->spwndActive) {
  3798. return GETPTI(pq->spwndActive);
  3799. }
  3800. UserAssert(pq->ptiKeyboard);
  3801. return pq->ptiKeyboard;
  3802. }
  3803. __inline PTHREADINFO ValidatePtiKbd(PQ pq)
  3804. {
  3805. if (pq == NULL) {
  3806. return NULL;
  3807. }
  3808. return PtiKbdFromQ(pq);
  3809. }
  3810. __inline PTHREADINFO PtiMouseFromQ(PQ pq)
  3811. {
  3812. if (pq->spwndCapture) {
  3813. return GETPTI(pq->spwndCapture);
  3814. }
  3815. UserAssert(pq->ptiMouse);
  3816. return pq->ptiMouse;
  3817. }
  3818. __inline PTHREADINFO ValidatePtiMouse(PQ pq)
  3819. {
  3820. if (pq == NULL) {
  3821. return NULL;
  3822. }
  3823. return PtiMouseFromQ(pq);
  3824. }
  3825. VOID QueueMouseEvent(
  3826. USHORT ButtonFlags,
  3827. USHORT ButtonData,
  3828. ULONG_PTR ExtraInfo,
  3829. POINT ptMouse,
  3830. LONG time,
  3831. #ifdef GENERIC_INPUT
  3832. HANDLE hDevice,
  3833. PMOUSE_INPUT_DATA pmei,
  3834. #endif
  3835. BOOL bInjected,
  3836. BOOL bWakeRIT
  3837. );
  3838. typedef struct {
  3839. DWORD dwVersion;
  3840. DWORD dwFlags;
  3841. DWORD dwMapCount;
  3842. DWORD dwMap[0];
  3843. } SCANCODEMAP, *PSCANCODEMAP;
  3844. #ifndef SCANCODE_NUMPAD_PLUS
  3845. #define SCANCODE_NUMPAD_PLUS (0x4e)
  3846. #endif
  3847. #ifndef SCANCODE_NUMPAD_DOT
  3848. #define SCANCODE_NUMPAD_DOT (0x53)
  3849. #endif
  3850. /*
  3851. * Flag (LowLevel and HighLevel) for
  3852. * hex Alt+Numpad mode.
  3853. * If you need to add a new flag for gfInNumpadHexInput,
  3854. * note the variable is BYTE.
  3855. */
  3856. #define NUMPAD_HEXMODE_LL (1)
  3857. #define NUMPAD_HEXMODE_HL (2)
  3858. #define MODIFIER_FOR_ALT_NUMPAD(wModBit) \
  3859. (((wModBits) == KBDALT) || ((wModBits) == (KBDALT | KBDSHIFT)) || \
  3860. ((wModBits) == (KBDKANA | KBDALT)) || ((wModBits) == (KBDKANA | KBDALT | KBDSHIFT)))
  3861. BOOL UnqueueMouseEvent(PMOUSEEVENT pme);
  3862. BYTE VKFromVSC(PKE pke, BYTE bPrefix, LPBYTE afKeyState);
  3863. BOOL KEOEMProcs(PKE pke);
  3864. BOOL xxxKELocaleProcs(PKE pke);
  3865. BOOL xxxKENLSProcs(PKE pke, ULONG_PTR dwExtraInformation);
  3866. VOID xxxKeyEvent(USHORT usVk, WORD wScanCode, DWORD time, ULONG_PTR ExtraInfo,
  3867. #ifdef GENERIC_INPUT
  3868. HANDLE hDevice,
  3869. PKEYBOARD_INPUT_DATA pkei,
  3870. #endif
  3871. BOOL bInjected);
  3872. typedef BITMAPINFOHEADER *PBMPHEADER, *LPBMPHEADER;
  3873. VOID xxxSimpleDoSyncPaint(PWND pwnd);
  3874. VOID xxxDoSyncPaint(PWND pwnd, DWORD flags);
  3875. VOID xxxInternalDoSyncPaint(PWND pwnd, DWORD flags);
  3876. /*
  3877. * NOTE: the first 4 values must be as defined for backward compatibility
  3878. * reasons. They are sent as parameters to the WM_SYNCPAINT message.
  3879. * They used to be hard-coded constants.
  3880. *
  3881. * Only ENUMCLIPPEDCHILDREN, ALLCHILDREN, and NOCHECKPARENTS are passed on
  3882. * during recursion. The other bits reflect the current window only.
  3883. */
  3884. #define DSP_ERASE 0x0001 // Send WM_ERASEBKGND
  3885. #define DSP_FRAME 0x0002 // Send WM_NCPAINT
  3886. #define DSP_ENUMCLIPPEDCHILDREN 0x0004 // Enum children if WS_CLIPCHILDREN
  3887. #define DSP_WM_SYNCPAINT 0x0008 // Called from WM_SYNCPAINT handler
  3888. #define DSP_NOCHECKPARENTS 0x0010 // Don't check parents for update region
  3889. #define DSP_ALLCHILDREN 0x0020 // Enumerate all children.
  3890. BOOL xxxDrawAnimatedRects(
  3891. PWND pwndClip,
  3892. int idAnimation,
  3893. LPRECT lprcStart,
  3894. LPRECT lprcEnd);
  3895. typedef struct tagTIMER {
  3896. HEAD head;
  3897. struct tagTIMER *ptmrNext;
  3898. struct tagTIMER *ptmrPrev;
  3899. PTHREADINFO pti;
  3900. struct tagWND * spwnd;
  3901. UINT_PTR nID;
  3902. DWORD cmsCountdown;
  3903. DWORD cmsRate;
  3904. UINT flags;
  3905. TIMERPROC_PWND pfn;
  3906. PTHREADINFO ptiOptCreator; // Used for journal playback -- Will be NULL
  3907. // if timer was created by non-GUI thread.
  3908. } TIMER, *PTIMER;
  3909. UINT_PTR InternalSetTimer(PWND pwnd, UINT_PTR nIDEvent, UINT dwElapse,
  3910. TIMERPROC_PWND pTimerFunc, UINT flags);
  3911. VOID FreeTimer(PTIMER ptmr);
  3912. /*
  3913. * Call FindTimer() with fKill == TRUE and TMRF_RIT. This will basically
  3914. * delete the timer.
  3915. */
  3916. #define KILLRITTIMER(pwnd, nID) FindTimer(pwnd, nID, TMRF_RIT, TRUE)
  3917. /*
  3918. * Raster Ops
  3919. */
  3920. #define PATOR 0x00FA0089L /* destination, pattern, or */
  3921. /*
  3922. * Message thunks.
  3923. */
  3924. typedef LRESULT (APIENTRY *SFNSCSENDMESSAGE)(PWND, UINT, WPARAM, LPARAM,
  3925. ULONG_PTR, PROC, DWORD, PSMS);
  3926. #define SMESSAGEPROTO(func) \
  3927. LRESULT CALLBACK Sfn ## func( \
  3928. PWND pwnd, UINT msg, WPARAM wParam, LPARAM lParam, \
  3929. ULONG_PTR xParam, PROC xpfnWndProc, DWORD dwSCMSFlags, PSMS psms)
  3930. SMESSAGEPROTO(SENTDDEMSG);
  3931. SMESSAGEPROTO(DDEINIT);
  3932. SMESSAGEPROTO(DWORD);
  3933. SMESSAGEPROTO(NCDESTROY);
  3934. SMESSAGEPROTO(INWPARAMCHAR);
  3935. SMESSAGEPROTO(INWPARAMDBCSCHAR);
  3936. SMESSAGEPROTO(GETTEXTLENGTHS);
  3937. SMESSAGEPROTO(GETDBCSTEXTLENGTHS);
  3938. SMESSAGEPROTO(INLPCREATESTRUCT);
  3939. SMESSAGEPROTO(INLPDROPSTRUCT);
  3940. SMESSAGEPROTO(INOUTLPPOINT5);
  3941. SMESSAGEPROTO(INOUTLPSCROLLINFO);
  3942. SMESSAGEPROTO(INOUTLPRECT);
  3943. SMESSAGEPROTO(INOUTNCCALCSIZE);
  3944. SMESSAGEPROTO(OUTLPRECT);
  3945. SMESSAGEPROTO(INLPMDICREATESTRUCT);
  3946. SMESSAGEPROTO(INLPCOMPAREITEMSTRUCT);
  3947. SMESSAGEPROTO(INLPDELETEITEMSTRUCT);
  3948. SMESSAGEPROTO(INLPHLPSTRUCT);
  3949. SMESSAGEPROTO(INLPHELPINFOSTRUCT); // WINHELP4
  3950. SMESSAGEPROTO(INLPDRAWITEMSTRUCT);
  3951. SMESSAGEPROTO(INOUTLPMEASUREITEMSTRUCT);
  3952. SMESSAGEPROTO(INSTRING);
  3953. SMESSAGEPROTO(INPOSTEDSTRING);
  3954. SMESSAGEPROTO(INSTRINGNULL);
  3955. SMESSAGEPROTO(OUTSTRING);
  3956. SMESSAGEPROTO(INCNTOUTSTRING);
  3957. SMESSAGEPROTO(POUTLPINT);
  3958. SMESSAGEPROTO(POPTINLPUINT);
  3959. SMESSAGEPROTO(INOUTLPWINDOWPOS);
  3960. SMESSAGEPROTO(INLPWINDOWPOS);
  3961. SMESSAGEPROTO(INLBOXSTRING);
  3962. SMESSAGEPROTO(OUTLBOXSTRING);
  3963. SMESSAGEPROTO(INCBOXSTRING);
  3964. SMESSAGEPROTO(OUTCBOXSTRING);
  3965. SMESSAGEPROTO(INCNTOUTSTRINGNULL);
  3966. SMESSAGEPROTO(INOUTDRAG);
  3967. SMESSAGEPROTO(FULLSCREEN);
  3968. SMESSAGEPROTO(INPAINTCLIPBRD);
  3969. SMESSAGEPROTO(INSIZECLIPBRD);
  3970. SMESSAGEPROTO(OUTDWORDDWORD);
  3971. SMESSAGEPROTO(OUTDWORDINDWORD);
  3972. SMESSAGEPROTO(OPTOUTLPDWORDOPTOUTLPDWORD);
  3973. SMESSAGEPROTO(DWORDOPTINLPMSG);
  3974. SMESSAGEPROTO(COPYGLOBALDATA);
  3975. SMESSAGEPROTO(COPYDATA);
  3976. SMESSAGEPROTO(INDESTROYCLIPBRD);
  3977. SMESSAGEPROTO(INOUTNEXTMENU);
  3978. SMESSAGEPROTO(INOUTSTYLECHANGE);
  3979. SMESSAGEPROTO(IMAGEIN);
  3980. SMESSAGEPROTO(IMAGEOUT);
  3981. SMESSAGEPROTO(INDEVICECHANGE);
  3982. SMESSAGEPROTO(INOUTMENUGETOBJECT);
  3983. SMESSAGEPROTO(POWERBROADCAST);
  3984. SMESSAGEPROTO(LOGONNOTIFY);
  3985. SMESSAGEPROTO(IMECONTROL);
  3986. SMESSAGEPROTO(IMEREQUEST);
  3987. SMESSAGEPROTO(INLPKDRAWSWITCHWND);
  3988. SMESSAGEPROTO(OUTLPCOMBOBOXINFO);
  3989. SMESSAGEPROTO(OUTLPSCROLLBARINFO);
  3990. /***************************************************************************\
  3991. * Function Prototypes
  3992. *
  3993. * NOTE: Only prototypes for GLOBAL (across module) functions should be put
  3994. * here. Prototypes for functions that are global to a single module should
  3995. * be put at the head of that module.
  3996. *
  3997. * LATER: There's still lots of bogus trash in here to be cleaned out.
  3998. *
  3999. \***************************************************************************/
  4000. /*
  4001. * Random prototypes.
  4002. */
  4003. DWORD _GetWindowContextHelpId(
  4004. PWND pwnd);
  4005. BOOL _SetWindowContextHelpId(
  4006. PWND pwnd,
  4007. DWORD dwContextId);
  4008. void xxxSendHelpMessage(
  4009. PWND pwnd,
  4010. int iType,
  4011. int iCtrlId,
  4012. HANDLE hItemHandle,
  4013. DWORD dwContextId);
  4014. HPALETTE _SelectPalette(
  4015. HDC hdc,
  4016. HPALETTE hpalette,
  4017. BOOL fForceBackground);
  4018. int xxxRealizePalette(
  4019. HDC hdc);
  4020. VOID xxxFlushPalette(
  4021. PWND pwnd);
  4022. VOID xxxBroadcastPaletteChanged(
  4023. PWND pwnd,
  4024. BOOL fForceDesktop);
  4025. PCURSOR SearchIconCache(
  4026. PCURSOR pCursorCache,
  4027. ATOM atomModName,
  4028. PUNICODE_STRING pstrResName,
  4029. PCURSOR pCursorSrc,
  4030. PCURSORFIND pcfSearch);
  4031. VOID ZombieCursor(PCURSOR pcur);
  4032. BOOL IsSmallerThanScreen(PWND pwnd);
  4033. BOOL zzzSetSystemCursor(
  4034. PCURSOR pcur,
  4035. DWORD id);
  4036. BOOL zzzSetSystemImage(
  4037. PCURSOR pcur,
  4038. PCURSOR pcurOld);
  4039. BOOL _InternalGetIconInfo(
  4040. IN PCURSOR pcur,
  4041. OUT PICONINFO piconinfo,
  4042. OUT OPTIONAL PUNICODE_STRING pstrModName,
  4043. OUT OPTIONAL PUNICODE_STRING pstrResName,
  4044. OUT OPTIONAL LPDWORD pbpp,
  4045. IN BOOL fInternalCursor);
  4046. VOID LinkCursor(
  4047. PCURSOR pcur);
  4048. BOOL _SetCursorIconData(
  4049. PCURSOR pcur,
  4050. PUNICODE_STRING pstrModName,
  4051. PUNICODE_STRING pstrResName,
  4052. PCURSORDATA pData,
  4053. DWORD cbData);
  4054. PCURSOR _GetCursorFrameInfo(
  4055. PCURSOR pcur,
  4056. int iFrame,
  4057. PJIF pjifRate,
  4058. LPINT pccur);
  4059. BOOL zzzSetSystemCursor(
  4060. PCURSOR pcur,
  4061. DWORD id);
  4062. PCURSOR _FindExistingCursorIcon(
  4063. ATOM atomModName,
  4064. PUNICODE_STRING pstrResName,
  4065. PCURSOR pcurSrc,
  4066. PCURSORFIND pcfSearch);
  4067. HCURSOR _CreateEmptyCursorObject(
  4068. BOOL fPublic);
  4069. BOOL _GetUserObjectInformation(HANDLE h,
  4070. int nIndex, PVOID pvInfo, DWORD nLength, LPDWORD lpnLengthNeeded);
  4071. BOOL _SetUserObjectInformation(HANDLE h,
  4072. int nIndex, PVOID pvInfo, DWORD nLength);
  4073. DWORD xxxWaitForInputIdle(ULONG_PTR idProcess, DWORD dwMilliseconds,
  4074. BOOL fSharedWow);
  4075. VOID StartScreenSaver(BOOL bOnlyIfSecure);
  4076. UINT InternalMapVirtualKeyEx(UINT wCode, UINT wType, PKBDTABLES pKbdTbl);
  4077. SHORT InternalVkKeyScanEx(WCHAR cChar, PKBDTABLES pKbdTbl);
  4078. PWND ParentNeedsPaint(PWND pwnd);
  4079. VOID SetHungFlag(PWND pwnd, WORD wFlag);
  4080. VOID ClearHungFlag(PWND pwnd, WORD wFlag);
  4081. BOOL _DdeSetQualityOfService(PWND pwndClient,
  4082. CONST PSECURITY_QUALITY_OF_SERVICE pqosNew,
  4083. PSECURITY_QUALITY_OF_SERVICE pqosOld);
  4084. BOOL _DdeGetQualityOfService(PWND pwndClient,
  4085. PWND pwndServer, PSECURITY_QUALITY_OF_SERVICE pqos);
  4086. BOOL QueryTrackMouseEvent(LPTRACKMOUSEEVENT lpTME);
  4087. void CancelMouseHover(PQ pq);
  4088. void ResetMouseTracking(PQ pq, PWND pwnd);
  4089. void _SetIMEShowStatus(BOOL fShow);
  4090. BOOL _GetIMEShowStatus(VOID);
  4091. /*
  4092. * Prototypes for internal version of APIs.
  4093. */
  4094. PWND _FindWindowEx(PWND pwndParent, PWND pwndChild,
  4095. LPCWSTR pszClass, LPCWSTR pszName, DWORD dwType);
  4096. UINT APIENTRY GreSetTextAlign(HDC, UINT);
  4097. UINT APIENTRY GreGetTextAlign(HDC);
  4098. /*
  4099. * Prototypes for validation, RIP, error handling, etc functions.
  4100. */
  4101. PWND FASTCALL ValidateHwnd(HWND hwnd);
  4102. NTSTATUS ValidateHwinsta(HWINSTA, KPROCESSOR_MODE, ACCESS_MASK, PWINDOWSTATION*);
  4103. NTSTATUS ValidateHdesk(HDESK, KPROCESSOR_MODE, ACCESS_MASK, PDESKTOP*);
  4104. PMENU ValidateHmenu(HMENU hmenu);
  4105. PMONITOR ValidateHmonitor(HMONITOR hmonitor);
  4106. HRGN UserValidateCopyRgn(HRGN);
  4107. BOOL ValidateHandleSecure(HANDLE h);
  4108. NTSTATUS UserJobCallout(PKWIN32_JOBCALLOUT_PARAMETERS Parm);
  4109. BOOL RemoveProcessFromJob(PPROCESSINFO ppi);
  4110. BOOL xxxActivateDebugger(UINT fsModifiers);
  4111. void ClientDied(void);
  4112. VOID SendMsgCleanup(PTHREADINFO ptiCurrent);
  4113. VOID ReceiverDied(PSMS psms, PSMS *ppsmsUnlink);
  4114. LRESULT xxxInterSendMsgEx(PWND, UINT, WPARAM, LPARAM, PTHREADINFO, PTHREADINFO, PINTRSENDMSGEX );
  4115. VOID ClearSendMessages(PWND pwnd);
  4116. PPCLS GetClassPtr(ATOM atom, PPROCESSINFO ppi, HANDLE hModule);
  4117. BOOL ReferenceClass(PCLS pcls, PWND pwnd);
  4118. VOID DereferenceClass(PWND pwnd);
  4119. ULONG_PTR MapClientToServerPfn(ULONG_PTR dw);
  4120. VOID xxxReceiveMessage(PTHREADINFO);
  4121. #define xxxReceiveMessages(pti) \
  4122. while ((pti)->pcti->fsWakeBits & QS_SENDMESSAGE) { xxxReceiveMessage((pti)); }
  4123. PBWL BuildHwndList(PWND pwnd, UINT flags, PTHREADINFO ptiOwner);
  4124. VOID FreeHwndList(PBWL pbwl);
  4125. #define MINMAX_KEEPHIDDEN 0x1
  4126. #define MINMAX_ANIMATE 0x10000
  4127. PWND xxxMinMaximize(PWND pwnd, UINT cmd, DWORD dwFlags);
  4128. void xxxMinimizeHungWindow(PWND pwnd);
  4129. VOID xxxInitSendValidateMinMaxInfo(PWND pwnd, LPMINMAXINFO lpmmi);
  4130. HRGN CreateEmptyRgn(void);
  4131. HRGN CreateEmptyRgnPublic(void);
  4132. HRGN SetOrCreateRectRgnIndirectPublic(HRGN * phrgn, LPCRECT lprc);
  4133. BOOL SetEmptyRgn(HRGN hrgn);
  4134. BOOL SetRectRgnIndirect(HRGN hrgn, LPCRECT lprc);
  4135. void RegisterCDROMNotify(void);
  4136. NTSTATUS xxxRegisterForDeviceClassNotifications();
  4137. VOID xxxUnregisterDeviceClassNotifications();
  4138. BOOL xxxInitInput(PTERMINAL);
  4139. VOID InitMice();
  4140. void UpdateMouseInfo(void);
  4141. BOOL OpenMouse(PDEVICEINFO pMouseInfo);
  4142. void ProcessDeviceChanges(DWORD DeviceType);
  4143. PDEVICEINFO CreateDeviceInfo(DWORD DeviceType, PUNICODE_STRING SymbolicLinkName, BYTE bFlags);
  4144. void InitKeyboard(void);
  4145. void InitKeyboardState(void);
  4146. UINT xxxHardErrorControl(DWORD, HANDLE, PDESKRESTOREDATA);
  4147. #define MAX_RETRIES_TO_OPEN 30
  4148. #define UPDATE_KBD_TYPEMATIC 1
  4149. #define UPDATE_KBD_LEDS 2
  4150. VOID SetKeyboardRate(UINT nKeySpeed);
  4151. VOID RecolorDeskPattern(VOID);
  4152. BOOL xxxInitWindowStation(VOID);
  4153. VOID zzzInternalSetCursorPos(int x, int y);
  4154. VOID UpdateKeyLights(BOOL bInjected);
  4155. VOID SetDebugHotKeys(VOID);
  4156. VOID BoundCursor(LPPOINT lppt);
  4157. void DestroyKF(PKBDFILE pkf);
  4158. VOID DestroyKL(PKL pkl);
  4159. VOID CleanupKeyboardLayouts(VOID);
  4160. BOOL xxxSetDeskPattern(PUNICODE_STRING pProfileUserName,LPWSTR lpPat, BOOL fCreation);
  4161. BOOL xxxSetDeskWallpaper(PUNICODE_STRING pProfileUserName,LPWSTR lpszFile);
  4162. HPALETTE CreateDIBPalette(LPBITMAPINFOHEADER pbmih, UINT colors);
  4163. BOOL CalcVisRgn(HRGN* hrgn, PWND pwndOrg, PWND pwndClip, DWORD flags);
  4164. NTSTATUS xxxCreateThreadInfo(PETHREAD pEThread);
  4165. BOOL DestroyProcessInfo(PW32PROCESS);
  4166. VOID RawInputThread(PVOID pVoid);
  4167. HANDLE GetRemoteProcessId(VOID);
  4168. VOID HandleSystemThreadCreationFailure(BOOL bRemoteThread);
  4169. VOID xxxCreateSystemThreads(BOOL bRemoteThread);
  4170. VOID xxxDesktopThread(PTERMINAL pTerm);
  4171. VOID ForceEmptyClipboard(PWINDOWSTATION);
  4172. NTSTATUS zzzInitTask(UINT dwExpWinVer, DWORD dwAppCompatFlags, DWORD dwUserWOWCompatFlags,
  4173. PUNICODE_STRING pstrModName, PUNICODE_STRING pstrBaseFileName,
  4174. DWORD hTaskWow, DWORD dwHotkey, DWORD idTask,
  4175. DWORD dwX, DWORD dwY, DWORD dwXSize, DWORD dwYSize);
  4176. VOID DestroyTask(PPROCESSINFO ppi, PTHREADINFO ptiToRemove);
  4177. BOOL PostInputMessage(PQ pq, PWND pwnd, UINT message, WPARAM wParam,
  4178. LPARAM lParam, DWORD time, ULONG_PTR dwExtraInfo);
  4179. PWND PwndForegroundCapture(VOID);
  4180. BOOL xxxSleepThread(UINT fsWakeMask, DWORD Timeout, BOOL fForegroundIdle);
  4181. VOID SetWakeBit(PTHREADINFO pti, UINT wWakeBit);
  4182. VOID WakeSomeone(PQ pq, UINT message, PQMSG pqmsg);
  4183. VOID ClearWakeBit(PTHREADINFO pti, UINT wWakeBit, BOOL fSysCheck);
  4184. NTSTATUS xxxInitProcessInfo(PW32PROCESS);
  4185. PTHREADINFO PtiFromThreadId(DWORD idThread);
  4186. BOOL zzzAttachThreadInput(PTHREADINFO ptiAttach, PTHREADINFO ptiAttachTo, BOOL fAttach);
  4187. BOOL zzzReattachThreads(BOOL fJournalAttach);
  4188. PQ AllocQueue(PTHREADINFO, PQ);
  4189. VOID FreeQueue(PQ pq);
  4190. VOID FreeCachedQueues(VOID);
  4191. VOID CleanupGDI(VOID);
  4192. VOID CleanupResources(VOID);
  4193. VOID zzzDestroyQueue(PQ pq, PTHREADINFO pti);
  4194. PQMSG AllocQEntry(PMLIST pml);
  4195. __inline VOID FreeQEntry(PQMSG pqmsg)
  4196. {
  4197. extern PPAGED_LOOKASIDE_LIST QEntryLookaside;
  4198. ExFreeToPagedLookasideList(QEntryLookaside, pqmsg);
  4199. }
  4200. VOID DelQEntry(PMLIST pml, PQMSG pqmsg);
  4201. VOID zzzAttachToQueue(PTHREADINFO pti, PQ pqAttach, PQ pqJournal,
  4202. BOOL fJoiningForeground);
  4203. VOID xxxProcessEventMessage(PTHREADINFO ptiCurrent, PQMSG pqmsg);
  4204. VOID xxxProcessSetWindowPosEvent(PSMWP psmwpT);
  4205. VOID xxxProcessAsyncSendMessage(PASYNCSENDMSG pmsg);
  4206. BOOL PostEventMessage(PTHREADINFO pti, PQ pq, DWORD dwQEvent, PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  4207. BOOL xxxDoPaint(PWND pwndFilter, LPMSG lpMsg);
  4208. BOOL DoTimer(PWND pwndFilter);
  4209. BOOL CheckPwndFilter(PWND pwnd, PWND pwndFilter);
  4210. #define WHT_IGNOREDISABLED 0x00000001
  4211. #ifdef REDIRECTION
  4212. #define WHT_FAKESPEEDHITTEST 0x00000002
  4213. PWND xxxCallSpeedHitTestHook(POINT* ppt);
  4214. VOID PushMouseMove(PQ pq, POINT pt);
  4215. VOID PopMouseMove(PQ pq, POINT* ppt);
  4216. #endif // REDIRECTION
  4217. BOOL xxxGetCursorPos(LPPOINT lpPt);
  4218. HWND xxxWindowHitTest(PWND pwnd, POINT pt, int *pipos, DWORD dwHitTestFlags);
  4219. HWND xxxWindowHitTest2(PWND pwnd, POINT pt, int *pipos, DWORD dwHitTestFlags);
  4220. PWND SpeedHitTest(PWND pwndParent, POINT pt);
  4221. VOID xxxDeactivate(PTHREADINFO pti, DWORD tidSetForeground);
  4222. #define SFW_STARTUP 0x0001
  4223. #define SFW_SWITCH 0x0002
  4224. #define SFW_NOZORDER 0x0004
  4225. #define SFW_SETFOCUS 0x0008
  4226. #define SFW_ACTIVATERESTORE 0x0010
  4227. BOOL xxxSetForegroundWindow2(PWND pwnd, PTHREADINFO ptiCurrent, DWORD fFlags);
  4228. VOID SetForegroundThread(PTHREADINFO pti);
  4229. VOID xxxSendFocusMessages(PTHREADINFO pti, PWND pwndReceive);
  4230. #define ATW_MOUSE 0x0001
  4231. #define ATW_SETFOCUS 0x0002
  4232. #define ATW_ASYNC 0x0004
  4233. #define ATW_NOZORDER 0x0008
  4234. BOOL FBadWindow(PWND pwnd);
  4235. BOOL xxxActivateThisWindow(PWND pwnd, DWORD tidLoseForeground, DWORD fFlags);
  4236. BOOL xxxActivateWindow(PWND pwnd, UINT cmd);
  4237. #define NTW_PREVIOUS 1
  4238. #define NTW_IGNORETOOLWINDOW 2
  4239. PWND NextTopWindow(PTHREADINFO pti, PWND pwnd, PWND pwndSkip, DWORD flags);
  4240. int xxxMouseActivate(PTHREADINFO pti, PWND pwnd, UINT message, WPARAM wParam, LPPOINT lppt, int ht);
  4241. int UT_GetParentDCClipBox(PWND pwnd, HDC hdc, LPRECT lprc);
  4242. VOID UpdateAsyncKeyState(PQ pq, UINT wVK, BOOL fBreak);
  4243. void PostUpdateKeyStateEvent(PQ pq);
  4244. void ProcessUpdateKeyStateEvent(PQ pq, CONST PBYTE pbKeyState, CONST PBYTE pbRecentDown);
  4245. BOOL InternalSetProp(PWND pwnd, LPWSTR pszKey, HANDLE hData, DWORD dwFlags);
  4246. HANDLE InternalRemoveProp(PWND pwnd, LPWSTR pszKey, BOOL fInternal);
  4247. VOID DeleteProperties(PWND pwnd);
  4248. CHECKPOINT *CkptRestore(PWND pwnd, LPCRECT lprcWindow);
  4249. UINT_PTR _SetTimer(PWND pwnd, UINT_PTR nIDEvent, UINT dwElapse, TIMERPROC_PWND pTimerFunc);
  4250. BOOL KillTimer2(PWND pwnd, UINT_PTR nIDEvent, BOOL fSystemTimer);
  4251. VOID DestroyThreadsTimers(PTHREADINFO pti);
  4252. VOID DecTimerCount(PTHREADINFO pti);
  4253. VOID zzzInternalShowCaret();
  4254. VOID zzzInternalHideCaret();
  4255. VOID zzzInternalDestroyCaret();
  4256. VOID ChangeAcquireResourceType(VOID);
  4257. VOID EnterCrit(VOID);
  4258. VOID EnterSharedCrit(VOID);
  4259. VOID LeaveCrit(VOID);
  4260. VOID _AssertCritIn(VOID);
  4261. VOID _AssertDeviceInfoListCritIn(VOID);
  4262. VOID _AssertCritInShared(VOID);
  4263. VOID _AssertCritOut(VOID);
  4264. VOID _AssertDeviceInfoListCritOut(VOID);
  4265. NTSTATUS _KeUserModeCallback(
  4266. IN ULONG ApiNumber,
  4267. IN PVOID InputBuffer,
  4268. IN ULONG InputLength,
  4269. OUT PVOID *OutputBuffer,
  4270. OUT PULONG OutputLength);
  4271. #define UnlockProcess ObDereferenceObject
  4272. #define UnlockThread ObDereferenceObject
  4273. extern ULONG gSessionId;
  4274. #if DBG
  4275. #define ValidateProcessSessionId(pEProcess) \
  4276. UserAssert(PsGetProcessSessionId(pEProcess) == gSessionId)
  4277. #define ValidateThreadSessionId(pEThread) \
  4278. UserAssert(PsGetThreadSessionId(pEThread) == gSessionId)
  4279. #else
  4280. #define ValidateProcessSessionId(pEProcess)
  4281. #define ValidateThreadSessionId(pEThread)
  4282. #endif
  4283. __inline NTSTATUS LockProcessByClientId(
  4284. HANDLE dwProcessId,
  4285. PEPROCESS* ppEProcess)
  4286. {
  4287. NTSTATUS Status;
  4288. Status = PsLookupProcessByProcessId(dwProcessId, ppEProcess);
  4289. if (NT_SUCCESS(Status) && (PsGetProcessSessionId(*ppEProcess) != gSessionId)) {
  4290. UnlockProcess(*ppEProcess);
  4291. return STATUS_UNSUCCESSFUL;
  4292. }
  4293. return Status;
  4294. }
  4295. __inline NTSTATUS LockThreadByClientId(
  4296. HANDLE dwThreadId,
  4297. PETHREAD* ppEThread)
  4298. {
  4299. NTSTATUS Status;
  4300. Status = PsLookupThreadByThreadId(dwThreadId, ppEThread);
  4301. if (NT_SUCCESS(Status) && (PsGetThreadSessionId(*ppEThread) != gSessionId)) {
  4302. UnlockThread(*ppEThread);
  4303. return STATUS_UNSUCCESSFUL;
  4304. }
  4305. return Status;
  4306. }
  4307. BOOL IsSAS(BYTE vk, UINT* pfsModifiers);
  4308. BOOL xxxDoHotKeyStuff(UINT vk, BOOL fBreak, DWORD fsReserveKeys);
  4309. PHOTKEY IsHotKey(UINT fsModifiers, UINT vk);
  4310. void ClearCachedHotkeyModifiers(void);
  4311. /*
  4312. * Server.c
  4313. */
  4314. #define USER_WINDOWSECT_SIZE 512
  4315. #define USER_NOIOSECT_SIZE 128
  4316. #define USR_LOGONSECT_SIZE 128
  4317. #define USR_DISCONNECTSECT_SIZE 64
  4318. #define NOIO_DESKTOP_NUMBER 10
  4319. BOOL InitCreateUserCrit(VOID);
  4320. PMDEV InitVideo(
  4321. BOOL bReenumerationNeeded);
  4322. /*
  4323. * DRVSUP.C
  4324. */
  4325. BOOL InitUserScreen();
  4326. VOID InitLoadResources();
  4327. typedef struct tagDISPLAYRESOURCE {
  4328. WORD cyThunb;
  4329. WORD cxThumb;
  4330. WORD xCompressIcon;
  4331. WORD yCompressIcon;
  4332. WORD xCompressCursor;
  4333. WORD yCompressCursor;
  4334. WORD yKanji;
  4335. WORD cxBorder;
  4336. WORD cyBorder;
  4337. } DISPLAYRESOURCE, *PDISPLAYRESOURCE;
  4338. VOID xxxUserResetDisplayDevice(VOID);
  4339. /*
  4340. * Object management and security
  4341. */
  4342. #define DEFAULT_WINSTA L"\\Windows\\WindowStations\\WinSta0"
  4343. #define POBJECT_NAME(pobj) (OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(pobj)) ? \
  4344. &(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(pobj))->Name) : NULL)
  4345. PSECURITY_DESCRIPTOR CreateSecurityDescriptor(PACCESS_ALLOWED_ACE paceList,
  4346. DWORD cbAce, BOOLEAN fDaclDefaulted);
  4347. PACCESS_ALLOWED_ACE AllocAce(PACCESS_ALLOWED_ACE pace, BYTE bType,
  4348. BYTE bFlags, ACCESS_MASK am, PSID psid, LPDWORD lpdwLength);
  4349. BOOL CheckGrantedAccess(ACCESS_MASK, ACCESS_MASK);
  4350. BOOL AccessCheckObject(PVOID, ACCESS_MASK, KPROCESSOR_MODE, CONST GENERIC_MAPPING *);
  4351. BOOL InitSecurity(VOID);
  4352. BOOL IsPrivileged(PPRIVILEGE_SET ppSet);
  4353. BOOL CheckWinstaWriteAttributesAccess(void);
  4354. HWINSTA xxxConnectService(PUNICODE_STRING, HDESK *);
  4355. NTSTATUS TestForInteractiveUser(PLUID pluidCaller);
  4356. NTSTATUS _UserTestForWinStaAccess( PUNICODE_STRING pstrWinSta, BOOL fInherit);
  4357. HDESK xxxResolveDesktop(HANDLE hProcess, PUNICODE_STRING pstrDesktop,
  4358. HWINSTA *phwinsta, BOOL fInherit, BOOL* pbShutDown);
  4359. NTSTATUS xxxResolveDesktopForWOW(
  4360. IN OUT PUNICODE_STRING pstrDesktop);
  4361. WORD xxxClientWOWGetProcModule(WNDPROC_PWND pfn);
  4362. DWORD xxxClientWOWTask16SchedNotify(DWORD NotifyParm,DWORD dwParam);
  4363. PVOID _MapDesktopObject(HANDLE h);
  4364. PDESKTOPVIEW GetDesktopView(PPROCESSINFO ppi, PDESKTOP pdesk);
  4365. VOID TerminateConsole(PDESKTOP);
  4366. /*
  4367. * Object manager callouts for windowstations
  4368. */
  4369. NTSTATUS DestroyWindowStation(
  4370. PKWIN32_CLOSEMETHOD_PARAMETERS pCloseParams );
  4371. NTSTATUS FreeWindowStation(
  4372. PKWIN32_DELETEMETHOD_PARAMETERS pDeleteParams );
  4373. NTSTATUS ParseWindowStation(
  4374. PKWIN32_PARSEMETHOD_PARAMETERS pParseParams );
  4375. NTSTATUS OkayToCloseWindowStation(
  4376. PKWIN32_OKAYTOCLOSEMETHOD_PARAMETERS pOkCloseParams);
  4377. NTSTATUS WindowStationOpenProcedure(
  4378. PKWIN32_OPENMETHOD_PARAMETERS pOpenParams);
  4379. /*
  4380. * Object manager callouts for desktops
  4381. */
  4382. NTSTATUS DesktopOpenProcedure(
  4383. PKWIN32_OPENMETHOD_PARAMETERS pOpenParams);
  4384. NTSTATUS MapDesktop(
  4385. PKWIN32_OPENMETHOD_PARAMETERS pOpenParams );
  4386. NTSTATUS UnmapDesktop(
  4387. PKWIN32_CLOSEMETHOD_PARAMETERS pCloseParams );
  4388. NTSTATUS FreeDesktop(
  4389. PKWIN32_DELETEMETHOD_PARAMETERS pDeleteParams );
  4390. NTSTATUS ParseDesktop(
  4391. IN PVOID ParseObject,
  4392. IN PVOID ObjectType,
  4393. IN OUT PACCESS_STATE AccessState,
  4394. IN KPROCESSOR_MODE AccessMode,
  4395. IN ULONG Attributes,
  4396. IN OUT PUNICODE_STRING CompleteName,
  4397. IN OUT PUNICODE_STRING RemainingName,
  4398. IN OUT PVOID Context OPTIONAL,
  4399. IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
  4400. OUT PVOID *Object);
  4401. NTSTATUS OkayToCloseDesktop(
  4402. PKWIN32_OKAYTOCLOSEMETHOD_PARAMETERS pOkCloseParams);
  4403. /*
  4404. * Routines pilfered from kernel32
  4405. */
  4406. VOID UserSleep(DWORD dwMilliseconds);
  4407. BOOL UserBeep(DWORD dwFreq, DWORD dwDuration);
  4408. NTSTATUS UserRtlCreateAtomTable(ULONG NumberOfBuckets);
  4409. ATOM UserAddAtom(LPCWSTR lpAtom, BOOL bPin);
  4410. ATOM UserFindAtom(LPCWSTR lpAtom);
  4411. ATOM UserDeleteAtom(ATOM atom);
  4412. UINT UserGetAtomName(ATOM atom, LPWSTR lpch, int cchMax);
  4413. #define FindClassAtom(lpszClassName) \
  4414. (IS_PTR(lpszClassName) ? UserFindAtom(lpszClassName) : PTR_TO_ID(lpszClassName))
  4415. /*
  4416. * Keyboard Layouts
  4417. */
  4418. void SetGlobalKeyboardTableInfo(PKL pklNew);
  4419. VOID ChangeForegroundKeyboardTable(PKL pklOld, PKL pklNew);
  4420. HKL xxxLoadKeyboardLayoutEx(PWINDOWSTATION, HANDLE, HKL, UINT,
  4421. PKBDTABLE_MULTI_INTERNAL,
  4422. LPCWSTR, UINT, UINT);
  4423. HKL xxxActivateKeyboardLayout(PWINDOWSTATION pwinsta, HKL hkl, UINT Flags, PWND pwnd);
  4424. HKL xxxInternalActivateKeyboardLayout(PKL pkl, UINT Flags, PWND pwnd);
  4425. BOOL GetKbdLangSwitch(PUNICODE_STRING pProfileUserName);
  4426. BOOL xxxUnloadKeyboardLayout(PWINDOWSTATION, HKL);
  4427. VOID RemoveKeyboardLayoutFile(PKBDFILE pkf);
  4428. HKL _GetKeyboardLayout(DWORD idThread);
  4429. UINT _GetKeyboardLayoutList(PWINDOWSTATION pwinsta, UINT nItems, HKL *lpBuff);
  4430. VOID xxxFreeKeyboardLayouts(PWINDOWSTATION, BOOL bUnlock);
  4431. DWORD xxxDragObject(PWND pwndParent, PWND xhwndFrom, UINT wFmt,
  4432. ULONG_PTR dwData, PCURSOR xpcur);
  4433. BOOL xxxDragDetect(PWND pwnd, POINT pt);
  4434. BOOL xxxIsDragging(PWND pwnd, POINT ptScreen, UINT uMsg);
  4435. HKL GetActiveHKL();
  4436. #define DMI_INVERT 0x00000001
  4437. #define DMI_GRAYED 0x00000002
  4438. VOID xxxDrawMenuItem(HDC hdc, PMENU pMenu, PITEM pItem, DWORD dwFlags);
  4439. BOOL xxxRealDrawMenuItem(HDC hdc, PGRAYMENU lpGray, int cx, int cy);
  4440. VOID xxxDrawMenuBarUnderlines(PWND pwnd, BOOL fShow);
  4441. UINT MNItemHitTest(PMENU pMenu, PWND pwnd, POINT pt);
  4442. /*
  4443. * Menu macros
  4444. */
  4445. __inline BOOL IsRootPopupMenu(PPOPUPMENU ppopupmenu)
  4446. {
  4447. return (ppopupmenu == ppopupmenu->ppopupmenuRoot);
  4448. }
  4449. __inline BOOL ExitMenuLoop (PMENUSTATE pMenuState, PPOPUPMENU ppopupmenu)
  4450. {
  4451. return (!pMenuState->fInsideMenuLoop || ppopupmenu->fDestroyed);
  4452. }
  4453. __inline PMENUSTATE GetpMenuState (PWND pwnd)
  4454. {
  4455. return (GETPTI(pwnd)->pMenuState);
  4456. }
  4457. __inline PPOPUPMENU GetpGlobalPopupMenu (PWND pwnd)
  4458. {
  4459. return (GetpMenuState(pwnd) ? GetpMenuState(pwnd)->pGlobalPopupMenu : NULL);
  4460. }
  4461. __inline BOOL IsInsideMenuLoop(PTHREADINFO pti)
  4462. {
  4463. return ((pti->pMenuState != NULL) && pti->pMenuState->fInsideMenuLoop);
  4464. }
  4465. __inline BOOL IsMenuStarted(PTHREADINFO pti)
  4466. {
  4467. return ((pti->pMenuState != NULL) && pti->pMenuState->fMenuStarted);
  4468. }
  4469. __inline PITEM MNGetToppItem(PMENU pMenu)
  4470. {
  4471. return pMenu->rgItems + pMenu->iTop;
  4472. }
  4473. __inline BOOL MNIsItemSelected(PPOPUPMENU ppopupmenu)
  4474. {
  4475. return ((int)ppopupmenu->posSelectedItem >= 0);
  4476. }
  4477. __inline PITEM MNGetSelectedpitem(PPOPUPMENU ppopupmenu)
  4478. {
  4479. return ppopupmenu->spmenu->rgItems + ppopupmenu->posSelectedItem;
  4480. }
  4481. __inline BOOL MNIsScrollArrowSelected(PPOPUPMENU ppopupmenu)
  4482. {
  4483. return ((ppopupmenu->posSelectedItem == MFMWFP_UPARROW)
  4484. || (ppopupmenu->posSelectedItem == MFMWFP_DOWNARROW));
  4485. }
  4486. __inline BOOL IsModelessMenuNotificationWindow (PWND pwnd)
  4487. {
  4488. PMENUSTATE pMenuState;
  4489. return (((pMenuState = GetpMenuState(pwnd)) != NULL)
  4490. && pMenuState->fModelessMenu
  4491. && (pMenuState->pGlobalPopupMenu->spwndNotify == pwnd));
  4492. }
  4493. __inline BOOL IsRecursedMenuState(PMENUSTATE pMenuState, PPOPUPMENU ppopupmenu)
  4494. {
  4495. return (pMenuState->pGlobalPopupMenu != ppopupmenu->ppopupmenuRoot);
  4496. }
  4497. __inline BOOL IsMDIItem (PITEM pitem)
  4498. {
  4499. return (TestMFS(pitem, MFS_CACHEDBMP)
  4500. && (pitem->hbmp != NULL)
  4501. && (pitem->hbmp <= HBMMENU_MBARLAST));
  4502. }
  4503. /*
  4504. * This definition for CM_MODE_TRANSITION must match the one in ntcon\inc\server.h
  4505. */
  4506. #define CM_MODE_TRANSITION (WM_USER+6)
  4507. #define MNXBORDER (SYSMET(CXBORDER) + SYSMET(CXEDGE))
  4508. #define MNYBORDER (SYSMET(CYBORDER) + SYSMET(CYEDGE))
  4509. #define MNXSPACE (SYSMET(CXEDGE))
  4510. #define MNLEFTMARGIN (SYSMET(CXEDGE))
  4511. /*
  4512. * xxxMNUpdateShownMenu flags
  4513. */
  4514. #define MNUS_DEFAULT 0x00000001
  4515. #define MNUS_DELETE 0x00000002
  4516. #define MNUS_DRAWFRAME 0x00000004
  4517. /* This tells xxxMNItemSize that the bitamp size is not avilable */
  4518. #define MNIS_MEASUREBMP -1
  4519. /*
  4520. * MN_SIZEWINDOW wParam flag. xxxMNUpdateShownMenu sends this
  4521. * message, so keep MNSW_ and MNUS_ in sync.
  4522. */
  4523. #define MNSW_RETURNSIZE 0
  4524. #define MNSW_SIZE MNUS_DEFAULT
  4525. #define MNSW_DRAWFRAME MNUS_DRAWFRAME
  4526. /*
  4527. * Animation flags (pMenuState->iAniDropDir)
  4528. */
  4529. #define PAS_RIGHT (TPM_HORPOSANIMATION >> TPM_FIRSTANIBITPOS)
  4530. #define PAS_LEFT (TPM_HORNEGANIMATION >> TPM_FIRSTANIBITPOS)
  4531. #define PAS_DOWN (TPM_VERPOSANIMATION >> TPM_FIRSTANIBITPOS)
  4532. #define PAS_UP (TPM_VERNEGANIMATION >> TPM_FIRSTANIBITPOS)
  4533. #define PAS_OUT 0x10
  4534. #define PAS_HORZ (PAS_LEFT | PAS_RIGHT)
  4535. #define PAS_VERT (PAS_UP | PAS_DOWN)
  4536. #if (PAS_HORZ + PAS_VERT >= PAS_OUT)
  4537. #error PAS_ & TPM_*ANIMATION conflict.
  4538. #endif
  4539. #define CXMENU3DEDGE 1
  4540. #define CYMENU3DEDGE 1
  4541. /*
  4542. * Scrollbar initialization types
  4543. */
  4544. #define SCROLL_NORMAL 0
  4545. #define SCROLL_DIRECT 1
  4546. #define SCROLL_MENU 2
  4547. /*
  4548. * movesize.c
  4549. */
  4550. void xxxDrawDragRect(PMOVESIZEDATA pmsd, LPRECT lprc, UINT flags);
  4551. void GetMonitorMaxArea(PWND pwnd, PMONITOR pMonitor, LPRECT * pprc);
  4552. /*
  4553. * focusact.c
  4554. */
  4555. VOID SetForegroundPriorityProcess(PPROCESSINFO ppi, PTHREADINFO pti, BOOL fSetForegound);
  4556. VOID SetForegroundPriority(PTHREADINFO pti, BOOL fSetForeground);
  4557. void xxxUpdateTray(PWND pwnd);
  4558. //
  4559. // mnchange.c
  4560. //
  4561. void xxxMNUpdateShownMenu(PPOPUPMENU ppopup, PITEM pItem, UINT uFlags);
  4562. //
  4563. // mnkey.c
  4564. //
  4565. UINT xxxMNFindChar(PMENU pMenu, UINT ch, INT idxC, INT *lpr);
  4566. UINT MNFindItemInColumn(PMENU pMenu, UINT idxB, int dir, BOOL fRoot);
  4567. //
  4568. // mndraw.c
  4569. //
  4570. void MNAnimate(PMENUSTATE pMenuState, BOOL fIterate);
  4571. void MNDrawFullNC(PWND pwnd, HDC hdcIn, PPOPUPMENU ppopup);
  4572. void MNDrawArrow(HDC hdcIn, PPOPUPMENU ppopup, UINT uArrow);
  4573. void MNEraseBackground (HDC hdc, PMENU pmenu, int x, int y, int cx, int cy);
  4574. void MNDrawEdge(PMENU pmenu, HDC hdc, RECT * prcDraw, UINT nFlags);
  4575. //
  4576. // mnstate.c
  4577. //
  4578. PMENUSTATE xxxMNAllocMenuState(PTHREADINFO ptiCurrent, PTHREADINFO ptiNotify, PPOPUPMENU ppopupmenuRoot);
  4579. void xxxMNEndMenuState(BOOL fFreePopup);
  4580. BOOL MNEndMenuStateNotify (PMENUSTATE pMenuState);
  4581. void MNFlushDestroyedPopups (PPOPUPMENU ppopupmenu, BOOL fUnlock);
  4582. BOOL MNSetupAnimationDC (PMENUSTATE pMenuState);
  4583. BOOL MNCreateAnimationBitmap(PMENUSTATE pMenuState, UINT cx, UINT cy);
  4584. void MNDestroyAnimationBitmap(PMENUSTATE pMenuState);
  4585. PMENUSTATE xxxMNStartMenuState(PWND pwnd, DWORD cmd, LPARAM lParam);
  4586. __inline VOID LockMenuState(
  4587. PMENUSTATE pMenuState)
  4588. {
  4589. (pMenuState->dwLockCount)++;
  4590. }
  4591. BOOL xxxUnlockMenuState (PMENUSTATE pMenuState);
  4592. //
  4593. // menu.c
  4594. //
  4595. #if DBG
  4596. VOID Validateppopupmenu(PPOPUPMENU ppopupmenu);
  4597. #else // DBG
  4598. #define Validateppopupmenu(ppopupmenu)
  4599. #endif // DBG
  4600. #if DBG
  4601. #define MNGetpItemIndex DBGMNGetpItemIndex
  4602. UINT DBGMNGetpItemIndex(PMENU pmenu, PITEM pitem);
  4603. #else // DBG
  4604. #define MNGetpItemIndex _MNGetpItemIndex
  4605. #endif // DBG
  4606. __inline UINT _MNGetpItemIndex(
  4607. PMENU pmenu,
  4608. PITEM pitem)
  4609. {
  4610. return (UINT)(((ULONG_PTR)pitem - (ULONG_PTR)pmenu->rgItems) / sizeof(ITEM));
  4611. }
  4612. VOID xxxMNDismiss(PMENUSTATE pMenuState);
  4613. PITEM MNGetpItem(PPOPUPMENU ppopup, UINT uIndex);
  4614. VOID xxxMNSetCapture(PPOPUPMENU ppopup);
  4615. VOID xxxMNReleaseCapture(VOID);
  4616. VOID MNCheckButtonDownState(PMENUSTATE pMenuState);
  4617. PWND GetMenuStateWindow(PMENUSTATE pMenuState);
  4618. PVOID LockPopupMenu(PPOPUPMENU ppopup, PMENU * pspmenu, PMENU pmenu);
  4619. PVOID UnlockPopupMenu(PPOPUPMENU ppopup, PMENU * pspmenu);
  4620. PVOID LockWndMenu(PWND pwnd, PMENU * pspmenu, PMENU pmenu);
  4621. PVOID UnlockWndMenu(PWND pwnd, PMENU * pspmenu);
  4622. UINT MNSetTimerToCloseHierarchy(PPOPUPMENU ppopup);
  4623. BOOL xxxMNSetTop(PPOPUPMENU ppopup, int iNewTop);
  4624. LRESULT xxxMenuWindowProc(PWND, UINT, WPARAM, LPARAM);
  4625. VOID xxxMNButtonUp(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT posItemHit, LPARAM lParam);
  4626. VOID xxxMNButtonDown(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT posItemHit, BOOL fClick);
  4627. PITEM xxxMNSelectItem(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT itemPos);
  4628. BOOL xxxMNSwitchToAlternateMenu(PPOPUPMENU ppopupMenu);
  4629. VOID xxxMNCancel(PMENUSTATE pMenuState, UINT uMsg, UINT cmd, LPARAM lParam);
  4630. VOID xxxMNKeyDown(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT key);
  4631. BOOL xxxMNDoubleClick(PMENUSTATE pMenuState, PPOPUPMENU ppopup, int idxItem);
  4632. VOID xxxMNCloseHierarchy(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState);
  4633. PWND xxxMNOpenHierarchy(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState);
  4634. VOID LockMFMWFPWindow (PULONG_PTR puHitArea, ULONG_PTR uNewHitArea);
  4635. VOID UnlockMFMWFPWindow (PULONG_PTR puHitArea);
  4636. BOOL IsMFMWFPWindow (ULONG_PTR uHitArea);
  4637. LONG_PTR xxxMNFindWindowFromPoint(PPOPUPMENU ppopupMenu, PUINT pIndex, POINTS screenPt);
  4638. VOID xxxMNMouseMove(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, POINTS screenPt);
  4639. int xxxMNCompute(PMENU pMenu, PWND pwndNotify, DWORD yMenuTop,
  4640. DWORD xMenuLeft,DWORD cxMax, LPDWORD lpdwHeight);
  4641. VOID xxxMNRecomputeBarIfNeeded(PWND pwndNotify, PMENU pMenu);
  4642. VOID xxxMenuDraw(HDC hdc, PMENU pMenu);
  4643. UINT MNFindNextValidItem(PMENU pMenu, int i, int dir, UINT flags);
  4644. VOID MNFreeItem(PMENU pMenu, PITEM pItem, BOOL fFreeItemPopup);
  4645. BOOL xxxMNStartMenu(PPOPUPMENU ppopupMenu, int mn);
  4646. VOID MNPositionSysMenu(PWND pwnd, PMENU pSysMenu);
  4647. PITEM xxxMNInvertItem(PPOPUPMENU ppopupmenu, PMENU pMenu,int itemNumber,PWND pwndNotify, BOOL fOn);
  4648. VOID xxxSendMenuSelect(PWND pwndNotify, PWND pwndMenu, PMENU pMenu, int idx);
  4649. #define SMS_NOMENU (PMENU)(-1)
  4650. BOOL xxxSetSystemMenu(PWND pwnd, PMENU pMenu);
  4651. BOOL xxxSetDialogSystemMenu(PWND pwnd);
  4652. VOID xxxMNChar(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT character);
  4653. PPOPUPMENU MNAllocPopup(BOOL fForceAlloc);
  4654. VOID MNFreePopup(PPOPUPMENU ppopupmenu);
  4655. /*
  4656. * Menu entry points used by the rest of USER
  4657. */
  4658. VOID xxxMNKeyFilter(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, UINT ch);
  4659. int xxxMenuBarCompute(PMENU pMenu, PWND pwndNotify, DWORD yMenuTop,
  4660. DWORD xMenuLeft, int cxMax);
  4661. VOID xxxEndMenu(PMENUSTATE pMenuState);
  4662. BOOL xxxCallHandleMenuMessages(PMENUSTATE pMenuState, PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  4663. BOOL xxxHandleMenuMessages(LPMSG lpmsg, PMENUSTATE pMenuState, PPOPUPMENU ppopupmenu);
  4664. void xxxEndMenuLoop (PMENUSTATE pMenuState, PPOPUPMENU ppopupmenu);
  4665. int xxxMNLoop(PPOPUPMENU ppopupMenu, PMENUSTATE pMenuState, LPARAM lParam, BOOL fDblClk);
  4666. VOID xxxSetSysMenu(PWND pwnd);
  4667. PMENU xxxGetSysMenuHandle(PWND pwnd);
  4668. PMENU xxxGetSysMenu(PWND pwnd, BOOL fSubMenu);
  4669. PMENU MakeMenuRtoL(PMENU pMenu, BOOL bRtoL);
  4670. HDC CreateCompatiblePublicDC(HDC hdc, HBITMAP *pbmDCGray);
  4671. void xxxPSMTextOut(HDC hdc, int xLeft, int yTop, LPWSTR lpsz, int cch, DWORD dwFlags);
  4672. BOOL xxxPSMGetTextExtent(HDC hdc, LPWSTR lpstr, int cch, PSIZE psize);
  4673. /*
  4674. * LPK callbacks
  4675. */
  4676. void xxxClientPSMTextOut(HDC hdc, int xLeft, int yTop, PUNICODE_STRING lpsz, int cch, DWORD dwFlags);
  4677. int xxxClientLpkDrawTextEx(HDC hdc, int xLeft, int yTop, LPCWSTR lpsz, int nCount,
  4678. BOOL fDraw, UINT wFormat, LPDRAWTEXTDATA lpDrawInfo, UINT bAction, int iCharSet);
  4679. BOOL xxxClientExtTextOutW(HDC hdc, int x, int y, int flOpts, RECT *prcl,
  4680. LPCWSTR pwsz, UINT cwc, INT *pdx);
  4681. BOOL xxxClientGetTextExtentPointW(HDC hdc, LPCWSTR lpstr, int cch, PSIZE psize);
  4682. /*
  4683. * Menu Drag and Drop
  4684. */
  4685. NTSTATUS xxxClientRegisterDragDrop (HWND hwnd);
  4686. NTSTATUS xxxClientRevokeDragDrop (HWND hwnd);
  4687. NTSTATUS xxxClientLoadOLE(VOID);
  4688. void xxxMNSetGapState (ULONG_PTR uHitArea, UINT uIndex, UINT uFlags, BOOL fSet);
  4689. BOOL xxxMNDragOver(POINT * ppt, PMNDRAGOVERINFO pmndoi);
  4690. BOOL xxxMNDragLeave(VOID);
  4691. void xxxMNUpdateDraggingInfo (PMENUSTATE pMenuState, ULONG_PTR uHitArea, UINT uIndex);
  4692. /*
  4693. * Scroll bar entry points
  4694. */
  4695. VOID xxxSBTrackInit(PWND pwnd, LPARAM lParam, int curArea, UINT uType);
  4696. VOID SBCtlSetup(PSBWND psbwnd);
  4697. void CalcSBStuff(PWND pwnd, PSBCALC pSBCalc, BOOL fVert);
  4698. void CalcSBStuff2(PSBCALC pSBCalc, LPRECT lprc, CONST PSBDATA pw, BOOL fVert);
  4699. BOOL xxxEnableScrollBar(PWND pwnd, UINT wSBflags, UINT wArrows);
  4700. void DrawSize(PWND pwnd, HDC hdc, int cxFrame, int cyFrame);
  4701. int xxxScrollWindowEx(PWND pwnd, int dx, int dy, LPRECT prcScroll,
  4702. LPRECT prcClip, HRGN hrgnUpdate, LPRECT prcUpdate, DWORD flags);
  4703. void xxxDoScrollMenu(PWND pwndNotify, PWND pwndSB, BOOL fVert, LPARAM lParam);
  4704. /*
  4705. * ICONS.C
  4706. */
  4707. BOOL xxxInternalEnumWindow(PWND pwndNext, WNDENUMPROC_PWND lpfn, LPARAM lParam, UINT fEnumChildren);
  4708. VOID ISV_InitMinMaxInfo(PWND pwnd, PPOINT aptMinMaxWnd);
  4709. VOID ISV_ValidateMinMaxInfo(PWND pwnd, PPOINT aptMinMaxWnd);
  4710. /*
  4711. * GETSET.C
  4712. */
  4713. WORD _SetWindowWord(PWND pwnd, int index, WORD value);
  4714. DWORD xxxSetWindowLong(PWND pwnd, int index, DWORD value, BOOL bAnsi);
  4715. ULONG_PTR xxxSetWindowData(PWND pwnd, int index, ULONG_PTR dwData, BOOL bAnsi);
  4716. LONG xxxSetWindowStyle(PWND pwnd, int gwl, DWORD styleNew);
  4717. BOOL FCallerOk(PWND pwnd);
  4718. int IntersectVisRect(HDC, int, int, int, int); // Imported from GDI
  4719. PCURSOR xxxGetWindowSmIcon(PWND pwnd, BOOL fDontSendMsg);
  4720. VOID xxxDrawCaptionBar(PWND pwnd, HDC hdc, UINT fFlags);
  4721. VOID xxxDrawScrollBar(PWND pwnd, HDC hdc, BOOL fVert);
  4722. VOID xxxTrackBox(PWND, UINT, WPARAM, LPARAM, PSBCALC);
  4723. VOID xxxTrackThumb(PWND, UINT, WPARAM, LPARAM, PSBCALC);
  4724. VOID xxxEndScroll(PWND pwnd, BOOL fCancel);
  4725. VOID xxxDrawWindowFrame(PWND pwnd, HDC hdc, UINT wFlags);
  4726. BOOL xxxInternalPaintDesktop(PWND pwnd, HDC hdc, BOOL fPaint);
  4727. VOID xxxSysCommand(PWND pwnd, DWORD cmd, LPARAM lParam);
  4728. VOID xxxHandleNCMouseGuys(PWND pwnd, UINT message, int htArea, LPARAM lParam);
  4729. void xxxCreateClassSmIcon(PCLS pcls);
  4730. HICON xxxCreateWindowSmIcon(PWND pwnd, HICON hIconBig, BOOL fCopyFromRes);
  4731. BOOL DestroyWindowSmIcon(PWND pwnd);
  4732. BOOL DestroyClassSmIcon(PCLS pcls);
  4733. UINT DWP_GetHotKey(PWND);
  4734. UINT DWP_SetHotKey(PWND, DWORD);
  4735. PWND HotKeyToWindow(DWORD);
  4736. VOID xxxDWP_DoNCActivate(PWND pwnd, DWORD dwFlags, HRGN hrgnClip);
  4737. #define NCA_ACTIVE 0x00000001
  4738. #define NCA_FORCEFRAMEOFF 0x00000002
  4739. VOID xxxDWP_ProcessVirtKey(UINT key);
  4740. BOOL xxxDWP_EraseBkgnd(PWND pwnd, UINT msg, HDC hdc);
  4741. VOID SetTiledRect(PWND pwnd, LPRECT lprc, PMONITOR pMonitor);
  4742. VOID LinkWindow(PWND pwnd, PWND pwndInsert, PWND pwndParent);
  4743. VOID UnlinkWindow(PWND pwndUnlink, PWND pwndParent);
  4744. VOID xxxDW_DestroyOwnedWindows(PWND pwndParent);
  4745. VOID xxxDW_SendDestroyMessages(PWND pwnd);
  4746. VOID xxxFreeWindow(PWND pwnd, PTL ptlpwndFree);
  4747. VOID xxxFW_DestroyAllChildren(PWND pwnd);
  4748. PHOTKEY FindHotKey(PTHREADINFO pti, PWND pwnd, int id, UINT fsModifiers, UINT vk,
  4749. BOOL fUnregister, PBOOL pfKeysExist);
  4750. NTSTATUS _BuildNameList(
  4751. PWINDOWSTATION pwinsta,
  4752. PNAMELIST pNameList,
  4753. UINT cbNameList,
  4754. PUINT pcbNeeded);
  4755. VOID xxxHelpLoop(PWND pwnd);
  4756. NTSTATUS _BuildPropList(PWND pwnd, PROPSET aPropSet[], UINT cPropMax, PUINT pcPropReturned);
  4757. BOOL xxxSendEraseBkgnd(PWND pwnd, HDC hdcBeginPaint, HRGN hrgnUpdate);
  4758. LONG xxxSetScrollBar(PWND pwnd, int code, LPSCROLLINFO lpsi, BOOL fRedraw);
  4759. VOID IncPaintCount(PWND pwnd);
  4760. VOID DecPaintCount(PWND pwnd);
  4761. PPROP CreateProp(PWND pwnd);
  4762. /*
  4763. * METRICS.C
  4764. */
  4765. VOID xxxRecreateSmallIcons(PWND pwnd);
  4766. VOID TransferWakeBit(PTHREADINFO pti, UINT message);
  4767. BOOL SysHasKanji(VOID);
  4768. LONG xxxBroadcastMessage(PWND, UINT, WPARAM, LPARAM, UINT, PBROADCASTMSG );
  4769. VOID zzzSetFMouseMoved();
  4770. VOID TimersProc(VOID);
  4771. VOID PostMove(PQ pq);
  4772. VOID DestroyWindowsTimers(PWND pwnd);
  4773. UINT_PTR StartTimers(VOID);
  4774. /*==========================================================================*/
  4775. /* */
  4776. /* Internal Function Declarations */
  4777. /* */
  4778. /*==========================================================================*/
  4779. LRESULT xxxTooltipWndProc(PWND, UINT, WPARAM, LPARAM);
  4780. LRESULT xxxSwitchWndProc(PWND, UINT, WPARAM, LPARAM);
  4781. LRESULT xxxDesktopWndProc(PWND, UINT, WPARAM, LPARAM);
  4782. LRESULT xxxSBWndProc(PSBWND, UINT, WPARAM, LPARAM);
  4783. VOID DrawThumb2(PWND, PSBCALC, HDC, HBRUSH, BOOL, UINT);
  4784. UINT GetWndSBDisableFlags(PWND, BOOL);
  4785. HANDLE _ConvertMemHandle(LPBYTE lpData, UINT cbData);
  4786. VOID zzzRegisterSystemThread (DWORD flags, DWORD reserved);
  4787. VOID zzzUpdateCursorImage();
  4788. void zzzCalcStartCursorHide(PW32PROCESS Process, DWORD timeAdd);
  4789. BOOL FinalUserInit();
  4790. BOOL LW_RegisterWindows(VOID);
  4791. BOOL xxxSystemParametersInfo(UINT wFlag, DWORD wParam, LPVOID lParam, UINT flags);
  4792. PWINDOWSTATION CheckClipboardAccess(VOID);
  4793. PCLIP FindClipFormat(PWINDOWSTATION pwinsta, UINT format);
  4794. BOOL InternalSetClipboardData(PWINDOWSTATION pwinsta, UINT format,
  4795. HANDLE hData, BOOL fGlobalHandle, BOOL fIncSerialNumber);
  4796. VOID xxxDisownClipboard(PWND pwndClipOwner);
  4797. VOID CaretBlinkProc(PWND pwnd, UINT message, UINT_PTR id, LPARAM lParam);
  4798. VOID xxxRedrawFrame(PWND pwnd);
  4799. VOID xxxRedrawFrameAndHook(PWND pwnd);
  4800. VOID BltColor(HDC, HBRUSH, HDC, int, int, int, int, int, int, UINT);
  4801. VOID StoreMessage(LPMSG pmsg, PWND pwnd, UINT message, WPARAM wParam,
  4802. LPARAM lParam, DWORD time);
  4803. VOID StoreQMessage(PQMSG pqmsg, PWND pwnd, UINT message, WPARAM wParam,
  4804. LPARAM lParam, DWORD time, DWORD dwQEvent, ULONG_PTR dwExtraInfo);
  4805. #ifdef REDIRECTION
  4806. __inline VOID StoreQMessagePti(
  4807. PQMSG pqmsg,
  4808. PTHREADINFO pti)
  4809. {
  4810. if (pqmsg->msg.message >= WM_MOUSEFIRST && pqmsg->msg.message <= WM_MOUSELAST) {
  4811. pqmsg->msg.pt.x = LOWORD(pqmsg->msg.lParam);
  4812. pqmsg->msg.pt.y = HIWORD(pqmsg->msg.lParam);
  4813. } else {
  4814. if (pti != NULL)
  4815. pqmsg->msg.pt = pti->ptLast;
  4816. }
  4817. pqmsg->pti = pti;
  4818. }
  4819. #else
  4820. __inline VOID StoreQMessagePti(
  4821. PQMSG pqmsg,
  4822. PTHREADINFO pti)
  4823. {
  4824. pqmsg->pti = pti;
  4825. }
  4826. #endif // REDIRECTION
  4827. VOID xxxSendSizeMessage(PWND pwnd, UINT cmdSize);
  4828. VOID xxxCheckFocus(PWND pwnd);
  4829. VOID OffsetChildren(PWND pwnd, int dx, int dy, LPRECT prcHitTest);
  4830. VOID xxxMoveSize(PWND pwnd, UINT cmdMove, DWORD wptStart);
  4831. VOID xxxShowOwnedWindows(PWND pwndOwner, UINT cmdShow, HRGN hrgnHung);
  4832. VOID xxxAdjustSize(PWND pwnd, LPINT lpcx, LPINT lpcy);
  4833. VOID xxxNextWindow(PQ pq, DWORD wParam);
  4834. VOID xxxOldNextWindow(UINT flags);
  4835. VOID xxxCancelCoolSwitch(void);
  4836. VOID RemoveThreadSwitchWindowInfo(PTHREADINFO pti);
  4837. VOID xxxCancelTracking(VOID);
  4838. VOID xxxCancelTrackingForThread(PTHREADINFO ptiCancel);
  4839. VOID xxxCapture(PTHREADINFO pti, PWND pwnd, UINT code);
  4840. UINT SystoChar(UINT message, LPARAM lParam);
  4841. PHOOK PhkFirstValid(PTHREADINFO pti, int nFilterType);
  4842. PHOOK PhkFirstGlobalValid(PTHREADINFO pti, int nFilterType);
  4843. VOID FreeHook(PHOOK phk);
  4844. int xxxCallHook(int, WPARAM, LPARAM, int);
  4845. LRESULT xxxCallHook2(PHOOK, int, WPARAM, LPARAM, LPBOOL);
  4846. BOOL xxxCallMouseHook(UINT message, PMOUSEHOOKSTRUCTEX pmhs, BOOL fRemove);
  4847. VOID xxxCallJournalRecordHook(PQMSG pqmsg);
  4848. DWORD xxxCallJournalPlaybackHook(PQMSG pqmsg);
  4849. VOID SetJournalTimer(DWORD dt, UINT msgJournal);
  4850. VOID FreeThreadsWindowHooks(VOID);
  4851. BOOL xxxSnapWindow(PWND pwnd);
  4852. BOOL DefSetText(PWND pwnd, PLARGE_STRING pstrText);
  4853. PWND DSW_GetTopLevelCreatorWindow(PWND pwnd);
  4854. VOID xxxCalcClientRect(PWND pwnd, LPRECT lprc, BOOL fHungRedraw);
  4855. VOID xxxUpdateClientRect(PWND pwnd);
  4856. BOOL AllocateUnicodeString(PUNICODE_STRING pstrDst, PUNICODE_STRING pstrSrc);
  4857. HANDLE CreateDesktopHeap(PWIN32HEAP* ppheapRet, ULONG ulHeapSize);
  4858. BOOL xxxSetInternalWindowPos(PWND pwnd, UINT cmdShow, LPRECT lprcWin,
  4859. LPPOINT lpptMin);
  4860. VOID xxxMetricsRecalc(UINT wFlags, int dx, int dy, int dyCaption, int dyMenu);
  4861. VOID xxxBroadcastDisplaySettingsChange(PDESKTOP, BOOL);
  4862. /*
  4863. * This is for SPI_GET/SETUSERPREFERENCE.
  4864. * Currently it's for DWORD values only. A type field will be added so all new
  4865. * settings will be mostly handled through common SystemParametersInfo code.
  4866. */
  4867. typedef struct tagPROFILEVALUEINFO {
  4868. DWORD dwValue;
  4869. UINT uSection;
  4870. LPCWSTR pwszKeyName;
  4871. } PROFILEVALUEINFO, *PPROFILEVALUEINFO;
  4872. /*
  4873. * SystemParametersInfo UserPreferences manipulation macros.
  4874. * SPI_ values in the BOOL or DWORD ranges (see winuser.w) are stored in
  4875. * gpdwCPUserPreferencesMask (BOOL) and gpviCPUserPreferences (DOWRD) (see kernel\globals.c).
  4876. * The following macros use the actual SPI_ value to determine the
  4877. * location of a given bit (BOOL mask) or DWORD in those globals.
  4878. *
  4879. * Macros to access DWORDs stored in gpviCPUserPreferences.
  4880. *
  4881. */
  4882. #define UPIsDWORDRange(uSetting) \
  4883. ((uSetting) >= SPI_STARTDWORDRANGE && (uSetting) < SPI_MAXDWORDRANGE)
  4884. /*
  4885. * The first entry in gpviCPUserPreferences is reserved for the bitmask, so add 1.
  4886. * Each setting has SPI_GET and SPI_SET, so divide by 2 to get the index
  4887. */
  4888. #define UPDWORDIndex(uSetting) \
  4889. (1 + (((uSetting) - SPI_STARTDWORDRANGE) / 2))
  4890. /*
  4891. * Macros to access BOOLs stored in gpdwCPUserPreferencesMask.
  4892. */
  4893. #define UPIsBOOLRange(uSetting) \
  4894. ((uSetting) >= SPI_STARTBOOLRANGE && (uSetting) < SPI_MAXBOOLRANGE)
  4895. /*
  4896. * Each setting has SPI_GET and SPI_SET, so divide by 2 to get the index
  4897. */
  4898. #define UPBOOLIndex(uSetting) \
  4899. (((uSetting) - SPI_STARTBOOLRANGE) / 2)
  4900. /*
  4901. * Returns a pointer to the DWORD that contains the bit corresponding to uSetting
  4902. */
  4903. #define UPBOOLPointer(pdw, uSetting) \
  4904. (pdw + (UPBOOLIndex(uSetting) / 32))
  4905. /*
  4906. * Returns the DWORD mask needed to test/set/clear the bit corresponding to uSetting
  4907. */
  4908. #define UPBOOLMask(uSetting) \
  4909. (1 << (UPBOOLIndex(uSetting) - ((UPBOOLIndex(uSetting) / 32) * 32)))
  4910. #define TestUPBOOL(pdw, uSetting) \
  4911. (*UPBOOLPointer(pdw, uSetting) & UPBOOLMask(uSetting))
  4912. #define SetUPBOOL(pdw, uSetting) \
  4913. (*UPBOOLPointer(pdw, uSetting) |= UPBOOLMask(uSetting))
  4914. #define ClearUPBOOL(pdw, uSetting) \
  4915. { \
  4916. UserAssert(UPIsBOOLRange(uSetting)); \
  4917. *UPBOOLPointer(pdw, uSetting) &= ~UPBOOLMask(uSetting); \
  4918. }
  4919. /*
  4920. * Use these macros ONLY if UPIsBOOLRange(SPI_GET ## uSetting) is TRUE
  4921. */
  4922. #define TestUP(uSetting) TestUPBOOL(gpdwCPUserPreferencesMask, SPI_GET ## uSetting)
  4923. #define SetUP(uSetting) SetUPBOOL(gpdwCPUserPreferencesMask, SPI_GET ## uSetting)
  4924. #define ClearUP(uSetting) ClearUPBOOL(gpdwCPUserPreferencesMask, SPI_GET ## uSetting)
  4925. #define IndexUP(uSetting) \
  4926. (1 << (((uSetting) - SPI_STARTBOOLRANGE) / 2))
  4927. /*
  4928. * Some settings (ie, UI Effects) are disabled when TestUP(UISETTINGS) is FALSE.
  4929. */
  4930. #define TestEffectUP(uSetting) \
  4931. ((*gpdwCPUserPreferencesMask & \
  4932. (IndexUP(SPI_GET ## uSetting) | IndexUP(SPI_GETUIEFFECTS))) == \
  4933. (IndexUP(SPI_GET ## uSetting) | IndexUP(SPI_GETUIEFFECTS)))
  4934. /*
  4935. * Some UI effects have an "inverted" disabled value (ie, disabled is TRUE).
  4936. */
  4937. #define TestEffectInvertUP(uSetting) (TestUP(uSetting) || !TestUP(UIEFFECTS))
  4938. /*
  4939. * Some of these BOOL values are needed in the client side. This macro
  4940. * propagates them to gpsi->PUSIFlags. Note that the SI_ value must match the
  4941. * UPBOOLMask value for this to work fine.
  4942. */
  4943. #define PropagetUPBOOLTogpsi(uSetting) \
  4944. UserAssert((DWORD)(PUSIF_ ## uSetting) == (DWORD)UPBOOLMask(SPI_GET ## uSetting)); \
  4945. COPY_FLAG(gpsi->PUSIFlags, TestUP(## uSetting), PUSIF_ ## uSetting)
  4946. /*
  4947. * Test if a TS session is connected remotly or locally through the console
  4948. * terminal.
  4949. */
  4950. #define IsRemoteConnection() (gProtocolType != PROTOCOL_CONSOLE)
  4951. #define IsMultimon() ((gpDispInfo != NULL) && (gpDispInfo->cMonitors > 1))
  4952. #define GETCONSOLEHDEV() (gfRemotingConsole?gConsoleShadowhDev:gpDispInfo->hDev)
  4953. #ifdef IMM_PER_LOGON
  4954. BOOL UpdatePerUserImmEnabling(VOID);
  4955. #endif
  4956. BOOL xxxUpdatePerUserSystemParameters(DWORD dwFlags);
  4957. VOID SaveVolatileUserSettings(VOID);
  4958. VOID MenuRecalc(VOID);
  4959. #define UNDERLINE_RECALC 0x7FFFFFFF // MAXINT; tells us to recalc underline position
  4960. /*
  4961. * Library management routines.
  4962. */
  4963. int GetHmodTableIndex(PUNICODE_STRING pstrName);
  4964. VOID AddHmodDependency(int iatom);
  4965. VOID RemoveHmodDependency(int iatom);
  4966. HANDLE xxxLoadHmodIndex(int iatom);
  4967. VOID xxxDoSysExpunge(PTHREADINFO pti);
  4968. VOID DestroyThreadsObjects(VOID);
  4969. VOID MarkThreadsObjects(PTHREADINFO pti);
  4970. VOID FreeMessageList(PMLIST pml);
  4971. VOID DestroyThreadsHotKeys(VOID);
  4972. VOID DestroyWindowsHotKeys(PWND pwnd);
  4973. VOID DestroyClass(PPCLS ppcls);
  4974. VOID PatchThreadWindows(PTHREADINFO);
  4975. VOID DestroyCacheDCEntries(PTHREADINFO);
  4976. VOID DestroyProcessesClasses(PPROCESSINFO);
  4977. /*
  4978. * Win16 Task Apis Taskman.c
  4979. */
  4980. VOID InsertTask(PPROCESSINFO ppi, PTDB ptdbNew);
  4981. BOOL xxxSleepTask(BOOL fInputIdle, HANDLE);
  4982. BOOL xxxUserYield(PTHREADINFO pti);
  4983. VOID xxxDirectedYield(DWORD dwThreadId);
  4984. VOID DirectedScheduleTask(PTHREADINFO ptiOld, PTHREADINFO ptiNew, BOOL bSendMsg, PSMS psms);
  4985. VOID WakeWowTask(PTHREADINFO Pti);
  4986. /*
  4987. * WowScheduler assertion for multiple wow tasks running simultaneously
  4988. */
  4989. _inline
  4990. VOID
  4991. EnterWowCritSect(
  4992. PTHREADINFO pti,
  4993. PWOWPROCESSINFO pwpi
  4994. )
  4995. {
  4996. if (!++pwpi->CSLockCount) {
  4997. pwpi->CSOwningThread = pti;
  4998. } else {
  4999. RIPMSG2(RIP_ERROR,
  5000. "MultipleWowTasks running simultaneously %x %x\n",
  5001. pwpi->CSOwningThread,
  5002. pwpi->CSLockCount);
  5003. }
  5004. }
  5005. _inline
  5006. VOID
  5007. ExitWowCritSect(
  5008. PTHREADINFO pti,
  5009. PWOWPROCESSINFO pwpi
  5010. )
  5011. {
  5012. if (pti == pwpi->CSOwningThread) {
  5013. pwpi->CSOwningThread = NULL;
  5014. pwpi->CSLockCount--;
  5015. }
  5016. }
  5017. ////////////////////////////////////////////////////////////////////////////
  5018. //
  5019. // These are internal USER functions called from inside and outside the
  5020. // critical section (from server & client side). They are a private 'API'.
  5021. //
  5022. // The prototypes appear in pairs:
  5023. // as called from outside the critsect (from client-side)
  5024. // as called from inside the critsect (from server-side)
  5025. // there must be layer code for the 1st function of each pair which validates
  5026. // handles, enters the critsect, calls the 2nd of the pair of functions, and
  5027. // leaves the critsect again.
  5028. //
  5029. // Things may have to change when we go client server: InitPwSB() mustn't
  5030. // return a pointer to global (server) data! etc.
  5031. //
  5032. ////////////////////////////////////////////////////////////////////////////
  5033. BOOL xxxFillWindow(PWND pwndBrush, PWND pwndPaint, HDC hdc, HBRUSH hbr);
  5034. HBRUSH xxxGetControlBrush(PWND pwnd, HDC hdc, UINT msg);
  5035. HBRUSH xxxGetControlColor(PWND pwndParent, PWND pwndCtl, HDC hdc, UINT message);
  5036. PSBINFO _InitPwSB(PWND);
  5037. BOOL _KillSystemTimer(PWND pwnd, UINT_PTR nIDEvent);
  5038. BOOL xxxPaintRect(PWND, PWND, HDC, HBRUSH, LPRECT);
  5039. ////////////////////////////////////////////////////////////////////////////
  5040. //
  5041. // these are called from stubs.c in the client so will probably go away
  5042. //
  5043. ////////////////////////////////////////////////////////////////////////////
  5044. /*
  5045. * From CLASS.C
  5046. */
  5047. typedef struct tagWNDCLASSVEREX {
  5048. WNDCLASSEXW;
  5049. LPCWSTR lpszClassNameVer;
  5050. } WNDCLASSVEREX, *LPWNDCLASSVEREX;
  5051. PCLS InternalRegisterClassEx(
  5052. LPWNDCLASSVEREX lpwndcls,
  5053. WORD fnid,
  5054. DWORD flags
  5055. );
  5056. PCURSOR GetClassIcoCur(PWND pwnd, int index);
  5057. PCURSOR xxxSetClassIcon(PWND pwnd, PCLS pcls, PCURSOR pCursor, int gcw);
  5058. ULONG_PTR xxxSetClassData(PWND pwnd, int index, ULONG_PTR dwData, BOOL bAnsi);
  5059. /*
  5060. * CREATEW.C
  5061. */
  5062. #define xxxNVCreateWindowEx(dwStyle, pstrClass, pstrName, style, \
  5063. x, y, cx, cy, pwndParent, pmenu, hModule, pCreateParams, \
  5064. dwExpWinVerAndFlags) \
  5065. xxxCreateWindowEx(dwStyle, pstrClass, pstrClass, pstrName, \
  5066. style, x, y, cx, cy, pwndParent, pmenu, hModule, pCreateParams, \
  5067. dwExpWinVerAndFlags, NULL)
  5068. PWND xxxCreateWindowEx(DWORD dwStyle, PLARGE_STRING pstrNVClass, PLARGE_STRING pstrClass,
  5069. PLARGE_STRING pstrName, DWORD style, int x, int y, int cx,
  5070. int cy, PWND pwndParent, PMENU pmenu, HANDLE hModule,
  5071. LPVOID pCreateParams, DWORD dwExpWinVerAndFlags, PACTIVATION_CONTEXT pActCtx);
  5072. BOOL xxxDestroyWindow(PWND pwnd);
  5073. /*
  5074. * SENDMSG.C
  5075. */
  5076. LRESULT xxxSendMessageFF(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam, ULONG_PTR xParam);
  5077. LONG xxxSendMessageBSM(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam,
  5078. LPBROADCASTSYSTEMMSGPARAMS pbsmParams);
  5079. LRESULT xxxSendMessageEx(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam, ULONG_PTR xParam);
  5080. LRESULT xxxSendMessage(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  5081. LRESULT xxxSendMessageTimeout(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam,
  5082. UINT fuFlags, UINT uTimeout, PLONG_PTR lpdwResult);
  5083. BOOL xxxSendNotifyMessage(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  5084. void QueueNotifyMessage(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  5085. BOOL xxxSendMessageCallback(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam,
  5086. SENDASYNCPROC lpResultCallBack, ULONG_PTR dwData, BOOL bClientReqest );
  5087. BOOL _ReplyMessage(LRESULT lRet);
  5088. VOID UserLogError(
  5089. PCWSTR pwszError,
  5090. ULONG cbError,
  5091. NTSTATUS ErrorCode);
  5092. /*
  5093. * MN*.C
  5094. */
  5095. int xxxTranslateAccelerator(PWND pwnd, LPACCELTABLE pat, LPMSG lpMsg);
  5096. BOOL xxxSetMenu(PWND pwnd, PMENU pmenu, BOOL fRedraw);
  5097. VOID ChangeMenuOwner(PMENU pMenu, PPROCESSINFO ppi);
  5098. int xxxMenuBarDraw(PWND pwnd, HDC hdc, int cxFrame, int cyFrame);
  5099. BOOL xxxDrawMenuBar(PWND pwnd);
  5100. UINT xxxPaintMenuBar(PWND pwnd, HDC hdc, int iLeftOffset, int iRightOffset, int iTopOffset, DWORD dwFlags);
  5101. UINT xxxCalcMenuBar(PWND pwnd, int iLeftOffset, int iRightOffset, int iTopOffset, LPCRECT prcWnd);
  5102. BOOL xxxSetMenuItemInfo(PMENU pMenu, UINT nPos, BOOL fByPosition,
  5103. LPMENUITEMINFOW lpmii, PUNICODE_STRING pstrItem);
  5104. BOOL _SetMenuContextHelpId(PMENU pMenu, DWORD dwContextHelpId);
  5105. BOOL _SetMenuFlagRtoL(PMENU pMenu);
  5106. BOOL xxxInsertMenuItem(PMENU pMenu, UINT wIndex, BOOL fByPosition,
  5107. LPMENUITEMINFOW lpmii, PUNICODE_STRING pstrItem);
  5108. BOOL xxxRemoveMenu(PMENU pMenu, UINT nPos, UINT dwFlags);
  5109. BOOL xxxDeleteMenu(PMENU pMenu, UINT nPos, UINT dwFlags);
  5110. BOOL xxxSetMenuInfo(PMENU pMenu, LPCMENUINFO lpmi);
  5111. BOOL xxxTrackPopupMenuEx(PMENU pmenu, UINT dwFlags, int x, int y,
  5112. PWND pwnd, CONST TPMPARAMS *pparams);
  5113. LONG FindBestPos(int x, int y, int cx, int cy, LPRECT prcExclude,
  5114. UINT wFlags, PPOPUPMENU ppopupmenu, PMONITOR pMonitor);
  5115. BOOL _SetMenuDefaultItem(PMENU pMenu, UINT wId, BOOL fByPosition);
  5116. int xxxMenuItemFromPoint(PWND pwnd, PMENU pMenu, POINT ptScreen);
  5117. BOOL xxxGetMenuItemRect(PWND pwnd, PMENU pMenu, UINT uIndex, LPRECT lprcScreen);
  5118. PPOPUPMENU MNGetPopupFromMenu(PMENU pMenu, PMENUSTATE *ppMenuState);
  5119. PVOID LockDesktopMenu(PMENU * ppmenu, PMENU pmenu);
  5120. PVOID UnlockDesktopMenu(PMENU * ppmenu);
  5121. #ifdef LAME_BUTTON
  5122. PMENU xxxLoadSysDesktopMenu (PMENU * ppmenu, UINT uMenuId, PWND pwnd);
  5123. #else
  5124. PMENU xxxLoadSysDesktopMenu (PMENU * ppmenu, UINT uMenuId);
  5125. #endif // LAME_BUTTON
  5126. __inline PVOID UnlockDesktopSysMenu(
  5127. PMENU * ppmenu)
  5128. {
  5129. ClearMF(*ppmenu, MFSYSMENU);
  5130. return UnlockDesktopMenu(ppmenu);
  5131. }
  5132. /*
  5133. * SHOWWIN.C
  5134. */
  5135. BOOL xxxShowWindow(PWND pwnd, DWORD cmdShowAnimate);
  5136. BOOL _ShowWindowAsync(PWND pwnd, int cmdShow, UINT uWPFlags);
  5137. BOOL xxxShowOwnedPopups(PWND pwndOwner, BOOL fShow);
  5138. #define RDW_HASWINDOWRGN 0x8000
  5139. BOOL xxxSetWindowRgn(PWND pwnd, HRGN hrgn, BOOL fRedraw);
  5140. /*
  5141. * SWP.C
  5142. */
  5143. void SelectWindowRgn(PWND pwnd, HRGN hrgnClip);
  5144. PWND GetTopMostInsertAfter (PWND pwnd);
  5145. #define GETTOPMOSTINSERTAFTER(pwnd) \
  5146. (gHardErrorHandler.pti == NULL ? NULL : GetTopMostInsertAfter(pwnd))
  5147. __inline BOOL FSwpTopmost(
  5148. PWND pwnd)
  5149. {
  5150. return (!!TestWF(pwnd, WEFTOPMOST) ^ !!TestWF(pwnd, WFTOGGLETOPMOST));
  5151. }
  5152. PWND PWInsertAfter(HWND hwnd);
  5153. PWND CalcForegroundInsertAfter(PWND pwnd);
  5154. BOOL xxxSetWindowPos(PWND pwnd, PWND pwndInsertAfter, int x, int y,
  5155. int cx, int cy, UINT flags);
  5156. PSMWP InternalBeginDeferWindowPos(int cwndGuess);
  5157. BOOL AllocateCvr (PSMWP psmwp, int cwndHint);
  5158. PSMWP _BeginDeferWindowPos(int cwndGuess);
  5159. PSMWP _DeferWindowPos(PSMWP psmwp, PWND pwnd, PWND pwndInsertAfter,
  5160. int x, int y, int cx, int cy, UINT rgf);
  5161. BOOL xxxEndDeferWindowPosEx(PSMWP psmwp, BOOL fAsync);
  5162. BOOL xxxMoveWindow(PWND pwnd, int x, int y, int cx, int cy, BOOL fRedraw);
  5163. PWND GetLastTopMostWindow(VOID);
  5164. VOID xxxHandleWindowPosChanged(PWND pwnd, PWINDOWPOS ppos);
  5165. VOID IncVisWindows(PWND pwnd);
  5166. VOID DecVisWindows(PWND pwnd);
  5167. BOOL FVisCountable(PWND pwnd);
  5168. VOID SetVisible(PWND pwnd, UINT flags);
  5169. VOID ClrFTrueVis(PWND pwnd);
  5170. VOID SetWindowState(PWND pwnd, DWORD flags);
  5171. VOID ClearWindowState(PWND pwnd, DWORD flags);
  5172. BOOL xxxUpdateWindows(PWND pwnd, HRGN hrgn);
  5173. VOID SetMinimize(PWND pwnd, UINT uFlags);
  5174. #define SMIN_CLEAR 0
  5175. #define SMIN_SET 1
  5176. PWND NextOwnedWindow(PWND pwnd, PWND pwndOwner, PWND pwndParent);
  5177. /*
  5178. * DWP.C
  5179. */
  5180. LRESULT xxxDefWindowProc(PWND, UINT, WPARAM, LPARAM);
  5181. LRESULT xxxRealDefWindowProc(PWND, UINT, WPARAM, LPARAM);
  5182. PWND DWP_GetEnabledPopup(PWND pwndStart);
  5183. /*
  5184. * INPUT.C
  5185. */
  5186. #ifdef MESSAGE_PUMP_HOOK
  5187. BOOL xxxWaitMessageEx(UINT fsWakeMask, DWORD Timeout);
  5188. __inline BOOL xxxWaitMessage(
  5189. VOID)
  5190. {
  5191. return xxxWaitMessageEx(QS_ALLINPUT | QS_EVENT, 0);
  5192. }
  5193. BOOL xxxRealWaitMessageEx(UINT fsWakeMask, DWORD Timeout);
  5194. #else
  5195. BOOL xxxWaitMessage(VOID);
  5196. #endif
  5197. VOID DBGValidateQueueStates(PDESKTOP pdesk);
  5198. VOID IdleTimerProc(VOID);
  5199. BOOL ValidateTimerCallback(PTHREADINFO, LPARAM);
  5200. VOID zzzWakeInputIdle(PTHREADINFO pti);
  5201. VOID SleepInputIdle(PTHREADINFO pti);
  5202. BOOL xxxInternalGetMessage(LPMSG lpmsg, HWND hwnd, UINT wMsgFilterMin,
  5203. UINT wMsgFilterMax, UINT wRemoveMsg, BOOL fGetMessage);
  5204. #ifdef MESSAGE_PUMP_HOOK
  5205. BOOL xxxRealInternalGetMessage(LPMSG lpMsg, HWND hwndFilter, UINT msgMin,
  5206. UINT msgMax, UINT flags, BOOL fGetMessage);
  5207. #endif
  5208. #define xxxPeekMessage(lpmsg, hwnd, wMsgMin, wMsgMax, wRemoveMsg) \
  5209. xxxInternalGetMessage(lpmsg, hwnd, wMsgMin, wMsgMax, wRemoveMsg, FALSE)
  5210. #define xxxGetMessage(lpmsg, hwnd, wMsgMin, wMsgMax) \
  5211. xxxInternalGetMessage(lpmsg, hwnd, wMsgMin, wMsgMax, PM_REMOVE, TRUE)
  5212. DWORD _GetMessagePos(VOID);
  5213. LRESULT xxxDispatchMessage(LPMSG lpmsg);
  5214. UINT GetMouseKeyFlags(PQ pq);
  5215. BOOL _PostMessage(PWND pwnd, UINT message, WPARAM wParam, LPARAM lParam);
  5216. BOOL IPostQuitMessage(PTHREADINFO pti, int nExitCode);
  5217. BOOL _PostQuitMessage(int nExitCode);
  5218. BOOL _PostThreadMessage(PTHREADINFO pti, UINT message, WPARAM wParam, LPARAM lParam);
  5219. BOOL xxxTranslateMessage(LPMSG pmsg, UINT flags);
  5220. BOOL _GetInputState(VOID);
  5221. DWORD _GetQueueStatus(UINT);
  5222. typedef VOID (CALLBACK* MSGWAITCALLBACK)(DWORD DeviceType);
  5223. DWORD xxxMsgWaitForMultipleObjects(DWORD nCount, PVOID *apObjects, MSGWAITCALLBACK pfnNonMsg, PKWAIT_BLOCK WaitBlockArray);
  5224. BOOL FHungApp(PTHREADINFO pti, DWORD dwTimeFromLastRead);
  5225. VOID xxxRedrawHungWindow(PWND pwnd, HRGN hrgnFullDrag);
  5226. VOID xxxRedrawHungWindowFrame(PWND pwnd, BOOL fActive);
  5227. VOID zzzActiveCursorTracking (PWND pwnd);
  5228. PWND GetActiveTrackPwnd(PWND pwnd, Q **ppq);
  5229. int xxxActiveWindowTracking(PWND pwnd, UINT uMsg, int iHitTest);
  5230. VOID xxxHungAppDemon(PWND pwnd, UINT message, UINT_PTR nID, LPARAM lParam);
  5231. /*
  5232. * shadow.c
  5233. */
  5234. BOOL WindowHasShadow(PWND pwnd);
  5235. BOOL xxxAddShadow(PWND pwnd);
  5236. VOID xxxRemoveShadow(PWND pwnd);
  5237. VOID CleanupShadow(PWND pwndShadow);
  5238. VOID MoveShadow(PWND pwnd);
  5239. VOID UpdateShadowShape(PWND pwnd);
  5240. VOID xxxUpdateShadowZorder(PWND pwnd);
  5241. BOOL FAnyShadows(VOID);
  5242. /*
  5243. * QUEUE.C
  5244. */
  5245. __inline BOOL IsShellProcess(
  5246. PPROCESSINFO ppi)
  5247. {
  5248. return ((ppi->rpdeskStartup != NULL)
  5249. && (ppi->rpdeskStartup->pDeskInfo->ppiShellProcess == ppi));
  5250. }
  5251. __inline DWORD GetAppCompatFlags2ForPti(
  5252. PTHREADINFO pti,
  5253. WORD wVer)
  5254. {
  5255. if (wVer < pti->dwExpWinVer) {
  5256. return 0;
  5257. }
  5258. return pti->dwCompatFlags2;
  5259. }
  5260. VOID ClearWakeMask(VOID);
  5261. VOID _AllowForegroundActivation(VOID);
  5262. ULONG GetTaskName(PTHREADINFO pti, PWSTR Buffer, ULONG BufferLength);
  5263. PQMSG FindQMsg(PTHREADINFO pti, PMLIST pml, PWND pwndFilter, UINT msgMin, UINT msgMax, BOOL bProcessAck);
  5264. VOID zzzShowStartGlass(DWORD dwTimeout);
  5265. DWORD _GetChangeBits(VOID);
  5266. NTSTATUS xxxSetCsrssThreadDesktop(PDESKTOP pdesk, PDESKRESTOREDATA pdrdRestore);
  5267. NTSTATUS xxxRestoreCsrssThreadDesktop(PDESKRESTOREDATA pdrdRestore);
  5268. PQ GetJournallingQueue(PTHREADINFO pti);
  5269. VOID ClearAppStarting (PPROCESSINFO ppi);
  5270. BOOL _GetProcessDefaultLayout(DWORD *pdwDefaultLayout);
  5271. BOOL _SetProcessDefaultLayout(DWORD dwDefaultLayout);
  5272. #ifdef HUNGAPP_GHOSTING
  5273. /*
  5274. * GHOST.C
  5275. */
  5276. VOID _DisableProcessWindowsGhosting(VOID);
  5277. LRESULT xxxGhostWndProc(PWND, UINT, WPARAM, LPARAM);
  5278. VOID SignalGhost(PWND pwnd);
  5279. BOOL xxxCreateGhost(PWND pwnd);
  5280. VOID RemoveGhost(PWND pwnd);
  5281. PWND FindGhost(PWND pwnd);
  5282. BOOL GhostSizedOrMoved(PWND pwnd);
  5283. #define WM_HUNGTHREAD (WM_USER + 0)
  5284. #define WM_CREATETRAILTIMER (WM_USER + 1)
  5285. #define WM_SCANGHOST (WM_USER + 2)
  5286. VOID GhostThread(PDESKTOP pdesk);
  5287. __inline VOID SignalGhost(
  5288. PWND pwnd)
  5289. {
  5290. /*
  5291. * No ghosting for applications that are debugged, since it can
  5292. * make debugging confusing to developers.
  5293. */
  5294. if (TestWF(pwnd, WFMINIMIZED) ||
  5295. (GETPTI(pwnd)->ppi->W32PF_Flags & W32PF_DISABLEWINDOWSGHOSTING) ||
  5296. (PsGetProcessDebugPort(GETPTI(pwnd)->ppi->Process) != NULL) ||
  5297. (GetAppCompatFlags2ForPti(GETPTI(pwnd), VERMAX) & GACF2_NOGHOST)) {
  5298. return;
  5299. }
  5300. _PostMessage(PWNDDESKTOP(pwnd), WM_HUNGTHREAD, 0, (LPARAM)HWq(pwnd));
  5301. }
  5302. #endif // HUNGAPP_GHOSTING
  5303. /*
  5304. * TMSWITCH.C
  5305. */
  5306. VOID xxxSwitchToThisWindow(PWND pwnd, BOOL fAltTab);
  5307. /*
  5308. * TOUNICOD.C
  5309. */
  5310. int xxxToUnicodeEx(UINT wVirtKey, UINT wScanCode, CONST BYTE *lpKeyState,
  5311. LPWSTR pwszBuff, int cchBuff, UINT wFlags, HKL hkl);
  5312. int xxxInternalToUnicode(UINT wVirtKey, UINT wScanCode, CONST IN PBYTE pfvk,
  5313. OUT PWCHAR awchChars, INT cChar, UINT uiTMFlags, OUT PDWORD pdwFlags, HKL hkl);
  5314. /*
  5315. * HOTKEYS.C
  5316. */
  5317. BOOL _RegisterHotKey(PWND pwnd, int id, UINT fsModifiers, UINT vk);
  5318. BOOL _UnregisterHotKey(PWND pwnd, int id);
  5319. /*
  5320. * FOCUSACT.C
  5321. */
  5322. PWND xxxSetFocus(PWND pwnd);
  5323. #ifdef FG_HOOKLOCK
  5324. #define FG_HOOKLOCK_PARAM(x) , x
  5325. #else
  5326. #define FG_HOOKLOCK_PARAM(x)
  5327. #endif
  5328. BOOL CanForceForeground(PPROCESSINFO ppi FG_HOOKLOCK_PARAM(PTHREADINFO pti));
  5329. BOOL xxxStubSetForegroundWindow(PWND pwnd);
  5330. BOOL xxxSetForegroundWindow(PWND pwnd, BOOL fFlash);
  5331. PWND xxxSetActiveWindow(PWND pwnd);
  5332. PWND _GetActiveWindow(VOID);
  5333. BOOL xxxAllowSetForegroundWindow(DWORD dwProcessId);
  5334. BOOL _LockSetForegroundWindow(UINT uLockCode);
  5335. /*
  5336. * UPDATE.C
  5337. */
  5338. BOOL xxxInvalidateRect(PWND pwnd, LPRECT lprc, BOOL fErase);
  5339. BOOL xxxValidateRect(PWND pwnd, LPRECT lprc);
  5340. BOOL xxxInvalidateRgn(PWND pwnd, HRGN hrgn, BOOL fErase);
  5341. BOOL xxxValidateRgn(PWND pwnd, HRGN hrgn);
  5342. BOOL xxxUpdateWindow(PWND pwnd);
  5343. BOOL xxxGetUpdateRect(PWND pwnd, LPRECT lprc, BOOL fErase);
  5344. int xxxGetUpdateRgn(PWND pwnd, HRGN hrgn, BOOL fErase);
  5345. int _ExcludeUpdateRgn(HDC hdc, PWND pwnd);
  5346. int CalcWindowRgn(PWND pwnd, HRGN hrgn, BOOL fClient);
  5347. VOID DeleteUpdateRgn(PWND pwnd);
  5348. BOOL xxxRedrawWindow(PWND pwnd, LPRECT lprcUpdate, HRGN hrgnUpdate, DWORD flags);
  5349. BOOL IntersectWithParents(PWND pwnd, LPRECT lprc);
  5350. VOID xxxInternalInvalidate(PWND pwnd, HRGN hrgnUpdate, DWORD flags);
  5351. /*
  5352. * WINMGR.C
  5353. */
  5354. BOOL xxxEnableWindow(PWND pwnd, BOOL fEnable);
  5355. int xxxGetWindowText(PWND pwnd, LPWSTR psz, int cchMax);
  5356. PWND xxxSetParent(PWND pwnd, PWND pwndNewParent);
  5357. BOOL xxxFlashWindow(PWND pwnd, DWORD dwFlags, DWORD dwTimeout);
  5358. extern ATOM gaFlashWState;
  5359. __inline DWORD GetFlashWindowState(
  5360. PWND pwnd)
  5361. {
  5362. return HandleToUlong(_GetProp(pwnd, MAKEINTATOM(gaFlashWState), PROPF_INTERNAL));
  5363. }
  5364. __inline VOID SetFlashWindowState(
  5365. PWND pwnd,
  5366. DWORD dwState)
  5367. {
  5368. InternalSetProp(pwnd, MAKEINTATOM(gaFlashWState),
  5369. (HANDLE)ULongToPtr(dwState), PROPF_INTERNAL | PROPF_NOPOOL);
  5370. }
  5371. __inline VOID RemoveFlashWindowState(
  5372. PWND pwnd)
  5373. {
  5374. InternalRemoveProp(pwnd, MAKEINTATOM(gaFlashWState), PROPF_INTERNAL);
  5375. }
  5376. BOOL _GetWindowPlacement(PWND pwnd, PWINDOWPLACEMENT pwp);
  5377. BOOL xxxSetWindowPlacement(PWND pwnd, PWINDOWPLACEMENT pwp);
  5378. BOOL ValidateParentDepth(PWND pwnd, PWND pwndParent);
  5379. BOOL ValidateOwnerDepth(PWND pwnd, PWND pwndOwner);
  5380. VOID WPUpdateCheckPointSettings (PWND pwnd, UINT uWPFlags);
  5381. /*
  5382. * DC.C
  5383. */
  5384. HDC _GetDC(PWND pwnd);
  5385. HDC _GetDCEx(PWND pwnd, HRGN hrgnClip, DWORD flags);
  5386. HDC _GetWindowDC(PWND pwnd);
  5387. BOOL _ReleaseDC(HDC hdc);
  5388. UINT ReleaseCacheDC(HDC hdc, BOOL fEndPaint);
  5389. HDC CreateCacheDC(PWND, DWORD, PMONITOR);
  5390. BOOL DestroyCacheDC(PDCE *, HDC);
  5391. VOID InvalidateDce(PDCE pdce);
  5392. VOID DeleteHrgnClip(PDCE pdce);
  5393. PWND WindowFromCacheDC(HDC hdc);
  5394. PWND FastWindowFromDC(HDC hdc);
  5395. VOID DelayedDestroyCacheDC(VOID);
  5396. PDCE LookupDC(HDC hdc);
  5397. HDC GetMonitorDC(PDCE pdceOrig, PMONITOR pMonitor);
  5398. BOOL GetDCOrgOnScreen(HDC hdc, LPPOINT ppt);
  5399. __inline VOID MarkDCEInvalid(
  5400. PDCE pdce)
  5401. {
  5402. /*
  5403. * Clear all bits, but these.
  5404. */
  5405. pdce->DCX_flags &= (DCX_CACHE | DCX_REDIRECTED);
  5406. /*
  5407. * Mark this cache entry as invalid
  5408. */
  5409. pdce->DCX_flags |= DCX_INVALID;
  5410. }
  5411. BOOL MirrorRegion(PWND pwnd, HRGN hrgn, BOOL bUseClient);
  5412. /*
  5413. * PAINT.C
  5414. */
  5415. HDC xxxBeginPaint(PWND pwnd, PAINTSTRUCT *lpps);
  5416. BOOL xxxEndPaint(PWND pwnd, PAINTSTRUCT *lpps);
  5417. /*
  5418. * CAPTURE.C
  5419. */
  5420. PWND xxxSetCapture(PWND pwnd);
  5421. BOOL xxxReleaseCapture(VOID);
  5422. /*
  5423. * KEYBOARD.C
  5424. */
  5425. SHORT _GetAsyncKeyState(int vk);
  5426. BOOL _SetKeyboardState(CONST BYTE *pKeyboard);
  5427. int _GetKeyboardType(int nTypeFlag);
  5428. VOID RegisterPerUserKeyboardIndicators(PUNICODE_STRING pProfileUserName);
  5429. VOID UpdatePerUserKeyboardIndicators(PUNICODE_STRING pProfileUserName);
  5430. VOID UpdatePerUserKeyboardMappings(PUNICODE_STRING pProfileUserName);
  5431. #define TestRawKeyDown(vk) TestKeyDownBit(gafRawKeyState, vk)
  5432. #define SetRawKeyDown(vk) SetKeyDownBit(gafRawKeyState, vk)
  5433. #define ClearRawKeyDown(vk) ClearKeyDownBit(gafRawKeyState, vk)
  5434. #define TestRawKeyToggle(vk) TestKeyToggleBit(gafRawKeyState, vk)
  5435. #define SetRawKeyToggle(vk) SetKeyToggleBit(gafRawKeyState, vk)
  5436. #define ClearRawKeyToggle(vk) ClearKeyToggleBit(gafRawKeyState, vk)
  5437. #define ToggleRawKeyToggle(vk) ToggleKeyToggleBit(gafRawKeyState, vk)
  5438. /*
  5439. * XLATE.C
  5440. */
  5441. int _GetKeyNameText(LONG lParam, LPWSTR lpString, int nSize);
  5442. /*
  5443. * TIMERS.C
  5444. */
  5445. BOOL _KillTimer(PWND pwnd, UINT_PTR nIDEvent);
  5446. PTIMER FindTimer(PWND pwnd, UINT_PTR nID, UINT flags, BOOL fKill);
  5447. VOID xxxSystemTimerProc(PWND pwnd, UINT msg, UINT_PTR id, LPARAM lParam);
  5448. /*
  5449. * CARET.C
  5450. */
  5451. BOOL zzzDestroyCaret(VOID);
  5452. BOOL xxxCreateCaret(PWND, HBITMAP, int, int);
  5453. BOOL zzzShowCaret(PWND);
  5454. BOOL zzzHideCaret(PWND);
  5455. BOOL _SetCaretBlinkTime(UINT);
  5456. BOOL zzzSetCaretPos(int, int);
  5457. /*
  5458. * MSGBEEP.C
  5459. */
  5460. BOOL xxxOldMessageBeep(VOID);
  5461. BOOL xxxMessageBeep(UINT wType);
  5462. VOID PlayEventSound(UINT idSound);
  5463. /*
  5464. * WINWHERE.C
  5465. */
  5466. PWND _ChildWindowFromPointEx(PWND pwndParent, POINT pt, UINT i);
  5467. PWND xxxWindowFromPoint(POINT pt);
  5468. PWND SizeBoxHwnd(PWND pwnd);
  5469. /*
  5470. * GETSET.C
  5471. */
  5472. WORD _SetWindowWord(PWND pwnd, int index, WORD value);
  5473. DWORD xxxSetWindowLong(PWND pwnd, int index, DWORD value, BOOL bAnsi);
  5474. #ifdef _WIN64
  5475. ULONG_PTR xxxSetWindowLongPtr(PWND pwnd, int index, ULONG_PTR value, BOOL bAnsi);
  5476. #else
  5477. #define xxxSetWindowLongPtr xxxSetWindowLong
  5478. #endif
  5479. #define __GetWindowLong(pwnd, index) ((LONG)(*(DWORD UNALIGNED *)((BYTE *)((pwnd) + 1) + (index))))
  5480. #define __GetWindowLongPtr(pwnd, index) ((LONG_PTR)(*(ULONG_PTR UNALIGNED *)((BYTE *)((pwnd) + 1) + (index))))
  5481. #if DBG
  5482. ULONG DBGGetWindowLong(PWND pwnd, int index);
  5483. #define _GetWindowLong DBGGetWindowLong
  5484. ULONG_PTR DBGGetWindowLongPtr(PWND pwnd, int index);
  5485. #define _GetWindowLongPtr DBGGetWindowLongPtr
  5486. #else
  5487. #define _GetWindowLong __GetWindowLong
  5488. #define _GetWindowLongPtr __GetWindowLongPtr
  5489. #endif
  5490. /*
  5491. * CLIPBRD.C
  5492. */
  5493. BOOL _OpenClipboard(PWND pwnd, LPBOOL lpfEmptyClient);
  5494. BOOL xxxCloseClipboard(PWINDOWSTATION pwinsta);
  5495. UINT _EnumClipboardFormats(UINT fmt);
  5496. BOOL xxxEmptyClipboard(PWINDOWSTATION pwinsta);
  5497. HANDLE xxxGetClipboardData(PWINDOWSTATION pwinsta, UINT fmt, PGETCLIPBDATA gcd);
  5498. BOOL _IsClipboardFormatAvailable(UINT fmt);
  5499. int _GetPriorityClipboardFormat(UINT *lpPriorityList, int cfmts);
  5500. PWND xxxSetClipboardViewer(PWND pwndClipViewerNew);
  5501. BOOL xxxChangeClipboardChain(PWND pwndRemove, PWND pwndNewNext);
  5502. /*
  5503. * miscutil.c
  5504. */
  5505. VOID SetDialogPointer(PWND pwnd, LONG_PTR lPtr);
  5506. VOID ZapActiveAndFocus(VOID);
  5507. BOOL xxxSetShellWindow(PWND pwnd, PWND pwndBkGnd);
  5508. BOOL _SetProgmanWindow(PWND pwnd);
  5509. BOOL _SetTaskmanWindow(PWND pwnd);
  5510. #define STW_SAME ((PWND) 1)
  5511. VOID xxxSetTrayWindow(PDESKTOP pdesk, PWND pwnd, PMONITOR pMonitor);
  5512. BOOL xxxAddFullScreen(PWND pwnd, PMONITOR pMonitor);
  5513. BOOL xxxRemoveFullScreen(PWND pwnd, PMONITOR pMonitor);
  5514. BOOL xxxCheckFullScreen(PWND pwnd, PSIZERECT psrc);
  5515. BOOL IsTrayWindow(PWND);
  5516. #define FDoTray() (SYSMET(ARRANGE) & ARW_HIDE)
  5517. #define FCallHookTray() (IsHooked(PtiCurrent(), WHF_SHELL))
  5518. #define FPostTray(p) (p->pDeskInfo->spwndTaskman)
  5519. #define FCallTray(p) (FDoTray() && ( FCallHookTray()|| FPostTray(p) ))
  5520. // ----------------------------------------------------------------------------
  5521. //
  5522. // FTopLevel() - TRUE if window is a top level window
  5523. //
  5524. // FHas31TrayStyles() - TRUE if window is either full screen or has
  5525. // both a system menu and a caption
  5526. // (NOTE: minimized windows always have captions)
  5527. //
  5528. // ----------------------------------------------------------------------------
  5529. #define FTopLevel(pwnd) (pwnd->spwndParent == PWNDDESKTOP(pwnd))
  5530. #define FHas31TrayStyles(pwnd) (TestWF(pwnd, WFFULLSCREEN) || \
  5531. (TestWF(pwnd, WFSYSMENU | WFMINBOX) && \
  5532. (TestWF(pwnd, WFCAPTION) || TestWF(pwnd, WFMINIMIZED))))
  5533. BOOL Is31TrayWindow(PWND pwnd);
  5534. /*
  5535. * fullscr.c
  5536. */
  5537. #if DBG
  5538. __inline VOID VerifyVisibleMonitorCount(
  5539. VOID)
  5540. {
  5541. extern PDISPLAYINFO gpDispInfo;
  5542. PMONITOR pMonitor = gpDispInfo->pMonitorFirst;
  5543. ULONG cVisMon = 0;
  5544. while (pMonitor) {
  5545. if (pMonitor->dwMONFlags & MONF_VISIBLE) {
  5546. cVisMon++;
  5547. }
  5548. pMonitor = pMonitor->pMonitorNext;
  5549. }
  5550. UserAssert(cVisMon == gpDispInfo->cMonitors);
  5551. }
  5552. #else
  5553. #define VerifyVisibleMonitorCount()
  5554. #endif
  5555. BOOL xxxMakeWindowForegroundWithState(PWND, BYTE);
  5556. VOID FullScreenCleanup(VOID);
  5557. LONG xxxUserChangeDisplaySettings(
  5558. PUNICODE_STRING pstrDeviceName,
  5559. LPDEVMODEW pDevMode,
  5560. PDESKTOP pdesk,
  5561. DWORD dwFlags,
  5562. PVOID lParam,
  5563. MODE PreviousMode);
  5564. BOOL xxxbFullscreenSwitch(BOOL bFullscreenSwitch, HWND hwnd);
  5565. /*
  5566. * SBAPI.C
  5567. */
  5568. BOOL xxxShowScrollBar(PWND, UINT, BOOL);
  5569. /*
  5570. * mngray.c
  5571. */
  5572. BOOL xxxDrawState(HDC hdcDraw, HBRUSH hbrFore,
  5573. LPARAM lData, int x, int y, int cx, int cy, UINT uFlags);
  5574. /*
  5575. * SCROLLW.C
  5576. */
  5577. BOOL _ScrollDC(HDC hdc, int dx, int dy, LPRECT prcSrc, LPRECT prcClip,
  5578. HRGN hrgnUpdate, LPRECT prcUpdate);
  5579. /*
  5580. * SPB.C
  5581. */
  5582. VOID SpbCheckRect(PWND pwnd, LPRECT lprc, DWORD flags);
  5583. VOID SpbCheck(VOID);
  5584. PSPB FindSpb(PWND pwnd);
  5585. VOID FreeSpb(PSPB pspb);
  5586. VOID FreeAllSpbs(VOID);
  5587. VOID CreateSpb(PWND pwnd, UINT flags, HDC hdcScreen);
  5588. UINT RestoreSpb(PWND pwnd, HRGN hrgnUncovered, HDC *phdcScreen);
  5589. VOID SpbCheckPwnd(PWND pwnd);
  5590. VOID SpbCheckDce(PDCE pdce);
  5591. BOOL LockWindowUpdate2(PWND pwndLock, BOOL fThreadOverride);
  5592. /*
  5593. * DRAWFRM.C
  5594. */
  5595. BOOL BitBltSysBmp(HDC hdc, int x, int y, UINT i);
  5596. /*
  5597. * SYSMET.c
  5598. */
  5599. BOOL APIENTRY xxxSetSysColors(PUNICODE_STRING pProfileUserName,int count, PUINT pIndex, LPDWORD pClrVal, UINT uOptions);
  5600. VOID SetSysColor(UINT icol, DWORD rgb, UINT uOptions);
  5601. /*
  5602. * ICONS.C
  5603. */
  5604. UINT xxxArrangeIconicWindows(PWND pwnd);
  5605. BOOL _SetSystemMenu(PWND pwnd, PMENU pMenu);
  5606. /*
  5607. * RMCREATE.C
  5608. */
  5609. PICON _CreateIconIndirect(PICONINFO piconinfo);
  5610. PCURSOR _CreateCursor(HANDLE hModule, int iXhotspot, int iYhotspot,
  5611. int iWidth, int iHeight, LPBYTE lpANDplane, LPBYTE lpXORplane);
  5612. PICON _CreateIcon(HANDLE hModule, int iWidth, int iHeight,
  5613. BYTE bPlanes, BYTE bBitsPixel, LPBYTE lpANDplane, LPBYTE lpXORplane);
  5614. VOID DestroyUnlockedCursor(VOID *pv);
  5615. BOOL _DestroyCursor(PCURSOR pcur, DWORD cmdDestroy);
  5616. HANDLE _CreateAcceleratorTable(LPACCEL ccxpaccel, int cbAccel);
  5617. /*
  5618. * CURSOR.C
  5619. */
  5620. #if DBG
  5621. PCURSOR DbgLockQCursor(PQ pq, PCURSOR pcur);
  5622. #define LockQCursor(pq, pcur) DbgLockQCursor(pq, pcur)
  5623. #else
  5624. #define LockQCursor(pq, pcur) Lock(&pq->spcurCurrent, pcur)
  5625. #endif // DBG
  5626. PCURSOR zzzSetCursor(PCURSOR pcur);
  5627. BOOL zzzSetCursorPos(int x, int y);
  5628. int zzzShowCursor(BOOL fShow);
  5629. BOOL zzzClipCursor(LPCRECT prcClip);
  5630. PCURSOR _GetCursor(VOID);
  5631. BOOL _SetCursorContents(PCURSOR pcur, PCURSOR pcurNew);
  5632. VOID SetPointer(BOOL fSet);
  5633. VOID zzzHideCursorNoCapture(VOID);
  5634. #define GETPCI(pcur) ((PCURSINFO)&(pcur->CI_FIRST))
  5635. /*
  5636. * WMICON.C
  5637. */
  5638. BOOL _DrawIconEx(HDC hdc, int x, int y, PCURSOR pcur, int cx, int cy,
  5639. UINT istepIfAniCur, HBRUSH hbrush, UINT diFlags) ;
  5640. BOOL BltIcon(HDC hdc, int x, int y, int cx, int cy,
  5641. HDC hdcSrc, PCURSOR pcursor, UINT diFlag, LONG rop);
  5642. /*
  5643. * DESKTOP.C
  5644. */
  5645. __inline VOID xxxCleanupMotherDesktopWindow(
  5646. PTERMINAL pTerm)
  5647. {
  5648. PWND pwnd = pTerm->spwndDesktopOwner;
  5649. /*
  5650. * Hide the window first.
  5651. */
  5652. SetVisible(pwnd, SV_UNSET);
  5653. pTerm->dwTERMF_Flags |= TERMF_MOTHERWND_DESTROYED;
  5654. if(Unlock(&(pTerm->spwndDesktopOwner))) {
  5655. xxxDestroyWindow(pwnd);
  5656. }
  5657. }
  5658. HDESK xxxCreateDesktop(
  5659. POBJECT_ATTRIBUTES,
  5660. KPROCESSOR_MODE,
  5661. PUNICODE_STRING,
  5662. LPDEVMODEW,
  5663. DWORD,
  5664. DWORD);
  5665. #define CST_MAX_THREADS 30
  5666. /*
  5667. * Flags for xxxSwitchDesktop().
  5668. */
  5669. #define SDF_CREATENEW 0x01 /* New desktop, don't send enable/disable */
  5670. #define SDF_SLOVERRIDE 0x02 /* Don't respect WSF_SWITCHLOCK on pwinsta */
  5671. HDESK _OpenDesktop(POBJECT_ATTRIBUTES ccxObja, KPROCESSOR_MODE AccessMode, DWORD dwFlags, DWORD dwDesiredAccess, BOOL *pbShutDown);
  5672. BOOL OpenDesktopCompletion(PDESKTOP pdesk, HDESK hdesk, DWORD dwFlags, BOOL *pbShutDown);
  5673. BOOL xxxSwitchDesktop(PWINDOWSTATION pwinsta, PDESKTOP pdesk, DWORD dwFlags);
  5674. BOOL zzzSetDesktop(PTHREADINFO pti, PDESKTOP pdesk, HDESK hdesk);
  5675. HDESK _GetInputDesktop(VOID);
  5676. BOOL xxxSetThreadDesktop(HDESK hdesk, PDESKTOP pdesk);
  5677. HDESK xxxGetThreadDesktop(DWORD dwThread, HDESK hdeskConsole, KPROCESSOR_MODE AccessMode);
  5678. BOOL xxxCloseDesktop(HDESK hdesk, KPROCESSOR_MODE AccessMode);
  5679. DWORD _SetDesktopConsoleThread(PDESKTOP pdesk, DWORD dwThreadId);
  5680. VOID xxxRealizeDesktop(PWND pwnd);
  5681. /*
  5682. * Flags for GetDesktopHeapSize().
  5683. */
  5684. #define DHS_LOGON 0x1
  5685. #define DHS_DISCONNECT 0x2
  5686. #define DHS_NOIO 0x3
  5687. ULONG GetDesktopHeapSize(
  5688. USHORT usFlags);
  5689. /*
  5690. * WINSTA.C
  5691. */
  5692. NTSTATUS CreateGlobalAtomTable(
  5693. PVOID* ppAtomTable);
  5694. HWINSTA xxxCreateWindowStation(
  5695. POBJECT_ATTRIBUTES ObjA,
  5696. KPROCESSOR_MODE OwnershipMode,
  5697. DWORD amRequest,
  5698. HANDLE hKbdLayoutFile,
  5699. DWORD offTable,
  5700. PKBDTABLE_MULTI_INTERNAL pKbdTableMulti,
  5701. PCWSTR pwszKLID,
  5702. UINT uKbdInputLocale);
  5703. HWINSTA _OpenWindowStation(
  5704. POBJECT_ATTRIBUTES pObjA,
  5705. DWORD dwDesiredAccess,
  5706. KPROCESSOR_MODE AccessMode);
  5707. BOOL _CloseWindowStation(
  5708. HWINSTA hwinsta);
  5709. NTSTATUS _SetProcessWindowStation(
  5710. HWINSTA hwinsta,
  5711. KPROCESSOR_MODE AccessMode);
  5712. PWINDOWSTATION _GetProcessWindowStation(
  5713. HWINSTA *phwinsta);
  5714. BOOL _LockWorkStation(
  5715. VOID);
  5716. NTSTATUS ReferenceWindowStation(
  5717. PETHREAD Thread,
  5718. HWINSTA hwinsta,
  5719. ACCESS_MASK amDesiredAccess,
  5720. PWINDOWSTATION *ppwinsta,
  5721. BOOL fUseDesktop);
  5722. /*
  5723. * HOOKS.C
  5724. */
  5725. PROC zzzSetWindowsHookAW(int nFilterType, PROC pfnFilterProc, DWORD dwFlags);
  5726. BOOL zzzUnhookWindowsHookEx(PHOOK phk);
  5727. BOOL zzzUnhookWindowsHook(int nFilterType, PROC pfnFilterProc);
  5728. LRESULT xxxCallNextHookEx(int nCode, WPARAM wParam, LPARAM lParam);
  5729. BOOL _CallMsgFilter(LPMSG lpMsg, int nCode);
  5730. VOID zzzCancelJournalling(VOID);
  5731. #if DBG
  5732. VOID DbgValidateHooks(PHOOK phk, int iType);
  5733. #else
  5734. #define DbgValidateHooks(phk, iType)
  5735. #endif
  5736. BOOL _RegisterUserApiHook(PUNICODE_STRING pstrLib, ULONG_PTR offPfnInitDefWindowProc);
  5737. BOOL _UnregisterUserApiHook(VOID);
  5738. BOOL xxxLoadUserApiHook(VOID);
  5739. extern int gihmodUserApiHook;
  5740. __inline BOOL IsInsideUserApiHook(
  5741. VOID)
  5742. {
  5743. return gihmodUserApiHook >= 0;
  5744. }
  5745. #ifdef MESSAGE_PUMP_HOOK
  5746. BOOL _DoInitMessagePumpHook(VOID);
  5747. BOOL _DoUninitMessagePumpHook(VOID);
  5748. extern PTHREADINFO gptiCurrent;
  5749. __inline BOOL IsInsideMPH(
  5750. VOID)
  5751. {
  5752. PCLIENTTHREADINFO pcti = PtiCurrent()->pcti;
  5753. return pcti->cMessagePumpHooks > 0;
  5754. }
  5755. #endif // MESSAGE_PUMP_HOOK
  5756. /*
  5757. * SRVHOOK.C
  5758. */
  5759. LRESULT fnHkINLPCWPEXSTRUCT(PWND pwnd, UINT message, WPARAM wParam,
  5760. LPARAM lParam, ULONG_PTR xParam);
  5761. LRESULT fnHkINLPCWPRETEXSTRUCT(PWND pwnd, UINT message, WPARAM wParam,
  5762. LPARAM lParam, ULONG_PTR xParam);
  5763. /*
  5764. * EXITWIN.C
  5765. */
  5766. LONG xxxClientShutdown(PWND pwnd, WPARAM wParam);
  5767. BOOL xxxRegisterUserHungAppHandlers(PFNW32ET pfnW32EndTask, HANDLE hEventWowExec);
  5768. /*
  5769. * INIT.C
  5770. */
  5771. BOOL CreateTerminalInput(PTERMINAL pTerm);
  5772. VOID LW_LoadProfileInitData(PUNICODE_STRING pProfileUserName);
  5773. VOID xxxODI_ColorInit(PUNICODE_STRING pProfileUserName);
  5774. HRGN InitCreateRgn(VOID);
  5775. VOID xxxUpdateSystemCursorsFromRegistry(PUNICODE_STRING pProfileUserName);
  5776. VOID xxxUpdateSystemIconsFromRegistry(PUNICODE_STRING pProfileUserName);
  5777. VOID RegisterLPK(DWORD dwLpkEntryPoints);
  5778. HBITMAP CreateCaptionStrip(VOID);
  5779. BOOL LW_BrushInit(VOID);
  5780. VOID xxxLW_LoadFonts(BOOL bRemote);
  5781. VOID _LoadCursorsAndIcons(VOID);
  5782. VOID UnloadCursorsAndIcons(VOID);
  5783. VOID IncrMBox(VOID);
  5784. VOID DecrMBox(VOID);
  5785. VOID InitAnsiOem(PCHAR pOemToAnsi, PCHAR pAnsiToOem);
  5786. int xxxAddFontResourceW(LPWSTR lpFile, FLONG flags, DESIGNVECTOR *pdv);
  5787. VOID EnforceColorDependentSettings(VOID);
  5788. /*
  5789. * ACCESS.C
  5790. */
  5791. VOID xxxUpdatePerUserAccessPackSettings(PUNICODE_STRING pProfileUserName);
  5792. /*
  5793. * inctlpan.c
  5794. */
  5795. VOID GetWindowNCMetrics(LPNONCLIENTMETRICS lpnc);
  5796. HFONT CreateFontFromWinIni(PUNICODE_STRING pProfileUserName,LPLOGFONT lplf, UINT idFont);
  5797. VOID SetMinMetrics(PUNICODE_STRING pProfileUserName,LPMINIMIZEDMETRICS lpmin);
  5798. BOOL xxxSetWindowNCMetrics(PUNICODE_STRING pProfileUserName,LPNONCLIENTMETRICS lpnc, BOOL fSizeChange, int clNewBorder);
  5799. BOOL SetIconMetrics(PUNICODE_STRING pProfileUserName,LPICONMETRICS lpicon);
  5800. BOOL xxxSetNCFonts(PUNICODE_STRING pProfileUserName, LPNONCLIENTMETRICS lpnc);
  5801. BOOL CreateBitmapStrip(VOID);
  5802. BOOL UpdateWinIniInt(PUNICODE_STRING pProfileUserName, UINT idSection, UINT wKeyNameId, int value);
  5803. /*
  5804. * rare.c
  5805. */
  5806. VOID SetDesktopMetrics(VOID);
  5807. VOID SetMsgBox(PWND pwnd);
  5808. BOOL _RegisterShellHookWindow(PWND pwnd);
  5809. BOOL _DeregisterShellHookWindow(PWND pwnd);
  5810. BOOL xxxSendMinRectMessages(PWND pwnd, RECT *lpRect);
  5811. void PostShellHookMessages(UINT message, LPARAM lParam);
  5812. VOID _ResetDblClk(VOID);
  5813. VOID xxxSimulateShiftF10(VOID);
  5814. BOOL VWPLAdd(PVWPL *ppvwpl, PWND pwnd, DWORD dwThreshold);
  5815. BOOL VWPLRemove(PVWPL *ppvwpl, PWND pwnd);
  5816. PWND VWPLNext(PVWPL pvwpl, PWND pwndPrev, DWORD *pnPrev);
  5817. /*
  5818. * DDETRACK STUFF
  5819. */
  5820. #if DBG
  5821. VOID ValidatePublicObjectList(VOID);
  5822. VOID TraceDdeMsg(UINT msg, HWND hwndFrom, HWND hwndTo, UINT code);
  5823. #define MSG_SENT 0
  5824. #define MSG_POST 1
  5825. #define MSG_RECV 2
  5826. #define MSG_PEEK 3
  5827. #else
  5828. #define ValidatePublicObjectList()
  5829. #define TraceDdeMsg(m, h1, h2, c)
  5830. #endif // DBG
  5831. typedef struct tagFREELIST {
  5832. struct tagFREELIST *next;
  5833. HANDLE h; // CSR client side GMEM_DDESHARE handle
  5834. DWORD flags; // XS_ flags describing data
  5835. } FREELIST, *PFREELIST;
  5836. typedef struct tagDDEIMP {
  5837. SECURITY_QUALITY_OF_SERVICE qos;
  5838. SECURITY_CLIENT_CONTEXT ClientContext;
  5839. short cRefInit;
  5840. short cRefConv;
  5841. } DDEIMP, *PDDEIMP;
  5842. typedef struct tagDDECONV {
  5843. THROBJHEAD head; // HM header
  5844. struct tagDDECONV *snext;
  5845. struct tagDDECONV *spartnerConv; // siamese twin
  5846. PWND spwnd; // associated pwnd
  5847. PWND spwndPartner; // associated partner pwnd
  5848. struct tagXSTATE *spxsOut; // transaction info queue - out point
  5849. struct tagXSTATE *spxsIn; // transaction info queue - in point
  5850. struct tagFREELIST *pfl; // free list
  5851. DWORD flags; // CXF_ flags
  5852. struct tagDDEIMP *pddei; // impersonation information
  5853. } DDECONV, *PDDECONV;
  5854. typedef DWORD (FNDDERESPONSE)(PDWORD pmsg, LPARAM *plParam, PDDECONV pDdeConv);
  5855. typedef FNDDERESPONSE *PFNDDERESPONSE;
  5856. typedef struct tagXSTATE {
  5857. THROBJHEAD head; // HM header
  5858. struct tagXSTATE *snext;
  5859. PFNDDERESPONSE fnResponse; // proc to handle next msg.
  5860. HANDLE hClient; // GMEM_DDESAHRE handle on client side
  5861. HANDLE hServer; // GMEM_DDESHARE handle on server side
  5862. PINTDDEINFO pIntDdeInfo; // DDE data being transfered
  5863. DWORD flags; // XS_ flags describing transaction/data
  5864. } XSTATE, *PXSTATE;
  5865. // values for flags field
  5866. #define CXF_IS_SERVER 0x0001
  5867. #define CXF_TERMINATE_POSTED 0x0002
  5868. #define CXF_PARTNER_WINDOW_DIED 0x0004
  5869. #define CXF_INTRA_PROCESS 0x8000
  5870. BOOL xxxDDETrackSendHook(PWND pwndTo, DWORD message, WPARAM wParam, LPARAM lParam);
  5871. DWORD xxxDDETrackPostHook(PUINT pmessage, PWND pwndTo, WPARAM wParam, LPARAM *plParam, BOOL fSent);
  5872. VOID FreeDdeXact(PXSTATE pxs);
  5873. VOID xxxDDETrackGetMessageHook(PMSG pmsg);
  5874. VOID xxxDDETrackWindowDying(PWND pwnd, PDDECONV pDdeConv);
  5875. VOID FreeDdeConv(PDDECONV pDdeConv);
  5876. BOOL _ImpersonateDdeClientWindow(PWND pwndClient, PWND pwndServer);
  5877. typedef struct tagMONITORPOS
  5878. {
  5879. RECT rcMonitor; /* where the monitor rect was */
  5880. RECT rcWork; /* where the work rect was */
  5881. PMONITOR pMonitor; /* what new monitor gets its windows */
  5882. } MONITORPOS, *PMONITORPOS;
  5883. typedef struct tagMONITORRECTS
  5884. {
  5885. int cMonitor; /* number of monitors */
  5886. MONITORPOS amp[1]; /* the monitor positions */
  5887. } MONITORRECTS, *PMONITORRECTS;
  5888. // stuctures for windows resize/ reposition on reconnect.
  5889. // when disconnecting from local console, these structures allow
  5890. // to memorize the monitors layout and windows size and positions
  5891. // on the monitors. When reconnecting back to local console, the snapshot
  5892. // is used to restore windows positions for windows that still exist.
  5893. typedef struct tagWPSNAPSHOT
  5894. {
  5895. RECT rcWindow; /* Windows rect */
  5896. HWND hwnd; /* hwnd */
  5897. } WPSNAPSHOT, *PWPSNAPSHOT;
  5898. typedef struct tagWMSNAPSHOT
  5899. {
  5900. PMONITORRECTS pmr; /* Monitors and their dimensions and positions */
  5901. PWPSNAPSHOT pwps; /* Windows and their dimensions and positions */
  5902. int cWindows; /* number of windows in pwps */
  5903. } WMSNAPSHOT, *PWMSNAPSHOT;
  5904. NTSTATUS RestoreMonitorsAndWindowsRects(VOID);
  5905. NTSTATUS SnapShotMonitorsAndWindowsRects(VOID);
  5906. VOID CleanupMonitorsAndWindowsSnapShot(VOID);
  5907. PWPSNAPSHOT SnapshotWindowRects(int *pnWindows);
  5908. PMONITORRECTS SnapshotMonitorRects(VOID);
  5909. VOID xxxDesktopRecalc(PMONITORRECTS pmrOld);
  5910. VOID UpdateMonitorRectsSnapShot(PMONITORRECTS pmr);
  5911. BOOL IsValidMonitor(PMONITOR pMonitor);
  5912. BOOL _SetDoubleClickTime(UINT dtTime);
  5913. BOOL _SwapMouseButton(BOOL fSwapButtons);
  5914. VOID xxxDestroyThreadInfo(VOID);
  5915. BOOL _GetWindowPlacement(PWND pwnd, PWINDOWPLACEMENT pwp);
  5916. PMENU xxxGetSystemMenu(PWND pWnd, BOOL bRevert);
  5917. PMENU _CreateMenu(VOID);
  5918. PMENU _CreatePopupMenu(VOID);
  5919. BOOL _DestroyMenu(PMENU pMenu);
  5920. DWORD _CheckMenuItem(PMENU pMenu, UINT wIDCheckItem, UINT wCheck);
  5921. DWORD xxxEnableMenuItem(PMENU pMenu, UINT wIDEnableItem, UINT wEnable);
  5922. PWND _GetNextQueueWindow(PWND pwnd, BOOL fDir, BOOL fAltEsc);
  5923. UINT_PTR _SetSystemTimer(PWND pwnd, UINT_PTR nIDEvent, DWORD dwElapse,
  5924. TIMERPROC_PWND pTimerFunc);
  5925. BOOL _SetClipboardData(UINT fmt, HANDLE hData, BOOL fGlobalHandle, BOOL fIncSerialNumber);
  5926. WORD _SetClassWord(PWND pwnd, int index, WORD value);
  5927. DWORD xxxSetClassLong(PWND pwnd, int index, DWORD value, BOOL bAnsi);
  5928. #ifdef _WIN64
  5929. ULONG_PTR xxxSetClassLongPtr(PWND pwnd, int index, ULONG_PTR value, BOOL bAnsi);
  5930. #else
  5931. #define xxxSetClassLongPtr xxxSetClassLong
  5932. #endif
  5933. ATOM _RegisterClassEx(LPWNDCLASSVEREX pwc,
  5934. PCLSMENUNAME pcmn,
  5935. WORD fnid,
  5936. DWORD dwFlags,
  5937. LPDWORD pdwWOW);
  5938. BOOL xxxHiliteMenuItem(PWND pwnd, PMENU pmenu, UINT cmd, UINT flags);
  5939. HANDLE _CreateAcceleratorTable(LPACCEL paccel, int cbAccel);
  5940. HANDLE xxxGetInputEvent(DWORD dwWakeMask);
  5941. BOOL _UnregisterClass(LPCWSTR lpszClassName, HANDLE hModule, PCLSMENUNAME pcmn);
  5942. ATOM _GetClassInfoEx(HANDLE hModule, LPCWSTR lpszClassName, LPWNDCLASSEX pwc, LPWSTR *ppszMenuName, BOOL bAnsi);
  5943. PWND _WindowFromDC(HDC hdc);
  5944. PCLS _GetWOWClass(HANDLE hModule, LPCWSTR lpszClassName);
  5945. LRESULT xxxHkCallHook(PHOOK phk, int nCode, WPARAM wParam, LPARAM lParam);
  5946. PHOOK zzzSetWindowsHookEx(HANDLE hmod, PUNICODE_STRING pstrLib,
  5947. PTHREADINFO ptiThread, int nFilterType, PROC pfnFilterProc, DWORD dwFlags);
  5948. DWORD GetDebugHookLParamSize(WPARAM wParam, PDEBUGHOOKINFO pdebughookstruct);
  5949. BOOL _RegisterLogonProcess(DWORD dwProcessId, BOOL fSecure);
  5950. UINT _LockWindowStation(PWINDOWSTATION pwinsta);
  5951. BOOL _UnlockWindowStation(PWINDOWSTATION pwinsta);
  5952. BOOL _SetWindowStationUser(PWINDOWSTATION pwinsta, PLUID pluidUser,
  5953. PSID psidUser, DWORD cbsidUser);
  5954. BOOL _SetDesktopBitmap(PDESKTOP pdesk, HBITMAP hbitmap, DWORD dwStyle);
  5955. BOOL _SetLogonNotifyWindow(PWND pwnd);
  5956. BOOL _RegisterTasklist(PWND pwndTasklist);
  5957. LONG_PTR _SetMessageExtraInfo(LONG_PTR);
  5958. VOID xxxRemoveEvents(PQ pq, int nQueue, DWORD flags);
  5959. PPCLS _InnerGetClassPtr(ATOM atom, PPCLS ppclsList, HANDLE hModule);
  5960. /*
  5961. * ntcb.h funtions.
  5962. */
  5963. DWORD ClientGetListboxString(PWND hwnd, UINT msg,
  5964. WPARAM wParam, PVOID lParam,
  5965. ULONG_PTR xParam, PROC xpfn, DWORD dwSCMSFlags, BOOL bNotString, PSMS psms);
  5966. HANDLE ClientLoadLibrary(PUNICODE_STRING pstrLib, ULONG_PTR offPfnInitDefWindowProc);
  5967. BOOL ClientFreeLibrary(HANDLE hmod);
  5968. #ifdef MESSAGE_PUMP_HOOK
  5969. BOOL ClientGetMessageMPH(LPMSG msg, HWND hwndFilter, UINT msgMin, UINT msgMax, UINT flags, BOOL fGetMessage);
  5970. BOOL ClientWaitMessageExMPH(UINT fsWakeMask, DWORD Timeout);
  5971. #endif
  5972. BOOL xxxClientGetCharsetInfo(LCID lcid, PCHARSETINFO pcs);
  5973. BOOL ClientExitProcess(PFNW32ET pfn, DWORD dwExitCode);
  5974. BOOL ClientGrayString(GRAYSTRINGPROC pfnOutProc, HDC hdc,
  5975. DWORD lpData, int nCount);
  5976. BOOL CopyFromClient(LPBYTE lpByte, LPBYTE lpByteClient, DWORD cch,
  5977. BOOL fString, BOOL fAnsi);
  5978. BOOL CopyToClient(LPBYTE lpByte, LPBYTE lpByteClient,
  5979. DWORD cchMax, BOOL fAnsi);
  5980. VOID ClientNoMemoryPopup(VOID);
  5981. NTSTATUS xxxClientThreadSetup(VOID);
  5982. VOID ClientDeliverUserApc(VOID);
  5983. BOOL ClientImmLoadLayout(HKL, PIMEINFOEX);
  5984. DWORD ClientImmProcessKey(HWND, HKL, UINT, LPARAM, DWORD);
  5985. NTSTATUS xxxUserModeCallback (ULONG uApi, PVOID pIn, ULONG cbIn, PVOID pOut, ULONG cbOut);
  5986. int xxxClientLoadStringW(UINT StrID, LPWSTR szText, int cch);
  5987. PCURSOR ClassSetSmallIcon(
  5988. PCLS pcls,
  5989. PCURSOR pcursor,
  5990. BOOL fServerCreated);
  5991. BOOL _GetTextMetricsW(
  5992. HDC hdc,
  5993. LPTEXTMETRICW ptm);
  5994. int xxxDrawMenuBarTemp(
  5995. PWND pwnd,
  5996. HDC hdc,
  5997. LPRECT lprc,
  5998. PMENU pMenu,
  5999. HFONT hFont);
  6000. BOOL xxxDrawCaptionTemp(
  6001. PWND pwnd,
  6002. HDC hdc,
  6003. LPRECT lprc,
  6004. HFONT hFont,
  6005. PCURSOR pcursor,
  6006. PUNICODE_STRING pstrText OPTIONAL,
  6007. UINT flags);
  6008. WORD xxxTrackCaptionButton(
  6009. PWND pwnd,
  6010. UINT hit);
  6011. VOID GiveForegroundActivateRight(HANDLE hPid);
  6012. BOOL HasForegroundActivateRight(HANDLE hPid);
  6013. BOOL FRemoveForegroundActivate(PTHREADINFO pti);
  6014. VOID RestoreForegroundActivate(VOID);
  6015. VOID CancelForegroundActivate(VOID);
  6016. #define ACTIVATE_ARRAY_SIZE 5
  6017. extern HANDLE ghCanActivateForegroundPIDs[ACTIVATE_ARRAY_SIZE];
  6018. __inline VOID GiveForegroundActivateRight(
  6019. HANDLE hPid)
  6020. {
  6021. static int index = 0;
  6022. TAGMSG1(DBGTAG_FOREGROUND, "Giving 0x%x foreground activate right", hPid);
  6023. ghCanActivateForegroundPIDs[index++] = hPid;
  6024. if (index == ACTIVATE_ARRAY_SIZE) {
  6025. index = 0;
  6026. }
  6027. }
  6028. __inline BOOL HasForegroundActivateRight(
  6029. HANDLE hPid)
  6030. {
  6031. int i = 0;
  6032. for(; i < ACTIVATE_ARRAY_SIZE; ++i) {
  6033. if (ghCanActivateForegroundPIDs[i] == hPid) {
  6034. TAGMSG1(DBGTAG_FOREGROUND, "HasForegroundActivateRight: Found 0x%x", hPid);
  6035. return TRUE;
  6036. }
  6037. }
  6038. TAGMSG1(DBGTAG_FOREGROUND, "HasForegroundActivateRight: Did NOT find 0x%x", hPid);
  6039. return FALSE;
  6040. }
  6041. #define WHERE_NOONE_CAN_SEE_ME ((int) -32000)
  6042. BOOL MinToTray(PWND pwnd);
  6043. void xxxUpdateThreadsWindows(
  6044. PTHREADINFO pti,
  6045. PWND pwnd,
  6046. HRGN hrgnFullDrag);
  6047. NTSTATUS xxxQueryInformationThread(
  6048. IN HANDLE hThread,
  6049. IN USERTHREADINFOCLASS ThreadInfoClass,
  6050. OUT PVOID ThreadInformation,
  6051. IN ULONG ThreadInformationLength,
  6052. OUT PULONG ReturnLength OPTIONAL);
  6053. NTSTATUS xxxSetInformationThread(
  6054. IN HANDLE hThread,
  6055. IN USERTHREADINFOCLASS ThreadInfoClass,
  6056. IN PVOID ThreadInformation,
  6057. IN ULONG ThreadInformationLength);
  6058. NTSTATUS GetProcessDefaultWindowOrientation(
  6059. IN HANDLE hProcess,
  6060. OUT DWORD *pdwDefaultOrientation);
  6061. NTSTATUS SetProcessDefaultWindowOrientation(
  6062. IN HANDLE hProcess,
  6063. IN DWORD dwDefaultOrientation);
  6064. NTSTATUS SetInformationProcess(
  6065. IN HANDLE hProcess,
  6066. IN USERPROCESSINFOCLASS ProcessInfoClass,
  6067. IN PVOID ProcessInformation,
  6068. IN ULONG ProcessInformationLength);
  6069. NTSTATUS xxxConsoleControl(
  6070. IN CONSOLECONTROL ConsoleControl,
  6071. IN PVOID ConsoleInformation,
  6072. IN ULONG ConsoleInformationLength);
  6073. /***************************************************************************\
  6074. * String Table Defines
  6075. *
  6076. * KERNEL\STRID.MC has a nice big table of strings that are meant to be
  6077. * localized. Before use, the strings are pulled from the resource table
  6078. * with LoadString, passing it one of the following string ids.
  6079. *
  6080. * NOTE: Only strings that need to be localized should be added to the
  6081. * string table. Class name strings, etc are NOT localized.
  6082. *
  6083. * LATER: All string table entries should be reexamined to be sure they
  6084. * conform to the note above.
  6085. *
  6086. \***************************************************************************/
  6087. #define OCR_APPSTARTING 32650
  6088. /*
  6089. * Win Event Hook struct
  6090. */
  6091. typedef struct tagEVENTHOOK {
  6092. THROBJHEAD head; //
  6093. struct tagEVENTHOOK *pehNext; // Next event hook
  6094. UINT eventMin; // Min event (>=) to hook
  6095. UINT eventMax; // Max event (<=) to hook
  6096. UINT fDestroyed:1; // If orphaned while in use
  6097. UINT fIgnoreOwnThread:1; // Ignore events for installer thread
  6098. UINT fIgnoreOwnProcess:1; // Ignore events for installer process
  6099. UINT fSync:1; // Sync event (inject DLL into each process)
  6100. HANDLE hEventProcess; // Process being hooked
  6101. DWORD idEventThread; // Thread being hooked
  6102. ULONG_PTR offPfn; // offset event proc
  6103. int ihmod; // index of module containing event proc
  6104. LPWSTR pwszModulePath; // Path of module library for global sync.
  6105. } EVENTHOOK, *PEVENTHOOK;
  6106. typedef struct tagNOTIFY {
  6107. struct tagNOTIFY *pNotifyNext; // Next notification
  6108. PEVENTHOOK spEventHook; // Event this refers to
  6109. DWORD event; // Event
  6110. HWND hwnd; // hwnd to ask about it
  6111. LONG idObject; // object ID
  6112. LONG idChild; // child id
  6113. DWORD idSenderThread; // Thread generating event
  6114. DWORD dwEventTime; // Event time
  6115. DWORD dwWEFlags; // WEF_DEFERNOTIFY etc.
  6116. PTHREADINFO ptiReceiver; // Thread receiving event
  6117. } NOTIFY, *PNOTIFY;
  6118. VOID xxxWindowEvent(DWORD event, PWND pwnd, LONG idObject, LONG idChild, DWORD dwFlags);
  6119. #define WEF_USEPWNDTHREAD 0x0001
  6120. #define WEF_DEFERNOTIFY 0x0002
  6121. #define WEF_ASYNC 0x0004
  6122. #define WEF_POSTED 0x0008
  6123. #define DeferWinEventNotify() CheckCritIn(); \
  6124. gdwDeferWinEvent++
  6125. #define IsWinEventNotifyDeferred() (gdwDeferWinEvent > 0)
  6126. #define IsWinEventNotifyDeferredOK() (!IsWinEventNotifyDeferred() || ISATOMICCHECK())
  6127. #define zzzEndDeferWinEventNotify() \
  6128. UserAssert(IsWinEventNotifyDeferred()); \
  6129. CheckCritIn(); \
  6130. if (--gdwDeferWinEvent == 0) { \
  6131. if (gpPendingNotifies != NULL) { \
  6132. xxxFlushDeferredWindowEvents(); \
  6133. } \
  6134. }
  6135. /*
  6136. * Only use this one for bookkeeping gdwDeferWinEvent,
  6137. * which may be required without leaving the critical section.
  6138. */
  6139. #define EndDeferWinEventNotifyWithoutProcessing() \
  6140. UserAssert(IsWinEventNotifyDeferred()); \
  6141. CheckCritIn(); \
  6142. --gdwDeferWinEvent
  6143. #define zzzWindowEvent(event, pwnd, idObject, idChild, dwFlags) \
  6144. xxxWindowEvent(event, pwnd, idObject, idChild, \
  6145. IsWinEventNotifyDeferred() ? (dwFlags) | WEF_DEFERNOTIFY : (dwFlags))
  6146. VOID xxxFlushDeferredWindowEvents();
  6147. BOOL xxxClientCallWinEventProc(WINEVENTPROC pfn, PEVENTHOOK pEventHook, PNOTIFY pNotify);
  6148. void DestroyEventHook(PEVENTHOOK);
  6149. VOID FreeThreadsWinEvents(PTHREADINFO pti);
  6150. BOOL _UnhookWinEvent(PEVENTHOOK peh);
  6151. VOID DestroyNotify(PNOTIFY pNotify);
  6152. PEVENTHOOK xxxProcessNotifyWinEvent(PNOTIFY pNotify);
  6153. PEVENTHOOK _SetWinEventHook(DWORD eventMin, DWORD eventMax,
  6154. HMODULE hmodWinEventProc, PUNICODE_STRING pstrLib,
  6155. WINEVENTPROC pfnWinEventProc, HANDLE hEventProcess,
  6156. DWORD idEventThread, DWORD dwFlags);
  6157. BOOL _GetGUIThreadInfo(PTHREADINFO pti, PGUITHREADINFO pgui);
  6158. BOOL xxxGetTitleBarInfo(PWND pwnd, PTITLEBARINFO ptbi);
  6159. BOOL xxxGetComboBoxInfo(PWND pwnd, PCOMBOBOXINFO ptbi);
  6160. DWORD xxxGetListBoxInfo(PWND pwnd);
  6161. BOOL xxxGetScrollBarInfo(PWND pwnd, LONG idObject, PSCROLLBARINFO ptbi);
  6162. PWND _GetAncestor(PWND pwnd, UINT gaFlags);
  6163. PWND _RealChildWindowFromPoint(PWND pwndParent, POINT pt);
  6164. BOOL _GetAltTabInfo(int iItem, PALTTABINFO pati,
  6165. LPWSTR lpszItemText, UINT cchItemText, BOOL bAnsi);
  6166. BOOL xxxGetMenuBarInfo(PWND pwnd, long idObject, long idItem, PMENUBARINFO pmbi);
  6167. typedef HWND *PHWND;
  6168. typedef struct tagSwitchWndInfo *PSWINFO;
  6169. typedef struct tagSwitchWndInfo {
  6170. PSWINFO pswiNext; // Pointer to the next Switch Window Info.
  6171. PTHREADINFO pti; // pit that allocated the strucutre.
  6172. PBWL pbwl; // Pointer to the window list built.
  6173. PHWND phwndLast; // Pointer to the last window in the list.
  6174. PHWND phwndCurrent; // pointer to the current window.
  6175. INT iTotalTasks; // Total number of tasks.
  6176. INT iTasksShown; // Total tasks shown.
  6177. BOOL fScroll; // Is there a need to scroll?
  6178. INT iFirstTaskIndex; // Index to the first task shown.
  6179. INT iNoOfColumns; // Max Number of tasks per row.
  6180. INT iNoOfRows; // Max Number of rows of icons in the switch window.
  6181. INT iIconsInLastRow; // Icons in last row.
  6182. INT iCurCol; // Current column where hilite lies.
  6183. INT iCurRow; // Current row where hilite lies.
  6184. INT cxSwitch; // Switch Window dimensions.
  6185. INT cySwitch;
  6186. POINT ptFirstRowStart; // Top left corner of the first Icon Slot.
  6187. RECT rcTaskName; // Rect where Task name is displayed.
  6188. BOOL fJournaling; // Determins how we check the keyboard state
  6189. } SWITCHWNDINFO, *PSWINFO;
  6190. typedef struct tagSWITCHWND {
  6191. WND;
  6192. PSWINFO pswi;
  6193. } SWITCHWND, *PSWITCHWND;
  6194. typedef struct tagHOTKEYSTRUCT {
  6195. PWND spwnd;
  6196. DWORD key;
  6197. } HOTKEYSTRUCT, *PHOTKEYSTRUCT;
  6198. #define LANGTOGGLEKEYS_SIZE 3
  6199. /*
  6200. * ACCF_ and PUDF_ flags share the same field. ACCF fields
  6201. * are so named because they may later move to a differnt
  6202. * struct.
  6203. */
  6204. #define ACCF_DEFAULTFILTERKEYSON 0x00000001
  6205. #define ACCF_DEFAULTSTICKYKEYSON 0x00000002
  6206. #define ACCF_DEFAULTMOUSEKEYSON 0x00000004
  6207. #define ACCF_DEFAULTTOGGLEKEYSON 0x00000008
  6208. #define ACCF_DEFAULTTIMEOUTON 0x00000010
  6209. #define ACCF_DEFAULTKEYBOARDPREF 0x00000020
  6210. #define ACCF_DEFAULTSCREENREADER 0x00000040
  6211. #define ACCF_DEFAULTHIGHCONTRASTON 0x00000080
  6212. #define ACCF_ACCESSENABLED 0x00000100
  6213. #define ACCF_IGNOREBREAKCODE 0x00000400
  6214. #define ACCF_FKMAKECODEPROCESSED 0x00000800
  6215. #define ACCF_MKVIRTUALMOUSE 0x00001000
  6216. #define ACCF_MKREPEATVK 0x00002000
  6217. #define ACCF_FIRSTTICK 0x00004000
  6218. #define ACCF_SHOWSOUNDSON 0x00008000
  6219. /*
  6220. * NOTE: PUDF_ANIMATE must have the same value as MINMAX_ANIMATE.
  6221. */
  6222. #define PUDF_ANIMATE 0x00010000
  6223. #define ACCF_KEYBOARDPREF 0x00020000
  6224. #define ACCF_SCREENREADER 0x00040000
  6225. #define PUDF_BEEP 0x00080000 /* Warning beeps allowed? */
  6226. #define PUDF_DRAGFULLWINDOWS 0x00100000 /* Drag xor rect or full windows */
  6227. #define PUDF_ICONTITLEWRAP 0x00200000 /* Wrap icon titles or just use single line */
  6228. #define PUDF_FONTSARELOADED 0x00400000
  6229. #define PUDF_POPUPINUSE 0x00800000
  6230. #define PUDF_EXTENDEDSOUNDS 0x01000000
  6231. #define PUDF_MENUSTATEINUSE 0x02000000
  6232. #define PUDF_VDMBOUNDSACTIVE 0x04000000
  6233. #define PUDF_ALLOWFOREGROUNDACTIVATE 0x08000000
  6234. #define PUDF_DRAGGINGFULLWINDOW 0x10000000
  6235. #define PUDF_LOCKFULLSCREEN 0x20000000
  6236. #define PUDF_GSMWPINUSE 0x40000000
  6237. #define TEST_ACCF(f) TEST_FLAG(gdwPUDFlags, f)
  6238. #define TEST_BOOL_ACCF(f) TEST_BOOL_FLAG(gdwPUDFlags, f)
  6239. #define SET_ACCF(f) SET_FLAG(gdwPUDFlags, f)
  6240. #define CLEAR_ACCF(f) CLEAR_FLAG(gdwPUDFlags, f)
  6241. #define SET_OR_CLEAR_ACCF(f, fSet) SET_OR_CLEAR_FLAG(gdwPUDFlags, f, fSet)
  6242. #define TOGGLE_ACCF(f) TOGGLE_FLAG(gdwPUDFlags, f)
  6243. #define TEST_PUDF(f) TEST_FLAG(gdwPUDFlags, f)
  6244. #define TEST_BOOL_PUDF(f) TEST_BOOL_FLAG(gdwPUDFlags, f)
  6245. #define SET_PUDF(f) SET_FLAG(gdwPUDFlags, f)
  6246. #define CLEAR_PUDF(f) CLEAR_FLAG(gdwPUDFlags, f)
  6247. #define SET_OR_CLEAR_PUDF(f, fSet) SET_OR_CLEAR_FLAG(gdwPUDFlags, f, fSet)
  6248. #define TOGGLE_PUDF(f) TOGGLE_FLAG(gdwPUDFlags, f)
  6249. /*
  6250. * Power state stuff
  6251. */
  6252. typedef struct tagPOWERSTATE {
  6253. volatile ULONG fInProgress:1;
  6254. volatile ULONG fCritical:1;
  6255. volatile ULONG fOverrideApps:1;
  6256. volatile ULONG fQueryAllowed:1;
  6257. volatile ULONG fUIAllowed:1;
  6258. PKEVENT pEvent;
  6259. BROADCASTSYSTEMMSGPARAMS bsmParams;
  6260. POWERSTATEPARAMS psParams;
  6261. ULONG PowerStateTask;
  6262. } POWERSTATE, *PPOWERSTATE;
  6263. typedef struct _POWER_INIT {
  6264. PVIDEO_WIN32K_CALLBACKS_PARAMS Params;
  6265. PKEVENT pPowerReadyEvent;
  6266. } POWER_INIT, *PPOWER_INIT;
  6267. #define POWERON_PHASE -1
  6268. #define LOWPOWER_PHASE 1
  6269. #define POWEROFF_PHASE 2
  6270. NTSTATUS InitializePowerRequestList(HANDLE hPowerRequestEvent);
  6271. VOID CleanupPowerRequestList(VOID);
  6272. VOID DeletePowerRequestList(VOID);
  6273. VOID xxxUserPowerCalloutWorker(VOID);
  6274. VOID VideoPortCalloutThread(PPOWER_INIT pInitData);
  6275. /*
  6276. * Fade-in / fade-out globals.
  6277. */
  6278. typedef struct tagFADE {
  6279. HANDLE hsprite;
  6280. HDC hdc;
  6281. HBITMAP hbm;
  6282. POINT ptDst;
  6283. SIZE size;
  6284. DWORD dwTime;
  6285. DWORD dwStart;
  6286. DWORD dwFlags;
  6287. #ifdef MOUSE_IP
  6288. COLORREF crColorKey;
  6289. #endif
  6290. } FADE, *PFADE;
  6291. /*
  6292. * Globals are included last because they may require some of the types
  6293. * being defined above.
  6294. */
  6295. #include "globals.h"
  6296. #include "ddemlsvr.h"
  6297. /*
  6298. * If you make a change that requires including strid.h when building
  6299. * ntuser\rtl, then you need to change the sources/makefil* files so this
  6300. * file will be built in ntuser\inc; make sure that the output of
  6301. * mc.exe still goes to the kernel directory; this is because there are
  6302. * other places (like ntuser\server) where we use the same file name.
  6303. */
  6304. #ifndef _USERRTL_
  6305. #include "strid.h"
  6306. #endif
  6307. #include "ntuser.h"
  6308. #define TestALPHA(uSetting) (!gbDisableAlpha && TestEffectUP(uSetting))
  6309. /*
  6310. * tooltips/tracking prototypes from tooltips.c
  6311. */
  6312. typedef struct tagTOOLTIP {
  6313. DWORD dwFlags;
  6314. UINT uTID;
  6315. DWORD dwAnimStart;
  6316. int iyAnim;
  6317. LPWSTR pstr;
  6318. } TOOLTIP;
  6319. typedef struct tagTOOLTIPWND {
  6320. WND;
  6321. DWORD dwShowDelay;
  6322. DWORD dwHideDelay;
  6323. HDC hdcMem;
  6324. HBITMAP hbmMem;
  6325. TOOLTIP; // this field must be last!
  6326. } TOOLTIPWND, *PTOOLTIPWND;
  6327. #define HTEXSCROLLFIRST 60
  6328. #define HTSCROLLUP 60
  6329. #define HTSCROLLDOWN 61
  6330. #define HTSCROLLUPPAGE 62
  6331. #define HTSCROLLDOWNPAGE 63
  6332. #define HTSCROLLTHUMB 64
  6333. #define HTEXSCROLLLAST 64
  6334. #define HTEXMENUFIRST 65
  6335. #define HTMDISYSMENU 65
  6336. #define HTMDIMAXBUTTON 66
  6337. #define HTMDIMINBUTTON 67
  6338. #define HTMDICLOSE 68
  6339. #define HTMENUITEM 69
  6340. #define HTEXMENULAST 69
  6341. int FindNCHitEx(PWND pwnd, int ht, POINT pt);
  6342. void xxxTrackMouseMove(PWND pwnd, int htEx, UINT message);
  6343. BOOL xxxHotTrack(PWND pwnd, int htEx, BOOL fDraw);
  6344. void xxxResetTooltip(PTOOLTIPWND pttwnd);
  6345. void xxxCancelMouseMoveTracking (DWORD dwDTFlags, PWND pwndTrack, int htEx, DWORD dwDTCancel);
  6346. /*
  6347. * String range IDs.
  6348. *
  6349. * These are defined here to avoid duplicate entries in strid.mc
  6350. */
  6351. #define STR_COLORSTART STR_SCROLLBAR
  6352. #define STR_COLOREND STR_MENUBAR
  6353. /*
  6354. * Sprite and Fade related functions and defines.
  6355. */
  6356. #define FADE_SHOW 0x00000001
  6357. #define FADE_COMPLETED 0x00000002
  6358. #define FADE_SHOWN 0x00000004
  6359. #define FADE_WINDOW 0x00000008
  6360. #define FADE_MENU 0x00000010
  6361. #define FADE_TOOLTIP 0x00000020
  6362. #ifdef MOUSE_IP
  6363. #define FADE_COLORKEY 0x00000040
  6364. #define FADE_SONAR 0x00000080
  6365. #endif
  6366. HDC CreateFade(PWND pwnd, RECT *prc, DWORD dwTime, DWORD dwFlags);
  6367. VOID StartFade(void);
  6368. VOID StopFade(void);
  6369. VOID ShowFade(void);
  6370. VOID AnimateFade(void);
  6371. __inline DWORD TestFadeFlags(
  6372. DWORD dwFlags)
  6373. {
  6374. return (gfade.dwFlags & dwFlags);
  6375. }
  6376. #ifdef MOUSE_IP
  6377. #define IS_SONAR_ACTIVE() (TestUP(MOUSESONAR) && TestFadeFlags(FADE_SONAR))
  6378. #define CLEAR_SONAR_LASTVK() (void)((TestUP(MOUSESONAR) && gbLastVkForSonar) ? (gbLastVkForSonar = 0) : 0)
  6379. BOOL StartSonar();
  6380. void StopSonar();
  6381. #endif
  6382. HANDLE xxxSetLayeredWindow(PWND pwnd, BOOL fRepaintBehind);
  6383. VOID UnsetLayeredWindow(PWND pwnd);
  6384. void TrackLayeredZorder(PWND pwnd);
  6385. VOID UpdateRedirectedDC(PDCE pdce);
  6386. BOOL _UpdateLayeredWindow(PWND pwnd, HDC hdcDst, POINT *pptDst, SIZE *psize, HDC hdcSrc,
  6387. POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags);
  6388. BOOL _GetLayeredWindowAttributes(PWND hwnd, COLORREF *pcrKey, BYTE *pbAlpha, DWORD *pdwFlags);
  6389. BOOL _SetLayeredWindowAttributes(PWND pwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags);
  6390. BOOL RecreateRedirectionBitmap(PWND pwnd);
  6391. VOID ResetRedirectedWindows(VOID);
  6392. PWND GetStyleWindow(PWND pwnd, DWORD dwStyle);
  6393. PWND GetLastChild(PWND pwnd);
  6394. BOOL SetRedirectedWindow(PWND pwnd, UINT uFlags);
  6395. VOID UnsetRedirectedWindow(PWND pwnd, UINT uFlags);
  6396. VOID ConvertRedirectionDCs(PWND pwnd, HBITMAP hbm);
  6397. VOID xxxCompositedPaint(PWND pwnd);
  6398. #define REDIRECT_LAYER 0x0001
  6399. #define REDIRECT_COMPOSITED 0x0002
  6400. #define REDIRECT_EXTREDIRECTED 0x0004
  6401. #define REDIRECT_PRINT 0x0008
  6402. typedef struct tagREDIRECT {
  6403. HBITMAP hbm;
  6404. RECT rcUpdate;
  6405. UINT uFlags;
  6406. HRGN hrgnComp;
  6407. #if DBG
  6408. PWND pwnd;
  6409. #endif // DBG
  6410. } REDIRECT, *PREDIRECT;
  6411. HBITMAP GetRedirectionBitmap(PWND pwnd);
  6412. BOOL SetRedirectionBitmap(PWND pwnd, HBITMAP hbm);
  6413. UINT GetRedirectionFlags(PWND pwnd);
  6414. BOOL xxxPrintWindow(PWND pwnd, HDC hdcBlt, UINT nFlags);
  6415. void xxxTurnOffCompositing(PWND pwndStart, BOOL fChild);
  6416. #ifdef REDIRECTION
  6417. BOOL xxxSetProcessRedirectionMode(BOOL fEnable, PPROCESSINFO ppi);
  6418. BOOL xxxSetDesktopRedirectionMode(BOOL fEnable, PDESKTOP pDesk, PPROCESSINFO ppi);
  6419. #endif // REDIRECTION
  6420. void InternalInvalidate3(
  6421. PWND pwnd,
  6422. HRGN hrgn,
  6423. DWORD flags);
  6424. BOOL UserSetFont(PUNICODE_STRING pProfileUserName,
  6425. LPLOGFONTW lplf,
  6426. UINT idFont,
  6427. HFONT* phfont
  6428. );
  6429. HICON DWP_GetIcon(
  6430. PWND pwnd,
  6431. UINT uType);
  6432. BOOL xxxRedrawTitle(
  6433. PWND pwnd, UINT wFlags);
  6434. DWORD GetContextHelpId(
  6435. PWND pwnd);
  6436. HANDLE xxxClientCopyImage(
  6437. HANDLE hImage,
  6438. UINT type,
  6439. int cxNew,
  6440. int cyNew,
  6441. UINT flags);
  6442. VOID _WOWCleanup(
  6443. HANDLE hInstance,
  6444. DWORD hTaskWow);
  6445. VOID _WOWModuleUnload(HANDLE hModule);
  6446. /*
  6447. * FastProfile APIs
  6448. */
  6449. typedef struct tagPROFINTINFO {
  6450. UINT idSection;
  6451. LPWSTR lpKeyName;
  6452. DWORD nDefault;
  6453. PUINT puResult;
  6454. } PROFINTINFO, *PPROFINTINFO;
  6455. typedef struct {
  6456. UINT idSection;
  6457. UINT id;
  6458. UINT idRes;
  6459. UINT def;
  6460. } SPINFO, *PSPINFO;
  6461. #define DEFAULT_USER_HANDLE_QUOTA 10000
  6462. #define DEFAULT_POSTMESSAGE_LIMIT 10000
  6463. /*
  6464. * See aFastRegMap[] in ntuser\kernel\profile.c
  6465. */
  6466. #define PMAP_COLORS 0
  6467. #define PMAP_CURSORS 1
  6468. #define PMAP_WINDOWSM 2
  6469. #define PMAP_WINDOWSU 3
  6470. #define PMAP_DESKTOP 4
  6471. #define PMAP_ICONS 5
  6472. #define PMAP_FONTS 6
  6473. #define PMAP_TRUETYPE 7
  6474. #define PMAP_KBDLAYOUT 8
  6475. #define PMAP_INPUT 9
  6476. #define PMAP_COMPAT 10
  6477. #define PMAP_SUBSYSTEMS 11
  6478. #define PMAP_BEEP 12
  6479. #define PMAP_MOUSE 13
  6480. #define PMAP_KEYBOARD 14
  6481. #define PMAP_STICKYKEYS 15
  6482. #define PMAP_KEYBOARDRESPONSE 16
  6483. #define PMAP_MOUSEKEYS 17
  6484. #define PMAP_TOGGLEKEYS 18
  6485. #define PMAP_TIMEOUT 19
  6486. #define PMAP_SOUNDSENTRY 20
  6487. #define PMAP_SHOWSOUNDS 21
  6488. #define PMAP_AEDEBUG 22
  6489. #define PMAP_NETWORK 23
  6490. #define PMAP_METRICS 24
  6491. #define PMAP_UKBDLAYOUT 25
  6492. #define PMAP_UKBDLAYOUTTOGGLE 26
  6493. #define PMAP_WINLOGON 27
  6494. #define PMAP_KEYBOARDPREF 28
  6495. #define PMAP_SCREENREADER 29
  6496. #define PMAP_HIGHCONTRAST 30
  6497. #define PMAP_IMECOMPAT 31
  6498. #define PMAP_IMM 32
  6499. #define PMAP_POOLLIMITS 33
  6500. #define PMAP_COMPAT32 34
  6501. #define PMAP_SETUPPROGRAMNAMES 35
  6502. #define PMAP_INPUTMETHOD 36
  6503. #define PMAP_COMPAT2 37
  6504. #define PMAP_MOUCLASS_PARAMS 38
  6505. #define PMAP_KBDCLASS_PARAMS 39
  6506. #define PMAP_COMPUTERNAME 40
  6507. #define PMAP_TS 41
  6508. #define PMAP_TABLETPC 42
  6509. #define PMAP_MEDIACENTER 43
  6510. #define PMAP_TS_EXCLUDE_DESKTOP_VERSION 44
  6511. #define PMAP_LAST 44
  6512. #define MAXPROFILEBUF 256
  6513. #define POLICY_NONE 0x0001
  6514. #define POLICY_USER 0x0002
  6515. #define POLICY_MACHINE 0x0004
  6516. #define POLICY_REMOTE 0x0008
  6517. #define POLICY_ONLY 0x0010
  6518. /*
  6519. * POLICY_REMOTE is not included in POLICY_ALL intentionally.
  6520. * Else, we will try to read the remote policy always.
  6521. */
  6522. #define POLICY_ALL (POLICY_NONE | POLICY_USER | POLICY_MACHINE)
  6523. #define POLICY_VALID (POLICY_ALL | POLICY_ONLY | POLICY_REMOTE)
  6524. PUNICODE_STRING CreateProfileUserName(TL *ptl);
  6525. void FreeProfileUserName(PUNICODE_STRING pProfileUserName,TL *ptl);
  6526. HANDLE OpenCacheKeyEx(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, ACCESS_MASK amRequest, PDWORD pdwPolicyFlags);
  6527. BOOL CheckDesktopPolicy(PUNICODE_STRING pProfileUserName OPTIONAL, PCWSTR lpKeyName);
  6528. BOOL CheckDesktopPolicyChange(PUNICODE_STRING pProfileUserName OPTIONAL);
  6529. DWORD FastGetProfileKeysW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR pszDefault, LPWSTR *ppszKeys);
  6530. BOOL FastGetProfileDwordW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName, DWORD dwDefault, PDWORD pdwReturn, DWORD dwPolicyOnly);
  6531. DWORD FastGetProfileStringW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize, DWORD dwPolicyOnly);
  6532. BOOL FastGetProfileIntW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName, UINT nDefault, PUINT puiReturn, DWORD dwPolicyOnly);
  6533. BOOL FastWriteProfileStringW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName, LPCWSTR lpString);
  6534. BOOL FastGetProfileIntFromID(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, UINT idKey, int def, PINT pResult, DWORD dwPolicyOnly);
  6535. DWORD FastGetProfileStringFromIDW(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, UINT idKey, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD cch, DWORD dwPolicyOnly);
  6536. BOOL FastWriteProfileValue(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName, UINT uType, LPBYTE lpStruct, UINT cbSizeStruct);
  6537. DWORD FastGetProfileValue(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, LPCWSTR lpKeyName,LPBYTE lpDefault, LPBYTE lpReturn, UINT cbSizeReturn, DWORD dwPolicyOnly);
  6538. BOOL FastGetProfileIntsW(PUNICODE_STRING pProfileUserName OPTIONAL, PPROFINTINFO ppii, DWORD dwPolicyOnly);
  6539. BOOL FastUpdateWinIni(PUNICODE_STRING pProfileUserName OPTIONAL, UINT idSection, UINT wKeyNameId, LPWSTR lpszValue);
  6540. /*
  6541. * # of pels added to border width. When a user requests a border width of 1
  6542. * that user actualy gets a border width of BORDER_EXTRA + 1 if the window
  6543. * has a sizing border.
  6544. */
  6545. #define BORDER_EXTRA 3
  6546. /*
  6547. * tmswitch.c stuff
  6548. */
  6549. __inline int GetCaptionHeight(
  6550. PWND pwnd)
  6551. {
  6552. if (!TestWF(pwnd, WFCPRESENT)) {
  6553. return 0;
  6554. } else {
  6555. return TestWF(pwnd, WEFTOOLWINDOW) ?
  6556. SYSMET(CYSMCAPTION) : SYSMET(CYCAPTION);
  6557. }
  6558. }
  6559. __inline VOID InitTooltipDelay(
  6560. PTOOLTIPWND pttwnd)
  6561. {
  6562. if (pttwnd != NULL) {
  6563. pttwnd->dwShowDelay = gdtDblClk * 3;
  6564. pttwnd->dwHideDelay = gdtDblClk * 8;
  6565. }
  6566. }
  6567. __inline PPROFILEVALUEINFO UPDWORDPointer(
  6568. UINT uSetting)
  6569. {
  6570. UserAssert(UPIsDWORDRange(uSetting));
  6571. return gpviCPUserPreferences + UPDWORDIndex(uSetting);
  6572. }
  6573. /*
  6574. * ComputeTickDelta
  6575. *
  6576. * ComputeTickDelta computes a time delta between two times. The
  6577. * delta is defined as a 31-bit, signed value. It is best to think of time as
  6578. * a clock that wraps around. The delta is the minimum distance on this circle
  6579. * between two different places on the circle. If the delta goes
  6580. * counter-clockwise, it is looking at a time in the PAST and is POSITIVE. If
  6581. * the delta goes clockwise, it is looking at a time in the FUTURE and is
  6582. * negative.
  6583. *
  6584. * It is IMPORTANT to realize that the (dwCurTime >= dwLastTime) comparison does
  6585. * not determine the delta's sign, but only determines the operation to compute
  6586. * the delta without an overflow occuring.
  6587. */
  6588. __inline
  6589. int ComputeTickDelta(
  6590. IN DWORD dwCurTick,
  6591. IN DWORD dwLastTick)
  6592. {
  6593. return (int) dwCurTick - dwLastTick;
  6594. }
  6595. __inline
  6596. DWORD ComputePastTickDelta(
  6597. IN DWORD dwCurTick,
  6598. IN DWORD dwLastTick)
  6599. {
  6600. /*
  6601. * This handles a wrap-around.
  6602. */
  6603. return dwCurTick - dwLastTick;
  6604. }
  6605. __inline BOOL IsTimeFromLastInput(
  6606. DWORD dwTimeout)
  6607. {
  6608. return ((NtGetTickCount() - glinp.timeLastInputMessage) > dwTimeout);
  6609. }
  6610. __inline BOOL IsTimeFromLastRITEvent(
  6611. DWORD dwTimeout)
  6612. {
  6613. return ((NtGetTickCount() - gpsi->dwLastRITEventTickCount) > dwTimeout);
  6614. }
  6615. #if DBG
  6616. __inline void DBGIncModalMenuCount(
  6617. VOID)
  6618. {
  6619. guModalMenuStateCount++;
  6620. }
  6621. __inline VOID DBGDecModalMenuCount(
  6622. VOID)
  6623. {
  6624. UserAssert(guModalMenuStateCount != 0);
  6625. guModalMenuStateCount--;
  6626. }
  6627. #else
  6628. #define DBGIncModalMenuCount()
  6629. #define DBGDecModalMenuCount()
  6630. #endif
  6631. __inline BOOL IsForegroundLocked(
  6632. VOID)
  6633. {
  6634. return (guSFWLockCount != 0 || gppiLockSFW != NULL);
  6635. }
  6636. /*
  6637. * Compatibility hack for foreground activation problems.
  6638. */
  6639. __inline
  6640. BOOL GiveUpForeground(
  6641. VOID)
  6642. {
  6643. if (gptiForeground == NULL) {
  6644. return FALSE;
  6645. }
  6646. if (GetAppCompatFlags2ForPti(gptiForeground, VER40) & GACF2_GIVEUPFOREGROUND) {
  6647. TAGMSG0(DBGTAG_FOREGROUND, "GiveUpForeground Hack Succeeded!");
  6648. return TRUE;
  6649. }
  6650. return FALSE;
  6651. }
  6652. __inline VOID IncSFWLockCount(
  6653. VOID)
  6654. {
  6655. guSFWLockCount++;
  6656. }
  6657. __inline VOID DecSFWLockCount(
  6658. VOID)
  6659. {
  6660. UserAssert(guSFWLockCount != 0);
  6661. guSFWLockCount--;
  6662. }
  6663. __inline DWORD UPDWORDValue(
  6664. UINT uSetting)
  6665. {
  6666. return UPDWORDPointer(uSetting)->dwValue;
  6667. }
  6668. /*
  6669. * Use this macro ONLY if UPIsDWORDRange(SPI_GET ## uSetting) is TRUE.
  6670. */
  6671. #define UP(uSetting) UPDWORDValue(SPI_GET ## uSetting)
  6672. /*
  6673. * NTIMM.C
  6674. */
  6675. #define IMESHOWSTATUS_NOTINITIALIZED ((BOOL)0xffff)
  6676. PIMC CreateInputContext(
  6677. IN ULONG_PTR dwClientImcData);
  6678. BOOL DestroyInputContext(
  6679. IN PIMC pImc);
  6680. VOID FreeInputContext(
  6681. IN PIMC pImc);
  6682. HIMC AssociateInputContext(
  6683. IN PWND pWnd,
  6684. IN PIMC pImc);
  6685. AIC_STATUS AssociateInputContextEx(
  6686. IN PWND pWnd,
  6687. IN PIMC pImc,
  6688. IN DWORD dwFlag);
  6689. BOOL UpdateInputContext(
  6690. IN PIMC pImc,
  6691. IN UPDATEINPUTCONTEXTCLASS UpdateType,
  6692. IN ULONG_PTR UpdateValue);
  6693. VOID xxxFocusSetInputContext(
  6694. IN PWND pwnd,
  6695. IN BOOL fActivate,
  6696. IN BOOL fQueueMsg);
  6697. UINT BuildHimcList(
  6698. PTHREADINFO pti,
  6699. UINT cHimcMax,
  6700. HIMC *phimcFirst);
  6701. PWND xxxCreateDefaultImeWindow(
  6702. IN PWND pwnd,
  6703. IN ATOM atomT,
  6704. IN HANDLE hInst);
  6705. BOOL xxxImmActivateThreadsLayout(
  6706. PTHREADINFO pti,
  6707. PTLBLOCK ptlBlockPrev,
  6708. PKL pkl);
  6709. VOID xxxImmActivateAndUnloadThreadsLayout(
  6710. IN PTHREADINFO *ptiList,
  6711. IN UINT nEntries,
  6712. IN PTLBLOCK ptlBlockPrev,
  6713. PKL pklCurrent,
  6714. DWORD dwHklReplace);
  6715. VOID xxxImmActivateLayout(
  6716. IN PTHREADINFO pti,
  6717. IN PKL pkl);
  6718. VOID xxxImmUnloadThreadsLayout(
  6719. IN PTHREADINFO *ptiList,
  6720. IN UINT nEntry,
  6721. IN PTLBLOCK ptlBlockPrev,
  6722. IN DWORD dwFlag);
  6723. VOID xxxImmUnloadLayout(
  6724. IN PTHREADINFO pti,
  6725. IN DWORD dwFlag);
  6726. PIMEINFOEX xxxImmLoadLayout(
  6727. IN HKL hKL);
  6728. VOID xxxImmActivateLayout(
  6729. IN PTHREADINFO pti,
  6730. IN PKL pkl);
  6731. BOOL GetImeInfoEx(
  6732. IN PWINDOWSTATION pwinsta,
  6733. IN PIMEINFOEX piiex,
  6734. IN IMEINFOEXCLASS SearchType);
  6735. BOOL SetImeInfoEx(
  6736. IN PWINDOWSTATION pwinsta,
  6737. IN PIMEINFOEX piiex);
  6738. DWORD xxxImmProcessKey(
  6739. IN PQ pq,
  6740. IN PWND pwnd,
  6741. IN UINT message,
  6742. IN WPARAM wParam,
  6743. IN LPARAM lParam);
  6744. BOOL GetImeHotKey(
  6745. DWORD dwHotKeyID,
  6746. PUINT puModifiers,
  6747. PUINT puVKey,
  6748. HKL *phKL );
  6749. BOOL SetImeHotKey(
  6750. DWORD dwHotKeyID,
  6751. UINT uModifiers,
  6752. UINT uVKey,
  6753. HKL hKL,
  6754. DWORD dwAction );
  6755. PIMEHOTKEYOBJ CheckImeHotKey(
  6756. PQ pq,
  6757. UINT uVKey,
  6758. LPARAM lParam);
  6759. BOOL ImeCanDestroyDefIME(
  6760. IN PWND pwndDefaultIme,
  6761. IN PWND pwndDestroy);
  6762. BOOL IsChildSameThread(
  6763. IN PWND pwndParent,
  6764. IN PWND pwndChild);
  6765. BOOL ImeCanDestroyDefIMEforChild(
  6766. IN PWND pwndDefaultIme,
  6767. IN PWND pwndDestroy);
  6768. VOID ImeCheckTopmost(
  6769. IN PWND pwnd);
  6770. VOID ImeSetOwnerWindow(
  6771. IN PWND pwndIme,
  6772. IN PWND pwndNewOwner);
  6773. VOID ImeSetFutureOwner(
  6774. IN PWND pwndDefaultIme,
  6775. IN PWND pwndOrgOwner);
  6776. VOID ImeSetTopmostChild(
  6777. IN PWND pwndRoot,
  6778. IN BOOL fFlag);
  6779. VOID ImeSetTopmost(
  6780. IN PWND pwndRoot,
  6781. IN BOOL fFlag,
  6782. IN PWND pwndInsertBefore);
  6783. PSOFTKBDDATA ProbeAndCaptureSoftKbdData(
  6784. PSOFTKBDDATA Source);
  6785. VOID xxxNotifyIMEStatus(
  6786. IN PWND pwnd,
  6787. IN DWORD dwOpen,
  6788. IN DWORD dwConversion );
  6789. BOOL xxxSetIMEShowStatus(
  6790. IN BOOL fShow);
  6791. VOID xxxBroadcastImeShowStatusChange(
  6792. IN PWND pwndDefIme,
  6793. IN BOOL fShow);
  6794. VOID xxxCheckImeShowStatusInThread(
  6795. IN PWND pwndDefIme);
  6796. #define IsWndImeRelated(pwnd) \
  6797. (pwnd->pcls->atomClassName == gpsi->atomSysClass[ICLS_IME] || \
  6798. TestCF(pwnd, CFIME))
  6799. /*
  6800. * Critical section routines for processing mouse input
  6801. */
  6802. __inline VOID EnterMouseCrit(
  6803. VOID)
  6804. {
  6805. KeEnterCriticalRegion();
  6806. ExAcquireResourceExclusiveLite(gpresMouseEventQueue, TRUE);
  6807. }
  6808. __inline VOID LeaveMouseCrit(
  6809. VOID)
  6810. {
  6811. ExReleaseResourceLite(gpresMouseEventQueue);
  6812. KeLeaveCriticalRegion();
  6813. }
  6814. #if DBG
  6815. #define EnterDeviceInfoListCrit _EnterDeviceInfoListCrit
  6816. #define LeaveDeviceInfoListCrit _LeaveDeviceInfoListCrit
  6817. VOID _EnterDeviceInfoListCrit();
  6818. VOID _LeaveDeviceInfoListCrit();
  6819. #else
  6820. /*
  6821. * Critical section routines for accessing the Device List (gpDeviceInfoList)
  6822. */
  6823. __inline VOID EnterDeviceInfoListCrit(
  6824. VOID)
  6825. {
  6826. KeEnterCriticalRegion();
  6827. ExAcquireResourceExclusiveLite(gpresDeviceInfoList, TRUE);
  6828. }
  6829. __inline VOID LeaveDeviceInfoListCrit(
  6830. VOID)
  6831. {
  6832. ExReleaseResourceLite(gpresDeviceInfoList);
  6833. KeLeaveCriticalRegion();
  6834. }
  6835. #endif // DBG
  6836. #define BEGIN_REENTER_DEVICEINFOLISTCRIT() \
  6837. { \
  6838. BOOL fAlreadyHadDeviceInfoCrit; \
  6839. \
  6840. /* \
  6841. * If we're not in the user crit then acquire it. \
  6842. */ \
  6843. fAlreadyHadDeviceInfoCrit = ExIsResourceAcquiredExclusiveLite(gpresDeviceInfoList); \
  6844. if (fAlreadyHadDeviceInfoCrit == FALSE) { \
  6845. EnterDeviceInfoListCrit(); \
  6846. }
  6847. #define END_REENTER_DEVICEINFOLISTCRIT() \
  6848. if (fAlreadyHadDeviceInfoCrit == FALSE) { \
  6849. LeaveDeviceInfoListCrit(); \
  6850. } \
  6851. }
  6852. /*
  6853. * Request RIT to update the keyboard h/w settings
  6854. */
  6855. __inline VOID RequestKeyboardRateUpdate(
  6856. VOID)
  6857. {
  6858. gdwUpdateKeyboard |= UPDATE_KBD_TYPEMATIC;
  6859. }
  6860. /*
  6861. * Keep some capture state visible from user-mode for performance.
  6862. */
  6863. __inline VOID LockCaptureWindow(
  6864. PQ pq,
  6865. PWND pwnd)
  6866. {
  6867. if (pq->spwndCapture) {
  6868. UserAssert(gpsi->cCaptures > 0);
  6869. gpsi->cCaptures--;
  6870. }
  6871. if (pwnd) {
  6872. gpsi->cCaptures++;
  6873. }
  6874. Lock(&pq->spwndCapture, pwnd);
  6875. }
  6876. __inline VOID UnlockCaptureWindow(
  6877. PQ pq)
  6878. {
  6879. if (pq->spwndCapture) {
  6880. UserAssert(gpsi->cCaptures > 0);
  6881. gpsi->cCaptures--;
  6882. Unlock(&pq->spwndCapture);
  6883. }
  6884. }
  6885. /*
  6886. * Some routines for manipulating desktop and windowstation handles.
  6887. */
  6888. #define HF_DESKTOPHOOK 0 // offset to desktop hook flag
  6889. #define HF_PROTECTED 1 // offset to protected flag
  6890. #define HF_LIMIT 2 // number of flags per handle
  6891. BOOL SetHandleFlag(HANDLE hObject, DWORD dwFlag, BOOL fSet);
  6892. BOOL CheckHandleFlag(PEPROCESS Process, DWORD dwSessionId, HANDLE hObject, DWORD dwFlag);
  6893. VOID SetHandleInUse(HANDLE hObject);
  6894. BOOL CheckHandleInUse(HANDLE hObject);
  6895. __inline NTSTATUS CloseProtectedHandle(
  6896. HANDLE handle)
  6897. {
  6898. if (handle != NULL) {
  6899. SetHandleFlag(handle, HF_PROTECTED, FALSE);
  6900. return ZwClose(handle);
  6901. }
  6902. return STATUS_SUCCESS;
  6903. }
  6904. __inline VOID EnterHandleFlagsCrit(
  6905. VOID)
  6906. {
  6907. KeEnterCriticalRegion();
  6908. ExAcquireFastMutexUnsafe(gpHandleFlagsMutex);
  6909. }
  6910. __inline VOID LeaveHandleFlagsCrit(
  6911. VOID)
  6912. {
  6913. ExReleaseFastMutexUnsafe(gpHandleFlagsMutex);
  6914. KeLeaveCriticalRegion();
  6915. }
  6916. // multimon apis
  6917. BOOL xxxEnumDisplayMonitors(
  6918. HDC hdc,
  6919. LPRECT lprcClip,
  6920. MONITORENUMPROC lpfnEnum,
  6921. LPARAM dwData,
  6922. BOOL fInternal);
  6923. BOOL xxxClientMonitorEnumProc(
  6924. HMONITOR hMonitor,
  6925. HDC hdcMonitor,
  6926. LPRECT lprc,
  6927. LPARAM dwData,
  6928. MONITORENUMPROC xpfnProc);
  6929. VOID ClipPointToDesktop(LPPOINT lppt);
  6930. VOID DestroyMonitor(PMONITOR pMonitor);
  6931. BOOL GetHDevName(HMONITOR hMon, PWCHAR pName);
  6932. ULONG HdevFromMonitor(PMONITOR pMonitor);
  6933. /*
  6934. * The global to assure the atomicness of
  6935. * the monitor update.
  6936. */
  6937. extern DWORD gdwMonitorBusy;
  6938. /*
  6939. * Rebasing functions for shared memory.
  6940. */
  6941. #define REBASESHAREDPTR(p) (p)
  6942. #define REBASESHAREDPTRALWAYS(p) (p)
  6943. #define PDEV_ENABLED() \
  6944. InterlockedExchange((LPLONG)&gbMDEVDisabled, FALSE);
  6945. #define PDEV_DISABLED() \
  6946. InterlockedExchange((LPLONG)&gbMDEVDisabled, TRUE);
  6947. __inline BOOL SafeEnableMDEV(
  6948. VOID)
  6949. {
  6950. if (gbMDEVDisabled) {
  6951. if (DrvEnableMDEV(gpDispInfo->pmdev, TRUE)) {
  6952. PDEV_ENABLED();
  6953. return TRUE;
  6954. } else {
  6955. return FALSE;
  6956. }
  6957. } else {
  6958. RIPMSGF0(RIP_WARNING, "Trying to enable an enabled MDEV");
  6959. return TRUE;
  6960. }
  6961. }
  6962. __inline BOOL SafeDisableMDEV(
  6963. VOID)
  6964. {
  6965. if (!gbMDEVDisabled) {
  6966. if (DrvDisableMDEV(gpDispInfo->pmdev, TRUE)) {
  6967. PDEV_DISABLED();
  6968. return TRUE;
  6969. } else {
  6970. return FALSE;
  6971. }
  6972. } else {
  6973. RIPMSGF0(RIP_WARNING, "Trying to disable a disabled MDEV");
  6974. return TRUE;
  6975. }
  6976. }
  6977. /*
  6978. * Multimonitor macros used in RTL. There are similar definitions
  6979. * in client\usercli.h
  6980. */
  6981. __inline PDISPLAYINFO
  6982. GetDispInfo(
  6983. VOID)
  6984. {
  6985. return gpDispInfo;
  6986. }
  6987. __inline PMONITOR
  6988. GetPrimaryMonitor(
  6989. VOID)
  6990. {
  6991. return REBASESHAREDPTRALWAYS(GetDispInfo()->pMonitorPrimary);
  6992. }
  6993. VOID _QueryUserHandles(
  6994. IN LPDWORD lpIn,
  6995. IN DWORD dwInLength,
  6996. OUT DWORD pdwResult[][TYPE_CTYPES]);
  6997. #define REMOVE_FROM_LIST(type, pstart, pitem, next) \
  6998. { \
  6999. type** pp; \
  7000. \
  7001. for (pp = &pstart; *pp != NULL; pp = &(*pp)->next) { \
  7002. if (*pp == pitem) { \
  7003. *pp = pitem->next; \
  7004. break; \
  7005. } \
  7006. } \
  7007. } \
  7008. #define HH_DRIVERENTRY 0x00000001
  7009. #define HH_USERINITIALIZE 0x00000002
  7010. #define HH_INITVIDEO 0x00000004
  7011. #define HH_REMOTECONNECT 0x00000008
  7012. #define HH_REMOTEDISCONNECT 0x00000010
  7013. #define HH_REMOTERECONNECT 0x00000020
  7014. #define HH_REMOTELOGOFF 0x00000040
  7015. #define HH_DRIVERUNLOAD 0x00000080
  7016. #define HH_GRECLEANUP 0x00000100
  7017. #define HH_USERKCLEANUP 0x00000200
  7018. #define HH_INITIATEWIN32KCLEANUP 0x00000400
  7019. #define HH_ALLDTGONE 0x00000800
  7020. #define HH_RITGONE 0x00001000
  7021. #define HH_RITCREATED 0x00002000
  7022. #define HH_LOADCURSORS 0x00004000
  7023. #define HH_KBDLYOUTGLOBALCLEANUP 0x00008000
  7024. #define HH_KBDLYOUTFREEWINSTA 0x00010000
  7025. #define HH_CLEANUPRESOURCES 0x00020000
  7026. #define HH_DISCONNECTDESKTOP 0x00040000
  7027. #define HH_DTQUITPOSTED 0x00080000
  7028. #define HH_DTQUITRECEIVED 0x00100000
  7029. #define HH_DTWAITONHANDLES 0x00400000
  7030. #define HYDRA_HINT(ev) (gdwHydraHint |= ev)
  7031. #if DBG
  7032. VOID TrackAddDesktop(PVOID pDesktop);
  7033. VOID TrackRemoveDesktop(PVOID pDesktop);
  7034. VOID DumpTrackedDesktops(BOOL bBreak);
  7035. #define DbgTrackAddDesktop(pdesk) TrackAddDesktop(pdesk)
  7036. #define DbgTrackRemoveDesktop(pdesk) TrackRemoveDesktop(pdesk)
  7037. #define DbgDumpTrackedDesktops(b) DumpTrackedDesktops(b)
  7038. #else
  7039. #define DbgTrackAddDesktop(pdesk)
  7040. #define DbgTrackRemoveDesktop(pdesk)
  7041. #define DbgDumpTrackedDesktops(b)
  7042. #endif
  7043. #if DBG
  7044. #define TRACE_HYDAPI(m) \
  7045. if (gbTraceHydraApi) { \
  7046. KdPrint(("HYD-%d API: ", gSessionId)); \
  7047. KdPrint(m); \
  7048. }
  7049. #else
  7050. #define TRACE_HYDAPI(m)
  7051. #endif
  7052. #if DBG
  7053. #define TRACE_DESKTOP(m) \
  7054. if (gbTraceDesktop) { \
  7055. KdPrint(("HYD-%d DT ", gSessionId)); \
  7056. KdPrint(m); \
  7057. }
  7058. #else
  7059. #define TRACE_DESKTOP(m)
  7060. #endif
  7061. NTSTATUS
  7062. RemoteConnect(
  7063. IN PDOCONNECTDATA pDoConnectData,
  7064. IN ULONG DisplayDriverNameLength,
  7065. IN PWCHAR DisplayDriverName);
  7066. NTSTATUS
  7067. xxxRemoteDisconnect(
  7068. VOID);
  7069. NTSTATUS
  7070. xxxRemoteConsoleShadowStop(
  7071. VOID);
  7072. NTSTATUS
  7073. xxxRemoteReconnect(
  7074. IN PDORECONNECTDATA pDoReconnectData);
  7075. NTSTATUS
  7076. xxxRemoteNotify(
  7077. IN PDONOTIFYDATA pDoNotifyData);
  7078. NTSTATUS
  7079. RemoteLogoff(
  7080. VOID);
  7081. BOOL
  7082. PrepareForLogoff(
  7083. UINT uFlags);
  7084. NTSTATUS
  7085. xxxRemoteStopScreenUpdates(
  7086. VOID);
  7087. VOID xxxPushKeyEvent(
  7088. BYTE bVk,
  7089. BYTE bScan,
  7090. DWORD dwFlags,
  7091. DWORD dwExtraInfo);
  7092. NTSTATUS
  7093. RemoteThinwireStats(
  7094. OUT PVOID Stats);
  7095. NTSTATUS
  7096. RemoteNtSecurity(
  7097. VOID);
  7098. NTSTATUS
  7099. xxxRemoteShadowSetup(
  7100. VOID);
  7101. NTSTATUS
  7102. RemoteShadowStart(
  7103. IN PVOID pThinwireData,
  7104. ULONG ThinwireDataLength);
  7105. NTSTATUS
  7106. xxxRemoteShadowStop(
  7107. VOID);
  7108. NTSTATUS
  7109. RemoteShadowCleanup(
  7110. IN PVOID pThinwireData,
  7111. ULONG ThinwireDataLength);
  7112. NTSTATUS
  7113. xxxRemotePassthruEnable(
  7114. VOID);
  7115. NTSTATUS
  7116. RemotePassthruDisable(
  7117. VOID);
  7118. NTSTATUS
  7119. CtxDisplayIOCtl(
  7120. ULONG DisplayIOCtlFlags,
  7121. PUCHAR pDisplayIOCtlData,
  7122. ULONG cbDisplayIOCtlData);
  7123. DWORD
  7124. RemoteConnectState(
  7125. VOID);
  7126. BOOL
  7127. _GetWinStationInfo(
  7128. WSINFO* pWsInfo);
  7129. // from fullscr.c
  7130. NTSTATUS
  7131. RemoteRedrawRectangle(
  7132. WORD Left,
  7133. WORD Top,
  7134. WORD Right,
  7135. WORD Bottom);
  7136. NTSTATUS
  7137. RemoteRedrawScreen(
  7138. VOID);
  7139. NTSTATUS
  7140. RemoteDisableScreen(
  7141. VOID);
  7142. // from fekbd.c
  7143. VOID
  7144. NlsKbdSendIMEProc(
  7145. DWORD dwImeOpen,
  7146. DWORD dwImeConversion);
  7147. /*
  7148. * Additional menu functions (dependant on previous inline functions)
  7149. */
  7150. __inline BOOL MNIsFlatMenu(
  7151. VOID)
  7152. {
  7153. return TestEffectUP(FLATMENU);
  7154. }
  7155. VOID SetMouseTrails(UINT n);
  7156. VOID HideMouseTrails(PWND pwnd, UINT message, UINT_PTR nID, LPARAM lParam);
  7157. #if DBG
  7158. #define CheckPublicDC(lpszStr, hdc) \
  7159. { \
  7160. if (GreGetObjectOwner((HOBJ)hdc, DC_TYPE) == OBJECT_OWNER_PUBLIC) { \
  7161. RIPMSG1(RIP_ERROR, lpszStr, hdc); \
  7162. } \
  7163. }
  7164. #else
  7165. #define CheckPublicDC(lpszStr, hdc)
  7166. #endif
  7167. #define szMESSAGE L"Message"
  7168. #ifdef LAME_BUTTON
  7169. /*
  7170. * Lame button constants -- HKCU\Control Panel\Desktop\LameButtonEnabled.
  7171. */
  7172. #define LBUTTON_DIALOG 0x4
  7173. #define LBUTTON_TOPLEVEL 0x8
  7174. __inline BOOL NeedsLameButton(
  7175. PWND pwnd,
  7176. PWND pwndParent)
  7177. {
  7178. /*
  7179. * Windows with the WS_EX_TOOLWINDOW style can't have a lame button (see
  7180. * Windows Bug #237648), nor can consoles.
  7181. */
  7182. if (TestWF(pwnd, WEFTOOLWINDOW) || PsGetCurrentProcess() == gpepCSRSS) {
  7183. return FALSE;
  7184. } else if (pwndParent != NULL && GETFNID(pwndParent) == FNID_DESKTOP) {
  7185. return (gdwLameFlags & LBUTTON_TOPLEVEL) != 0;
  7186. } else if (GETFNID(pwnd) == FNID_DIALOG) {
  7187. return (gdwLameFlags & LBUTTON_DIALOG) != 0;
  7188. } else {
  7189. return FALSE;
  7190. }
  7191. }
  7192. #endif // LAME_BUTTON
  7193. #ifdef TRACK_PNP_NOTIFICATION
  7194. typedef enum tagPNP_NOTIFICATION_TYPE {
  7195. PNP_NTF_CLASSNOTIFY,
  7196. PNP_NTF_CREATEDEVICEINFO,
  7197. PNP_NTF_FREEDEVICEINFO,
  7198. PNP_NTF_PROCESSDEVICECHANGES,
  7199. PNP_NTF_REQUESTDEVICECHANGE,
  7200. PNP_NTF_DEVICENOTIFY,
  7201. PNP_NTF_FREEDEVICEINFO_DEFERRED,
  7202. PNP_NTF_CLOSEDEVICE,
  7203. PNP_NTF_DEVICENOTIFY_UNLISTED,
  7204. PNP_NTF_UNREGISTER_NOTIFICATION,
  7205. PNP_NTF_UNREGISTER_REMOTE_CANCELLED,
  7206. } PNP_NOTIFICATION_TYPE;
  7207. typedef struct tagPNP_NOTIFICATION_RECORD {
  7208. UINT iSeq;
  7209. PNP_NOTIFICATION_TYPE type;
  7210. PVOID pKThread;
  7211. PDEVICEINFO pDeviceInfo;
  7212. HANDLE hDeviceInfo;
  7213. UCHAR szPathName[80];
  7214. ULONG_PTR NotificationCode;
  7215. PVOID trace[LOCKRECORD_STACK];
  7216. } PNP_NOTIFICATION_RECORD, *PPNP_NOTIFICATION_RECORD;
  7217. VOID CleanupPnpNotificationRecord(
  7218. VOID);
  7219. VOID RecordPnpNotification(
  7220. PNP_NOTIFICATION_TYPE type,
  7221. PDEVICEINFO pDeviceInfo,
  7222. ULONG_PTR NotificationCode);
  7223. extern BOOL gfRecordPnpNotification;
  7224. #endif // TRACK_PNP_NOTIFICATION
  7225. #ifdef SUBPIXEL_MOUSE
  7226. VOID BuildMouseAccelerationCurve(
  7227. PMONITOR pMonitor);
  7228. VOID DoNewMouseAccel(
  7229. INT *dx,
  7230. INT *dw);
  7231. VOID ReadDefaultAccelerationCurves(
  7232. PUNICODE_STRING pProfileUserName);
  7233. VOID ResetMouseAccelerationCurves(
  7234. VOID);
  7235. #endif // SUBPIXEL_MOUSE
  7236. #ifdef AUTORUN_CURSOR
  7237. VOID ShowAutorunCursor(
  7238. ULONG ulTimeout);
  7239. VOID HideAutorunCursor(
  7240. PWND pwnd,
  7241. UINT message,
  7242. UINT_PTR nID,
  7243. LPARAM lParam);
  7244. #endif // AUTORUN_CURSOR
  7245. /*
  7246. * These must go after globals.h is #include'd, as they're inline functions and
  7247. * they use gptiCurrent (indirectly, by way of ThreadLock()).
  7248. */
  7249. __inline VOID ThreadLockMenuNoModify(
  7250. PMENU pMenu,
  7251. PTL ptl)
  7252. {
  7253. UserAssert(!TestMF(pMenu, MFREADONLY));
  7254. SetMF(pMenu, MFREADONLY);
  7255. ThreadLock(pMenu, ptl);
  7256. }
  7257. __inline VOID ThreadLockMenuAlwaysNoModify(
  7258. PMENU pMenu,
  7259. PTL ptl)
  7260. {
  7261. UserAssert(!TestMF(pMenu, MFREADONLY));
  7262. SetMF(pMenu, MFREADONLY);
  7263. ThreadLockAlways(pMenu, ptl);
  7264. }
  7265. __inline VOID ThreadUnlockMenuNoModify(
  7266. PTL ptl)
  7267. {
  7268. UserAssert(TestMF((PMENU)ptl->pobj, MFREADONLY));
  7269. ClearMF((PMENU)ptl->pobj, MFREADONLY);
  7270. ThreadUnlock(ptl);
  7271. }
  7272. __inline int
  7273. SetBestStretchMode(
  7274. HDC hdc,
  7275. UINT bpp,
  7276. BOOL fHT)
  7277. {
  7278. return GreSetStretchBltMode(
  7279. hdc,
  7280. ((fHT) ?
  7281. HALFTONE : ((bpp == 1) ? BLACKONWHITE : COLORONCOLOR)));
  7282. }
  7283. #endif