[WIN32SS][USER32] Refactor USER32 callbacks (#6619)

Refactoring kernel-to-USER32 callback code.
Localize USER32 callback entry definitions.
JIRA issue: N/A
- Add header file win32ss/include/u32cb.h and use it to define the
  USER32 callback entries.
This commit is contained in:
Katayama Hirofumi MZ 2024-03-20 09:45:04 +09:00 committed by GitHub
parent 3be8934107
commit de5c472033
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 46 deletions

View file

@ -1,27 +1,22 @@
#ifndef __INCLUDE_USER32_CALLBACK_H
#define __INCLUDE_USER32_CALLBACK_H
/*
* PROJECT: ReactOS Kernel
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Defining kernel-to-user32 callbacks
* COPYRIGHT: Copyright 2018 James Tabor <james.tabor@reactos.org>
* Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#define USER32_CALLBACK_WINDOWPROC (0)
#define USER32_CALLBACK_SENDASYNCPROC (1)
#define USER32_CALLBACK_LOADSYSMENUTEMPLATE (2)
#define USER32_CALLBACK_LOADDEFAULTCURSORS (3)
#define USER32_CALLBACK_HOOKPROC (4)
#define USER32_CALLBACK_EVENTPROC (5)
#define USER32_CALLBACK_LOADMENU (6)
#define USER32_CALLBACK_CLIENTTHREADSTARTUP (7)
#define USER32_CALLBACK_CLIENTLOADLIBRARY (8)
#define USER32_CALLBACK_GETCHARSETINFO (9)
#define USER32_CALLBACK_COPYIMAGE (10)
#define USER32_CALLBACK_SETWNDICONS (11)
#define USER32_CALLBACK_DELIVERUSERAPC (12)
#define USER32_CALLBACK_DDEPOST (13)
#define USER32_CALLBACK_DDEGET (14)
#define USER32_CALLBACK_SETOBM (15)
#define USER32_CALLBACK_LPK (16)
#define USER32_CALLBACK_UMPD (17)
#define USER32_CALLBACK_IMMPROCESSKEY (18)
#define USER32_CALLBACK_IMMLOADLAYOUT (19)
#define USER32_CALLBACK_MAXIMUM USER32_CALLBACK_IMMLOADLAYOUT
#pragma once
#define DEFINE_USER32_CALLBACK(id, value, fn) id,
typedef enum _USER32_CALLBACK
{
#include "u32cb.h"
USER32_CALLBACK_COUNT
} USER32_CALLBACK;
#undef DEFINE_USER32_CALLBACK
typedef struct _WINDOWPROC_CALLBACK_ARGUMENTS
{
@ -230,5 +225,3 @@ NTSTATUS WINAPI
User32CallImmProcessKeyFromKernel(PVOID Arguments, ULONG ArgumentLength);
NTSTATUS WINAPI
User32CallImmLoadLayoutFromKernel(PVOID Arguments, ULONG ArgumentLength);
#endif /* __INCLUDE_USER32_CALLBACK_H */

28
win32ss/include/u32cb.h Normal file
View file

@ -0,0 +1,28 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Defining kernel-to-user32 callback entries
* COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
/* DEFINE_USER32_CALLBACK(id, value, fn) */
DEFINE_USER32_CALLBACK(USER32_CALLBACK_WINDOWPROC, 0, User32CallWindowProcFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_SENDASYNCPROC, 1, User32CallSendAsyncProcForKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_LOADSYSMENUTEMPLATE, 2, User32LoadSysMenuTemplateForKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_LOADDEFAULTCURSORS, 3, User32SetupDefaultCursors)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_HOOKPROC, 4, User32CallHookProcFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_EVENTPROC, 5, User32CallEventProcFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_LOADMENU, 6, User32CallLoadMenuFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_CLIENTTHREADSTARTUP, 7, User32CallClientThreadSetupFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_CLIENTLOADLIBRARY, 8, User32CallClientLoadLibraryFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_GETCHARSETINFO, 9, User32CallGetCharsetInfo)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_COPYIMAGE, 10, User32CallCopyImageFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_SETWNDICONS, 11, User32CallSetWndIconsFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_DELIVERUSERAPC, 12, User32DeliverUserAPC)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_DDEPOST, 13, User32CallDDEPostFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_DDEGET, 14, User32CallDDEGetFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_SETOBM, 15, User32CallOBMFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_LPK, 16, User32CallLPKFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_UMPD, 17, User32CallUMPDFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_IMMPROCESSKEY, 18, User32CallImmProcessKeyFromKernel)
DEFINE_USER32_CALLBACK(USER32_CALLBACK_IMMLOADLAYOUT, 19, User32CallImmLoadLayoutFromKernel)

View file

@ -203,30 +203,14 @@ UnloadAppInitDlls(VOID)
}
}
PVOID apfnDispatch[USER32_CALLBACK_MAXIMUM + 1] =
#define DEFINE_USER32_CALLBACK(id, value, fn) fn,
PVOID apfnDispatch[USER32_CALLBACK_COUNT] =
{
User32CallWindowProcFromKernel,
User32CallSendAsyncProcForKernel,
User32LoadSysMenuTemplateForKernel,
User32SetupDefaultCursors,
User32CallHookProcFromKernel,
User32CallEventProcFromKernel,
User32CallLoadMenuFromKernel,
User32CallClientThreadSetupFromKernel,
User32CallClientLoadLibraryFromKernel,
User32CallGetCharsetInfo,
User32CallCopyImageFromKernel,
User32CallSetWndIconsFromKernel,
User32DeliverUserAPC,
User32CallDDEPostFromKernel,
User32CallDDEGetFromKernel,
User32CallOBMFromKernel,
User32CallLPKFromKernel,
User32CallUMPDFromKernel,
User32CallImmProcessKeyFromKernel,
User32CallImmLoadLayoutFromKernel,
#include "u32cb.h"
};
#undef DEFINE_USER32_CALLBACK
VOID
WINAPI