ReactOS  0.4.15-dev-3324-gda4e15f
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 397 of file misc.c.

398 {
400  if (Wnd != NULL)
401  Wnd = DesktopPtrToUser(Wnd);
402  return Wnd;
403 }
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
struct _WND * spwnd
Definition: ntuser.h:133
Definition: ntuser.h:663
#define NULL
Definition: types.h:112
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 195 of file misc.c.

196 {
197  INT Index;
199 
200  if (!handle) return NULL;
201 
202  Index = (((UINT_PTR)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
203 
205  return NULL;
206 
208  return NULL;
209 
210  generation = (UINT_PTR)handle >> 16;
211 
213  return &gHandleEntries[Index];
214 
215  return NULL;
216 }
unsigned __int3264 UINT_PTR
Definition: activex.cpp:275
#define FIRST_USER_HANDLE
Definition: ntuser.h:10
int32_t INT
Definition: typedefs.h:58
static PVOID ptr
Definition: dispmode.c:27
_In_ WDFCOLLECTION _In_ ULONG Index
unsigned short USHORT
Definition: pedump.c:61
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2929
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PUSER_HANDLE_ENTRY gHandleEntries
Definition: dllmain.c:33

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 {
84 
85  Status = NtQuerySecurityObject(hObject,
86  *pSecurityInfo,
87  pSecurityDescriptor,
88  dwLength,
89  pdwLengthNeeded);
90  if (!NT_SUCCESS(Status))
91  {
93  return FALSE;
94  }
95 
96  return TRUE;
97 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
VOID WINAPI UserSetLastNTError(IN NTSTATUS Status)
Definition: misc.c:25
Status
Definition: gdiplustypes.h:24
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:85
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32

◆ 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 }
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
#define NULL
Definition: types.h:112

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 145 of file misc.c.

147 {
148  PTHREADINFO ti = (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo;
149  if (ti == NULL)
150  {
151  if(bConvert)
152  {
154  if ((PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo) return TRUE;
155  else
157  }
158  return FALSE;
159  }
160  else
161  return TRUE;
162 }
#define TRUE
Definition: types.h:120
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define FALSE
Definition: types.h:117
struct _THREADINFO * PTHREADINFO
Definition: ntwin32.h:6
#define SetLastError(x)
Definition: compat.h:611
DWORD_PTR APIENTRY NtUserGetThreadState(DWORD Routine)
Definition: misc.c:231
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define NULL
Definition: types.h:112

Referenced by do_InitialDesktop_child().

◆ MBToWCSEx()

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

Definition at line 457 of file misc.c.

458 {
459  DWORD Size;
460  if (MBSize == -1)
461  {
462  MBSize = strlen(MBString)+1;
463  }
464  if (UnicodeSize == -1)
465  {
466  if (!Allocate)
467  {
468  return 0;
469  }
470  UnicodeSize = MBSize;
471  }
472  if (Allocate)
473  {
474  LPWSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, UnicodeSize);
475  if (SafeString == NULL)
476  return 0;
477  *UnicodeString = SafeString;
478  }
479  UnicodeSize *= sizeof(WCHAR);
480  if (CodePage == 0)
481  {
482  RtlMultiByteToUnicodeN(*UnicodeString,UnicodeSize,&Size,MBString,MBSize);
483  }
484  else
485  {
486  Size = MultiByteToWideChar(CodePage,0,MBString,MBSize,*UnicodeString,UnicodeSize);
487  }
488  return Size;
489 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:595
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ SetUserObjectSecurity()

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

Definition at line 120 of file misc.c.

125 {
127 
128  Status = NtSetSecurityObject(hObject,
129  *pSecurityInfo,
130  pSecurityDescriptor);
131  if (!NT_SUCCESS(Status))
132  {
134  return FALSE;
135  }
136 
137  return TRUE;
138 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
VOID WINAPI UserSetLastNTError(IN NTSTATUS Status)
Definition: misc.c:25
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS WINAPI NtSetSecurityObject(HANDLE Handle, SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR SecurityDescriptor)

◆ TestState()

BOOL FASTCALL TestState ( PWND  pWnd,
UINT  Flag 
)

Definition at line 177 of file misc.c.

178 {
179  UINT bit;
180  bit = 1 << LOWORD(Flag);
181  switch(HIWORD(Flag))
182  {
183  case 0:
184  return (pWnd->state & bit);
185  case 1:
186  return (pWnd->state2 & bit);
187  case 2:
188  return (pWnd->ExStyle2 & bit);
189  }
190  return FALSE;
191 }
DWORD ExStyle2
Definition: ntuser.h:715
#define FALSE
Definition: types.h:117
Definition: xml2sdb.h:79
DWORD state
Definition: ntuser.h:671
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:247
DWORD state2
Definition: ntuser.h:672
#define LOWORD(l)
Definition: pedump.c:82

Referenced by NtUserxClearWindowState(), and NtUserxSetWindowState().

◆ TestWindowProcess()

BOOL FASTCALL TestWindowProcess ( PWND  Wnd)

Definition at line 166 of file misc.c.

167 {
168  if (Wnd->head.pti == (PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo)
169  return TRUE;
170  else
173 }
#define QUERY_WINDOW_UNIQUE_PROCESS_ID
Definition: ntuser.h:2900
#define TRUE
Definition: types.h:120
HANDLE UniqueProcess
Definition: compat.h:684
DWORD_PTR NTAPI NtUserQueryWindow(HWND hWnd, DWORD Index)
Definition: window.c:3929
THRDESKHEAD head
Definition: ntuser.h:665
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1163
uint32_t DWORD_PTR
Definition: typedefs.h:65
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
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
Status
Definition: gdiplustypes.h:24

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

◆ ValidateCallProc()

PCALLPROCDATA FASTCALL ValidateCallProc ( HANDLE  hCallProc)

Definition at line 339 of file misc.c.

340 {
342 
343  PCALLPROCDATA CallProc = ValidateHandle(hCallProc, TYPE_CALLPROC);
344 
345  pEntry = GetUser32Handle(hCallProc);
346 
347  if (CallProc != NULL && pEntry->ppi == g_ppi)
348  return CallProc;
349 
350  return NULL;
351 }
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:195
PPROCESSINFO g_ppi
Definition: dllmain.c:29
Definition: ntuser.h:16
PVOID FASTCALL ValidateHandle(HANDLE handle, UINT uType)
Definition: misc.c:252
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by CallWindowProcA(), and CallWindowProcW().

◆ ValidateHandle()

PVOID FASTCALL ValidateHandle ( HANDLE  handle,
UINT  uType 
)

Definition at line 252 of file misc.c.

253 {
254  PVOID ret;
256 
257  ASSERT(uType < TYPE_CTYPES);
258 
260 
261  if (pEntry && uType == 0)
262  uType = pEntry->type;
263 
264 // Must have an entry and must be the same type!
265  if ( (!pEntry) ||
266  (pEntry->type != uType) ||
267  !pEntry->ptr ||
268  (pEntry->flags & HANDLEENTRY_DESTROY) || (pEntry->flags & HANDLEENTRY_INDESTROY) )
269  {
270  switch ( uType )
271  { // Test (with wine too) confirms these results!
272  case TYPE_WINDOW:
274  break;
275  case TYPE_MENU:
277  break;
278  case TYPE_CURSOR:
280  break;
281  case TYPE_SETWINDOWPOS:
283  break;
284  case TYPE_HOOK:
286  break;
287  case TYPE_ACCELTABLE:
289  break;
290  default:
292  break;
293  }
294  return NULL;
295  }
296 
297  if (g_ObjectHeapTypeShared[uType])
298  ret = SharedPtrToUser(pEntry->ptr);
299  else
300  ret = DesktopPtrToUser(pEntry->ptr);
301 
302  return ret;
303 }
#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
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:195
Definition: ntuser.h:16
static const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
Definition: misc.c:221
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define ASSERT(a)
Definition: mode.c:44
#define SetLastError(x)
Definition: compat.h:611
int ret
#define HANDLEENTRY_DESTROY
Definition: ntuser.h:13
static __inline PVOID SharedPtrToUser(PVOID Ptr)
Definition: user_x.h:4
#define NULL
Definition: types.h:112
#define HANDLEENTRY_INDESTROY
Definition: ntuser.h:14
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by ValidateCallProc(), and ValidateHwnd().

◆ ValidateHandleNoErr()

PVOID FASTCALL ValidateHandleNoErr ( HANDLE  handle,
UINT  uType 
)

Definition at line 310 of file misc.c.

311 {
312  PVOID ret;
314 
315  ASSERT(uType < TYPE_CTYPES);
316 
318 
319  if (pEntry && uType == 0)
320  uType = pEntry->type;
321 
322 // Must have an entry and must be the same type!
323  if ( (!pEntry) || (pEntry->type != uType) || !pEntry->ptr )
324  return NULL;
325 
326  if (g_ObjectHeapTypeShared[uType])
327  ret = SharedPtrToUser(pEntry->ptr);
328  else
329  ret = DesktopPtrToUser(pEntry->ptr);
330 
331  return ret;
332 }
static __inline PVOID DesktopPtrToUser(PVOID Ptr)
Definition: user_x.h:12
PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE handle)
Definition: misc.c:195
Definition: ntuser.h:16
static const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
Definition: misc.c:221
#define ASSERT(a)
Definition: mode.c:44
int ret
static __inline PVOID SharedPtrToUser(PVOID Ptr)
Definition: user_x.h:4
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by Imm32CleanupContext(), ImmLockClientImc(), MENU_GetMenu(), and ValidateHwndNoErr().

◆ ValidateHwnd()

PWND FASTCALL ValidateHwnd ( HWND  hwnd)

Definition at line 359 of file misc.c.

360 {
362  ASSERT(ClientInfo != NULL);
363 
364  /* See if the window is cached */
365  if (hwnd && hwnd == ClientInfo->CallbackWnd.hWnd)
366  return ClientInfo->CallbackWnd.pWnd;
367 
369 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWin32ClientInfo()
Definition: ntuser.h:326
CLIENT_DATA ClientInfo
#define ASSERT(a)
Definition: mode.c:44
PVOID FASTCALL ValidateHandle(HANDLE handle, UINT uType)
Definition: misc.c:252
#define NULL
Definition: types.h:112

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 376 of file misc.c.

377 {
378  PWND Wnd;
380  ASSERT(ClientInfo != NULL);
381 
382  /* See if the window is cached */
383  if (hwnd == ClientInfo->CallbackWnd.hWnd)
384  return ClientInfo->CallbackWnd.pWnd;
385 
387  if (Wnd != NULL)
388  {
389  return Wnd;
390  }
391 
392  return NULL;
393 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define GetWin32ClientInfo()
Definition: ntuser.h:326
CLIENT_DATA ClientInfo
PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType)
Definition: misc.c:310
#define ASSERT(a)
Definition: mode.c:44
Definition: ntuser.h:663
#define NULL
Definition: types.h:112

Referenced by co_IntDestroyCaret(), co_IntFixCaret(), co_IntProcessKeyboardMessage(), co_IntProcessMouseMessage(), co_IntSendActivateMessages(), co_IntSendDeactivateMessages(), co_MsqSendMessage(), co_UserProcessHotKeys(), co_UserShowCaret(), co_WinPosSearchChildren(), co_WinPosSetWindowPos(), DefWndHandleSysCommand(), get_win_sys_menu(), Imm32GetContextEx(), Imm32RequestMessageAW(), Imm32UnknownProcess1(), ImmAssociateContext(), ImmAssociateContextEx(), ImmConfigureIMEA(), ImmConfigureIMEW(), IntChildWindowFromPointEx(), IntDeactivateWindow(), IntDestroyMenuObject(), IntEndDeferWindowPosEx(), IntGetMenu(), IntGhostWindowFromHungWindow(), IntHungWindowFromGhostWindow(), IntMakeHungWindowGhosted(), IntRealChildWindowFromPoint(), IntTrackPopupMenuEx(), MENU_DoNextMenu(), MENU_DrawBitmapItem(), MENU_EnsureMenuItemVisible(), MENU_FindItemByCoords(), MENU_HideSubPopups(), MENU_IsMenuActive(), MENU_PtMenu(), MENU_SelectItem(), MENU_ShowPopup(), MENU_ShowSubPopup(), MENU_TrackMenu(), MsqSetStateWindow(), NtUserFlashWindowEx(), UserGhostWindowFromHungWindow(), UserHungWindowFromGhostWindow(), WinPosDoOwnedPopups(), and WinPosFixupFlags().

◆ ValidateHwndOrDesk()

PWND FASTCALL ValidateHwndOrDesk ( HWND  hwnd)

Definition at line 410 of file misc.c.

411 {
412  if (hwnd == HWND_DESKTOP)
413  return GetThreadDesktopWnd();
414 
415  return ValidateHwnd(hwnd);
416 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:359
#define HWND_DESKTOP
Definition: winuser.h:1195
PWND FASTCALL GetThreadDesktopWnd(VOID)
Definition: misc.c:397

◆ WCSToMBEx()

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

Definition at line 421 of file misc.c.

422 {
423  DWORD Size;
424  if (UnicodeSize == -1)
425  {
426  UnicodeSize = wcslen(UnicodeString)+1;
427  }
428  if (MBSize == -1)
429  {
430  if (!Allocate)
431  {
432  return 0;
433  }
434  MBSize = UnicodeSize * 2;
435  }
436  if (Allocate)
437  {
438  LPSTR SafeString = RtlAllocateHeap(GetProcessHeap(), 0, MBSize);
439  if (SafeString == NULL)
440  return 0;
441  *MBString = SafeString;
442  }
443  if (CodePage == 0)
444  {
445  RtlUnicodeToMultiByteN(*MBString,MBSize,&Size,UnicodeString,UnicodeSize);
446  }
447  else
448  {
449  WideCharToMultiByte(CodePage,0,UnicodeString,UnicodeSize,*MBString,MBSize,0,0);
450  }
451  return UnicodeSize;
452 }
#define WideCharToMultiByte
Definition: compat.h:111
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
char * LPSTR
Definition: xmlstorage.h:182
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:595
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Variable Documentation

◆ g_ObjectHeapTypeShared

const BOOL g_ObjectHeapTypeShared[TYPE_CTYPES]
static
Initial value:
=
{
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
TRUE,
}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Definition at line 221 of file misc.c.

Referenced by ValidateHandle(), and ValidateHandleNoErr().