[PATCH 04/11] wineandroid: Move DllMain to separated file.

Jacek Caban wine at gitlab.winehq.org
Mon Jun 6 19:33:03 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
 dlls/wineandroid.drv/Makefile.in |  1 +
 dlls/wineandroid.drv/android.h   |  1 +
 dlls/wineandroid.drv/dllmain.c   | 36 ++++++++++++++++++++++++++++++++
 dlls/wineandroid.drv/init.c      | 29 ++++++++++++-------------
 dlls/wineandroid.drv/unixlib.h   | 30 ++++++++++++++++++++++++++
 5 files changed, 83 insertions(+), 14 deletions(-)
 create mode 100644 dlls/wineandroid.drv/dllmain.c
 create mode 100644 dlls/wineandroid.drv/unixlib.h

diff --git a/dlls/wineandroid.drv/Makefile.in b/dlls/wineandroid.drv/Makefile.in
index 5426fc75b94..4c4b63d2e78 100644
--- a/dlls/wineandroid.drv/Makefile.in
+++ b/dlls/wineandroid.drv/Makefile.in
@@ -7,6 +7,7 @@ EXTRADLLFLAGS = -mcygwin
 
 C_SRCS = \
 	device.c \
+	dllmain.c \
 	init.c \
 	keyboard.c \
 	opengl.c \
diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h
index 8008db52cfb..8b62bec862d 100644
--- a/dlls/wineandroid.drv/android.h
+++ b/dlls/wineandroid.drv/android.h
@@ -34,6 +34,7 @@
 #include "winbase.h"
 #include "ntgdi.h"
 #include "wine/gdi_driver.h"
+#include "unixlib.h"
 #include "android_native.h"
 
 
diff --git a/dlls/wineandroid.drv/dllmain.c b/dlls/wineandroid.drv/dllmain.c
new file mode 100644
index 00000000000..7886efe4b58
--- /dev/null
+++ b/dlls/wineandroid.drv/dllmain.c
@@ -0,0 +1,36 @@
+/*
+ * wineandroid.drv entry points
+ *
+ * Copyright 2022 Jacek Caban for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "unixlib.h"
+
+
+/***********************************************************************
+ *       dll initialisation routine
+ */
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+{
+    if (reason == DLL_PROCESS_ATTACH) return TRUE;
+
+    DisableThreadLibraryCalls( inst );
+    return !ANDROID_CALL(init, NULL);
+}
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c
index f769608befd..c0b3332df30 100644
--- a/dlls/wineandroid.drv/init.c
+++ b/dlls/wineandroid.drv/init.c
@@ -556,7 +556,7 @@ JavaVM **p_java_vm = NULL;
 jobject *p_java_object = NULL;
 unsigned short *p_java_gdt_sel = NULL;
 
-static BOOL process_attach(void)
+static HRESULT android_init( void *arg )
 {
     pthread_mutexattr_t attr;
     jclass class;
@@ -565,7 +565,7 @@ static BOOL process_attach(void)
     JavaVM *java_vm;
     void *ntdll;
 
-    if (!(ntdll = dlopen( "ntdll.so", RTLD_NOW ))) return FALSE;
+    if (!(ntdll = dlopen( "ntdll.so", RTLD_NOW ))) return STATUS_UNSUCCESSFUL;
 
     p_java_vm = dlsym( ntdll, "java_vm" );
     p_java_object = dlsym( ntdll, "java_object" );
@@ -598,19 +598,20 @@ static BOOL process_attach(void)
 #endif
     }
     __wine_set_user_driver( &android_drv_funcs, WINE_GDI_DRIVER_VERSION );
-    return TRUE;
+    return STATUS_SUCCESS;
 }
 
-/***********************************************************************
- *       dll initialisation routine
- */
-BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
+const unixlib_entry_t __wine_unix_call_funcs[] =
 {
-    switch (reason)
-    {
-    case DLL_PROCESS_ATTACH:
-        DisableThreadLibraryCalls( inst );
-        return process_attach();
-    }
-    return TRUE;
+    android_init,
+};
+
+
+C_ASSERT( ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count );
+
+
+/* FIXME: Use __wine_unix_call instead */
+NTSTATUS unix_call( enum android_funcs code, void *params )
+{
+    return __wine_unix_call_funcs[code]( params );
 }
diff --git a/dlls/wineandroid.drv/unixlib.h b/dlls/wineandroid.drv/unixlib.h
new file mode 100644
index 00000000000..d8327b30f08
--- /dev/null
+++ b/dlls/wineandroid.drv/unixlib.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2022 Jacek Caban for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "ntuser.h"
+#include "wine/unixlib.h"
+
+enum android_funcs
+{
+    unix_init,
+    unix_funcs_count
+};
+
+/* FIXME: Use __wine_unix_call when the rest of the stack is ready */
+extern NTSTATUS unix_call( enum android_funcs func, void *arg ) DECLSPEC_HIDDEN;
+#define ANDROID_CALL(func, params) unix_call( unix_ ## func, params )
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/193



More information about the wine-devel mailing list