ReactOS  0.4.14-dev-55-g2da92ac
misc.c File Reference
#include <user32.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Functions

VOID WINAPI UserSetLastError (IN DWORD dwErrCode)
 
VOID WINAPI UserSetLastNTError (IN NTSTATUS Status)
 
PTHREADINFO GetW32ThreadInfo (VOID)
 
BOOL WINAPI GetUserObjectSecurity (IN HANDLE hObject, IN PSECURITY_INFORMATION pSecurityInfo, OUT PSECURITY_DESCRIPTOR pSecurityDescriptor, IN DWORD dwLength, OUT PDWORD pdwLengthNeeded)
 
BOOL WINAPI SetUserObjectSecurity (IN HANDLE hObject, IN PSECURITY_INFORMATION pSecurityInfo, IN PSECURITY_DESCRIPTOR pSecurityDescriptor)
 
BOOL WINAPI IsGUIThread (BOOL bConvert)
 
BOOL FASTCALL TestWindowProcess (PWND Wnd)
 
BOOL FASTCALL TestState (PWND pWnd, UINT Flag)
 
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle (HANDLE handle)
 
PVOID FASTCALL ValidateHandle (HANDLE handle, UINT uType)
 
PVOID FASTCALL ValidateHandleNoErr (HANDLE handle, UINT uType)
 
PCALLPROCDATA FASTCALL ValidateCallProc (HANDLE hCallProc)
 
PWND FASTCALL ValidateHwnd (HWND hwnd)
 
PWND FASTCALL ValidateHwndNoErr (HWND hwnd)
 
PWND FASTCALL GetThreadDesktopWnd (VOID)
 
PWND FASTCALL ValidateHwndOrDesk (HWND hwnd)
 
DWORD WINAPI WCSToMBEx (WORD CodePage, LPWSTR UnicodeString, LONG UnicodeSize, LPSTR *MBString, LONG MBSize, BOOL Allocate)
 
DWORD WINAPI MBToWCSEx (WORD CodePage, LPSTR MBString, LONG MBSize, LPWSTR *UnicodeString, LONG UnicodeSize, BOOL Allocate)
 

Variables

static const BOOL g_ObjectHeapTypeShared [TYPE_CTYPES]
 

Function Documentation

◆ GetThreadDesktopWnd()

PWND FASTCALL GetThreadDesktopWnd ( VOID  )

Definition at line 407 of file misc.c.

408 {
410  if (Wnd != NULL)
411  Wnd = DesktopPtrToUser(Wnd);
412  return Wnd;
413 }
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
smooth NULL
Definition: ftsmooth.c:416
struct _WND * spwnd
Definition: ntuser.h:136
Definition: ntuser.h:657
static __inline PDESKTOPINFO GetThreadDesktopInfo(VOID)
Definition: user_x.h:43

Referenced by GetDesktopWindow(), IsChild(), and ValidateHwndOrDesk().

◆ GetUser32Handle()

PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle ( HANDLE  handle)

Definition at line 205 of file misc.c.

206 {
207  INT Index;
209 
210  if (!handle) return NULL;
211 
212  Index = (((UINT_PTR)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
213 
214  if (Index < 0 || Index >= gHandleTable->nb_handles)
215  return NULL;
216 
218  return NULL;
219 
220  generation = (UINT_PTR)handle >> 16;
221 
223  return &gHandleEntries[Index];
224 
225  return NULL;
226 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FIRST_USER_HANDLE
Definition: ntuser.h:13
int32_t INT
Definition: typedefs.h:56
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned short USHORT
Definition: pedump.c:61
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2882
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PUSER_HANDLE_ENTRY gHandleEntries
Definition: dllmain.c:31

Referenced by ValidateCallProc(), ValidateHandle(), and ValidateHandleNoErr().

◆ GetUserObjectSecurity()

BOOL WINAPI GetUserObjectSecurity ( IN HANDLE  hObject,
IN PSECURITY_INFORMATION  pSecurityInfo,
OUT PSECURITY_DESCRIPTOR  pSecurityDescriptor,
IN DWORD  dwLength,
OUT PDWORD  pdwLengthNeeded 
)

Definition at line 75 of file misc.c.

82 {
83 DWORD dwWin32Error;
85 
86 
88  hObject, // Object Handle
89  *pSecurityInfo, // Security Information
90  pSecurityDescriptor,// Security Descriptor
91  dwLength, // Buffer Length
92  pdwLengthNeeded // Actual Length
93  );
94 
95  if ( ! NT_SUCCESS( Status ) ) {
96  dwWin32Error = RtlNtStatusToDosError( Status );
97  NtCurrentTeb()->LastErrorValue = dwWin32Error;
98  return FALSE;
99  }
100 
101  return TRUE;
102 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtQuerySecurityObject(IN HANDLE Handle, IN SECURITY_INFORMATION SecurityInformation, OUT PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Length, OUT PULONG ResultLength)
Definition: obsecure.c:803
static DWORD DWORD * dwLength
Definition: fusion.c:83
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

◆ GetW32ThreadInfo()

PTHREADINFO GetW32ThreadInfo ( VOID  )

Definition at line 36 of file misc.c.

37 {
38  PTHREADINFO ti;
39 
40  ti = (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo;
41  if (ti == NULL)
42  {
43  /* create the THREADINFO structure */
45  ti = (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo;
46  }
47 
48  return ti;
49 }
smooth NULL
Definition: ftsmooth.c:416
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
DWORD_PTR APIENTRY NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by co_UserCreateWindowEx(), DceAllocDCE(), DesktopPtrToUser(), GetThreadDesktopInfo(), GetWindowThreadProcessId(), IntCallMessageProc(), IntCallWindowProcA(), IntCallWindowProcW(), IntCreateCurIconHandle(), IntCreateWindow(), IntSendNCPaint(), NtUserCallHwndOpt(), NtUserCallNextHookEx(), NtUserCallNoParam(), NtUserCallOneParam(), NtUserMessageCall(), NtUserSetShellWindowEx(), RawInputThreadMain(), SendMessageA(), SendMessageW(), UserCreateMenu(), UserGetDCEx(), and UserRegisterClass().

◆ IsGUIThread()

BOOL WINAPI IsGUIThread ( BOOL  bConvert)

Definition at line 155 of file misc.c.

157 {
158  PTHREADINFO ti = (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo;
159  if (ti == NULL)
160  {
161  if(bConvert)
162  {
164  if ((PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo) return TRUE;
165  else
167  }
168  return FALSE;
169  }
170  else
171  return TRUE;
172 }
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
smooth NULL
Definition: ftsmooth.c:416
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
#define SetLastError(x)
Definition: compat.h:409
DWORD_PTR APIENTRY NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by do_InitialDesktop_child().

◆ MBToWCSEx()

DWORD WINAPI MBToWCSEx ( WORD  CodePage,
LPSTR  MBString,
LONG  MBSize,
LPWSTR UnicodeString,
LONG  UnicodeSize,
BOOL  Allocate 
)

Definition at line 467 of file misc.c.

468 {
469  DWORD Size;
470  if (MBSize == -1)
471  {
472  MBSize = strlen(MBString)+1;
473  }
474  if (UnicodeSize == -1)
475  {
476  if (!Allocate)
477  {
478  return 0;
479  }
480  UnicodeSize = MBSize;
481  }
482  if (Allocate)
483  {
484  LPWSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize);
485  if (SafeString == NULL)
486  return 0;
487  *UnicodeString = SafeString;
488  }
489  UnicodeSize *= sizeof(WCHAR);
490  if (CodePage == 0)
491  {
492  RtlMultiByteToUnicodeN(*UnicodeString,UnicodeSize,&Size,MBString,MBSize);
493  }
494  else
495  {
496  Size = MultiByteToWideChar(CodePage,0,MBString,MBSize,*UnicodeString,UnicodeSize);
497  }
498  return Size;
499 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define MultiByteToWideChar
Definition: compat.h:100
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ SetUserObjectSecurity()

BOOL WINAPI SetUserObjectSecurity ( IN HANDLE  hObject,
IN PSECURITY_INFORMATION  pSecurityInfo,
IN PSECURITY_DESCRIPTOR  pSecurityDescriptor 
)

Definition at line 125 of file misc.c.

130 {
131 DWORD dwWin32Error;
133 
134 
136  hObject, // Object Handle
137  *pSecurityInfo, // Security Information
138  pSecurityDescriptor // Security Descriptor
139  );
140 
141  if ( ! NT_SUCCESS( Status ) ) {
142  dwWin32Error = RtlNtStatusToDosError( Status );
143  NtCurrentTeb()->LastErrorValue = dwWin32Error;
144  return FALSE;
145  }
146 
147  return TRUE;
148 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

◆ TestState()

BOOL FASTCALL TestState ( PWND  pWnd,
UINT  Flag 
)

Definition at line 187 of file misc.c.

188 {
189  UINT bit;
190  bit = 1 << LOWORD(Flag);
191  switch(HIWORD(Flag))
192  {
193  case 0:
194  return (pWnd->state & bit);
195  case 1:
196  return (pWnd->state2 & bit);
197  case 2:
198  return (pWnd->ExStyle2 & bit);
199  }
200  return FALSE;
201 }
DWORD ExStyle2
Definition: ntuser.h:709
Definition: xml2sdb.h:79
DWORD state
Definition: ntuser.h:665
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:246
DWORD state2
Definition: ntuser.h:666
#define LOWORD(l)
Definition: pedump.c:82

Referenced by NtUserxClearWindowState(), and NtUserxSetWindowState().

◆ TestWindowProcess()

BOOL FASTCALL TestWindowProcess ( PWND  Wnd)

Definition at line 176 of file misc.c.

177 {
178  if (Wnd->head.pti == (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo)
179  return TRUE;
180  else
183 }
#define TRUE
Definition: types.h:120
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2796
HANDLE UniqueProcess
Definition: compat.h:474
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3997
THRDESKHEAD head
Definition: ntuser.h:659
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
uint32_t DWORD_PTR
Definition: typedefs.h:63
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by DIALOG_FindMsgDestination(), GetWindowTextA(), GetWindowTextLengthA(), GetWindowTextLengthW(), GetWindowTextW(), IntGetWindowLong(), IsDialogMessageW(), SetWindowTextA(), and SetWindowTextW().

◆ UserSetLastError()

VOID WINAPI UserSetLastError ( IN DWORD  dwErrCode)

Definition at line 13 of file misc.c.

14 {
15  /*
16  * Equivalent of SetLastError in kernel32, but without breaking
17  * into the debugger nor checking whether the last old error is
18  * the same as the one we are going to set.
19  */
20  NtCurrentTeb()->LastErrorValue = dwErrCode;
21 }
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by EndTask(), ExitWindowsWorker(), and UserSetLastNTError().

◆ UserSetLastNTError()

VOID WINAPI UserSetLastNTError ( IN NTSTATUS  Status)

Definition at line 25 of file misc.c.

26 {
27  /*
28  * Equivalent of BaseSetLastNTError in kernel32, but using
29  * UserSetLastError: convert from NT to Win32, then set.
30  */
32 }
VOID WINAPI UserSetLastError(IN DWORD dwErrCode)
Definition: misc.c:13
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

Referenced by EndTask(), ExitWindowsWorker(), GetThreadDesktop(), RegisterLogonProcess(), and RegisterServicesProcess().

◆ ValidateCallProc()

PCALLPROCDATA FASTCALL ValidateCallProc ( HANDLE  hCallProc)

Definition at line 349 of file misc.c.

350 {
351  PUSER_HANDLE_ENTRY pEntry;
352 
353  PCALLPROCDATA CallProc = ValidateHandle(hCallProc, TYPE_CALLPROC);
354 
355  pEntry = GetUser32Handle(hCallProc);
356 
357  if (CallProc != NULL && pEntry->ppi == g_ppi)
358  return CallProc;
359 
360  return NULL;
361 }
struct _PROCESSINFO * ppi
Definition: ntuser.h:26
smooth NULL
Definition: ftsmooth.c:416
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:205
PPROCESSINFO g_ppi
Definition: dllmain.c:29
Definition: ntuser.h:19
PVOID FASTCALL ValidateHandle(HANDLE handle, UINT uType)
Definition: misc.c:262

Referenced by CallWindowProcA(), and CallWindowProcW().

◆ ValidateHandle()

PVOID FASTCALL ValidateHandle ( HANDLE  handle,
UINT  uType 
)

Definition at line 262 of file misc.c.

263 {
264  PVOID ret;
265  PUSER_HANDLE_ENTRY pEntry;
266 
267  ASSERT(uType < TYPE_CTYPES);
268 
269  pEntry = GetUser32Handle(handle);
270 
271  if (pEntry && uType == 0)
272  uType = pEntry->type;
273 
274 // Must have an entry and must be the same type!
275  if ( (!pEntry) ||
276  (pEntry->type != uType) ||
277  !pEntry->ptr ||
278  (pEntry->flags & HANDLEENTRY_DESTROY) || (pEntry->flags & HANDLEENTRY_INDESTROY) )
279  {
280  switch ( uType )
281  { // Test (with wine too) confirms these results!
282  case TYPE_WINDOW:
284  break;
285  case TYPE_MENU:
287  break;
288  case TYPE_CURSOR:
290  break;
291  case TYPE_SETWINDOWPOS:
293  break;
294  case TYPE_HOOK:
296  break;
297  case TYPE_ACCELTABLE:
299  break;
300  default:
302  break;
303  }
304  return NULL;
305  }
306 
307  if (g_ObjectHeapTypeShared[uType])
308  ret = SharedPtrToUser(pEntry->ptr);
309  else
310  ret = DesktopPtrToUser(pEntry->ptr);
311 
312  return ret;
313 }
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883
#define ERROR_INVALID_DWP_HANDLE
Definition: winerror.h:886
#define ERROR_INVALID_ACCEL_HANDLE
Definition: winerror.h:884
#define ERROR_INVALID_HOOK_HANDLE
Definition: winerror.h:885
unsigned char type
Definition: ntuser.h:28
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
smooth NULL
Definition: ftsmooth.c:416
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:205
Definition: ntuser.h:19
static const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
Definition: misc.c:231
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define SetLastError(x)
Definition: compat.h:409
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
#define HANDLEENTRY_DESTROY
Definition: ntuser.h:16
static __inline PVOID SharedPtrToUser(PVOID Ptr)
Definition: user_x.h:4
void * ptr
Definition: ntuser.h:21
#define HANDLEENTRY_INDESTROY
Definition: ntuser.h:17
unsigned char flags
Definition: ntuser.h:29

Referenced by ValidateCallProc(), and ValidateHwnd().

◆ ValidateHandleNoErr()

PVOID FASTCALL ValidateHandleNoErr ( HANDLE  handle,
UINT  uType 
)

Definition at line 320 of file misc.c.

321 {
322  PVOID ret;
323  PUSER_HANDLE_ENTRY pEntry;
324 
325  ASSERT(uType < TYPE_CTYPES);
326 
327  pEntry = GetUser32Handle(handle);
328 
329  if (pEntry && uType == 0)
330  uType = pEntry->type;
331 
332 // Must have an entry and must be the same type!
333  if ( (!pEntry) || (pEntry->type != uType) || !pEntry->ptr )
334  return NULL;
335 
336  if (g_ObjectHeapTypeShared[uType])
337  ret = SharedPtrToUser(pEntry->ptr);
338  else
339  ret = DesktopPtrToUser(pEntry->ptr);
340 
341  return ret;
342 }
unsigned char type
Definition: ntuser.h:28
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
smooth NULL
Definition: ftsmooth.c:416
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:205
Definition: ntuser.h:19
static const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
Definition: misc.c:231
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
static __inline PVOID SharedPtrToUser(PVOID Ptr)
Definition: user_x.h:4
void * ptr
Definition: ntuser.h:21

Referenced by MENU_GetMenu(), and ValidateHwndNoErr().

◆ ValidateHwnd()

PWND FASTCALL ValidateHwnd ( HWND  hwnd)

Definition at line 369 of file misc.c.

370 {
372  ASSERT(ClientInfo != NULL);
373 
374  /* See if the window is cached */
375  if (hwnd && hwnd == ClientInfo->CallbackWnd.hWnd)
376  return ClientInfo->CallbackWnd.pWnd;
377 
379 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWin32ClientInfo()
Definition: ntuser.h:320
CLIENT_DATA ClientInfo
smooth NULL
Definition: ftsmooth.c:416
PVOID FASTCALL ValidateHandle(HANDLE handle, UINT uType)
Definition: misc.c:262
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by ButtonWndProc_common(), CallWindowProcA(), CallWindowProcW(), ClientToScreen(), ComboWndProc_common(), CreateWindowExA(), CreateWindowExW(), DIALOG_DoDialogBox(), DIALOG_FindMsgDestination(), DIALOG_get_info(), DispatchMessageA(), DispatchMessageW(), EditWndProc_common(), GetAncestor(), GetClassLongA(), GetClassLongW(), GetClassWord(), GetClientRect(), GetLastActivePopup(), GetMenu(), GetNextDlgTabItem(), GetParent(), GetScrollBarInfo(), GetScrollPos(), GetScrollRange(), GetUpdateRect(), GetUpdateRgn(), GetWindow(), GetWindowInfo(), GetWindowModuleFileNameA(), GetWindowModuleFileNameW(), GetWindowRect(), GetWindowRgn(), GetWindowRgnBox(), GetWindowTextA(), GetWindowTextLengthA(), GetWindowTextLengthW(), GetWindowTextW(), GetWindowThreadProcessId(), Ghost_OnCreate(), ImeWndProc_common(), IntFindChildWindowToOwner(), IntGetProp(), IntGetWindowLong(), IntScrollGetScrollBarRect(), IntScrollGetThumbVal(), IsChild(), IsDialogMessageW(), IsHungAppWindow(), IsIconic(), IsWindowInDestroy(), IsWindowUnicode(), IsWindowVisible(), ListBoxWndProc_common(), MapWindowPoints(), MsgWindowProc(), PopupMenuWndProcA(), PopupMenuWndProcW(), RealDefWindowProcA(), RealDefWindowProcW(), RealGetScrollInfo(), ScreenToClient(), ScrollBarWndProc_common(), ScrollTrackScrollBar(), SendMessageA(), SendMessageW(), SetScrollRange(), SetWindowTextA(), SetWindowTextW(), StaticWndProc_common(), SwitchWndProc_common(), UpdateWindow(), User32DefWindowProc(), and ValidateHwndOrDesk().

◆ ValidateHwndNoErr()

PWND FASTCALL ValidateHwndNoErr ( HWND  hwnd)

Definition at line 386 of file misc.c.

387 {
388  PWND Wnd;
390  ASSERT(ClientInfo != NULL);
391 
392  /* See if the window is cached */
393  if (hwnd == ClientInfo->CallbackWnd.hWnd)
394  return ClientInfo->CallbackWnd.pWnd;
395 
397  if (Wnd != NULL)
398  {
399  return Wnd;
400  }
401 
402  return NULL;
403 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWin32ClientInfo()
Definition: ntuser.h:320
CLIENT_DATA ClientInfo
smooth NULL
Definition: ftsmooth.c:416
PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType)
Definition: misc.c:320
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: ntuser.h:657

◆ ValidateHwndOrDesk()

PWND FASTCALL ValidateHwndOrDesk ( HWND  hwnd)

Definition at line 420 of file misc.c.

421 {
422  if (hwnd == HWND_DESKTOP)
423  return GetThreadDesktopWnd();
424 
425  return ValidateHwnd(hwnd);
426 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
#define HWND_DESKTOP
Definition: winuser.h:1195
PWND FASTCALL GetThreadDesktopWnd(VOID)
Definition: misc.c:407

◆ WCSToMBEx()

DWORD WINAPI WCSToMBEx ( WORD  CodePage,
LPWSTR  UnicodeString,
LONG  UnicodeSize,
LPSTR MBString,
LONG  MBSize,
BOOL  Allocate 
)

Definition at line 431 of file misc.c.

432 {
433  DWORD Size;
434  if (UnicodeSize == -1)
435  {
436  UnicodeSize = wcslen(UnicodeString)+1;
437  }
438  if (MBSize == -1)
439  {
440  if (!Allocate)
441  {
442  return 0;
443  }
444  MBSize = UnicodeSize * 2;
445  }
446  if (Allocate)
447  {
448  LPSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize);
449  if (SafeString == NULL)
450  return 0;
451  *MBString = SafeString;
452  }
453  if (CodePage == 0)
454  {
455  RtlUnicodeToMultiByteN(*MBString,MBSize,&Size,UnicodeString,UnicodeSize);
456  }
457  else
458  {
459  WideCharToMultiByte(CodePage,0,UnicodeString,UnicodeSize,*MBString,MBSize,0,0);
460  }
461  return UnicodeSize;
462 }
#define WideCharToMultiByte
Definition: compat.h:101
char * LPSTR
Definition: xmlstorage.h:182
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
smooth NULL
Definition: ftsmooth.c:416
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Variable Documentation

◆ g_ObjectHeapTypeShared

const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
static
Initial value:

Definition at line 231 of file misc.c.

Referenced by ValidateHandle(), and ValidateHandleNoErr().