https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fbab1914a6fb6f2865cb80d892dd3f36836b136f

commit fbab1914a6fb6f2865cb80d892dd3f36836b136f
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Mon Jan 31 09:30:47 2022 +0900
Commit:     GitHub <[email protected]>
CommitDate: Mon Jan 31 09:30:47 2022 +0900

    [USER32] Don't delay-load-link to imm32.dll (#4328)
    
    Reduce binary size.
    - Don't directly call the IMM32 functions. Use IMM_FN instead.
    - Modify CMakeLists.txt to unlink imm32.dll.
    CORE-11700
---
 win32ss/user/user32/CMakeLists.txt   |  2 +-
 win32ss/user/user32/controls/edit.c  |  5 +++++
 win32ss/user/user32/windows/defwnd.c | 28 ++++++++++++++--------------
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/win32ss/user/user32/CMakeLists.txt 
b/win32ss/user/user32/CMakeLists.txt
index 4cf9620a5c8..c181932f8ee 100644
--- a/win32ss/user/user32/CMakeLists.txt
+++ b/win32ss/user/user32/CMakeLists.txt
@@ -87,7 +87,7 @@ if(MSVC AND (ARCH STREQUAL "i386"))
     target_sources(user32 PRIVATE $<TARGET_OBJECTS:ftol2_sse>)
 endif()
 
-add_delay_importlibs(user32 imm32 usp10)
+add_delay_importlibs(user32 usp10)
 add_importlibs(user32 gdi32 advapi32 kernel32 ntdll)
 add_pch(user32 include/user32.h SOURCE)
 add_cd_file(TARGET user32 DESTINATION reactos/system32 FOR all)
diff --git a/win32ss/user/user32/controls/edit.c 
b/win32ss/user/user32/controls/edit.c
index f01558a9d06..9fc7d3f0f0d 100644
--- a/win32ss/user/user32/controls/edit.c
+++ b/win32ss/user/user32/controls/edit.c
@@ -45,6 +45,11 @@
 #include <user32.h>
 #define WIN32_LEAN_AND_MEAN
 #include <usp10.h>
+#ifdef __REACTOS__
+#define ImmGetContext               IMM_FN(ImmGetContext)
+#define ImmGetCompositionStringW    IMM_FN(ImmGetCompositionStringW)
+#define ImmReleaseContext           IMM_FN(ImmReleaseContext)
+#endif
 
 WINE_DEFAULT_DEBUG_CHANNEL(edit);
 WINE_DECLARE_DEBUG_CHANNEL(combo);
diff --git a/win32ss/user/user32/windows/defwnd.c 
b/win32ss/user/user32/windows/defwnd.c
index b7a624061e3..c6e97e5f704 100644
--- a/win32ss/user/user32/windows/defwnd.c
+++ b/win32ss/user/user32/windows/defwnd.c
@@ -951,16 +951,16 @@ RealDefWindowProcA(HWND hWnd,
             LONG size, i;
             unsigned char lead = 0;
             char *buf = NULL;
-            HIMC himc = ImmGetContext( hWnd );
+            HIMC himc = IMM_FN(ImmGetContext)( hWnd );
 
             if (himc)
             {
-                if ((size = ImmGetCompositionStringA( himc, GCS_RESULTSTR, 
NULL, 0 )))
+                if ((size = IMM_FN(ImmGetCompositionStringA)( himc, 
GCS_RESULTSTR, NULL, 0 )))
                 {
                     if (!(buf = HeapAlloc( GetProcessHeap(), 0, size ))) size 
= 0;
-                    else size = ImmGetCompositionStringA( himc, GCS_RESULTSTR, 
buf, size );
+                    else size = IMM_FN(ImmGetCompositionStringA)( himc, 
GCS_RESULTSTR, buf, size );
                 }
-                ImmReleaseContext( hWnd, himc );
+                IMM_FN(ImmReleaseContext)( hWnd, himc );
 
                 for (i = 0; i < size; i++)
                 {
@@ -990,7 +990,7 @@ RealDefWindowProcA(HWND hWnd,
         {
             HWND hwndIME;
 
-            hwndIME = ImmGetDefaultIMEWnd(hWnd);
+            hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
             if (hwndIME)
                 Result = SendMessageA(hwndIME, Msg, wParam, lParam);
             break;
@@ -1000,9 +1000,9 @@ RealDefWindowProcA(HWND hWnd,
         {
             HWND hwndIME;
 
-            hwndIME = ImmGetDefaultIMEWnd(hWnd);
+            hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
             if (hwndIME)
-                Result = ImmIsUIMessageA(hwndIME, Msg, wParam, lParam);
+                Result = SendMessageA(hwndIME, Msg, wParam, lParam);
             break;
         }
 
@@ -1150,16 +1150,16 @@ RealDefWindowProcW(HWND hWnd,
         {
             LONG size, i;
             WCHAR *buf = NULL;
-            HIMC himc = ImmGetContext( hWnd );
+            HIMC himc = IMM_FN(ImmGetContext)( hWnd );
 
             if (himc)
             {
-                if ((size = ImmGetCompositionStringW( himc, GCS_RESULTSTR, 
NULL, 0 )))
+                if ((size = IMM_FN(ImmGetCompositionStringW)( himc, 
GCS_RESULTSTR, NULL, 0 )))
                 {
                     if (!(buf = HeapAlloc( GetProcessHeap(), 0, size * 
sizeof(WCHAR) ))) size = 0;
-                    else size = ImmGetCompositionStringW( himc, GCS_RESULTSTR, 
buf, size * sizeof(WCHAR) );
+                    else size = IMM_FN(ImmGetCompositionStringW)( himc, 
GCS_RESULTSTR, buf, size * sizeof(WCHAR) );
                 }
-                ImmReleaseContext( hWnd, himc );
+                IMM_FN(ImmReleaseContext)( hWnd, himc );
 
                 for (i = 0; i < size / sizeof(WCHAR); i++)
                     SendMessageW( hWnd, WM_IME_CHAR, buf[i], 1 );
@@ -1175,7 +1175,7 @@ RealDefWindowProcW(HWND hWnd,
         {
             HWND hwndIME;
 
-            hwndIME = ImmGetDefaultIMEWnd(hWnd);
+            hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
             if (hwndIME)
                 Result = SendMessageW(hwndIME, Msg, wParam, lParam);
             break;
@@ -1185,9 +1185,9 @@ RealDefWindowProcW(HWND hWnd,
         {
             HWND hwndIME;
 
-            hwndIME = ImmGetDefaultIMEWnd(hWnd);
+            hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
             if (hwndIME)
-                Result = ImmIsUIMessageW(hwndIME, Msg, wParam, lParam);
+                Result = SendMessageW(hwndIME, Msg, wParam, lParam);
             break;
         }
 

Reply via email to