Module: wine
Branch: master
Commit: 91d5d5674892028a4423a86b5c6b85f7d5758b12
URL: https://source.winehq.org/git/wine.git/?a=commit;h=91d5d5674892028a4423a86b…
Author: Ken Thomases <ken(a)codeweavers.com>
Date: Wed Mar 6 18:59:37 2019 -0600
libwine: On Mac, use a more capable Mach function to map memory and avoid calling mmap() in some cases.
Signed-off-by: Ken Thomases <ken(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
libs/wine/mmap.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/libs/wine/mmap.c b/libs/wine/mmap.c
index 458cc13..affdc0a 100644
--- a/libs/wine/mmap.c
+++ b/libs/wine/mmap.c
@@ -165,23 +165,29 @@ static int try_mmap_fixed (void *addr, size_t len, int prot, int flags,
#elif defined(__APPLE__)
#include <mach/mach_init.h>
-#include <mach/vm_map.h>
+#include <mach/mach_vm.h>
/*
- * On Darwin, we can use the Mach call vm_allocate to allocate
- * anonymous memory at the specified address, and then use mmap with
- * MAP_FIXED to replace the mapping.
+ * On Darwin, we can use the Mach call mach_vm_map to allocate
+ * anonymous memory at the specified address and then, if necessary, use
+ * mmap with MAP_FIXED to replace the mapping.
*/
static int try_mmap_fixed (void *addr, size_t len, int prot, int flags,
int fildes, off_t off)
{
- vm_address_t result = (vm_address_t)addr;
+ mach_vm_address_t result = (mach_vm_address_t)addr;
+ int vm_flags = VM_FLAGS_FIXED;
- if (!vm_allocate(mach_task_self(),&result,len,0))
+ if (flags & MAP_NOCACHE)
+ vm_flags |= VM_FLAGS_NO_CACHE;
+ if (!mach_vm_map( mach_task_self(), &result, len, 0, vm_flags, MEMORY_OBJECT_NULL,
+ 0, 0, prot, VM_PROT_ALL, VM_INHERIT_COPY ))
{
- if (mmap( (void *)result, len, prot, flags | MAP_FIXED, fildes, off ) != MAP_FAILED)
+ flags |= MAP_FIXED;
+ if (((flags & ~(MAP_NORESERVE | MAP_NOCACHE)) == (MAP_ANON | MAP_FIXED | MAP_PRIVATE)) ||
+ mmap( (void *)result, len, prot, flags, fildes, off ) != MAP_FAILED)
return 1;
- vm_deallocate(mach_task_self(),result,len);
+ mach_vm_deallocate(mach_task_self(),result,len);
}
return 0;
}
Module: wine
Branch: master
Commit: 65f30810c17949498c95d64be7f3bdc6f48ae7d4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=65f30810c17949498c95d64b…
Author: Hans Leidekker <hans(a)codeweavers.com>
Date: Thu Mar 7 14:14:13 2019 +0100
amsi: Add stub implementations for a couple of functions.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/amsi/Makefile.in | 3 +++
dlls/amsi/amsi.spec | 12 +++++-----
dlls/amsi/main.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
include/Makefile.in | 1 +
include/amsi.idl | 36 ++++++++++++++++++++++++++++
5 files changed, 111 insertions(+), 6 deletions(-)
diff --git a/dlls/amsi/Makefile.in b/dlls/amsi/Makefile.in
index dfaec30..213d3e0 100644
--- a/dlls/amsi/Makefile.in
+++ b/dlls/amsi/Makefile.in
@@ -1 +1,4 @@
MODULE = amsi.dll
+
+C_SRCS = \
+ main.c
diff --git a/dlls/amsi/amsi.spec b/dlls/amsi/amsi.spec
index 6c2b4ae..27e6b3d 100644
--- a/dlls/amsi/amsi.spec
+++ b/dlls/amsi/amsi.spec
@@ -1,12 +1,12 @@
-@ stub AmsiCloseSession
-@ stub AmsiInitialize
-@ stub AmsiOpenSession
-@ stub AmsiScanBuffer
-@ stub AmsiScanString
+@ stdcall AmsiCloseSession(ptr ptr)
+@ stdcall AmsiInitialize(wstr ptr)
+@ stdcall AmsiOpenSession(ptr ptr)
+@ stdcall AmsiScanBuffer(ptr ptr long wstr ptr ptr)
+@ stdcall AmsiScanString(ptr wstr wstr ptr ptr)
@ stub AmsiUacInitialize
@ stub AmsiUacScan
@ stub AmsiUacUninitialize
-@ stub AmsiUninitialize
+@ stdcall AmsiUninitialize(ptr)
@ stub DllCanUnloadNow
@ stub DllGetClassObject
@ stub DllRegisterServer
diff --git a/dlls/amsi/main.c b/dlls/amsi/main.c
new file mode 100644
index 0000000..f56e699
--- /dev/null
+++ b/dlls/amsi/main.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2019 Hans Leidekker 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 "amsi.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(amsi);
+
+HRESULT WINAPI AmsiInitialize( const WCHAR *appname, HAMSICONTEXT *context )
+{
+ FIXME( "%s, %p\n", debugstr_w(appname), context );
+ *context = (HAMSICONTEXT)0xdeadbeef;
+ return S_OK;
+}
+
+HRESULT WINAPI AmsiOpenSession( HAMSICONTEXT context, HAMSISESSION *session )
+{
+ FIXME( "%p, %p\n", context, session );
+ *session = (HAMSISESSION)0xdeadbeef;
+ return S_OK;
+}
+
+void WINAPI AmsiCloseSession( HAMSICONTEXT context, HAMSISESSION session )
+{
+ FIXME( "%p, %p\n", context, session );
+}
+
+HRESULT WINAPI AmsiScanBuffer( HAMSICONTEXT context, void *buffer, ULONG length, const WCHAR *name,
+ HAMSISESSION session, AMSI_RESULT *result )
+{
+ FIXME( "%p, %p, %u, %s, %p, %p\n", context, buffer, length, debugstr_w(name), session, result );
+ *result = AMSI_RESULT_NOT_DETECTED;
+ return S_OK;
+}
+
+HRESULT WINAPI AmsiScanString( HAMSICONTEXT context, const WCHAR *string, const WCHAR *name,
+ HAMSISESSION session, AMSI_RESULT *result )
+{
+ FIXME( "%p, %s, %s, %p, %p\n", context, debugstr_w(string), debugstr_w(name), session, result );
+ *result = AMSI_RESULT_NOT_DETECTED;
+ return S_OK;
+}
+
+void WINAPI AmsiUninitialize( HAMSICONTEXT context )
+{
+ FIXME( "%p\n", context );
+}
diff --git a/include/Makefile.in b/include/Makefile.in
index c9f5be9..2817c10 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -11,6 +11,7 @@ SOURCES = \
advpub.h \
af_irda.h \
amaudio.h \
+ amsi.idl \
amstream.idl \
amvideo.idl \
appcompatapi.h \
diff --git a/include/amsi.idl b/include/amsi.idl
new file mode 100644
index 0000000..31303a3
--- /dev/null
+++ b/include/amsi.idl
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019 Hans Leidekker 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
+ */
+
+cpp_quote("DECLARE_HANDLE(HAMSICONTEXT);")
+cpp_quote("DECLARE_HANDLE(HAMSISESSION);")
+
+typedef [v1_enum] enum AMSI_RESULT
+{
+ AMSI_RESULT_CLEAN = 0x00,
+ AMSI_RESULT_NOT_DETECTED = 0x01,
+ AMSI_RESULT_BLOCKED_BY_ADMIN_START = 0x4000,
+ AMSI_RESULT_BLOCKED_BY_ADMIN_END = 0x4fff,
+ AMSI_RESULT_DETECTED = 0x8000,
+} AMSI_RESULT;
+
+cpp_quote("void WINAPI AmsiCloseSession(HAMSICONTEXT,HAMSISESSION);")
+cpp_quote("HRESULT WINAPI AmsiInitialize(const WCHAR*,HAMSICONTEXT*);")
+cpp_quote("HRESULT WINAPI AmsiOpenSession(HAMSICONTEXT,HAMSISESSION*);")
+cpp_quote("HRESULT WINAPI AmsiScanBuffer(HAMSICONTEXT,void*,ULONG,const WCHAR*,HAMSISESSION,AMSI_RESULT*);")
+cpp_quote("HRESULT WINAPI AmsiScanString(HAMSICONTEXT,const WCHAR*,const WCHAR *,HAMSISESSION,AMSI_RESULT*);")
+cpp_quote("void WINAPI AmsiUninitialize(HAMSICONTEXT);")