Browse Source

commit: fix crash on auto load ramdisk; fix enable on auto load disk entry; change ILMerge to ILRepack; remove duplicate icon, use PE resources to compact final size

HOME 4 years ago
parent
commit
2e248ac272

+ 0 - 2
ISCSIConsole/AddTargetForm.Designer.cs

@@ -28,7 +28,6 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddTargetForm));
             this.btnAddDiskImage = new System.Windows.Forms.Button();
             this.btnAddPhysicalDisk = new System.Windows.Forms.Button();
             this.txtTargetIQN = new System.Windows.Forms.TextBox();
@@ -186,7 +185,6 @@ namespace ISCSIConsole
             this.Controls.Add(this.btnAddPhysicalDisk);
             this.Controls.Add(this.btnAddDiskImage);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.KeyPreview = true;
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 260);

+ 5 - 9
ISCSIConsole/AddTargetForm.cs

@@ -1,18 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.IO;
-using System.Text;
-using System.Windows.Forms;
 using DiskAccessLibrary;
 using DiskAccessLibrary.Mod;
 using ISCSI.Server;
-using Utilities;
+using ISCSIConsole.Mods;
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
 
 namespace ISCSIConsole
 {
-    public partial class AddTargetForm : Form
+    public partial class AddTargetForm : BaseForm
     {
         public static int m_targetNumber = 1;
         public const string DefaultTargetIQN = "iqn.1991-05.com.talaloni";

File diff suppressed because it is too large
+ 0 - 6173
ISCSIConsole/AddTargetForm.resx


+ 0 - 2
ISCSIConsole/CreateDiskImageForm.Designer.cs

@@ -28,7 +28,6 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateDiskImageForm));
             this.ImageSizeUpDown = new System.Windows.Forms.NumericUpDown();
             this.lblSize = new System.Windows.Forms.Label();
             this.MbLabel = new System.Windows.Forms.Label();
@@ -274,7 +273,6 @@ namespace ISCSIConsole
             this.Controls.Add(this.lblSize);
             this.Controls.Add(this.ImageSizeUpDown);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 250);
             this.MinimumSize = new System.Drawing.Size(500, 250);

+ 2 - 1
ISCSIConsole/CreateDiskImageForm.cs

@@ -1,4 +1,5 @@
 using DiskAccessLibrary;
+using ISCSIConsole.Mods;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -8,7 +9,7 @@ using static DiskAccessLibrary.Mod.Consts;
 
 namespace ISCSIConsole
 {
-    public partial class CreateDiskImageForm : Form
+    public partial class CreateDiskImageForm : BaseForm
     {
         private bool m_isWorking;
 

File diff suppressed because it is too large
+ 0 - 6173
ISCSIConsole/CreateDiskImageForm.resx


+ 0 - 2
ISCSIConsole/CreateRAMDiskForm.Designer.cs

@@ -28,7 +28,6 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreateRAMDiskForm));
             this.numericDiskSize = new System.Windows.Forms.NumericUpDown();
             this.lblSize = new System.Windows.Forms.Label();
             this.btnOK = new System.Windows.Forms.Button();
@@ -189,7 +188,6 @@ namespace ISCSIConsole
             this.Controls.Add(this.lblSize);
             this.Controls.Add(this.numericDiskSize);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 250);
             this.MinimumSize = new System.Drawing.Size(500, 250);

+ 2 - 1
ISCSIConsole/CreateRAMDiskForm.cs

@@ -2,10 +2,11 @@ using DiskAccessLibrary;
 using DiskAccessLibrary.Mod;
 using System;
 using System.Windows.Forms;
+using ISCSIConsole.Mods;
 
 namespace ISCSIConsole
 {
-    public partial class CreateRAMDiskForm : Form
+    public partial class CreateRAMDiskForm : BaseForm
     {
         public CreateRAMDiskForm()
         {

File diff suppressed because it is too large
+ 0 - 6173
ISCSIConsole/CreateRAMDiskForm.resx


+ 0 - 6
ISCSIConsole/ILMerge/ILMerge.bat

@@ -1,6 +0,0 @@
-set binaryPath=%CD%\..\bin\Release
-set outputPath=%CD%\..\bin\ILMerge
-IF NOT EXIST "%outputPath%" MKDIR "%outputPath%"
-IF ["%programfiles(x86)%"]==[""] SET ilmergePath="%programfiles%\Microsoft\ILMerge"
-IF NOT ["%programfiles(x86)%"]==[""] SET ilmergePath="%programfiles(x86)%\Microsoft\ILMerge"
-%ilmergePath%\ilmerge /ndebug /target:winexe /out:"%outputPath%\ISCSIConsole.exe" "%binaryPath%\ISCSIConsole.exe" "%binaryPath%\Utilities.dll" "%binaryPath%\DiskAccessLibrary.dll" "%binaryPath%\ISCSI.dll"

+ 22 - 2
ISCSIConsole/ISCSIConsole.csproj

@@ -1,4 +1,5 @@
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
+  <Import Project="C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -17,6 +18,8 @@
     <OldToolsVersion>2.0</OldToolsVersion>
     <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
     <TargetFrameworkProfile />
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -40,6 +43,7 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Configuration" />
+    <Reference Include="System.Data" />
     <Reference Include="System.Drawing" />
     <Reference Include="System.Windows.Forms" />
     <Reference Include="System.Xml" />
@@ -51,6 +55,9 @@
     <Compile Include="AddTargetForm.Designer.cs">
       <DependentUpon>AddTargetForm.cs</DependentUpon>
     </Compile>
+    <Compile Include="Mods\BaseForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
     <Compile Include="CreateDiskImageForm.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -75,6 +82,8 @@
       <DependentUpon>MainForm.cs</DependentUpon>
     </Compile>
     <Compile Include="Mods\AutoLoadEntry.cs" />
+    <Compile Include="Mods\IconExtractor.cs" />
+    <Compile Include="Mods\NativeMethods.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Program.Log.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -153,6 +162,7 @@
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
+    <None Include="packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
@@ -163,7 +173,17 @@
   </Target>
   -->
   <PropertyGroup>
-    <PostBuildEvent>if $(ConfigurationName) == Release CD "$(ProjectDir)ILMerge\"
-if $(ConfigurationName) == Release "$(ProjectDir)ILMerge\ILMerge.bat"</PostBuildEvent>
+    <PostBuildEvent>if $(ConfigurationName) == Release setlocal enabledelayedexpansion enableextensions
+if $(ConfigurationName) == Release set DLL_LIST=
+if $(ConfigurationName) == Release for %25%25x in ($(TargetDir)*.dll) do set DLL_LIST=!DLL_LIST! "%25%25x"
+if $(ConfigurationName) == Release echo dlls: !DLL_LIST!
+if $(ConfigurationName) == Release if not exist "$(TargetDir)Packed" md "$(TargetDir)Packed"
+if $(ConfigurationName) == Release $(ILRepack) /ndebug "/out:$(TargetDir)Packed\$(TargetFileName)" "$(TargetPath)" !DLL_LIST!</PostBuildEvent>
   </PropertyGroup>
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props')" Text="$([System.String]::Format('$(ErrorText)', 'C:\NuGetLocalRepo\ILRepack.2.0.18\build\ILRepack.props'))" />
+  </Target>
 </Project>

+ 0 - 2
ISCSIConsole/MainForm.Designer.cs

@@ -28,7 +28,6 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
             this.btnStart = new System.Windows.Forms.Button();
             this.lblPort = new System.Windows.Forms.Label();
             this.txtPort = new System.Windows.Forms.TextBox();
@@ -169,7 +168,6 @@ namespace ISCSIConsole
             this.Controls.Add(this.lblPort);
             this.Controls.Add(this.btnStart);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(480, 220);
             this.MinimumSize = new System.Drawing.Size(480, 220);

+ 1 - 2
ISCSIConsole/MainForm.cs

@@ -19,7 +19,7 @@ using Utilities;
 
 namespace ISCSIConsole
 {
-    public partial class MainForm : Form
+    public partial class MainForm : BaseForm
     {
         private ISCSIServer m_server = new ISCSIServer();
         private List<ISCSITarget> m_targets = new List<ISCSITarget>();
@@ -228,7 +228,6 @@ namespace ISCSIConsole
 
             for (int i = 0; i < arr.Length; i++)
             {
-
                 arr[i] = entries[i].CreateTarget();
             }
 

File diff suppressed because it is too large
+ 0 - 6173
ISCSIConsole/MainForm.resx


+ 4 - 1
ISCSIConsole/Mods/AutoLoadEntry.cs

@@ -5,6 +5,7 @@ using System;
 using System.Collections.Generic;
 using System.Configuration;
 using System.Diagnostics;
+using System.Linq;
 using System.Xml;
 
 namespace ISCSIConsole.Mods
@@ -60,7 +61,7 @@ namespace ISCSIConsole.Mods
         {
             var disks = new List<Disk>();
             var target = new ISCSITarget(Iqn, disks);
-            foreach (var disk in Disks)
+            foreach (var disk in Disks.Where(p=>p.Enable))
             {
                 disks.Add(disk.CreateDisk());
             }
@@ -87,6 +88,8 @@ namespace ISCSIConsole.Mods
                         if (false == bdd.IsNoBaseImage) throw new ConfigurationErrorsException("RamDiskFromFile: Only ** No Base Image Mode ** supported");
 
                         var ramDisk = new UnmanagedGigabyteBlockSeparatedRamDisk((int)Math.Ceiling(bdd.Size / (float)Consts.Gigabyte));
+                        ramDisk.Allocate();
+
                         var buffer = new byte[bdd.BlockSize];
                         for (var i = 0; i < bdd.NumberOfBlocks; i++)
                         {

+ 12 - 0
ISCSIConsole/Mods/BaseForm.cs

@@ -0,0 +1,12 @@
+using System.Windows.Forms;
+
+namespace ISCSIConsole.Mods
+{
+    public class BaseForm : Form
+    {
+        public BaseForm()
+        {
+            Icon = IconExtractor.GetMainIcon();
+        }
+    }
+}

+ 195 - 0
ISCSIConsole/Mods/IconExtractor.cs

@@ -0,0 +1,195 @@
+/*
+ *  IconExtractor/IconUtil for .NET
+ *  Copyright (C) 2014 Tsuda Kageyu. All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ *  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ *  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
+ *  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace ISCSIConsole.Mods
+{
+    internal class IconExtractor
+    {
+        ////////////////////////////////////////////////////////////////////////
+        // Constants
+
+        // Flags for LoadLibraryEx().
+
+        private const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
+
+        // Resource types for EnumResourceNames().
+
+        private static readonly IntPtr RtIcon = (IntPtr)3;
+        private static readonly IntPtr RtGroupIcon = (IntPtr)14;
+
+        ////////////////////////////////////////////////////////////////////////
+        // Fields
+
+        private byte[][] _iconData = null;   // Binary data of each icon.
+
+        ////////////////////////////////////////////////////////////////////////
+        // Public properties
+
+        /// <summary>
+        /// Gets the count of the icons in the associated file.
+        /// </summary>
+        public int Count => _iconData.Length;
+
+        /// <summary>
+        /// Initializes a new instance of the IconExtractor class from the specified file name.
+        /// </summary>
+        /// <param name="fileName">The file to extract icons from.</param>
+        public IconExtractor(string fileName) => Initialize(fileName);
+
+        /// <summary>
+        /// Extracts an icon from the file.
+        /// </summary>
+        /// <param name="index">Zero based index of the icon to be extracted.</param>
+        /// <returns>A System.Drawing.Icon object.</returns>
+        /// <remarks>Always returns new copy of the Icon. It should be disposed by the user.</remarks>
+        public Icon GetIcon(int index)
+        {
+            if (index < 0 || Count <= index) throw new ArgumentOutOfRangeException(nameof(index));
+
+            // Create an Icon based on a .ico file in memory.
+
+            using (var ms = new MemoryStream(_iconData[index])) return new Icon(ms);
+        }
+
+        private void Initialize(string fileName)
+        {
+            if (fileName == null) throw new ArgumentNullException(nameof(fileName));
+
+            var hModule = IntPtr.Zero;
+            try
+            {
+                hModule = NativeMethods.LoadLibraryEx(fileName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE);
+                if (hModule == IntPtr.Zero) throw new Win32Exception();
+
+                // Enumerate the icon resource and build .ico files in memory.
+
+                var tmpData = new List<byte[]>();
+
+                bool Callback(IntPtr h, IntPtr t, IntPtr name, IntPtr l)
+                {
+                    // Refer the following URL for the data structures used here:
+                    // http://msdn.microsoft.com/en-us/library/ms997538.aspx
+
+                    // RT_GROUP_ICON resource consists of a GRPICONDIR and GRPICONDIRENTRY's.
+
+                    var dir = GetDataFromResource(hModule, RtGroupIcon, name);
+
+                    // Calculate the size of an entire .icon file.
+
+                    int count = BitConverter.ToUInt16(dir, 4); // GRPICONDIR.idCount
+                    var len = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count
+                    for (var i = 0; i < count; ++i)
+                        len += BitConverter.ToInt32(dir, 6 + 14 * i + 8); // GRPICONDIRENTRY.dwBytesInRes
+
+                    using (var dst = new BinaryWriter(new MemoryStream(len)))
+                    {
+                        // Copy GRPICONDIR to ICONDIR.
+
+                        dst.Write(dir, 0, 6);
+
+                        var picOffset = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count
+
+                        for (var i = 0; i < count; ++i)
+                        {
+                            // Load the picture.
+
+                            var id = BitConverter.ToUInt16(dir, 6 + 14 * i + 12); // GRPICONDIRENTRY.nID
+                            var pic = GetDataFromResource(hModule, RtIcon, (IntPtr)id);
+
+                            // Copy GRPICONDIRENTRY to ICONDIRENTRY.
+
+                            dst.Seek(6 + 16 * i, SeekOrigin.Begin);
+
+                            dst.Write(dir, 6 + 14 * i, 8); // First 8bytes are identical.
+                            dst.Write(pic.Length); // ICONDIRENTRY.dwBytesInRes
+                            dst.Write(picOffset); // ICONDIRENTRY.dwImageOffset
+
+                            // Copy a picture.
+
+                            dst.Seek(picOffset, SeekOrigin.Begin);
+                            dst.Write(pic, 0, pic.Length);
+
+                            picOffset += pic.Length;
+                        }
+
+                        tmpData.Add(((MemoryStream)dst.BaseStream).ToArray());
+                    }
+
+                    return true;
+                }
+
+                NativeMethods.EnumResourceNames(hModule, RtGroupIcon, Callback, IntPtr.Zero);
+
+                _iconData = tmpData.ToArray();
+            }
+            finally
+            {
+                if (hModule != IntPtr.Zero) NativeMethods.FreeLibrary(hModule);
+            }
+        }
+
+        private static byte[] GetDataFromResource(IntPtr hModule, IntPtr type, IntPtr name)
+        {
+            // Load the binary data from the specified resource.
+
+            var hResInfo = NativeMethods.FindResource(hModule, name, type);
+            if (hResInfo == IntPtr.Zero)
+                throw new Win32Exception();
+
+            var hResData = NativeMethods.LoadResource(hModule, hResInfo);
+            if (hResData == IntPtr.Zero)
+                throw new Win32Exception();
+
+            var pResData = NativeMethods.LockResource(hResData);
+            if (pResData == IntPtr.Zero)
+                throw new Win32Exception();
+
+            var size = NativeMethods.SizeofResource(hModule, hResInfo);
+            if (size == 0)
+                throw new Win32Exception();
+
+            var buf = new byte[size];
+            Marshal.Copy(pResData, buf, 0, buf.Length);
+
+            return buf;
+        }
+
+        public static Icon GetMainIcon()
+        {
+            var iex = new IconExtractor(Application.ExecutablePath);
+            return iex.Count > 0 ? iex.GetIcon(0) : null;
+        }
+    }
+}

+ 41 - 0
ISCSIConsole/Mods/NativeMethods.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+
+namespace ISCSIConsole.Mods
+{
+    internal static class NativeMethods
+    {
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);
+
+        [DllImport("kernel32.dll", SetLastError = true)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern bool FreeLibrary(IntPtr hModule);
+
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern bool EnumResourceNames(IntPtr hModule, IntPtr lpszType, Enumresnameproc lpEnumFunc, IntPtr lParam);
+
+        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern IntPtr FindResource(IntPtr hModule, IntPtr lpName, IntPtr lpType);
+
+        [DllImport("kernel32.dll", SetLastError = true)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern IntPtr LoadResource(IntPtr hModule, IntPtr hResInfo);
+
+        [DllImport("kernel32.dll", SetLastError = true)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern IntPtr LockResource(IntPtr hResData);
+
+        [DllImport("kernel32.dll", SetLastError = true)]
+        [SuppressUnmanagedCodeSecurity]
+        public static extern uint SizeofResource(IntPtr hModule, IntPtr hResInfo);
+    }
+
+    [UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)]
+    [SuppressUnmanagedCodeSecurity]
+    internal delegate bool Enumresnameproc(IntPtr hModule, IntPtr lpszType, IntPtr lpszName, IntPtr lParam);
+}

+ 0 - 1
ISCSIConsole/SelectDiskImageForm.Designer.cs

@@ -139,7 +139,6 @@ namespace ISCSIConsole
             this.Controls.Add(this.btnBrowse);
             this.Controls.Add(this.txtFilePath);
             this.Controls.Add(this.lblFilePath);
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 500);
             this.MinimumSize = new System.Drawing.Size(400, 150);

+ 2 - 1
ISCSIConsole/SelectDiskImageForm.cs

@@ -1,11 +1,12 @@
 using DiskAccessLibrary;
+using ISCSIConsole.Mods;
 using System;
 using System.IO;
 using System.Windows.Forms;
 
 namespace ISCSIConsole
 {
-    public partial class SelectDiskImageForm : Form
+    public partial class SelectDiskImageForm : BaseForm
     {
         private DiskImage m_diskImage;
 

File diff suppressed because it is too large
+ 0 - 6173
ISCSIConsole/SelectDiskImageForm.resx


+ 6 - 8
ISCSIConsole/Win32/SelectPhysicalDiskForm.Designer.cs

@@ -28,15 +28,14 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SelectPhysicalDiskForm));
             this.btnCancel = new System.Windows.Forms.Button();
             this.btnOK = new System.Windows.Forms.Button();
             this.chkReadOnly = new System.Windows.Forms.CheckBox();
             this.listPhysicalDisks = new System.Windows.Forms.ListView();
-            this.columnDisk = new System.Windows.Forms.ColumnHeader();
-            this.columnDescription = new System.Windows.Forms.ColumnHeader();
-            this.columnSerialNumber = new System.Windows.Forms.ColumnHeader();
-            this.columnSize = new System.Windows.Forms.ColumnHeader();
+            this.columnDisk = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnSerialNumber = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.SuspendLayout();
             // 
             // btnCancel
@@ -65,7 +64,7 @@ namespace ISCSIConsole
             this.chkReadOnly.AutoSize = true;
             this.chkReadOnly.Location = new System.Drawing.Point(12, 195);
             this.chkReadOnly.Name = "chkReadOnly";
-            this.chkReadOnly.Size = new System.Drawing.Size(76, 17);
+            this.chkReadOnly.Size = new System.Drawing.Size(78, 16);
             this.chkReadOnly.TabIndex = 3;
             this.chkReadOnly.Text = "Read Only";
             this.chkReadOnly.UseVisualStyleBackColor = true;
@@ -110,13 +109,12 @@ namespace ISCSIConsole
             this.AcceptButton = this.btnOK;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
             this.CancelButton = this.btnCancel;
-            this.ClientSize = new System.Drawing.Size(494, 225);
+            this.ClientSize = new System.Drawing.Size(484, 211);
             this.Controls.Add(this.listPhysicalDisks);
             this.Controls.Add(this.chkReadOnly);
             this.Controls.Add(this.btnOK);
             this.Controls.Add(this.btnCancel);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 250);
             this.MinimumSize = new System.Drawing.Size(500, 250);

+ 4 - 7
ISCSIConsole/Win32/SelectPhysicalDiskForm.cs

@@ -1,16 +1,13 @@
+using DiskAccessLibrary;
+using DiskAccessLibrary.LogicalDiskManager;
+using ISCSIConsole.Mods;
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
 using System.Windows.Forms;
-using DiskAccessLibrary;
-using DiskAccessLibrary.LogicalDiskManager;
-using Utilities;
 
 namespace ISCSIConsole
 {
-    public partial class SelectPhysicalDiskForm : Form
+    public partial class SelectPhysicalDiskForm : BaseForm
     {
         private PhysicalDisk m_selectedDisk;
 

File diff suppressed because it is too large
+ 2 - 6175
ISCSIConsole/Win32/SelectPhysicalDiskForm.resx


+ 7 - 9
ISCSIConsole/Win32/SelectVolumeForm.Designer.cs

@@ -28,16 +28,15 @@ namespace ISCSIConsole
         /// </summary>
         private void InitializeComponent()
         {
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SelectVolumeForm));
             this.btnCancel = new System.Windows.Forms.Button();
             this.btnOK = new System.Windows.Forms.Button();
             this.chkReadOnly = new System.Windows.Forms.CheckBox();
             this.listVolumes = new System.Windows.Forms.ListView();
-            this.columnVolume = new System.Windows.Forms.ColumnHeader();
-            this.columnName = new System.Windows.Forms.ColumnHeader();
-            this.columnType = new System.Windows.Forms.ColumnHeader();
-            this.columnStatus = new System.Windows.Forms.ColumnHeader();
-            this.columnSize = new System.Windows.Forms.ColumnHeader();
+            this.columnVolume = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.columnSize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.SuspendLayout();
             // 
             // btnCancel
@@ -66,7 +65,7 @@ namespace ISCSIConsole
             this.chkReadOnly.AutoSize = true;
             this.chkReadOnly.Location = new System.Drawing.Point(12, 195);
             this.chkReadOnly.Name = "chkReadOnly";
-            this.chkReadOnly.Size = new System.Drawing.Size(76, 17);
+            this.chkReadOnly.Size = new System.Drawing.Size(78, 16);
             this.chkReadOnly.TabIndex = 3;
             this.chkReadOnly.Text = "Read Only";
             this.chkReadOnly.UseVisualStyleBackColor = true;
@@ -116,13 +115,12 @@ namespace ISCSIConsole
             this.AcceptButton = this.btnOK;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
             this.CancelButton = this.btnCancel;
-            this.ClientSize = new System.Drawing.Size(494, 225);
+            this.ClientSize = new System.Drawing.Size(484, 211);
             this.Controls.Add(this.listVolumes);
             this.Controls.Add(this.chkReadOnly);
             this.Controls.Add(this.btnOK);
             this.Controls.Add(this.btnCancel);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
-            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
             this.MaximizeBox = false;
             this.MaximumSize = new System.Drawing.Size(500, 250);
             this.MinimumSize = new System.Drawing.Size(500, 250);

+ 6 - 9
ISCSIConsole/Win32/SelectVolumeForm.cs

@@ -1,16 +1,13 @@
+using DiskAccessLibrary;
+using DiskAccessLibrary.LogicalDiskManager;
+using ISCSIConsole.Mods;
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Text;
 using System.Windows.Forms;
-using DiskAccessLibrary;
-using DiskAccessLibrary.LogicalDiskManager;
-using Utilities;
 
 namespace ISCSIConsole
 {
-    public partial class SelectVolumeForm : Form
+    public partial class SelectVolumeForm : BaseForm
     {
         private Volume m_selectedVolume;
         private bool m_isReadOnly;
@@ -23,7 +20,7 @@ namespace ISCSIConsole
         private void SelectPhysicalDiskForm_Load(object sender, EventArgs e)
         {
             List<Volume> volumes = WindowsVolumeHelper.GetVolumes();
-            for(int index = 0; index < volumes.Count; index++)
+            for (int index = 0; index < volumes.Count; index++)
             {
                 Volume volume = volumes[index];
                 string title = String.Format("Volume {0}", index);
@@ -105,7 +102,7 @@ namespace ISCSIConsole
 
         private IList<PhysicalDisk> GetVolumeDisks(Volume volume)
         {
-            SortedList<int, PhysicalDisk> disks = new SortedList<int,PhysicalDisk>();
+            SortedList<int, PhysicalDisk> disks = new SortedList<int, PhysicalDisk>();
             if (volume is DynamicVolume)
             {
                 foreach (DiskExtent extent in ((DynamicVolume)volume).Extents)

File diff suppressed because it is too large
+ 2 - 6175
ISCSIConsole/Win32/SelectVolumeForm.resx


+ 2 - 2
ISCSIConsole/app.config

@@ -10,10 +10,10 @@
     <add key="AutoStart" value="true" />
   </appSettings>
   <autoLoad>
-    <entry Enable="true" Iqn="iqn.1991-05.com.talaloni:LocalRamDisk">
+    <entry Enable="false" Iqn="iqn.1991-05.com.talaloni:LocalRamDisk">
       <disk Enable="true" Type="RamDiskFromFile" FilePath="C:\Path\To\YourRamDisk.bdd" />
     </entry>
-    <entry Enable="true" Iqn="iqn.1991-05.com.talaloni:LocalDisk">
+    <entry Enable="false" Iqn="iqn.1991-05.com.talaloni:LocalDisk">
       <disk Enable="true" Type="AttachFile"  ReadOnly="true" FilePath="C:\Path\To\Your.img" />
       <disk Enable="true" Type="AttachFile" FilePath="C:\Path\To\Your.bdd" />
     </entry>

+ 4 - 0
ISCSIConsole/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="ILRepack" version="2.0.18" targetFramework="net472" />
+</packages>

+ 6 - 0
NuGet.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?> 
+<configuration> 
+  <config> 
+    <add key="repositorypath" value="C:\NuGetLocalRepo" /> 
+  </config> 
+</configuration>