Author: damjan
Date: Tue Mar  6 18:27:27 2018
New Revision: 1826021

URL: http://svn.apache.org/viewvc?rev=1826021&view=rev
Log:
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


Added:
    openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi64.dxp
Modified:
    openoffice/trunk/main/sal/systools/win32/kill/kill.cxx
    
openoffice/trunk/main/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
    openoffice/trunk/main/sal/systools/win32/uwinapi/makefile.mk
    openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi.dxp

Modified: openoffice/trunk/main/sal/systools/win32/kill/kill.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/systools/win32/kill/kill.cxx?rev=1826021&r1=1826020&r2=1826021&view=diff
==============================================================================
--- openoffice/trunk/main/sal/systools/win32/kill/kill.cxx (original)
+++ openoffice/trunk/main/sal/systools/win32/kill/kill.cxx Tue Mar  6 18:27:27 
2018
@@ -190,6 +190,7 @@ static BOOL RaiseSignalEx( HANDLE hProce
 
                        if ( fSuccess )
                        {
+#if defined(INTEL)
                                if ( sig )
                                {
                                        DWORD   dwStackBuffer[] =
@@ -207,8 +208,28 @@ static BOOL RaiseSignalEx( HANDLE hProce
                                }
                                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 
);
                        }

Modified: 
openoffice/trunk/main/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp?rev=1826021&r1=1826020&r2=1826021&view=diff
==============================================================================
--- 
openoffice/trunk/main/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
 (original)
+++ 
openoffice/trunk/main/sal/systools/win32/uwinapi/SHCreateItemFromParsingName.cpp
 Tue Mar  6 18:27:27 2018
@@ -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;
+

Modified: openoffice/trunk/main/sal/systools/win32/uwinapi/makefile.mk
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/systools/win32/uwinapi/makefile.mk?rev=1826021&r1=1826020&r2=1826021&view=diff
==============================================================================
--- openoffice/trunk/main/sal/systools/win32/uwinapi/makefile.mk (original)
+++ openoffice/trunk/main/sal/systools/win32/uwinapi/makefile.mk Tue Mar  6 
18:27:27 2018
@@ -51,6 +51,14 @@ LINK=$(WRAPCMD) "$(PSDK_HOME)$/Bin$/Win6
 .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

Modified: openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi.dxp
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi.dxp?rev=1826021&r1=1826020&r2=1826021&view=diff
==============================================================================
--- openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi.dxp (original)
+++ openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi.dxp Tue Mar  6 
18:27:27 2018
@@ -77,4 +77,3 @@ PathRemoveExtensionW
 PathRemoveFileSpecW
 PathSetDlgItemPathW
 PathStripToRootW
-SHCreateItemFromParsingName

Added: openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi64.dxp
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi64.dxp?rev=1826021&view=auto
==============================================================================
--- openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi64.dxp (added)
+++ openoffice/trunk/main/sal/systools/win32/uwinapi/uwinapi64.dxp Tue Mar  6 
18:27:27 2018
@@ -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


Reply via email to