VirtualBox

source: vbox/trunk/src/VBox/Installer/win/MsiHack/MsiHackExtension.cs@ 84825

Last change on this file since 84825 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1/* $Id: MsiHackExtension.cs 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * MsiHackExtension - Wix Extension that loads MsiHack.dll
4 */
5
6/*
7 * Copyright (C) 2016-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19using Microsoft.Tools.WindowsInstallerXml;
20using System; /* For Console. */
21using System.Reflection; /* For Assembly*(). */
22using System.Runtime.InteropServices; /* For DllImport. */
23using System.IO; /* For Path. */
24
25
26
27[assembly: AssemblyTitle("org.virtualbox.wix.msi.speed.hack")]
28[assembly: AssemblyDescription("Speeding up MSI.DLL")]
29[assembly: AssemblyConfiguration("")]
30[assembly: AssemblyCompany("Oracle Corporation")]
31[assembly: AssemblyProduct("org.virtualbox.wix.msi.speed.hack")]
32[assembly: AssemblyCopyright("Copyright (C) 2016")]
33[assembly: AssemblyTrademark("")]
34[assembly: AssemblyCulture("")]
35[assembly: AssemblyDefaultWixExtension(typeof(MsiHackExtension))]
36
37
38static class NativeMethods
39{
40 [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
41 public static extern IntPtr LoadLibrary(string strPath);
42}
43
44
45public class MsiHackExtension : WixExtension
46{
47 public MsiHackExtension()
48 {
49 /* Figure out where we are. */
50 string strCodeBase = Assembly.GetExecutingAssembly().CodeBase;
51 //Console.WriteLine("MsiHackExtension: strCodeBase={0}", strCodeBase);
52
53 UriBuilder uri = new UriBuilder(strCodeBase);
54 string strPath = Uri.UnescapeDataString(uri.Path);
55 //Console.WriteLine("MsiHackExtension: strPath={0}", strPath);
56
57 string strDir = Path.GetDirectoryName(strPath);
58 //Console.WriteLine("MsiHackExtension: strDir={0}", strDir);
59
60 string strHackDll = strDir + "\\MsiHack.dll";
61 //Console.WriteLine("strHackDll={0}", strHackDll);
62
63 try
64 {
65 IntPtr hHackDll = NativeMethods.LoadLibrary(strHackDll);
66 Console.WriteLine("MsiHackExtension: Loaded {0} at {1}!", strHackDll, hHackDll.ToString("X"));
67 }
68 catch (Exception Xcpt)
69 {
70 Console.WriteLine("MsiHackExtension: Exception loading {0}: {1}", strHackDll, Xcpt);
71 }
72 }
73}
74
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette