ReactOS 0.4.16-dev-329-g9223134
ghost.c File Reference
#include <win32k.h>
#include "ghostwnd.h"
#include <debug.h>
Include dependency graph for ghost.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 DBG_DEFAULT_CHANNEL (UserInput)
 
VOID NTAPI UserGhostThreadEntry (VOID)
 
BOOL FASTCALL IntIsGhostWindow (PWND Window)
 
HWND FASTCALL IntGhostWindowFromHungWindow (PWND pHungWnd)
 
HWND FASTCALL UserGhostWindowFromHungWindow (HWND hwndHung)
 
HWND FASTCALL IntHungWindowFromGhostWindow (PWND pGhostWnd)
 
HWND FASTCALL UserHungWindowFromGhostWindow (HWND hwndGhost)
 
BOOL FASTCALL IntMakeHungWindowGhosted (HWND hwndHung)
 

Variables

static UNICODE_STRING GhostClass = RTL_CONSTANT_STRING(GHOSTCLASSNAME)
 
static UNICODE_STRING GhostProp = RTL_CONSTANT_STRING(GHOST_PROP)
 
PTHREADINFO gptiGhostThread = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file ghost.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserInput  )

◆ IntGhostWindowFromHungWindow()

HWND FASTCALL IntGhostWindowFromHungWindow ( PWND  pHungWnd)

Definition at line 76 of file ghost.c.

77{
79 HWND hwndGhost;
80
81 if (!IntGetAtomFromStringOrAtom(&GhostProp, &Atom))
82 return NULL;
83
84 hwndGhost = UserGetProp(pHungWnd, Atom, TRUE);
85 if (hwndGhost)
86 {
87 if (ValidateHwndNoErr(hwndGhost))
88 return hwndGhost;
89
90 DPRINT("Not a window\n");
91 }
92
93 return NULL;
94}
_Out_ RTL_ATOM * Atom
Definition: class.h:54
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ValidateHwndNoErr(hwnd)
Definition: precomp.h:84
unsigned short RTL_ATOM
Definition: atom.c:42
static UNICODE_STRING GhostProp
Definition: ghost.c:17
#define DPRINT
Definition: sndvol32.h:73
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46

Referenced by IntMakeHungWindowGhosted(), and UserGhostWindowFromHungWindow().

◆ IntHungWindowFromGhostWindow()

HWND FASTCALL IntHungWindowFromGhostWindow ( PWND  pGhostWnd)

Definition at line 107 of file ghost.c.

108{
109 const GHOST_DATA *UserData;
110 HWND hwndTarget;
111
112 if (!IntIsGhostWindow(pGhostWnd))
113 {
114 DPRINT("Not a ghost window\n");
115 return NULL;
116 }
117
118 UserData = (const GHOST_DATA *)pGhostWnd->dwUserData;
119 if (UserData)
120 {
122 {
123 ProbeForRead(UserData, sizeof(GHOST_DATA), 1);
124 hwndTarget = UserData->hwndTarget;
125 }
127 {
128 DPRINT1("Exception!\n");
129 hwndTarget = NULL;
130 }
131 _SEH2_END;
132 }
133 else
134 {
135 DPRINT("No user data\n");
136 hwndTarget = NULL;
137 }
138
139 if (hwndTarget)
140 {
141 if (ValidateHwndNoErr(hwndTarget))
142 return hwndTarget;
143
144 DPRINT1("Not a window\n");
145 }
146
147 return NULL;
148}
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
if(dx< 0)
Definition: linetemp.h:194
struct tagUserData UserData
BOOL FASTCALL IntIsGhostWindow(PWND Window)
Definition: ghost.c:42
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
LONG_PTR dwUserData
Definition: ntuser.h:741

Referenced by UserHungWindowFromGhostWindow().

◆ IntIsGhostWindow()

BOOL FASTCALL IntIsGhostWindow ( PWND  Window)

Definition at line 42 of file ghost.c.

43{
44 BOOLEAN Ret = FALSE;
45 UNICODE_STRING ClassName;
46 INT iCls, Len;
47 RTL_ATOM Atom = 0;
48
49 if (!Window)
50 return FALSE;
51
52 if (Window->fnid && !(Window->fnid & FNID_DESTROY))
53 {
54 if (LookupFnIdToiCls(Window->fnid, &iCls))
55 {
56 Atom = gpsi->atomSysClass[iCls];
57 }
58 }
59
60 // check class name
61 RtlInitUnicodeString(&ClassName, NULL);
62 Len = UserGetClassName(Window->pcls, &ClassName, Atom, FALSE);
63 if (Len > 0)
64 {
65 Ret = RtlEqualUnicodeString(&ClassName, &GhostClass, TRUE);
66 }
67 else
68 {
69 DPRINT1("Unable to get class name\n");
70 }
71 RtlFreeUnicodeString(&ClassName);
72
73 return Ret;
74}
unsigned char BOOLEAN
#define Len
Definition: deflate.h:82
#define FALSE
Definition: types.h:117
PSERVERINFO gpsi
Definition: imm.c:18
#define FNID_DESTROY
Definition: ntuser.h:898
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static UNICODE_STRING GhostClass
Definition: ghost.c:16
Definition: window.c:28
ATOM atomSysClass[ICLS_NOTUSED+1]
Definition: ntuser.h:1060
int32_t INT
Definition: typedefs.h:58
INT UserGetClassName(IN PCLS Class, IN OUT PUNICODE_STRING ClassName, IN RTL_ATOM Atom, IN BOOL Ansi)
Definition: class.c:1647
BOOL FASTCALL LookupFnIdToiCls(int FnId, int *iCls)
Definition: class.c:133

Referenced by IntHungWindowFromGhostWindow(), and IntMakeHungWindowGhosted().

◆ IntMakeHungWindowGhosted()

BOOL FASTCALL IntMakeHungWindowGhosted ( HWND  hwndHung)

Definition at line 156 of file ghost.c.

157{
158 PWND pHungWnd = ValidateHwndNoErr(hwndHung);
159 if (!pHungWnd)
160 {
161 DPRINT1("Not a window\n");
162 return FALSE; // not a window
163 }
164
165 if (!MsqIsHung(pHungWnd->head.pti, MSQ_HUNG))
166 {
167 DPRINT1("Not hung window\n");
168 return FALSE; // not hung window
169 }
170
171 if (!(pHungWnd->style & WS_VISIBLE))
172 return FALSE; // invisible
173
174 if (pHungWnd->style & WS_CHILD)
175 return FALSE; // child
176
177 if (IntIsGhostWindow(pHungWnd))
178 {
179 DPRINT1("IntIsGhostWindow\n");
180 return FALSE; // ghost window cannot be ghosted
181 }
182
183 if (IntGhostWindowFromHungWindow(pHungWnd))
184 {
185 DPRINT("Already ghosting\n");
186 return FALSE; // already ghosting
187 }
188
189 // TODO: Find a way to pass the hwnd of pHungWnd to the ghost thread as we can't pass parameters directly
190
191 if (!gptiGhostThread)
193
194 return TRUE;
195}
BOOL UserCreateSystemThread(DWORD Type)
Definition: csr.c:247
BOOL FASTCALL MsqIsHung(PTHREADINFO pti, DWORD TimeOut)
Definition: msgqueue.c:2143
#define MSQ_HUNG
Definition: msgqueue.h:3
HWND FASTCALL IntGhostWindowFromHungWindow(PWND pHungWnd)
Definition: ghost.c:76
PTHREADINFO gptiGhostThread
Definition: ghost.c:19
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
Definition: ntuser.h:694
THRDESKHEAD head
Definition: ntuser.h:695
DWORD style
Definition: ntuser.h:706
#define ST_GHOST_THREAD
Definition: csr.h:37

Referenced by co_IntSendMessageTimeoutSingle().

◆ UserGhostThreadEntry()

VOID NTAPI UserGhostThreadEntry ( VOID  )

Definition at line 27 of file ghost.c.

28{
29 TRACE("Ghost thread started\n");
30
32
34
35 //TODO: Implement. This thread should handle all ghost windows and exit when no ghost window is needed.
36
38
39 UserLeave();
40}
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by UserSystemThreadProc().

◆ UserGhostWindowFromHungWindow()

HWND FASTCALL UserGhostWindowFromHungWindow ( HWND  hwndHung)

Definition at line 96 of file ghost.c.

97{
98 PWND pHungWnd = ValidateHwndNoErr(hwndHung);
99 if (!pHungWnd)
100 {
101 DPRINT("Not a window\n");
102 return NULL;
103 }
104 return IntGhostWindowFromHungWindow(pHungWnd);
105}

◆ UserHungWindowFromGhostWindow()

HWND FASTCALL UserHungWindowFromGhostWindow ( HWND  hwndGhost)

Definition at line 150 of file ghost.c.

151{
152 PWND pGhostWnd = ValidateHwndNoErr(hwndGhost);
153 return IntHungWindowFromGhostWindow(pGhostWnd);
154}
HWND FASTCALL IntHungWindowFromGhostWindow(PWND pGhostWnd)
Definition: ghost.c:107

Variable Documentation

◆ GhostClass

Definition at line 16 of file ghost.c.

Referenced by IntIsGhostWindow().

◆ GhostProp

Definition at line 17 of file ghost.c.

Referenced by IntGhostWindowFromHungWindow().

◆ gptiGhostThread

PTHREADINFO gptiGhostThread = NULL

Definition at line 19 of file ghost.c.

Referenced by IntMakeHungWindowGhosted(), and UserGhostThreadEntry().