diff --git a/Build/build.bat b/Build/build.bat
deleted file mode 100644
index da5fe8d..0000000
--- a/Build/build.bat
+++ /dev/null
@@ -1,2 +0,0 @@
-..\Tools\nuget pack ..\Src\Workshell.PE\Workshell.PE.csproj -Build -Prop Configuration=Release;
-..\Tools\nuget pack ..\Src\Workshell.PE.Resources\Workshell.PE.Resources.csproj -Build -Prop Configuration=Release;
\ No newline at end of file
diff --git a/Src/Debug Application/App.config b/Src/Debug Application/App.config
deleted file mode 100644
index 8e15646..0000000
--- a/Src/Debug Application/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Src/Debug Application/Debug Application.csproj b/Src/Debug Application/Debug Application.csproj
deleted file mode 100644
index 47ca090..0000000
--- a/Src/Debug Application/Debug Application.csproj
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {BE0852C4-A347-4E12-84C3-550AE6E5636F}
- Exe
- Properties
- Workshell.PE.Demo
- pedebug
- v4.5
- 512
-
-
- AnyCPU
- true
- full
- false
- ..\..\Bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- AnyCPU
- pdbonly
- true
- ..\..\Bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {2b06cbf8-136a-4bec-8624-861992139489}
- Workshell.PE.Resources
-
-
- {2e173d25-1c2e-4a7b-8b37-d231324d372d}
- Workshell.PE
-
-
-
-
-
\ No newline at end of file
diff --git a/Src/Debug Application/Program.cs b/Src/Debug Application/Program.cs
deleted file mode 100644
index 56a12f3..0000000
--- a/Src/Debug Application/Program.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using System.Reflection;
-using System.Security.Cryptography.X509Certificates;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-using Workshell.PE;
-using Workshell.PE.Imports;
-using Workshell.PE.Resources;
-using Workshell.PE.Relocations;
-
-namespace Workshell.PE.Demo
-{
-
- class Program
- {
-
- static void Main(string[] args)
- {
- //string file_name = Environment.GetCommandLineArgs()[0];
- //string file_name = Assembly.GetEntryAssembly().Location;
- //string file_name = @"C:\Windows\SysWOW64\kernel32.dll";
- //string file_name = @"C:\Windows\System32\kernel32.dll";
- //string file_name = @"C:\Windows\SysWOW64\shell32.dll";
- //string file_name = @"C:\Windows\System32\shell32.dll";
- //string file_name = @"C:\Windows\System32\user32.dll";
- //string file_name = @"C:\Windows\explorer.exe";
- //string file_name = @"C:\Windows\SysWOW64\xpsservices.dll";
- //string file_name = @"c:\windows\system32\advapi32.dll";
- //string file_name = @"C:\Program Files (x86)\Notepad++\notepad++.exe";
- string file_name = @"C:\Windows\System32\dsparse.dll";
- string error_message;
-
- if (!ExecutableImage.IsValid(file_name,out error_message))
- {
- Console.WriteLine("Invalid executable image: " + error_message);
-
- return;
- }
-
- MessageTableResource.Register();
-
- var image = ExecutableImage.FromFile(file_name);
- var delayedImports = DelayImportCollection.Get(image);
-
- }
-
- }
-
-}
diff --git a/Src/Debug Application/Properties/AssemblyInfo.cs b/Src/Debug Application/Properties/AssemblyInfo.cs
deleted file mode 100644
index f62e741..0000000
--- a/Src/Debug Application/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Demo Application")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Demo Application")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("772dcbca-dca9-42e6-b69e-3b16c8a4b72e")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Src/PE Dump/App.config b/Src/PE Dump/App.config
deleted file mode 100644
index 74ade9d..0000000
--- a/Src/PE Dump/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/Src/PE Dump/Options.cs b/Src/PE Dump/Options.cs
deleted file mode 100644
index f4b9d7c..0000000
--- a/Src/PE Dump/Options.cs
+++ /dev/null
@@ -1,1474 +0,0 @@
-//
-// Options.cs
-//
-// Authors:
-// Jonathan Pryor
-// Federico Di Gregorio
-// Rolf Bjarne Kvinge
-//
-// Copyright (C) 2008 Novell (http://www.novell.com)
-// Copyright (C) 2009 Federico Di Gregorio.
-// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-// Compile With:
-// gmcs -debug+ -r:System.Core Options.cs -o:NDesk.Options.dll
-// gmcs -debug+ -d:LINQ -r:System.Core Options.cs -o:NDesk.Options.dll
-//
-// The LINQ version just changes the implementation of
-// OptionSet.Parse(IEnumerable), and confers no semantic changes.
-
-//
-// A Getopt::Long-inspired option parsing library for C#.
-//
-// NDesk.Options.OptionSet is built upon a key/value table, where the
-// key is a option format string and the value is a delegate that is
-// invoked when the format string is matched.
-//
-// Option format strings:
-// Regex-like BNF Grammar:
-// name: .+
-// type: [=:]
-// sep: ( [^{}]+ | '{' .+ '}' )?
-// aliases: ( name type sep ) ( '|' name type sep )*
-//
-// Each '|'-delimited name is an alias for the associated action. If the
-// format string ends in a '=', it has a required value. If the format
-// string ends in a ':', it has an optional value. If neither '=' or ':'
-// is present, no value is supported. `=' or `:' need only be defined on one
-// alias, but if they are provided on more than one they must be consistent.
-//
-// Each alias portion may also end with a "key/value separator", which is used
-// to split option values if the option accepts > 1 value. If not specified,
-// it defaults to '=' and ':'. If specified, it can be any character except
-// '{' and '}' OR the *string* between '{' and '}'. If no separator should be
-// used (i.e. the separate values should be distinct arguments), then "{}"
-// should be used as the separator.
-//
-// Options are extracted either from the current option by looking for
-// the option name followed by an '=' or ':', or is taken from the
-// following option IFF:
-// - The current option does not contain a '=' or a ':'
-// - The current option requires a value (i.e. not a Option type of ':')
-//
-// The `name' used in the option format string does NOT include any leading
-// option indicator, such as '-', '--', or '/'. All three of these are
-// permitted/required on any named option.
-//
-// Option bundling is permitted so long as:
-// - '-' is used to start the option group
-// - all of the bundled options are a single character
-// - at most one of the bundled options accepts a value, and the value
-// provided starts from the next character to the end of the string.
-//
-// This allows specifying '-a -b -c' as '-abc', and specifying '-D name=value'
-// as '-Dname=value'.
-//
-// Option processing is disabled by specifying "--". All options after "--"
-// are returned by OptionSet.Parse() unchanged and unprocessed.
-//
-// Unprocessed options are returned from OptionSet.Parse().
-//
-// Examples:
-// int verbose = 0;
-// OptionSet p = new OptionSet ()
-// .Add ("v", v => ++verbose)
-// .Add ("name=|value=", v => Console.WriteLine (v));
-// p.Parse (new string[]{"-v", "--v", "/v", "-name=A", "/name", "B", "extra"});
-//
-// The above would parse the argument string array, and would invoke the
-// lambda expression three times, setting `verbose' to 3 when complete.
-// It would also print out "A" and "B" to standard output.
-// The returned array would contain the string "extra".
-//
-// C# 3.0 collection initializers are supported and encouraged:
-// var p = new OptionSet () {
-// { "h|?|help", v => ShowHelp () },
-// };
-//
-// System.ComponentModel.TypeConverter is also supported, allowing the use of
-// custom data types in the callback type; TypeConverter.ConvertFromString()
-// is used to convert the value option to an instance of the specified
-// type:
-//
-// var p = new OptionSet () {
-// { "foo=", (Foo f) => Console.WriteLine (f.ToString ()) },
-// };
-//
-// Random other tidbits:
-// - Boolean options (those w/o '=' or ':' in the option format string)
-// are explicitly enabled if they are followed with '+', and explicitly
-// disabled if they are followed with '-':
-// string a = null;
-// var p = new OptionSet () {
-// { "a", s => a = s },
-// };
-// p.Parse (new string[]{"-a"}); // sets v != null
-// p.Parse (new string[]{"-a+"}); // sets v != null
-// p.Parse (new string[]{"-a-"}); // sets v == null
-//
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Globalization;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Security.Permissions;
-using System.Text;
-using System.Text.RegularExpressions;
-
-#if LINQ
-using System.Linq;
-#endif
-
-#if TEST
-using NDesk.Options;
-#endif
-
-#if NDESK_OPTIONS
-namespace NDesk.Options
-#else
-namespace Mono.Options
-#endif
-{
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- static class StringCoda
- {
-
- public static IEnumerable WrappedLines(string self, params int[] widths)
- {
- IEnumerable w = widths;
- return WrappedLines(self, w);
- }
-
- public static IEnumerable WrappedLines(string self, IEnumerable widths)
- {
- if (widths == null)
- throw new ArgumentNullException("widths");
- return CreateWrappedLinesIterator(self, widths);
- }
-
- private static IEnumerable CreateWrappedLinesIterator(string self, IEnumerable widths)
- {
- if (string.IsNullOrEmpty(self))
- {
- yield return string.Empty;
- yield break;
- }
- using (IEnumerator ewidths = widths.GetEnumerator())
- {
- bool? hw = null;
- int width = GetNextWidth(ewidths, int.MaxValue, ref hw);
- int start = 0, end;
- do
- {
- end = GetLineEnd(start, width, self);
- char c = self[end - 1];
- if (char.IsWhiteSpace(c))
- --end;
- bool needContinuation = end != self.Length && !IsEolChar(c);
- string continuation = "";
- if (needContinuation)
- {
- --end;
- continuation = "-";
- }
- string line = self.Substring(start, end - start) + continuation;
- yield return line;
- start = end;
- if (char.IsWhiteSpace(c))
- ++start;
- width = GetNextWidth(ewidths, width, ref hw);
- } while (start < self.Length);
- }
- }
-
- private static int GetNextWidth(IEnumerator ewidths, int curWidth, ref bool? eValid)
- {
- if (!eValid.HasValue || (eValid.HasValue && eValid.Value))
- {
- curWidth = (eValid = ewidths.MoveNext()).Value ? ewidths.Current : curWidth;
- // '.' is any character, - is for a continuation
- const string minWidth = ".-";
- if (curWidth < minWidth.Length)
- throw new ArgumentOutOfRangeException("widths",
- string.Format("Element must be >= {0}, was {1}.", minWidth.Length, curWidth));
- return curWidth;
- }
- // no more elements, use the last element.
- return curWidth;
- }
-
- private static bool IsEolChar(char c)
- {
- return !char.IsLetterOrDigit(c);
- }
-
- private static int GetLineEnd(int start, int length, string description)
- {
- int end = System.Math.Min(start + length, description.Length);
- int sep = -1;
- for (int i = start; i < end; ++i)
- {
- if (description[i] == '\n')
- return i + 1;
- if (IsEolChar(description[i]))
- sep = i + 1;
- }
- if (sep == -1 || end == description.Length)
- return end;
- return sep;
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public class OptionValueCollection : IList, IList
- {
-
- List values = new List();
- OptionContext c;
-
- internal OptionValueCollection(OptionContext c)
- {
- this.c = c;
- }
-
- #region ICollection
- void ICollection.CopyTo(Array array, int index) { (values as ICollection).CopyTo(array, index); }
- bool ICollection.IsSynchronized { get { return (values as ICollection).IsSynchronized; } }
- object ICollection.SyncRoot { get { return (values as ICollection).SyncRoot; } }
- #endregion
-
- #region ICollection
- public void Add(string item) { values.Add(item); }
- public void Clear() { values.Clear(); }
- public bool Contains(string item) { return values.Contains(item); }
- public void CopyTo(string[] array, int arrayIndex) { values.CopyTo(array, arrayIndex); }
- public bool Remove(string item) { return values.Remove(item); }
- public int Count { get { return values.Count; } }
- public bool IsReadOnly { get { return false; } }
- #endregion
-
- #region IEnumerable
- IEnumerator IEnumerable.GetEnumerator() { return values.GetEnumerator(); }
- #endregion
-
- #region IEnumerable
- public IEnumerator GetEnumerator() { return values.GetEnumerator(); }
- #endregion
-
- #region IList
- int IList.Add(object value) { return (values as IList).Add(value); }
- bool IList.Contains(object value) { return (values as IList).Contains(value); }
- int IList.IndexOf(object value) { return (values as IList).IndexOf(value); }
- void IList.Insert(int index, object value) { (values as IList).Insert(index, value); }
- void IList.Remove(object value) { (values as IList).Remove(value); }
- void IList.RemoveAt(int index) { (values as IList).RemoveAt(index); }
- bool IList.IsFixedSize { get { return false; } }
- object IList.this[int index] { get { return this[index]; } set { (values as IList)[index] = value; } }
- #endregion
-
- #region IList
- public int IndexOf(string item) { return values.IndexOf(item); }
- public void Insert(int index, string item) { values.Insert(index, item); }
- public void RemoveAt(int index) { values.RemoveAt(index); }
-
- private void AssertValid(int index)
- {
- if (c.Option == null)
- throw new InvalidOperationException("OptionContext.Option is null.");
- if (index >= c.Option.MaxValueCount)
- throw new ArgumentOutOfRangeException("index");
- if (c.Option.OptionValueType == OptionValueType.Required &&
- index >= values.Count)
- throw new OptionException(string.Format(
- c.OptionSet.MessageLocalizer("Missing required value for option '{0}'."), c.OptionName),
- c.OptionName);
- }
-
- public string this[int index]
- {
- get
- {
- AssertValid(index);
- return index >= values.Count ? null : values[index];
- }
- set
- {
- values[index] = value;
- }
- }
- #endregion
-
- public List ToList()
- {
- return new List(values);
- }
-
- public string[] ToArray()
- {
- return values.ToArray();
- }
-
- public override string ToString()
- {
- return string.Join(", ", values.ToArray());
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public class OptionContext
- {
- private Option option;
- private string name;
- private int index;
- private OptionSet set;
- private OptionValueCollection c;
-
- public OptionContext(OptionSet set)
- {
- this.set = set;
- this.c = new OptionValueCollection(this);
- }
-
- public Option Option
- {
- get { return option; }
- set { option = value; }
- }
-
- public string OptionName
- {
- get { return name; }
- set { name = value; }
- }
-
- public int OptionIndex
- {
- get { return index; }
- set { index = value; }
- }
-
- public OptionSet OptionSet
- {
- get { return set; }
- }
-
- public OptionValueCollection OptionValues
- {
- get { return c; }
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public enum OptionValueType
- {
- None,
- Optional,
- Required,
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public abstract class Option
- {
- string prototype, description;
- string[] names;
- OptionValueType type;
- int count;
- string[] separators;
- bool hidden;
-
- protected Option(string prototype, string description)
- : this(prototype, description, 1, false)
- {
- }
-
- protected Option(string prototype, string description, int maxValueCount)
- : this(prototype, description, maxValueCount, false)
- {
- }
-
- protected Option(string prototype, string description, int maxValueCount, bool hidden)
- {
- if (prototype == null)
- throw new ArgumentNullException("prototype");
- if (prototype.Length == 0)
- throw new ArgumentException("Cannot be the empty string.", "prototype");
- if (maxValueCount < 0)
- throw new ArgumentOutOfRangeException("maxValueCount");
-
- this.prototype = prototype;
- this.description = description;
- this.count = maxValueCount;
- this.names = (this is OptionSet.Category)
- // append GetHashCode() so that "duplicate" categories have distinct
- // names, e.g. adding multiple "" categories should be valid.
- ? new[] { prototype + this.GetHashCode() }
- : prototype.Split('|');
-
- if (this is OptionSet.Category)
- return;
-
- this.type = ParsePrototype();
- this.hidden = hidden;
-
- if (this.count == 0 && type != OptionValueType.None)
- throw new ArgumentException(
- "Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
- "OptionValueType.Optional.",
- "maxValueCount");
- if (this.type == OptionValueType.None && maxValueCount > 1)
- throw new ArgumentException(
- string.Format("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount),
- "maxValueCount");
- if (Array.IndexOf(names, "<>") >= 0 &&
- ((names.Length == 1 && this.type != OptionValueType.None) ||
- (names.Length > 1 && this.MaxValueCount > 1)))
- throw new ArgumentException(
- "The default option handler '<>' cannot require values.",
- "prototype");
- }
-
- public string Prototype { get { return prototype; } }
- public string Description { get { return description; } }
- public OptionValueType OptionValueType { get { return type; } }
- public int MaxValueCount { get { return count; } }
- public bool Hidden { get { return hidden; } }
-
- public string[] GetNames()
- {
- return (string[])names.Clone();
- }
-
- public string[] GetValueSeparators()
- {
- if (separators == null)
- return new string[0];
- return (string[])separators.Clone();
- }
-
- protected static T Parse(string value, OptionContext c)
- {
- Type tt = typeof(T);
- bool nullable = tt.IsValueType && tt.IsGenericType &&
- !tt.IsGenericTypeDefinition &&
- tt.GetGenericTypeDefinition() == typeof(Nullable<>);
- Type targetType = nullable ? tt.GetGenericArguments()[0] : typeof(T);
- TypeConverter conv = TypeDescriptor.GetConverter(targetType);
- T t = default(T);
- try
- {
- if (value != null)
- t = (T)conv.ConvertFromString(value);
- }
- catch (Exception e)
- {
- throw new OptionException(
- string.Format(
- c.OptionSet.MessageLocalizer("Could not convert string `{0}' to type {1} for option `{2}'."),
- value, targetType.Name, c.OptionName),
- c.OptionName, e);
- }
- return t;
- }
-
- internal string[] Names { get { return names; } }
- internal string[] ValueSeparators { get { return separators; } }
-
- static readonly char[] NameTerminator = new char[] { '=', ':' };
-
- private OptionValueType ParsePrototype()
- {
- char type = '\0';
- List seps = new List();
- for (int i = 0; i < names.Length; ++i)
- {
- string name = names[i];
- if (name.Length == 0)
- throw new ArgumentException("Empty option names are not supported.", "prototype");
-
- int end = name.IndexOfAny(NameTerminator);
- if (end == -1)
- continue;
- names[i] = name.Substring(0, end);
- if (type == '\0' || type == name[end])
- type = name[end];
- else
- throw new ArgumentException(
- string.Format("Conflicting option types: '{0}' vs. '{1}'.", type, name[end]),
- "prototype");
- AddSeparators(name, end, seps);
- }
-
- if (type == '\0')
- return OptionValueType.None;
-
- if (count <= 1 && seps.Count != 0)
- throw new ArgumentException(
- string.Format("Cannot provide key/value separators for Options taking {0} value(s).", count),
- "prototype");
- if (count > 1)
- {
- if (seps.Count == 0)
- this.separators = new string[] { ":", "=" };
- else if (seps.Count == 1 && seps[0].Length == 0)
- this.separators = null;
- else
- this.separators = seps.ToArray();
- }
-
- return type == '=' ? OptionValueType.Required : OptionValueType.Optional;
- }
-
- private static void AddSeparators(string name, int end, ICollection seps)
- {
- int start = -1;
- for (int i = end + 1; i < name.Length; ++i)
- {
- switch (name[i])
- {
- case '{':
- if (start != -1)
- throw new ArgumentException(
- string.Format("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- start = i + 1;
- break;
- case '}':
- if (start == -1)
- throw new ArgumentException(
- string.Format("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- seps.Add(name.Substring(start, i - start));
- start = -1;
- break;
- default:
- if (start == -1)
- seps.Add(name[i].ToString());
- break;
- }
- }
- if (start != -1)
- throw new ArgumentException(
- string.Format("Ill-formed name/value separator found in \"{0}\".", name),
- "prototype");
- }
-
- public void Invoke(OptionContext c)
- {
- OnParseComplete(c);
- c.OptionName = null;
- c.Option = null;
- c.OptionValues.Clear();
- }
-
- protected abstract void OnParseComplete(OptionContext c);
-
- public override string ToString()
- {
- return Prototype;
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public abstract class ArgumentSource
- {
-
- protected ArgumentSource()
- {
- }
-
- public abstract string[] GetNames();
- public abstract string Description { get; }
- public abstract bool GetArguments(string value, out IEnumerable replacement);
-
- public static IEnumerable GetArgumentsFromFile(string file)
- {
- return GetArguments(File.OpenText(file), true);
- }
-
- public static IEnumerable GetArguments(TextReader reader)
- {
- return GetArguments(reader, false);
- }
-
- // Cribbed from mcs/driver.cs:LoadArgs(string)
- static IEnumerable GetArguments(TextReader reader, bool close)
- {
- try
- {
- StringBuilder arg = new StringBuilder();
-
- string line;
- while ((line = reader.ReadLine()) != null)
- {
- int t = line.Length;
-
- for (int i = 0; i < t; i++)
- {
- char c = line[i];
-
- if (c == '"' || c == '\'')
- {
- char end = c;
-
- for (i++; i < t; i++)
- {
- c = line[i];
-
- if (c == end)
- break;
- arg.Append(c);
- }
- }
- else if (c == ' ')
- {
- if (arg.Length > 0)
- {
- yield return arg.ToString();
- arg.Length = 0;
- }
- }
- else
- arg.Append(c);
- }
- if (arg.Length > 0)
- {
- yield return arg.ToString();
- arg.Length = 0;
- }
- }
- }
- finally
- {
- if (close)
- reader.Close();
- }
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public class ResponseFileSource : ArgumentSource
- {
-
- public override string[] GetNames()
- {
- return new string[] { "@file" };
- }
-
- public override string Description
- {
- get { return "Read response file for more options."; }
- }
-
- public override bool GetArguments(string value, out IEnumerable replacement)
- {
- if (string.IsNullOrEmpty(value) || !value.StartsWith("@"))
- {
- replacement = null;
- return false;
- }
- replacement = ArgumentSource.GetArgumentsFromFile(value.Substring(1));
- return true;
- }
- }
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- [Serializable]
- public class OptionException : Exception
- {
- private string option;
-
- public OptionException()
- {
- }
-
- public OptionException(string message, string optionName)
- : base(message)
- {
- this.option = optionName;
- }
-
- public OptionException(string message, string optionName, Exception innerException)
- : base(message, innerException)
- {
- this.option = optionName;
- }
-
- protected OptionException(SerializationInfo info, StreamingContext context)
- : base(info, context)
- {
- this.option = info.GetString("OptionName");
- }
-
- public string OptionName
- {
- get { return this.option; }
- }
-
- [SecurityPermission(SecurityAction.LinkDemand, SerializationFormatter = true)]
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData(info, context);
- info.AddValue("OptionName", option);
- }
- }
-
- public delegate void OptionAction(TKey key, TValue value);
-
- [System.Reflection.Obfuscation(ApplyToMembers = true, StripAfterObfuscation = true)]
- public class OptionSet : KeyedCollection
- {
- public OptionSet()
- : this(delegate (string f) { return f; })
- {
- }
-
- public OptionSet(Converter localizer)
- {
- this.localizer = localizer;
- this.roSources = new ReadOnlyCollection(sources);
- }
-
- Converter localizer;
-
- public Converter MessageLocalizer
- {
- get { return localizer; }
- }
-
- List sources = new List();
- ReadOnlyCollection roSources;
-
- public ReadOnlyCollection ArgumentSources
- {
- get { return roSources; }
- }
-
-
- protected override string GetKeyForItem(Option item)
- {
- if (item == null)
- throw new ArgumentNullException("option");
- if (item.Names != null && item.Names.Length > 0)
- return item.Names[0];
- // This should never happen, as it's invalid for Option to be
- // constructed w/o any names.
- throw new InvalidOperationException("Option has no names!");
- }
-
- [Obsolete("Use KeyedCollection.this[string]")]
- protected Option GetOptionForName(string option)
- {
- if (option == null)
- throw new ArgumentNullException("option");
- try
- {
- return base[option];
- }
- catch (KeyNotFoundException)
- {
- return null;
- }
- }
-
- protected override void InsertItem(int index, Option item)
- {
- base.InsertItem(index, item);
- AddImpl(item);
- }
-
- protected override void RemoveItem(int index)
- {
- Option p = Items[index];
- base.RemoveItem(index);
- // KeyedCollection.RemoveItem() handles the 0th item
- for (int i = 1; i < p.Names.Length; ++i)
- {
- Dictionary.Remove(p.Names[i]);
- }
- }
-
- protected override void SetItem(int index, Option item)
- {
- base.SetItem(index, item);
- AddImpl(item);
- }
-
- private void AddImpl(Option option)
- {
- if (option == null)
- throw new ArgumentNullException("option");
- List added = new List(option.Names.Length);
- try
- {
- // KeyedCollection.InsertItem/SetItem handle the 0th name.
- for (int i = 1; i < option.Names.Length; ++i)
- {
- Dictionary.Add(option.Names[i], option);
- added.Add(option.Names[i]);
- }
- }
- catch (Exception)
- {
- foreach (string name in added)
- Dictionary.Remove(name);
- throw;
- }
- }
-
- public OptionSet Add(string header)
- {
- if (header == null)
- throw new ArgumentNullException("header");
- Add(new Category(header));
- return this;
- }
-
- internal sealed class Category : Option
- {
-
- // Prototype starts with '=' because this is an invalid prototype
- // (see Option.ParsePrototype(), and thus it'll prevent Category
- // instances from being accidentally used as normal options.
- public Category(string description)
- : base("=:Category:= " + description, description)
- {
- }
-
- protected override void OnParseComplete(OptionContext c)
- {
- throw new NotSupportedException("Category.OnParseComplete should not be invoked.");
- }
- }
-
-
- public new OptionSet Add(Option option)
- {
- base.Add(option);
- return this;
- }
-
- sealed class ActionOption : Option
- {
- Action action;
-
- public ActionOption(string prototype, string description, int count, Action action)
- : this(prototype, description, count, action, false)
- {
- }
-
- public ActionOption(string prototype, string description, int count, Action action, bool hidden)
- : base(prototype, description, count, hidden)
- {
- if (action == null)
- throw new ArgumentNullException("action");
- this.action = action;
- }
-
- protected override void OnParseComplete(OptionContext c)
- {
- action(c.OptionValues);
- }
- }
-
- public OptionSet Add(string prototype, Action action)
- {
- return Add(prototype, null, action);
- }
-
- public OptionSet Add(string prototype, string description, Action action)
- {
- return Add(prototype, description, action, false);
- }
-
- public OptionSet Add(string prototype, string description, Action action, bool hidden)
- {
- if (action == null)
- throw new ArgumentNullException("action");
- Option p = new ActionOption(prototype, description, 1,
- delegate (OptionValueCollection v) { action(v[0]); }, hidden);
- base.Add(p);
- return this;
- }
-
- public OptionSet Add(string prototype, OptionAction action)
- {
- return Add(prototype, null, action);
- }
-
- public OptionSet Add(string prototype, string description, OptionAction action)
- {
- return Add(prototype, description, action, false);
- }
-
- public OptionSet Add(string prototype, string description, OptionAction action, bool hidden)
- {
- if (action == null)
- throw new ArgumentNullException("action");
- Option p = new ActionOption(prototype, description, 2,
- delegate (OptionValueCollection v) { action(v[0], v[1]); }, hidden);
- base.Add(p);
- return this;
- }
-
- sealed class ActionOption : Option
- {
- Action action;
-
- public ActionOption(string prototype, string description, Action action)
- : base(prototype, description, 1)
- {
- if (action == null)
- throw new ArgumentNullException("action");
- this.action = action;
- }
-
- protected override void OnParseComplete(OptionContext c)
- {
- action(Parse(c.OptionValues[0], c));
- }
- }
-
- sealed class ActionOption : Option
- {
- OptionAction action;
-
- public ActionOption(string prototype, string description, OptionAction action)
- : base(prototype, description, 2)
- {
- if (action == null)
- throw new ArgumentNullException("action");
- this.action = action;
- }
-
- protected override void OnParseComplete(OptionContext c)
- {
- action(
- Parse(c.OptionValues[0], c),
- Parse(c.OptionValues[1], c));
- }
- }
-
- public OptionSet Add(string prototype, Action action)
- {
- return Add(prototype, null, action);
- }
-
- public OptionSet Add(string prototype, string description, Action action)
- {
- return Add(new ActionOption(prototype, description, action));
- }
-
- public OptionSet Add(string prototype, OptionAction action)
- {
- return Add(prototype, null, action);
- }
-
- public OptionSet Add(string prototype, string description, OptionAction action)
- {
- return Add(new ActionOption(prototype, description, action));
- }
-
- public OptionSet Add(ArgumentSource source)
- {
- if (source == null)
- throw new ArgumentNullException("source");
- sources.Add(source);
- return this;
- }
-
- protected virtual OptionContext CreateOptionContext()
- {
- return new OptionContext(this);
- }
-
- public List Parse(IEnumerable arguments)
- {
- if (arguments == null)
- throw new ArgumentNullException("arguments");
- OptionContext c = CreateOptionContext();
- c.OptionIndex = -1;
- bool process = true;
- List unprocessed = new List();
- Option def = Contains("<>") ? this["<>"] : null;
- ArgumentEnumerator ae = new ArgumentEnumerator(arguments);
- foreach (string argument in ae)
- {
- ++c.OptionIndex;
- if (argument == "--")
- {
- process = false;
- continue;
- }
- if (!process)
- {
- Unprocessed(unprocessed, def, c, argument);
- continue;
- }
- if (AddSource(ae, argument))
- continue;
- if (!Parse(argument, c))
- Unprocessed(unprocessed, def, c, argument);
- }
- if (c.Option != null)
- c.Option.Invoke(c);
- return unprocessed;
- }
-
- class ArgumentEnumerator : IEnumerable
- {
- List> sources = new List>();
-
- public ArgumentEnumerator(IEnumerable arguments)
- {
- sources.Add(arguments.GetEnumerator());
- }
-
- public void Add(IEnumerable arguments)
- {
- sources.Add(arguments.GetEnumerator());
- }
-
- public IEnumerator GetEnumerator()
- {
- do
- {
- IEnumerator c = sources[sources.Count - 1];
- if (c.MoveNext())
- yield return c.Current;
- else
- {
- c.Dispose();
- sources.RemoveAt(sources.Count - 1);
- }
- } while (sources.Count > 0);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-
- bool AddSource(ArgumentEnumerator ae, string argument)
- {
- foreach (ArgumentSource source in sources)
- {
- IEnumerable replacement;
- if (!source.GetArguments(argument, out replacement))
- continue;
- ae.Add(replacement);
- return true;
- }
- return false;
- }
-
- private static bool Unprocessed(ICollection extra, Option def, OptionContext c, string argument)
- {
- if (def == null)
- {
- extra.Add(argument);
- return false;
- }
- c.OptionValues.Add(argument);
- c.Option = def;
- c.Option.Invoke(c);
- return false;
- }
-
- private readonly Regex ValueOption = new Regex(
- @"^(?--|-|/)(?[^:=]+)((?[:=])(?.*))?$");
-
- protected bool GetOptionParts(string argument, out string flag, out string name, out string sep, out string value)
- {
- if (argument == null)
- throw new ArgumentNullException("argument");
-
- flag = name = sep = value = null;
- Match m = ValueOption.Match(argument);
- if (!m.Success)
- {
- return false;
- }
- flag = m.Groups["flag"].Value;
- name = m.Groups["name"].Value;
- if (m.Groups["sep"].Success && m.Groups["value"].Success)
- {
- sep = m.Groups["sep"].Value;
- value = m.Groups["value"].Value;
- }
- return true;
- }
-
- protected virtual bool Parse(string argument, OptionContext c)
- {
- if (c.Option != null)
- {
- ParseValue(argument, c);
- return true;
- }
-
- string f, n, s, v;
- if (!GetOptionParts(argument, out f, out n, out s, out v))
- return false;
-
- Option p;
- if (Contains(n))
- {
- p = this[n];
- c.OptionName = f + n;
- c.Option = p;
- switch (p.OptionValueType)
- {
- case OptionValueType.None:
- c.OptionValues.Add(n);
- c.Option.Invoke(c);
- break;
- case OptionValueType.Optional:
- case OptionValueType.Required:
- ParseValue(v, c);
- break;
- }
- return true;
- }
- // no match; is it a bool option?
- if (ParseBool(argument, n, c))
- return true;
- // is it a bundled option?
- if (ParseBundledValue(f, string.Concat(n + s + v), c))
- return true;
-
- return false;
- }
-
- private void ParseValue(string option, OptionContext c)
- {
- if (option != null)
- foreach (string o in c.Option.ValueSeparators != null
- ? option.Split(c.Option.ValueSeparators, c.Option.MaxValueCount - c.OptionValues.Count, StringSplitOptions.None)
- : new string[] { option })
- {
- c.OptionValues.Add(o);
- }
- if (c.OptionValues.Count == c.Option.MaxValueCount ||
- c.Option.OptionValueType == OptionValueType.Optional)
- c.Option.Invoke(c);
- else if (c.OptionValues.Count > c.Option.MaxValueCount)
- {
- throw new OptionException(localizer(string.Format(
- "Error: Found {0} option values when expecting {1}.",
- c.OptionValues.Count, c.Option.MaxValueCount)),
- c.OptionName);
- }
- }
-
- private bool ParseBool(string option, string n, OptionContext c)
- {
- Option p;
- string rn;
- if (n.Length >= 1 && (n[n.Length - 1] == '+' || n[n.Length - 1] == '-') &&
- Contains((rn = n.Substring(0, n.Length - 1))))
- {
- p = this[rn];
- string v = n[n.Length - 1] == '+' ? option : null;
- c.OptionName = option;
- c.Option = p;
- c.OptionValues.Add(v);
- p.Invoke(c);
- return true;
- }
- return false;
- }
-
- private bool ParseBundledValue(string f, string n, OptionContext c)
- {
- if (f != "-")
- return false;
- for (int i = 0; i < n.Length; ++i)
- {
- Option p;
- string opt = f + n[i].ToString();
- string rn = n[i].ToString();
- if (!Contains(rn))
- {
- if (i == 0)
- return false;
- throw new OptionException(string.Format(localizer(
- "Cannot bundle unregistered option '{0}'."), opt), opt);
- }
- p = this[rn];
- switch (p.OptionValueType)
- {
- case OptionValueType.None:
- Invoke(c, opt, n, p);
- break;
- case OptionValueType.Optional:
- case OptionValueType.Required:
- {
- string v = n.Substring(i + 1);
- c.Option = p;
- c.OptionName = opt;
- ParseValue(v.Length != 0 ? v : null, c);
- return true;
- }
- default:
- throw new InvalidOperationException("Unknown OptionValueType: " + p.OptionValueType);
- }
- }
- return true;
- }
-
- private static void Invoke(OptionContext c, string name, string value, Option option)
- {
- c.OptionName = name;
- c.Option = option;
- c.OptionValues.Add(value);
- option.Invoke(c);
- }
-
- private const int OptionWidth = 29;
- private const int Description_FirstWidth = 80 - OptionWidth;
- private const int Description_RemWidth = 80 - OptionWidth - 2;
-
- public void WriteOptionDescriptions(TextWriter o)
- {
- foreach (Option p in this)
- {
- int written = 0;
-
- if (p.Hidden)
- continue;
-
- Category c = p as Category;
- if (c != null)
- {
- WriteDescription(o, p.Description, "", 80, 80);
- continue;
- }
-
- if (!WriteOptionPrototype(o, p, ref written))
- continue;
-
- if (written < OptionWidth)
- o.Write(new string(' ', OptionWidth - written));
- else
- {
- o.WriteLine();
- o.Write(new string(' ', OptionWidth));
- }
-
- WriteDescription(o, p.Description, new string(' ', OptionWidth + 2),
- Description_FirstWidth, Description_RemWidth);
- }
-
- foreach (ArgumentSource s in sources)
- {
- string[] names = s.GetNames();
- if (names == null || names.Length == 0)
- continue;
-
- int written = 0;
-
- Write(o, ref written, " ");
- Write(o, ref written, names[0]);
- for (int i = 1; i < names.Length; ++i)
- {
- Write(o, ref written, ", ");
- Write(o, ref written, names[i]);
- }
-
- if (written < OptionWidth)
- o.Write(new string(' ', OptionWidth - written));
- else
- {
- o.WriteLine();
- o.Write(new string(' ', OptionWidth));
- }
-
- WriteDescription(o, s.Description, new string(' ', OptionWidth + 2),
- Description_FirstWidth, Description_RemWidth);
- }
- }
-
- void WriteDescription(TextWriter o, string value, string prefix, int firstWidth, int remWidth)
- {
- bool indent = false;
- foreach (string line in GetLines(localizer(GetDescription(value)), firstWidth, remWidth))
- {
- if (indent)
- o.Write(prefix);
- o.WriteLine(line);
- indent = true;
- }
- }
-
- bool WriteOptionPrototype(TextWriter o, Option p, ref int written)
- {
- string[] names = p.Names;
-
- int i = GetNextOptionIndex(names, 0);
- if (i == names.Length)
- return false;
-
- if (names[i].Length == 1)
- {
- Write(o, ref written, " -");
- Write(o, ref written, names[0]);
- }
- else
- {
- Write(o, ref written, " --");
- Write(o, ref written, names[0]);
- }
-
- for (i = GetNextOptionIndex(names, i + 1);
- i < names.Length; i = GetNextOptionIndex(names, i + 1))
- {
- Write(o, ref written, ", ");
- Write(o, ref written, names[i].Length == 1 ? "-" : "--");
- Write(o, ref written, names[i]);
- }
-
- if (p.OptionValueType == OptionValueType.Optional ||
- p.OptionValueType == OptionValueType.Required)
- {
- if (p.OptionValueType == OptionValueType.Optional)
- {
- Write(o, ref written, localizer("["));
- }
- Write(o, ref written, localizer("=" + GetArgumentName(0, p.MaxValueCount, p.Description)));
- string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0
- ? p.ValueSeparators[0]
- : " ";
- for (int c = 1; c < p.MaxValueCount; ++c)
- {
- Write(o, ref written, localizer(sep + GetArgumentName(c, p.MaxValueCount, p.Description)));
- }
- if (p.OptionValueType == OptionValueType.Optional)
- {
- Write(o, ref written, localizer("]"));
- }
- }
- return true;
- }
-
- static int GetNextOptionIndex(string[] names, int i)
- {
- while (i < names.Length && names[i] == "<>")
- {
- ++i;
- }
- return i;
- }
-
- static void Write(TextWriter o, ref int n, string s)
- {
- n += s.Length;
- o.Write(s);
- }
-
- private static string GetArgumentName(int index, int maxIndex, string description)
- {
- if (description == null)
- return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
- string[] nameStart;
- if (maxIndex == 1)
- nameStart = new string[] { "{0:", "{" };
- else
- nameStart = new string[] { "{" + index + ":" };
- for (int i = 0; i < nameStart.Length; ++i)
- {
- int start, j = 0;
- do
- {
- start = description.IndexOf(nameStart[i], j);
- } while (start >= 0 && j != 0 ? description[j++ - 1] == '{' : false);
- if (start == -1)
- continue;
- int end = description.IndexOf("}", start);
- if (end == -1)
- continue;
- return description.Substring(start + nameStart[i].Length, end - start - nameStart[i].Length);
- }
- return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1);
- }
-
- private static string GetDescription(string description)
- {
- if (description == null)
- return string.Empty;
- StringBuilder sb = new StringBuilder(description.Length);
- int start = -1;
- for (int i = 0; i < description.Length; ++i)
- {
- switch (description[i])
- {
- case '{':
- if (i == start)
- {
- sb.Append('{');
- start = -1;
- }
- else if (start < 0)
- start = i + 1;
- break;
- case '}':
- if (start < 0)
- {
- if ((i + 1) == description.Length || description[i + 1] != '}')
- throw new InvalidOperationException("Invalid option description: " + description);
- ++i;
- sb.Append("}");
- }
- else
- {
- sb.Append(description.Substring(start, i - start));
- start = -1;
- }
- break;
- case ':':
- if (start < 0)
- goto default;
- start = i + 1;
- break;
- default:
- if (start < 0)
- sb.Append(description[i]);
- break;
- }
- }
- return sb.ToString();
- }
-
- private static IEnumerable GetLines(string description, int firstWidth, int remWidth)
- {
- return StringCoda.WrappedLines(description, firstWidth, remWidth);
- }
- }
-
-}
-
diff --git a/Src/PE Dump/PE Dump.csproj b/Src/PE Dump/PE Dump.csproj
deleted file mode 100644
index b833498..0000000
--- a/Src/PE Dump/PE Dump.csproj
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {3A01212E-8461-41A0-B154-22CBA75929A3}
- Exe
- Properties
- Workshell.PE.Dump
- pedump
- v4.0
- 512
-
-
-
- AnyCPU
- true
- full
- false
- ..\..\Bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- ..\..\Bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {2b06cbf8-136a-4bec-8624-861992139489}
- Workshell.PE.Resources
-
-
- {2e173d25-1c2e-4a7b-8b37-d231324d372d}
- Workshell.PE
-
-
-
-
-
\ No newline at end of file
diff --git a/Src/PE Dump/Program.cs b/Src/PE Dump/Program.cs
deleted file mode 100644
index fb57e75..0000000
--- a/Src/PE Dump/Program.cs
+++ /dev/null
@@ -1,1044 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Mono.Options;
-using Workshell.PE;
-using Workshell.PE.Annotations;
-using Workshell.PE.Debug;
-using Workshell.PE.LoadConfiguration;
-
-namespace Workshell.PE.Dump
-{
-
- class Program
- {
-
- private OptionSet options;
- private string offset_type;
- private bool show_all;
- private bool show_dos_header;
- private bool show_dos_stub;
- private bool show_file_header;
- private bool show_opt_header;
- private bool show_data_directories;
- private bool show_section_table;
- private bool show_debug;
- private bool show_load_config;
-
- public Program()
- {
- options = new OptionSet();
-
- options.Add("offset=", "", v => offset_type = v);
- options.Add("all", "", v => show_all = v != null);
- options.Add("dos-header", "", v => show_dos_header = v != null);
- options.Add("dos-stub", "", v => show_dos_stub = v != null);
- options.Add("file-header", "", v => show_file_header = v != null);
- options.Add("optional-header", "", v => show_opt_header = v != null);
- options.Add("data-directories", "", v => show_data_directories = v != null);
- options.Add("sections", "", v => show_section_table = v != null);
- options.Add("debug", "", v => show_debug = v != null);
- options.Add("load-config", "", v => show_load_config = v != null);
-
- offset_type = "fo";
- show_all = false;
- show_dos_header = false;
- show_dos_stub = false;
- show_file_header = false;
- show_opt_header = false;
- show_data_directories = false;
- show_section_table = false;
- show_debug = false;
- show_load_config = false;
- }
-
- #region Static Methods
-
- static int Main(string[] args)
- {
- return (new Program()).Run(args);
- }
-
- #endregion
-
- #region Methods
-
- public int Run(string[] args)
- {
- try
- {
- if (args.Length == 0)
- {
- Usage();
-
- return 1;
- }
-
- List extra = options.Parse(args);
-
- if (extra.Count == 0)
- {
- Console.WriteLine("Error: No file specified.");
-
- return 2;
- }
-
- string[] address_types = { "fo", "vo", "va", "rva" };
-
- if (!address_types.Contains(offset_type, StringComparer.OrdinalIgnoreCase))
- {
- Console.WriteLine("Error: Unknown address type - " + offset_type);
-
- return 3;
- }
-
- string file_name = extra[0];
- string valid_message = null;
-
- if (!ExecutableImage.IsValid(file_name, out valid_message))
- {
- Console.WriteLine("Error: {0}", valid_message);
-
- return 4;
- }
-
- ExecutableImage image = ExecutableImage.FromFile(file_name);
-
- try
- {
- if (show_all)
- {
- show_dos_header = true;
- show_dos_stub = true;
- show_file_header = true;
- show_opt_header = true;
- show_data_directories = true;
- show_section_table = true;
- show_debug = true;
- show_load_config = true;
- }
-
- int result = ShowBasicDetails(image, file_name);
-
- if (result == 0 && show_dos_header)
- result = ShowDOSHeader(image);
-
- if (result == 0 && show_dos_stub)
- result = ShowDOSStub(image);
-
- if (result == 0 && show_file_header)
- result = ShowFileHeader(image);
-
- if (result == 0 && show_opt_header)
- result = ShowOptionalHeader(image);
-
- if (result == 0 && show_data_directories)
- result = ShowDataDirectories(image);
-
- if (result == 0 && show_section_table)
- result = ShowSectionTable(image);
-
- if (result == 0 && show_debug)
- result = ShowDebugDirectory(image);
-
- if (result == 0 && show_load_config)
- result = ShowLoadConfig(image);
-
- return result;
- }
- finally
- {
- image.Dispose();
- }
- }
- catch (Exception ex)
- {
-#if DEBUG
- throw;
-#else
- Console.WriteLine("Error: {0}", ex.Message);
-
- return 666;
-#endif
- }
- }
-
- private void Usage()
- {
-
- }
-
- private int ShowBasicDetails(ExecutableImage image, string fileName)
- {
- Stream stream = image.GetStream();
- string image_type = "Unknown";
- CharacteristicsType characteristics = image.NTHeaders.FileHeader.GetCharacteristics();
-
- if ((characteristics & CharacteristicsType.IsDLL) == CharacteristicsType.IsDLL)
- {
- image_type = "Dynamic Link Library";
- }
- else
- {
- SubSystemType sub_system = image.NTHeaders.OptionalHeader.GetSubsystem();
-
- if (sub_system == SubSystemType.WindowsCUI)
- {
- image_type = "Console Application";
- }
- else if (sub_system == SubSystemType.WindowsGUI)
- {
- image_type = "Windows Application";
- }
- }
-
- Console.WriteLine("[ Basic Details ]");
- Console.WriteLine();
-
- Console.WriteLine(" Filename: {0}", Path.GetFileName(fileName));
- Console.WriteLine(" Path: {0}", Path.GetDirectoryName(fileName));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(stream.Length), stream.Length);
- Console.WriteLine(" Architecture: {0}", (image.Is64Bit ? "64-Bit" : "32-Bit"));
- Console.WriteLine(" Image Type: {0}", image_type);
- Console.WriteLine(" Is .NET: {0}", (image.IsCLR ? "Yes" : "No"));
- Console.WriteLine(" Is Signed: {0}", (image.IsSigned ? "Yes" : "No"));
-
- Console.WriteLine();
- Console.WriteLine();
-
- return 0;
- }
-
- private int ShowDOSHeader(ExecutableImage image)
- {
- Console.WriteLine("[ MS-DOS Header ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.DOSHeader.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.DOSHeader.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.DOSHeader.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.DOSHeader.Location.FileSize)), image.DOSHeader.Location.FileSize);
-
- Console.WriteLine();
-
- List> tuples = new List>();
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = image.DOSHeader.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = image.DOSHeader.Location.VirtualAddress;
- }
- else
- {
- offset = image.DOSHeader.Location.RelativeVirtualAddress;
- }
-
- int address_size = (image.Is64Bit ? 16 : 8);
-
- FieldAnnotations annotations = FieldAnnotations.Get(image.DOSHeader);
-
- foreach (FieldAnnotation annotation in annotations)
- {
- int size = annotation.Size;
- int array_size = (annotation.IsArray ? annotation.ArraySize : annotation.Size);
- object value = (annotation.IsArray ? Utils.GetDefaultValue(annotation.Type.GetElementType()) : annotation.Value);
-
- Tuple tuple = new Tuple(Utils.IntToHex(offset, address_size), Utils.IntToHex(value, size * 2), annotation.Description);
-
- tuples.Add(tuple);
-
- offset += Convert.ToUInt32(array_size);
- }
-
- int max_value_len = 0;
- int max_desc_len = 0;
-
- foreach(var tuple in tuples)
- {
- if (tuple.Item2.Length > max_value_len)
- max_value_len = tuple.Item2.Length;
-
- if (tuple.Item3.Length > max_desc_len)
- max_desc_len = tuple.Item3.Length;
- }
-
- string header = String.Format("{0} {1} {2}", "Address".PadRight(address_size + 2), "Value".PadRight(max_value_len), "Description".PadRight(max_desc_len));
-
- Console.WriteLine(" " + header);
- Console.WriteLine(" " + String.Empty.PadRight(header.Length, '-'));
-
- foreach (var tuple in tuples)
- Console.WriteLine(" {0} {1} {2}", tuple.Item1.PadRight(address_size + 2), tuple.Item2.PadRight(max_value_len), tuple.Item3.PadRight(max_desc_len));
-
- Console.WriteLine();
- Console.WriteLine();
-
- return 0;
- }
-
- private int ShowDOSStub(ExecutableImage image)
- {
- Console.WriteLine("[ MS-DOS Stub ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.DOSStub.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.DOSStub.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.DOSStub.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.DOSStub.Location.FileSize)), image.DOSStub.Location.FileSize);
-
- Console.WriteLine();
- Console.WriteLine();
-
- return 0;
- }
-
- private int ShowFileHeader(ExecutableImage image)
- {
- Console.WriteLine("[ File Header ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.NTHeaders.FileHeader.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.NTHeaders.FileHeader.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.NTHeaders.FileHeader.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.NTHeaders.FileHeader.Location.FileSize)), image.NTHeaders.FileHeader.Location.FileSize);
-
- Console.WriteLine();
-
- List> tuples = new List>();
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = image.NTHeaders.FileHeader.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = image.NTHeaders.FileHeader.Location.VirtualAddress;
- }
- else
- {
- offset = image.NTHeaders.FileHeader.Location.RelativeVirtualAddress;
- }
-
- int address_size = (image.Is64Bit ? 16 : 8);
-
- FieldAnnotations annotations = FieldAnnotations.Get(image.NTHeaders.FileHeader);
-
- foreach (FieldAnnotation annotation in annotations)
- {
- int size = annotation.Size;
- int array_size = (annotation.IsArray ? annotation.ArraySize : annotation.Size);
- object value = (annotation.IsArray ? Utils.GetDefaultValue(annotation.Type.GetElementType()) : annotation.Value);
-
- Tuple tuple = new Tuple(Utils.IntToHex(offset, address_size), Utils.IntToHex(value, size * 2), annotation.Description);
-
- tuples.Add(tuple);
-
- offset += Convert.ToUInt32(array_size);
- }
-
- int max_value_len = 0;
- int max_desc_len = 0;
-
- foreach (var tuple in tuples)
- {
- if (tuple.Item2.Length > max_value_len)
- max_value_len = tuple.Item2.Length;
-
- if (tuple.Item3.Length > max_desc_len)
- max_desc_len = tuple.Item3.Length;
- }
-
- string header = String.Format("{0} {1} {2}", "Address".PadRight(address_size + 2), "Value".PadRight(max_value_len), "Description".PadRight(max_desc_len));
-
- Console.WriteLine(" " + header);
- Console.WriteLine(" " + String.Empty.PadRight(header.Length, '-'));
-
- foreach (var tuple in tuples)
- Console.WriteLine(" {0} {1} {2}", tuple.Item1.PadRight(address_size + 2), tuple.Item2.PadRight(max_value_len), tuple.Item3.PadRight(max_desc_len));
-
- Console.WriteLine();
-
- ShowFileHeader_Characteristics(image);
-
- Console.WriteLine();
-
- return 0;
- }
-
- private void ShowFileHeader_Characteristics(ExecutableImage image)
- {
- List lines = new List();
-
- CharacteristicsType characteristics = image.NTHeaders.FileHeader.GetCharacteristics();
- long enum_value = Convert.ToInt64(characteristics);
- EnumAnnotations enum_annotations = new EnumAnnotations();
-
- foreach (EnumAnnotation annotation in enum_annotations)
- {
- long value = Convert.ToInt64(annotation.Value);
- bool selected = ((enum_value & value) == value);
-
- if (!selected)
- continue;
-
- string line = String.Format("{0} {1}", Utils.IntToHex(value, 4), annotation.HeaderName);
-
- lines.Add(line);
- }
-
- int max_len = 0;
-
- foreach (var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" Characteristics".PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach(var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
- }
-
- private int ShowOptionalHeader(ExecutableImage image)
- {
- Console.WriteLine("[ Optional Header ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.NTHeaders.OptionalHeader.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.NTHeaders.OptionalHeader.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.NTHeaders.OptionalHeader.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.NTHeaders.OptionalHeader.Location.FileSize)), image.NTHeaders.OptionalHeader.Location.FileSize);
- Console.WriteLine();
-
- List> tuples = new List>();
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = image.NTHeaders.OptionalHeader.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = image.NTHeaders.OptionalHeader.Location.VirtualAddress;
- }
- else
- {
- offset = image.NTHeaders.OptionalHeader.Location.RelativeVirtualAddress;
- }
-
- int address_size = (image.Is64Bit ? 16 : 8);
-
- string[] VARY_FIELDS = { "ImageBase", "SizeOfStackReserve", "SizeOfStackCommit", "SizeOfHeapReserve", "SizeOfHeapCommit" };
- FieldAnnotations annotations = FieldAnnotations.Get(image.NTHeaders.OptionalHeader);
-
- foreach (FieldAnnotation annotation in annotations)
- {
- int size = annotation.Size * 2;
-
- if (VARY_FIELDS.Contains(annotation.Name, StringComparer.OrdinalIgnoreCase))
- size = (image.Is64Bit ? 16 : 8);
-
- int array_size = (annotation.IsArray ? annotation.ArraySize : annotation.Size);
- object value = (annotation.IsArray ? Utils.GetDefaultValue(annotation.Type.GetElementType()) : annotation.Value);
-
- Tuple tuple = new Tuple(Utils.IntToHex(offset, address_size), Utils.IntToHex(value, size), annotation.Description);
-
- tuples.Add(tuple);
-
- offset += Convert.ToUInt32(array_size);
- }
-
- int max_value_len = 0;
- int max_desc_len = 0;
-
- foreach (var tuple in tuples)
- {
- if (tuple.Item2.Length > max_value_len)
- max_value_len = tuple.Item2.Length;
-
- if (tuple.Item3.Length > max_desc_len)
- max_desc_len = tuple.Item3.Length;
- }
-
- string header = String.Format("{0} {1} {2}", "Address".PadRight(address_size + 2), "Value".PadRight(max_value_len), "Description".PadRight(max_desc_len));
-
- Console.WriteLine(" " + header);
- Console.WriteLine(" " + String.Empty.PadRight(header.Length, '-'));
-
- foreach (var tuple in tuples)
- Console.WriteLine(" {0} {1} {2}", tuple.Item1.PadRight(address_size + 2), tuple.Item2.PadRight(max_value_len), tuple.Item3.PadRight(max_desc_len));
-
- Console.WriteLine();
-
- ShowOptionalHeader_SubSystem(image);
- ShowOptionalHeader_DllCharacteristics(image);
-
- Console.WriteLine();
-
- return 0;
- }
-
- private void ShowOptionalHeader_SubSystem(ExecutableImage image)
- {
- List lines = new List();
-
- SubSystemType sub_system = image.NTHeaders.OptionalHeader.GetSubsystem();
- long enum_value = Convert.ToInt64(sub_system);
- EnumAnnotations enum_annotations = new EnumAnnotations();
-
- foreach (EnumAnnotation annotation in enum_annotations)
- {
- long value = Convert.ToInt64(annotation.Value);
-
- if (value == 0)
- continue;
-
- bool selected = ((enum_value & value) == value);
-
- if (!selected)
- continue;
-
- string line = String.Format("{0} {1}", Utils.IntToHex(value, 4), annotation.HeaderName);
-
- lines.Add(line);
- }
-
- int max_len = 0;
-
- foreach (var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" Sub-System".PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach (var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
- }
-
- private void ShowOptionalHeader_DllCharacteristics(ExecutableImage image)
- {
- List lines = new List();
-
- DllCharacteristicsType dll_chars = image.NTHeaders.OptionalHeader.GetDllCharacteristics();
- long enum_value = Convert.ToInt64(dll_chars);
- EnumAnnotations enum_annotations = new EnumAnnotations();
-
- foreach (EnumAnnotation annotation in enum_annotations)
- {
- long value = Convert.ToInt64(annotation.Value);
-
- if (value == 0)
- continue;
-
- bool selected = ((enum_value & value) == value);
-
- if (!selected)
- continue;
-
- string line = String.Format("{0} {1}", Utils.IntToHex(value, 4), annotation.HeaderName);
-
- lines.Add(line);
- }
-
- int max_len = 0;
-
- foreach (var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" DLL Characteristics".PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach (var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
- }
-
- private int ShowDataDirectories(ExecutableImage image)
- {
- Console.WriteLine("[ Data Directories ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.NTHeaders.DataDirectories.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.NTHeaders.DataDirectories.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.NTHeaders.DataDirectories.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.NTHeaders.DataDirectories.Location.FileSize)), image.NTHeaders.DataDirectories.Location.FileSize);
- Console.WriteLine();
-
- int address_size = (image.Is64Bit ? 16 : 8);
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = image.NTHeaders.DataDirectories.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = image.NTHeaders.DataDirectories.Location.VirtualAddress;
- }
- else
- {
- offset = image.NTHeaders.DataDirectories.Location.RelativeVirtualAddress;
- }
-
- for(var i = 0; i < image.NTHeaders.DataDirectories.Count - 1; i++)
- {
- DataDirectory directory = image.NTHeaders.DataDirectories[i];
- string name;
-
- switch (directory.DirectoryType)
- {
- case DataDirectoryType.Unknown:
- name = String.Empty;
- break;
- case DataDirectoryType.ExportTable:
- name = "Export Table";
- break;
- case DataDirectoryType.ImportTable:
- name = "Import Table";
- break;
- case DataDirectoryType.ResourceTable:
- name = "Resource Table";
- break;
- case DataDirectoryType.ExceptionTable:
- name = "Exception Table";
- break;
- case DataDirectoryType.CertificateTable:
- name = "Certificate Table";
- break;
- case DataDirectoryType.BaseRelocationTable:
- name = "Base Relocation Table";
- break;
- case DataDirectoryType.Debug:
- name = "Debug Directory";
- break;
- case DataDirectoryType.Architecture:
- name = "Architecture";
- break;
- case DataDirectoryType.GlobalPtr:
- name = "Global Pointer";
- break;
- case DataDirectoryType.TLSTable:
- name = "TLS Table";
- break;
- case DataDirectoryType.LoadConfigTable:
- name = "Load Configuration Table";
- break;
- case DataDirectoryType.BoundImport:
- name = "Bound Import Table";
- break;
- case DataDirectoryType.ImportAddressTable:
- name = "Import Address Table";
- break;
- case DataDirectoryType.DelayImportDescriptor:
- name = "Delayed Import Descriptors";
- break;
- case DataDirectoryType.CLRRuntimeHeader:
- name = ".NET Common Language Runtime Header";
- break;
- default:
- name = "Unknown";
- break;
- }
-
- List lines = new List();
-
- lines.Add(String.Format("Entry Offset: {0}",Utils.IntToHex(offset, address_size)));
- lines.Add(String.Format("RVA: {0}", Utils.IntToHex(directory.VirtualAddress)));
- lines.Add(String.Format("Size: {0} ({1})", directory.Size, Utils.FormatBytes(directory.Size)));
-
- string section = directory.GetSectionName();
-
- if (!String.IsNullOrWhiteSpace(section))
- lines.Add(String.Format("Section: {0}", section));
-
- int max_len = name.Length;
-
- foreach(var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" " + name.PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach(var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
-
- offset += sizeof(uint) * 2;
- }
-
- Console.WriteLine();
-
- return 0;
- }
-
- private int ShowSectionTable(ExecutableImage image)
- {
- Console.WriteLine("[ Section Table ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(image.SectionTable.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(image.SectionTable.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(image.SectionTable.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(image.SectionTable.Location.FileSize)), image.SectionTable.Location.FileSize);
- Console.WriteLine();
-
- int address_size = (image.Is64Bit ? 16 : 8);
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = image.SectionTable.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = image.SectionTable.Location.VirtualAddress;
- }
- else
- {
- offset = image.SectionTable.Location.RelativeVirtualAddress;
- }
-
- foreach(SectionTableEntry section in image.SectionTable)
- {
- string name = section.Name;
- string[] chars = ShowSectionTable_Characteristics(section);
- List lines = new List();
-
- lines.Add(String.Format("Entry Offset: {0}", Utils.IntToHex(offset, address_size)));
- lines.Add(String.Format("Virtual Size: {0} ({1})", section.VirtualSizeOrPhysicalAddress, Utils.FormatBytes(section.VirtualSizeOrPhysicalAddress)));
- lines.Add(String.Format("RVA: {0}", Utils.IntToHex(section.VirtualAddress)));
- lines.Add(String.Format("Size of Raw Data: {0} ({1})", section.SizeOfRawData, Utils.FormatBytes(section.SizeOfRawData)));
- lines.Add(String.Format("Pointer to Raw Data: {0}", Utils.IntToHex(section.PointerToRawData)));
- lines.Add(String.Format("Pointer to Relocations: {0}", Utils.IntToHex(section.PointerToRelocations)));
- lines.Add(String.Format("Pointer to Line Numbers: {0}", Utils.IntToHex(section.PointerToLineNumbers)));
- lines.Add(String.Format("Number of Relocations: {0}", section.NumberOfRelocations));
- lines.Add(String.Format("Number of Line Numbers: {0}", section.NumberOfLineNumbers));
-
- if (chars.Length > 0)
- {
- lines.Add(String.Format("Characteristics: {0}", chars.First()));
-
- if (chars.Length > 1)
- {
- foreach(string line in chars.Skip(1))
- lines.Add(String.Format(" {0}", line));
- }
- }
-
- int max_len = name.Length;
-
- foreach (var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" " + name.PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach (var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
-
- offset += section.Location.FileSize;
- }
-
- Console.WriteLine();
-
- return 0;
- }
-
- private string[] ShowSectionTable_Characteristics(SectionTableEntry section)
- {
- List results = new List();
-
- SectionCharacteristicsType chars = section.GetCharacteristics();
- long enum_value = Convert.ToInt64(chars);
- EnumAnnotations enum_annotations = new EnumAnnotations();
-
- foreach (EnumAnnotation annotation in enum_annotations)
- {
- long value = Convert.ToInt64(annotation.Value);
-
- if (value == 0)
- continue;
-
- bool selected = ((enum_value & value) == value);
-
- if (!selected)
- continue;
-
- string line = String.Format("{0} {1}", Utils.IntToHex(value, 8), annotation.HeaderName);
-
- results.Add(line);
- }
-
- int max_len = 0;
-
- foreach (var line in results)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- return results.ToArray();
- }
-
- private int ShowDebugDirectory(ExecutableImage image)
- {
- DebugDirectory directory = DebugDirectory.Get(image);
-
- if (directory == null)
- return 0;
-
- Console.WriteLine("[ Debug Directory ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(directory.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(directory.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(directory.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(directory.Location.FileSize)), directory.Location.FileSize);
- Console.WriteLine();
-
- int address_size = (image.Is64Bit ? 16 : 8);
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = directory.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = directory.Location.VirtualAddress;
- }
- else
- {
- offset = directory.Location.RelativeVirtualAddress;
- }
-
- foreach (DebugDirectoryEntry entry in directory)
- {
- string name = entry.GetEntryType().ToString();
- string type = ShowDebugDirectory_Type(entry);
- List lines = new List();
-
- lines.Add(String.Format("Entry Offset: {0}", Utils.IntToHex(offset, address_size)));
- lines.Add(String.Format("Characteristics: {0}", Utils.IntToHex(entry.Characteristics)));
- lines.Add(String.Format("Date/Time Stamp: {0}", Utils.IntToHex(entry.TimeDateStamp)));
- lines.Add(String.Format("Major Version: {0}", Utils.IntToHex(entry.MajorVersion)));
- lines.Add(String.Format("Minor Version: {0}", Utils.IntToHex(entry.MinorVersion)));
- lines.Add(String.Format("Type: {0}", type));
- lines.Add(String.Format("Size of Data: {0} ({1})", entry.SizeOfData, Utils.FormatBytes(entry.SizeOfData)));
- lines.Add(String.Format("Address of Raw Data: {0}", Utils.IntToHex(entry.AddressOfRawData)));
- lines.Add(String.Format("Pointer to Raw Data: {0}", Utils.IntToHex(entry.PointerToRawData)));
-
- int max_len = name.Length;
-
- foreach (var line in lines)
- {
- if (line.Length > max_len)
- max_len = line.Length;
- }
-
- max_len = max_len + 2;
-
- Console.WriteLine(" " + name.PadRight(max_len));
- Console.WriteLine(" " + String.Empty.PadRight(max_len, '-'));
-
- foreach (var line in lines)
- Console.WriteLine(" " + line.PadRight(max_len));
-
- Console.WriteLine();
-
- offset += entry.Location.FileSize;
- }
-
- Console.WriteLine();
-
- return 0;
- }
-
- private string ShowDebugDirectory_Type(DebugDirectoryEntry directoryEntry)
- {
- DebugDirectoryEntryType type = directoryEntry.GetEntryType();
- EnumAnnotations annotations = new EnumAnnotations();
- EnumAnnotation annotation = annotations.FirstOrDefault(a => a.Value == type);
-
- if (annotation == null)
- return null;
-
- long value = Convert.ToInt64(annotation.Value);
- string result = String.Format("{0} {1}", Utils.IntToHex(value, 8), annotation.HeaderName);
-
- return result;
- }
-
- private int ShowLoadConfig(ExecutableImage image)
- {
- LoadConfigDirectory directory = LoadConfigDirectory.Get(image);
-
- if (directory == null)
- return 0;
-
- Console.WriteLine("[ Load Configuration ]");
- Console.WriteLine();
-
- Console.WriteLine(" File Offset: {0}", Utils.IntToHex(directory.Location.FileOffset));
- Console.WriteLine(" Virtual Address: {0}", Utils.IntToHex(directory.Location.VirtualAddress));
- Console.WriteLine(" RVA: {0}", Utils.IntToHex(directory.Location.RelativeVirtualAddress));
- Console.WriteLine(" Size: {1} ({0})", Utils.FormatBytes(Convert.ToInt64(directory.Location.FileSize)), directory.Location.FileSize);
- Console.WriteLine();
-
- List> tuples = new List>();
- ulong offset;
-
- if (offset_type == "fo")
- {
- offset = directory.Location.FileOffset;
- }
- else if (offset_type == "vo")
- {
- offset = 0;
- }
- else if (offset_type == "va")
- {
- offset = directory.Location.VirtualAddress;
- }
- else
- {
- offset = directory.Location.RelativeVirtualAddress;
- }
-
- int address_size = (image.Is64Bit ? 16 : 8);
-
- string[] VARY_FIELDS = {
- "DeCommitFreeBlockThreshold",
- "DeCommitTotalFreeThreshold",
- "LockPrefixTable",
- "MaximumAllocationSize",
- "VirtualMemoryThreshold",
- "ProcessAffinityMask",
- "EditList",
- "SecurityCookie",
- "SEHandlerTable",
- "SEHandlerCount",
- "GuardCFCheckFunctionPointer",
- "Reserved2",
- "GuardCFFunctionTable",
- "GuardCFFunctionCount"
- };
- FieldAnnotations annotations = FieldAnnotations.Get(directory);
-
- foreach (FieldAnnotation annotation in annotations)
- {
- int size = annotation.Size * 2;
-
- if (VARY_FIELDS.Contains(annotation.Name, StringComparer.OrdinalIgnoreCase))
- size = (image.Is64Bit ? 16 : 8);
-
- int array_size = (annotation.IsArray ? annotation.ArraySize : annotation.Size);
- object value = (annotation.IsArray ? Utils.GetDefaultValue(annotation.Type.GetElementType()) : annotation.Value);
-
- Tuple tuple = new Tuple(Utils.IntToHex(offset, address_size), Utils.IntToHex(value, size), annotation.Description);
-
- tuples.Add(tuple);
-
- offset += Convert.ToUInt32(array_size);
- }
-
- int max_value_len = 0;
- int max_desc_len = 0;
-
- foreach (var tuple in tuples)
- {
- if (tuple.Item2.Length > max_value_len)
- max_value_len = tuple.Item2.Length;
-
- if (tuple.Item3.Length > max_desc_len)
- max_desc_len = tuple.Item3.Length;
- }
-
- string header = String.Format("{0} {1} {2}", "Address".PadRight(address_size + 2), "Value".PadRight(max_value_len), "Description".PadRight(max_desc_len));
-
- Console.WriteLine(" " + header);
- Console.WriteLine(" " + String.Empty.PadRight(header.Length, '-'));
-
- foreach (var tuple in tuples)
- Console.WriteLine(" {0} {1} {2}", tuple.Item1.PadRight(address_size + 2), tuple.Item2.PadRight(max_value_len), tuple.Item3.PadRight(max_desc_len));
-
- Console.WriteLine();
-
- //ShowOptionalHeader_SubSystem(image);
- //ShowOptionalHeader_DllCharacteristics(image);
- //
- //Console.WriteLine();
-
- return 0;
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/PE Dump/Properties/AssemblyInfo.cs b/Src/PE Dump/Properties/AssemblyInfo.cs
deleted file mode 100644
index 70ef2ff..0000000
--- a/Src/PE Dump/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("PE Dump")]
-[assembly: AssemblyDescription("A console application to view and dump information about a Portable Executable.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Workshell Ltd")]
-[assembly: AssemblyProduct("PE Dump")]
-[assembly: AssemblyCopyright("Copyright ©2016 Workshell Ltd")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("3a01212e-8461-41a0-b154-22cba75929a3")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.4.*")]
-[assembly: AssemblyInformationalVersion("1.4.0")]
diff --git a/Src/PE Dump/Utils.cs b/Src/PE Dump/Utils.cs
deleted file mode 100644
index f1a6b80..0000000
--- a/Src/PE Dump/Utils.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Workshell.PE.Dump
-{
-
- public enum NumberStyle : int
- {
- Decimal,
- Hexadecimal
- }
-
- internal class Utils
- {
-
- public static bool IsNumeric(object value)
- {
- switch (Type.GetTypeCode(value.GetType()))
- {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.UInt16:
- case TypeCode.Int16:
- case TypeCode.UInt32:
- case TypeCode.Int32:
- case TypeCode.UInt64:
- case TypeCode.Int64:
- case TypeCode.Single:
- case TypeCode.Double:
- case TypeCode.Decimal:
- return true;
- default:
- return false;
- }
- }
-
- public static string IntToHex(object value)
- {
- switch (Type.GetTypeCode(value.GetType()))
- {
- case TypeCode.Byte: return IntToHex(value, 2);
- case TypeCode.SByte: return IntToHex(value, 2);
- case TypeCode.UInt16: return IntToHex(value, 4);
- case TypeCode.Int16: return IntToHex(value, 4);
- case TypeCode.UInt32: return IntToHex(value, 8);
- case TypeCode.Int32: return IntToHex(value, 8);
- case TypeCode.UInt64: return IntToHex(value, 16);
- case TypeCode.Int64: return IntToHex(value, 16);
- default:
- throw new FormatException("Unknown integer value type.");
- }
- }
-
- public static string IntToHex(object value, int size)
- {
- string result = String.Empty;
-
- switch (Type.GetTypeCode(value.GetType()))
- {
- case TypeCode.Byte:
- result = "0x" + ((byte)(value)).ToString("X" + size);
- break;
- case TypeCode.SByte:
- result = "0x" + ((sbyte)(value)).ToString("X" + size);
- break;
- case TypeCode.UInt16:
- result = "0x" + ((ushort)(value)).ToString("X" + size);
- break;
- case TypeCode.Int16:
- result = "0x" + ((short)(value)).ToString("X" + size);
- break;
- case TypeCode.UInt32:
- result = "0x" + ((uint)(value)).ToString("X" + size);
- break;
- case TypeCode.Int32:
- result = "0x" + ((int)(value)).ToString("X" + size);
- break;
- case TypeCode.UInt64:
- result = "0x" + ((ulong)(value)).ToString("X" + size);
- break;
- case TypeCode.Int64:
- result = "0x" + ((long)(value)).ToString("X" + size);
- break;
- default:
- throw new FormatException("Unknown integer value type.");
- }
-
- return result;
- }
-
- public static string FormatNumber(object value, NumberStyle numberStyle)
- {
- if (!IsNumeric(value))
- throw new FormatException("Unknown numeric value type.");
-
- if (numberStyle == NumberStyle.Decimal)
- {
- return value.ToString();
- }
- else
- {
- return IntToHex(value);
- }
- }
-
- public static string FormatNumber(object value, NumberStyle numberStyle, int size)
- {
- if (!IsNumeric(value))
- throw new FormatException("Unknown numeric value type.");
-
- string result = String.Empty;
-
- if (numberStyle == NumberStyle.Decimal)
- {
- switch (Type.GetTypeCode(value.GetType()))
- {
- case TypeCode.Byte:
- result = ((byte)(value)).ToString("D" + size);
- break;
- case TypeCode.SByte:
- result = ((sbyte)(value)).ToString("D" + size);
- break;
- case TypeCode.UInt16:
- result = ((ushort)(value)).ToString("D" + size);
- break;
- case TypeCode.Int16:
- result = ((short)(value)).ToString("D" + size);
- break;
- case TypeCode.UInt32:
- result = ((uint)(value)).ToString("D" + size);
- break;
- case TypeCode.Int32:
- result = ((int)(value)).ToString("D" + size);
- break;
- case TypeCode.UInt64:
- result = ((ulong)(value)).ToString("D" + size);
- break;
- case TypeCode.Int64:
- result = ((long)(value)).ToString("D" + size);
- break;
- default:
- throw new FormatException("Unknown integer value type.");
- }
- }
- else
- {
- result = IntToHex(value, size);
- }
-
- return result;
- }
-
- public static object GetDefaultValue(Type type)
- {
- if (type.IsValueType)
- {
- return Activator.CreateInstance(type);
- }
- else
- {
- return null;
- }
- }
-
- private static readonly string[] suf = { "Bytes", "KB", "MB", "GB", "TB", "PB", "EB" };
-
- public static string FormatBytes(long byteCount)
- {
- if (byteCount == 0)
- return "0 B";
-
- long bytes = Math.Abs(byteCount);
- int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
- double num = Math.Round(bytes / Math.Pow(1024, place), 1);
-
- return String.Format("{0} {1}", (Math.Sign(byteCount) * num), suf[place]);
- }
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Accelerators/AcceleratorResource.cs b/Src/Workshell.PE.Resources/Accelerators/AcceleratorResource.cs
deleted file mode 100644
index 7308481..0000000
--- a/Src/Workshell.PE.Resources/Accelerators/AcceleratorResource.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-using Workshell.PE.Annotations;
-using Workshell.PE.Extensions;
-using Workshell.PE.Native;
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- [Flags]
- public enum AcceleratorFlags : ushort
- {
- [EnumAnnotation("FVIRTKEY")]
- VirtualKey = 0x0001,
- [EnumAnnotation("FNOINVERT")]
- NoInvert = 0x0002,
- [EnumAnnotation("FSHIFT")]
- Shift = 0x0004,
- [EnumAnnotation("FCONTROL")]
- Control = 0x0008,
- [EnumAnnotation("FALT")]
- Alt = 0x0010,
- End = 0x0080
- }
-
- public sealed class AcceleratorEntry
- {
-
- private ushort flags;
- private ushort key;
- private ushort id;
-
- internal AcceleratorEntry(ushort accelFlag, ushort accelKey, ushort accelId)
- {
- flags = accelFlag;
- key = accelKey;
- id = accelId;
- }
-
- #region Methods
-
- public override string ToString()
- {
- return String.Format("Id: {0}; Key: {1}; Flags: {2}", id, GetKey(), GetFlags());
- }
-
- public AcceleratorFlags GetFlags()
- {
- return (AcceleratorFlags)flags;
- }
-
- public Keys GetKey()
- {
- return (Keys)key;
- }
-
- #endregion
-
- #region Properties
-
- public ushort Flags
- {
- get
- {
- return flags;
- }
- }
-
- public ushort Key
- {
- get
- {
- return key;
- }
- }
-
- public ushort Id
- {
- get
- {
- return id;
- }
- }
-
- #endregion
-
- }
-
- public sealed class Accelerators : IEnumerable
- {
-
- private AcceleratorResource resource;
- private uint language_id;
- private AcceleratorEntry[] accelerators;
-
- internal Accelerators(AcceleratorResource acceleratorResource, uint languageId, AcceleratorEntry[] acceleratorEntries)
- {
- resource = acceleratorResource;
- language_id = languageId;
- accelerators = acceleratorEntries;
- }
-
- #region Methods
-
- public IEnumerator GetEnumerator()
- {
- for (var i = 0; i < accelerators.Length; i++)
- yield return accelerators[i];
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
- #region Properties
-
- public AcceleratorResource Resource
- {
- get
- {
- return resource;
- }
- }
-
- public uint Language
- {
- get
- {
- return language_id;
- }
- }
-
- public int Count
- {
- get
- {
- return accelerators.Length;
- }
- }
-
- public AcceleratorEntry this[int index]
- {
- get
- {
- return accelerators[index];
- }
- }
-
- #endregion
-
- }
-
- /*
- public enum AcceleratorSaveFormat
- {
- Raw
- }
- */
-
- public sealed class AcceleratorResource : Resource
- {
-
- public AcceleratorResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_ACCELERATOR);
-
- return ResourceType.Register(resource_type, typeof(AcceleratorResource));
- }
-
- #endregion
-
- #region Methods
-
- public Accelerators Get(uint languageId)
- {
- byte[] data = GetBytes(languageId);
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- int size = Utils.SizeOf();
- long count = mem.Length / size;
-
- AcceleratorEntry[] accelerators = new AcceleratorEntry[count];
-
- for (var i = 0; i < count; i++)
- {
- ACCELTABLEENTRY table_entry = Utils.Read(mem, size);
- AcceleratorEntry entry = new AcceleratorEntry(table_entry.fFlags, table_entry.wAnsi, table_entry.wId);
-
- accelerators[i] = entry;
- }
-
- Accelerators result = new Accelerators(this, languageId, accelerators);
-
- return result;
- }
- }
-
- /*
- public void Save(string fileName, uint languageId, AcceleratorSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, AcceleratorSaveFormat format)
- {
- if (format == AcceleratorSaveFormat.Raw)
- {
- byte[] data = GetBytes(languageId);
-
- stream.Write(data, 0, data.Length);
- }
- }
- */
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/CharacterSet.cs b/Src/Workshell.PE.Resources/CharacterSet.cs
deleted file mode 100644
index eff7e17..0000000
--- a/Src/Workshell.PE.Resources/CharacterSet.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Workshell.PE.Annotations;
-
-namespace Workshell.PE.Resources
-{
-
- public enum CharacterSet : byte
- {
- [EnumAnnotation("ANSI_CHARSET")]
- ANSI = 0,
- [EnumAnnotation("DEFAULT_CHARSET")]
- Default = 0x01,
- [EnumAnnotation("SYMBOL_CHARSET")]
- Symbol = 0x02,
- [EnumAnnotation("MAC_CHARSET")]
- Mac = 0x4D,
- [EnumAnnotation("SHIFTJIS_CHARSET")]
- ShiftJis = 0x80,
- [EnumAnnotation("HANGUL_CHARSET")]
- Hangul = 0x81,
- [EnumAnnotation("JOHAB_CHARSET")]
- Johab = 0x82,
- [EnumAnnotation("GB2312_CHARSET")]
- GB2312 = 0x86,
- [EnumAnnotation("CHINESEBIG5_CHARSET")]
- ChineseBig5 = 0x88,
- [EnumAnnotation("GREEK_CHARSET")]
- Greek = 0xA1,
- [EnumAnnotation("TURKISH_CHARSET")]
- Turkish = 0xA2,
- [EnumAnnotation("VIETNAMESE_CHARSET")]
- Vietnamese = 0xA3,
- [EnumAnnotation("HEBREW_CHARSET")]
- Hebrew = 0xB1,
- [EnumAnnotation("ARABIC_CHARSET")]
- Arabic = 0xB2,
- [EnumAnnotation("BALTIC_CHARSET")]
- Baltic = 0xBA,
- [EnumAnnotation("RUSSIAN_CHARSET")]
- Russian = 0xCC,
- [EnumAnnotation("THAI_CHARSET")]
- Thai = 0xDE,
- [EnumAnnotation("EASTEUROPE_CHARSET")]
- EastEurope = 0xEE,
- [EnumAnnotation("OEM_CHARSET")]
- OEM = 0xFF
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Dialogs/Dialog.cs b/Src/Workshell.PE.Resources/Dialogs/Dialog.cs
deleted file mode 100644
index 4dec89c..0000000
--- a/Src/Workshell.PE.Resources/Dialogs/Dialog.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class Dialog
- {
-
- internal Dialog(DialogResource dialogResource, uint languageId)
- {
- Resource = dialogResource;
- Language = languageId;
- }
-
- #region Properties
-
- public DialogResource Resource
- {
- get;
- private set;
- }
-
- public uint Language
- {
- get;
- private set;
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Dialogs/DialogEx.cs b/Src/Workshell.PE.Resources/Dialogs/DialogEx.cs
deleted file mode 100644
index 951879d..0000000
--- a/Src/Workshell.PE.Resources/Dialogs/DialogEx.cs
+++ /dev/null
@@ -1,484 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class DialogItemEx
- {
-
- public const ushort BUTTON = 0x0080;
- public const ushort EDIT = 0x0081;
- public const ushort STATIC = 0x0082;
- public const ushort LISTBOX = 0x0083;
- public const ushort SCROLLBAR = 0x0084;
- public const ushort COMBOBOX = 0x0085;
-
- private uint help_id;
- private uint ex_styles;
- private uint styles;
- private Point position;
- private Size size;
- private int id;
- private ResourceId cls;
- private ResourceId title;
- private byte[] extra_data;
-
- internal DialogItemEx(Stream stream)
- {
- help_id = Utils.ReadUInt32(stream);
- ex_styles = Utils.ReadUInt32(stream);
- styles = Utils.ReadUInt32(stream);
-
- short x = Utils.ReadInt16(stream);
- short y = Utils.ReadInt16(stream);
-
- position = new Point(x, y);
-
- short cx = Utils.ReadInt16(stream);
- short cy = Utils.ReadInt16(stream);
-
- size = new Size(cx, cy);
- id = Utils.ReadInt32(stream);
-
- string class_name = String.Empty;
- ushort class_id = ResourceUtils.OrdOrSz(stream, out class_name);
-
- if (class_id > 0)
- {
- switch (class_id)
- {
- case BUTTON:
- class_name = "BUTTON";
- break;
- case EDIT:
- class_name = "EDIT";
- break;
- case STATIC:
- class_name = "STATIC";
- break;
- case LISTBOX:
- class_name = "LISTBOX";
- break;
- case SCROLLBAR:
- class_name = "SCROLLBAR";
- break;
- case COMBOBOX:
- class_name = "COMBOBOX";
- break;
- }
-
- cls = new ResourceId(class_id, class_name);
- }
- else
- {
- cls = new ResourceId(class_name);
- }
-
- string title_name = String.Empty;
- ushort title_id = ResourceUtils.OrdOrSz(stream, out title_name);
-
- if (title_id > 0)
- {
- title = new ResourceId(title_id);
- }
- else
- {
- title = new ResourceId(title_name);
- }
-
- ushort extra_count = Utils.ReadUInt16(stream);
-
- if (stream.Position % 2 != 0)
- Utils.ReadByte(stream);
-
- extra_data = new byte[extra_count];
-
- if (extra_data.Length > 0)
- extra_data = Utils.ReadBytes(stream, extra_count);
- }
-
- #region Methods
-
- public override string ToString()
- {
- return String.Format("{0}, {1}, {2}", title, id, cls);
- }
-
- public T GetControlStyle()
- {
- Type type = typeof(T);
-
- if (!type.IsEnum)
- throw new Exception("Not an enum type.");
-
- return (T)Enum.Parse(typeof(T), styles.ToString(), true);
- }
-
- #endregion
-
- #region Properties
-
- public uint HelpId
- {
- get
- {
- return help_id;
- }
- }
-
- public uint ExtendedStyles
- {
- get
- {
- return ex_styles;
- }
- }
-
- public uint Styles
- {
- get
- {
- return styles;
- }
- }
-
- public Point Position
- {
- get
- {
- return position;
- }
- }
-
- public Size Size
- {
- get
- {
- return size;
- }
- }
-
- public int Id
- {
- get
- {
- return id;
- }
- }
-
- public ResourceId Class
- {
- get
- {
- return cls;
- }
- }
-
- public ResourceId Title
- {
- get
- {
- return title;
- }
- }
-
- public byte[] ExtraData
- {
- get
- {
- return extra_data;
- }
- }
-
- #endregion
-
- }
-
- public sealed class DialogEx : IEnumerable
- {
-
- private DialogResource resource;
- private uint language_id;
-
- private uint help_id;
- private uint ex_styles;
- private uint styles;
- private Point position;
- private Size size;
- private ResourceId menu;
- private ResourceId cls;
- private string title;
- private Font font;
- private CharacterSet char_set;
- private DialogItemEx[] items;
-
- internal DialogEx(DialogResource dialogResource, uint languageId, Stream stream)
- {
- resource = dialogResource;
- language_id = languageId;
-
- ushort ver = Utils.ReadUInt16(stream);
- ushort sig = Utils.ReadUInt16(stream);
-
- help_id = Utils.ReadUInt32(stream);
- ex_styles = Utils.ReadUInt32(stream);
- styles = Utils.ReadUInt32(stream);
-
- ushort item_count = Utils.ReadUInt16(stream);
-
- short x = Utils.ReadInt16(stream);
- short y = Utils.ReadInt16(stream);
-
- position = new Point(x, y);
-
- short cx = Utils.ReadInt16(stream);
- short cy = Utils.ReadInt16(stream);
-
- size = new Size(cx, cy);
-
- string menu_name = String.Empty;
- ushort menu_id = ResourceUtils.OrdOrSz(stream, out menu_name);
-
- if (menu_id > 0)
- {
- menu = menu_id;
- }
- else
- {
- menu = menu_name;
- }
-
- string class_name = String.Empty;
- ushort class_id = ResourceUtils.OrdOrSz(stream, out menu_name);
-
- if (class_id > 0)
- {
- cls = class_id;
- }
- else
- {
- cls = class_name;
- }
-
- title = Utils.ReadUnicodeString(stream);
-
- DialogStyle dialog_styles = GetDialogStyles();
-
- if ((dialog_styles & DialogStyle.DS_SETFONT) == DialogStyle.DS_SETFONT)
- {
- ushort point_size = Utils.ReadUInt16(stream);
- ushort weight = Utils.ReadUInt16(stream);
- byte italic = Utils.ReadByte(stream);
-
- char_set = (CharacterSet)Utils.ReadByte(stream);
-
- string type_face = Utils.ReadUnicodeString(stream);
-
- font = new Font(type_face, point_size);
- }
- else
- {
- font = null;
- }
-
- items = new DialogItemEx[item_count];
-
- for (var i = 0; i < item_count; i++)
- {
- while (stream.Position % 4 != 0)
- Utils.ReadByte(stream);
-
- DialogItemEx item = new Resources.DialogItemEx(stream);
-
- items[i] = item;
- }
- }
-
- #region Methods
-
- public override string ToString()
- {
- return title;
- }
-
- public IEnumerator GetEnumerator()
- {
- for (var i = 0; i < items.Length; i++)
- yield return items[i];
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public WindowStyleEx GetExtendedWindowStyles()
- {
- return (WindowStyleEx)ex_styles;
- }
-
- public WindowStyle GetWindowStyles()
- {
- return (WindowStyle)styles;
- }
-
- public DialogStyle GetDialogStyles()
- {
- return (DialogStyle)styles;
- }
-
- #endregion
-
- #region Properties
-
- public DialogResource Resource
- {
- get
- {
- return resource;
- }
- }
-
- public uint Language
- {
- get
- {
- return language_id;
- }
- }
-
- public uint HelpId
- {
- get
- {
- return help_id;
- }
- }
-
- public uint ExtendedStyles
- {
- get
- {
- return ex_styles;
- }
- }
-
- public uint Styles
- {
- get
- {
- return styles;
- }
- }
-
- public Point Position
- {
- get
- {
- return position;
- }
- }
-
- public Size Size
- {
- get
- {
- return size;
- }
- }
-
- public ResourceId Menu
- {
- get
- {
- return menu;
- }
- }
-
- public ResourceId Class
- {
- get
- {
- return cls;
- }
- }
-
- public string Title
- {
- get
- {
- return title;
- }
- }
-
- public Font Font
- {
- get
- {
- return font;
- }
- }
-
- public CharacterSet CharSet
- {
- get
- {
- return char_set;
- }
- }
-
- public int ItemCount
- {
- get
- {
- return items.Length;
- }
- }
-
- public DialogItemEx this[int index]
- {
- get
- {
- return items[index];
- }
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Dialogs/DialogResource.cs b/Src/Workshell.PE.Resources/Dialogs/DialogResource.cs
deleted file mode 100644
index ddfb1ed..0000000
--- a/Src/Workshell.PE.Resources/Dialogs/DialogResource.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-using Workshell.PE.Extensions;
-using Workshell.PE.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class DialogResource : Resource
- {
-
- public DialogResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_DIALOG);
-
- return ResourceType.Register(resource_type, typeof(DialogResource));
- }
-
- #endregion
-
- #region Methods
-
- public Dialog GetDialog(uint languageId)
- {
- byte[] data = GetBytes(languageId);
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- ushort ver = Utils.ReadUInt16(mem);
- ushort sig = Utils.ReadUInt16(mem);
-
- bool is_extended = (ver == 1 && sig == 0xFFFF);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- if (!is_extended)
- {
- Dialog dialog = new Dialog(this, languageId);
-
- return dialog;
- }
- else
- {
- return null;
- }
- }
- }
-
- public DialogEx GetDialogEx(uint languageId)
- {
- byte[] data = GetBytes(languageId);
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- ushort ver = Utils.ReadUInt16(mem);
- ushort sig = Utils.ReadUInt16(mem);
-
- bool is_extended = (ver == 1 && sig == 0xFFFF);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- if (!is_extended)
- {
- return null;
- }
- else
- {
- DialogEx dialog = new DialogEx(this, languageId, mem);
-
- return dialog;
- }
- }
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/BitmapResource.cs b/Src/Workshell.PE.Resources/Graphics/BitmapResource.cs
deleted file mode 100644
index 815ed18..0000000
--- a/Src/Workshell.PE.Resources/Graphics/BitmapResource.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-using Workshell.PE.Extensions;
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public enum BitmapSaveFormat
- {
- Raw,
- Bitmap
- }
-
- public sealed class BitmapResource : Resource
- {
-
- public BitmapResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_BITMAP);
-
- return ResourceType.Register(resource_type, typeof(BitmapResource));
- }
-
- #endregion
-
- #region Methods
-
- public Bitmap ToBitmap()
- {
- return ToBitmap(DEFAULT_LANGUAGE);
- }
-
- public Bitmap ToBitmap(uint languageId)
- {
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- byte[] dib = GetBytes(languageId);
- MemoryStream dib_mem = new MemoryStream(dib);
-
- using (dib_mem)
- {
- BITMAPINFOHEADER header = Utils.Read(dib_mem);
- BITMAPFILEHEADER file_header = new BITMAPFILEHEADER();
-
- file_header.Tag = 19778;
- file_header.Size = (Utils.SizeOf() + dib.Length).ToUInt32();
- file_header.Reserved1 = 0;
- file_header.Reserved2 = 0;
- file_header.BitmapOffset = Utils.SizeOf().ToUInt32() + header.biSize;
-
- Utils.Write(file_header, mem);
- Utils.Write(dib, mem);
- }
-
- mem.Seek(0, SeekOrigin.Begin);
-
- using (Bitmap bitmap = (Bitmap)Image.FromStream(mem))
- {
- Bitmap result = new Bitmap(bitmap); // Create a copy of the image so we can release the stream
-
- return result;
- }
- }
- }
-
- public void Save(string fileName, uint languageId, BitmapSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, BitmapSaveFormat format)
- {
- if (format == BitmapSaveFormat.Raw)
- {
- Save(stream, languageId);
- }
- else
- {
- using (Bitmap bitmap = ToBitmap(languageId))
- {
- bitmap.Save(stream, ImageFormat.Bmp);
- }
- }
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/CursorGroupResource.cs b/Src/Workshell.PE.Resources/Graphics/CursorGroupResource.cs
deleted file mode 100644
index 8b48056..0000000
--- a/Src/Workshell.PE.Resources/Graphics/CursorGroupResource.cs
+++ /dev/null
@@ -1,327 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Workshell.PE.Extensions;
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class CursorGroupEntry
- {
-
- internal CursorGroupEntry(CURSOR_RESDIR resDir)
- {
- Width = resDir.Cursor.Width;
- Height = resDir.Cursor.Height;
- Planes = resDir.Planes;
- BitCount = resDir.BitCount;
- BytesInRes = resDir.BytesInRes;
- CursorId = resDir.CursorId;
- }
-
- #region Methods
-
- public override string ToString()
- {
- return String.Format("{0}x{1} {2}-bit, ID: {3}", Width, Height, BitCount, CursorId);
- }
-
- #endregion
-
- #region Properties
-
- public ushort Width
- {
- get;
- private set;
- }
-
- public ushort Height
- {
- get;
- private set;
- }
-
- public ushort Planes
- {
- get;
- private set;
- }
-
- public ushort BitCount
- {
- get;
- private set;
- }
-
- public uint BytesInRes
- {
- get;
- private set;
- }
-
- public ushort CursorId
- {
- get;
- private set;
- }
-
- #endregion
-
- }
-
- public sealed class CursorGroup : IEnumerable
- {
-
- private CursorGroupResource resource;
- private uint language_id;
- private CursorGroupEntry[] entries;
-
- internal CursorGroup(CursorGroupResource cursorResource, uint languageId, CursorGroupEntry[] groupEntries)
- {
- resource = cursorResource;
- language_id = languageId;
- entries = groupEntries;
- }
-
- #region Methods
-
- public IEnumerator GetEnumerator()
- {
- for (var i = 0; i < entries.Length; i++)
- yield return entries[i];
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
- #region Properties
-
- public CursorGroupResource Resource
- {
- get
- {
- return resource;
- }
- }
-
- public uint Language
- {
- get
- {
- return language_id;
- }
- }
-
- public int Count
- {
- get
- {
- return entries.Length;
- }
- }
-
- public CursorGroupEntry this[int index]
- {
- get
- {
- return entries[index];
- }
- }
-
- #endregion
-
- }
-
- public enum CursorGroupSaveFormat
- {
- Raw,
- Cursor
- }
-
- public sealed class CursorGroupResource : Resource
- {
-
- public CursorGroupResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_GROUP_CURSOR);
-
- return ResourceType.Register(resource_type, typeof(CursorGroupResource));
- }
-
- #endregion
-
- #region Methods
-
- public CursorGroup ToGroup()
- {
- return ToGroup(DEFAULT_LANGUAGE);
- }
-
- public CursorGroup ToGroup(uint languageId)
- {
- byte[] data = GetBytes(languageId);
- MemoryStream mem = new MemoryStream(data);
-
- using (mem)
- {
- NEWHEADER header = Utils.Read(mem);
-
- if (header.ResType != 2)
- throw new Exception("Not a cursor group resource.");
-
- CursorGroupEntry[] entries = new CursorGroupEntry[header.ResCount];
-
- for (var i = 0; i < header.ResCount; i++)
- {
- CURSOR_RESDIR cursor = Utils.Read(mem);
- CursorGroupEntry entry = new CursorGroupEntry(cursor);
-
- entries[i] = entry;
- }
-
- CursorGroup group = new CursorGroup(this, languageId, entries);
-
- return group;
- }
- }
-
- public void Save(string fileName, uint languageId, CursorGroupSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, CursorGroupSaveFormat format)
- {
- if (format == CursorGroupSaveFormat.Raw)
- {
- Save(stream, languageId);
- }
- else
- {
- CursorGroup group = ToGroup(languageId);
- List> cursors = new List>(group.Count);
-
- for (var i = 0; i < group.Count; i++)
- {
- CursorGroupEntry entry = group[i];
- ResourceType res_type = Type.Resources.First(t => t.Id == ResourceType.RT_CURSOR);
- Resource res = res_type.First(c => c.Id == entry.CursorId);
- byte[] data = res.GetBytes(languageId);
-
- ushort hotspot_x = 0;
- ushort hotspot_y = 0;
- byte[] dib = new byte[0];
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- hotspot_x = Utils.ReadUInt16(mem);
- hotspot_y = Utils.ReadUInt16(mem);
-
- using (MemoryStream dib_mem = new MemoryStream())
- {
- mem.CopyTo(dib_mem, 4096);
-
- dib = dib_mem.ToArray();
- }
- }
-
- Tuple tuple = new Tuple(entry.CursorId, hotspot_x, hotspot_y, dib);
-
- cursors.Add(tuple);
- }
-
- uint[] offsets = new uint[group.Count];
- uint offset = Convert.ToUInt32(6 + (16 * offsets.Length));
-
- for (var i = 0; i < group.Count; i++)
- {
- CursorGroupEntry entry = group[i];
- Tuple tuple = cursors[i];
-
- offsets[i] = offset;
- offset += tuple.Item4.Length.ToUInt32();
- }
-
- Utils.Write(Convert.ToUInt16(0), stream);
- Utils.Write(Convert.ToUInt16(2), stream);
- Utils.Write(Convert.ToUInt16(group.Count), stream);
-
- for (var i = 0; i < group.Count; i++)
- {
- CursorGroupEntry entry = group[i];
- Tuple tuple = cursors[i];
-
- Utils.Write(Convert.ToByte(entry.Width), stream);
- Utils.Write(Convert.ToByte(entry.Height), stream);
- Utils.Write(Convert.ToByte(entry.BitCount), stream);
- Utils.Write(Convert.ToByte(0), stream);
- Utils.Write(tuple.Item2, stream);
- Utils.Write(tuple.Item3, stream);
- Utils.Write(tuple.Item4.Length, stream);
- Utils.Write(offsets[i], stream);
- }
-
- for (var i = 0; i < group.Count; i++)
- {
- CursorGroupEntry entry = group[i];
- Tuple tuple = cursors[i];
-
- stream.Write(tuple.Item4, 0, tuple.Item4.Length);
- }
- }
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/CursorResource.cs b/Src/Workshell.PE.Resources/Graphics/CursorResource.cs
deleted file mode 100644
index 6a3e859..0000000
--- a/Src/Workshell.PE.Resources/Graphics/CursorResource.cs
+++ /dev/null
@@ -1,476 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class CursorInfo
- {
-
- internal CursorInfo(CursorResource cursor, uint languageId, ushort hotspotX, ushort hotspotY, ushort width, ushort height, byte colors, byte[] dib, bool isPNG)
- {
- Cursor = cursor;
- Language = languageId;
- Hotspot = new Point(hotspotX, hotspotY);
- Size = new Size(width, height);
- Colors = colors;
- DIB = dib;
- IsPNG = isPNG;
- }
-
- #region Properties
-
- public CursorResource Cursor
- {
- get;
- private set;
- }
-
- public uint Language
- {
- get;
- private set;
- }
-
- public Point Hotspot
- {
- get;
- private set;
- }
-
- public Size Size
- {
- get;
- private set;
- }
-
- public byte Colors
- {
- get;
- private set;
- }
-
- public byte[] DIB
- {
- get;
- private set;
- }
-
- public bool IsPNG
- {
- get;
- private set;
- }
-
- #endregion
-
- }
-
- public enum CursorSaveFormat
- {
- Raw,
- Cursor,
- Icon,
- Bitmap,
- PNG
- }
-
- public class CursorResource : Resource
- {
-
- public CursorResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_CURSOR);
-
- return ResourceType.Register(resource_type, typeof(CursorResource));
- }
-
- #endregion
-
- #region Methods
-
- public CursorInfo GetInfo()
- {
- return GetInfo(DEFAULT_LANGUAGE);
- }
-
- public CursorInfo GetInfo(uint languageId)
- {
- Tuple tuple = Load(languageId);
- CursorInfo result = new CursorInfo(this, languageId, tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6, tuple.Item7);
-
- return result;
- }
-
- public Icon ToIcon()
- {
- return ToIcon(DEFAULT_LANGUAGE);
- }
-
- public Icon ToIcon(uint languageId)
- {
- /*
- Tuple tuple = Load(languageId);
-
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item3))
- {
- BITMAPINFOHEADER header = Utils.Read(dib_mem);
-
- ushort width = Convert.ToUInt16(header.biWidth);
- ushort height = Convert.ToUInt16(header.biHeight / 2);
- byte color_count = Convert.ToByte(header.biBitCount);
-
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- Utils.Write(Convert.ToUInt16(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
-
- uint colors = 0;
-
- if (color_count != 0 && color_count < 8)
- colors = Convert.ToUInt32(Math.Pow(2, color_count));
-
- Utils.Write(Convert.ToByte(width >= 256 ? 0 : width), mem);
- Utils.Write(Convert.ToByte(height >= 256 ? 0 : height), mem);
- Utils.Write(Convert.ToByte(colors), mem);
- Utils.Write(Convert.ToByte(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(color_count), mem);
- Utils.Write(tuple.Item3.Length, mem);
- Utils.Write(22, mem);
-
- Utils.Write(tuple.Item3, mem);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- Icon icon = new Icon(mem);
-
- return icon;
- }
- }
- */
-
- Tuple tuple = Load(languageId);
-
- if (!tuple.Item7)
- {
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item6))
- {
- BITMAPINFOHEADER header = Utils.Read(dib_mem);
-
- ushort width = Convert.ToUInt16(header.biWidth);
- ushort height = Convert.ToUInt16(header.biHeight / 2);
- byte color_count = Convert.ToByte(header.biBitCount);
-
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- Utils.Write(Convert.ToUInt16(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
-
- ulong colors = Convert.ToUInt64(Math.Pow(2, color_count));
-
- if (colors >= 256)
- colors = 0;
-
- Utils.Write(Convert.ToByte(width >= 256 ? 0 : width), mem);
- Utils.Write(Convert.ToByte(height >= 256 ? 0 : height), mem);
- Utils.Write(Convert.ToByte(colors), mem);
- Utils.Write(Convert.ToByte(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(color_count), mem);
- Utils.Write(tuple.Item6.Length, mem);
- Utils.Write(22, mem);
-
- Utils.Write(tuple.Item6, mem);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- Icon icon = new Icon(mem);
-
- return icon;
- }
- }
- }
- else
- {
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item6))
- {
- using (Image png = Image.FromStream(dib_mem))
- {
- ushort width = Convert.ToUInt16(png.Width);
- ushort height = Convert.ToUInt16(png.Height);
- byte color_count = 32;
-
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- Utils.Write(Convert.ToUInt16(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
-
- Utils.Write(Convert.ToByte(width >= 256 ? 0 : width), mem);
- Utils.Write(Convert.ToByte(height >= 256 ? 0 : height), mem);
- Utils.Write(Convert.ToByte(0), mem); // 32-bit (16m colors) so 0
- Utils.Write(Convert.ToByte(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(color_count), mem);
- Utils.Write(tuple.Item6.Length, mem);
- Utils.Write(22, mem);
-
- Utils.Write(tuple.Item6, mem);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- Icon icon = new Icon(mem);
-
- return icon;
- }
- }
- }
- }
- }
-
- public Bitmap ToBitmap()
- {
- return ToBitmap(Color.Transparent);
- }
-
- public Bitmap ToBitmap(Color backgroundColor)
- {
- return ToBitmap(DEFAULT_LANGUAGE, Color.Transparent);
- }
-
- public Bitmap ToBitmap(uint languageId)
- {
- return ToBitmap(languageId, Color.Transparent);
- }
-
- public Bitmap ToBitmap(uint languageId, Color backgroundColor)
- {
- using (Icon icon = ToIcon(languageId))
- {
- Rectangle rect = new Rectangle(0, 0, icon.Width, icon.Height);
- Bitmap bitmap = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
-
- using (Graphics graphics = Graphics.FromImage(bitmap))
- {
- using (SolidBrush brush = new SolidBrush(backgroundColor))
- graphics.FillRectangle(brush, rect);
-
- graphics.DrawIcon(icon, rect);
- }
-
- bitmap.MakeTransparent(backgroundColor);
-
- return bitmap;
- }
- }
-
- public void Save(string fileName, uint languageId, CursorSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, CursorSaveFormat format)
- {
- switch (format)
- {
- case CursorSaveFormat.Raw:
- Save(stream, languageId);
- break;
- case CursorSaveFormat.Icon:
- {
- using (Icon icon = ToIcon(languageId))
- {
- icon.Save(stream);
- }
-
- break;
- }
- case CursorSaveFormat.Bitmap:
- {
- using (Bitmap bitmap = ToBitmap(languageId))
- {
- bitmap.Save(stream, ImageFormat.Bmp);
- }
-
- break;
- }
- case CursorSaveFormat.PNG:
- {
- Tuple tuple = Load(languageId);
-
- if (!tuple.Item7)
- {
- using (Bitmap bitmap = ToBitmap(languageId))
- {
- bitmap.Save(stream, ImageFormat.Png);
- }
- }
- else
- {
- stream.Write(tuple.Item6, 0, tuple.Item6.Length);
- }
-
- break;
- }
- case CursorSaveFormat.Cursor:
- default:
- {
- Tuple tuple = Load(languageId);
- MemoryStream mem = new MemoryStream(tuple.Item6);
-
- using (mem)
- {
- BITMAPINFOHEADER header = Utils.Read(mem);
-
- Utils.Write(Convert.ToUInt16(0), stream);
- Utils.Write(Convert.ToUInt16(2), stream);
- Utils.Write(Convert.ToUInt16(1), stream);
-
- Utils.Write(Convert.ToByte(header.biWidth), stream);
- Utils.Write(Convert.ToByte(header.biHeight), stream);
- Utils.Write(Convert.ToByte(0), stream);
- Utils.Write(Convert.ToByte(0), stream);
- Utils.Write(tuple.Item1, stream);
- Utils.Write(tuple.Item2, stream);
- Utils.Write(tuple.Item6.Length, stream);
- Utils.Write(22, stream);
-
- Utils.Write(tuple.Item6, stream);
- }
-
- break;
- }
- }
- }
-
- private Tuple Load(uint languageId)
- {
- /*
- byte[] data = GetBytes(languageId);
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- ushort hotspot_x = Utils.ReadUInt16(mem);
- ushort hotspot_y = Utils.ReadUInt16(mem);
- byte[] dib;
-
- using (MemoryStream dib_mem = new MemoryStream(data.Length - (sizeof(ushort) * 2)))
- {
- mem.CopyTo(dib_mem, 4096);
-
- dib = dib_mem.ToArray();
- }
-
- Tuple tuple = new Tuple(hotspot_x, hotspot_y, dib);
-
- return tuple;
- }
- */
-
- byte[] data = GetBytes(languageId);
- ushort hotspot_x;
- ushort hotspot_y;
- ushort width;
- ushort height;
- byte color_count;
- byte[] dib;
- bool is_png;
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- hotspot_x = Utils.ReadUInt16(mem);
- hotspot_y = Utils.ReadUInt16(mem);
-
- using (MemoryStream dib_mem = new MemoryStream(data.Length))
- {
- mem.CopyTo(dib_mem, 4096);
- dib_mem.Seek(0, SeekOrigin.Begin);
-
- dib = dib_mem.ToArray();
-
- if (!GraphicResources.IsPNG(dib))
- {
- BITMAPINFOHEADER header = Utils.Read(dib_mem);
-
- width = Convert.ToUInt16(header.biWidth);
- height = Convert.ToUInt16(header.biHeight / 2);
- color_count = Convert.ToByte(header.biBitCount);
- is_png = false;
- }
- else
- {
- using (Image png = Image.FromStream(dib_mem))
- {
- width = Convert.ToUInt16(png.Width);
- height = Convert.ToUInt16(png.Height);
- color_count = 32;
- is_png = true;
- }
- }
- }
- }
-
- Tuple tuple = new Tuple(hotspot_x, hotspot_y, width, height, color_count, dib, is_png);
-
- return tuple;
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/GraphicResources.cs b/Src/Workshell.PE.Resources/Graphics/GraphicResources.cs
deleted file mode 100644
index 5d757cc..0000000
--- a/Src/Workshell.PE.Resources/Graphics/GraphicResources.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Workshell.PE.Resources
-{
-
- [Serializable]
- public class GraphicResourcesException : Exception
- {
-
- public GraphicResourcesException() : base()
- {
- }
-
- public GraphicResourcesException(string message) : base(message)
- {
- }
-
- public GraphicResourcesException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected GraphicResourcesException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
- }
-
- public static class GraphicResources
- {
-
- #region Methods
-
- public static void Register()
- {
- Register(false);
- }
-
- public static void Register(bool throwOnFail)
- {
- if (!BitmapResource.Register() && throwOnFail)
- throw new GraphicResourcesException("Could not register BitmapResource, already registered.");
-
- if (!CursorGroupResource.Register() && throwOnFail)
- throw new GraphicResourcesException("Could not register CursorGroupResource, already registered.");
-
- if (!CursorResource.Register() && throwOnFail)
- throw new GraphicResourcesException("Could not register CursorResource, already registered.");
-
- if (!IconGroupResource.Register() && throwOnFail)
- throw new GraphicResourcesException("Could not register IconGroupResource, already registered.");
-
- if (!IconResource.Register() && throwOnFail)
- throw new GraphicResourcesException("Could not register IconResource, already registered.");
- }
-
- public static bool IsPNG(byte[] data)
- {
- if (data.Length < 8)
- return false;
-
- ulong signature = BitConverter.ToUInt64(data, 0);
-
- return (signature == 727905341920923785L);
- }
-
- public static bool IsPNG(Stream stream)
- {
- byte[] buffer = new byte[sizeof(ulong)];
- int num_read = stream.Read(buffer, 0, buffer.Length);
-
- if (num_read < sizeof(ulong))
- return false;
-
- return IsPNG(buffer);
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/IconGroupResource.cs b/Src/Workshell.PE.Resources/Graphics/IconGroupResource.cs
deleted file mode 100644
index 96fa1a8..0000000
--- a/Src/Workshell.PE.Resources/Graphics/IconGroupResource.cs
+++ /dev/null
@@ -1,313 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Workshell.PE.Extensions;
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class IconGroupEntry
- {
-
- internal IconGroupEntry(ICON_RESDIR resDir)
- {
- Width = resDir.Icon.Width;
- Height = resDir.Icon.Height;
- ColorCount = resDir.Icon.ColorCount;
- Planes = resDir.Planes;
- BitCount = resDir.BitCount;
- BytesInRes = resDir.BytesInRes;
- IconId = resDir.IconId;
-
- if (Width == 0)
- Width = 256;
-
- if (Height == 0)
- Height = 256;
- }
-
- #region Methods
-
- public override string ToString()
- {
- return String.Format("{0}x{1} {2}-bit, ID: {3}", Width, Height, BitCount, IconId);
- }
-
- #endregion
-
- #region Properties
-
- public ushort Width
- {
- get;
- private set;
- }
-
- public ushort Height
- {
- get;
- private set;
- }
-
- public byte ColorCount
- {
- get;
- private set;
- }
-
- public ushort Planes
- {
- get;
- private set;
- }
-
- public ushort BitCount
- {
- get;
- private set;
- }
-
- public uint BytesInRes
- {
- get;
- private set;
- }
-
- public ushort IconId
- {
- get;
- private set;
- }
-
- #endregion
-
- }
-
- public sealed class IconGroup : IEnumerable
- {
-
- private IconGroupResource resource;
- private uint language_id;
- private IconGroupEntry[] entries;
-
- internal IconGroup(IconGroupResource groupResource, uint languageId, IconGroupEntry[] groupEntries)
- {
- resource = groupResource;
- language_id = languageId;
- entries = groupEntries;
- }
-
- #region Methods
-
- public IEnumerator GetEnumerator()
- {
- for (var i = 0; i < entries.Length; i++)
- yield return entries[i];
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
- #region Properties
-
- public IconGroupResource Resource
- {
- get
- {
- return resource;
- }
- }
-
- public uint Language
- {
- get
- {
- return language_id;
- }
- }
-
- public int Count
- {
- get
- {
- return entries.Length;
- }
- }
-
- public IconGroupEntry this[int index]
- {
- get
- {
- return entries[index];
- }
- }
-
- #endregion
-
- }
-
- public enum IconGroupSaveFormat
- {
- Raw,
- Icon
- }
-
- public sealed class IconGroupResource : Resource
- {
-
- public IconGroupResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_GROUP_ICON);
-
- return ResourceType.Register(resource_type, typeof(IconGroupResource));
- }
-
- #endregion
-
- #region Methods
-
- public IconGroup ToGroup()
- {
- return ToGroup(DEFAULT_LANGUAGE);
- }
-
- public IconGroup ToGroup(uint languageId)
- {
- byte[] data = GetBytes(languageId);
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- NEWHEADER header = Utils.Read(mem);
-
- if (header.ResType != 1)
- throw new Exception("Not an icon group resource.");
-
- IconGroupEntry[] entries = new IconGroupEntry[header.ResCount];
-
- for (var i = 0; i < header.ResCount; i++)
- {
- ICON_RESDIR icon = Utils.Read(mem);
- IconGroupEntry entry = new IconGroupEntry(icon);
-
- entries[i] = entry;
- }
-
- IconGroup group = new IconGroup(this, languageId, entries);
-
- return group;
- }
- }
-
- public void Save(string fileName, uint languageId, IconGroupSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, IconGroupSaveFormat format)
- {
- if (format == IconGroupSaveFormat.Raw)
- {
- Save(stream, languageId);
- }
- else
- {
- IconGroup group = ToGroup(languageId);
- uint[] offsets = new uint[group.Count];
- uint offset = Convert.ToUInt32(6 + (16 * offsets.Length));
-
- for (var i = 0; i < group.Count; i++)
- {
- IconGroupEntry entry = group[i];
- offsets[i] = offset;
-
- offset += entry.BytesInRes;
- }
-
- Utils.Write(Convert.ToUInt16(0), stream);
- Utils.Write(Convert.ToUInt16(1), stream);
- Utils.Write(Convert.ToUInt16(group.Count), stream);
-
- for (var i = 0; i < group.Count; i++)
- {
- IconGroupEntry entry = group[i];
-
- ulong color_count = Convert.ToUInt64(Math.Pow(2, entry.BitCount));
-
- if (color_count >= 256)
- color_count = 0;
-
- Utils.Write(Convert.ToByte(entry.Width >= 256 ? 0 : entry.Width), stream);
- Utils.Write(Convert.ToByte(entry.Height >= 256 ? 0 : entry.Height), stream);
- Utils.Write(Convert.ToByte(color_count), stream);
- Utils.Write(Convert.ToByte(0), stream);
- Utils.Write(Convert.ToUInt16(1), stream);
- Utils.Write(entry.BitCount, stream);
- Utils.Write(entry.BytesInRes, stream);
- Utils.Write(offsets[i], stream);
- }
-
- ResourceType icon_type = Type.Resources.First(t => t.Id == ResourceType.RT_ICON);
-
- for (var i = 0; i < group.Count; i++)
- {
- IconGroupEntry entry = group[i];
- Resource resource = icon_type.First(r => r.Id == entry.IconId);
- byte[] data = resource.GetBytes(languageId);
-
- Utils.Write(data, stream);
- }
- }
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Graphics/IconResource.cs b/Src/Workshell.PE.Resources/Graphics/IconResource.cs
deleted file mode 100644
index cf253a1..0000000
--- a/Src/Workshell.PE.Resources/Graphics/IconResource.cs
+++ /dev/null
@@ -1,383 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-using Workshell.PE.Resources.Native;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class IconInfo
- {
-
- internal IconInfo(IconResource resource, uint languageId, ushort width, ushort height, byte colors, byte[] dib, bool isPNG)
- {
- Icon = resource;
- Language = languageId;
- Size = new Size(width, height);
- Colors = colors;
- DIB = dib;
- IsPNG = isPNG;
- }
-
- #region Properties
-
- public IconResource Icon
- {
- get;
- private set;
- }
-
- public uint Language
- {
- get;
- private set;
- }
-
- public Size Size
- {
- get;
- private set;
- }
-
- public byte Colors
- {
- get;
- private set;
- }
-
- public byte[] DIB
- {
- get;
- private set;
- }
-
- public bool IsPNG
- {
- get;
- private set;
- }
-
- #endregion
-
- }
-
- public enum IconSaveFormat
- {
- Raw,
- Icon,
- Bitmap,
- PNG
- }
-
- public class IconResource : Resource
- {
-
- public IconResource(ResourceType owningType, ResourceDirectoryEntry directoryEntry) : base(owningType, directoryEntry)
- {
- }
-
- #region Static Methods
-
- public static bool Register()
- {
- ResourceId resource_type = new ResourceId(ResourceType.RT_ICON);
-
- return ResourceType.Register(resource_type, typeof(IconResource));
- }
-
- #endregion
-
- #region Methods
-
- public IconInfo GetInfo()
- {
- return GetInfo(DEFAULT_LANGUAGE);
- }
-
- public IconInfo GetInfo(uint languageId)
- {
- Tuple tuple = Load(languageId);
- IconInfo result = new IconInfo(this, languageId, tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5);
-
- return result;
- }
-
- public Icon ToIcon()
- {
- return ToIcon(DEFAULT_LANGUAGE);
- }
-
- public Icon ToIcon(uint languageId)
- {
- Tuple tuple = Load(languageId);
-
- if (!tuple.Item5)
- {
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item4))
- {
- BITMAPINFOHEADER header = Utils.Read(dib_mem);
-
- ushort width = Convert.ToUInt16(header.biWidth);
- ushort height = Convert.ToUInt16(header.biHeight / 2);
- byte color_count = Convert.ToByte(header.biBitCount);
-
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- Utils.Write(Convert.ToUInt16(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
-
- ulong colors = Convert.ToUInt64(Math.Pow(2, color_count));
-
- if (colors >= 256)
- colors = 0;
-
- Utils.Write(Convert.ToByte(width >= 256 ? 0 : width), mem);
- Utils.Write(Convert.ToByte(height >= 256 ? 0 : height), mem);
- Utils.Write(Convert.ToByte(colors), mem);
- Utils.Write(Convert.ToByte(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(color_count), mem);
- Utils.Write(tuple.Item4.Length, mem);
- Utils.Write(22, mem);
-
- Utils.Write(tuple.Item4, mem);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- Icon icon = new Icon(mem);
-
- return icon;
- }
- }
- }
- else
- {
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item4))
- {
- using (Image png = Image.FromStream(dib_mem))
- {
- ushort width = Convert.ToUInt16(png.Width);
- ushort height = Convert.ToUInt16(png.Height);
- byte color_count = 32;
-
- MemoryStream mem = new MemoryStream();
-
- using (mem)
- {
- Utils.Write(Convert.ToUInt16(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
-
- Utils.Write(Convert.ToByte(width >= 256 ? 0 : width), mem);
- Utils.Write(Convert.ToByte(height >= 256 ? 0 : height), mem);
- Utils.Write(Convert.ToByte(0), mem); // 32-bit (16m colors) so 0
- Utils.Write(Convert.ToByte(0), mem);
- Utils.Write(Convert.ToUInt16(1), mem);
- Utils.Write(Convert.ToUInt16(color_count), mem);
- Utils.Write(tuple.Item4.Length, mem);
- Utils.Write(22, mem);
-
- Utils.Write(tuple.Item4, mem);
-
- mem.Seek(0, SeekOrigin.Begin);
-
- Icon icon = new Icon(mem);
-
- return icon;
- }
- }
- }
- }
- }
-
- public Bitmap ToBitmap()
- {
- return ToBitmap(Color.Transparent);
- }
-
- public Bitmap ToBitmap(Color backgroundColor)
- {
- return ToBitmap(DEFAULT_LANGUAGE, Color.Transparent);
- }
-
- public Bitmap ToBitmap(uint languageId)
- {
- return ToBitmap(languageId, Color.Transparent);
- }
-
- public Bitmap ToBitmap(uint languageId, Color backgroundColor)
- {
- Tuple tuple = Load(languageId);
-
- if (!tuple.Item5)
- {
- using (Icon icon = ToIcon(languageId))
- {
- Rectangle rect = new Rectangle(0, 0, icon.Width, icon.Height);
- Bitmap bitmap = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
-
- using (Graphics graphics = Graphics.FromImage(bitmap))
- {
-
- using (SolidBrush brush = new SolidBrush(backgroundColor))
- graphics.FillRectangle(brush, rect);
-
- graphics.DrawIcon(icon, rect);
- }
-
- bitmap.MakeTransparent(backgroundColor);
-
- return bitmap;
- }
- }
- else
- {
- using (MemoryStream dib_mem = new MemoryStream(tuple.Item4))
- {
- using (Image png = Image.FromStream(dib_mem))
- {
- Bitmap bitmap = new Bitmap(png);
-
- return bitmap;
- }
- }
- }
- }
-
- public void Save(string fileName, uint languageId, IconSaveFormat format)
- {
- using (FileStream file = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
- {
- Save(file, languageId, format);
- file.Flush();
- }
- }
-
- public void Save(Stream stream, uint languageId, IconSaveFormat format)
- {
- switch (format)
- {
- case IconSaveFormat.Raw:
- Save(stream, languageId);
- break;
- case IconSaveFormat.Icon:
- default:
- {
- using (Icon icon = ToIcon(languageId))
- {
- icon.Save(stream);
- }
-
- break;
- }
- case IconSaveFormat.Bitmap:
- {
- using (Bitmap bitmap = ToBitmap(languageId))
- {
- bitmap.Save(stream, ImageFormat.Bmp);
- }
-
- break;
- }
- case IconSaveFormat.PNG:
- {
- Tuple tuple = Load(languageId);
-
- if (!tuple.Item5)
- {
- using (Bitmap bitmap = ToBitmap(languageId))
- {
- bitmap.Save(stream, ImageFormat.Png);
- }
- }
- else
- {
- stream.Write(tuple.Item4, 0, tuple.Item4.Length);
- }
-
- break;
- }
- }
- }
-
- private Tuple Load(uint languageId)
- {
- byte[] data = GetBytes(languageId);
- ushort width;
- ushort height;
- byte color_count;
- byte[] dib;
- bool is_png;
-
- using (MemoryStream mem = new MemoryStream(data))
- {
- if (!GraphicResources.IsPNG(data))
- {
- BITMAPINFOHEADER header = Utils.Read(mem);
-
- width = Convert.ToUInt16(header.biWidth);
- height = Convert.ToUInt16(header.biHeight / 2);
- color_count = Convert.ToByte(header.biBitCount);
- dib = mem.ToArray();
- is_png = false;
- }
- else
- {
- using (Image png = Image.FromStream(mem))
- {
- width = Convert.ToUInt16(png.Width);
- height = Convert.ToUInt16(png.Height);
- color_count = 32;
- dib = mem.ToArray();
- is_png = true;
- }
- }
- }
-
- Tuple tuple = new Tuple(width, height, color_count, dib, is_png);
-
- return tuple;
- }
-
- #endregion
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/LanguageIdentifiers.cs b/Src/Workshell.PE.Resources/LanguageIdentifiers.cs
deleted file mode 100644
index 20d1268..0000000
--- a/Src/Workshell.PE.Resources/LanguageIdentifiers.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class LanguageIdentifiers
- {
-
- public const byte LANG_NEUTRAL = 0x00;
- public const byte LANG_INVARIANT = 0x7f;
- public const byte LANG_AFRIKAANS = 0x36;
- public const byte LANG_ALBANIAN = 0x1c;
- public const byte LANG_ARABIC = 0x01;
- public const byte LANG_BASQUE = 0x2d;
- public const byte LANG_BELARUSIAN = 0x23;
- public const byte LANG_BULGARIAN = 0x02;
- public const byte LANG_CATALAN = 0x03;
- public const byte LANG_CHINESE = 0x04;
- public const byte LANG_CROATIAN = 0x1a;
- public const byte LANG_CZECH = 0x05;
- public const byte LANG_DANISH = 0x06;
- public const byte LANG_DUTCH = 0x13;
- public const byte LANG_ENGLISH = 0x09;
- public const byte LANG_ESTONIAN = 0x25;
- public const byte LANG_FAEROESE = 0x38;
- public const byte LANG_FARSI = 0x29;
- public const byte LANG_FINNISH = 0x0b;
- public const byte LANG_FRENCH = 0x0c;
- public const byte LANG_GERMAN = 0x07;
- public const byte LANG_GREEK = 0x08;
- public const byte LANG_HEBREW = 0x0d;
- public const byte LANG_HUNGARIAN = 0x0e;
- public const byte LANG_ICELANDIC = 0x0f;
- public const byte LANG_INDONESIAN = 0x21;
- public const byte LANG_ITALIAN = 0x10;
- public const byte LANG_JAPANESE = 0x11;
- public const byte LANG_KOREAN = 0x12;
- public const byte LANG_LATVIAN = 0x26;
- public const byte LANG_LITHUANIAN = 0x27;
- public const byte LANG_NORWEGIAN = 0x14;
- public const byte LANG_POLISH = 0x15;
- public const byte LANG_PORTUGUESE = 0x16;
- public const byte LANG_ROMANIAN = 0x18;
- public const byte LANG_RUSSIAN = 0x19;
- public const byte LANG_SERBIAN = 0x1a;
- public const byte LANG_SLOVAK = 0x1b;
- public const byte LANG_SLOVENIAN = 0x24;
- public const byte LANG_SPANISH = 0x0a;
- public const byte LANG_SWEDISH = 0x1d;
- public const byte LANG_THAI = 0x1e;
- public const byte LANG_TURKISH = 0x1f;
- public const byte LANG_UKRAINIAN = 0x22;
- public const byte LANG_VIETNAMESE = 0x2a;
-
- public const byte SUBLANG_NEUTRAL = 0x00; // language neutral
- public const byte SUBLANG_DEFAULT = 0x01; // user default
- public const byte SUBLANG_SYS_DEFAULT = 0x02; // system default
- public const byte SUBLANG_CUSTOM_UNSPECIFIED = 0x04; // custom language/locale
- public const byte SUBLANG_UI_CUSTOM_DEFAULT = 0x05; // Default custom MUI language/locale
-
- public const byte SUBLANG_ARABIC_SAUDI_ARABIA = 0x01; // Arabic (Saudi Arabia)
- public const byte SUBLANG_ARABIC_IRAQ = 0x02; // Arabic (Iraq)
- public const byte SUBLANG_ARABIC_EGYPT = 0x03; // Arabic (Egypt)
- public const byte SUBLANG_ARABIC_LIBYA = 0x04; // Arabic (Libya)
- public const byte SUBLANG_ARABIC_ALGERIA = 0x05; // Arabic (Algeria)
- public const byte SUBLANG_ARABIC_MOROCCO = 0x06; // Arabic (Morocco)
- public const byte SUBLANG_ARABIC_TUNISIA = 0x07; // Arabic (Tunisia)
- public const byte SUBLANG_ARABIC_OMAN = 0x08; // Arabic (Oman)
- public const byte SUBLANG_ARABIC_YEMEN = 0x09; // Arabic (Yemen)
- public const byte SUBLANG_ARABIC_SYRIA = 0x0a; // Arabic (Syria)
- public const byte SUBLANG_ARABIC_JORDAN = 0x0b; // Arabic (Jordan)
- public const byte SUBLANG_ARABIC_LEBANON = 0x0c; // Arabic (Lebanon)
- public const byte SUBLANG_ARABIC_KUWAIT = 0x0d; // Arabic (Kuwait)
- public const byte SUBLANG_ARABIC_UAE = 0x0e; // Arabic (U.A.E)
- public const byte SUBLANG_ARABIC_BAHRAIN = 0x0f; // Arabic (Bahrain)
- public const byte SUBLANG_ARABIC_QATAR = 0x10; // Arabic (Qatar)
-
- public const byte SUBLANG_CHINESE_TRADITIONAL = 0x01; // Chinese (Taiwan)
- public const byte SUBLANG_CHINESE_SIMPLIFIED = 0x02; // Chinese (PR China)
- public const byte SUBLANG_CHINESE_HONGKONG = 0x03; // Chinese (Hong Kong)
- public const byte SUBLANG_CHINESE_SINGAPORE = 0x04; // Chinese (Singapore)
-
- public const byte SUBLANG_DUTCH = 0x01; // Dutch
- public const byte SUBLANG_DUTCH_BELGIAN = 0x02; // Dutch (Belgian)
-
- public const byte SUBLANG_ENGLISH_US = 0x01; // English (USA)
- public const byte SUBLANG_ENGLISH_UK = 0x02; // English (UK)
- public const byte SUBLANG_ENGLISH_AUS = 0x03; // English (Australian)
- public const byte SUBLANG_ENGLISH_CAN = 0x04; // English (Canadian)
- public const byte SUBLANG_ENGLISH_NZ = 0x05; // English (New Zealand)
- public const byte SUBLANG_ENGLISH_EIRE = 0x06; // English (Irish)
- public const byte SUBLANG_ENGLISH_SOUTH_AFRICA = 0x07; // English (South Africa)
- public const byte SUBLANG_ENGLISH_JAMAICA = 0x08; // English (Jamaica)
- public const byte SUBLANG_ENGLISH_CARIBBEAN = 0x09; // English (Caribbean)
- public const byte SUBLANG_ENGLISH_BELIZE = 0x0a; // English (Belize)
- public const byte SUBLANG_ENGLISH_TRINIDAD = 0x0b; // English (Trinidad)
-
- public const byte SUBLANG_FRENCH = 0x01; // French
- public const byte SUBLANG_FRENCH_BELGIAN = 0x02; // French (Belgian)
- public const byte SUBLANG_FRENCH_CANADIAN = 0x03; // French (Canadian)
- public const byte SUBLANG_FRENCH_SWISS = 0x04; // French (Swiss)
- public const byte SUBLANG_FRENCH_LUXEMBOURG = 0x05; // French (Luxembourg)
-
- public const byte SUBLANG_GERMAN = 0x01; // German
- public const byte SUBLANG_GERMAN_SWISS = 0x02; // German (Swiss)
- public const byte SUBLANG_GERMAN_AUSTRIAN = 0x03; // German (Austrian)
- public const byte SUBLANG_GERMAN_LUXEMBOURG = 0x04; // German (Luxembourg)
- public const byte SUBLANG_GERMAN_LIECHTENSTEIN = 0x05; // German (Liechtenstein)
-
- public const byte SUBLANG_ITALIAN = 0x01; // Italian
- public const byte SUBLANG_ITALIAN_SWISS = 0x02; // Italian (Swiss)
-
- public const byte SUBLANG_KOREAN = 0x01; // Korean (Extended Wansung)
- public const byte SUBLANG_KOREAN_JOHAB = 0x02; // Korean (Johab)
-
- public const byte SUBLANG_NORWEGIAN_BOKMAL = 0x01; // Norwegian (Bokmal)
- public const byte SUBLANG_NORWEGIAN_NYNORSK = 0x02; // Norwegian (Nynorsk)
-
- public const byte SUBLANG_PORTUGUESE = 0x02; // Portuguese
- public const byte SUBLANG_PORTUGUESE_BRAZILIAN = 0x01; // Portuguese (Brazilian)
-
- public const byte SUBLANG_SERBIAN_LATIN = 0x02; // Serbian (Latin)
- public const byte SUBLANG_SERBIAN_CYRILLIC = 0x03; // Serbian (Cyrillic)
-
- public const byte SUBLANG_SPANISH = 0x01; // Spanish (Castilian)
- public const byte SUBLANG_SPANISH_MEXICAN = 0x02; // Spanish (Mexican)
- public const byte SUBLANG_SPANISH_MODERN = 0x03; // Spanish (Modern)
- public const byte SUBLANG_SPANISH_GUATEMALA = 0x04; // Spanish (Guatemala)
- public const byte SUBLANG_SPANISH_COSTA_RICA = 0x05; // Spanish (Costa Rica)
- public const byte SUBLANG_SPANISH_PANAMA = 0x06; // Spanish (Panama)
- public const byte SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x07; // Spanish (Dominican Republic)
- public const byte SUBLANG_SPANISH_VENEZUELA = 0x08; // Spanish (Venezuela)
- public const byte SUBLANG_SPANISH_COLOMBIA = 0x09; // Spanish (Colombia)
- public const byte SUBLANG_SPANISH_PERU = 0x0a; // Spanish (Peru)
- public const byte SUBLANG_SPANISH_ARGENTINA = 0x0b; // Spanish (Argentina)
- public const byte SUBLANG_SPANISH_ECUADOR = 0x0c; // Spanish (Ecuador)
- public const byte SUBLANG_SPANISH_CHILE = 0x0d; // Spanish (Chile)
- public const byte SUBLANG_SPANISH_URUGUAY = 0x0e; // Spanish (Uruguay)
- public const byte SUBLANG_SPANISH_PARAGUAY = 0x0f; // Spanish (Paraguay)
- public const byte SUBLANG_SPANISH_BOLIVIA = 0x10; // Spanish (Bolivia)
- public const byte SUBLANG_SPANISH_EL_SALVADOR = 0x11; // Spanish (El Salvador)
- public const byte SUBLANG_SPANISH_HONDURAS = 0x12; // Spanish (Honduras)
- public const byte SUBLANG_SPANISH_NICARAGUA = 0x13; // Spanish (Nicaragua)
- public const byte SUBLANG_SPANISH_PUERTO_RICO = 0x14; // Spanish (Puerto Rico)
-
- public const byte SUBLANG_SWEDISH = 0x01; // Swedish
- public const byte SUBLANG_SWEDISH_FINLAND = 0x02; // Swedish (Finland)
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/LocaleIdentifiers.cs b/Src/Workshell.PE.Resources/LocaleIdentifiers.cs
deleted file mode 100644
index cc3fe85..0000000
--- a/Src/Workshell.PE.Resources/LocaleIdentifiers.cs
+++ /dev/null
@@ -1,272 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Workshell.PE.Resources
-{
-
- public sealed class LocaleIdentifiers
- {
-
- public const ushort SUBLANG_CUSTOM_DEFAULT = 0x0C00;
- public const ushort SUBLANG_UI_CUSTOM_DEFAULT = 0x1400;
- public const ushort SUBLANG_NEUTRAL_INVARIANT = 0x007F;
- public const ushort SUBLANG_NEUTRAL = 0x0000;
- public const ushort SUBLANG_SYS_DEFAULT = 0x0800;
- public const ushort SUBLANG_CUSTOM_UNSPECIFIED = 0x1000;
- public const ushort SUBLANG_DEFAULT = 0x0400;
-
- public const ushort SUBLANG_AFRIKAANS_SOUTH_AFRICA = 0x0436;
- public const ushort SUBLANG_ALBANIAN_ALBANIA = 0x041C;
- public const ushort SUBLANG_ALSATIAN_FRANCE = 0x0484;
- public const ushort SUBLANG_AMHARIC_ETHIOPIA = 0x045E;
- public const ushort SUBLANG_ARABIC_ALGERIA = 0x1401;
- public const ushort SUBLANG_ARABIC_BAHRAIN = 0x3C01;
- public const ushort SUBLANG_ARABIC_EGYPT = 0x0C01;
- public const ushort SUBLANG_ARABIC_IRAQ = 0x0801;
- public const ushort SUBLANG_ARABIC_JORDAN = 0x2C01;
- public const ushort SUBLANG_ARABIC_KUWAIT = 0x3401;
- public const ushort SUBLANG_ARABIC_LEBANON = 0x3001;
- public const ushort SUBLANG_ARABIC_LIBYA = 0x1001;
- public const ushort SUBLANG_ARABIC_MOROCCO = 0x1801;
- public const ushort SUBLANG_ARABIC_OMAN = 0x2001;
- public const ushort SUBLANG_ARABIC_QATAR = 0x4001;
- public const ushort SUBLANG_ARABIC_SAUDI_ARABIA = 0x0401;
- public const ushort SUBLANG_ARABIC_SYRIA = 0x2801;
- public const ushort SUBLANG_ARABIC_TUNISIA = 0x1C01;
- public const ushort SUBLANG_ARABIC_UAE = 0x3801;
- public const ushort SUBLANG_ARABIC_YEMEN = 0x2401;
- public const ushort SUBLANG_ARMENIAN_ARMENIA = 0x042B;
- public const ushort SUBLANG_ASSAMESE_INDIA = 0x044D;
- public const ushort SUBLANG_AZERI_CYRILLIC = 0x082C;
- public const ushort SUBLANG_AZERI_LATIN = 0x042C;
- public const ushort SUBLANG_BANGLA_BANGLADESH = 0x0445;
- public const ushort SUBLANG_BASHKIR_RUSSIA = 0x046D;
- public const ushort SUBLANG_BASQUE_BASQUE = 0x042D;
- public const ushort SUBLANG_BELARUSIAN_BELARUS = 0x0423;
- public const ushort SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 0x201A;
- public const ushort SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN = 0x141A;
- public const ushort SUBLANG_BRETON_FRANCE = 0x047E;
- public const ushort SUBLANG_BULGARIAN_BULGARIA = 0x0402;
- public const ushort SUBLANG_CENTRAL_KURDISH_IRAQ = 0x0492;
- public const ushort SUBLANG_CHEROKEE_CHEROKEE = 0x045C;
- public const ushort SUBLANG_CATALAN_CATALAN = 0x0403;
- public const ushort SUBLANG_CHINESE_HONGKONG = 0x0C04;
- public const ushort SUBLANG_CHINESE_MACAU = 0x1404;
- public const ushort SUBLANG_CHINESE_SINGAPORE = 0x1004;
- public const ushort SUBLANG_CHINESE_SIMPLIFIED = 0x0004;
- public const ushort SUBLANG_CHINESE_TRADITIONAL = 0x7C04;
- public const ushort SUBLANG_CORSICAN_FRANCE = 0x0483;
- public const ushort SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN = 0x101A;
- public const ushort SUBLANG_CROATIAN_CROATIA = 0x041A;
- public const ushort SUBLANG_CZECH_CZECH_REPUBLIC = 0x0405;
- public const ushort SUBLANG_DANISH_DENMARK = 0x0406;
- public const ushort SUBLANG_DARI_AFGHANISTAN = 0x048C;
- public const ushort SUBLANG_DIVEHI_MALDIVES = 0x0465;
- public const ushort SUBLANG_DUTCH_BELGIAN = 0x0813;
- public const ushort SUBLANG_DUTCH = 0x0413;
- public const ushort SUBLANG_ENGLISH_AUS = 0x0C09;
- public const ushort SUBLANG_ENGLISH_BELIZE = 0x2809;
- public const ushort SUBLANG_ENGLISH_CAN = 0x1009;
- public const ushort SUBLANG_ENGLISH_CARIBBEAN = 0x2409;
- public const ushort SUBLANG_ENGLISH_INDIA = 0x4009;
- public const ushort SUBLANG_ENGLISH_EIRE = 0x1809;
- public const ushort SUBLANG_ENGLISH_IRELAND = 0x1809;
- public const ushort SUBLANG_ENGLISH_JAMAICA = 0x2009;
- public const ushort SUBLANG_ENGLISH_MALAYSIA = 0x4409;
- public const ushort SUBLANG_ENGLISH_NZ = 0x1409;
- public const ushort SUBLANG_ENGLISH_PHILIPPINES = 0x3409;
- public const ushort SUBLANG_ENGLISH_SINGAPORE = 0x4809;
- public const ushort SUBLANG_ENGLISH_SOUTH_AFRICA = 0x1C09;
- public const ushort SUBLANG_ENGLISH_TRINIDAD = 0x2C09;
- public const ushort SUBLANG_ENGLISH_UK = 0x0809;
- public const ushort SUBLANG_ENGLISH_US = 0x0409;
- public const ushort SUBLANG_ENGLISH_ZIMBABWE = 0x3009;
- public const ushort SUBLANG_ESTONIAN_ESTONIA = 0x0425;
- public const ushort SUBLANG_FAEROESE_FAROE_ISLANDS = 0x0438;
- public const ushort SUBLANG_FILIPINO_PHILIPPINES = 0x0464;
- public const ushort SUBLANG_FINNISH_FINLAND = 0x040B;
- public const ushort SUBLANG_FRENCH_BELGIAN = 0x080C;
- public const ushort SUBLANG_FRENCH_CANADIAN = 0x0C0C;
- public const ushort SUBLANG_FRENCH = 0x040C;
- public const ushort SUBLANG_FRENCH_LUXEMBOURG = 0x140C;
- public const ushort SUBLANG_FRENCH_MONACO = 0x180C;
- public const ushort SUBLANG_FRENCH_SWISS = 0x100C;
- public const ushort SUBLANG_FRISIAN_NETHERLANDS = 0x0462;
- public const ushort SUBLANG_GALICIAN_GALICIAN = 0x0456;
- public const ushort SUBLANG_GEORGIAN_GEORGIA = 0x0437;
- public const ushort SUBLANG_GERMAN_AUSTRIAN = 0x0C07;
- public const ushort SUBLANG_GERMAN = 0x0407;
- public const ushort SUBLANG_GERMAN_LIECHTENSTEIN = 0x1407;
- public const ushort SUBLANG_GERMAN_LUXEMBOURG = 0x1007;
- public const ushort SUBLANG_GERMAN_SWISS = 0x0807;
- public const ushort SUBLANG_GREEK_GREECE = 0x0408;
- public const ushort SUBLANG_GREENLANDIC_GREENLAND = 0x046F;
- public const ushort SUBLANG_GUJARATI_INDIA = 0x0447;
- public const ushort SUBLANG_HAUSA_NIGERIA_LATIN = 0x0468;
- public const ushort SUBLANG_HAWAIIAN_US = 0x0475;
- public const ushort SUBLANG_HEBREW_ISRAEL = 0x040D;
- public const ushort SUBLANG_HINDI_INDIA = 0x0439;
- public const ushort SUBLANG_HUNGARIAN_HUNGARY = 0x040E;
- public const ushort SUBLANG_ICELANDIC_ICELAND = 0x040F;
- public const ushort SUBLANG_IGBO_NIGERIA = 0x0470;
- public const ushort SUBLANG_INDONESIAN_INDONESIA = 0x0421;
- public const ushort SUBLANG_INUKTITUT_CANADA_LATIN = 0x085D;
- public const ushort SUBLANG_INUKTITUT_CANADA = 0x045D;
- public const ushort SUBLANG_IRISH_IRELAND = 0x083C;
- public const ushort SUBLANG_XHOSA_SOUTH_AFRICA = 0x0434;
- public const ushort SUBLANG_ZULU_SOUTH_AFRICA = 0x0435;
- public const ushort SUBLANG_ITALIAN = 0x0410;
- public const ushort SUBLANG_ITALIAN_SWISS = 0x0810;
- public const ushort SUBLANG_JAPANESE_JAPAN = 0x0411;
- public const ushort SUBLANG_KANNADA_INDIA = 0x044B;
- public const ushort SUBLANG_KAZAK_KAZAKHSTAN = 0x043F;
- public const ushort SUBLANG_KHMER_CAMBODIA = 0x0453;
- public const ushort SUBLANG_KICHE_GUATEMALA = 0x0486;
- public const ushort SUBLANG_KINYARWANDA_RWANDA = 0x0487;
- public const ushort SUBLANG_KONKANI_INDIA = 0x0457;
- public const ushort SUBLANG_KOREAN = 0x0412;
- public const ushort SUBLANG_KYRGYZ_KYRGYZSTAN = 0x0440;
- public const ushort SUBLANG_LAO_LAO = 0x0454;
- public const ushort SUBLANG_LATVIAN_LATVIA = 0x0426;
- public const ushort SUBLANG_LITHUANIAN_LITHUANIA = 0x0427;
- public const ushort SUBLANG_LOWER_SORBIAN_GERMANY = 0x082E;
- public const ushort SUBLANG_LUXEMBOURGISH_LUXEMBOURG = 0x046E;
- public const ushort SUBLANG_MACEDONIAN_MACEDONIA = 0x042F;
- public const ushort SUBLANG_MALAY_BRUNEI_DARUSSALAM = 0x083E;
- public const ushort SUBLANG_MALAY_MALAYSIA = 0x043E;
- public const ushort SUBLANG_MALAYALAM_INDIA = 0x044C;
- public const ushort SUBLANG_MALTESE_MALTA = 0x043A;
- public const ushort SUBLANG_MAORI_NEW_ZEALAND = 0x0481;
- public const ushort SUBLANG_MAPUDUNGUN_CHILE = 0x047A;
- public const ushort SUBLANG_MARATHI_INDIA = 0x044E;
- public const ushort SUBLANG_MOHAWK_MOHAWK = 0x047C;
- public const ushort SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA = 0x0450;
- public const ushort SUBLANG_MONGOLIAN_PRC = 0x0850;
- public const ushort SUBLANG_NEPALI_NEPAL = 0x0461;
- public const ushort SUBLANG_NORWEGIAN_BOKMAL = 0x0414;
- public const ushort SUBLANG_NORWEGIAN_NYNORSK = 0x0814;
- public const ushort SUBLANG_OCCITAN_FRANCE = 0x0482;
- public const ushort SUBLANG_ORIYA_INDIA = 0x0448;
- public const ushort SUBLANG_PASHTO_AFGHANISTAN = 0x0463;
- public const ushort SUBLANG_PERSIAN_IRAN = 0x0429;
- public const ushort SUBLANG_POLISH_POLAND = 0x0415;
- public const ushort SUBLANG_PORTUGUESE_BRAZILIAN = 0x0416;
- public const ushort SUBLANG_PORTUGUESE = 0x0816;
- public const ushort SUBLANG_PULAR_SENEGAL = 0x0867;
- public const ushort SUBLANG_PUNJABI_INDIA = 0x0446;
- public const ushort SUBLANG_PUNJABI_PAKISTAN = 0x0846;
- public const ushort SUBLANG_QUECHUA_BOLIVIA = 0x046B;
- public const ushort SUBLANG_QUECHUA_ECUADOR = 0x086B;
- public const ushort SUBLANG_QUECHUA_PERU = 0x0C6B;
- public const ushort SUBLANG_ROMANIAN_ROMANIA = 0x0418;
- public const ushort SUBLANG_ROMANSH_SWITZERLAND = 0x0417;
- public const ushort SUBLANG_RUSSIAN_RUSSIA = 0x0419;
- public const ushort SUBLANG_SAKHA_RUSSIA = 0x0485;
- public const ushort SUBLANG_SAMI_INARI_FINLAND = 0x243B;
- public const ushort SUBLANG_SAMI_LULE_NORWAY = 0x103B;
- public const ushort SUBLANG_SAMI_LULE_SWEDEN = 0x143B;
- public const ushort SUBLANG_SAMI_NORTHERN_FINLAND = 0x0C3B;
- public const ushort SUBLANG_SAMI_NORTHERN_NORWAY = 0x043B;
- public const ushort SUBLANG_SAMI_NORTHERN_SWEDEN = 0x083B;
- public const ushort SUBLANG_SAMI_SKOLT_FINLAND = 0x203B;
- public const ushort SUBLANG_SAMI_SOUTHERN_NORWAY = 0x183B;
- public const ushort SUBLANG_SAMI_SOUTHERN_SWEDEN = 0x1C3B;
- public const ushort SUBLANG_SANSKRIT_INDIA = 0x044F;
- public const ushort SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC = 0x1C1A;
- public const ushort SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN = 0x181A;
- public const ushort SUBLANG_SERBIAN_CYRILLIC = 0x0C1A;
- public const ushort SUBLANG_SERBIAN_LATIN = 0x081A;
- public const ushort SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA = 0x046C;
- public const ushort SUBLANG_TSWANA_BOTSWANA = 0x0832;
- public const ushort SUBLANG_TSWANA_SOUTH_AFRICA = 0x0432;
- public const ushort SUBLANG_SINDHI_INDIA = 0x0459;
- public const ushort SUBLANG_SINDHI_PAKISTAN = 0x0859;
- public const ushort SUBLANG_SINHALESE_SRI_LANKA = 0x045B;
- public const ushort SUBLANG_SLOVAK_SLOVAKIA = 0x041B;
- public const ushort SUBLANG_SLOVENIAN_SLOVENIA = 0x0424;
- public const ushort SUBLANG_SPANISH_ARGENTINA = 0x2C0A;
- public const ushort SUBLANG_SPANISH_BOLIVIA = 0x400A;
- public const ushort SUBLANG_SPANISH_CHILE = 0x340A;
- public const ushort SUBLANG_SPANISH_COLOMBIA = 0x240A;
- public const ushort SUBLANG_SPANISH_COSTA_RICA = 0x140A;
- public const ushort SUBLANG_SPANISH_DOMINICAN_REPUBLIC = 0x1C0A;
- public const ushort SUBLANG_SPANISH_ECUADOR = 0x300A;
- public const ushort SUBLANG_SPANISH_EL_SALVADOR = 0x440A;
- public const ushort SUBLANG_SPANISH_GUATEMALA = 0x100A;
- public const ushort SUBLANG_SPANISH_HONDURAS = 0x480A;
- public const ushort SUBLANG_SPANISH_MEXICAN = 0x080A;
- public const ushort SUBLANG_SPANISH_NICARAGUA = 0x4C0A;
- public const ushort SUBLANG_SPANISH_PANAMA = 0x180A;
- public const ushort SUBLANG_SPANISH_PARAGUAY = 0x3C0A;
- public const ushort SUBLANG_SPANISH_PERU = 0x280A;
- public const ushort SUBLANG_SPANISH_PUERTO_RICO = 0x500A;
- public const ushort SUBLANG_SPANISH_MODERN = 0x0C0A;
- public const ushort SUBLANG_SPANISH = 0x040A;
- public const ushort SUBLANG_SPANISH_US = 0x540A;
- public const ushort SUBLANG_SPANISH_URUGUAY = 0x380A;
- public const ushort SUBLANG_SPANISH_VENEZUELA = 0x200A;
- public const ushort SUBLANG_SWAHILI = 0x0441;
- public const ushort SUBLANG_SWEDISH_FINLAND = 0x081D;
- public const ushort SUBLANG_SWEDISH = 0x041D;
- public const ushort SUBLANG_SWEDISH_SWEDEN = 0x041D;
- public const ushort SUBLANG_SYRIAC = 0x045A;
- public const ushort SUBLANG_TAJIK_TAJIKISTAN = 0x0428;
- public const ushort SUBLANG_TAMAZIGHT_ALGERIA_LATIN = 0x085F;
- public const ushort SUBLANG_TAMIL_INDIA = 0x0449;
- public const ushort SUBLANG_TAMIL_SRI_LANKA = 0x0849;
- public const ushort SUBLANG_TATAR_RUSSIA = 0x0444;
- public const ushort SUBLANG_TELUGU_INDIA = 0x044A;
- public const ushort SUBLANG_THAI_THAILAND = 0x041E;
- public const ushort SUBLANG_TIBETAN_PRC = 0x0451;
- public const ushort SUBLANG_TIGRINYA_ERITREA = 0x0873;
- public const ushort SUBLANG_TIGRINYA_ETHIOPIA = 0x0473;
- public const ushort SUBLANG_TIGRIGNA_ERITREA = 0x0873;
- public const ushort SUBLANG_TURKISH_TURKEY = 0x041F;
- public const ushort SUBLANG_TURKMEN_TURKMENISTAN = 0x0442;
- public const ushort SUBLANG_UKRAINIAN_UKRAINE = 0x0422;
- public const ushort SUBLANG_UPPER_SORBIAN_GERMANY = 0x042E;
- public const ushort SUBLANG_URDU_INDIA = 0x0820;
- public const ushort SUBLANG_URDU_PAKISTAN = 0x0420;
- public const ushort SUBLANG_UIGHUR_PRC = 0x0480;
- public const ushort SUBLANG_UZBEK_CYRILLIC = 0x0843;
- public const ushort SUBLANG_UZBEK_LATIN = 0x0443;
- public const ushort SUBLANG_VALENCIAN_VALENCIA = 0x0803;
- public const ushort SUBLANG_VIETNAMESE_VIETNAM = 0x042A;
- public const ushort SUBLANG_WELSH_UNITED_KINGDOM = 0x0452;
- public const ushort SUBLANG_WOLOF_SENEGAL = 0x0488;
- public const ushort SUBLANG_YI_PRC = 0x0478;
- public const ushort SUBLANG_YORUBA_NIGERIA = 0x046A;
-
- }
-
-}
diff --git a/Src/Workshell.PE.Resources/Menus/MenuItem.cs b/Src/Workshell.PE.Resources/Menus/MenuItem.cs
deleted file mode 100644
index 3a73817..0000000
--- a/Src/Workshell.PE.Resources/Menus/MenuItem.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-#region License
-// Copyright(c) 2016, Workshell Ltd
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * 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.
-// * Neither the name of Workshell Ltd nor the names of its contributors
-// may be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// 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 WORKSHELL 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.
-#endregion
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using Workshell.PE.Annotations;
-
-namespace Workshell.PE.Resources
-{
-
- [Flags]
- public enum MenuItemFlags : ushort
- {
- Enabled = 0,
- Grayed = 0x0001,
- Disabled = 0x0002,
- Bitmap = 0x0004,
- OwnerDraw = 0x0100,
- Checked = 0x0008,
- Popup = 0x0010,
- MenubarBreak = 0x0020,
- MenuBreak = 0x0040,
- EndMenu = 0x0080,
- Seperator = 0x0800
- }
-
- public class MenuItem
- {
-
- private ushort id;
- private string text;
- private string shortcut;
- private ushort flags;
-
- internal MenuItem(ushort itemId, string itemText, ushort itemFlags)
- {
- id = itemId;
-
- string[] parts = itemText.Split(new char[] { '\t' }, 2);
-
- text = parts[0];
-
- if (parts.Length > 1)
- {
- shortcut = parts[1];
- }
- else
- {
- shortcut = String.Empty;
- }
-
- flags = itemFlags;
- }
-
- #region Methods
-
- public override string ToString()
- {
- if (!IsSeperator)
- {
- string result = text;
-
- if (IsPopup)
- result = "+" + result;
-
- if (shortcut != String.Empty)
- result += " | " + shortcut;
-
- return result;
- }
- else
- {
- return "-";
- }
- }
-
- #endregion
-
- #region Properties
-
- public ushort Id
- {
- get
- {
- return id;
- }
- }
-
- public string Text
- {
- get
- {
- return text;
- }
- }
-
- public string Shortcut
- {
- get
- {
- return shortcut;
- }
- }
-
- public MenuItemFlags Flags
- {
- get
- {
- return (MenuItemFlags)flags;
- }
- }
-
- public bool IsPopup
- {
- get
- {
- return (id == 0);
- }
- }
-
- public bool IsSeperator
- {
- get
- {
- return (id == 0 && flags == 0 && shortcut == String.Empty);
- }
- }
-
- #endregion
-
- }
-
- public sealed class PopupMenuItem : MenuItem, IEnumerable