DWORD dwShowMode = SW_SHOW;
CREATESTRUCTW *pCsw = NULL;
PVOID pszClass = NULL, pszName = NULL;
- DECLARE_RETURN(PWND);
+ PWND ret = NULL;
/* Get the current window station and reference it */
pti = GetW32ThreadInfo();
if(!Class)
{
DPRINT1("Failed to find class %wZ\n", ClassName);
- RETURN(NULL);
+ goto cleanup;
}
/* Now find the parent and the owner window */
{
DPRINT1("Cannot create a child window without a parrent!\n");
EngSetLastError(ERROR_TLW_WITH_WSCHILD);
- RETURN(NULL); /* WS_CHILD needs a parent, but WS_POPUP doesn't */
+ goto cleanup; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
}
ParentWindow = hWndParent ? UserGetWindowObject(hWndParent): NULL;
if(!Window)
{
DPRINT1("IntCreateWindow failed!\n");
- RETURN(0);
+ goto cleanup;
}
hWnd = UserHMGetHandle(Window);
// Allocate the calling structures Justin Case this goes Global.
pCsw = ExAllocatePoolWithTag(NonPagedPool, sizeof(CREATESTRUCTW), TAG_HOOK);
pCbtCreate = ExAllocatePoolWithTag(NonPagedPool, sizeof(CBT_CREATEWNDW), TAG_HOOK);
+ if (!pCsw || !pCbtCreate)
+ {
+ DPRINT1("UserHeapAlloc() failed!\n");
+ goto cleanup;
+ }
/* Fill the new CREATESTRUCTW */
RtlCopyMemory(pCsw, Cs, sizeof(CREATESTRUCTW));
ANSI_STRING AnsiString;
AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(ClassName)+sizeof(CHAR);
pszClass = UserHeapAlloc(AnsiString.MaximumLength);
+ if (!pszClass)
+ {
+ DPRINT1("UserHeapAlloc() failed!\n");
+ goto cleanup;
+ }
RtlZeroMemory(pszClass, AnsiString.MaximumLength);
AnsiString.Buffer = (PCHAR)pszClass;
RtlUnicodeStringToAnsiString(&AnsiString, ClassName, FALSE);
UNICODE_STRING UnicodeString;
UnicodeString.MaximumLength = ClassName->Length + sizeof(UNICODE_NULL);
pszClass = UserHeapAlloc(UnicodeString.MaximumLength);
+ if (!pszClass)
+ {
+ DPRINT1("UserHeapAlloc() failed!\n");
+ goto cleanup;
+ }
RtlZeroMemory(pszClass, UnicodeString.MaximumLength);
UnicodeString.Buffer = (PWSTR)pszClass;
RtlCopyUnicodeString(&UnicodeString, ClassName);
}
- if (pszClass) pCsw->lpszClass = UserHeapAddressToUser(pszClass);
+ pCsw->lpszClass = UserHeapAddressToUser(pszClass);
}
if (WindowName->Length)
{
if (Window->state & WNDS_ANSICREATOR)
{
ANSI_STRING AnsiString;
- AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(&Name)+sizeof(CHAR);
+ AnsiString.MaximumLength = RtlUnicodeStringToAnsiSize(&Name) + sizeof(CHAR);
pszName = UserHeapAlloc(AnsiString.MaximumLength);
+ if (!pszName)
+ {
+ DPRINT1("UserHeapAlloc() failed!\n");
+ goto cleanup;
+ }
RtlZeroMemory(pszName, AnsiString.MaximumLength);
AnsiString.Buffer = (PCHAR)pszName;
RtlUnicodeStringToAnsiString(&AnsiString, &Name, FALSE);
UNICODE_STRING UnicodeString;
UnicodeString.MaximumLength = Name.Length + sizeof(UNICODE_NULL);
pszName = UserHeapAlloc(UnicodeString.MaximumLength);
+ if (!pszName)
+ {
+ DPRINT1("UserHeapAlloc() failed!\n");
+ goto cleanup;
+ }
RtlZeroMemory(pszName, UnicodeString.MaximumLength);
UnicodeString.Buffer = (PWSTR)pszName;
RtlCopyUnicodeString(&UnicodeString, &Name);
}
- if (pszName) pCsw->lpszName = UserHeapAddressToUser(pszName);
+ pCsw->lpszName = UserHeapAddressToUser(pszName);
}
pCbtCreate->lpcs = pCsw;
if (Result != 0)
{
DPRINT1("WH_CBT HCBT_CREATEWND hook failed! 0x%x\n", Result);
- RETURN( (PWND) NULL);
+ goto cleanup;
}
// Write back changes.
Cs->cx = pCsw->cx;
if (!Result)
{
DPRINT1("co_UserCreateWindowEx(): NCCREATE message failed\n");
- RETURN((PWND)0);
+ goto cleanup;
}
/* Send the WM_NCCALCSIZE message */
if (Result == (LRESULT)-1)
{
DPRINT1("co_UserCreateWindowEx(): WM_CREATE message failed\n");
- RETURN((PWND)0);
+ goto cleanup;
}
/* Send the EVENT_OBJECT_CREATE event*/
}
DPRINT("co_UserCreateWindowEx(): Created window %X\n", hWnd);
- RETURN( Window);
+ ret = Window;
-CLEANUP:
- if (!_ret_)
+cleanup:
+ if (!ret)
{
DPRINT("co_UserCreateWindowEx(): Error Created window!\n");
/* If the window was created, the class will be dereferenced by co_UserDestroyWindow */
UserDereferenceObject(Window);
}
if (ParentWindow) UserDerefObjectCo(ParentWindow);
-
- END_CLEANUP;
+
+ return ret;
}
NTSTATUS