From fbbe9c7b24bb9b0ad47a1a7669a459b972b97982 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Tue, 28 Jul 2009 09:21:19 +0000 Subject: CWS-TOOLING: integrate CWS fwk112 2009-07-17 08:54:15 +0200 cd r274075 : #i102094# MinGW needs additional path info for linking 2009-07-13 15:09:07 +0200 cd r273938 : #i102094# Add special part for MinGW linking to imagehlp.lib 2009-07-10 08:05:14 +0200 cd r273871 : #i102094# Use size_t for constant values to fix warnings 2009-07-09 13:45:27 +0200 cd r273859 : #i102094# MinGW needs include malloc.h for function alloca 2009-07-09 12:37:39 +0200 cd r273856 : #i102094# Fix problem with signed/unsigned comparision warning 2009-06-19 11:34:40 +0200 cd r273154 : #i102094# Added comment for future maintenance 2009-06-19 11:34:11 +0200 cd r273153 : #i102094# Added comment for future maintenance 2009-06-16 17:25:03 +0200 cd r273032 : #i102094# Extend md5.cxx to detect Windows PE images and ignore PE header date+time/checksum to have the same MD5 checksum 2009-06-16 17:22:47 +0200 cd r273031 : #i102094# Added rebase custom action 2009-06-16 17:01:12 +0200 cd r273030 : #i102094# Use rebaseoo.exe instead of rebase.exe to prevent clash with build tool 2009-06-16 17:00:34 +0200 cd r273029 : #i102094# Execute rebase custom action for administrative installations 2009-06-16 16:59:11 +0200 cd r273028 : #i102094# Small changes for rebaseoo/rebasegui tools 2009-06-16 16:58:29 +0200 cd r273027 : i102094# Deliver rebase tool as rebaseoo.exe as build env already use a rebase.exe 2009-06-16 16:57:15 +0200 cd r273026 : i102094# Crash reporter should not use PE header date+time/checksum data for MD5 checksum 2009-05-29 17:03:26 +0200 cd r272474 : #i102094# Fix wrong deliver statement 2009-05-29 14:55:35 +0200 cd r272459 : #i102904# Make executables more robust. Add error message if installation cannot be found 2009-05-28 17:41:07 +0200 cd r272422 : CWS-TOOLING: rebase CWS fwk112 to trunk@272291 (milestone: DEV300:m49) 2009-05-28 17:31:27 +0200 cd r272421 : #i10000# Resolve conflict on merge 2009-05-28 15:32:09 +0200 cd r272409 : #i102094# Added resource and localization files for rebasegui tool 2009-05-27 13:56:33 +0200 cd r272341 : #i102094# Added new command line tool to rebase libraries to a default virtual load address. Additional GUI tool to check the state of an installation 2009-05-26 10:49:20 +0200 cd r272285 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-26 10:40:02 +0200 cd r272282 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-26 08:57:24 +0200 cd r272280 : #i102094# Fixed wrong variable usage 2009-05-26 08:41:29 +0200 cd r272278 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-20 16:47:24 +0200 cd r272141 : #102094# Added missing include statement for debug build 2009-05-20 15:39:21 +0200 is r272136 : #102094# rebase to default value in installation 2009-05-20 15:38:38 +0200 is r272135 : #102094# rebase to default value in installation 2009-05-20 15:37:45 +0200 is r272134 : #102094# rebase to default value in installation --- desktop/prj/build.lst | 3 +- desktop/prj/d.lst | 2 + desktop/win32/source/rebase/Resource.h | 41 ++++++ desktop/win32/source/rebase/makefile.mk | 93 ++++++++++++++ desktop/win32/source/rebase/rcfooter.txt | 2 + desktop/win32/source/rebase/rcheader.txt | 39 ++++++ desktop/win32/source/rebase/rctmpl.txt | 9 ++ desktop/win32/source/rebase/rebase.cxx | 190 ++++++++++++++++++++++++++++ desktop/win32/source/rebase/rebasegui.cxx | 200 ++++++++++++++++++++++++++++++ desktop/win32/source/rebase/rebasegui.ulf | 11 ++ 10 files changed, 589 insertions(+), 1 deletion(-) create mode 100644 desktop/win32/source/rebase/Resource.h create mode 100644 desktop/win32/source/rebase/makefile.mk create mode 100644 desktop/win32/source/rebase/rcfooter.txt create mode 100644 desktop/win32/source/rebase/rcheader.txt create mode 100644 desktop/win32/source/rebase/rctmpl.txt create mode 100644 desktop/win32/source/rebase/rebase.cxx create mode 100644 desktop/win32/source/rebase/rebasegui.cxx create mode 100644 desktop/win32/source/rebase/rebasegui.ulf (limited to 'desktop') diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 4b6a5664e3d8..3aa56e273ff3 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -16,6 +16,7 @@ dt desktop\win32\source\guiloader nmake - w dt_guiloader dt_wrapper.w dt_inc N dt desktop\win32\source\guistdio nmake - w dt_guistdio dt_inc NULL dt desktop\win32\source\applauncher nmake - w dt_applauncher dt_inc NULL dt desktop\win32\source\applauncher\ooo nmake - w dt_applauncher_ooo dt_applauncher.w dt_inc NULL +dt desktop\win32\source\rebase nmake - w dt_rebase dt_inc NULL dt desktop\os2\source\applauncher nmake - p dt_applauncher dt_inc NULL dt desktop\unx\source\officeloader nmake - u dt_officeloader_unx dt_inc NULL dt desktop\source\pagein nmake - u dt_pagein dt_inc NULL @@ -35,5 +36,5 @@ dt desktop\source\deployment\registry\configuration nmake - all dt_dp_registry_c dt desktop\source\deployment\registry\help nmake - all dt_dp_registry_help dt_inc NULL dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_executable dt_inc NULL dt desktop\scripts nmake - u dt_scripts dt_inc NULL -dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr NULL +dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL dt desktop\zipintro nmake - all dt_zipintro NULL diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst index 78897216c386..eb0d93886e8a 100644 --- a/desktop/prj/d.lst +++ b/desktop/prj/d.lst @@ -82,6 +82,8 @@ mkdir: %_DEST%\bin%_EXT%\odf4ms ..\%__SRC%\bin\unopkga*.dll %_DEST%\bin%_EXT%\unopkga*.dll ..\%__SRC%\lib\libunopkgapp.dylib %_DEST%\lib%_EXT%\libunopkgapp.dylib ..\%__SRC%\lib\libunopkgapp.so %_DEST%\lib%_EXT%\libunopkgapp.so +..\%__SRC%\bin\rebasegui.exe %_DEST%\bin%_EXT%\rebasegui.exe +..\%__SRC%\bin\rebaseoo.exe %_DEST%\bin%_EXT%\rebaseoo.exe ..\%__SRC%\bin\pagein %_DEST%\bin%_EXT%\pagein ..\%__SRC%\misc\pagein-* %_DEST%\bin%_EXT%\pagein-* diff --git a/desktop/win32/source/rebase/Resource.h b/desktop/win32/source/rebase/Resource.h new file mode 100644 index 000000000000..2ebbc5c5bfb7 --- /dev/null +++ b/desktop/win32/source/rebase/Resource.h @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Resource.h,v $ + * $Revision: 1.7 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _RESOURCE_H +#define _RESOURCE_H + +#define IDS_APP_TITLE 10 +#define IDS_MSG_OPTIMIZED_FOR_CLIENT 11 +#define IDS_MSG_OPTIMIZED_FOR_SERVER 12 +#define IDS_MSG_NO_INSTALLATION_FOUND 13 + +#define IDI_REBASEGUI 99 + +#endif diff --git a/desktop/win32/source/rebase/makefile.mk b/desktop/win32/source/rebase/makefile.mk new file mode 100644 index 000000000000..8114403a8e8b --- /dev/null +++ b/desktop/win32/source/rebase/makefile.mk @@ -0,0 +1,93 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.4 $ +# +# 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 +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=desktop +TARGET=rebasegui +LIBTARGET=NO +TARGETTYPE=GUI +UWINAPILIB= + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +OBJFILES = \ + $(OBJ)$/rebase.obj \ + $(OBJ)$/rebasegui.obj + +ULFFILES= rebasegui.ulf + +.IF "$(WITH_LANG)"!="" +ULFDIR:=$(COMMONMISC)$/$(TARGET) +.ELSE # "$(WITH_LANG)"!="" +ULFDIR:=. +.ENDIF # "$(WITH_LANG)"!="" + +RCFILES= $(RES)$/$(TARGET).rc + +# --- Targets ------------------------------------------------------ + +APP1NOSAL= TRUE +APP1TARGET= rebaseoo + +APP1STDLIBS= $(SHELL32LIB) $(SOLARLIBDIR)$/pathutils-obj.obj +.IF "$(COM)"=="GCC" + APP1STDLIBS+=$(PSDK_HOME)$/lib$/imagehlp.lib +.ELSE + APP1STDLIBS+=imagehlp.lib +.ENDIF + +APP1OBJS= $(OBJ)$/rebase.obj + +APP1RPATH= BRAND + +APP2NOSAL= TRUE +APP2TARGET= rebasegui +APP2STDLIBS= $(SHELL32LIB) $(SOLARLIBDIR)$/pathutils-obj.obj + +APP2OBJS= $(OBJ)$/rebasegui.obj + +APP2DEF= $(MISC)$/$(TARGET).def +APP2RPATH= BRAND + +APP2RES= $(RES)$/$(TARGET).res +APP2NOSVRES= $(RES)$/$(TARGET).res + +# --- setup -------------------------------------------------------------- + +.INCLUDE : target.mk + +$(RCFILES) : $(ULFDIR)$/rebasegui.ulf makefile.mk rcfooter.txt rcheader.txt rctmpl.txt + $(WRAPCMD) lngconvex.exe -ulf $(ULFDIR)$/rebasegui.ulf -rc $(RCFILES) -rct rctmpl.txt -rch rcheader.txt -rcf rcfooter.txt diff --git a/desktop/win32/source/rebase/rcfooter.txt b/desktop/win32/source/rebase/rcfooter.txt new file mode 100644 index 000000000000..3237729437f5 --- /dev/null +++ b/desktop/win32/source/rebase/rcfooter.txt @@ -0,0 +1,2 @@ + +// The end diff --git a/desktop/win32/source/rebase/rcheader.txt b/desktop/win32/source/rebase/rcheader.txt new file mode 100644 index 000000000000..56afc5377920 --- /dev/null +++ b/desktop/win32/source/rebase/rcheader.txt @@ -0,0 +1,39 @@ +#if defined(_MSC_VER) && (_MSC_VER < 1500) +#include +#else +#define WINVER 0x0500 +#include +#define IDC_STATIC (-1) +#endif +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,1,1,0 + PRODUCTVERSION 1,1,1,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + diff --git a/desktop/win32/source/rebase/rctmpl.txt b/desktop/win32/source/rebase/rctmpl.txt new file mode 100644 index 000000000000..97a2775e9b02 --- /dev/null +++ b/desktop/win32/source/rebase/rctmpl.txt @@ -0,0 +1,9 @@ +// String Table + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE %APP_TITLE% + IDS_MSG_OPTIMIZED_FOR_CLIENT %MSG_OPTIMIZED_FOR_CLIENT% + IDS_MSG_OPTIMIZED_FOR_SERVER %MSG_OPTIMIZED_FOR_SERVER% + IDS_MSG_NO_INSTALLATION_FOUND %MSG_NO_INSTALLATION_FOUND% +END diff --git a/desktop/win32/source/rebase/rebase.cxx b/desktop/win32/source/rebase/rebase.cxx new file mode 100644 index 000000000000..e651ad0affcc --- /dev/null +++ b/desktop/win32/source/rebase/rebase.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: md5.cxx,v $ + * $Revision: 1.8 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_desktop.hxx" +#define UNICODE +#define _UNICODE + +#define WIN32_LEAN_AND_MEAN +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include +#include +#include +#include +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include +#include "sal/config.h" +#include "tools/pathutils.hxx" + +#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1) +#define MY_STRING(s) (s), MY_LENGTH(s) + +const int FORMAT_MESSAGE_SIZE = 4096; +const DWORD PE_Signature = 0x00004550; +const DWORD BASEVIRTUALADDRESS = 0x10000000; + +namespace +{ + +bool IsValidHandle( HANDLE handle ) +{ + return ((NULL != handle) && (INVALID_HANDLE_VALUE != handle)); +} + +void fail() +{ + LPWSTR buf = NULL; + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, NULL); + MessageBoxW(NULL, buf, NULL, MB_OK | MB_ICONERROR); + LocalFree(buf); + TerminateProcess(GetCurrentProcess(), 255); +} + +bool rebaseImage( wchar_t* pszFilePath, ULONG nNewImageBase) +{ + ULONG ulOldImageSize; + ULONG_PTR lpOldImageBase; + ULONG ulNewImageSize; + ULONG_PTR lpNewImageBase = nNewImageBase; + ULONG ulDateTimeStamp = 0; + bool bResult(false); + + char cszFilePath[_MAX_PATH+1] = {0}; + int nResult = WideCharToMultiByte(CP_ACP, 0, pszFilePath, -1, cszFilePath, _MAX_PATH, NULL, NULL); + + if (nResult != 0) + { + BOOL bResult = ReBaseImage( + cszFilePath, + "", + TRUE, + FALSE, + FALSE, + 0, + &ulOldImageSize, + &lpOldImageBase, + &ulNewImageSize, + &lpNewImageBase, + ulDateTimeStamp ); + } + + return bResult; +} + +wchar_t* getBrandPath(wchar_t * path) +{ + DWORD n = GetModuleFileNameW(NULL, path, MAX_PATH); + if (n == 0 || n >= MAX_PATH) { + exit(EXIT_FAILURE); + } + return tools::filename(path); +} + +void rebaseImagesInFolder( wchar_t* pszFolder, DWORD nNewImageBase ) +{ + wchar_t szPattern[MAX_PATH]; + wchar_t *lpLastSlash = wcsrchr( pszFolder, '\\' ); + if ( lpLastSlash ) + { + size_t len = lpLastSlash - pszFolder + 1; + wcsncpy( szPattern, pszFolder, len ); + wcsncpy( szPattern + len, TEXT("*.dll"), sizeof(szPattern)/sizeof(szPattern[0]) - len ); + } + + WIN32_FIND_DATA aFindFileData; + HANDLE hFind = FindFirstFile( szPattern, &aFindFileData ); + + if ( IsValidHandle(hFind) ) + { + BOOL fSuccess = false; + + do + { + wchar_t szLibFilePath[MAX_PATH]; + wchar_t *lpLastSlash = wcsrchr( pszFolder, '\\' ); + if ( lpLastSlash ) + { + size_t len = lpLastSlash - pszFolder + 1; + wcsncpy( szLibFilePath, pszFolder, len ); + wcsncpy( szLibFilePath + len, aFindFileData.cFileName, sizeof(szLibFilePath)/sizeof(szLibFilePath[0]) - len ); + } + + rebaseImage( szLibFilePath, nNewImageBase ); + fSuccess = FindNextFile( hFind, &aFindFileData ); + } + while ( fSuccess ); + + FindClose( hFind ); + } +} + +} + +extern "C" int APIENTRY WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) +{ + wchar_t path[MAX_PATH]; + + wchar_t * pathEnd = getBrandPath(path); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"")) == NULL) + fail(); + rebaseImagesInFolder(path, BASEVIRTUALADDRESS); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\basis-link")) == NULL) + fail(); + pathEnd = tools::resolveLink(path); + + if ( pathEnd == NULL ) + return 0; + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\program\\")) == NULL) + fail(); + rebaseImagesInFolder(path, BASEVIRTUALADDRESS); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\ure-link")) == NULL) + fail(); + pathEnd = tools::resolveLink(path); + + if ( pathEnd == NULL ) + return 0; + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\bin\\")) == NULL) + fail(); + rebaseImagesInFolder(path, BASEVIRTUALADDRESS); + + return 0; +} diff --git a/desktop/win32/source/rebase/rebasegui.cxx b/desktop/win32/source/rebase/rebasegui.cxx new file mode 100644 index 000000000000..feba7556b74c --- /dev/null +++ b/desktop/win32/source/rebase/rebasegui.cxx @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: md5.cxx,v $ + * $Revision: 1.8 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_desktop.hxx" + +#define UNICODE 1 +#define _UNICODE 1 + +#ifndef _WINDOWS_ +# define WIN32_LEAN_AND_MEAN +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +# include +# include +# include +#if defined _MSC_VER +#pragma warning(pop) +#endif +#endif + +#include "Resource.h" +#include +#include "sal/config.h" +#include "tools/pathutils.hxx" + +const DWORD PE_Signature = 0x00004550; + +#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1) +#define MY_STRING(s) (s), MY_LENGTH(s) +#define MAX_STR_CAPTION 256 +#define MAX_TEXT_LENGTH 1024 + +static void failPath(wchar_t* pszAppTitle, wchar_t* pszMsg) +{ + MessageBoxW(NULL, pszMsg, pszAppTitle, MB_OK | MB_ICONERROR); + TerminateProcess(GetCurrentProcess(), 255); +} + +static void fail() +{ + LPWSTR buf = NULL; + FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, + GetLastError(), 0, reinterpret_cast< LPWSTR >(&buf), 0, NULL); + MessageBoxW(NULL, buf, NULL, MB_OK | MB_ICONERROR); + LocalFree(buf); + TerminateProcess(GetCurrentProcess(), 255); +} + +static LPVOID getVirtualBaseAddress( wchar_t* pszFilePath ) +{ + HANDLE hFile; + HANDLE hFileMapping; + LPVOID lpFileBase = 0; + PIMAGE_DOS_HEADER lpDosHeader; + PIMAGE_NT_HEADERS lpNTHeader; + + hFile = CreateFile(pszFilePath, + GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, + 0); + + if ( hFile == INVALID_HANDLE_VALUE ) + { + return NULL; + } + + hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if ( hFileMapping == 0 ) + { + CloseHandle(hFile); + return NULL; + } + + lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); + if ( lpFileBase == 0 ) + { + CloseHandle(hFileMapping); + CloseHandle(hFile); + return NULL; + } + + lpDosHeader = (PIMAGE_DOS_HEADER)lpFileBase; + if ( lpDosHeader->e_magic == IMAGE_DOS_SIGNATURE ) + { + lpNTHeader = (PIMAGE_NT_HEADERS)((char*)lpDosHeader + lpDosHeader->e_lfanew); + if (lpNTHeader->Signature == PE_Signature ) + lpFileBase = reinterpret_cast( lpNTHeader->OptionalHeader.ImageBase ); + } + + UnmapViewOfFile(lpFileBase); + CloseHandle(hFileMapping); + CloseHandle(hFile); + + return lpFileBase; +} + +static bool checkImageVirtualBaseAddress(wchar_t* pszFilePath, LPVOID lpVBA) +{ + LPVOID lpImageVBA = getVirtualBaseAddress(pszFilePath); + if ( lpImageVBA == lpVBA ) + return true; + else + return false; +} + +static wchar_t* getBrandPath(wchar_t * pszPath) +{ + DWORD n = GetModuleFileNameW(NULL, pszPath, MAX_PATH); + if (n == 0 || n >= MAX_PATH) { + exit(EXIT_FAILURE); + } + return tools::filename(pszPath); +} + +extern "C" int APIENTRY WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int ) +{ + wchar_t* pAppTitle = new wchar_t[ MAX_STR_CAPTION ]; + pAppTitle[0] = '\0'; + LoadString( hInst, IDS_APP_TITLE, pAppTitle, MAX_STR_CAPTION ); + + wchar_t* pTextServer = new wchar_t[ MAX_TEXT_LENGTH ]; + pTextServer[0] = '\0'; + LoadString( hInst, IDS_MSG_OPTIMIZED_FOR_SERVER, pTextServer, MAX_TEXT_LENGTH ); + + wchar_t* pTextClient = new wchar_t[ MAX_TEXT_LENGTH ]; + pTextClient[0] = '\0'; + LoadString( hInst, IDS_MSG_OPTIMIZED_FOR_CLIENT, pTextClient, MAX_TEXT_LENGTH ); + + wchar_t* pTextNoInstallation = new wchar_t[ MAX_TEXT_LENGTH ]; + pTextNoInstallation[0] = '\0'; + LoadString( hInst, IDS_MSG_NO_INSTALLATION_FOUND, pTextNoInstallation, MAX_TEXT_LENGTH ); + + LPVOID VBA = (void*)0x10000000; + wchar_t path[MAX_PATH]; + + wchar_t * pathEnd = getBrandPath(path); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"libxml2.dll")) == NULL) + fail(); + bool bFast = checkImageVirtualBaseAddress(path, VBA); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"..\\basis-link")) == NULL) + fail(); + pathEnd = tools::resolveLink(path); + + if (pathEnd == NULL) + failPath(pAppTitle, pTextNoInstallation); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\program\\vclmi.dll")) == NULL) + fail(); + bFast &= checkImageVirtualBaseAddress(path, VBA); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\ure-link")) == NULL) + fail(); + pathEnd = tools::resolveLink(path); + + if (pathEnd == NULL) + failPath(pAppTitle, pTextNoInstallation); + + if (tools::buildPath(path, path, pathEnd, MY_STRING(L"\\bin\\sal3.dll")) == NULL) + fail(); + bFast &= checkImageVirtualBaseAddress(path, VBA); + + const wchar_t* pOutput = pTextClient; + if (!bFast) + pOutput = pTextServer; + + MessageBoxW( NULL, pOutput, pAppTitle, MB_OK ); + + return 0; +} diff --git a/desktop/win32/source/rebase/rebasegui.ulf b/desktop/win32/source/rebase/rebasegui.ulf new file mode 100644 index 000000000000..ee6b6e828ac1 --- /dev/null +++ b/desktop/win32/source/rebase/rebasegui.ulf @@ -0,0 +1,11 @@ +[%APP_TITLE%] +en-US = "Installation Status" + +[%MSG_OPTIMIZED_FOR_CLIENT%] +en-US = "Installation is optimized for clients." + +[%MSG_OPTIMIZED_FOR_SERVER%] +en-US = "Installation is optimized for servers." + +[%MSG_NO_INSTALLATION_FOUND%] +en-US = "Cannot find Office installation." -- cgit