- Child = UserGetWindowObject(*ChildHandle);
- if (Child == NULL)
- continue;
- if (Child->spwndOwner != Window)
- {
- continue;
- }
-
- if (IntWndBelongsToThread(Child, PsGetCurrentThreadWin32Thread()))
- {
- USER_REFERENCE_ENTRY ChildRef;
- UserRefObjectCo(Child, &ChildRef); // Temp HACK?
- co_UserDestroyWindow(Child);
- UserDerefObjectCo(Child); // Temp HACK?
-
- GotOne = TRUE;
- continue;
- }
-
- if (Child->spwndOwner != NULL)
- {
- Child->spwndOwner = NULL;
- }
-
+ pWnd = ValidateHwndNoErr(*phWnd);
+ if (pWnd == NULL)
+ continue;
+ ASSERT(pWnd->spwndOwner == Window);
+ ASSERT(pWnd != Window);
+
+ pWnd->spwndOwner = NULL;
+ if (IntWndBelongsToThread(pWnd, PsGetCurrentThreadWin32Thread()))
+ {
+ USER_REFERENCE_ENTRY Ref;
+ UserRefObjectCo(pWnd, &Ref); // Temp HACK?
+ co_UserDestroyWindow(pWnd);
+ UserDerefObjectCo(pWnd); // Temp HACK?
+ }
+ else
+ {
+ ERR("IntWndBelongsToThread(0x%p) is FALSE, ignoring.\n", pWnd);
+ }