Alexandre Julliard : win32u: Add the infrastructure for building the syscall table.

Alexandre Julliard julliard at winehq.org
Tue Aug 31 15:40:22 CDT 2021


Module: wine
Branch: master
Commit: 33e99ce5f750331a287b033fe98d949011a41f18
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=33e99ce5f750331a287b033fe98d949011a41f18

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug 31 11:18:20 2021 +0200

win32u: Add the infrastructure for building the syscall table.

With a simple NtGdiFlush() export as example.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/win32u/Makefile.in |  8 ++++++
 dlls/win32u/main.c      | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
 dlls/win32u/syscall.c   | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 dlls/win32u/win32u.spec |  3 ++-
 4 files changed, 138 insertions(+), 1 deletion(-)

diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in
index 4147d8586b9..9dce0bc39fd 100644
--- a/dlls/win32u/Makefile.in
+++ b/dlls/win32u/Makefile.in
@@ -1 +1,9 @@
 MODULE    = win32u.dll
+IMPORTS   = ntdll winecrt0
+EXTRALIBS = -Wl,--subsystem,unixlib
+
+EXTRADLLFLAGS = -nodefaultlibs -mno-cygwin -Wb,--syscall-table,1
+
+C_SRCS = \
+	main.c \
+	syscall.c
diff --git a/dlls/win32u/main.c b/dlls/win32u/main.c
new file mode 100644
index 00000000000..f0a052be545
--- /dev/null
+++ b/dlls/win32u/main.c
@@ -0,0 +1,65 @@
+/*
+ * Win32u kernel interface
+ *
+ * Copyright 2021 Alexandre Julliard
+ *
+ * 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 "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "winternl.h"
+#include "wine/exception.h"
+#include "wine/unixlib.h"
+
+extern void *__wine_syscall_dispatcher DECLSPEC_HIDDEN;
+
+static unixlib_handle_t win32u_handle;
+
+void __cdecl __wine_spec_unimplemented_stub( const char *module, const char *function )
+{
+    EXCEPTION_RECORD record;
+
+    record.ExceptionCode    = EXCEPTION_WINE_STUB;
+    record.ExceptionFlags   = EH_NONCONTINUABLE;
+    record.ExceptionRecord  = NULL;
+    record.ExceptionAddress = __wine_spec_unimplemented_stub;
+    record.NumberParameters = 2;
+    record.ExceptionInformation[0] = (ULONG_PTR)module;
+    record.ExceptionInformation[1] = (ULONG_PTR)function;
+    for (;;) RtlRaiseException( &record );
+}
+
+BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved )
+{
+    switch (reason)
+    {
+    case DLL_PROCESS_ATTACH:
+        LdrDisableThreadCalloutsForDll( inst );
+        if (__wine_syscall_dispatcher) break;  /* already set through Wow64Transition */
+        if (!NtQueryVirtualMemory( GetCurrentProcess(), inst, MemoryWineUnixFuncs,
+                                   &win32u_handle, sizeof(win32u_handle), NULL ))
+        {
+            __wine_unix_call( win32u_handle, 0, &__wine_syscall_dispatcher );
+        }
+        break;
+    }
+    return TRUE;
+}
diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c
new file mode 100644
index 00000000000..cb9d88a5b92
--- /dev/null
+++ b/dlls/win32u/syscall.c
@@ -0,0 +1,63 @@
+/*
+ * Unix interface for Win32 syscalls
+ *
+ * Copyright (C) 2021 Alexandre Julliard
+ *
+ * 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
+ */
+
+#if 0
+#pragma makedep unix
+#endif
+
+#include <stdarg.h>
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winnt.h"
+#include "winternl.h"
+#include "wine/unixlib.h"
+
+
+/***********************************************************************
+ *           NtGdiFlush    (win32u.@)
+ */
+BOOL WINAPI NtGdiFlush(void)
+{
+    return TRUE;
+}
+
+static void * const syscalls[] =
+{
+    NtGdiFlush,
+};
+
+static BYTE arguments[ARRAY_SIZE(syscalls)];
+
+static SYSTEM_SERVICE_TABLE syscall_table =
+{
+    (ULONG_PTR *)syscalls,
+    0,
+    ARRAY_SIZE(syscalls),
+    arguments
+};
+
+static NTSTATUS init( void *dispatcher )
+{
+    return ntdll_init_syscalls( 1, &syscall_table, dispatcher );
+}
+
+unixlib_entry_t __wine_unix_call_funcs[] = { init };
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index 57d1871f453..7bb8c334069 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -1,3 +1,4 @@
+@ extern -arch=win32 Wow64Transition __wine_syscall_dispatcher
 @ stub NtBindCompositionSurface
 @ stub NtCloseCompositionInputSink
 @ stub NtCompositionInputThread
@@ -435,7 +436,7 @@
 @ stub NtGdiFillPath
 @ stub NtGdiFillRgn
 @ stub NtGdiFlattenPath
-@ stub NtGdiFlush
+@ stdcall -syscall NtGdiFlush()
 @ stub NtGdiFontIsLinked
 @ stub NtGdiForceUFIMapping
 @ stub NtGdiFrameRgn




More information about the wine-cvs mailing list