diff options
Diffstat (limited to 'desktop/win32/source/rebase')
-rw-r--r-- | desktop/win32/source/rebase/Resource.h | 7 | ||||
-rw-r--r-- | desktop/win32/source/rebase/makefile.mk | 8 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rebase.cxx | 329 | ||||
-rw-r--r-- | desktop/win32/source/rebase/rebasegui.cxx | 349 |
4 files changed, 340 insertions, 353 deletions
diff --git a/desktop/win32/source/rebase/Resource.h b/desktop/win32/source/rebase/Resource.h index 03ec1d4eee..b90d9b7c5e 100644 --- a/desktop/win32/source/rebase/Resource.h +++ b/desktop/win32/source/rebase/Resource.h @@ -1,13 +1,10 @@ /************************************************************************* * * 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 + * Copyright 2000, 2010 Oracle and/or its affiliates. * - * $RCSfile: Resource.h,v $ - * $Revision: 1.7 $ + * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * diff --git a/desktop/win32/source/rebase/makefile.mk b/desktop/win32/source/rebase/makefile.mk index dbab5a5d09..45af781cc1 100644 --- a/desktop/win32/source/rebase/makefile.mk +++ b/desktop/win32/source/rebase/makefile.mk @@ -1,14 +1,10 @@ #************************************************************************* # # 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 $ +# Copyright 2000, 2010 Oracle and/or its affiliates. # -# $Revision: 1.4 $ +# OpenOffice.org - a multi-platform office productivity suite # # This file is part of OpenOffice.org. # diff --git a/desktop/win32/source/rebase/rebase.cxx b/desktop/win32/source/rebase/rebase.cxx index 633e74723c..5688c63ef6 100644 --- a/desktop/win32/source/rebase/rebase.cxx +++ b/desktop/win32/source/rebase/rebase.cxx @@ -1,13 +1,10 @@ /************************************************************************* * * 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 + * Copyright 2000, 2010 Oracle and/or its affiliates. * - * $RCSfile: md5.cxx,v $ - * $Revision: 1.8 $ + * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * @@ -27,164 +24,164 @@ * 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;
-}
+ +#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 index 3cb36cb49b..99dff9f213 100644 --- a/desktop/win32/source/rebase/rebasegui.cxx +++ b/desktop/win32/source/rebase/rebasegui.cxx @@ -1,13 +1,10 @@ /************************************************************************* * * 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 + * Copyright 2000, 2010 Oracle and/or its affiliates. * - * $RCSfile: md5.cxx,v $ - * $Revision: 1.8 $ + * OpenOffice.org - a multi-platform office productivity suite * * This file is part of OpenOffice.org. * @@ -27,174 +24,174 @@ * 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;
-}
+ +#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; +} |