diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:18 +0000 |
commit | 4035b1bfb1e5843a539a8b624d21952b756974d1 (patch) | |
tree | f1e9cd5bf548cbc57ff2fddfb2b4aa9ae95587e2 /src/libs/xpcom18a4/xpcom/tools | |
parent | Initial commit. (diff) | |
download | virtualbox-upstream.tar.xz virtualbox-upstream.zip |
Adding upstream version 6.1.22-dfsg.upstream/6.1.22-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/xpcom18a4/xpcom/tools')
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/.cvsignore | 1 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/Makefile.in | 53 | ||||
-rwxr-xr-x | src/libs/xpcom18a4/xpcom/tools/analyze-xpcom-log.pl | 177 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/registry/.cvsignore | 3 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/registry/Makefile.in | 77 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/registry/regxpcom.cpp | 404 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/windows/.cvsignore | 1 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/windows/Makefile.in | 52 | ||||
-rw-r--r-- | src/libs/xpcom18a4/xpcom/tools/windows/rebasedlls.cpp | 104 |
9 files changed, 872 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/xpcom/tools/.cvsignore b/src/libs/xpcom18a4/xpcom/tools/.cvsignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/src/libs/xpcom18a4/xpcom/tools/Makefile.in b/src/libs/xpcom18a4/xpcom/tools/Makefile.in new file mode 100644 index 00000000..be87de04 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/Makefile.in @@ -0,0 +1,53 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (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.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = xpcom +DIRS = registry + +ifeq ($(OS_ARCH),WINNT) +DIRS += windows +endif + +include $(topsrcdir)/config/rules.mk + diff --git a/src/libs/xpcom18a4/xpcom/tools/analyze-xpcom-log.pl b/src/libs/xpcom18a4/xpcom/tools/analyze-xpcom-log.pl new file mode 100755 index 00000000..81ccb212 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/analyze-xpcom-log.pl @@ -0,0 +1,177 @@ +#!/usr/local/bin/perl -w + +# Perl script to analyze the xpcom output file +# +# To create xpcom output file : +# +# setenv NSPR_LOG_MODULES nsComponentManager:5 +# setenv NSPR_LOG_FILE xpcom.out +# ./mozilla +# +# Also to try to convert CID -> contractID this program looks for +# a file reg.out in the current directory. To generate this file +# +# $ regExport > reg.out +# +# Usage: analyze-xpcom-log.pl < xpcom.out +# [does better if ./reg.out is available] +# +# Suresh Duddi <dpsuresh@netscape.net> + + +use strict; + +# forward declarations +sub getContractID($); +sub sum($); + +# Configuration parameters +# Print all ? +my $all = 0; + +# hash of cid -> contractid +my %contractid; +my %contractid_n; +my %failedContractid_n; + +# count of instances of objects created +my (%objs, %objs_contractid, %failedObjs) = (); + +# dlls loaded +my @dlls; + +# temporaries +my ($cid, $n, $str); + +while (<>) { + chomp; + + # dlls loaded + if (/loading \"(.*)\"/) { + push @dlls, $1; + next; + } + + # FAILED ContractIDToClassID + if (/ContractIDToClassID\((.*)\).*\[FAILED\]/) { + $failedContractid_n{$1}++; + next; + } + + # ContractIDToClassID + if (/ContractIDToClassID\((.*)\).*\{(.*)\}/) { + $contractid{$2} = $1; + $contractid_n{$2}++; + next; + } + + # CreateInstance() + if (/CreateInstance\(\{(.*)\}\) succeeded/) { + $objs{$1}++; + next; + } + + # CreateInstanceByContractID() + if (/CreateInstanceByContractID\((.*)\) succeeded/) { + $objs_contractid{$1}++; + next; + } + + # FAILED CreateInstance() + if (/CreateInstance\(\{(.*)\}\) FAILED/) { + $failedObjs{$1}++; + next; + } +} + +# if there is a file named reg.out in the current dir +# then use that to fill in the ContractIDToClassID mapping. +my $REG; +open REG, "<reg.out"; +while (<REG>) { + chomp; + if (/contractID - (.*)$/) { + my $id = $1; + $cid = <REG>; + chomp($cid); + $cid =~ s/^.*\{(.*)\}.*$/$1/; + $contractid{$cid} = $id; + } +} + +# print results +# ---------------------------------------------------------------------- + +# dlls loaded +print "dlls loaded [", scalar @dlls, "]\n"; +print "----------------------------------------------------------------------\n"; +for ($n = 0; $n < scalar @dlls; $n++) { + printf "%2d. %s\n", $n+1, $dlls[$n]; +} +print "\n"; + +# Objects created +print "Object creations from CID [", sum(\%objs), "]\n"; +print "----------------------------------------------------------------------\n"; +foreach $cid (sort {$objs{$b} <=> $objs{$a} } keys %objs) { + last if (!$all && $objs{$cid} < 50); + printf "%5d. %s - %s\n", $objs{$cid}, $cid, getContractID($cid); +} +print "\n"; + +print "Object creations from ContractID [", sum(\%objs_contractid), "]\n"; +print "----------------------------------------------------------------------\n"; +foreach $cid (sort {$objs_contractid{$b} <=> $objs_contractid{$a} } keys %objs_contractid) { + last if (!$all && $objs_contractid{$cid} < 50); + printf "%5d. %s - %s\n", $objs_contractid{$cid}, $cid, getContractID($cid); +} +print "\n"; + +# FAILED Objects created +print "FAILED Objects creations [", sum(\%failedObjs), "]\n"; +print "----------------------------------------------------------------------\n"; +foreach $cid (sort {$failedObjs{$b} <=> $failedObjs{$a} } keys %failedObjs) { + last if (!$all && $failedObjs{$cid} < 50); + printf "%5d. %s - %s", $failedObjs{$cid}, $cid, getContractID($cid); +} +print "\n"; + +# ContractIDToClassID calls +print "ContractIDToClassID() calls [", sum(\%contractid_n),"]\n"; +print "----------------------------------------------------------------------\n"; +foreach $cid (sort {$contractid_n{$b} <=> $contractid_n{$a} } keys %contractid_n) { + last if (!$all && $contractid_n{$cid} < 50); + printf "%5d. %s - %s\n", $contractid_n{$cid}, $cid, getContractID($cid); +} +print "\n"; + + +# FAILED ContractIDToClassID calls +print "FAILED ContractIDToClassID() calls [", sum(\%failedContractid_n), "]\n"; +print "----------------------------------------------------------------------\n"; +foreach $cid (sort {$failedContractid_n{$b} <=> $failedContractid_n{$a} } keys %failedContractid_n) { + last if (!$all && $failedContractid_n{$cid} < 50); + printf "%5d. %s\n", $failedContractid_n{$cid}, $cid; +} +print "\n"; + + +# Subroutines + +sub getContractID($) { + my $cid = shift; + my $ret = ""; + $ret = $contractid{$cid} if (exists $contractid{$cid}); + return $ret; +} + +sub sum($) { + my $hash_ref = shift; + my %hash = %$hash_ref; + my $total = 0; + my $key; + foreach $key (keys %hash) { + $total += $hash{$key}; + } + return $total; +} diff --git a/src/libs/xpcom18a4/xpcom/tools/registry/.cvsignore b/src/libs/xpcom18a4/xpcom/tools/registry/.cvsignore new file mode 100644 index 00000000..91acd38b --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/registry/.cvsignore @@ -0,0 +1,3 @@ +Makefile +regExport +regxpcom diff --git a/src/libs/xpcom18a4/xpcom/tools/registry/Makefile.in b/src/libs/xpcom18a4/xpcom/tools/registry/Makefile.in new file mode 100644 index 00000000..5c19d014 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/registry/Makefile.in @@ -0,0 +1,77 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (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.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = xpcom +CPPSRCS = regxpcom.cpp + +DEFINES += -DXPCOM_GLUE + +REQUIRES = \ + string \ + $(NULL) + +LOCAL_INCLUDES = \ + -I$(srcdir)/../../build \ + $(NULL) + +SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX)) + +LIBS = \ + $(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \ + $(NSPR_LIBS) \ + $(NULL) + +# Need to link with CoreFoundation on Mac +ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +LIBS += \ + $(TK_LIBS) \ + $(NULL) +endif + +SDK_BINARY = \ + $(SIMPLE_PROGRAMS) \ + $(NULL) + +include $(topsrcdir)/config/rules.mk + diff --git a/src/libs/xpcom18a4/xpcom/tools/registry/regxpcom.cpp b/src/libs/xpcom18a4/xpcom/tools/registry/regxpcom.cpp new file mode 100644 index 00000000..b8822b8f --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/registry/regxpcom.cpp @@ -0,0 +1,404 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Pierre Phaneuf <pp@ludusdesign.com> + * Mike Shaver <shaver@mozilla.org> + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "stdlib.h" +#include "prenv.h" +#include "nspr.h" + +#include "nsXPCOMPrivate.h" // for XPCOM_DLL defines. + +#include "nsXPCOMGlue.h" +#include "nsIComponentManager.h" +#include "nsIComponentRegistrar.h" +#include "nsIServiceManager.h" +#include "nsCOMPtr.h" +#include "nsILocalFile.h" +#include "nsEmbedString.h" +#include "nsIDirectoryService.h" +#include "nsDirectoryServiceDefs.h" + + +static PRBool gUnreg = PR_FALSE, gQuiet = PR_FALSE; + +static const char* gXPCOMLocation = nsnull; +static const char* gCompRegLocation = nsnull; +static const char* gXPTIDatLocation = nsnull; +static char* gPathEnvString = nsnull; + +class DirectoryServiceProvider : public nsIDirectoryServiceProvider +{ + public: + DirectoryServiceProvider() {} + + NS_DECL_ISUPPORTS + NS_DECL_NSIDIRECTORYSERVICEPROVIDER + + private: + ~DirectoryServiceProvider() {} +}; + +NS_IMPL_ISUPPORTS1(DirectoryServiceProvider, nsIDirectoryServiceProvider) + +NS_IMETHODIMP +DirectoryServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval) +{ + nsCOMPtr<nsILocalFile> localFile; + nsresult rv = NS_ERROR_FAILURE; + + *_retval = nsnull; + *persistant = PR_TRUE; + + const char* fileLocation = nsnull; + + if(strcmp(prop, NS_XPCOM_CURRENT_PROCESS_DIR) == 0 && gXPCOMLocation) + { + fileLocation = gXPCOMLocation; + } + else if(strcmp(prop, NS_XPCOM_COMPONENT_REGISTRY_FILE) == 0 && gCompRegLocation) + { + fileLocation = gCompRegLocation; + } + else if(strcmp(prop, NS_XPCOM_XPTI_REGISTRY_FILE) == 0 && gXPTIDatLocation) + { + fileLocation = gXPTIDatLocation; + } + else + return NS_ERROR_FAILURE; + + rv = NS_NewNativeLocalFile(nsEmbedCString(fileLocation), PR_TRUE, getter_AddRefs(localFile)); + if (NS_FAILED(rv)) return rv; + + return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); +} + +int startup_xpcom() +{ + nsresult rv; + + if (gXPCOMLocation) { + int len = strlen(gXPCOMLocation); + char* xpcomPath = (char*) malloc(len + sizeof(XPCOM_DLL) + sizeof(XPCOM_FILE_PATH_SEPARATOR) + 1); + sprintf(xpcomPath, "%s" XPCOM_FILE_PATH_SEPARATOR XPCOM_DLL, gXPCOMLocation); + + rv = XPCOMGlueStartup(xpcomPath); + + free(xpcomPath); + + const char* path = PR_GetEnv(XPCOM_SEARCH_KEY); + if (!path) { + path = ""; + } + + if (gPathEnvString) + PR_smprintf_free(gPathEnvString); + + gPathEnvString = PR_smprintf("%s=%s;%s", + XPCOM_SEARCH_KEY, + gXPCOMLocation, + path); + + if (gXPCOMLocation) + PR_SetEnv(gPathEnvString); + } + else + { + rv = XPCOMGlueStartup(nsnull); + } + + if (NS_FAILED(rv)) + { + printf("Can not initialize XPCOM Glue\n"); + return -1; + } + + DirectoryServiceProvider *provider = new DirectoryServiceProvider(); + if ( !provider ) + { + NS_WARNING("GRE_Startup failed"); + XPCOMGlueShutdown(); + return -1; + } + + nsCOMPtr<nsILocalFile> file; + if (gXPCOMLocation) + { + rv = NS_NewNativeLocalFile(nsEmbedCString(gXPCOMLocation), + PR_TRUE, + getter_AddRefs(file)); + } + + NS_ADDREF(provider); + rv = NS_InitXPCOM2(nsnull, file, provider); + NS_RELEASE(provider); + + if (NS_FAILED(rv)) { + printf("Can not initialize XPCOM\n"); + XPCOMGlueShutdown(); + return -1; + } + + return 0; +} + +void shutdown_xpcom() +{ + nsresult rv; + + rv = NS_ShutdownXPCOM(nsnull); + + if (NS_FAILED(rv)) { + printf("Can not shutdown XPCOM cleanly\n"); + } + + rv = XPCOMGlueShutdown(); + + if (NS_FAILED(rv)) { + printf("Can not shutdown XPCOM Glue cleanly\n"); + } + if (gPathEnvString) + PR_smprintf_free(gPathEnvString); +} + + +nsresult Register(const char *path) +{ + startup_xpcom(); + + nsresult rv; + nsCOMPtr<nsILocalFile> spec; + + if (path) { + rv = NS_NewNativeLocalFile(nsEmbedCString(path), + PR_TRUE, + getter_AddRefs(spec)); + } + + nsCOMPtr<nsIComponentRegistrar> registrar; + rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); + if (NS_FAILED(rv)) { + printf("Can not aquire component registrar\n"); + return rv; + } + + if (gUnreg) + rv = registrar->AutoUnregister(spec); + else + rv = registrar->AutoRegister(spec); + + spec = 0; + registrar = 0; + + shutdown_xpcom(); + return rv; +} + + +void ReportSuccess(const char *file) +{ + if (gQuiet) + return; + + if (gUnreg) + printf("Unregistration successful for %s\n", file); + else + printf("Registration successful for %s\n", file); +} + +void ReportError(nsresult err, const char *file) +{ + if (gUnreg) + printf("Unregistration failed: ("); + else + printf("Registration failed: ("); + + switch (err) + { + case NS_ERROR_FACTORY_NOT_LOADED: + printf("Factory not loaded"); + break; + case NS_NOINTERFACE: + printf("No Interface"); + break; + case NS_ERROR_NULL_POINTER: + printf("Null pointer"); + break; + case NS_ERROR_OUT_OF_MEMORY: + printf("Out of memory"); + break; + default: + printf("%x", (unsigned)err); + } + + printf(") %s\n", file); +} + +void printHelp() +{ + printf( +"Mozilla regxpcom - a registration tool for xpcom components \n" +" \n" +"Usage: regxpcom [options] [file-or-directory] \n" +" \n" +"Options: \n" +" -x path Specifies the location of a directory containing the \n" +" xpcom library which will be used when registering new \n" +" component libraries. This path will also be added to \n" +" the \"load library\" path. If not specified, the \n" +" current working directory will be used. \n" +" -c path Specifies the location of the compreg.dat file. If \n" +" not specifed, the compreg.dat file will be in its \n" +" default location. \n" +" -d path Specifies the location of the xpti.dat file. If not \n" +" specifed, the xpti.dat file will be in its default \n" +" location. \n" +" -a Option to register all files in the default component \n" +" directories. This is the default behavior if regxpcom \n" +" is called without any arguments. \n" +" -h Displays this help screen. Must be the only option \n" +" specified. \n" +" -u Option to uninstall the files-or-directory instead of \n" +" registering them. \n" +" -q Quiets some of the output of regxpcom. \n\n"); +} + +int ProcessArgs(int argc, char *argv[]) +{ + int i = 1, result = 0; + nsresult res; + + while (i < argc) + { + if (argv[i][0] == '-') + { + int j; + for (j = 1; argv[i][j] != '\0'; j++) + { + switch (argv[i][j]) + { + case 'h': + printHelp(); + return 0; // we are all done! + + case 'u': + gUnreg = PR_TRUE; + break; + + case 'q': + gQuiet = PR_TRUE; + break; + + case 'a': + { + res = Register(nsnull); + if (NS_FAILED(res)) + { + ReportError(res, "component directory"); + result = -1; + } + else + { + ReportSuccess("component directory"); + } + } + break; + + case 'x': + gXPCOMLocation = argv[++i]; + j = strlen(gXPCOMLocation) - 1; + break; + + case 'c': + gCompRegLocation = argv[++i]; + j = strlen(gCompRegLocation) - 1; + break; + + case 'd': + gXPTIDatLocation = argv[++i]; + j = strlen(gXPTIDatLocation) - 1; + break; + + default: + printf("Unknown option '%c'\n", argv[i][j]); + } + } + } + else + { + res = Register(argv[i]); + + if (NS_FAILED(res)) + { + ReportError(res, argv[i]); + result = -1; + } + else + { + ReportSuccess(argv[i]); + } + } + i++; + } + return result; +} + + +int main(int argc, char *argv[]) +{ + int ret; + nsresult rv; + + /* With no arguments, regxpcom will autoregister */ + if (argc <= 1) + { + startup_xpcom(); + nsCOMPtr<nsIComponentRegistrar> registrar; + rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); + if (NS_FAILED(rv)) { + printf("Can not aquire component registrar\n"); + return -1; + } + rv = registrar->AutoRegister(nsnull); + ret = (NS_FAILED(rv)) ? -1 : 0; + registrar = 0; + shutdown_xpcom(); + } else + ret = ProcessArgs(argc, argv); + + return ret; +} diff --git a/src/libs/xpcom18a4/xpcom/tools/windows/.cvsignore b/src/libs/xpcom18a4/xpcom/tools/windows/.cvsignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/windows/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/src/libs/xpcom18a4/xpcom/tools/windows/Makefile.in b/src/libs/xpcom18a4/xpcom/tools/windows/Makefile.in new file mode 100644 index 00000000..f6ba7e69 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/windows/Makefile.in @@ -0,0 +1,52 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (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.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is mozilla.org code. +# +# The Initial Developer of the Original Code is +# Netscape Communications Corporation. +# Portions created by the Initial Developer are Copyright (C) 1998 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either of the GNU General Public License Version 2 or later (the "GPL"), +# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +SIMPLE_PROGRAMS = rebasedlls$(BIN_SUFFIX) + +CPPSRCS = rebasedlls.cpp + +OS_LIBS += $(call EXPAND_LIBNAME,imagehlp) + +include $(topsrcdir)/config/rules.mk + diff --git a/src/libs/xpcom18a4/xpcom/tools/windows/rebasedlls.cpp b/src/libs/xpcom18a4/xpcom/tools/windows/rebasedlls.cpp new file mode 100644 index 00000000..321160e7 --- /dev/null +++ b/src/libs/xpcom18a4/xpcom/tools/windows/rebasedlls.cpp @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#include <windows.h> +#include <stdio.h> +#include <imagehlp.h> +#include <time.h> + +static char* gSymbolPath = NULL; +static DWORD gBaseAddr = (DWORD) 0x60000000; +static time_t now; + +static void +ReBase(char* aDLLName) +{ + DWORD oldsize, oldbase, newsize; + DWORD newbase = gBaseAddr; + BOOL b = ReBaseImage(aDLLName, gSymbolPath, TRUE, FALSE, FALSE, + 0, &oldsize, &oldbase, &newsize, &newbase, + now); + DWORD lastError = ::GetLastError(); + printf("%-20s %08x %08x %08x %08x", + aDLLName, oldbase, oldsize, newbase, newsize); + if (!b) { + printf(" (failed: error=%d/0x%x)", lastError, lastError); + } + fputs("\n", stdout); + + // advance base; round size up to nearest 64k + newsize = ((newsize + 65535) >> 16) << 16; + gBaseAddr = newbase + newsize; +} + +static void +Usage() +{ + printf("Usage: ReBase [-libs library-path] dlls...\n"); +} + +int +main(int argc, char** argv) +{ + now = time(0); + int i; + for (i = 1; i < argc; i++) { + if (argv[i][0] == '-') { + if (strcmp(argv[i], "-libs") == 0) { + if (i == argc - 1) { + Usage(); + return -1; + } + gSymbolPath = argv[++i]; + } + else { + Usage(); + return -1; + } + } + else + break; + } + + if (i < argc) { + printf("Library OldBase OldSize NewBase NewSize\n"); + printf("------- ------- ------- ------- -------\n"); + } + for (; i < argc; i++) { + ReBase(argv[i]); + } + return 0; +} |