user32: Use ntuser object type constants.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-02-22 13:40:33 +01:00 committed by Alexandre Julliard
parent dd2dd00665
commit b86842bb15
7 changed files with 37 additions and 38 deletions

View File

@ -129,7 +129,7 @@ static HICON alloc_icon_handle( BOOL is_ani, UINT num_steps )
obj->ani.num_frames = num_steps; /* changed later for some animated cursors */
}
if (!(handle = alloc_user_handle( &obj->obj, USER_ICON )))
if (!(handle = alloc_user_handle( &obj->obj, NTUSER_OBJ_ICON )))
{
if (obj->is_ani) HeapFree( GetProcessHeap(), 0, obj->ani.frames );
HeapFree( GetProcessHeap(), 0, obj );
@ -139,7 +139,7 @@ static HICON alloc_icon_handle( BOOL is_ani, UINT num_steps )
static struct cursoricon_object *get_icon_ptr( HICON handle )
{
struct cursoricon_object *obj = get_user_handle_ptr( handle, USER_ICON );
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
if (obj == OBJ_OTHER_PROCESS)
{
WARN( "icon handle %p from other process\n", handle );
@ -175,7 +175,7 @@ static UINT get_icon_steps( struct cursoricon_object *obj )
static BOOL free_icon_handle( HICON handle )
{
struct cursoricon_object *obj = free_user_handle( handle, USER_ICON );
struct cursoricon_object *obj = free_user_handle( handle, NTUSER_OBJ_ICON );
if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle );
else if (obj)
@ -225,7 +225,7 @@ static BOOL free_icon_handle( HICON handle )
ULONG_PTR get_icon_param( HICON handle )
{
ULONG_PTR ret = 0;
struct cursoricon_object *obj = get_user_handle_ptr( handle, USER_ICON );
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle );
else if (obj)
@ -239,7 +239,7 @@ ULONG_PTR get_icon_param( HICON handle )
ULONG_PTR set_icon_param( HICON handle, ULONG_PTR param )
{
ULONG_PTR ret = 0;
struct cursoricon_object *obj = get_user_handle_ptr( handle, USER_ICON );
struct cursoricon_object *obj = get_user_handle_ptr( handle, NTUSER_OBJ_ICON );
if (obj == OBJ_OTHER_PROCESS) WARN( "icon handle %p from other process\n", handle );
else if (obj)

View File

@ -287,7 +287,7 @@ static void do_debug_print_menuitem(const char *prefix, const MENUITEM *mp,
*/
static POPUPMENU *MENU_GetMenu(HMENU hMenu)
{
POPUPMENU *menu = get_user_handle_ptr( hMenu, USER_MENU );
POPUPMENU *menu = get_user_handle_ptr( hMenu, NTUSER_OBJ_MENU );
if (menu == OBJ_OTHER_PROCESS)
{
@ -301,7 +301,7 @@ static POPUPMENU *MENU_GetMenu(HMENU hMenu)
static POPUPMENU *grab_menu_ptr(HMENU hMenu)
{
POPUPMENU *menu = get_user_handle_ptr( hMenu, USER_MENU );
POPUPMENU *menu = get_user_handle_ptr( hMenu, NTUSER_OBJ_MENU );
if (menu == OBJ_OTHER_PROCESS)
{
@ -4246,7 +4246,7 @@ HMENU WINAPI CreateMenu(void)
menu->FocusedItem = NO_SELECTED_ITEM;
menu->refcount = 1;
if (!(hMenu = alloc_user_handle( &menu->obj, USER_MENU ))) HeapFree( GetProcessHeap(), 0, menu );
if (!(hMenu = alloc_user_handle( &menu->obj, NTUSER_OBJ_MENU ))) HeapFree( GetProcessHeap(), 0, menu );
TRACE("return %p\n", hMenu );
@ -4263,7 +4263,7 @@ BOOL WINAPI DestroyMenu( HMENU hMenu )
TRACE("(%p)\n", hMenu);
if (!(lppop = free_user_handle( hMenu, USER_MENU ))) return FALSE;
if (!(lppop = free_user_handle( hMenu, NTUSER_OBJ_MENU ))) return FALSE;
if (lppop == OBJ_OTHER_PROCESS) return FALSE;
/* DestroyMenu should not destroy system menu popup owner */

View File

@ -68,7 +68,7 @@ HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance, LPCWSTR name)
if (!accel) return 0;
accel->count = count;
memcpy( accel->table, table, count * sizeof(*table) );
if (!(handle = alloc_user_handle( &accel->obj, USER_ACCEL )))
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
HeapFree( GetProcessHeap(), 0, accel );
TRACE_(accel)("%p %s returning %p\n", instance, debugstr_w(name), handle );
return handle;
@ -123,7 +123,7 @@ INT WINAPI CopyAcceleratorTableW(HACCEL src, LPACCEL dst, INT count)
struct accelerator *accel;
int i;
if (!(accel = get_user_handle_ptr( src, USER_ACCEL ))) return 0;
if (!(accel = get_user_handle_ptr( src, NTUSER_OBJ_ACCEL ))) return 0;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", src );
@ -172,7 +172,7 @@ HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT count)
}
else accel->table[i].key = lpaccel[i].key;
}
if (!(handle = alloc_user_handle( &accel->obj, USER_ACCEL )))
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
HeapFree( GetProcessHeap(), 0, accel );
TRACE_(accel)("returning %p\n", handle );
return handle;
@ -201,7 +201,7 @@ HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccel, INT count)
accel->table[i].key = lpaccel[i].key;
accel->table[i].cmd = lpaccel[i].cmd;
}
if (!(handle = alloc_user_handle( &accel->obj, USER_ACCEL )))
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
HeapFree( GetProcessHeap(), 0, accel );
TRACE_(accel)("returning %p\n", handle );
return handle;
@ -222,7 +222,7 @@ BOOL WINAPI DestroyAcceleratorTable( HACCEL handle )
{
struct accelerator *accel;
if (!(accel = free_user_handle( handle, USER_ACCEL ))) return FALSE;
if (!(accel = free_user_handle( handle, NTUSER_OBJ_ACCEL ))) return FALSE;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", accel );

View File

@ -50,27 +50,18 @@ extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
struct received_message_info;
enum user_obj_type
{
USER_WINDOW = 1, /* window */
USER_MENU, /* menu */
USER_ACCEL, /* accelerator */
USER_ICON, /* icon or cursor */
USER_DWP /* DeferWindowPos structure */
};
struct user_object
{
HANDLE handle;
enum user_obj_type type;
HANDLE handle;
unsigned int type;
};
#define OBJ_OTHER_PROCESS ((void *)1) /* returned by get_user_handle_ptr on unknown handles */
HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type ) DECLSPEC_HIDDEN;
void *get_user_handle_ptr( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
HANDLE alloc_user_handle( struct user_object *ptr, unsigned int type ) DECLSPEC_HIDDEN;
void *get_user_handle_ptr( HANDLE handle, unsigned int type ) DECLSPEC_HIDDEN;
void release_user_handle_ptr( void *ptr ) DECLSPEC_HIDDEN;
void *free_user_handle( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
void *free_user_handle( HANDLE handle, unsigned int type ) DECLSPEC_HIDDEN;
/* type of message-sending functions that need special WM_CHAR handling */
enum wm_char_mapping

View File

@ -92,7 +92,7 @@ static void *user_handles[NB_USER_HANDLES];
/***********************************************************************
* alloc_user_handle
*/
HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type )
HANDLE alloc_user_handle( struct user_object *ptr, unsigned int type )
{
HANDLE handle = 0;
@ -118,7 +118,7 @@ HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type )
/***********************************************************************
* get_user_handle_ptr
*/
void *get_user_handle_ptr( HANDLE handle, enum user_obj_type type )
void *get_user_handle_ptr( HANDLE handle, unsigned int type )
{
struct user_object *ptr;
WORD index = USER_HANDLE_TO_INDEX( handle );
@ -153,7 +153,7 @@ void release_user_handle_ptr( void *ptr )
/***********************************************************************
* free_user_handle
*/
void *free_user_handle( HANDLE handle, enum user_obj_type type )
void *free_user_handle( HANDLE handle, unsigned int type )
{
struct user_object *ptr;
WORD index = USER_HANDLE_TO_INDEX( handle );
@ -256,7 +256,7 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
index = USER_HANDLE_TO_INDEX(handle);
assert( index < NB_USER_HANDLES );
win->obj.handle = handle;
win->obj.type = USER_WINDOW;
win->obj.type = NTUSER_OBJ_WINDOW;
win->parent = full_parent;
win->owner = full_owner;
win->class = class;
@ -280,7 +280,7 @@ static void free_window_handle( HWND hwnd )
struct user_object *ptr;
WORD index = USER_HANDLE_TO_INDEX(hwnd);
if ((ptr = get_user_handle_ptr( hwnd, USER_WINDOW )) && ptr != OBJ_OTHER_PROCESS)
if ((ptr = get_user_handle_ptr( hwnd, NTUSER_OBJ_WINDOW )) && ptr != OBJ_OTHER_PROCESS)
{
SERVER_START_REQ( destroy_window )
{
@ -748,7 +748,7 @@ WND *WIN_GetPtr( HWND hwnd )
{
WND *ptr;
if ((ptr = get_user_handle_ptr( hwnd, USER_WINDOW )) == WND_OTHER_PROCESS)
if ((ptr = get_user_handle_ptr( hwnd, NTUSER_OBJ_WINDOW )) == WND_OTHER_PROCESS)
{
if (is_desktop_window( hwnd )) ptr = WND_DESKTOP;
}
@ -1163,7 +1163,7 @@ static WND *next_thread_window( HWND *hwnd )
while (index < NB_USER_HANDLES)
{
if (!(ptr = user_handles[index++])) continue;
if (ptr->type != USER_WINDOW) continue;
if (ptr->type != NTUSER_OBJ_WINDOW) continue;
win = (WND *)ptr;
if (win->tid != GetCurrentThreadId()) continue;
*hwnd = ptr->handle;

View File

@ -2520,7 +2520,7 @@ HDWP WINAPI BeginDeferWindowPos( INT count )
pDWP->hwndParent = 0;
if (!(pDWP->winPos = HeapAlloc( GetProcessHeap(), 0, count * sizeof(WINDOWPOS) )) ||
!(handle = alloc_user_handle( &pDWP->obj, USER_DWP )))
!(handle = alloc_user_handle( &pDWP->obj, NTUSER_OBJ_WINPOS )))
{
HeapFree( GetProcessHeap(), 0, pDWP->winPos );
HeapFree( GetProcessHeap(), 0, pDWP );
@ -2561,7 +2561,7 @@ HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
winpos.cy = cy;
map_dpi_winpos( &winpos );
if (!(pDWP = get_user_handle_ptr( hdwp, USER_DWP ))) return 0;
if (!(pDWP = get_user_handle_ptr( hdwp, NTUSER_OBJ_WINPOS ))) return 0;
if (pDWP == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", hdwp );
@ -2626,7 +2626,7 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
TRACE("%p\n", hdwp);
if (!(pDWP = free_user_handle( hdwp, USER_DWP ))) return FALSE;
if (!(pDWP = free_user_handle( hdwp, NTUSER_OBJ_WINPOS ))) return FALSE;
if (pDWP == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", hdwp );

View File

@ -105,6 +105,14 @@ enum
/* color index used to retrieve system 55aa brush */
#define COLOR_55AA_BRUSH 0x100
/* user object types */
#define NTUSER_OBJ_WINDOW 0x01
#define NTUSER_OBJ_MENU 0x02
#define NTUSER_OBJ_ICON 0x03
#define NTUSER_OBJ_WINPOS 0x04
#define NTUSER_OBJ_ACCEL 0x08
#define NTUSER_OBJ_HOOK 0x0f
/* internal messages codes */
enum wine_internal_message
{