sal/systools/win32/kill/kill.cxx                           |   21 ++++++++++++
 sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp |   21 +++++++++++-
 sal/systools/win32/uwinapi/makefile.mk                     |   19 ++++++++---
 sal/systools/win32/uwinapi/uwinapi.dxp                     |    1 
 sal/systools/win32/uwinapi/uwinapi64.dxp                   |   22 +++++++++++++
 5 files changed, 77 insertions(+), 7 deletions(-)

New commits:
commit 6c23838c651a392004274ac27db335eb5b0221a9
Author: Damjan Jovanovic <dam...@apache.org>
Date:   Tue Mar 6 18:27:27 2018 +0000

    Port the "kill" command and some useful parts
    
    of the Windows API wrapper "uwinapi" to AMD64.
    
    We aren't going to rewrite it in AMD64 assembly
    as most of the uwinapi thunked/emulated
    functions are very old, and AMD64 only came out
    in the Windows XP and Windows 2003 era, so only
    function not available on those versions of
    Windows such as SHCreateItemFromParsingName
    and (unbelievably!!) snprintf and co need to
    be ported. And I've used C code instead of
    assembly as it's clearer and performance isn't
    that important nowdays.
    
    Patch by: me

diff --git a/sal/systools/win32/kill/kill.cxx b/sal/systools/win32/kill/kill.cxx
index 76f0b2669d35..ab1cb57d7973 100644
--- a/sal/systools/win32/kill/kill.cxx
+++ b/sal/systools/win32/kill/kill.cxx
@@ -190,6 +190,7 @@ static BOOL RaiseSignalEx( HANDLE hProcess, int sig )
 
             if ( fSuccess )
             {
+#if defined(INTEL)
                 if ( sig )
                 {
                     DWORD   dwStackBuffer[] =
@@ -207,8 +208,28 @@ static BOOL RaiseSignalEx( HANDLE hProcess, int sig )
                 }
                 else
                 {
+                    // FIXME: why? Does AMD64 need it too?
                     aContext.Ecx = aContext.Eax = aContext.Ebx = aContext.Edx 
= aContext.Esi = aContext.Edi = 0;
                 }
+#elif defined(X86_64)
+                if ( sig )
+                {
+                    DWORD   dwStackBuffer[] =
+                    {
+                        (DWORD)(aContext.Rip >> 32),
+                        (DWORD)(aContext.Rip),
+                        SignalToExceptionCode( sig ),
+                        EXCEPTION_NONCONTINUABLE,
+                        0,
+                        0,
+                        0
+                    };
+
+                    aContext.Rsp -= sizeof(dwStackBuffer);
+                    WriteProcessMemory( hProcess, (LPVOID)aContext.Rsp, 
dwStackBuffer, sizeof(dwStackBuffer), NULL );
+                    aContext.Rip = (DWORD64) GetProcAddressEx( hProcess, 
GetModuleHandleA("KERNEL32"), "RaiseException" );
+                }
+#endif
 
                 fSuccess = SetThreadContext( hThread, &aContext );
             }
diff --git a/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp 
b/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
index eb7624ed656c..b59f2972679e 100644
--- a/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
+++ b/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
@@ -26,4 +26,23 @@
 
 #include "macros.h"
 
-DEFINE_DEFAULT_THUNK( shell32, TRYLOAD, HRESULT, WINAPI, 
SHCreateItemFromParsingName, (PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void 
**ppv) )
\ No newline at end of file
+static HRESULT WINAPI SHCreateItemFromParsingName_Failure (PCWSTR pszPath, 
IBindCtx *pbc, REFIID riid, void **ppv)
+{
+    return E_NOTIMPL;
+}
+
+extern HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx 
*pbc, REFIID riid, void **ppv);
+
+static HRESULT WINAPI SHCreateItemFromParsingName_Thunk (PCWSTR pszPath, 
IBindCtx *pbc, REFIID riid, void **ppv)
+{
+    ResolveThunk_TRYLOAD( (FARPROC*)&pSHCreateItemFromParsingName, 
"shell32.dll", "SHCreateItemFromParsingName", 0, 
(FARPROC)SHCreateItemFromParsingName_Failure);
+    return pSHCreateItemFromParsingName(pszPath, pbc, riid, ppv);
+}
+
+extern "C" HRESULT WINAPI SHCreateItemFromParsingName (PCWSTR pszPath, 
IBindCtx *pbc, REFIID riid, void **ppv)
+{
+    return pSHCreateItemFromParsingName(pszPath, pbc, riid, ppv);
+}
+
+HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR pszPath, IBindCtx *pbc, 
REFIID riid, void **ppv) = SHCreateItemFromParsingName_Thunk;
+
diff --git a/sal/systools/win32/uwinapi/makefile.mk 
b/sal/systools/win32/uwinapi/makefile.mk
index effeea41f8b3..ff4aa4f24fd8 100644
--- a/sal/systools/win32/uwinapi/makefile.mk
+++ b/sal/systools/win32/uwinapi/makefile.mk
@@ -51,6 +51,14 @@ LINK=$(WRAPCMD) "$(PSDK_HOME)$/Bin$/Win64$/LINK.EXE"
 .ENDIF
 
 SLOFILES=\
+        $(SLO)$/ResolveThunk.obj\
+        $(SLO)$/SHCreateItemFromParsingName.obj\
+        $(SLO)$/snprintf.obj\
+        $(SLO)$/snwprintf.obj
+
+
+.IF "$(CPUNAME)"=="INTEL"
+SLOFILES+=\
         $(SLO)$/CheckTokenMembership.obj\
         $(SLO)$/CommandLineToArgvW.obj\
         $(SLO)$/CopyFileExA.obj\
@@ -71,10 +79,7 @@ SLOFILES=\
         $(SLO)$/MoveFileExA.obj\
         $(SLO)$/MoveFileExW.obj\
         $(SLO)$/toolhelp.obj\
-        $(SLO)$/ResolveThunk.obj\
         $(SLO)$/ResolveUnicows.obj\
-        $(SLO)$/snprintf.obj\
-        $(SLO)$/snwprintf.obj\
         $(SLO)$/FindFirstVolumeA.obj\
         $(SLO)$/FindFirstVolumeW.obj\
         $(SLO)$/FindNextVolumeA.obj\
@@ -103,8 +108,8 @@ SLOFILES=\
         $(SLO)$/PathRemoveExtensionW.obj\
         $(SLO)$/PathRemoveFileSpecW.obj\
         $(SLO)$/PathSetDlgItemPathW.obj\
-        $(SLO)$/PathStripToRootW.obj\
-        $(SLO)$/SHCreateItemFromParsingName.obj
+        $(SLO)$/PathStripToRootW.obj
+.ENDIF
         
 SHL1TARGET=$(TARGET)
 SHL1IMPLIB=$(SHL1TARGET)
@@ -116,9 +121,13 @@ DEF1EXPORTFILE=\
     unicows_mingw.dxp
 .ELSE
 DEF1EXPORTFILE=\
+    $(SHL1TARGET)64.dxp
+.IF "$(CPUNAME)"=="INTEL"
+DEF1EXPORTFILE+=\
     $(SHL1TARGET).dxp\
     unicows.dxp
 .ENDIF
+.ENDIF
 DEF1DEPN=\
         $(DEF1EXPORTFILE)\
         makefile.mk
diff --git a/sal/systools/win32/uwinapi/uwinapi.dxp 
b/sal/systools/win32/uwinapi/uwinapi.dxp
index 61583f996bc6..309c47bcfafa 100644
--- a/sal/systools/win32/uwinapi/uwinapi.dxp
+++ b/sal/systools/win32/uwinapi/uwinapi.dxp
@@ -77,4 +77,3 @@ PathRemoveExtensionW
 PathRemoveFileSpecW
 PathSetDlgItemPathW
 PathStripToRootW
-SHCreateItemFromParsingName
diff --git a/sal/systools/win32/uwinapi/uwinapi64.dxp 
b/sal/systools/win32/uwinapi/uwinapi64.dxp
new file mode 100644
index 000000000000..3212475dbd1a
--- /dev/null
+++ b/sal/systools/win32/uwinapi/uwinapi64.dxp
@@ -0,0 +1,22 @@
+;*************************************************************************
+;
+;  Licensed to the Apache Software Foundation (ASF) under one
+;  or more contributor license agreements.  See the NOTICE file
+;  distributed with this work for additional information
+;  regarding copyright ownership.  The ASF licenses this file
+;  to you under the Apache License, Version 2.0 (the
+;  "License"); you may not use this file except in compliance
+;  with the License.  You may obtain a copy of the License at
+;
+;    http://www.apache.org/licenses/LICENSE-2.0
+;
+;  Unless required by applicable law or agreed to in writing,
+;  software distributed under the License is distributed on an
+;  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+;  KIND, either express or implied.  See the License for the
+;  specific language governing permissions and limitations
+;  under the License.
+;
+;*************************************************************************
+
+SHCreateItemFromParsingName
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to