diff options
Diffstat (limited to 'desktop/win32/source')
-rw-r--r-- | desktop/win32/source/extendloaderenvironment.cxx | 9 | ||||
-rw-r--r-- | desktop/win32/source/guistdio/guistdio.inc | 75 | ||||
-rw-r--r-- | desktop/win32/source/rebase/Resource.h | 41 | ||||
-rw-r--r-- | desktop/win32/source/rebase/makefile.mk | 93 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rcfooter.txt | 2 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rcheader.txt | 39 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rctmpl.txt | 9 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rebase.cxx | 190 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rebasegui.cxx | 200 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rebasegui.ulf | 11 |
10 files changed, 654 insertions, 15 deletions
diff --git a/desktop/win32/source/extendloaderenvironment.cxx b/desktop/win32/source/extendloaderenvironment.cxx index 4c8ae784acf7..e5b33f5aa2be 100644 --- a/desktop/win32/source/extendloaderenvironment.cxx +++ b/desktop/win32/source/extendloaderenvironment.cxx @@ -135,18 +135,21 @@ void extendLoaderEnvironment(WCHAR * binPath, WCHAR * iniDirectory) { if (GetLastError() != ERROR_FILE_NOT_FOUND) { fail(); } + // This path is only taken by testtool.exe in basis program directory; + // its PATH needs to include the brand program directory: pathEnd = tools::buildPath( path, iniDirectory, iniDirEnd, MY_STRING(L"..")); if (pathEnd == NULL) { fail(); } - exclude1 = true; - } else { - padEnd = tools::buildPath(pad, path, pathEnd, MY_STRING(L"\\program")); + padEnd = tools::buildPath( + pad, path, pathEnd, MY_STRING(L"\\..\\program")); if (padEnd == NULL) { fail(); } exclude1 = contains(env, pad, padEnd); + } else { + exclude1 = true; } WCHAR * pad2 = exclude1 ? pad : padEnd + 1; pathEnd = tools::buildPath(path, path, pathEnd, MY_STRING(L"\\ure-link")); diff --git a/desktop/win32/source/guistdio/guistdio.inc b/desktop/win32/source/guistdio/guistdio.inc index 6ee59c891bf0..024b456efa99 100644 --- a/desktop/win32/source/guistdio/guistdio.inc +++ b/desktop/win32/source/guistdio/guistdio.inc @@ -47,10 +47,6 @@ #include <stdio.h> -//--------------------------------------------------------------------------- -// Thread that reads from child process standard output pipe -//--------------------------------------------------------------------------- - #ifdef UNOPKG DWORD passOutputToConsole(HANDLE readPipe, HANDLE console) @@ -169,21 +165,76 @@ DWORD WINAPI ErrorThread( LPVOID pParam ) // Thread that writes to child process standard input pipe //--------------------------------------------------------------------------- #ifdef UNOPKG + DWORD WINAPI InputThread( LPVOID pParam ) { - const DWORD dwBufferSize = 256; - wchar_t aBuffer[dwBufferSize]; DWORD dwRead = 0; HANDLE hWritePipe = (HANDLE)pParam; - - while (ReadConsoleW( GetStdHandle( STD_INPUT_HANDLE ), &aBuffer, dwBufferSize, &dwRead, NULL ) ) + + //We need to read in the complete input until we encounter a new line before + //converting to Unicode. This is necessary because the input string can use + //characters of one, two, and more bytes. If the last character is not + //complete, then it will not be converted properly. + + //Find out how a new line (0xd 0xa) looks like with the used code page. + //Characters may have one or multiple bytes and different byte ordering + //can be used (little and big endian); + int cNewLine = WideCharToMultiByte( + GetConsoleCP(), 0, L"\r\n", 2, NULL, 0, NULL, NULL); + char * mbBuff = new char[cNewLine]; + WideCharToMultiByte( + GetConsoleCP(), 0, L"\r\n", 2, mbBuff, cNewLine, NULL, NULL); + + const size_t dwBufferSize = 256; + char* readBuf = (char*) malloc(dwBufferSize); + int readAll = 0; + size_t curBufSize = dwBufferSize; + + while ( ReadFile( GetStdHandle( STD_INPUT_HANDLE ), + readBuf + readAll, + curBufSize - readAll, &dwRead, NULL ) ) { - BOOL fSuccess; + readAll += dwRead; + int lastBufSize = curBufSize; + //Grow the buffer if necessary + if (readAll > curBufSize * 0.7) + { + curBufSize *= 2; + readBuf = (char *) realloc(readBuf, curBufSize); + } + + //If the buffer was filled completely then + //there could be more input coming. But if we read from the console + //and the console input fits exactly in the buffer, then the next + //ReadFile would block until the users presses return, etc. + //Therefor we check if last character is a new line. + //To test this, set dwBufferSize to 4 and enter "no". This should produce + //4 bytes with most code pages. + if ( readAll == lastBufSize + && memcmp(readBuf + lastBufSize - cNewLine, mbBuff, cNewLine) != 0) + { + //The buffer was completely filled and the last byte(s) are no + //new line, so there is more to come. + continue; + } + //Obtain the size of the buffer for the converted string. + int sizeWBuf = MultiByteToWideChar( + GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, NULL, 0); + + wchar_t * wideBuf = new wchar_t[sizeWBuf]; + + //Do the conversion. + MultiByteToWideChar( + GetConsoleCP(), MB_PRECOMPOSED, readBuf, readAll, wideBuf, sizeWBuf); + + BOOL fSuccess; DWORD dwWritten; - - fSuccess = WriteFile( hWritePipe, aBuffer, dwRead * 2, &dwWritten, NULL ); + fSuccess = WriteFile( hWritePipe, wideBuf, sizeWBuf * 2, &dwWritten, NULL ); + delete[] wideBuf; + readAll = 0; } - + delete[] mbBuff; + free(readBuf); return 0; } #else 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 + * <http://www.openoffice.org/license.html> + * 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..dbab5a5d0921 --- /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 +# <http://www.openoffice.org/license.html> +# 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 + $(LNGCONVEX) -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 <winres.h> +#else +#define WINVER 0x0500 +#include <winresrc.h> +#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 + * <http://www.openoffice.org/license.html> + * 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 <windows.h>
+#include <shellapi.h>
+#include <imagehlp.h>
+#include <wchar.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <time.h>
+#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 + * <http://www.openoffice.org/license.html> + * 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 <windows.h>
+# include <shellapi.h>
+# include <wchar.h>
+#if defined _MSC_VER
+#pragma warning(pop)
+#endif
+#endif
+
+#include "Resource.h"
+#include <time.h>
+#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<LPVOID>( 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." |