Killing even the last remenants of rebase
Change-Id: I649275360a1d57aeec03d3cecdb02f5f7ccdd1e8
This commit is contained in:
parent
77f8ca7142
commit
bf7657fc2a
@ -824,17 +824,6 @@ End
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(WNT) && defined(HAVE_WINDOWS_SDK)
|
||||
|
||||
File gid_File_Lib_Rebasemsi
|
||||
LIB_FILE_BODY;
|
||||
Name = "rebase.dll";
|
||||
Dir = SCP2_OOO_BIN_DIR;
|
||||
Styles = (PACKED,BINARYTABLE,BINARYTABLE_ONLY,DONTRENAMEINPATCH);
|
||||
End
|
||||
|
||||
#endif /* WNT && HAVE_WINDOWS_SDK */
|
||||
|
||||
STD_LIB_FILE( gid_File_Lib_Lng, lng)
|
||||
|
||||
File gid_File_Lib_Localedata_En
|
||||
|
@ -401,16 +401,6 @@ WindowsCustomAction gid_Customaction_SortTree
|
||||
Assignment1 = ("ControlEvent", "CustomSetup", "Tree", "DoAction", "SortTree", "1", "1");
|
||||
End
|
||||
|
||||
WindowsCustomAction gid_Customaction_RebaseLibrariesonproperties
|
||||
Name = "RebaseLibrariesOnProperties";
|
||||
Typ = "65";
|
||||
Source = "rebase.dll";
|
||||
Target = "RebaseLibrariesOnProperties";
|
||||
Inbinarytable = 1;
|
||||
Assignment1 = ("InstallExecuteSequence", "VersionNT < 600 And Not REMOVE=\"ALL\"", "end");
|
||||
Assignment2 = ("AdminExecuteSequence", "VersionNT < 600 And Not REMOVE=\"ALL\"", "end");
|
||||
End
|
||||
|
||||
WindowsCustomAction gid_Customaction_LookForRegisteredExtensions
|
||||
Name = "LookForRegisteredExtensions";
|
||||
Typ = "65";
|
||||
|
@ -5,7 +5,6 @@ pk setup_native\scripts nmake - u sn_scri
|
||||
pk setup_native\source\mac nmake - u sn_mac NULL
|
||||
pk setup_native\source\packinfo nmake - w sn_packinfo NULL
|
||||
pk setup_native\source\win32\customactions\tools nmake - w sn_tools NULL
|
||||
pk setup_native\source\win32\customactions\rebase nmake - w sn_rebase NULL
|
||||
pk setup_native\source\win32\customactions\regactivex nmake - w sn_regactivex NULL
|
||||
pk setup_native\source\win32\customactions\regpatchactivex nmake - w sn_regpatchactivex NULL
|
||||
pk setup_native\source\win32\customactions\reg4allmsdoc nmake - w sn_reg4allmsdoc NULL
|
||||
|
@ -1,82 +0,0 @@
|
||||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org 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 version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..$/..$/..$/..
|
||||
PRJNAME=setup_native
|
||||
TARGET=rebase
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
LIBTARGET=NO
|
||||
ENABLE_EXCEPTIONS=TRUE
|
||||
NO_DEFAULT_STL=TRUE
|
||||
DYNAMIC_CRT=
|
||||
USE_DEFFILE=TRUE
|
||||
MINGW_NODLL=YES
|
||||
|
||||
.INCLUDE : settings.mk
|
||||
|
||||
UWINAPILIB=
|
||||
|
||||
# --- Files --------------------------------------------------------
|
||||
|
||||
.IF "$(GUI)"=="WNT" && "$(WINDOWS_SDK_HOME)"!=""
|
||||
|
||||
STDSHL += \
|
||||
$(ADVAPI32LIB)\
|
||||
$(SHELL32LIB)\
|
||||
$(MSILIB)
|
||||
|
||||
.IF "$(COM)"=="GCC"
|
||||
STDSHL+= \
|
||||
$(KERNEL32LIB)\
|
||||
-lmsvcrt \
|
||||
$(PSDK_HOME)$/lib$/imagehlp.lib
|
||||
.ELSE
|
||||
STDSHL+= \
|
||||
Imagehlp.lib
|
||||
.ENDIF
|
||||
|
||||
SHL1OBJS = \
|
||||
$(SLO)$/rebase.obj
|
||||
|
||||
SHL1TARGET = $(TARGET)
|
||||
SHL1IMPLIB = i$(TARGET)
|
||||
|
||||
SHL1DEF = $(MISC)$/$(SHL1TARGET).def
|
||||
SHL1BASE = 0x1c000000
|
||||
DEF1NAME=$(SHL1TARGET)
|
||||
SHL1DEPN=$(SHL1OBJS)
|
||||
DEF1EXPORTFILE=$(TARGET).dxp
|
||||
|
||||
.ENDIF
|
||||
|
||||
# --- Targets --------------------------------------------------------------
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
||||
# -------------------------------------------------------------------------
|
@ -1,227 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
#undef UNICODE
|
||||
#undef _UNICODE
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1) /* disable warnings within system headers */
|
||||
#endif
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <msiquery.h>
|
||||
#include <imagehlp.h>
|
||||
#include <tchar.h>
|
||||
#define STRSAFE_NO_DEPRECATE
|
||||
#include <strsafe.h>
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
const DWORD PE_Signature = 0x00004550;
|
||||
typedef std::pair< std::string, bool > StringPair;
|
||||
typedef boost::unordered_map< std::string, bool > ExcludeLibsMap;
|
||||
|
||||
#ifdef DEBUG
|
||||
static void OutputDebugStringFormat( LPCSTR pFormat, ... )
|
||||
{
|
||||
CHAR buffer[1024];
|
||||
va_list args;
|
||||
|
||||
va_start( args, pFormat );
|
||||
StringCchVPrintfA( buffer, sizeof(buffer), pFormat, args );
|
||||
OutputDebugStringA( buffer );
|
||||
}
|
||||
#else
|
||||
static void OutputDebugStringFormat( LPCSTR, ... )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool IsValidHandle( HANDLE handle )
|
||||
{
|
||||
return NULL != handle && INVALID_HANDLE_VALUE != handle;
|
||||
}
|
||||
|
||||
static std::string GetMsiProperty(MSIHANDLE handle, const std::string& sProperty)
|
||||
{
|
||||
std::string result;
|
||||
TCHAR szDummy[1] = TEXT("");
|
||||
DWORD nChars = 0;
|
||||
|
||||
if (MsiGetProperty(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
|
||||
{
|
||||
DWORD nBytes = ++nChars * sizeof(TCHAR);
|
||||
LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes));
|
||||
ZeroMemory( buffer, nBytes );
|
||||
MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars);
|
||||
result = buffer;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static BOOL rebaseImage( const std::string& filePath, LPVOID address )
|
||||
{
|
||||
ULONG ulOldImageSize;
|
||||
ULONG_PTR lpOldImageBase;
|
||||
ULONG ulNewImageSize;
|
||||
ULONG_PTR lpNewImageBase = reinterpret_cast<ULONG_PTR>(address);
|
||||
|
||||
BOOL bResult = ReBaseImage(
|
||||
(PSTR)filePath.c_str(),
|
||||
(PSTR)"",
|
||||
TRUE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
0,
|
||||
&ulOldImageSize,
|
||||
&lpOldImageBase,
|
||||
&ulNewImageSize,
|
||||
&lpNewImageBase,
|
||||
(ULONG)time(NULL) );
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static BOOL rebaseImage( MSIHANDLE /*handle*/, const std::string& sFilePath, LPVOID address )
|
||||
{
|
||||
std::string mystr;
|
||||
mystr = "Full file: " + sFilePath;
|
||||
|
||||
BOOL bResult = rebaseImage( sFilePath, address );
|
||||
|
||||
if ( !bResult )
|
||||
{
|
||||
OutputDebugStringFormat( "Rebasing library %s failed", mystr.c_str() );
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static BOOL rebaseImagesInFolder( MSIHANDLE handle, const std::string& sPath, LPVOID address, ExcludeLibsMap& rExcludeMap )
|
||||
{
|
||||
std::string sDir = sPath;
|
||||
std::string sPattern = sPath + TEXT("*.dll");
|
||||
WIN32_FIND_DATA aFindFileData;
|
||||
|
||||
HANDLE hFind = FindFirstFile( sPattern.c_str(), &aFindFileData );
|
||||
if ( IsValidHandle(hFind) )
|
||||
{
|
||||
BOOL fSuccess = false;
|
||||
|
||||
do
|
||||
{
|
||||
std::string sFileName = aFindFileData.cFileName;
|
||||
if ( rExcludeMap.find( sFileName ) == rExcludeMap.end() )
|
||||
{
|
||||
OutputDebugStringFormat( "Rebase library: %s", sFileName.c_str() );
|
||||
std::string sLibFile = sDir + sFileName;
|
||||
rebaseImage( handle, sLibFile, address );
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebugStringFormat( "Exclude library %s from rebase", sFileName.c_str() );
|
||||
}
|
||||
|
||||
fSuccess = FindNextFile( hFind, &aFindFileData );
|
||||
}
|
||||
while ( fSuccess );
|
||||
|
||||
FindClose( hFind );
|
||||
}
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL rebaseImages( MSIHANDLE handle, LPVOID pAddress, ExcludeLibsMap& rMap )
|
||||
{
|
||||
std::string sInstallPath = GetMsiProperty(handle, TEXT("INSTALLLOCATION"));
|
||||
|
||||
std::string sBasisDir = sInstallPath + TEXT("Basis\\program\\");
|
||||
std::string sOfficeDir = sInstallPath + TEXT("program\\");
|
||||
std::string sUreDir = sInstallPath + TEXT("URE\\bin\\");
|
||||
|
||||
BOOL bResult = rebaseImagesInFolder( handle, sBasisDir, pAddress, rMap );
|
||||
bResult &= rebaseImagesInFolder( handle, sOfficeDir, pAddress, rMap );
|
||||
bResult &= rebaseImagesInFolder( handle, sUreDir, pAddress, rMap );
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static BOOL IsServerSystem( MSIHANDLE /*handle*/ )
|
||||
{
|
||||
OSVERSIONINFOEX osVersionInfoEx;
|
||||
osVersionInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osVersionInfoEx));
|
||||
|
||||
if ( osVersionInfoEx.wProductType != VER_NT_WORKSTATION )
|
||||
{
|
||||
OutputDebugStringFormat( "Server system detected. No rebase necessary!" );
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebugStringFormat( "Client system detected. Rebase necessary!" );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void InitExcludeFromRebaseList( MSIHANDLE handle, ExcludeLibsMap& rMap )
|
||||
{
|
||||
size_t nPos( 0 );
|
||||
const TCHAR cDelim = ',';
|
||||
std::string sLibsExcluded = GetMsiProperty(handle, TEXT("EXCLUDE_FROM_REBASE"));
|
||||
|
||||
while ( nPos < sLibsExcluded.size() )
|
||||
{
|
||||
size_t nDelPos = sLibsExcluded.find_first_of( cDelim, nPos );
|
||||
|
||||
std::string sExcludedLibName;
|
||||
if ( nDelPos != std::string::npos )
|
||||
{
|
||||
sExcludedLibName = sLibsExcluded.substr( nPos, nDelPos - nPos );
|
||||
nPos = nDelPos+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sExcludedLibName = sLibsExcluded.substr( nPos );
|
||||
nPos = sLibsExcluded.size();
|
||||
}
|
||||
|
||||
if ( sExcludedLibName.size() > 0 )
|
||||
{
|
||||
OutputDebugStringFormat( "Insert library %s into exclude from rebase list", sExcludedLibName.c_str() );
|
||||
rMap.insert( StringPair( sExcludedLibName, true ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" BOOL __stdcall RebaseLibrariesOnProperties( MSIHANDLE handle )
|
||||
{
|
||||
static LPVOID pDefault = reinterpret_cast<LPVOID>(0x10000000);
|
||||
|
||||
OutputDebugStringFormat( "RebaseLibrariesOnProperties has been called" );
|
||||
std::string sDontOptimizeLibs = GetMsiProperty(handle, TEXT("DONTOPTIMIZELIBS"));
|
||||
if ( sDontOptimizeLibs.length() > 0 && sDontOptimizeLibs == "1" )
|
||||
{
|
||||
OutputDebugStringFormat( "Don't optimize libraries set. No rebase necessary!" );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( !IsServerSystem( handle ))
|
||||
{
|
||||
ExcludeLibsMap aExcludeLibsMap;
|
||||
InitExcludeFromRebaseList( handle, aExcludeLibsMap );
|
||||
|
||||
return rebaseImages( handle, pDefault, aExcludeLibsMap );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -1 +0,0 @@
|
||||
RebaseLibrariesOnProperties
|
Loading…
x
Reference in New Issue
Block a user