diff --git a/.gitignore b/.gitignore
index 4d4725b..91b4ef0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
-Release_*
-Debug_*
-*/Debug_*
-*/Release_*
+Release*
+Debug*
+*/Debug*
+*/Release*
*.user
*.opensdf
*.sdf
@@ -9,3 +9,6 @@ Debug_*
*.ncb
*.aps
.vs
+*.VC*
+packages
+obj
diff --git a/LsapiSharp.Test/LsapiSharp.Test.csproj b/LsapiSharp.Test/LsapiSharp.Test.csproj
new file mode 100644
index 0000000..1b47bed
--- /dev/null
+++ b/LsapiSharp.Test/LsapiSharp.Test.csproj
@@ -0,0 +1,139 @@
+
+
+
+ Debug
+ AnyCPU
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}
+ Library
+ Properties
+ LsapiSharp.Test
+ LsapiSharp.Test
+ v4.6.1
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+ x64
+ bin\x64\Debug\
+ false
+ false
+
+
+ x64
+ bin\x64\Release\
+ false
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+ false
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+ false
+
+
+
+ ..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {7f8140dc-7815-4368-94f8-a7ed7cf04a2a}
+ LsapiSharp
+
+
+
+
+ Always
+
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+ copy $(SolutionDir)bin\$(ConfigurationName)_$(PlatformName)\lsapi.dll $(TargetDir)
+
+
+
\ No newline at end of file
diff --git a/LsapiSharp.Test/LsapiSharpTest.cs b/LsapiSharp.Test/LsapiSharpTest.cs
new file mode 100644
index 0000000..c3367ea
--- /dev/null
+++ b/LsapiSharp.Test/LsapiSharpTest.cs
@@ -0,0 +1,600 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Text;
+
+using Microsoft.Win32.SafeHandles;
+using NUnit.Framework;
+
+using static LsapiSharp.NativeMethods;
+
+
+namespace LsapiSharp.Test
+{
+ [TestFixture]
+ [Author("Donelle Sanders Jr", "donelle@donellesandersjr.com")]
+ public class LsapiSharpTest
+ {
+ const int MAX_PATH = 256;
+ const int MAX_LINE_LENGTH = 4096;
+ const int MAX_COMMAND = 64;
+
+ static string stepRCPath;
+ static SafeFileHandle hstepRCFile;
+
+ [OneTimeSetUp()]
+ public static void InitializeTest()
+ {
+ var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ var initialized = LSAPIInitialize(location, stepRCPath = Path.Combine(location, "step.rc"));
+ Assert.IsTrue(initialized);
+
+ hstepRCFile = LCOpen(stepRCPath);
+ Assert.IsFalse(hstepRCFile.IsClosed);
+ }
+
+ [OneTimeTearDown]
+ public static void FinalizeTest()
+ {
+ var closed = LCClose(hstepRCFile);
+ Assert.IsTrue(closed);
+ }
+
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LCTokenize_Test()
+ {
+ const string LINE = "*Setting option1 option2 option3 option4 somemore stuff";
+
+ string[] tokens = new string[5];
+ StringBuilder extraConfig = new StringBuilder(25);
+
+ int len = Tokenize(LCTokenize, LINE, tokens, extraConfig);
+ string extraParams = extraConfig.ToString();
+
+ Assert.AreEqual(tokens.Length, len);
+ Assert.AreEqual("*Setting", tokens[0]);
+ Assert.AreEqual("option1", tokens[1]);
+ Assert.AreEqual("option2", tokens[2]);
+ Assert.AreEqual("option3", tokens[3]);
+ Assert.AreEqual("option4", tokens[4]);
+ Assert.IsTrue(extraParams.StartsWith("somemore"));
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void CommandTokenize_Test()
+ {
+ const string LINE = "*Setting !commandA [!command1][!command2] somemore stuff";
+
+ string[] tokens = new string[4];
+ StringBuilder extraConfig = new StringBuilder(25);
+
+ int len = Tokenize(CommandTokenize, LINE, tokens, extraConfig);
+ string extraParams = extraConfig.ToString();
+
+ Assert.AreEqual(tokens.Length, len);
+ Assert.AreEqual("*Setting", tokens[0]);
+ Assert.AreEqual("!commandA", tokens[1]);
+ Assert.AreEqual("!command1", tokens[2]);
+ Assert.AreEqual("!command2", tokens[3]);
+ Assert.IsTrue(extraParams.StartsWith("somemore"));
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void CommandParse_Test()
+ {
+ string line = "[!command1][!command2][!command3 !command4]";
+
+ string cmd = "!command1";
+ StringBuilder cmdbuffer = new StringBuilder(cmd.Length + 1),
+ argbuffer = new StringBuilder(line.Length + 1);
+
+ CommandParse(line, cmdbuffer, argbuffer, cmdbuffer.Capacity, argbuffer.Capacity);
+ Assert.AreEqual(cmd, cmdbuffer.ToString());
+
+ line = argbuffer.ToString();
+ cmd = "!command2";
+ cmdbuffer = new StringBuilder(cmd.Length + 1);
+ argbuffer = new StringBuilder(line.Length + 1);
+
+ CommandParse(line, cmdbuffer, argbuffer, cmdbuffer.Capacity, argbuffer.Capacity);
+ Assert.AreEqual(cmd, cmdbuffer.ToString());
+
+ line = argbuffer.ToString();
+ cmd = "!command3 !command4";
+ cmdbuffer = new StringBuilder(cmd.Length + 1);
+
+ CommandParse(line, cmdbuffer, null, cmdbuffer.Capacity, 0);
+ Assert.AreEqual(cmd, cmdbuffer.ToString());
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LCReadNextCommand_Test()
+ {
+ StringBuilder buffer = new StringBuilder(MAX_LINE_LENGTH);
+ bool retval = LCReadNextCommand(hstepRCFile, buffer, buffer.Capacity);
+ string line = buffer.ToString();
+
+ Assert.IsTrue(retval);
+ Assert.NotZero(line.Length);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LCReadNextConfig_Test()
+ {
+ StringBuilder buffer = new StringBuilder(MAX_LINE_LENGTH);
+ bool retval = LCReadNextConfig(hstepRCFile, "*Config", buffer, buffer.Capacity);
+ Assert.IsTrue(retval);
+
+ string line = buffer.ToString();
+ string[] tokens = new string[4];
+ int len = Tokenize(LCTokenize, line, tokens);
+
+ Assert.AreEqual(tokens.Length, len);
+ Assert.AreEqual("*Config", tokens[0]);
+ Assert.AreEqual("option1", tokens[1]);
+ Assert.AreEqual("option2", tokens[2]);
+ Assert.AreEqual("option3", tokens[3]);
+
+ tokens = new string[2];
+
+ retval = LCReadNextConfig(hstepRCFile, "*Config", buffer, buffer.Capacity);
+ Assert.IsTrue(retval);
+
+ line = buffer.ToString();
+ len = Tokenize(LCTokenize, line, tokens);
+
+ Assert.AreEqual(tokens.Length, len);
+ Assert.AreEqual("*Config", tokens[0]);
+ Assert.AreEqual("option1", tokens[1]);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LCReadNextLine_Test()
+ {
+ StringBuilder buffer = new StringBuilder(MAX_LINE_LENGTH);
+ bool retval = LCReadNextLine(hstepRCFile, buffer, buffer.Capacity);
+ string line = buffer.ToString();
+
+ Assert.IsTrue(retval);
+ Assert.NotZero(line.Length);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCInt_Test()
+ {
+ int retval = GetRCInt("VarB", 0);
+ Assert.AreEqual(15, retval);
+
+ retval = GetRCInt("SomeSetting", 0);
+ Assert.AreEqual(0, retval);
+
+ long retval64 = GetRCInt64("VarD", 0);
+ Assert.AreEqual(9223372036854775800L, retval64);
+
+ retval64 = GetRCInt("SomeSetting", 0);
+ Assert.AreEqual(0, retval64);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCFloat_Test()
+ {
+ float retval = GetRCFloat("VarF", 0);
+ Assert.AreEqual(53.675f, retval);
+
+ retval = GetRCFloat("SomeSetting", 0);
+ Assert.AreEqual(0, retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCDouble_Test()
+ {
+ double retval = GetRCDouble("VarG", 0);
+ Assert.AreEqual(1.7E+3d, retval);
+
+ retval = GetRCFloat("SomeSetting", 0);
+ Assert.AreEqual(0, retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCBoolDef_Test()
+ {
+ bool retval = GetRCBoolDef("VarA", false);
+ Assert.IsTrue(retval);
+
+ retval = GetRCBoolDef("VarH", false);
+ Assert.IsTrue(retval);
+
+ retval = GetRCBoolDef("SomeSetting", false);
+ Assert.IsFalse(retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCBool_Test()
+ {
+ bool retval = GetRCBool("VarA", false);
+ Assert.IsFalse(retval);
+
+ retval = GetRCBool("VarA", true);
+ Assert.IsTrue(retval);
+
+ retval = GetRCBool("SomeSetting", false);
+ Assert.IsTrue(retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCString_Test()
+ {
+ StringBuilder buffer = new StringBuilder(MAX_COMMAND);
+ bool retval = GetRCString("VarC", buffer, "Test", buffer.Capacity);
+ string rcVal = buffer.ToString();
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual("Command3", rcVal);
+
+ retval = GetRCString("SomeSetting", buffer, "Test", buffer.Capacity);
+ rcVal = buffer.ToString();
+
+ Assert.IsFalse(retval);
+ Assert.AreEqual("Test", rcVal);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCLine_Test()
+ {
+ StringBuilder buffer = new StringBuilder(MAX_LINE_LENGTH);
+ bool retval = GetRCLine("*Script", buffer, buffer.Capacity, null);
+
+ Assert.IsTrue(retval);
+
+ string[] tokens = new string[6];
+ Tokenize(LCTokenize, buffer.ToString(), tokens);
+
+ Assert.AreEqual("exec", tokens[0]);
+ Assert.AreEqual("!LabelSetAlpha", tokens[1]);
+ Assert.AreEqual("Initialising", tokens[2]);
+ Assert.AreEqual("250", tokens[3]);
+ Assert.AreEqual("3", tokens[4]);
+ Assert.AreEqual("10", tokens[5]);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCColor_Test()
+ {
+ var defaultVal = new LSColorRef(0);
+ LSColorRef retval = GetRCColor("VarJ", defaultVal);
+
+ Assert.AreEqual(70, retval.R);
+ Assert.AreEqual(130, retval.G);
+ Assert.AreEqual(180, retval.B);
+ Assert.AreEqual(11829830, retval.Value);
+
+ retval = GetRCColor("SomethingElse", defaultVal);
+
+ Assert.AreEqual(defaultVal.Value, retval.Value);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetRCCoordinate_Test()
+ {
+ var retval = GetRCCoordinate("VarK", 0, 0);
+ Assert.AreEqual(100, retval);
+
+ retval = GetRCCoordinate("VarL", 0, 100);
+ Assert.AreEqual(20, retval);
+
+ retval = GetRCCoordinate("SomethingElse", 50, 50);
+ Assert.AreEqual(50, retval);
+
+ retval = ParseCoordinate("1000", 50, 0);
+ Assert.AreEqual(1000, retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LSGetVariable_Test()
+ {
+ StringBuilder value = new StringBuilder(MAX_LINE_LENGTH);
+ var retval = LSGetVariable("VarJ", value);
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual("4682B4", value.ToString());
+
+ value = new StringBuilder(2);
+ retval = LSGetVariable("at", value, value.Capacity);
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual("@", value.ToString());
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void LSSetVariable_Test()
+ {
+ string val = "1234";
+ LSSetVariable("Test", val);
+
+ StringBuilder value = new StringBuilder(4);
+ var retval = LSGetVariable("Test", value);
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual(val, value.ToString());
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void VarExpansion_Test()
+ {
+ StringBuilder buffer = new StringBuilder(10);
+ VarExpansion(buffer, "$VarA$");
+
+ Assert.AreEqual("TRUE", buffer.ToString());
+
+ buffer = new StringBuilder(MAX_COMMAND);
+ VarExpansion(buffer, "$VarB$", buffer.Capacity);
+
+ Assert.AreEqual("15", buffer.ToString());
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void GetToken_Test()
+ {
+ string line = "*Script exec !LabelSetAlpha Initialising 250 3 10";
+ string[] tokens = line.Split(' ');
+
+ foreach (var token in tokens)
+ {
+ StringBuilder buffer = new StringBuilder(token.Length);
+
+ IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(char)) * line.Length);
+ IntPtr nextToken = Marshal.AllocHGlobal(Marshal.SizeOf(ptr));
+ Marshal.WriteIntPtr(nextToken, ptr);
+
+ var retval = GetToken(line, buffer, nextToken, false);
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual(token, buffer.ToString());
+
+ ptr = Marshal.ReadIntPtr(nextToken);
+ line = Marshal.PtrToStringAuto(ptr);
+
+ Marshal.FreeHGlobal(nextToken);
+ }
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void Match_Test()
+ {
+ var retval = Match("ex?c", "exec");
+ Assert.IsTrue(retval);
+
+ retval = Match("ex*", "exec");
+ Assert.IsTrue(retval);
+
+ retval = Match("exec", "exec ");
+ Assert.IsFalse(retval);
+
+ var iretval = MatchE("[A-Z", "exec");
+ Assert.AreEqual(MATCH_PATTERN, iretval);
+
+ iretval = MatchE("exec", "exec ");
+ Assert.AreEqual(MATCH_END, iretval);
+
+ iretval = MatchE("[0-9]", "exec");
+ Assert.AreEqual(MATCH_RANGE, iretval);
+
+ iretval = MatchE("'exec", "exec");
+ Assert.AreEqual(MATCH_LITERAL, iretval);
+
+ iretval = MatchE("exe* ", "exec");
+ Assert.AreEqual(MATCH_ABORT, iretval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void IsPatternValid_Test()
+ {
+ int errorCode = 0;
+
+ var retval = IsPatternValid("exec\\", ref errorCode);
+
+ Assert.IsFalse(retval);
+ Assert.AreEqual(PATTERN_ESC, errorCode);
+
+ retval = IsPatternValid("[]", ref errorCode);
+
+ Assert.IsFalse(retval);
+ Assert.AreEqual(PATTERN_EMPTY, errorCode);
+
+ retval = IsPatternValid("[a-z][", ref errorCode);
+
+ Assert.IsFalse(retval);
+ Assert.AreEqual(PATTERN_CLOSE, errorCode);
+
+ retval = IsPatternValid("[a-]", ref errorCode);
+
+ Assert.IsFalse(retval);
+ Assert.AreEqual(PATTERN_RANGE, errorCode);
+
+ retval = IsPatternValid("[a-zA-Z_0-9]", ref errorCode);
+
+ Assert.IsTrue(retval);
+ Assert.AreEqual(PATTERN_VALID, errorCode);
+ }
+
+ [TestCase]
+ [Category("Diagnostics")]
+ public void LSLog_Test()
+ {
+ Assert.IsTrue(GetRCBool("LSLogFile", true));
+
+ var loglevel = GetRCInt("LSLogLevel", LS_LOG_DEBUG);
+
+ var retval = LSLog(loglevel, "LsapiSharpTest", "Logging test");
+ Assert.IsTrue(retval);
+
+ retval = LSLog(loglevel, "LsapiSharpTest", "Logging Test with logging level %i", loglevel);
+ Assert.IsTrue(retval);
+ }
+
+ [TestCase]
+ [Category("Configuration")]
+ public void EnumLSData_Test()
+ {
+ EnumBangDelegate bangCb = (cmd, lparam) =>
+ {
+ LSLog(LS_LOG_DEBUG, "LsapiSharpTest", "Enum Bang command: " + cmd);
+ return true;
+ };
+
+ EnumBangV2Delegate bangV2Cb = (hInst, cmd, lparam) =>
+ {
+ LSLog(LS_LOG_DEBUG, "LsapiSharpTest", "Enum Bang V2 command: " + cmd);
+ return true;
+ };
+
+ EnumRevIdsDelegate revIdCb = (revId, lparam) =>
+ {
+ LSLog(LS_LOG_DEBUG, "LsapiSharpTest", "Enum RevId: " + revId);
+ return true;
+ };
+
+ var retval = EnumLSData(ELD_BANGS, bangCb, IntPtr.Zero);
+ Assert.AreEqual(LSHResult.S_OK, retval.Value);
+
+ retval = EnumLSData(ELD_BANGS_V2, bangV2Cb, IntPtr.Zero);
+ Assert.AreEqual(LSHResult.S_OK, retval.Value);
+
+ retval = EnumLSData(ELD_REVIDS, revIdCb, IntPtr.Zero);
+ Assert.AreEqual(LSHResult.S_OK, retval.Value);
+ }
+
+ [TestCase]
+ public void GetLitestepPath_Test()
+ {
+ StringBuilder path = new StringBuilder(MAX_PATH);
+ string lspath = Path.GetDirectoryName(stepRCPath) + @"\";
+
+ var retval = LSGetLitestepPath(path, MAX_PATH);
+ Assert.IsTrue(retval);
+ Assert.AreEqual(lspath, path.ToString());
+ }
+
+ [TestCase]
+ public void LSGetImagePath_Test()
+ {
+ StringBuilder path = new StringBuilder(MAX_PATH);
+ string imgpath = Path.GetDirectoryName(stepRCPath) + @"\images\";
+
+ var retval = LSGetImagePath(path, MAX_PATH);
+ Assert.IsTrue(retval);
+ Assert.AreEqual(imgpath, path.ToString());
+ }
+
+ [TestCase]
+ public void Bang_Test()
+ {
+ const string TEST_ARGS = "testarg";
+
+ BangCommandDelegate bang = (sender, args) => Assert.AreEqual(TEST_ARGS, args);
+
+ BangCommandDelegate2 bang2 = (sender, cmd, args) =>
+ {
+ Assert.AreEqual("!Test2", cmd);
+ Assert.AreEqual(TEST_ARGS, args);
+ };
+
+ var retval = AddBangCommand("!Test1", bang);
+ Assert.IsTrue(retval);
+
+ retval = AddBangCommand("!Test2", bang2);
+ Assert.IsTrue(retval);
+
+ retval = ExecuteBangCommand(IntPtr.Zero, "!Test1", TEST_ARGS);
+ Assert.IsTrue(retval);
+
+ retval = ExecuteBangCommand(IntPtr.Zero, "!Test2", TEST_ARGS);
+ Assert.IsTrue(retval);
+
+ retval = RemoveBangCommand("!Test1");
+ Assert.IsTrue(retval);
+
+ retval = RemoveBangCommand("!Test2");
+ Assert.IsTrue(retval);
+
+ retval = ExecuteBangCommand(IntPtr.Zero, "!Test1", TEST_ARGS);
+ Assert.IsFalse(retval);
+
+ retval = ExecuteBangCommand(IntPtr.Zero, "!Test2", TEST_ARGS);
+ Assert.IsFalse(retval);
+ }
+
+ private static int Tokenize(
+ Func tokenize,
+ string line,
+ string [] tokens,
+ StringBuilder extra = null)
+ {
+ int intPtrSize = Marshal.SizeOf(typeof(IntPtr));
+ IntPtr tokensPtr = Marshal.AllocHGlobal(intPtrSize * tokens.Length);
+
+ for (int i = 0; i < tokens.Length; i++)
+ {
+ IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(char)) * MAX_COMMAND);
+ Marshal.WriteIntPtr(tokensPtr, i * intPtrSize, ptr);
+ }
+
+ int tokenLen = tokenize(line, tokensPtr, tokens.Length, extra);
+
+ for (int i = 0; i < tokens.Length; i++)
+ {
+ IntPtr ptr = Marshal.ReadIntPtr(tokensPtr, i * intPtrSize);
+ tokens[i] = Marshal.PtrToStringAuto(ptr);
+ Marshal.FreeHGlobal(ptr);
+ }
+
+ Marshal.FreeHGlobal(tokensPtr);
+ return tokenLen;
+ }
+ }
+}
diff --git a/LsapiSharp.Test/Properties/AssemblyInfo.cs b/LsapiSharp.Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..391cc6b
--- /dev/null
+++ b/LsapiSharp.Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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("LsapiSharp.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LsapiSharp.Test")]
+[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("580b3cbe-9e12-41a2-b723-6ce9bbcb7527")]
+
+// 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/LsapiSharp.Test/packages.config b/LsapiSharp.Test/packages.config
new file mode 100644
index 0000000..756e55e
--- /dev/null
+++ b/LsapiSharp.Test/packages.config
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LsapiSharp.Test/step.rc b/LsapiSharp.Test/step.rc
new file mode 100644
index 0000000..4ecd9c0
--- /dev/null
+++ b/LsapiSharp.Test/step.rc
@@ -0,0 +1,25 @@
+; test configurations
+
+VarA TRUE
+VarB 15
+VarC "Command3"
+VarD 9223372036854775800
+VarF 53.675
+VarG 1.7E+3
+VarH 1
+VarJ 4682B4
+VarK 100C
+VarL -80%
+
+; LCReadNextConfig test configurations
+
+*Config option1 option2 option3
+*Config option1
+
+; GetRCLine test configurations
+
+*Script exec !LabelSetAlpha Initialising 250 3 10
+
+; LSLog test
+LSLogFile $LiteStepDir$log.txt
+LSLogLevel 4
\ No newline at end of file
diff --git a/LsapiSharp/LsapiSharp.csproj b/LsapiSharp/LsapiSharp.csproj
new file mode 100644
index 0000000..b4da6a7
--- /dev/null
+++ b/LsapiSharp/LsapiSharp.csproj
@@ -0,0 +1,86 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}
+ Library
+ Properties
+ LsapiSharp
+ LsapiSharp
+ v2.0
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x64
+
+
+ x64
+ bin\x64\Debug\
+ true
+
+
+ x64
+ bin\x64\Release\
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE
+ full
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ bin\x86\Release\
+ TRACE
+ true
+ pdbonly
+ x86
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ true
+
+
+ LsapiSharp.pfx
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LsapiSharp/LsapiSharp.pfx b/LsapiSharp/LsapiSharp.pfx
new file mode 100644
index 0000000..093cc6a
Binary files /dev/null and b/LsapiSharp/LsapiSharp.pfx differ
diff --git a/LsapiSharp/NativeMethods.cs b/LsapiSharp/NativeMethods.cs
new file mode 100644
index 0000000..c2d8458
--- /dev/null
+++ b/LsapiSharp/NativeMethods.cs
@@ -0,0 +1,1603 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+using Microsoft.Win32.SafeHandles;
+
+[assembly: CLSCompliant(true)]
+
+namespace LsapiSharp
+{
+ public static class NativeMethods
+ {
+ private const string LSAPI = "lsapi.dll";
+
+ ///
+ /// Some "magical" shit that the main litestep window uses
+ ///
+ public const int MagicDword = 0x49474541;
+
+ ///
+ /// Logging Level Error
+ ///
+ public const int LS_LOG_ERROR = 1;
+
+ ///
+ /// Logging Level Warning
+ ///
+ public const int LS_LOG_WARNING = 2;
+
+ ///
+ /// Logging Level Notice (Info)
+ ///
+ public const int LS_LOG_NOTICE = 3;
+
+ ///
+ /// Logging Level Debug
+ ///
+ public const int LS_LOG_DEBUG = 4;
+
+ ///
+ /// Valid match
+ ///
+ public const int MATCH_VALID = 1;
+
+ ///
+ /// Premature end of pattern string
+ ///
+ public const int MATCH_END = 2;
+
+ ///
+ /// Premature end of text string
+ ///
+ public const int MATCH_ABORT = 3;
+
+ ///
+ /// Match failure on [..] construct
+ ///
+ public const int MATCH_RANGE = 4;
+
+ ///
+ /// Match failure on literal match
+ ///
+ public const int MATCH_LITERAL = 5;
+
+ ///
+ /// Bad pattern
+ ///
+ public const int MATCH_PATTERN = 6;
+
+ ///
+ /// Valid pattern
+ ///
+ public const int PATTERN_VALID = 0;
+
+ ///
+ /// Literal escape at end of pattern
+ ///
+ public const int PATTERN_ESC = -1;
+
+ ///
+ /// Malformed range in [..] construct
+ ///
+ public const int PATTERN_RANGE = -2;
+
+ ///
+ /// No end bracket in [..] construct
+ ///
+ public const int PATTERN_CLOSE = -3;
+
+ ///
+ /// [..] contstruct is empty
+ ///
+ public const int PATTERN_EMPTY = -4;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int ELD_BANGS = 1;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int ELD_MODULES = 2;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int ELD_REVIDS = 3;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int ELD_BANGS_V2 = 4;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int ELD_PERFORMANCE = 5;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SHUTDOWN = 8889;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_REPAINT = 8890;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_BRINGTOFRONT = 8891;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SAVEDATA = 8892;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_RESTOREDATA = 8893;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_POPUP = 9182;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_HIDEPOPUP = 9183;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_LSSELECT = 9185;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SENDSYSTRAY = 9213;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SYSTRAYA = 9214;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SYSTRAYREADY = 9215;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SYSTRAYINFOEVENT = 9216;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_RECYCLE = 9260;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_REGISTERMESSAGE = 9263;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_UNREGISTERMESSAGE = 9264;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_GETREVIDA = 9265;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_UNLOADMODULEA = 9266;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_RELOADMODULEA = 9267;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SHADETOGGLE = 9300;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_REFRESH = 9305;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_VWMUP = 9350;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_VWMDOWN = 9351;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_VWMLEFT = 9352;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_VWMRIGHT = 9353;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_VWMNAV = 9354;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SWITCHTON = 9355;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_ISSTICKY = 9356;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_STICK = 9357;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_UNSTICK = 9358;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_LISTDESKTOPS = 9359;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_DESKTOPINFO = 9360;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_GETDESKTOPOF = 9361;
+
+ ///
+ /// Internal
+ ///
+ private const int LM_SHELLHOOK = 9500;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WINDOWCREATED = LM_SHELLHOOK + 1 /*HSHELL_WINDOWCREATED*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WINDOWDESTROYED = LM_SHELLHOOK + 2 /*HSHELL_WINDOWDESTROYED*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_ACTIVATESHELLWINDOW = LM_SHELLHOOK + 3 /*HSHELL_ACTIVATESHELLWINDOW*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WINDOWACTIVATED = LM_SHELLHOOK + 4 /*HSHELL_WINDOWACTIVATED*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_GETMINRECT = LM_SHELLHOOK + 5 /*HSHELL_GETMINRECT*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_REDRAW = LM_SHELLHOOK + 6 /*HSHELL_REDRAW*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASKMAN = LM_SHELLHOOK + 7 /*HSHELL_TASKMAN*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_LANGUAGE = LM_SHELLHOOK + 8 /*HSHELL_LANGUAGE*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_ACCESSIBILITYSTATE = LM_SHELLHOOK + 11 /*HSHELL_ACCESSIBILITYSTATE*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_APPCOMMAND = LM_SHELLHOOK + 12 /*HSHELL_APPCOMMAND*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WINDOWREPLACED = LM_SHELLHOOK + 13 /*HSHELL_WINDOWREPLACED*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WINDOWREPLACING = LM_SHELLHOOK + 14 /*HSHELL_WINDOWREPLACING*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_MONITORCHANGED = LM_SHELLHOOK + 16 /*HSHELL_MONITORCHANGED*/;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_FULLSCREENACTIVATED = 32768;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_FULLSCREENDEACTIVATED = 32769;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETPROGRESSSTATE = 33024;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETPROGRESSVALUE = 33025;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_MARKASACTIVE = 33026;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_REGISTERTAB = 33027;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_UNREGISTERTAB = 33028;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETACTIVETAB = 33029;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETTABORDER = 33030;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETTABPROPERTIES = 33031;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETOVERLAYICON = 33032;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETOVERLAYICONDESC = 33033;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETTHUMBNAILTOOLTIP = 33034;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_SETTHUMBNAILCLIP = 33035;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_THUMBBARADDBUTTONS = 33036;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_THUMBBARUPDATEBUTTONS = 33037;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_TASK_THUMBBARSETIMAGELIST = 33038;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_UNLOADMODULEW = 33281;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_RELOADMODULEW = 33282;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_GETREVIDW = 33283;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_BANGCOMMANDW = 33284;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_SYSTRAYW = 33285;
+
+ ///
+ /// FILL ME IN
+ ///
+ public const int LM_WALLPAPERCHANGE = 33286;
+
+ ///
+ /// Win32 representation of THUMBBUTTON value
+ ///
+ [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)]
+ public struct LSThumbButton
+ {
+ ///
+ /// THUMBBUTTONMASK
+ ///
+ public int Mask;
+ public int Id;
+ public int Bitmap;
+ public IntPtr hIcon;
+
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 259)]
+ public string Tip;
+
+ ///
+ /// THUMBBUTTONFLAGS
+ ///
+ public int Flags;
+ }
+
+ ///
+ /// Win32 representation of THUMBBUTTONLIST value
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct LSThumbButtonList
+ {
+ int Buttons;
+
+ [MarshalAs(UnmanagedType.LPStruct)]
+ LSThumbButton Button;
+ }
+
+ ///
+ /// Win32 representation of DWORD value
+ ///
+ [StructLayout(LayoutKind.Explicit, Size = 4)]
+ public struct LSColorRef
+ {
+ [FieldOffset(0)]
+ public byte R;
+
+ [FieldOffset(1)]
+ public byte G;
+
+ [FieldOffset(2)]
+ public byte B;
+
+ [FieldOffset(0)]
+ public int Value;
+
+ public LSColorRef(byte r, byte g, byte b)
+ {
+ this.Value = 0;
+ this.R = r;
+ this.G = g;
+ this.B = b;
+ }
+
+ public LSColorRef(int value)
+ {
+ this.R = 0;
+ this.G = 0;
+ this.B = 0;
+ this.Value = value & 0x00FFFFFF;
+ }
+ }
+
+ ///
+ /// Win32 representation of the HRESULT value
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct LSHResult
+ {
+ ///
+ ///Success code
+ ///
+ public const int S_OK = unchecked((int)0x00000000);
+
+ ///
+ ///Success code false
+ ///
+ public const int S_FALSE = unchecked((int)0x00000001);
+
+ ///
+ ///Catastrophic failure
+ ///
+ public const int E_UNEXPECTED = unchecked((int)0x8000FFFF);
+
+ ///
+ ///One or more arguments are invalid
+ ///
+ public const int E_INVALIDARG = unchecked((int)0x80070057);
+
+ ///
+ ///Invalid pointer
+ ///
+ public const int E_POINTER = unchecked((int)0x80004003);
+
+ ///
+ ///Unspecified error
+ ///
+ public const int E_FAIL = unchecked((int)0x80004005);
+
+ ///
+ /// No such interface supported
+ ///
+ public const int E_NOINTERFACE = unchecked((int)0x80004002);
+
+ ///
+ /// Class not registered
+ ///
+ public const int REGDB_E_CLASSNOTREG = unchecked((int)0x80040154);
+
+ ///
+ /// Class does not support aggregation (or class object is remote)
+ ///
+ public const int CLASS_E_NOAGGREGATION = unchecked((int)0x80040110);
+
+ public int Value;
+
+ public LSHResult(int value)
+ {
+ this.Value = value;
+ }
+
+ public static implicit operator int(LSHResult hr)
+ {
+ return hr.Value;
+ }
+
+ public static implicit operator LSHResult(int hr)
+ {
+ return new LSHResult(hr);
+ }
+ }
+
+ ///
+ /// Win32 representation of the RECT structure
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct LSRect
+ {
+ int Left, Top, Right, Bottom;
+
+ public LSRect(int left, int top, int right, int bottom)
+ {
+ Left = left;
+ Top = top;
+ Right = right;
+ Bottom = bottom;
+ }
+
+ public int X
+ {
+ get { return Left; }
+ set { Right -= (Left - value); Left = value; }
+ }
+
+ public int Y
+ {
+ get { return Top; }
+ set { Bottom -= (Top - value); Top = value; }
+ }
+
+ public int Height
+ {
+ get { return Bottom - Top; }
+ set { Bottom = value + Top; }
+ }
+
+ public int Width
+ {
+ get { return Right - Left; }
+ set { Right = value + Left; }
+ }
+ }
+
+ ///
+ /// Win32 representation of the POINT structure
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct LSPoint
+ {
+ int X;
+ int Y;
+
+ public LSPoint(int x, int y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+ }
+
+ ///
+ /// Win32 representation of the MONITORINFO structure
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct LSMonitorInfo
+ {
+ int Size;
+ LSRect Monitor;
+ LSRect Work;
+ int flags;
+
+ public static LSMonitorInfo Create()
+ {
+ return new LSMonitorInfo { Size = Marshal.SizeOf(typeof(LSMonitorInfo)) };
+ }
+ }
+
+ ///
+ /// Win32 representation of the DISPLAY_DEVICEW structure
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ public struct LSDisplayDevice
+ {
+ int cb;
+ string DeviceName;
+ string DeviceString;
+ int StateFlags;
+ string DeviceID;
+ string DeviceKey;
+
+ public static LSDisplayDevice Create()
+ {
+ return new LSDisplayDevice { cb = Marshal.SizeOf(typeof(LSDisplayDevice)) };
+ }
+ }
+
+ ///
+ /// Initializes the Litestep API which is the main entry point into library
+ ///
+ /// Litestep's working directory
+ /// Path to Litestep's configuration file
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool LSAPIInitialize(string litestepPath, string steprcPath);
+
+ ///
+ /// Refreshes the list of bang commands
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void LSAPIReloadBangs();
+
+ ///
+ /// Refreshes the settings
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void LSAPIReloadSettings();
+
+ ///
+ /// Opens a configuration file for sequential access to its contents.
+ ///
+ ///
+ /// The file contents can be read with {@link #LCReadNextConfig} or {@link #LCReadNextLineOrCommand}.
+ /// The file should be closed with a call to {@link #LCClose} when it is no longer needed.
+ ///
+ /// If the argument is NULL
, opens the global settings
+ /// for sequential access.
+ ///
+ /// Full path to the file to open
+ /// File handle on success or NULL
if the file could not be opened
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern SafeFileHandle LCOpen(string filePath);
+
+ ///
+ /// Closes a configuration file opened with {@link #LCOpen}.
+ ///
+ /// A valid file handle reference
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LCClose(SafeFileHandle hFile);
+
+ ///
+ /// Retrieves the next none config line (one that does not start with a '*' from a
+ /// configuration file. The entire line (including the setting name) is placed in the buffer.
+ ///
+ ///
+ /// Call this function repeatedly until it returns FALSE
to retrieve all non config lines in the file.
+ ///
+ /// File handle returned by LCOpen
+ /// Buffer to receive line
+ /// Size of buffer
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool LCReadNextCommand(SafeFileHandle hFile, StringBuilder buffer, int size);
+
+ ///
+ /// Retrieves the next config line (one that starts with a '*') that begins with the
+ /// specified setting name from a configuration file. The entire line (including the setting name)
+ /// is placed in the buffer.
+ ///
+ ///
+ /// Call this function repeatedly until it returns FALSE
to retrieve all the
+ /// lines that begin with the specified setting name.
+ ///
+ /// File handle returned by LCOpen
+ /// Setting name
+ /// Buffer to receive line
+ /// Size of buffer
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool LCReadNextConfig(SafeFileHandle hFile, string config, StringBuilder buffer, int size);
+
+ ///
+ /// Retrieves the next line from a configuration file. The entire line (including the setting name) is placed in the buffer.
+ ///
+ ///
+ /// Call this function repeatedly until it returns FALSE
to retrieve all non config lines in the file.
+ ///
+ /// File handle returned by LCOpen
+ /// Buffer to receive line
+ /// Size of buffer
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool LCReadNextLine(SafeFileHandle hFile, StringBuilder buffer, int size);
+
+ ///
+ /// Parses and retrieves the values in a config line (one that starts with a '*') that begins with the
+ /// specified setting name from a configuration file.
+ ///
+ ///
+ /// Call this function repeatedly until it returns 0
to retrieve all config lines for the specified config name.
+ ///
+ /// Setting name
+ /// An array of buffers to receive the values
+ /// The number of tokens expected to retrieve
+ /// The remaining part of the config line that was not collected in the buffer
+ /// Returns the number of tokens found in the configuration line
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern int LCTokenize(string config, IntPtr tokens, int tokenLen, StringBuilder extraParams);
+
+ ///
+ /// Parses and retrieves the values in a config line (one that starts with a '*') that begins with the
+ /// specified setting name from a configuration file.
+ ///
+ ///
+ /// Parses lines that contain commands within brackes i.e [!command]
+ ///
+ /// Command name
+ /// An array of buffers to receive the values
+ /// The number of tokens expected to retrieve
+ /// The remaining part of the config line that was not collected in the buffer
+ /// Returns the number of tokens found in the configuration line
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern int CommandTokenize(string config, IntPtr tokens, int tokenLen, StringBuilder extraParams);
+
+ ///
+ /// Parses and retrieves the commands in a config line
+ ///
+ /// A line in a configuration file
+ /// The buffer to receive the parsed command
+ /// The buffer to receive the arguments
+ /// The size of the buffer
+ /// The size of the buffer
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern void CommandParse(string line, StringBuilder command, StringBuilder args, int commandLen, int argsLen);
+
+ ///
+ /// Cycles through a list of tokens parsing and retreiving values in a config line (one that starts with a '*')
+ /// that begins with the specified setting name from a configuration file.
+ ///
+ /// A line in a configuration file
+ /// The buffer to receive the next token
+ /// The next token in the line
+ /// parse tokens between brackes '[]'
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool GetToken(string line, StringBuilder token, IntPtr nextToken, bool useBrackets);
+
+ ///
+ /// Retrieves an integer value from the global settings. Returns
+ /// if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern int GetRCInt(string settingName, int defaultVal);
+
+ ///
+ /// Retrieves an integer value from the global settings. Returns
+ /// if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern long GetRCInt64(string settingName, long defaultVal);
+
+ ///
+ /// Retrieves an integer value from the global settings. Returns
+ /// if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern float GetRCFloat(string settingName, float defaultVal);
+
+ ///
+ /// Retrieves an integer value from the global settings. Returns
+ /// if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern double GetRCDouble(string settingName, double defaultVal);
+
+ ///
+ /// Retrieves an boolean value from the global settings. Returns
+ /// if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool GetRCBoolDef(string settingName, bool defaultVal);
+
+ ///
+ /// Retrieves a Boolean value from the global settings. Returns
+ /// if the setting exists and ! if it does not.
+ ///
+ /// Setting name
+ /// Value to return if setting is found
+ /// The setting value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool GetRCBool(string settingName, bool ifFound);
+
+ ///
+ /// Retrieves a string value from the global settings. Returns FALSE
if
+ /// the setting does not exist copies into the buffer and returns
+ /// FALSE
. may be null
in which case
+ /// nothing is copied into the buffer.
+ ///
+ ///
+ /// The raw setting value is parsed and the first space-delimited token or quoted string is the value returned.
+ ///
+ /// Setting name
+ /// Buffer to receive value
+ /// Default value
+ /// Size of buffer
+ /// Returns true if it exists otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool GetRCString(string settingName, StringBuilder buffer, string defaultVal, int size);
+
+ ///
+ /// Retrieves a raw string value from the global settings. If setting does not exist, copies
+ /// into the buffer and returns FALSE
. may be null
in which case
+ /// nothing is copied into the buffer.
+ ///
+ ///
+ /// GetRCLine
does not parse the string value like GetRCString
does. Its purpose is for retreiving command
+ /// lines for applications and bang commands.
+ ///
+ /// Setting name
+ /// Buffer to receive value
+ /// Size of buffer
+ /// Default value
+ /// TRUE
if setting exists or FALSE
otherwise
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool GetRCLine(string settingName, StringBuilder buffer, int size, string defaultVal);
+
+ ///
+ /// Retrieves a color value from the global settings. Returns if the setting does not exist.
+ ///
+ /// Setting name
+ /// Default value
+ /// The setting value or default value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern LSColorRef GetRCColor(string settingsName, LSColorRef defaultVal);
+
+ ///
+ /// FILL ME IN
+ ///
+ /// Setting name
+ /// Default value
+ /// Max value
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int GetRCCoordinate(string settingName, int defaultVal, int maxVal);
+
+ ///
+ /// Parses the coordinate from the line
+ ///
+ ///
+ /// Default value
+ /// Max value
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int ParseCoordinate(string line, int defaultVal, int maxVal);
+
+ ///
+ /// Retrieves a string value from the global settings. Returns FALSE
if the setting
+ /// does not exist. Performs the same operation as {@link #GetRCString}.
+ ///
+ /// The setting name
+ /// Buffer to receive value
+ /// TRUE
if setting exists or FALSE
otherwise
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool LSGetVariable(string settingName, StringBuilder settingVal);
+
+ ///
+ /// Retrieves a string value from the global settings. Returns FALSE
if the setting
+ /// does not exist. Performs the same operation as {@link #GetRCString}.
+ ///
+ /// The setting name
+ /// Buffer to receive value
+ /// The size of buffer
+ /// TRUE
if setting exists or FALSE
otherwise
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LSGetVariableExW")]
+ public static extern bool LSGetVariable(string settingName, StringBuilder settingVal, long size);
+
+ ///
+ /// Assigns a new value to a global setting. If the setting already exists its previous value
+ /// is overwritten, otherwise a new setting is created.
+ ///
+ /// The setting name
+ /// New setting value
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern void LSSetVariable(string settingName, string settingVal);
+
+ ///
+ /// Expands variable references. The template string is copied into the buffer with
+ /// all variable references ($var$
) replaced by the value of the variable.
+ ///
+ /// buffer to received the expanded string
+ /// string to be expanded
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern void VarExpansion(StringBuilder buffer, string template);
+
+ ///
+ /// Expands variable references. The template string is copied into the buffer with
+ /// all variable references ($var$
) replaced by the value of the variable.
+ ///
+ /// buffer to received the expanded string
+ /// string to be expanded
+ /// The size of buffer
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "VarExpansionExW")]
+ public static extern void VarExpansion(StringBuilder buffer, string template, int size);
+
+ ///
+ /// Match the pattern against a text value
+ ///
+ ///
+ /// A match means the entire string is used up in matching.
+ ///
+ /// A pattern expression
+ /// The string value to evaluate
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "matchW")]
+ public static extern bool Match(string pattern, string text);
+
+ ///
+ /// Match the pattern against a text value
+ ///
+ /// A pattern expression
+ /// The string value to evaluate
+ ///
+ /// returns MATCH_VALID if pattern matches, or an errorcode as follows
+ /// otherwise:
+ ///
+ /// MATCH_PATTERN - bad pattern
+ /// MATCH_LITERAL - match failure on literal mismatch
+ /// MATCH_RANGE - match failure on[..] construct
+ /// MATCH_ABORT - premature end of text string
+ /// MATCH_END - premature end of pattern string
+ /// MATCH_VALID - valid match
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "matcheW")]
+ public static extern int MatchE(string pattern, string text);
+
+ ///
+ /// Determines if a pattern is a well formed regular expression according to the folowing syntax:
+ ///
+ /// In the pattern string:
+ /// `*' matches any sequence of characters (zero or more)
+ /// `?' matches any character
+ /// [SET] matches any character in the specified set,
+ /// [!SET] or[^ SET] matches any character not in the specified set.
+ ///
+ /// A set is composed of characters or ranges; a range looks like
+ /// character hyphen character(as in 0-9 or A-Z). [0-9a-zA-Z_] is the
+ /// minimal set of characters allowed in the[..] pattern construct.
+ /// Other characters are allowed(ie. 8 bit characters) if your _tsystem
+ /// will support them.
+ ///
+ /// To suppress the special syntactic significance of any of `[]*?!^-\',
+ /// and match the character exactly, precede it with a `\'.
+ ///
+ ///
+ /// Zero is returned in error_type if the pattern is a valid one.
+ /// error_type return values are as follows:
+ ///
+ /// PATTERN_VALID - pattern is well formed
+ /// PATTERN_ESC - pattern has invalid escape('\' at end of pattern)
+ /// PATTERN_RANGE - [..] construct has a no end range in a '-' pair (ie[a -])
+ /// PATTERN_CLOSE - [..] construct has no end bracket(ie[abc - g )
+ /// PATTERN_EMPTY - [..] construct is empty(ie[])
+ ///
+ /// A regular expression
+ /// Is a return code based on the type of pattern error
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "is_valid_patternW")]
+ public static extern bool IsPatternValid(string pattern, ref int errorCode);
+
+ ///
+ /// Bang command callback
+ ///
+ ///
+ /// typedef void (__cdecl *BangCommandW)(HWND hSender, LPCWSTR pszArgs);
+ ///
+ /// The window handle sent the command
+ /// The arguments associated with the command
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public delegate void BangCommandDelegate(IntPtr hWndSender, string args);
+
+ ///
+ /// Bang command callback
+ ///
+ ///
+ /// typedef void (__cdecl *BangCommandExW)(HWND hSender, LPCWSTR pszCommand, LPCWSTR pszArgs);
+ ///
+ /// The window handle sent the command
+ ///
+ /// The arguments associated with the command
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public delegate void BangCommandDelegate2(IntPtr hWndSender, string command, string args);
+
+ ///
+ /// Registers bang commands
+ ///
+ /// the command identifier that starts with an exclamation point (!)
+ /// the callback method associated with the command
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool AddBangCommand(string command, [MarshalAs(UnmanagedType.FunctionPtr)] BangCommandDelegate commandDelegate);
+
+ ///
+ /// Registers bang commands
+ ///
+ /// the command identifier that starts with an exclamation point (!)
+ /// the callback method associated with the command
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "AddBangCommandExW")]
+ public static extern bool AddBangCommand(string command, [MarshalAs(UnmanagedType.FunctionPtr)] BangCommandDelegate2 commandDelegate);
+
+ ///
+ /// Removes a bang command from the list.
+ ///
+ /// bang command name
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern bool RemoveBangCommand(string command);
+
+ ///
+ /// Executes a bang command !command
+ ///
+ /// The window handle sent the command
+ /// The identifier representing the command
+ /// The arguments associated with the command
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "ParseBangCommandW")]
+ public static extern bool ExecuteBangCommand(IntPtr hwndCaller, string command, string args);
+
+ ///
+ /// Self explanatory :-)
+ ///
+ /// The level to log to
+ /// The name of the module logging from
+ /// The content to write to file
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Winapi)]
+ public static extern bool LSLog(int level, string module, string message);
+
+ ///
+ /// Self explanatory :-)
+ ///
+ /// The level to log to
+ /// The name of the module logging from
+ /// The formatting instructions
+ /// The values toreplace the tokens in the formatting instruction
+ /// Returns true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, EntryPoint = "LSLogPrintf")]
+ public static extern bool LSLog(int level, string module, string format, params object[] args);
+
+ ///
+ /// Loads a string resource from the executable file associated with a specified module,
+ /// copies the string into a buffer, and appends a terminating null character.
+ ///
+ /// A handle to an instance of the module whose executable file contains the string resource.
+ /// The identifier of the string to be loaded.
+ /// The buffer is to receive the string. Must be of sufficient length to hold a pointer (8 bytes).
+ ///
+ /// The size of the buffer, in characters. The string is truncated and null-terminated if it is longer
+ /// than the number of characters specified. If this parameter is 0, then lpBuffer receives a read-only pointer to the resource itself.
+ ///
+ /// The default string to return if the resource was not located
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "GetResStrW")]
+ public static extern void GetResString(IntPtr hInstance, int resId, StringBuilder resText, int size, string defaultText);
+
+ ///
+ /// Loads a string resource from the executable file associated with a specified module,
+ /// copies the string into a buffer, and appends a terminating null character.
+ ///
+ /// A handle to an instance of the module whose executable file contains the string resource.
+ /// The identifier of the string to be loaded.
+ /// The buffer is to receive the string. Must be of sufficient length to hold a pointer (8 bytes).
+ ///
+ /// The size of the buffer, in characters. The string is truncated and null-terminated if it is longer
+ /// than the number of characters specified. If this parameter is 0, then lpBuffer receives a read-only pointer to the resource itself.
+ ///
+ /// The default string to return if the resource was not located
+ /// Formatting arguements
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "GetResStrExW")]
+ public static extern void GetResString(IntPtr hInstance, int resId, StringBuilder resText, int size, string defaultText, params object[] args);
+
+ ///
+ /// Bang enumeration callback
+ ///
+ ///
+ /// typedef BOOL (CALLBACK* LSENUMBANGSPROCW)(LPCWSTR, LPARAM);
+ ///
+ ///
+ ///
+ /// Returns true on success otherwise false
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public delegate bool EnumBangDelegate(string command, IntPtr lparam);
+
+ ///
+ /// Bang enumeration callback
+ ///
+ /// typedef BOOL (CALLBACK* LSENUMBANGSV2PROCW)(HINSTANCE, LPCWSTR, LPARAM);
+ ///
+ ///
+ ///
+ /// Returns true on success otherwise false
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public delegate bool EnumBangV2Delegate(IntPtr hInstance, string command, IntPtr lparam);
+
+ ///
+ /// Rev ID enumeration callback
+ ///
+ /// typedef BOOL (CALLBACK* LSENUMREVIDSPROCW)(LPCWSTR, LPARAM);
+ ///
+ ///
+ /// Returns true on success otherwise false
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public delegate bool EnumRevIdsDelegate(string revId, IntPtr lparam);
+
+ ///
+ /// Module enumeration callback
+ ///
+ /// typedef BOOL (CALLBACK* LSENUMMODULESPROCW)(LPCWSTR, DWORD, LPARAM)
+ ///
+ ///
+ ///
+ /// Returns true on success otherwise false
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public delegate bool EnumModuleDelegate(string module, long flags, IntPtr lparam);
+
+ ///
+ /// Module performance enumeration callback
+ ///
+ /// typedef BOOL (CALLBACK* LSENUMPERFORMANCEPROCW)(LPCWSTR, DWORD, LPARAM)
+ ///
+ ///
+ ///
+ /// Returns true on success otherwise false
+ [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public delegate bool EnumPerformanceDelegate(string module, long flags, IntPtr lparam);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ /// Enumerates over the following information:
+ /// - Bang commands
+ /// - Revision IDs
+ /// - Loaded Modules
+ /// - Performance information about the module
+ ///
+ /// The type of information to enumerate
+ /// The delegate to call during enumeration
+ /// Extra information
+ ///
+ /// Return values:
+ /// E_INVALIDARG - Invalid value for uInfo
+ /// E_POINTER - Invalid callback
+ /// E_FAIL - Unspecified error
+ /// E_UNEXPECTED - Callback crashed or other catastrophic failure
+ /// S_OK - Enumeration successful, callback always returned TRUE
+ /// S_FALSE - Enumeration successful, but cancelled by callback
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern LSHResult EnumLSData(int eldInfo, [MarshalAs(UnmanagedType.FunctionPtr)] Delegate callback, IntPtr lparam);
+
+ ///
+ /// Performs an operation on a specified file.
+ ///
+ /// A handle to the parent window used for displaying a UI or error messages.
+ /// A pointer to a null-terminated string that specifies the !bang command on which to execute the
+ ///
+ /// The flags that specify how an application is to be displayed when it is opened. If lpFile specifies a
+ /// document file, the flag is simply passed to the associated application. It is up to the application to
+ /// decide how to handle it.
+ ///
+ ///
+ /// If the function succeeds, it returns a value greater than 32. If the function fails,
+ /// it returns an error value that indicates the cause of the failure.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern IntPtr LSExecute(IntPtr hOwnerWnd, string command, int showCommand);
+
+ ///
+ /// Performs an operation on a specified file.
+ ///
+ /// A handle to the parent window used for displaying a UI or error messages.
+ ///
+ /// A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to
+ /// be performed. The set of available verbs depends on the particular file or folder. Generally, the actions
+ /// available from an object's shortcut menu are available verbs.
+ ///
+ ///
+ /// A pointer to a null-terminated string that specifies the file or !bang command on which to execute the
+ /// specified verb.
+ ///
+ ///
+ /// If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to
+ /// the application. The format of this string is determined by the verb that is to be invoked.
+ ///
+ /// A pointer to a null-terminated string that specifies the default (working) directory for the action.
+ ///
+ /// The flags that specify how an application is to be displayed when it is opened. If lpFile specifies a
+ /// document file, the flag is simply passed to the associated application. It is up to the application to
+ /// decide how to handle it.
+ ///
+ ///
+ /// If the function succeeds, it returns a value greater than 32. If the function fails,
+ /// it returns an error value that indicates the cause of the failure.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "LSExecuteExW")]
+ public static extern IntPtr LSExecute(IntPtr hOwnerWnd, string operation, string command, string args, string directory, int nShowCmd);
+
+ ///
+ /// Sets the main litestep window
+ ///
+ /// The handle to the window
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void LSAPISetLitestepWindow(IntPtr hWnd);
+
+ ///
+ /// Gets the litestep main window
+ ///
+ /// Returns a handle to the litestep main window on success
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "GetLitestepWnd")]
+ public static extern IntPtr GetLitestepWindow();
+
+ ///
+ /// Gets the path to the litestep directory
+ ///
+ ///
+ ///
+ /// Returns to true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, EntryPoint = "LSGetLitestepPathW")]
+ public static extern bool LSGetLitestepPath(StringBuilder path, int size);
+
+ ///
+ /// Gets the path to the image directory
+ ///
+ ///
+ ///
+ /// Returns to true on success otherwise false
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, EntryPoint = "LSGetImagePathW")]
+ public static extern bool LSGetImagePath(StringBuilder path, int size);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void Frame3D(IntPtr hDC, LSRect rect, LSColorRef topColor, LSColorRef bottomColor, int width);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr BitmapToRegion(IntPtr hBmp, LSColorRef transparent, LSColorRef tolerance, int xoffset, int yoffset);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr BitmapFromIcon(IntPtr hIcon);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern IntPtr LoadLSImage(string file, string image);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
+ public static extern IntPtr LoadLSIcon(string image, string file);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void GetLSBitmapSize(
+ IntPtr hBitmap,
+ [MarshalAs(UnmanagedType.LPStruct)] out int width,
+ [MarshalAs(UnmanagedType.LPStruct)] out int height);
+
+ ///
+ /// FILL ME IN
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void TransparentBltLS(IntPtr hDC, int xDest, int yDest, int width, int height, IntPtr tempDC, int xSrc, int ySrc, LSColorRef transparent);
+
+ ///
+ /// Sets the size of the work area.
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void SetDesktopArea(int left, int top, int right, int bottom);
+
+ ///
+ /// Retrieves the specified system metric or system configuration setting.
+ ///
+ /// See
+ /// for details on values
+ /// The system metric or configuration setting to be retrieved
+ ///
+ /// If the function succeeds, the return value is the requested system metric or configuration setting.
+ /// If the function fails, the return value is 0. GetLastError does not provide extended error information.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern int LSGetSystemMetrics(int index);
+
+ ///
+ /// The MonitorFromWindow function retrieves a handle to the display monitor that has
+ /// the largest area of intersection with the bounding rectangle of a specified window.
+ ///
+ /// A handle to the window of interest.
+ /// Determines the function's return value if the window does not intersect any display monitor.
+ ///
+ /// If the window intersects one or more display monitor rectangles, the return value is an HMONITOR handle to the display monitor
+ /// that has the largest area of intersection with the window.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr LSMonitorFromWindow(IntPtr hWnd, int flags);
+
+ ///
+ /// The MonitorFromRect function retrieves a handle to the display monitor that has the
+ /// largest area of intersection with a specified rectangle.
+ ///
+ /// A pointer to a RECT structure that specifies the rectangle of interest in virtual-screen coordinates.
+ /// Determines the function's return value if the rectangle does not intersect any display monitor.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr LSMonitorFromRect([In, MarshalAs(UnmanagedType.LPStruct)] LSRect coordinates, int flags);
+
+ ///
+ /// The MonitorFromPoint function retrieves a handle to the display monitor that contains a specified point.
+ ///
+ /// A POINT structure that specifies the point of interest in virtual-screen coordinates.
+ /// Determines the function's return value if the point is not contained within any display monitor.
+ ///
+ /// If the point is contained by a display monitor, the return value is an HMONITOR handle to that display monitor.
+ /// If the point is not contained by a display monitor, the return value depends on the value of .
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr LSMonitorFromPoint(LSPoint coordinates, int flags);
+
+ ///
+ /// Retrieves information about a display monitor.
+ ///
+ /// A handle to the display monitor of interest.
+ /// A pointer to a MONITORINFO or MONITORINFOEX structure that receives information
+ /// about the specified display monitor.
+ ///
+ /// If the function succeeds, the return value is nonzero.
+ /// If the function fails, the return value is zero.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LSGetMonitorInfo(IntPtr hMonitor, [In, Out, MarshalAs(UnmanagedType.LPStruct)] LSMonitorInfo info);
+
+ ///
+ /// A MonitorEnumProc function is an application-defined callback function that
+ /// is called by the EnumDisplayMonitors function.
+ ///
+ /// typedef BOOL (CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM)
+ /// A handle to the display monitor.
+ /// A handle to a device context.
+ /// A pointer to a RECT structure.
+ /// Application-defined data that EnumDisplayMonitors passes directly to the enumeration function.
+ /// To continue the enumeration, return TRUE otherise FALSE.
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ public delegate bool EnumMonitorDelegate(IntPtr hMonitor, IntPtr hDC, LSRect area, IntPtr lparam);
+
+ ///
+ /// Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers) that
+ /// intersect a region formed by the intersection of a specified clipping rectangle and the visible region of a device context.
+ ///
+ /// A handle to a display device context that defines the visible region of interest.
+ /// A pointer to a RECT structure that specifies a clipping rectangle. The region of interest is the intersection
+ /// of the clipping rectangle with the visible region specified by hdc.
+ /// A pointer to a MonitorEnumProc application-defined callback function.
+ /// Application-defined data that EnumDisplayMonitors passes directly to the MonitorEnumProc function.
+ /// If the function succeeds, the return value is nonzero otherwise zero
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LSEnumDisplayMonitors(
+ IntPtr hDC,
+ [In, MarshalAs(UnmanagedType.LPStruct)] LSRect clip,
+ [MarshalAs(UnmanagedType.FunctionPtr)] EnumMonitorDelegate callback,
+ IntPtr lparam);
+
+ ///
+ /// Obtains information about the display devices in the current session.
+ ///
+ /// A pointer to the device name.
+ /// An index value that specifies the display device of interest.
+ /// A pointer to a structure that
+ /// receives information about the display device specified by .
+ /// Set this flag to EDD_GET_DEVICE_INTERFACE_NAME (0x00000001) to retrieve
+ /// the device interface name for GUID_DEVINTERFACE_MONITOR, which is registered by the operating
+ /// system on a per monitor basis.
+ ///
+ /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
+ /// The function fails if is greater than the largest device index.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern bool LSEnumDisplayDevices(
+ string device,
+ int index,
+ [In, MarshalAs(UnmanagedType.LPStruct)] LSDisplayDevice displayInfo,
+ int flags);
+
+ ///
+ /// Creates a single uninitialized object of the class associated with a specified CLSID.
+ ///
+ /// The CLSID associated with the data and code that will be used to create the object.
+ ///
+ /// If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL,
+ /// pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
+ ///
+ /// Context in which the code that manages the newly created object will run.
+ /// A reference to the identifier of the interface to be used to communicate with the object.
+ ///
+ /// Address of pointer variable that receives the interface pointer requested in riid.
+ /// Upon successful return, *ppv contains the requested interface pointer.
+ ///
+ ///
+ /// This function can return the following values
+ /// E_NOINTERFACE - The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface
+ /// E_POINTER - The ppv parameter is NULL.
+ /// CLASS_E_NOAGGREGATION - This class cannot be created as part of an aggregate.
+ /// REGDB_E_CLASSNOTREG - A specified class is not registered in the registration database.
+ /// S_OK - An instance of the specified object class was successfully created.
+ ///
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern LSHResult LSCoCreateInstance(
+ [In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid,
+ IntPtr pUnkOuter,
+ int dwClsContext,
+ [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid,
+ [MarshalAs(UnmanagedType.IUnknown)] out object ppv);
+
+
+ ///
+ /// Sets the COM interface factory for this API
+ ///
+ /// Factory object
+ [DllImport(LSAPI, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void LSAPISetCOMFactory([In, MarshalAs(UnmanagedType.IUnknown)] object factory);
+ }
+}
diff --git a/LsapiSharp/Properties/AssemblyInfo.cs b/LsapiSharp/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..e13f53d
--- /dev/null
+++ b/LsapiSharp/Properties/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("LsapiSharp")]
+[assembly: AssemblyDescription(".NET Framework Interop for Litestep")]
+[assembly: AssemblyProduct("LsapiSharp")]
+[assembly: AssemblyCopyright("Copyright © 2016 LiteStep Development Team")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/LsapiSharpCore/AssemblyInfo.cs b/LsapiSharpCore/AssemblyInfo.cs
new file mode 100644
index 0000000..1da5919
--- /dev/null
+++ b/LsapiSharpCore/AssemblyInfo.cs
@@ -0,0 +1,6 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyDescription(".NET Core Interop for Litestep")]
+[assembly: AssemblyCopyright("Copyright © 2016 LiteStep Development Team")]
+[assembly: ComVisible(false)]
diff --git a/LsapiSharpCore/LsapiSharp.snk b/LsapiSharpCore/LsapiSharp.snk
new file mode 100644
index 0000000..ae52fd4
Binary files /dev/null and b/LsapiSharpCore/LsapiSharp.snk differ
diff --git a/LsapiSharpCore/LsapiSharpCore.csproj b/LsapiSharpCore/LsapiSharpCore.csproj
new file mode 100644
index 0000000..ef23da7
--- /dev/null
+++ b/LsapiSharpCore/LsapiSharpCore.csproj
@@ -0,0 +1,30 @@
+
+
+
+ netstandard2.0
+ LsapiSharp
+ 1.0.0.0
+ Donelle Sanders Jr
+ Lsapi , LsapiSharp-Core, Litestep
+ https://raw.githubusercontent.com/lsdev/LiteStep/master/litestep/litestep.bmp
+ "https://github.com/Donelle/LiteStep.git
+ git
+ http://www.lsdev.org
+ ttps://github.com/Donelle/LiteStep/blob/master/docs/0.24.7/license.txt
+ Version 1.0.0.0
+ LsapiSharp Core
+
+ true
+ LsapiSharp.snk
+ AnyCPU;x86;x64
+
+
+
+ bin\Debug\
+ AnyCPU
+
+
+
+
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1a74683
--- /dev/null
+++ b/README.md
@@ -0,0 +1,101 @@
+# LiteStep
+LiteStep Alternative Shell is a replacement shell for the standard Windows® Explorer shell originally created by Francis Gastellu.
+
+This fork focuses on the interoperability of Litestep and the [.NET Framework](https://www.microsoft.com/net/framework).
+
+## Installation
+
+Please refer to the official [installation guide](http://litestep.info/overview/litestep-manual.html) for information on how to setup and configure Litestep
+
+## Documentation
+
+#### Step.rc
+
+As mentioned above this version of Litestep is focused on the .NET Framework and the following are descriptions of the configurations that should be present in the `step.rc` in order to use .NET.
+
+ ; Set the version of the .NET Runtime that Litestep will use to load modules. This version represents
+ ; the actual folder name on the file system located in %WINDIR%\Microsoft.NET\Framework64
+ ; If the setting is omitted the default runtime is v2.0.50727
+ LSCLRVersion v4.0.30319
+
+ ; Loading modules are the same as described in the Litestep manual
+ ; To load a module built using the .NET Framework append the "clr" token after the module path
+ LoadModule $LiteStepDir$HelloCLR.dll clr
+
+ ; OR to set the version of the .NET Core Runtime. This version represents
+ ; the actual folder name on the file system located in %PROGRAMFILES%\dotnet\shared\Microsoft.NETCore.App
+ LSCoreCLRVersion 2.0.0
+
+ ; Loading modules are the same as described in the Litestep manual
+ ; To load a module built using the .NET Core append the "coreclr" token after the module path
+ LoadModule $LiteStepDir$HelloCoreCLR.dll coreclr
+
+#### .NET Module
+
+Now that you know how to configure Litestep to load the .NET Runtime the following demonstrates how to create a module with the .NET Framework. The Litestep SDK comes with a library called Lsapi# _(pronounced LSAPI-sharp)_ which is a C# binding for Litestep's API that will enable modules to interact with the shell.
+
+Following is a list of requirements in order for your module to be loaded by the shell
+
+1. Add the LsapiSharp assembly as a reference to your project
+2. Name the assembly and the entry point namespace the same (ie. MyModule.dll and namespace MyModule {})
+3. The entry point class name must be called **LSModule** with two methods called **initModule** and **quitModule** respectively
+
+#### Example HelloCLR.dll
+
+```c#
+using System;
+using System.Runtime.InteropServices;
+using static LsapiSharp.NativeMethods;
+
+namespace HelloCLR
+{
+ public static class LSModule
+ {
+ const string BANG_COMMAND = "!HelloClr";
+
+ // Implements the !Hello bang command
+ static BangCommandDelegate BangHello = (sender, cmd) =>
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "BangHello called");
+ MessageBox(IntPtr.Zero, "Hello, Litestep!", typeof(LSModule).FullName, 0);
+ };
+
+ ///
+ /// Litestep calls this function after it loads the module. This is where the
+ /// module should register bang commands and create windows. If initialization
+ /// succeeds, return zero. If an error occurs, return a nonzero value.
+ ///
+ ///
+ ///
+ public static void initModule(Int32 hWndMain, String appPath)
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "initModule called");
+ AddBangCommand(BANG_COMMAND, BangHello);
+ }
+
+ ///
+ /// Litestep calls this function before it unloads the module. This function
+ /// should unregister bang commands and destroy windows.
+ ///
+ public static void quitModule()
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "quitModule called");
+ RemoveBangCommand(BANG_COMMAND);
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
+ }
+}
+```
+
+## LICENSE
+
+LiteStep is released under the GNU General Public License Version 2. [link](docs/license.txt)
+
+## Questions?
+
+If you have any questions or comments please feel free to drop me a line :-).
+
+Email:
+Follow Me: [@DonelleJr](https://twitter.com/DonelleJr)
diff --git a/litestep.sln b/litestep.sln
index f9c5fa9..44bbf2b 100644
--- a/litestep.sln
+++ b/litestep.sln
@@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 14.00
-# Visual Studio 2015
-VisualStudioVersion = 14.0.22310.1
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 14.0.22310.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "litestep", "litestep\litestep.vcxproj", "{994556EE-2F21-4811-A85D-6925F7F84B0D}"
EndProject
@@ -110,43 +110,136 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{DEC29FCD-9
sdk\docs\lsapi\VarExpansionEx.xml = sdk\docs\lsapi\VarExpansionEx.xml
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LsapiSharp", "LsapiSharp\LsapiSharp.csproj", "{7F8140DC-7815-4368-94F8-A7ED7CF04A2A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA} = {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LsapiSharp.Test", "LsapiSharp.Test\LsapiSharp.Test.csproj", "{580B3CBE-9E12-41A2-B723-6CE9BBCB7527}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA} = {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CLR", "CLR", "{757E055D-EC8C-4038-B2F3-E6C978057563}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LsapiSharpCore", "LsapiSharpCore\LsapiSharpCore.csproj", "{038BF1B5-7B36-4A20-8F10-E8F427A0C561}"
+ ProjectSection(ProjectDependencies) = postProject
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA} = {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
Release|Win32 = Release|Win32
Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|Any CPU.ActiveCfg = Debug|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|Win32.ActiveCfg = Debug|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|Win32.Build.0 = Debug|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|x64.ActiveCfg = Debug|x64
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|x64.Build.0 = Debug|x64
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|x86.ActiveCfg = Debug|Win32
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Debug|x86.Build.0 = Debug|Win32
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|Any CPU.ActiveCfg = Release|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|Win32.ActiveCfg = Release|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|Win32.Build.0 = Release|Win32
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|x64.ActiveCfg = Release|x64
{994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|x64.Build.0 = Release|x64
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|x86.ActiveCfg = Release|Win32
+ {994556EE-2F21-4811-A85D-6925F7F84B0D}.Release|x86.Build.0 = Release|Win32
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|Any CPU.ActiveCfg = Debug|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|Win32.ActiveCfg = Debug|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|Win32.Build.0 = Debug|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|x64.ActiveCfg = Debug|x64
{2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|x64.Build.0 = Debug|x64
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|x86.ActiveCfg = Debug|Win32
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Debug|x86.Build.0 = Debug|Win32
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Release|Any CPU.ActiveCfg = Release|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Release|Win32.ActiveCfg = Release|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Release|Win32.Build.0 = Release|Win32
{2213036F-018C-416A-8A6A-7934C936CFFC}.Release|x64.ActiveCfg = Release|x64
{2213036F-018C-416A-8A6A-7934C936CFFC}.Release|x64.Build.0 = Release|x64
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Release|x86.ActiveCfg = Release|Win32
+ {2213036F-018C-416A-8A6A-7934C936CFFC}.Release|x86.Build.0 = Release|Win32
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|Any CPU.ActiveCfg = Debug|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|Win32.ActiveCfg = Debug|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|Win32.Build.0 = Debug|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|x64.ActiveCfg = Debug|x64
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|x64.Build.0 = Debug|x64
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|x86.ActiveCfg = Debug|Win32
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Debug|x86.Build.0 = Debug|Win32
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|Any CPU.ActiveCfg = Release|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|Win32.ActiveCfg = Release|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|Win32.Build.0 = Release|Win32
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|x64.ActiveCfg = Release|x64
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|x64.Build.0 = Release|x64
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|x86.ActiveCfg = Release|Win32
+ {2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}.Release|x86.Build.0 = Release|Win32
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|Win32.ActiveCfg = Debug|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|Win32.Build.0 = Debug|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|x64.ActiveCfg = Debug|x64
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|x64.Build.0 = Debug|x64
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|x86.ActiveCfg = Debug|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Debug|x86.Build.0 = Debug|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|Win32.ActiveCfg = Release|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|Win32.Build.0 = Release|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|x64.ActiveCfg = Release|x64
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|x64.Build.0 = Release|x64
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|x86.ActiveCfg = Release|x86
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A}.Release|x86.Build.0 = Release|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|Win32.ActiveCfg = Debug|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|Win32.Build.0 = Debug|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|x64.ActiveCfg = Debug|x64
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|x64.Build.0 = Debug|x64
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|x86.ActiveCfg = Debug|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Debug|x86.Build.0 = Debug|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|Any CPU.Build.0 = Release|Any CPU
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|Win32.ActiveCfg = Release|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|Win32.Build.0 = Release|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|x64.ActiveCfg = Release|x64
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|x64.Build.0 = Release|x64
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|x86.ActiveCfg = Release|x86
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527}.Release|x86.Build.0 = Release|x86
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|Win32.Build.0 = Debug|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|x64.ActiveCfg = Debug|x64
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|x64.Build.0 = Debug|x64
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|x86.ActiveCfg = Debug|x86
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Debug|x86.Build.0 = Debug|x86
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|Any CPU.Build.0 = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|Win32.ActiveCfg = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|Win32.Build.0 = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|x64.ActiveCfg = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|x64.Build.0 = Release|Any CPU
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|x86.ActiveCfg = Release|x86
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{DEC29FCD-986F-4AAB-A697-AE091EFEF71A} = {0CB7B995-8934-4494-8EB9-968D5407C6E5}
+ {7F8140DC-7815-4368-94F8-A7ED7CF04A2A} = {757E055D-EC8C-4038-B2F3-E6C978057563}
+ {580B3CBE-9E12-41A2-B723-6CE9BBCB7527} = {757E055D-EC8C-4038-B2F3-E6C978057563}
+ {038BF1B5-7B36-4A20-8F10-E8F427A0C561} = {757E055D-EC8C-4038-B2F3-E6C978057563}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {443E0FE0-A28C-4AD6-A341-1B587E63BA20}
EndGlobalSection
EndGlobal
diff --git a/litestep/CLRModule.cpp b/litestep/CLRModule.cpp
new file mode 100644
index 0000000..34b9ccf
--- /dev/null
+++ b/litestep/CLRModule.cpp
@@ -0,0 +1,263 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "CLRModule.h"
+#include "../utility/core.hpp"
+#include "../utility/safeutility.h"
+#include
+
+using namespace mscorlib;
+
+
+#define DEFAULT_CLRVERSION _T("v2.0.50727")
+static CLRManager g_clrManager;
+
+
+
+CLRModule::CLRModule(const std::wstring& sLocation, DWORD dwFlags)
+ : Module(sLocation, dwFlags)
+{
+ m_pModuleInstance = nullptr;
+ m_Instance = nullptr;
+}
+
+
+CLRModule::~CLRModule()
+{
+
+}
+
+
+bool CLRModule::Init(HWND hMainWindow, const std::wstring& sAppPath)
+{
+ HRESULT hr = E_FAIL;
+
+ if (g_clrManager.LoadRuntime())
+ {
+ TCHAR wzAppPath[MAX_PATH];
+ StringCchCopy(wzAppPath, MAX_PATH, sAppPath.c_str());
+
+ hr = g_clrManager.LoadModule(this, hMainWindow, wzAppPath);
+ if (SUCCEEDED(hr))
+ m_Instance = HINSTANCE();
+ }
+
+ return SUCCEEDED(hr);
+}
+
+
+void CLRModule::Quit()
+{
+ g_clrManager.UnloadModule(this);
+ m_pModuleInstance = nullptr;
+ m_Instance = nullptr;
+}
+
+
+HINSTANCE CLRModule::GetInstance() const
+{
+ return m_Instance;
+}
+
+
+CLRManager::CLRManager()
+{
+ m_pCorRuntimeHost = nullptr;
+ m_pMetaHost = nullptr;
+ m_pRuntimeInfo = nullptr;
+}
+
+
+CLRManager::~CLRManager()
+{
+ _Dispose();
+}
+
+
+bool CLRManager::LoadRuntime()
+{
+ if (m_pCorRuntimeHost != nullptr)
+ return true;
+
+ HRESULT hr;
+
+ do {
+ hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_PPV_ARGS(&m_pMetaHost));
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "CLRCreateInstance failed w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ TCHAR clrVersion[MAX_PATH];
+ GetRCStringW(L"LSCLRVersion", clrVersion, DEFAULT_CLRVERSION, MAX_PATH);
+
+ hr = m_pMetaHost->GetRuntime(clrVersion, IID_PPV_ARGS(&m_pRuntimeInfo));
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "ICLRMetaHost::GetRuntime failed w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ BOOL fLoadable;
+ hr = m_pRuntimeInfo->IsLoadable(&fLoadable);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "ICLRRuntimeInfo::IsLoadable failed w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ if (!fLoadable)
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", ".NET runtime %s cannot be loaded\n", clrVersion);
+ break;
+ }
+
+ hr = m_pRuntimeInfo->GetInterface(CLSID_CorRuntimeHost, IID_PPV_ARGS(&m_pCorRuntimeHost));
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "ICLRRuntimeInfo::GetInterface failed w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ hr = m_pCorRuntimeHost->Start();
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "CLR failed to start w/hr 0x%08lx\n", hr);
+ break;
+ }
+ } while (false);
+
+ //
+ // If we fail for any reason then cleanup
+ //
+ if (FAILED(hr))
+ {
+ _Dispose();
+ }
+
+ return SUCCEEDED(hr);
+}
+
+HRESULT CLRManager::LoadModule(CLRModule * module, HWND hWnd, TCHAR * appPath)
+{
+ HRESULT hr;
+
+ do {
+ IUnknownPtr pAppDomainThunk = nullptr;
+ hr = m_pCorRuntimeHost->GetDefaultDomain(&pAppDomainThunk);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "ICorRuntimeHost::GetDefaultDomain failed w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ mscorlib::_AppDomainPtr pDefaultAppDomain = nullptr;
+ hr = pAppDomainThunk->QueryInterface(IID_PPV_ARGS(&pDefaultAppDomain));
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "Failed to get default AppDomain w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ TCHAR assemblyName[MAX_PATH];
+ StringCchCopy(assemblyName, MAX_PATH, PathFindFileName(module->GetLocation()));
+ PathRemoveExtension(assemblyName);
+
+ _AssemblyPtr pAssembly = nullptr;
+ bstr_t bstrAssemblyName(assemblyName);
+
+ hr = pDefaultAppDomain->Load_2(bstrAssemblyName, &pAssembly);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "Failed to load the assembly w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ bstr_t bstrClassName(bstrAssemblyName + _T(".LSModule"));
+ hr = pAssembly->GetType_2(bstrClassName, &module->m_pModuleInstance);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "Failed to get the Type interface w/hr 0x%08lx\n", hr);
+ break;
+ }
+
+ bstr_t bstrStaticMethodName(_T("initModule"));
+ SAFEARRAY *args = SafeArrayCreateVector(VT_VARIANT, 0, 2);
+ LONG index[] = { 0, 1 };
+
+ variant_t vtWndArg;
+ V_VT(&vtWndArg) = VT_INT;
+ vtWndArg.byref = hWnd;
+ SafeArrayPutElement(args, &index[0], &vtWndArg);
+
+ variant_t vtAppPathArg(appPath);
+ SafeArrayPutElement(args, &index[1], &vtAppPathArg);
+
+ variant_t vtEmpty, vtRetVal;
+ auto bindings = BindingFlags_InvokeMethod | BindingFlags_Static | BindingFlags_Public;
+
+ hr = module->m_pModuleInstance->InvokeMember_3(bstrStaticMethodName, static_cast(bindings), NULL, vtEmpty, args, &vtRetVal);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "Failed to invoke initModule w/hr 0x%08lx\n", hr);
+ }
+
+ SafeArrayDestroy(args);
+ } while (false);
+
+ return hr;
+}
+
+HRESULT CLRManager::UnloadModule(CLRModule * module)
+{
+ HRESULT hr = S_OK;
+
+ if (module->m_pModuleInstance != nullptr) {
+ bstr_t bstrStaticMethodName(_T("quitModule"));
+ SAFEARRAY * args = SafeArrayCreateVector(VT_VARIANT, 0, 0);
+
+ variant_t vtEmpty, vtRetVal;
+ auto bindings = BindingFlags_InvokeMethod | BindingFlags_Static | BindingFlags_Public;
+
+ hr = module->m_pModuleInstance->InvokeMember_3(bstrStaticMethodName, static_cast(bindings), NULL, vtEmpty, args, &vtRetVal);
+ if (FAILED(hr))
+ {
+ LSLogPrintf(LOG_ERROR, "CLRModule", "Failed to invoke quitModule w/hr 0x%08lx\n", hr);
+ }
+
+ SafeArrayDestroy(args);
+ }
+
+ return hr;
+}
+
+void CLRManager::_Dispose()
+{
+ if (m_pCorRuntimeHost)
+ {
+ m_pCorRuntimeHost->Stop();
+ SafeRelease(m_pCorRuntimeHost);
+ }
+
+ SafeRelease(m_pMetaHost);
+ SafeRelease(m_pRuntimeInfo);
+}
diff --git a/litestep/CLRModule.h b/litestep/CLRModule.h
new file mode 100644
index 0000000..2e1835e
--- /dev/null
+++ b/litestep/CLRModule.h
@@ -0,0 +1,73 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#if !defined(CLRMODULE_H)
+#define CLRMODULE_H
+
+#include "../utility/Base.h"
+#include "Module.h"
+#include
+
+#import "mscorlib.tlb" raw_interfaces_only \
+ high_property_prefixes("_get","_put","_putref") \
+ rename("ReportEvent", "InteropServices_ReportEvent")
+
+class CLRModule : public Module
+{
+private:
+ HINSTANCE m_Instance;
+ mscorlib::_TypePtr m_pModuleInstance;
+
+public:
+ CLRModule(const std::wstring& sLocation, DWORD dwFlags);
+ ~CLRModule();
+
+ bool Init(HWND hMainWindow, const std::wstring& sAppPath);
+ void Quit();
+ HINSTANCE GetInstance() const;
+
+private:
+ friend class CLRManager;
+};
+
+
+
+class CLRManager : CountedBase
+{
+private:
+ ICorRuntimeHost* m_pCorRuntimeHost;
+ ICLRMetaHost* m_pMetaHost;
+ ICLRRuntimeInfo* m_pRuntimeInfo;
+
+public:
+ CLRManager();
+ ~CLRManager();
+
+ bool LoadRuntime();
+ HRESULT LoadModule(CLRModule * module, HWND hWnd, TCHAR * appPath);
+ HRESULT UnloadModule(CLRModule * module);
+
+private:
+ void _Dispose();
+};
+
+
+#endif
diff --git a/litestep/CoreCLRModule.cpp b/litestep/CoreCLRModule.cpp
new file mode 100644
index 0000000..9f62077
--- /dev/null
+++ b/litestep/CoreCLRModule.cpp
@@ -0,0 +1,428 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "CoreCLRModule.h"
+#include "mscoree_core.h"
+#include "../utility/core.hpp"
+#include "../utility/safeutility.h"
+#include
+
+#define CORECLRDLL _T("coreclr.dll")
+#define DEFAULT_CLRVERSION _T("2.0.0")
+#define MAX_CORECLR_PATH 100 * MAX_PATH
+
+static CoreCLRManager g_clrManager;
+
+CoreCLRModule::CoreCLRModule(const std::wstring & sLocation, DWORD dwFlags)
+ : Module(sLocation, dwFlags)
+{
+ m_Instance = nullptr;
+ m_pfInitModule = nullptr;
+ m_pfQuitModule = nullptr;
+ m_domainId = 0;
+}
+
+
+CoreCLRModule::~CoreCLRModule()
+{
+ m_Instance = nullptr;
+ m_pfInitModule = nullptr;
+ m_pfQuitModule = nullptr;
+ m_domainId = 0;
+}
+
+
+bool CoreCLRModule::Init(HWND hMainWindow, const std::wstring & sAppPath)
+{
+ HRESULT hr = E_FAIL;
+
+ if (g_clrManager.LoadRuntime())
+ {
+ TCHAR wzAppPath[MAX_PATH];
+ StringCchCopy(wzAppPath, MAX_PATH, sAppPath.c_str());
+
+ hr = g_clrManager.LoadModule(this, hMainWindow, wzAppPath);
+ if (SUCCEEDED(hr))
+ m_Instance = HINSTANCE();
+ }
+
+ return SUCCEEDED(hr);
+}
+
+
+void CoreCLRModule::Quit()
+{
+ g_clrManager.UnloadModule(this);
+}
+
+
+HINSTANCE CoreCLRModule::GetInstance() const
+{
+ return m_Instance;
+}
+
+
+CoreCLRManager::CoreCLRManager() : CountedBase()
+{
+ m_pCorRuntimeHost = nullptr;
+ m_coreCLRModule = nullptr;
+ m_coreClrRootPath = nullptr;
+ m_trustedAssemblies = nullptr;
+}
+
+
+CoreCLRManager::~CoreCLRManager()
+{
+ SafeDelete(m_coreClrRootPath);
+ SafeDelete(m_trustedAssemblies);
+
+ if (m_pCorRuntimeHost)
+ {
+ m_pCorRuntimeHost->Stop();
+ SafeRelease(m_pCorRuntimeHost);
+ }
+
+ // Free the module would be done for completeness, but in fact CoreCLR.dll
+ // was pinned earlier so this call won't actually free it. The pinning is
+ // done because CoreCLR does not support unloading.
+ FreeLibrary(m_coreCLRModule);
+}
+
+
+bool CoreCLRManager::LoadRuntime()
+{
+ return _LoadCLR() && _InitializeRuntime();
+}
+
+
+HRESULT CoreCLRManager::LoadModule(CoreCLRModule * module, HWND hWnd, TCHAR * location)
+{
+ if (m_coreCLRModule == nullptr || m_pCorRuntimeHost == nullptr)
+ return E_FAIL;
+
+ TCHAR moduleRootPath[MAX_PATH];
+ StringCchCopy(moduleRootPath, MAX_PATH, module->GetLocation());
+ PathRemoveFileSpec(moduleRootPath);
+
+ TCHAR appPath[MAX_PATH * 2];
+ StringCchPrintf(appPath, MAX_PATH * 2, _T("%s;%s"), moduleRootPath, m_coreClrRootPath);
+
+ TCHAR appNiPath[MAX_PATH];
+ StringCchPrintf(appNiPath, MAX_PATH, _T("%s\\NI;"), moduleRootPath);
+
+ TCHAR appLocalWinmetadata[MAX_PATH];
+ StringCchPrintf(appLocalWinmetadata, MAX_PATH, _T("%s\\WinMetadata;"), moduleRootPath);
+
+ TCHAR appNativeDllPath[MAX_PATH * 50];
+ StringCchPrintf(appNativeDllPath, MAX_PATH * 50, _T("%s;%s;"), moduleRootPath, location);
+
+ TCHAR assemblyName[MAX_PATH];
+ StringCchCopy(assemblyName, MAX_PATH, PathFindFileName(module->GetLocation()));
+ _RemoveExtensionAndNi(assemblyName);
+
+ const TCHAR *property_keys[] = {
+ _T("TRUSTED_PLATFORM_ASSEMBLIES"),
+ _T("APP_PATHS"),
+ _T("APP_NI_PATHS"),
+ _T("NATIVE_DLL_SEARCH_DIRECTORIES"),
+ _T("APP_LOCAL_WINMETADATA")
+ };
+ const TCHAR *property_values[] = {
+ // TRUSTED_PLATFORM_ASSEMBLIES
+ m_trustedAssemblies,
+ // APP_PATHS
+ appPath,
+ // APP_NI_PATHS
+ appNiPath,
+ // NATIVE_DLL_SEARCH_DIRECTORIES
+ appNativeDllPath,
+ // APP_LOCAL_WINMETADATA
+ appLocalWinmetadata
+ };
+
+ HRESULT hr = m_pCorRuntimeHost->CreateAppDomainWithManager(
+ assemblyName,
+ APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS | // Enable platform-specific assemblies to run
+ APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP | // Allow PInvoking from non-TPA assemblies
+ APPDOMAIN_DISABLE_TRANSPARENCY_ENFORCEMENT, // Entirely disables transparency checks ,
+ NULL,
+ NULL,
+ sizeof(property_keys) / sizeof(TCHAR *),
+ property_keys,
+ property_values,
+ &module->m_domainId
+ );
+ if (SUCCEEDED(hr))
+ {
+ TCHAR className[MAX_PATH];
+ StringCchPrintf(className, MAX_PATH, _T("%s.LSModule"), assemblyName);
+
+ hr = m_pCorRuntimeHost->CreateDelegate(module->m_domainId, assemblyName, className, _T("initModule"), (INT_PTR*)&module->m_pfInitModule);
+ if (SUCCEEDED(hr))
+ {
+ module->m_pfInitModule(hWnd, appPath);
+ AddRef();
+ }
+ }
+
+ return hr;
+}
+
+
+HRESULT CoreCLRManager::UnloadModule(CoreCLRModule * module)
+{
+ if (m_coreCLRModule == nullptr || m_pCorRuntimeHost == nullptr)
+ return E_FAIL;
+
+ TCHAR assemblyName[MAX_PATH];
+ StringCchCopy(assemblyName, MAX_PATH, PathFindFileName(module->GetLocation()));
+ _RemoveExtensionAndNi(assemblyName);
+
+ TCHAR className[MAX_PATH];
+ StringCchPrintf(className, MAX_PATH, _T("%s.LSModule"), assemblyName);
+
+ HRESULT hr = m_pCorRuntimeHost->CreateDelegate(module->m_domainId, assemblyName, className, _T("quitModule"), (INT_PTR*)&module->m_pfQuitModule);
+ if (SUCCEEDED(hr))
+ {
+ module->m_pfQuitModule();
+ }
+
+ DWORD exitCode;
+ hr = m_pCorRuntimeHost->UnloadAppDomain2(module->m_domainId, true, (int *)&exitCode);
+
+ Release();
+ return hr;
+}
+
+
+bool CoreCLRManager::_LoadCLR()
+{
+ // IF we are already loaded skip this
+ if (m_coreCLRModule != nullptr)
+ return true;
+
+ SafeDelete(m_coreClrRootPath);
+ m_coreClrRootPath = new TCHAR[MAX_PATH];
+ TCHAR coreClrDllPath[MAX_PATH];
+
+ // Try to load the version set in the config if it was set
+ TCHAR clrVersion[MAX_PATH], buffer[MAX_PATH];
+ GetRCStringW(_T("LSCoreCLRVersion"), clrVersion, DEFAULT_CLRVERSION, MAX_PATH);
+
+ DWORD chars = ExpandEnvironmentStrings(_T("%PROGRAMFILES%\\dotnet\\shared\\Microsoft.NETCore.App"), buffer, MAX_PATH);
+ if (chars > 1)
+ {
+ StringCchPrintf(m_coreClrRootPath, MAX_PATH, _T("%s\\%s\\"), buffer, clrVersion);
+ StringCchPrintf(coreClrDllPath, MAX_PATH, _T("%s%s"), m_coreClrRootPath, CORECLRDLL);
+ m_coreCLRModule = LoadLibraryEx(coreClrDllPath, NULL, 0);
+ }
+
+ if (m_coreCLRModule)
+ {
+ // Pin the module - CoreCLR.dll does not support being unloaded.
+ HMODULE dummy_coreCLRModule;
+ if (::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN, coreClrDllPath, &dummy_coreCLRModule))
+ return true;
+
+ // Pin failed so unload the library
+ FreeLibrary(m_coreCLRModule);
+ }
+
+ m_coreCLRModule = nullptr;
+ return false;
+}
+
+
+bool CoreCLRManager::_InitializeRuntime()
+{
+ if (m_pCorRuntimeHost)
+ return true;
+
+ do
+ {
+ FnGetCLRRuntimeHost pfnGetCLRRuntimeHost = (FnGetCLRRuntimeHost)::GetProcAddress(m_coreCLRModule, "GetCLRRuntimeHost");
+ if (pfnGetCLRRuntimeHost == nullptr)
+ break;
+
+ HRESULT hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&m_pCorRuntimeHost);
+ if (FAILED(hr))
+ break;
+
+ hr = m_pCorRuntimeHost->SetStartupFlags(
+ static_cast(
+ STARTUP_FLAGS::STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN |
+ STARTUP_FLAGS::STARTUP_SINGLE_APPDOMAIN |
+ STARTUP_FLAGS::STARTUP_CONCURRENT_GC));
+ if (FAILED(hr))
+ break;
+
+ hr = m_pCorRuntimeHost->Start();
+ if (FAILED(hr))
+ break;
+
+ _GenerateTrustedAssemblyList();
+ return true;
+
+ } while (false);
+
+ SafeRelease(m_pCorRuntimeHost);
+ return false;
+}
+
+
+void CoreCLRManager::_GenerateTrustedAssemblyList()
+{
+ //
+ // TRUSTED_PLATFORM_ASSEMBLIES
+ // "Trusted Platform Assemblies" are prioritized by the loader and always loaded with full trust.
+ // A common pattern is to include any assemblies next to CoreCLR.dll as platform assemblies.
+ // More sophisticated hosts may also include their own Framework extensions (such as AppDomain managers)
+ // in this list.
+ //
+ SafeDelete(m_trustedAssemblies);
+
+ m_trustedAssemblies = new TCHAR[MAX_CORECLR_PATH];
+ memset(m_trustedAssemblies, '\0', MAX_CORECLR_PATH);
+
+ // Try looking at the %CORE_LIBRARIES% variable
+ size_t outSize;
+ TCHAR coreLibrariesPath[MAX_PATH];
+ _tgetenv_s(&outSize, coreLibrariesPath, MAX_PATH, _T("CORE_LIBRARIES"));
+ if (outSize > 0)
+ {
+ if (coreLibrariesPath[outSize - 1] != _T('\\'))
+ StringCchCat(coreLibrariesPath, MAX_PATH, _T("\\"));
+
+ _AddFilesToTrustedAssembliesList(coreLibrariesPath);
+ }
+
+ // Now look into the directory we loaded the CoreCLR.dll from
+ _AddFilesToTrustedAssembliesList(m_coreClrRootPath);
+}
+
+
+void CoreCLRManager::_AddFilesToTrustedAssembliesList(TCHAR * location)
+{
+ const TCHAR * exts[] = {
+ _T("*.ni.dll"),
+ _T("*.dll"),
+ _T("*.ni.exe"),
+ _T("*.exe"),
+ _T("*.ni.winmd"),
+ _T("*.winmd")
+ };
+ int extlen = sizeof(exts)/sizeof(TCHAR);
+ int tpaSize = MAX_CORECLR_PATH;
+ TCHAR asmPath[MAX_PATH];
+
+ for (int i = 0; i < extlen; i++)
+ {
+ memset(asmPath, '\0', MAX_PATH);
+ StringCchPrintf(asmPath, MAX_PATH, _T("%s%s"), location, exts[i]);
+
+ WIN32_FIND_DATA data;
+ HANDLE findHandle = FindFirstFile(asmPath, &data);
+ if (findHandle != INVALID_HANDLE_VALUE)
+ {
+ do {
+ if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ // It seems that CoreCLR doesn't always use the first instance of an assembly on the TPA list (ni's may be preferred
+ // over il, even if they appear later). So, only include the first instance of a simple assembly name to allow
+ // users the opportunity to override Framework assemblies by placing dlls in %CORE_LIBRARIES%
+
+ CharLower(data.cFileName);
+
+ TCHAR fileNameWithoutExtension[MAX_PATH];
+ StringCchCopy(fileNameWithoutExtension, MAX_PATH, data.cFileName);
+
+ _RemoveExtensionAndNi(fileNameWithoutExtension);
+
+ // Add to the list if not already on it
+ if (!_ContainsTrustedAssembly(fileNameWithoutExtension, exts))
+ {
+ StringCchPrintf(asmPath, MAX_PATH, _T("%s%s;"), location, data.cFileName);
+
+ // Check to see if TPA list needs expanded
+ int buffLen = _tcsclen(asmPath) + _tcsclen(m_trustedAssemblies);
+ if (buffLen > tpaSize)
+ {
+ tpaSize = buffLen + 1;
+
+ TCHAR* newTPAList = new TCHAR[tpaSize];
+ StringCchCopy(newTPAList, tpaSize, m_trustedAssemblies);
+
+ SafeDelete(m_trustedAssemblies);
+ m_trustedAssemblies = newTPAList;
+ }
+
+ StringCchCat(m_trustedAssemblies, MAX_CORECLR_PATH, asmPath);
+ }
+ }
+ } while (0 != FindNextFile(findHandle, &data));
+
+ FindClose(findHandle);
+ }
+ }
+}
+
+bool CoreCLRManager::_ContainsTrustedAssembly(TCHAR * fileName, const TCHAR ** fileExts)
+{
+ if (_tclen(m_trustedAssemblies) <= 0)
+ return false;
+
+ std::wstring asmList(m_trustedAssemblies);
+
+ TCHAR fileNameExt[MAX_PATH];
+ int len = sizeof(fileExts) / sizeof(fileExts[0]);
+
+ for (int i = 0; i < len; i++)
+ {
+ memset(fileNameExt, '\0', MAX_PATH);
+ StringCchPrintf(fileNameExt, MAX_PATH, _TEXT("\\%s%s;"), fileName, fileExts[i]);
+ if (asmList.find(fileNameExt, 0) != std::wstring::npos)
+ return true;
+ }
+
+ return false;
+}
+
+
+void CoreCLRManager::_RemoveExtensionAndNi(TCHAR * fileName)
+{
+ // Remove extension, if it exists
+ TCHAR* extension = wcsrchr(fileName, _T('.'));
+ if (extension != NULL)
+ {
+ extension[0] = _T('\0');
+
+ // Check for .ni
+ size_t len = _tclen(fileName);
+ if (len > 3 &&
+ fileName[len - 1] == _T('i') &&
+ fileName[len - 2] == _T('n') &&
+ fileName[len - 3] == _T('.'))
+ {
+ fileName[len - 3] = _T('\0');
+ }
+ }
+}
+
diff --git a/litestep/CoreCLRModule.h b/litestep/CoreCLRModule.h
new file mode 100644
index 0000000..0d5a99e
--- /dev/null
+++ b/litestep/CoreCLRModule.h
@@ -0,0 +1,81 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#if !defined(CORECLRMODULE_H)
+#define CORECLRMODULE_H
+
+#include "../utility/Base.h"
+#include "Module.h"
+
+typedef void (*initModule)(HWND hWndMain, TCHAR * appPath);
+typedef void (*quitModule)();
+
+struct ICLRRuntimeHost4;
+
+class CoreCLRModule : public Module
+{
+private:
+ HINSTANCE m_Instance;
+ DWORD m_domainId;
+ initModule m_pfInitModule;
+ quitModule m_pfQuitModule;
+
+public:
+ CoreCLRModule(const std::wstring& sLocation, DWORD dwFlags);
+ ~CoreCLRModule();
+
+ bool Init(HWND hMainWindow, const std::wstring& sAppPath);
+ void Quit();
+ HINSTANCE GetInstance() const;
+
+private:
+ friend class CoreCLRManager;
+};
+
+
+
+class CoreCLRManager : CountedBase
+{
+private:
+ HINSTANCE m_coreCLRModule;
+ TCHAR* m_coreClrRootPath;
+ TCHAR* m_trustedAssemblies;
+ ICLRRuntimeHost4* m_pCorRuntimeHost;
+
+public:
+ CoreCLRManager();
+ ~CoreCLRManager();
+
+ bool LoadRuntime();
+ HRESULT LoadModule(CoreCLRModule * module, HWND hWnd, TCHAR * appPath);
+ HRESULT UnloadModule(CoreCLRModule * module);
+
+private:
+ bool _LoadCLR();
+ bool _InitializeRuntime();
+ void _GenerateTrustedAssemblyList();
+ void _AddFilesToTrustedAssembliesList(TCHAR* location);
+ bool _ContainsTrustedAssembly(TCHAR * fileName, const TCHAR** fileExts);
+ void _RemoveExtensionAndNi(TCHAR * fileName);
+};
+
+#endif
+
diff --git a/litestep/Module.cpp b/litestep/Module.cpp
index 6e842bf..2b94583 100755
--- a/litestep/Module.cpp
+++ b/litestep/Module.cpp
@@ -19,401 +19,16 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#include "module.h"
-#include "../lsapi/ThreadedBangCommand.h"
-#include "../utility/macros.h"
-#include "../utility/core.hpp"
-#include "../utility/stringutility.h"
+#include "CLRModule.h"
+#include "CoreCLRModule.h"
+#include "NativeModule.h"
-#include
-
-
-Module::Module(const std::wstring& sLocation, DWORD dwFlags)
-{
- m_hInstance = nullptr;
- m_hThread = nullptr;
- m_pInit = nullptr;
- m_hInitEvent = nullptr;
- m_hInitCopyEvent = nullptr;
- m_pQuit = nullptr;
- m_dwFlags = dwFlags;
- m_dwLoadTime = 0;
- m_wzLocation = sLocation;
-}
-
-
-static WORD GetModuleArchitecture(LPCWSTR wzModuleName)
-{
- WORD wRet = 0;
- HANDLE hFile = CreateFileW(wzModuleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if (hFile != INVALID_HANDLE_VALUE)
- {
- HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
- if (hFileMapping != nullptr)
- {
- LPVOID lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
- if (lpFileBase != nullptr)
- {
- PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)lpFileBase;
- PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((LPBYTE)pDosHeader + pDosHeader->e_lfanew);
- wRet = pNTHeader->OptionalHeader.Magic;
- UnmapViewOfFile(lpFileBase);
- }
- CloseHandle(hFileMapping);
- }
- CloseHandle(hFile);
- }
- return wRet;
-}
-
-
-//
-// This is a workaround because Microsofts std::function implementation is bugged
-//
-template
-void AssignToFunction(std::function &func, T* value)
+Module * Module::CreateInstance(const std::wstring & sLocation, DWORD dwFlags)
{
- if (value == nullptr)
- {
- func = nullptr;
- }
+ if (dwFlags & LS_MODULE_CLR)
+ return new CLRModule(sLocation, dwFlags);
+ else if (dwFlags & LS_MODULE_CORECLR)
+ return new CoreCLRModule(sLocation, dwFlags);
else
- {
- func = value;
- }
-}
-
-
-bool Module::_LoadDll()
-{
- bool bReturn = false;
-
- if (!m_hInstance)
- {
- // Modules like popup2 like to call SetErrorMode. While that may not be
- // good style, there is little we can do about it. However, LoadLibrary
- // usually produces helpful error messages such as
- // "msvcp70.dll not found" which are not displayed if a module has
- // disabled them via SetErrorMode. We force their display here.
- // First, make Windows display all errors
- UINT uOldMode = SetErrorMode(0);
-
- if ((m_hInstance = LoadLibraryW(m_wzLocation.c_str())) != nullptr)
- {
- AssignToFunction(m_pInit, (initModuleProc) GetProcAddress(
- m_hInstance, "initModuleW"));
-
- if (!m_pInit) // Might be a legacy module, check for initModuleEx
- {
- initModuleProcA pInit = (initModuleProcA)GetProcAddress(
- m_hInstance, "initModuleEx");
-
- if (!pInit) // Might be a BC module, check for underscore
- {
- pInit = (initModuleProcA)GetProcAddress(
- m_hInstance, "_initModuleEx");
- }
-
- if (pInit)
- {
- m_pInit = [pInit] (HWND hWnd, HINSTANCE hInst, LPCWSTR pwzPath) -> int {
- char szPath[MAX_PATH];
- WideCharToMultiByte(CP_ACP, 0, pwzPath, -1,
- szPath, sizeof(szPath), "", nullptr);
- return pInit(hWnd, hInst, szPath);
- };
- }
- }
-
- m_pQuit = (quitModuleProc)GetProcAddress(
- m_hInstance, "quitModule");
-
- if (!m_pQuit) // Might be a BC module, check for underscore
- {
- m_pQuit = (quitModuleProc)GetProcAddress(
- m_hInstance, "_quitModule");
- }
-
- if (m_pInit == nullptr)
- {
- RESOURCE_STR(nullptr, IDS_INITMODULEEXNOTFOUND_ERROR,
- L"Error: Could not find initModule().\n"
- L"\n"
- L"Please confirm that the dll is a LiteStep module,\n"
- L"and check with the author for updates.");
- }
- else if (m_pQuit == nullptr)
- {
- RESOURCE_STR(nullptr, IDS_QUITMODULENOTFOUND_ERROR,
- L"Error: Could not find quitModule().\n"
- L"\n"
- L"Please confirm that the dll is a LiteStep module.");
- }
- else
- {
- bReturn = true;
- }
- }
- else
- {
- HRESULT hrError = HrGetLastError();
-
-#if defined(_WIN64)
- if (GetModuleArchitecture(m_wzLocation.c_str()) == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
- {
- RESOURCE_STR(nullptr, IDS_MODULEWRONGARCH64_ERROR,
- L"Error: Could not load module.\n"
- L"\n"
- L"The module seems to compiled for 32-bit LiteStep. This is a 64-bit version of LiteStep, which can only load 64-bit modules.");
- }
-#else
- if (GetModuleArchitecture(m_wzLocation.c_str()) == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
- {
- RESOURCE_STR(nullptr, IDS_MODULEWRONGARCH32_ERROR,
- L"Error: Could not load module.\n"
- L"\n"
- L"The module seems to compiled for 64-bit LiteStep. This is a 32-bit version of LiteStep, which can only load 32-bit modules.");
- }
-#endif
- else if (PathFileExistsW(m_wzLocation.c_str()))
- {
- RESOURCE_STR(nullptr, IDS_MODULEDEPENDENCY_ERROR,
- L"Error: Could not load module.\n"
- L"\n"
- L"This is likely a case of a missing C Run-Time Library"
- L"or other dependency."
- L"\n"
- L"Error Information:"
- L"\n");
-
- size_t nLen = 0;
- StringCchLengthW(resourceTextBuffer, _countof(resourceTextBuffer), &nLen);
- DescriptionFromHR(hrError, resourceTextBuffer + nLen, _countof(resourceTextBuffer) - nLen);
- }
- else
- {
- RESOURCE_STR(nullptr, IDS_MODULENOTFOUND_ERROR,
- L"Error: Could not locate module.\n"
- L"\n"
- L"Please check your configuration.");
- }
- }
-
- // Second, restore the old state
- SetErrorMode(uOldMode);
-
- if (!bReturn)
- {
- LPCWSTR pwzFileName = PathFindFileNameW(m_wzLocation.c_str());
-
- RESOURCE_MSGBOX_F(pwzFileName, MB_ICONERROR);
-
- if (m_hInstance)
- {
- FreeLibrary(m_hInstance);
- m_hInstance = nullptr;
- }
- }
- }
-
- return bReturn;
-}
-
-
-Module::~Module()
-{
- if (m_dwFlags & LS_MODULE_THREADED)
- {
- // Note:
- // - This is problematic because these handles may currently
- // be used in _WaitForModules(), and by closing the handle
- // here before it is done being used, we may cause invalid
- // behavior of that function, with potential lockups.
- // - The solution within our current structure, is to allow
- // an external procedure to take ownership of these handles.
- // Meaning, whoever calls _WaitForModules would be required
- // to free these objects when done with them, instead of us
- // releasing them here. (See: TakeThread() TakeInitEvent())
- // - The correct solution is re-writing our module threading
- // behavior, which we will be doing on the trunk code.
- if (m_hInitEvent)
- {
- CloseHandle(m_hInitEvent);
- m_hInitEvent = NULL;
- }
-
- if (m_hThread)
- {
- CloseHandle(m_hThread);
- m_hThread = NULL;
- }
- }
-
- if (m_hInstance)
- {
- FreeLibrary(m_hInstance);
- m_hInstance = NULL;
- }
-}
-
-
-bool Module::Init(HWND hMainWindow, const std::wstring& sAppPath)
-{
- ASSERT(NULL == m_hInstance);
-
- DWORD dwStartTime = 0;
- __int64 iStartTime, iEndTime, iFrequency;
- bool bResult = false;
-
- if (QueryPerformanceCounter((LARGE_INTEGER*)&iStartTime) == FALSE)
- {
- dwStartTime = GetTickCount();
- }
-
- // delaying the LoadLibrary call until this point is necessary to make
- // grdtransparent work (it hooks LoadLibrary)
- if (_LoadDll())
- {
- ASSERT(nullptr != m_pInit);
- ASSERT(nullptr != m_pQuit);
-
- m_hMainWindow = hMainWindow;
- m_wzAppPath = sAppPath;
-
- if (m_dwFlags & LS_MODULE_THREADED)
- {
- SECURITY_ATTRIBUTES sa;
-
- sa.nLength = sizeof(SECURITY_ATTRIBUTES);
- sa.lpSecurityDescriptor = nullptr;
- sa.bInheritHandle = FALSE;
-
- m_hInitCopyEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
- m_hInitEvent = m_hInitCopyEvent;
- // using _beginthreadex instead of CreateThread because modules
- // might use CRT functions
- m_hThread = (HANDLE)_beginthreadex(&sa, 0, Module::ThreadProc,
- this, 0, (UINT*)&m_dwThreadID);
- bResult = true;
- }
- else
- {
- bResult = CallInit() == 0;
- }
-
- if (QueryPerformanceCounter((LARGE_INTEGER*)&iEndTime) == FALSE ||
- QueryPerformanceFrequency((LARGE_INTEGER*)&iFrequency) == FALSE)
- {
- m_dwLoadTime = GetTickCount() - dwStartTime;
- }
- else
- {
- m_dwLoadTime = (DWORD)((iEndTime - iStartTime)*1000/iFrequency);
- }
- }
-
- return bResult;
-}
-
-
-int Module::CallInit()
-{
- ASSERT(m_pInit != nullptr);
- return m_pInit(m_hMainWindow, m_hInstance, m_wzAppPath.c_str());
-}
-
-
-void Module::CallQuit()
-{
- ASSERT(m_pQuit != NULL);
- m_pQuit(m_hInstance);
-}
-
-
-void Module::Quit()
-{
- if (m_hInstance)
- {
- if (m_dwFlags & LS_MODULE_THREADED)
- {
- PostThreadMessage(m_dwThreadID, WM_DESTROY, 0, (LPARAM)this);
- }
- else
- {
- CallQuit();
- }
- }
-}
-
-
-UINT __stdcall Module::ThreadProc(void* dllModPtr)
-{
- Module* dllMod = (Module*)dllModPtr;
-
-#if defined(MSVC_DEBUG)
- LPCTSTR pszFileName = PathFindFileName(dllMod->m_wzLocation.c_str());
- DbgSetCurrentThreadName(WCSTOMBS(pszFileName));
-#endif
-
- dllMod->CallInit();
-
- // We must use a copy of our event, and hope no one has closed it before
- // waiting for it to be signaled. See: TakeThread() member function.
- SetEvent(dllMod->m_hInitCopyEvent);
-
- MSG msg;
-
- while (GetMessage(&msg, 0, 0, 0) > 0)
- {
- if (msg.hwnd == NULL)
- {
- // Thread message
- HandleThreadMessage(msg);
- }
- else
- {
- // Window message
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
-
- return 0;
-}
-
-
-void Module::HandleThreadMessage(MSG &msg)
-{
- switch (msg.message)
- {
- case LM_THREAD_BANGCOMMAND:
- {
- ThreadedBangCommand * pInfo = (ThreadedBangCommand*)msg.wParam;
-
- if (pInfo != NULL)
- {
- pInfo->Execute();
- pInfo->Release(); //check BangCommand.cpp for the reason
- }
- }
- break;
-
- case WM_DESTROY:
- {
- Module *dll_mod = (Module*)msg.lParam;
-
- if (dll_mod)
- {
- dll_mod->CallQuit();
- PostQuitMessage(0);
- }
- }
- break;
-
- default:
- {
- // do nothing
- }
- break;
- }
+ return new NativeModule(sLocation, dwFlags);
}
diff --git a/litestep/Module.h b/litestep/Module.h
index eae2a3e..bec12e3 100755
--- a/litestep/Module.h
+++ b/litestep/Module.h
@@ -25,8 +25,6 @@
#include "../lsapi/lsapidefines.h"
#include "../utility/common.h"
#include
-#include
-
/**
* Dynamically-loadable module.
@@ -34,41 +32,20 @@
class Module
{
private:
- /** Instance handle of module's DLL */
- HINSTANCE m_hInstance;
-
- /** Thread handle */
- HANDLE m_hThread;
-
- /** LiteStep's main window handle */
- HWND m_hMainWindow;
-
- /** Thread ID */
- DWORD m_dwThreadID;
-
- /** Path to module's DLL */
- std::basic_string m_wzLocation;
+ /** Flags used to load module */
+ DWORD m_dwFlags;
- /** Path to LiteStep's root directory */
- std::basic_string m_wzAppPath;
+ /** Path to module's DLL */
+ std::basic_string m_wzLocation;
- /** Pointer to initModuleEx
function */
- std::function m_pInit;
+ /** The amount of time it took to load the module */
+ DWORD m_dwLoadTime;
- /** Pointer to quitModule
function */
- quitModuleProc m_pQuit;
-
- /** Flags used to load module */
- DWORD m_dwFlags;
-
- /** The amount of time it took to load the module */
- DWORD m_dwLoadTime;
-
- /**
- * Event that is triggered when a threaded module completes initialization
- */
- HANDLE m_hInitEvent;
- HANDLE m_hInitCopyEvent;
+protected:
+ void SetLoadTime(DWORD dwLoadTime)
+ {
+ m_dwLoadTime = dwLoadTime;
+ }
public:
/**
@@ -77,12 +54,12 @@ class Module
* @param sLocation path to the module's DLL
* @param dwFlags set of flags that control how the module is loaded
*/
- Module(const std::wstring& sLocation, DWORD dwFlags);
-
- /**
- * Destructor.
- */
- virtual ~Module();
+ Module(const std::wstring& sLocation, DWORD dwFlags)
+ {
+ m_wzLocation = sLocation;
+ m_dwFlags = dwFlags;
+ m_dwLoadTime = 0;
+ }
/**
* Loads and initializes the module. If the module is loaded in its own
@@ -95,47 +72,26 @@ class Module
* @param sAppPath path to LiteStep's root directory
* @return true
if successful or false
otherwise
*/
- bool Init(HWND hMainWindow, const std::wstring& sAppPath);
+ virtual bool Init(HWND hMainWindow, const std::wstring& sAppPath) = 0;
/**
* Shuts down the module and unloads it. If the module was loaded in its
* own thread then shutdown is done asynchronously. Use event handle
* returned by GetQuitEvent
to wait for shutdown to complete.
*/
- void Quit();
-
- /**
- * Entry point for the module's main thread.
- *
- * @param dllModPtr pointer to this
- * @return unused
- */
- static UINT __stdcall ThreadProc(void* dllModPtr);
-
- /**
- * Handles messages sent to the module's main thread.
- *
- * @param msg message information
- */
- static void HandleThreadMessage(MSG &msg);
+ virtual void Quit() = 0;
/**
* Returns this module's DLL instance handle.
*/
- HINSTANCE GetInstance() const
- {
- return m_hInstance;
- }
+ virtual HINSTANCE GetInstance() const = 0;
/**
* Returns this module's thread handle. Returns NULL
if the
* module was not loaded in its own thread.
*/
- HANDLE GetThread() const
- {
- return m_hThread;
- }
-
+ virtual HANDLE GetThread() const { return nullptr; }
+
/**
* Returns this module's thread handle. Returns NULL
if the
* module was not loaded in its own thread.
@@ -143,21 +99,12 @@ class Module
* Caller is responsible for calling CloseHandle() on the return value.
* Caller must NOT call CloseHandle() until the thread has an exit signal.
*/
- HANDLE TakeThread()
- {
- HANDLE hTemp = m_hThread;
- m_hThread = nullptr;
-
- return hTemp;
- }
-
+ virtual HANDLE TakeThread() { return nullptr; };
+
/**
* Returns an event that is set once this module has been initialized.
*/
- HANDLE GetInitEvent() const
- {
- return m_hInitEvent;
- }
+ virtual HANDLE GetInitEvent() const { return nullptr; }
/**
* Returns an event that is set once this module has been initialized.
@@ -166,21 +113,7 @@ class Module
* Caller must NOT call CloseHandle() until the event has been set to
* signaled.
*/
- HANDLE TakeInitEvent()
- {
- HANDLE hTemp = m_hInitEvent;
- m_hInitEvent = nullptr;
-
- return hTemp;
- }
-
- /**
- * Returns the path to this module's DLL.
- */
- LPCWSTR GetLocation() const
- {
- return m_wzLocation.c_str();
- }
+ virtual HANDLE TakeInitEvent() { return nullptr; }
/**
* Returns the set of flags used to load this module.
@@ -190,51 +123,26 @@ class Module
return m_dwFlags;
}
- /**
- * Returns how long this module took to load.
- */
- DWORD GetLoadTime() const
- {
- return m_dwLoadTime;
- }
-
- /**
- * Returns a pointer to this module's quitModule
function.
- */
- decltype(m_pQuit) GetQuit() const
- {
- return m_pQuit;
- }
-
- /**
- * Returns a pointer to this module's initModuleEx
function.
- */
- decltype(m_pInit) GetInit() const
- {
- return m_pInit;
- }
-
-private:
- /**
- * Loads this module's DLL.
- *
- * @return true
if successful or
- * false
if an error occurs
- */
- bool _LoadDll();
-
- /**
- * Calls this module's initModuleEx
function.
- *
- * @return return value from initModuleEx
- */
- int CallInit();
-
- /**
- * Calls this module's quitModule
function.
- */
- void CallQuit();
+ /**
+ * Returns the path to this module's DLL.
+ */
+ LPCWCHAR GetLocation() const
+ {
+ return m_wzLocation.c_str();
+ }
+
+ /**
+ * Returns how long this module took to load.
+ */
+ DWORD GetLoadTime() const
+ {
+ return m_dwLoadTime;
+ }
+
+ /**
+ * Module factory
+ */
+ static Module * CreateInstance(const std::wstring& sLocation, DWORD dwFlags);
};
-
#endif // MODULE_H
diff --git a/litestep/ModuleManager.cpp b/litestep/ModuleManager.cpp
index 537cc43..73b8581 100755
--- a/litestep/ModuleManager.cpp
+++ b/litestep/ModuleManager.cpp
@@ -152,6 +152,14 @@ UINT ModuleManager::_LoadModules()
{
dwFlags |= LS_MODULE_THREADED;
}
+ else if (_wcsicmp(wzToken2, L"clr") == 0)
+ {
+ dwFlags |= LS_MODULE_CLR;
+ }
+ else if (_wcsicmp(wzToken2, L"coreclr") == 0)
+ {
+ dwFlags |= LS_MODULE_CORECLR;
+ }
Module* pModule = _MakeModule(wzToken1, dwFlags);
@@ -189,7 +197,7 @@ BOOL ModuleManager::LoadModule(LPCWSTR pwzLocation, DWORD dwFlags)
Module* ModuleManager::_MakeModule(LPCWSTR pwzLocation, DWORD dwFlags)
{
- return new Module(pwzLocation, dwFlags);
+ return Module::CreateInstance(pwzLocation, dwFlags);
}
diff --git a/litestep/NativeModule.cpp b/litestep/NativeModule.cpp
new file mode 100644
index 0000000..316395b
--- /dev/null
+++ b/litestep/NativeModule.cpp
@@ -0,0 +1,417 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "NativeModule.h"
+#include "../lsapi/ThreadedBangCommand.h"
+#include "../utility/macros.h"
+#include "../utility/core.hpp"
+#include "../utility/stringutility.h"
+
+#include
+
+static WORD GetModuleArchitecture(LPCWSTR wzModuleName)
+{
+ WORD wRet = 0;
+ HANDLE hFile = CreateFileW(wzModuleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+ if (hFile != INVALID_HANDLE_VALUE)
+ {
+ HANDLE hFileMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (hFileMapping != nullptr)
+ {
+ LPVOID lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
+ if (lpFileBase != nullptr)
+ {
+ PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)lpFileBase;
+ PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((LPBYTE)pDosHeader + pDosHeader->e_lfanew);
+ wRet = pNTHeader->OptionalHeader.Magic;
+ UnmapViewOfFile(lpFileBase);
+ }
+ CloseHandle(hFileMapping);
+ }
+ CloseHandle(hFile);
+ }
+ return wRet;
+}
+
+
+//
+// This is a workaround because Microsofts std::function implementation is bugged
+//
+template
+void AssignToFunction(std::function &func, T* value)
+{
+ if (value == nullptr)
+ {
+ func = nullptr;
+ }
+ else
+ {
+ func = value;
+ }
+}
+
+
+NativeModule::NativeModule(const std::wstring& sLocation, DWORD dwFlags)
+ : Module(sLocation, dwFlags)
+{
+ m_hInstance = nullptr;
+ m_hThread = nullptr;
+ m_pInit = nullptr;
+ m_hInitEvent = nullptr;
+ m_hInitCopyEvent = nullptr;
+ m_pQuit = nullptr;
+}
+
+
+NativeModule::~NativeModule()
+{
+ if (GetFlags() & LS_MODULE_THREADED)
+ {
+ // Note:
+ // - This is problematic because these handles may currently
+ // be used in _WaitForModules(), and by closing the handle
+ // here before it is done being used, we may cause invalid
+ // behavior of that function, with potential lockups.
+ // - The solution within our current structure, is to allow
+ // an external procedure to take ownership of these handles.
+ // Meaning, whoever calls _WaitForModules would be required
+ // to free these objects when done with them, instead of us
+ // releasing them here. (See: TakeThread() TakeInitEvent())
+ // - The correct solution is re-writing our module threading
+ // behavior, which we will be doing on the trunk code.
+ if (m_hInitEvent)
+ {
+ CloseHandle(m_hInitEvent);
+ m_hInitEvent = NULL;
+ }
+
+ if (m_hThread)
+ {
+ CloseHandle(m_hThread);
+ m_hThread = NULL;
+ }
+ }
+
+ if (m_hInstance)
+ {
+ FreeLibrary(m_hInstance);
+ m_hInstance = NULL;
+ }
+}
+
+bool NativeModule::Init(HWND hMainWindow, const std::wstring& sAppPath)
+{
+ ASSERT(NULL == m_hInstance);
+
+ DWORD dwStartTime = 0;
+ __int64 iStartTime, iEndTime, iFrequency;
+ bool bResult = false;
+
+ if (QueryPerformanceCounter((LARGE_INTEGER*)&iStartTime) == FALSE)
+ {
+ dwStartTime = GetTickCount();
+ }
+
+ // delaying the LoadLibrary call until this point is necessary to make
+ // grdtransparent work (it hooks LoadLibrary)
+ if (_LoadDll())
+ {
+ ASSERT(nullptr != m_pInit);
+ ASSERT(nullptr != m_pQuit);
+
+ m_hMainWindow = hMainWindow;
+ m_wzAppPath = sAppPath;
+
+ if (GetFlags() & LS_MODULE_THREADED)
+ {
+ SECURITY_ATTRIBUTES sa;
+
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
+ sa.lpSecurityDescriptor = nullptr;
+ sa.bInheritHandle = FALSE;
+
+ m_hInitCopyEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ m_hInitEvent = m_hInitCopyEvent;
+ // using _beginthreadex instead of CreateThread because modules
+ // might use CRT functions
+ m_hThread = (HANDLE)_beginthreadex(&sa, 0, NativeModule::ThreadProc,
+ this, 0, (UINT*)&m_dwThreadID);
+ bResult = true;
+ }
+ else
+ {
+ bResult = _CallInit() == 0;
+ }
+
+ if (QueryPerformanceCounter((LARGE_INTEGER*)&iEndTime) == FALSE ||
+ QueryPerformanceFrequency((LARGE_INTEGER*)&iFrequency) == FALSE)
+ {
+ SetLoadTime(GetTickCount() - dwStartTime);
+ }
+ else
+ {
+ SetLoadTime((DWORD)((iEndTime - iStartTime) * 1000 / iFrequency));
+ }
+ }
+
+ return bResult;
+}
+
+
+void NativeModule::Quit()
+{
+ if (m_hInstance)
+ {
+ if (GetFlags() & LS_MODULE_THREADED)
+ {
+ PostThreadMessage(m_dwThreadID, WM_DESTROY, 0, (LPARAM)this);
+ }
+ else
+ {
+ _CallQuit();
+ }
+ }
+}
+
+
+bool NativeModule::_LoadDll()
+{
+ bool bReturn = false;
+
+ if (!m_hInstance)
+ {
+ // Modules like popup2 like to call SetErrorMode. While that may not be
+ // good style, there is little we can do about it. However, LoadLibrary
+ // usually produces helpful error messages such as
+ // "msvcp70.dll not found" which are not displayed if a module has
+ // disabled them via SetErrorMode. We force their display here.
+ // First, make Windows display all errors
+ UINT uOldMode = SetErrorMode(0);
+
+ if ((m_hInstance = LoadLibraryW(GetLocation())) != nullptr)
+ {
+ AssignToFunction(m_pInit, (initModuleProc)GetProcAddress(
+ m_hInstance, "initModuleW"));
+
+ if (!m_pInit) // Might be a legacy module, check for initModuleEx
+ {
+ initModuleProcA pInit = (initModuleProcA)GetProcAddress(
+ m_hInstance, "initModuleEx");
+
+ if (!pInit) // Might be a BC module, check for underscore
+ {
+ pInit = (initModuleProcA)GetProcAddress(
+ m_hInstance, "_initModuleEx");
+ }
+
+ if (pInit)
+ {
+ m_pInit = [pInit](HWND hWnd, HINSTANCE hInst, LPCWSTR pwzPath) -> int {
+ char szPath[MAX_PATH];
+ WideCharToMultiByte(CP_ACP, 0, pwzPath, -1,
+ szPath, sizeof(szPath), "", nullptr);
+ return pInit(hWnd, hInst, szPath);
+ };
+ }
+ }
+
+ m_pQuit = (quitModuleProc)GetProcAddress(
+ m_hInstance, "quitModule");
+
+ if (!m_pQuit) // Might be a BC module, check for underscore
+ {
+ m_pQuit = (quitModuleProc)GetProcAddress(
+ m_hInstance, "_quitModule");
+ }
+
+ if (m_pInit == nullptr)
+ {
+ RESOURCE_STR(nullptr, IDS_INITMODULEEXNOTFOUND_ERROR,
+ L"Error: Could not find initModule().\n"
+ L"\n"
+ L"Please confirm that the dll is a LiteStep module,\n"
+ L"and check with the author for updates.");
+ }
+ else if (m_pQuit == nullptr)
+ {
+ RESOURCE_STR(nullptr, IDS_QUITMODULENOTFOUND_ERROR,
+ L"Error: Could not find quitModule().\n"
+ L"\n"
+ L"Please confirm that the dll is a LiteStep module.");
+ }
+ else
+ {
+ bReturn = true;
+ }
+ }
+ else
+ {
+ HRESULT hrError = HrGetLastError();
+
+#if defined(_WIN64)
+ if (GetModuleArchitecture(GetLocation()) == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+ {
+ RESOURCE_STR(nullptr, IDS_MODULEWRONGARCH64_ERROR,
+ L"Error: Could not load module.\n"
+ L"\n"
+ L"The module seems to compiled for 32-bit LiteStep. This is a 64-bit version of LiteStep, which can only load 64-bit modules.");
+ }
+#else
+ if (GetModuleArchitecture(GetLocation()) == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+ {
+ RESOURCE_STR(nullptr, IDS_MODULEWRONGARCH32_ERROR,
+ L"Error: Could not load module.\n"
+ L"\n"
+ L"The module seems to compiled for 64-bit LiteStep. This is a 32-bit version of LiteStep, which can only load 32-bit modules.");
+ }
+#endif
+ else if (PathFileExistsW(GetLocation()))
+ {
+ RESOURCE_STR(nullptr, IDS_MODULEDEPENDENCY_ERROR,
+ L"Error: Could not load module.\n"
+ L"\n"
+ L"This is likely a case of a missing C Run-Time Library"
+ L"or other dependency."
+ L"\n"
+ L"Error Information:"
+ L"\n");
+
+ size_t nLen = 0;
+ StringCchLengthW(resourceTextBuffer, _countof(resourceTextBuffer), &nLen);
+ DescriptionFromHR(hrError, resourceTextBuffer + nLen, _countof(resourceTextBuffer) - nLen);
+ }
+ else
+ {
+ RESOURCE_STR(nullptr, IDS_MODULENOTFOUND_ERROR,
+ L"Error: Could not locate module.\n"
+ L"\n"
+ L"Please check your configuration.");
+ }
+ }
+
+ // Second, restore the old state
+ SetErrorMode(uOldMode);
+
+ if (!bReturn)
+ {
+ LPCWSTR pwzFileName = PathFindFileNameW(GetLocation());
+
+ RESOURCE_MSGBOX_F(pwzFileName, MB_ICONERROR);
+
+ if (m_hInstance)
+ {
+ FreeLibrary(m_hInstance);
+ m_hInstance = nullptr;
+ }
+ }
+ }
+
+ return bReturn;
+}
+
+
+int NativeModule::_CallInit()
+{
+ ASSERT(m_pInit != nullptr);
+ return m_pInit(m_hMainWindow, m_hInstance, m_wzAppPath.c_str());
+}
+
+
+void NativeModule::_CallQuit()
+{
+ ASSERT(m_pQuit != NULL);
+ m_pQuit(m_hInstance);
+}
+
+
+
+UINT __stdcall NativeModule::ThreadProc(void* dllModPtr)
+{
+ NativeModule* dllMod = (NativeModule*)dllModPtr;
+
+#if defined(MSVC_DEBUG)
+ LPCTSTR pszFileName = PathFindFileName(dllMod->GetLocation());
+ DbgSetCurrentThreadName(WCSTOMBS(pszFileName));
+#endif
+
+ dllMod->_CallInit();
+
+ // We must use a copy of our event, and hope no one has closed it before
+ // waiting for it to be signaled. See: TakeThread() member function.
+ SetEvent(dllMod->m_hInitCopyEvent);
+
+ MSG msg;
+
+ while (GetMessage(&msg, 0, 0, 0) > 0)
+ {
+ if (msg.hwnd == NULL)
+ {
+ // Thread message
+ HandleThreadMessage(msg);
+ }
+ else
+ {
+ // Window message
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+
+ return 0;
+}
+
+
+void NativeModule::HandleThreadMessage(MSG &msg)
+{
+ switch (msg.message)
+ {
+ case LM_THREAD_BANGCOMMAND:
+ {
+ ThreadedBangCommand * pInfo = (ThreadedBangCommand*)msg.wParam;
+
+ if (pInfo != NULL)
+ {
+ pInfo->Execute();
+ pInfo->Release(); //check BangCommand.cpp for the reason
+ }
+ }
+ break;
+
+ case WM_DESTROY:
+ {
+ NativeModule *dll_mod = (NativeModule*)msg.lParam;
+
+ if (dll_mod)
+ {
+ dll_mod->_CallQuit();
+ PostQuitMessage(0);
+ }
+ }
+ break;
+
+ default:
+ {
+ // do nothing
+ }
+ break;
+ }
+}
diff --git a/litestep/NativeModule.h b/litestep/NativeModule.h
new file mode 100644
index 0000000..5d0991d
--- /dev/null
+++ b/litestep/NativeModule.h
@@ -0,0 +1,153 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#if !defined(NATIVE_MODULE_H)
+#define NATIVE_MODULE_H
+
+#include "Module.h"
+#include
+
+class NativeModule : public Module
+{
+private:
+ /** Instance handle of module's DLL */
+ HINSTANCE m_hInstance;
+
+ /** Thread handle */
+ HANDLE m_hThread;
+
+ /** LiteStep's main window handle */
+ HWND m_hMainWindow;
+
+ /** Thread ID */
+ DWORD m_dwThreadID;
+
+ /** Path to LiteStep's root directory */
+ std::basic_string m_wzAppPath;
+
+ /** Pointer to initModuleEx
function */
+ std::function m_pInit;
+
+ /** Pointer to quitModule
function */
+ quitModuleProc m_pQuit;
+
+ /**
+ * Event that is triggered when a threaded module completes initialization
+ */
+ HANDLE m_hInitEvent;
+ HANDLE m_hInitCopyEvent;
+
+public:
+ NativeModule(const std::wstring& sLocation, DWORD dwFlags);
+ virtual ~NativeModule();
+
+
+ bool Init(HWND hMainWindow, const std::wstring& sAppPath);
+
+ void Quit();
+
+ HINSTANCE GetInstance() const
+ {
+ return m_hInstance;
+ }
+
+ HANDLE GetThread() const
+ {
+ return m_hThread;
+ }
+
+ HANDLE TakeThread()
+ {
+ HANDLE hTemp = m_hThread;
+ m_hThread = nullptr;
+
+ return hTemp;
+ }
+
+ HANDLE GetInitEvent() const
+ {
+ return m_hInitEvent;
+ }
+
+ HANDLE TakeInitEvent()
+ {
+ HANDLE hTemp = m_hInitEvent;
+ m_hInitEvent = nullptr;
+
+ return hTemp;
+ }
+
+
+ /**
+ * Returns a pointer to this module's quitModule
function.
+ */
+ decltype(m_pQuit) GetQuit() const
+ {
+ return m_pQuit;
+ }
+
+ /**
+ * Returns a pointer to this module's initModuleEx
function.
+ */
+ decltype(m_pInit) GetInit() const
+ {
+ return m_pInit;
+ }
+
+ /**
+ * Entry point for the module's main thread.
+ *
+ * @param dllModPtr pointer to this
+ * @return unused
+ */
+ static UINT __stdcall ThreadProc(void* dllModPtr);
+
+ /**
+ * Handles messages sent to the module's main thread.
+ *
+ * @param msg message information
+ */
+ static void HandleThreadMessage(MSG &msg);
+
+private:
+ /**
+ * Loads this module's DLL.
+ *
+ * @return true
if successful or
+ * false
if an error occurs
+ */
+ bool _LoadDll();
+
+ /**
+ * Calls this module's initModuleEx
function.
+ *
+ * @return return value from initModuleEx
+ */
+ int _CallInit();
+
+ /**
+ * Calls this module's quitModule
function.
+ */
+ void _CallQuit();
+
+};
+
+#endif
\ No newline at end of file
diff --git a/litestep/litestep.vcxproj b/litestep/litestep.vcxproj
index e502c99..e86d905 100644
--- a/litestep/litestep.vcxproj
+++ b/litestep/litestep.vcxproj
@@ -23,6 +23,7 @@
{994556EE-2F21-4811-A85D-6925F7F84B0D}
litestep
Win32Proj
+ "Windows"
@@ -63,12 +64,17 @@
+
+ $(LibraryPath)
+ $(SolutionDir)bin\$(Configuration)_$(PlatformTarget)
+
LSAPI_PRIVATE;%(PreprocessorDefinitions)
+ false
- advapi32.lib;gdi32.lib;ole32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;%(AdditionalDependencies)
+ advapi32.lib;gdi32.lib;ole32.lib;oleaut32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;mscoree.lib;comsuppw.lib;%(AdditionalDependencies)
PerMonitorHighDPIAware
@@ -77,10 +83,12 @@
- LSAPI_PRIVATE;%(PreprocessorDefinitions)
+ LSAPI_PRIVATE;DEBUG;%(PreprocessorDefinitions)
+ false
+ Disabled
- advapi32.lib;gdi32.lib;ole32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;%(AdditionalDependencies)
+ advapi32.lib;gdi32.lib;ole32.lib;oleaut32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;mscoree.lib;comsuppw.lib;%(AdditionalDependencies)
PerMonitorHighDPIAware
@@ -102,9 +110,10 @@
LSAPI_PRIVATE;%(PreprocessorDefinitions)
+ false
- advapi32.lib;gdi32.lib;ole32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;%(AdditionalDependencies)
+ advapi32.lib;gdi32.lib;ole32.lib;oleaut32.lib;shell32.lib;shlwapi.lib;userenv.lib;uuid.lib;mscoree.lib;comsuppw.lib;%(AdditionalDependencies)
PerMonitorHighDPIAware
@@ -112,8 +121,10 @@
+
+
@@ -125,6 +136,7 @@
+
@@ -136,7 +148,9 @@
+
+
@@ -150,6 +164,8 @@
+
+
diff --git a/litestep/mscoree_core.h b/litestep/mscoree_core.h
new file mode 100644
index 0000000..a030585
--- /dev/null
+++ b/litestep/mscoree_core.h
@@ -0,0 +1,2930 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 8.00.0603 */
+/* @@MIDL_FILE_HEADING( ) */
+
+#pragma warning( disable: 4049 ) /* more than 64k source lines */
+
+
+/* verify that the version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 475
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of
+#endif // __RPCNDR_H_VERSION__
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+#ifndef __mscoree_h__
+#define __mscoree_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif
+
+/* Forward Declarations */
+
+#ifndef __IDebuggerThreadControl_FWD_DEFINED__
+#define __IDebuggerThreadControl_FWD_DEFINED__
+typedef interface IDebuggerThreadControl IDebuggerThreadControl;
+
+#endif /* __IDebuggerThreadControl_FWD_DEFINED__ */
+
+
+#ifndef __IDebuggerInfo_FWD_DEFINED__
+#define __IDebuggerInfo_FWD_DEFINED__
+typedef interface IDebuggerInfo IDebuggerInfo;
+
+#endif /* __IDebuggerInfo_FWD_DEFINED__ */
+
+
+#ifndef __ICLRErrorReportingManager_FWD_DEFINED__
+#define __ICLRErrorReportingManager_FWD_DEFINED__
+typedef interface ICLRErrorReportingManager ICLRErrorReportingManager;
+
+#endif /* __ICLRErrorReportingManager_FWD_DEFINED__ */
+
+
+#ifndef __ICLRErrorReportingManager2_FWD_DEFINED__
+#define __ICLRErrorReportingManager2_FWD_DEFINED__
+typedef interface ICLRErrorReportingManager2 ICLRErrorReportingManager2;
+
+#endif /* __ICLRErrorReportingManager2_FWD_DEFINED__ */
+
+
+#ifndef __ICLRPolicyManager_FWD_DEFINED__
+#define __ICLRPolicyManager_FWD_DEFINED__
+typedef interface ICLRPolicyManager ICLRPolicyManager;
+
+#endif /* __ICLRPolicyManager_FWD_DEFINED__ */
+
+
+#ifndef __ICLRGCManager_FWD_DEFINED__
+#define __ICLRGCManager_FWD_DEFINED__
+typedef interface ICLRGCManager ICLRGCManager;
+
+#endif /* __ICLRGCManager_FWD_DEFINED__ */
+
+
+#ifndef __ICLRGCManager2_FWD_DEFINED__
+#define __ICLRGCManager2_FWD_DEFINED__
+typedef interface ICLRGCManager2 ICLRGCManager2;
+
+#endif /* __ICLRGCManager2_FWD_DEFINED__ */
+
+
+#ifndef __IHostControl_FWD_DEFINED__
+#define __IHostControl_FWD_DEFINED__
+typedef interface IHostControl IHostControl;
+
+#endif /* __IHostControl_FWD_DEFINED__ */
+
+
+#ifndef __ICLRControl_FWD_DEFINED__
+#define __ICLRControl_FWD_DEFINED__
+typedef interface ICLRControl ICLRControl;
+
+#endif /* __ICLRControl_FWD_DEFINED__ */
+
+
+#ifndef __ICLRRuntimeHost_FWD_DEFINED__
+#define __ICLRRuntimeHost_FWD_DEFINED__
+typedef interface ICLRRuntimeHost ICLRRuntimeHost;
+
+#endif /* __ICLRRuntimeHost_FWD_DEFINED__ */
+
+
+#ifndef __ICLRRuntimeHost2_FWD_DEFINED__
+#define __ICLRRuntimeHost2_FWD_DEFINED__
+typedef interface ICLRRuntimeHost2 ICLRRuntimeHost2;
+
+#endif /* __ICLRRuntimeHost4_FWD_DEFINED__ */
+
+#ifndef __ICLRRuntimeHost4_FWD_DEFINED__
+#define __ICLRRuntimeHost4_FWD_DEFINED__
+typedef interface ICLRRuntimeHost4 ICLRRuntimeHost4;
+
+#endif /* __ICLRRuntimeHost4_FWD_DEFINED__ */
+
+#ifndef __ICLRExecutionManager_FWD_DEFINED__
+#define __ICLRExecutionManager_FWD_DEFINED__
+typedef interface ICLRExecutionManager ICLRExecutionManager;
+
+#endif /* __ICLRExecutionManager_FWD_DEFINED__ */
+
+
+#ifndef __IHostNetCFDebugControlManager_FWD_DEFINED__
+#define __IHostNetCFDebugControlManager_FWD_DEFINED__
+typedef interface IHostNetCFDebugControlManager IHostNetCFDebugControlManager;
+
+#endif /* __IHostNetCFDebugControlManager_FWD_DEFINED__ */
+
+
+#ifndef __ITypeName_FWD_DEFINED__
+#define __ITypeName_FWD_DEFINED__
+typedef interface ITypeName ITypeName;
+
+#endif /* __ITypeName_FWD_DEFINED__ */
+
+
+#ifndef __ITypeNameBuilder_FWD_DEFINED__
+#define __ITypeNameBuilder_FWD_DEFINED__
+typedef interface ITypeNameBuilder ITypeNameBuilder;
+
+#endif /* __ITypeNameBuilder_FWD_DEFINED__ */
+
+
+#ifndef __ITypeNameFactory_FWD_DEFINED__
+#define __ITypeNameFactory_FWD_DEFINED__
+typedef interface ITypeNameFactory ITypeNameFactory;
+
+#endif /* __ITypeNameFactory_FWD_DEFINED__ */
+
+
+#ifndef __IManagedObject_FWD_DEFINED__
+#define __IManagedObject_FWD_DEFINED__
+typedef interface IManagedObject IManagedObject;
+
+#endif /* __IManagedObject_FWD_DEFINED__ */
+
+
+#ifndef __ComCallUnmarshal_FWD_DEFINED__
+#define __ComCallUnmarshal_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class ComCallUnmarshal ComCallUnmarshal;
+#else
+typedef struct ComCallUnmarshal ComCallUnmarshal;
+#endif /* __cplusplus */
+
+#endif /* __ComCallUnmarshal_FWD_DEFINED__ */
+
+
+#ifndef __ComCallUnmarshalV4_FWD_DEFINED__
+#define __ComCallUnmarshalV4_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class ComCallUnmarshalV4 ComCallUnmarshalV4;
+#else
+typedef struct ComCallUnmarshalV4 ComCallUnmarshalV4;
+#endif /* __cplusplus */
+
+#endif /* __ComCallUnmarshalV4_FWD_DEFINED__ */
+
+
+#ifndef __CLRRuntimeHost_FWD_DEFINED__
+#define __CLRRuntimeHost_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class CLRRuntimeHost CLRRuntimeHost;
+#else
+typedef struct CLRRuntimeHost CLRRuntimeHost;
+#endif /* __cplusplus */
+
+#endif /* __CLRRuntimeHost_FWD_DEFINED__ */
+
+
+#ifndef __TypeNameFactory_FWD_DEFINED__
+#define __TypeNameFactory_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class TypeNameFactory TypeNameFactory;
+#else
+typedef struct TypeNameFactory TypeNameFactory;
+#endif /* __cplusplus */
+
+#endif /* __TypeNameFactory_FWD_DEFINED__ */
+
+
+#ifndef __ICLRAppDomainResourceMonitor_FWD_DEFINED__
+#define __ICLRAppDomainResourceMonitor_FWD_DEFINED__
+typedef interface ICLRAppDomainResourceMonitor ICLRAppDomainResourceMonitor;
+
+#endif /* __ICLRAppDomainResourceMonitor_FWD_DEFINED__ */
+
+
+/* header files for imported files */
+#include "unknwn.h"
+#include "gchost.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+
+/* interface __MIDL_itf_mscoree_0000_0000 */
+/* [local] */
+
+#define DECLARE_DEPRECATED
+#define DEPRECATED_CLR_STDAPI STDAPI
+
+struct IActivationFactory;
+
+EXTERN_GUID(CLSID_TypeNameFactory, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x25);
+EXTERN_GUID(CLSID_ComCallUnmarshal, 0x3F281000,0xE95A,0x11d2,0x88,0x6B,0x00,0xC0,0x4F,0x86,0x9F,0x04);
+EXTERN_GUID(CLSID_ComCallUnmarshalV4, 0x45fb4600,0xe6e8,0x4928,0xb2,0x5e,0x50,0x47,0x6f,0xf7,0x94,0x25);
+EXTERN_GUID(IID_IManagedObject, 0xc3fcc19e, 0xa970, 0x11d2, 0x8b, 0x5a, 0x00, 0xa0, 0xc9, 0xb7, 0xc9, 0xc4);
+EXTERN_GUID(IID_ICLRAppDomainResourceMonitor, 0XC62DE18C, 0X2E23, 0X4AEA, 0X84, 0X23, 0XB4, 0X0C, 0X1F, 0XC5, 0X9E, 0XAE);
+EXTERN_GUID(IID_ICLRPolicyManager, 0x7D290010, 0xD781, 0x45da, 0xA6, 0xF8, 0xAA, 0x5D, 0x71, 0x1A, 0x73, 0x0E);
+EXTERN_GUID(IID_ICLRGCManager, 0x54D9007E, 0xA8E2, 0x4885, 0xB7, 0xBF, 0xF9, 0x98, 0xDE, 0xEE, 0x4F, 0x2A);
+EXTERN_GUID(IID_ICLRGCManager2, 0x0603B793, 0xA97A, 0x4712, 0x9C, 0xB4, 0x0C, 0xD1, 0xC7, 0x4C, 0x0F, 0x7C);
+EXTERN_GUID(IID_ICLRErrorReportingManager, 0x980d2f1a, 0xbf79, 0x4c08, 0x81, 0x2a, 0xbb, 0x97, 0x78, 0x92, 0x8f, 0x78);
+EXTERN_GUID(IID_ICLRErrorReportingManager2, 0xc68f63b1, 0x4d8b, 0x4e0b, 0x95, 0x64, 0x9d, 0x2e, 0xfe, 0x2f, 0xa1, 0x8c);
+EXTERN_GUID(IID_ICLRRuntimeHost, 0x90F1A06C, 0x7712, 0x4762, 0x86, 0xB5, 0x7A, 0x5E, 0xBA, 0x6B, 0xDB, 0x02);
+EXTERN_GUID(IID_ICLRRuntimeHost2, 0x712AB73F, 0x2C22, 0x4807, 0xAD, 0x7E, 0xF5, 0x01, 0xD7, 0xb7, 0x2C, 0x2D);
+EXTERN_GUID(IID_ICLRRuntimeHost4, 0x64F6D366, 0xD7C2, 0x4F1F, 0xB4, 0xB2, 0xE8, 0x16, 0x0C, 0xAC, 0x43, 0xAF);
+EXTERN_GUID(IID_ICLRExecutionManager, 0x1000A3E7, 0xB420, 0x4620, 0xAE, 0x30, 0xFB, 0x19, 0xB5, 0x87, 0xAD, 0x1D);
+EXTERN_GUID(IID_ITypeName, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x22);
+EXTERN_GUID(IID_ITypeNameBuilder, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x23);
+EXTERN_GUID(IID_ITypeNameFactory, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x21);
+DEPRECATED_CLR_STDAPI GetCORSystemDirectory(_Out_writes_to_(cchBuffer, *dwLength) LPWSTR pbuffer, DWORD cchBuffer, DWORD* dwLength);
+DEPRECATED_CLR_STDAPI GetCORVersion(_Out_writes_to_(cchBuffer, *dwLength) LPWSTR pbBuffer, DWORD cchBuffer, DWORD* dwLength);
+DEPRECATED_CLR_STDAPI GetFileVersion(LPCWSTR szFilename, _Out_writes_to_opt_(cchBuffer, *dwLength) LPWSTR szBuffer, DWORD cchBuffer, DWORD* dwLength);
+DEPRECATED_CLR_STDAPI GetCORRequiredVersion(_Out_writes_to_(cchBuffer, *dwLength) LPWSTR pbuffer, DWORD cchBuffer, DWORD* dwLength);
+DEPRECATED_CLR_STDAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile, DWORD startupFlags, DWORD runtimeInfoFlags, _Out_writes_opt_(dwDirectory) LPWSTR pDirectory, DWORD dwDirectory, _Out_opt_ DWORD *dwDirectoryLength, _Out_writes_opt_(cchBuffer) LPWSTR pVersion, DWORD cchBuffer, _Out_opt_ DWORD* dwlength);
+DEPRECATED_CLR_STDAPI GetRequestedRuntimeVersion(_In_ LPWSTR pExe, _Out_writes_to_(cchBuffer, *dwLength) LPWSTR pVersion, DWORD cchBuffer, _Out_ DWORD* dwLength);
+DEPRECATED_CLR_STDAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, LPCWSTR pwszHostConfigFile, VOID* pReserved, DWORD startupFlags, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);
+DEPRECATED_CLR_STDAPI CorBindToRuntimeEx(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, DWORD startupFlags, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);
+DEPRECATED_CLR_STDAPI CorBindToRuntimeByCfg(IStream* pCfgStream, DWORD reserved, DWORD startupFlags, REFCLSID rclsid,REFIID riid, LPVOID FAR* ppv);
+DEPRECATED_CLR_STDAPI CorBindToRuntime(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);
+DEPRECATED_CLR_STDAPI CorBindToCurrentRuntime(LPCWSTR pwszFileName, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);
+DEPRECATED_CLR_STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void **ppObject);
+DECLARE_DEPRECATED void STDMETHODCALLTYPE CorMarkThreadInThreadPool();
+DEPRECATED_CLR_STDAPI RunDll32ShimW(HWND hwnd, HINSTANCE hinst, LPCWSTR lpszCmdLine, int nCmdShow);
+DEPRECATED_CLR_STDAPI LoadLibraryShim(LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE *phModDll);
+DEPRECATED_CLR_STDAPI CallFunctionShim(LPCWSTR szDllName, LPCSTR szFunctionName, LPVOID lpvArgument1, LPVOID lpvArgument2, LPCWSTR szVersion, LPVOID pvReserved);
+DEPRECATED_CLR_STDAPI GetRealProcAddress(LPCSTR pwszProcName, VOID** ppv);
+DECLARE_DEPRECATED void STDMETHODCALLTYPE CorExitProcess(int exitCode);
+DEPRECATED_CLR_STDAPI LoadStringRC(UINT iResouceID, _Out_writes_z_(iMax) LPWSTR szBuffer, int iMax, int bQuiet);
+typedef HRESULT (STDAPICALLTYPE *FnGetCLRRuntimeHost)(REFIID riid, IUnknown **pUnk);
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0000_0001
+ {
+ HOST_TYPE_DEFAULT = 0,
+ HOST_TYPE_APPLAUNCH = 0x1,
+ HOST_TYPE_CORFLAG = 0x2
+ } HOST_TYPE;
+
+STDAPI CorLaunchApplication(HOST_TYPE dwClickOnceHost, LPCWSTR pwzAppFullName, DWORD dwManifestPaths, LPCWSTR* ppwzManifestPaths, DWORD dwActivationData, LPCWSTR* ppwzActivationData, LPPROCESS_INFORMATION lpProcessInformation);
+typedef HRESULT ( __stdcall *FExecuteInAppDomainCallback )(
+ void *cookie);
+
+typedef /* [public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0000_0002
+ {
+ STARTUP_CONCURRENT_GC = 0x1,
+ STARTUP_LOADER_OPTIMIZATION_MASK = ( 0x3 << 1 ) ,
+ STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN = ( 0x1 << 1 ) ,
+ STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN = ( 0x2 << 1 ) ,
+ STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST = ( 0x3 << 1 ) ,
+ STARTUP_LOADER_SAFEMODE = 0x10,
+ STARTUP_LOADER_SETPREFERENCE = 0x100,
+ STARTUP_SERVER_GC = 0x1000,
+ STARTUP_HOARD_GC_VM = 0x2000,
+ STARTUP_SINGLE_VERSION_HOSTING_INTERFACE = 0x4000,
+ STARTUP_LEGACY_IMPERSONATION = 0x10000,
+ STARTUP_DISABLE_COMMITTHREADSTACK = 0x20000,
+ STARTUP_ALWAYSFLOW_IMPERSONATION = 0x40000,
+ STARTUP_TRIM_GC_COMMIT = 0x80000,
+ STARTUP_ETW = 0x100000,
+ STARTUP_ARM = 0x400000,
+ STARTUP_SINGLE_APPDOMAIN = 0x800000,
+ STARTUP_APPX_APP_MODEL = 0x1000000,
+ STARTUP_DISABLE_RANDOMIZED_STRING_HASHING = 0x2000000 // not supported
+ } STARTUP_FLAGS;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0000_0003
+ {
+ CLSID_RESOLUTION_DEFAULT = 0,
+ CLSID_RESOLUTION_REGISTERED = 0x1
+ } CLSID_RESOLUTION_FLAGS;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0000_0004
+ {
+ RUNTIME_INFO_UPGRADE_VERSION = 0x1,
+ RUNTIME_INFO_REQUEST_IA64 = 0x2,
+ RUNTIME_INFO_REQUEST_AMD64 = 0x4,
+ RUNTIME_INFO_REQUEST_X86 = 0x8,
+ RUNTIME_INFO_DONT_RETURN_DIRECTORY = 0x10,
+ RUNTIME_INFO_DONT_RETURN_VERSION = 0x20,
+ RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG = 0x40,
+ RUNTIME_INFO_IGNORE_ERROR_MODE = 0x1000
+ } RUNTIME_INFO_FLAGS;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0000_0005
+ {
+ APPDOMAIN_SECURITY_DEFAULT = 0,
+ APPDOMAIN_SECURITY_SANDBOXED = 0x1,
+ APPDOMAIN_SECURITY_FORBID_CROSSAD_REVERSE_PINVOKE = 0x2,
+ APPDOMAIN_IGNORE_UNHANDLED_EXCEPTIONS = 0x4,
+ APPDOMAIN_FORCE_TRIVIAL_WAIT_OPERATIONS = 0x8,
+ APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP = 0x10,
+ APPDOMAIN_SET_TEST_KEY = 0x20,
+ APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS = 0x40,
+ APPDOMAIN_ENABLE_ASSEMBLY_LOADFILE = 0x80,
+ APPDOMAIN_DISABLE_TRANSPARENCY_ENFORCEMENT = 0x100
+ } APPDOMAIN_SECURITY_FLAGS;
+
+STDAPI GetRequestedRuntimeVersionForCLSID(REFCLSID rclsid, _Out_writes_opt_(cchBuffer) LPWSTR pVersion, DWORD cchBuffer, _Out_opt_ DWORD* dwLength, CLSID_RESOLUTION_FLAGS dwResolutionFlags);
+EXTERN_GUID(IID_IDebuggerThreadControl, 0x23d86786, 0x0bb5, 0x4774, 0x8f, 0xb5, 0xe3, 0x52, 0x2a, 0xdd, 0x62, 0x46);
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0000_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0000_v0_0_s_ifspec;
+
+#ifndef __IDebuggerThreadControl_INTERFACE_DEFINED__
+#define __IDebuggerThreadControl_INTERFACE_DEFINED__
+
+/* interface IDebuggerThreadControl */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_IDebuggerThreadControl;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("23D86786-0BB5-4774-8FB5-E3522ADD6246")
+ IDebuggerThreadControl : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE ThreadIsBlockingForDebugger( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ReleaseAllRuntimeThreads( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE StartBlockingForDebugger(
+ DWORD dwUnused) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IDebuggerThreadControlVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IDebuggerThreadControl * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IDebuggerThreadControl * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IDebuggerThreadControl * This);
+
+ HRESULT ( STDMETHODCALLTYPE *ThreadIsBlockingForDebugger )(
+ IDebuggerThreadControl * This);
+
+ HRESULT ( STDMETHODCALLTYPE *ReleaseAllRuntimeThreads )(
+ IDebuggerThreadControl * This);
+
+ HRESULT ( STDMETHODCALLTYPE *StartBlockingForDebugger )(
+ IDebuggerThreadControl * This,
+ DWORD dwUnused);
+
+ END_INTERFACE
+ } IDebuggerThreadControlVtbl;
+
+ interface IDebuggerThreadControl
+ {
+ CONST_VTBL struct IDebuggerThreadControlVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IDebuggerThreadControl_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IDebuggerThreadControl_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IDebuggerThreadControl_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IDebuggerThreadControl_ThreadIsBlockingForDebugger(This) \
+ ( (This)->lpVtbl -> ThreadIsBlockingForDebugger(This) )
+
+#define IDebuggerThreadControl_ReleaseAllRuntimeThreads(This) \
+ ( (This)->lpVtbl -> ReleaseAllRuntimeThreads(This) )
+
+#define IDebuggerThreadControl_StartBlockingForDebugger(This,dwUnused) \
+ ( (This)->lpVtbl -> StartBlockingForDebugger(This,dwUnused) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IDebuggerThreadControl_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0001 */
+/* [local] */
+
+EXTERN_GUID(IID_IDebuggerInfo, 0xbf24142d, 0xa47d, 0x4d24, 0xa6, 0x6d, 0x8c, 0x21, 0x41, 0x94, 0x4e, 0x44);
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0001_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0001_v0_0_s_ifspec;
+
+#ifndef __IDebuggerInfo_INTERFACE_DEFINED__
+#define __IDebuggerInfo_INTERFACE_DEFINED__
+
+/* interface IDebuggerInfo */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_IDebuggerInfo;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("BF24142D-A47D-4d24-A66D-8C2141944E44")
+ IDebuggerInfo : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE IsDebuggerAttached(
+ /* [out] */ BOOL *pbAttached) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IDebuggerInfoVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IDebuggerInfo * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IDebuggerInfo * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IDebuggerInfo * This);
+
+ HRESULT ( STDMETHODCALLTYPE *IsDebuggerAttached )(
+ IDebuggerInfo * This,
+ /* [out] */ BOOL *pbAttached);
+
+ END_INTERFACE
+ } IDebuggerInfoVtbl;
+
+ interface IDebuggerInfo
+ {
+ CONST_VTBL struct IDebuggerInfoVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IDebuggerInfo_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IDebuggerInfo_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IDebuggerInfo_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IDebuggerInfo_IsDebuggerAttached(This,pbAttached) \
+ ( (This)->lpVtbl -> IsDebuggerAttached(This,pbAttached) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IDebuggerInfo_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0002 */
+/* [local] */
+
+typedef void *HDOMAINENUM;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0001
+ {
+ eMemoryAvailableLow = 1,
+ eMemoryAvailableNeutral = 2,
+ eMemoryAvailableHigh = 3
+ } EMemoryAvailable;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0002
+ {
+ eTaskCritical = 0,
+ eAppDomainCritical = 1,
+ eProcessCritical = 2
+ } EMemoryCriticalLevel;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0003
+ {
+ WAIT_MSGPUMP = 0x1,
+ WAIT_ALERTABLE = 0x2,
+ WAIT_NOTINDEADLOCK = 0x4
+ } WAIT_OPTION;
+
+typedef UINT64 TASKID;
+
+typedef DWORD CONNID;
+
+typedef
+enum ETaskType
+ {
+ TT_DEBUGGERHELPER = 0x1,
+ TT_GC = 0x2,
+ TT_FINALIZER = 0x4,
+ TT_THREADPOOL_TIMER = 0x8,
+ TT_THREADPOOL_GATE = 0x10,
+ TT_THREADPOOL_WORKER = 0x20,
+ TT_THREADPOOL_IOCOMPLETION = 0x40,
+ TT_ADUNLOAD = 0x80,
+ TT_USER = 0x100,
+ TT_THREADPOOL_WAIT = 0x200,
+ TT_UNKNOWN = 0x80000000
+ } ETaskType;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0004
+ {
+ eSymbolReadingNever = 0,
+ eSymbolReadingAlways = 1,
+ eSymbolReadingFullTrustOnly = 2
+ } ESymbolReadingPolicy;
+
+typedef /* [public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0005
+ {
+ DUMP_FLAVOR_Mini = 0,
+ DUMP_FLAVOR_CriticalCLRState = 1,
+ DUMP_FLAVOR_NonHeapCLRState = 2,
+ DUMP_FLAVOR_Default = DUMP_FLAVOR_Mini
+ } ECustomDumpFlavor;
+
+typedef /* [public][public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0006
+ {
+ DUMP_ITEM_None = 0
+ } ECustomDumpItemKind;
+
+typedef /* [public][public] */ struct __MIDL___MIDL_itf_mscoree_0000_0002_0007
+ {
+ ECustomDumpItemKind itemKind;
+ union
+ {
+ UINT_PTR pReserved;
+ } ;
+ } CustomDumpItem;
+
+#define BucketParamsCount ( 10 )
+
+#define BucketParamLength ( 255 )
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0002_0009
+ {
+ Parameter1 = 0,
+ Parameter2 = ( Parameter1 + 1 ) ,
+ Parameter3 = ( Parameter2 + 1 ) ,
+ Parameter4 = ( Parameter3 + 1 ) ,
+ Parameter5 = ( Parameter4 + 1 ) ,
+ Parameter6 = ( Parameter5 + 1 ) ,
+ Parameter7 = ( Parameter6 + 1 ) ,
+ Parameter8 = ( Parameter7 + 1 ) ,
+ Parameter9 = ( Parameter8 + 1 ) ,
+ InvalidBucketParamIndex = ( Parameter9 + 1 )
+ } BucketParameterIndex;
+
+typedef struct _BucketParameters
+ {
+ BOOL fInited;
+ WCHAR pszEventTypeName[ 255 ];
+ WCHAR pszParams[ 10 ][ 255 ];
+ } BucketParameters;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0002_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0002_v0_0_s_ifspec;
+
+#ifndef __ICLRErrorReportingManager_INTERFACE_DEFINED__
+#define __ICLRErrorReportingManager_INTERFACE_DEFINED__
+
+/* interface ICLRErrorReportingManager */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRErrorReportingManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("980D2F1A-BF79-4c08-812A-BB9778928F78")
+ ICLRErrorReportingManager : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetBucketParametersForCurrentException(
+ /* [out] */ BucketParameters *pParams) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE BeginCustomDump(
+ /* [in] */ ECustomDumpFlavor dwFlavor,
+ /* [in] */ DWORD dwNumItems,
+ /* [length_is][size_is][in] */ CustomDumpItem *items,
+ DWORD dwReserved) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE EndCustomDump( void) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRErrorReportingManagerVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRErrorReportingManager * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRErrorReportingManager * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRErrorReportingManager * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetBucketParametersForCurrentException )(
+ ICLRErrorReportingManager * This,
+ /* [out] */ BucketParameters *pParams);
+
+ HRESULT ( STDMETHODCALLTYPE *BeginCustomDump )(
+ ICLRErrorReportingManager * This,
+ /* [in] */ ECustomDumpFlavor dwFlavor,
+ /* [in] */ DWORD dwNumItems,
+ /* [length_is][size_is][in] */ CustomDumpItem *items,
+ DWORD dwReserved);
+
+ HRESULT ( STDMETHODCALLTYPE *EndCustomDump )(
+ ICLRErrorReportingManager * This);
+
+ END_INTERFACE
+ } ICLRErrorReportingManagerVtbl;
+
+ interface ICLRErrorReportingManager
+ {
+ CONST_VTBL struct ICLRErrorReportingManagerVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRErrorReportingManager_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRErrorReportingManager_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRErrorReportingManager_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRErrorReportingManager_GetBucketParametersForCurrentException(This,pParams) \
+ ( (This)->lpVtbl -> GetBucketParametersForCurrentException(This,pParams) )
+
+#define ICLRErrorReportingManager_BeginCustomDump(This,dwFlavor,dwNumItems,items,dwReserved) \
+ ( (This)->lpVtbl -> BeginCustomDump(This,dwFlavor,dwNumItems,items,dwReserved) )
+
+#define ICLRErrorReportingManager_EndCustomDump(This) \
+ ( (This)->lpVtbl -> EndCustomDump(This) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRErrorReportingManager_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0003 */
+/* [local] */
+
+typedef /* [public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0003_0001
+ {
+ ApplicationID = 0x1,
+ InstanceID = 0x2
+ } ApplicationDataKey;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0003_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0003_v0_0_s_ifspec;
+
+#ifndef __ICLRErrorReportingManager2_INTERFACE_DEFINED__
+#define __ICLRErrorReportingManager2_INTERFACE_DEFINED__
+
+/* interface ICLRErrorReportingManager2 */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRErrorReportingManager2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("C68F63B1-4D8B-4E0B-9564-9D2EFE2FA18C")
+ ICLRErrorReportingManager2 : public ICLRErrorReportingManager
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE SetApplicationData(
+ /* [in] */ ApplicationDataKey key,
+ /* [in] */ const WCHAR *pValue) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetBucketParametersForUnhandledException(
+ /* [in] */ const BucketParameters *pBucketParams,
+ /* [out] */ DWORD *pCountParams) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRErrorReportingManager2Vtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRErrorReportingManager2 * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRErrorReportingManager2 * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRErrorReportingManager2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetBucketParametersForCurrentException )(
+ ICLRErrorReportingManager2 * This,
+ /* [out] */ BucketParameters *pParams);
+
+ HRESULT ( STDMETHODCALLTYPE *BeginCustomDump )(
+ ICLRErrorReportingManager2 * This,
+ /* [in] */ ECustomDumpFlavor dwFlavor,
+ /* [in] */ DWORD dwNumItems,
+ /* [length_is][size_is][in] */ CustomDumpItem *items,
+ DWORD dwReserved);
+
+ HRESULT ( STDMETHODCALLTYPE *EndCustomDump )(
+ ICLRErrorReportingManager2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *SetApplicationData )(
+ ICLRErrorReportingManager2 * This,
+ /* [in] */ ApplicationDataKey key,
+ /* [in] */ const WCHAR *pValue);
+
+ HRESULT ( STDMETHODCALLTYPE *SetBucketParametersForUnhandledException )(
+ ICLRErrorReportingManager2 * This,
+ /* [in] */ const BucketParameters *pBucketParams,
+ /* [out] */ DWORD *pCountParams);
+
+ END_INTERFACE
+ } ICLRErrorReportingManager2Vtbl;
+
+ interface ICLRErrorReportingManager2
+ {
+ CONST_VTBL struct ICLRErrorReportingManager2Vtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRErrorReportingManager2_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRErrorReportingManager2_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRErrorReportingManager2_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRErrorReportingManager2_GetBucketParametersForCurrentException(This,pParams) \
+ ( (This)->lpVtbl -> GetBucketParametersForCurrentException(This,pParams) )
+
+#define ICLRErrorReportingManager2_BeginCustomDump(This,dwFlavor,dwNumItems,items,dwReserved) \
+ ( (This)->lpVtbl -> BeginCustomDump(This,dwFlavor,dwNumItems,items,dwReserved) )
+
+#define ICLRErrorReportingManager2_EndCustomDump(This) \
+ ( (This)->lpVtbl -> EndCustomDump(This) )
+
+
+#define ICLRErrorReportingManager2_SetApplicationData(This,key,pValue) \
+ ( (This)->lpVtbl -> SetApplicationData(This,key,pValue) )
+
+#define ICLRErrorReportingManager2_SetBucketParametersForUnhandledException(This,pBucketParams,pCountParams) \
+ ( (This)->lpVtbl -> SetBucketParametersForUnhandledException(This,pBucketParams,pCountParams) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRErrorReportingManager2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0004 */
+/* [local] */
+
+typedef /* [public][public][public][public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0004_0001
+ {
+ OPR_ThreadAbort = 0,
+ OPR_ThreadRudeAbortInNonCriticalRegion = ( OPR_ThreadAbort + 1 ) ,
+ OPR_ThreadRudeAbortInCriticalRegion = ( OPR_ThreadRudeAbortInNonCriticalRegion + 1 ) ,
+ OPR_AppDomainUnload = ( OPR_ThreadRudeAbortInCriticalRegion + 1 ) ,
+ OPR_AppDomainRudeUnload = ( OPR_AppDomainUnload + 1 ) ,
+ OPR_ProcessExit = ( OPR_AppDomainRudeUnload + 1 ) ,
+ OPR_FinalizerRun = ( OPR_ProcessExit + 1 ) ,
+ MaxClrOperation = ( OPR_FinalizerRun + 1 )
+ } EClrOperation;
+
+typedef /* [public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0004_0002
+ {
+ FAIL_NonCriticalResource = 0,
+ FAIL_CriticalResource = ( FAIL_NonCriticalResource + 1 ) ,
+ FAIL_FatalRuntime = ( FAIL_CriticalResource + 1 ) ,
+ FAIL_OrphanedLock = ( FAIL_FatalRuntime + 1 ) ,
+ FAIL_StackOverflow = ( FAIL_OrphanedLock + 1 ) ,
+ FAIL_AccessViolation = ( FAIL_StackOverflow + 1 ) ,
+ FAIL_CodeContract = ( FAIL_AccessViolation + 1 ) ,
+ MaxClrFailure = ( FAIL_CodeContract + 1 )
+ } EClrFailure;
+
+typedef /* [public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0004_0003
+ {
+ eRuntimeDeterminedPolicy = 0,
+ eHostDeterminedPolicy = ( eRuntimeDeterminedPolicy + 1 )
+ } EClrUnhandledException;
+
+typedef /* [public][public][public][public][public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0004_0004
+ {
+ eNoAction = 0,
+ eThrowException = ( eNoAction + 1 ) ,
+ eAbortThread = ( eThrowException + 1 ) ,
+ eRudeAbortThread = ( eAbortThread + 1 ) ,
+ eUnloadAppDomain = ( eRudeAbortThread + 1 ) ,
+ eRudeUnloadAppDomain = ( eUnloadAppDomain + 1 ) ,
+ eExitProcess = ( eRudeUnloadAppDomain + 1 ) ,
+ eFastExitProcess = ( eExitProcess + 1 ) ,
+ eRudeExitProcess = ( eFastExitProcess + 1 ) ,
+ eDisableRuntime = ( eRudeExitProcess + 1 ) ,
+ MaxPolicyAction = ( eDisableRuntime + 1 )
+ } EPolicyAction;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0004_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0004_v0_0_s_ifspec;
+
+#ifndef __ICLRPolicyManager_INTERFACE_DEFINED__
+#define __ICLRPolicyManager_INTERFACE_DEFINED__
+
+/* interface ICLRPolicyManager */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRPolicyManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("7D290010-D781-45da-A6F8-AA5D711A730E")
+ ICLRPolicyManager : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE SetDefaultAction(
+ /* [in] */ EClrOperation operation,
+ /* [in] */ EPolicyAction action) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetTimeout(
+ /* [in] */ EClrOperation operation,
+ /* [in] */ DWORD dwMilliseconds) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetActionOnTimeout(
+ /* [in] */ EClrOperation operation,
+ /* [in] */ EPolicyAction action) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetTimeoutAndAction(
+ /* [in] */ EClrOperation operation,
+ /* [in] */ DWORD dwMilliseconds,
+ /* [in] */ EPolicyAction action) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetActionOnFailure(
+ /* [in] */ EClrFailure failure,
+ /* [in] */ EPolicyAction action) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetUnhandledExceptionPolicy(
+ /* [in] */ EClrUnhandledException policy) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRPolicyManagerVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRPolicyManager * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRPolicyManager * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRPolicyManager * This);
+
+ HRESULT ( STDMETHODCALLTYPE *SetDefaultAction )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrOperation operation,
+ /* [in] */ EPolicyAction action);
+
+ HRESULT ( STDMETHODCALLTYPE *SetTimeout )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrOperation operation,
+ /* [in] */ DWORD dwMilliseconds);
+
+ HRESULT ( STDMETHODCALLTYPE *SetActionOnTimeout )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrOperation operation,
+ /* [in] */ EPolicyAction action);
+
+ HRESULT ( STDMETHODCALLTYPE *SetTimeoutAndAction )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrOperation operation,
+ /* [in] */ DWORD dwMilliseconds,
+ /* [in] */ EPolicyAction action);
+
+ HRESULT ( STDMETHODCALLTYPE *SetActionOnFailure )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrFailure failure,
+ /* [in] */ EPolicyAction action);
+
+ HRESULT ( STDMETHODCALLTYPE *SetUnhandledExceptionPolicy )(
+ ICLRPolicyManager * This,
+ /* [in] */ EClrUnhandledException policy);
+
+ END_INTERFACE
+ } ICLRPolicyManagerVtbl;
+
+ interface ICLRPolicyManager
+ {
+ CONST_VTBL struct ICLRPolicyManagerVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRPolicyManager_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRPolicyManager_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRPolicyManager_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRPolicyManager_SetDefaultAction(This,operation,action) \
+ ( (This)->lpVtbl -> SetDefaultAction(This,operation,action) )
+
+#define ICLRPolicyManager_SetTimeout(This,operation,dwMilliseconds) \
+ ( (This)->lpVtbl -> SetTimeout(This,operation,dwMilliseconds) )
+
+#define ICLRPolicyManager_SetActionOnTimeout(This,operation,action) \
+ ( (This)->lpVtbl -> SetActionOnTimeout(This,operation,action) )
+
+#define ICLRPolicyManager_SetTimeoutAndAction(This,operation,dwMilliseconds,action) \
+ ( (This)->lpVtbl -> SetTimeoutAndAction(This,operation,dwMilliseconds,action) )
+
+#define ICLRPolicyManager_SetActionOnFailure(This,failure,action) \
+ ( (This)->lpVtbl -> SetActionOnFailure(This,failure,action) )
+
+#define ICLRPolicyManager_SetUnhandledExceptionPolicy(This,policy) \
+ ( (This)->lpVtbl -> SetUnhandledExceptionPolicy(This,policy) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRPolicyManager_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0005 */
+/* [local] */
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0005_0001
+ {
+ Event_DomainUnload = 0,
+ Event_ClrDisabled = ( Event_DomainUnload + 1 ) ,
+ Event_MDAFired = ( Event_ClrDisabled + 1 ) ,
+ Event_StackOverflow = ( Event_MDAFired + 1 ) ,
+ MaxClrEvent = ( Event_StackOverflow + 1 )
+ } EClrEvent;
+
+typedef struct _MDAInfo
+ {
+ LPCWSTR lpMDACaption;
+ LPCWSTR lpMDAMessage;
+ LPCWSTR lpStackTrace;
+ } MDAInfo;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0005_0002
+ {
+ SO_Managed = 0,
+ SO_ClrEngine = ( SO_Managed + 1 ) ,
+ SO_Other = ( SO_ClrEngine + 1 )
+ } StackOverflowType;
+
+typedef struct _StackOverflowInfo
+{
+ StackOverflowType soType;
+ EXCEPTION_POINTERS *pExceptionInfo;
+} StackOverflowInfo;
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0005_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0005_v0_0_s_ifspec;
+
+#ifndef __ICLRGCManager_INTERFACE_DEFINED__
+#define __ICLRGCManager_INTERFACE_DEFINED__
+
+/* interface ICLRGCManager */
+/* [object][local][unique][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRGCManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("54D9007E-A8E2-4885-B7BF-F998DEEE4F2A")
+ ICLRGCManager : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE Collect(
+ /* [in] */ LONG Generation) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetStats(
+ /* [out][in] */ COR_GC_STATS *pStats) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetGCStartupLimits(
+ /* [in] */ DWORD SegmentSize,
+ /* [in] */ DWORD MaxGen0Size) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRGCManagerVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRGCManager * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRGCManager * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRGCManager * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Collect )(
+ ICLRGCManager * This,
+ /* [in] */ LONG Generation);
+
+ HRESULT ( STDMETHODCALLTYPE *GetStats )(
+ ICLRGCManager * This,
+ /* [out][in] */ COR_GC_STATS *pStats);
+
+ HRESULT ( STDMETHODCALLTYPE *SetGCStartupLimits )(
+ ICLRGCManager * This,
+ /* [in] */ DWORD SegmentSize,
+ /* [in] */ DWORD MaxGen0Size);
+
+ END_INTERFACE
+ } ICLRGCManagerVtbl;
+
+ interface ICLRGCManager
+ {
+ CONST_VTBL struct ICLRGCManagerVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRGCManager_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRGCManager_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRGCManager_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRGCManager_Collect(This,Generation) \
+ ( (This)->lpVtbl -> Collect(This,Generation) )
+
+#define ICLRGCManager_GetStats(This,pStats) \
+ ( (This)->lpVtbl -> GetStats(This,pStats) )
+
+#define ICLRGCManager_SetGCStartupLimits(This,SegmentSize,MaxGen0Size) \
+ ( (This)->lpVtbl -> SetGCStartupLimits(This,SegmentSize,MaxGen0Size) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRGCManager_INTERFACE_DEFINED__ */
+
+
+#ifndef __ICLRGCManager2_INTERFACE_DEFINED__
+#define __ICLRGCManager2_INTERFACE_DEFINED__
+
+/* interface ICLRGCManager2 */
+/* [object][local][unique][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRGCManager2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("0603B793-A97A-4712-9CB4-0CD1C74C0F7C")
+ ICLRGCManager2 : public ICLRGCManager
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE SetGCStartupLimitsEx(
+ /* [in] */ SIZE_T SegmentSize,
+ /* [in] */ SIZE_T MaxGen0Size) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRGCManager2Vtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRGCManager2 * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRGCManager2 * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRGCManager2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Collect )(
+ ICLRGCManager2 * This,
+ /* [in] */ LONG Generation);
+
+ HRESULT ( STDMETHODCALLTYPE *GetStats )(
+ ICLRGCManager2 * This,
+ /* [out][in] */ COR_GC_STATS *pStats);
+
+ HRESULT ( STDMETHODCALLTYPE *SetGCStartupLimits )(
+ ICLRGCManager2 * This,
+ /* [in] */ DWORD SegmentSize,
+ /* [in] */ DWORD MaxGen0Size);
+
+ HRESULT ( STDMETHODCALLTYPE *SetGCStartupLimitsEx )(
+ ICLRGCManager2 * This,
+ /* [in] */ SIZE_T SegmentSize,
+ /* [in] */ SIZE_T MaxGen0Size);
+
+ END_INTERFACE
+ } ICLRGCManager2Vtbl;
+
+ interface ICLRGCManager2
+ {
+ CONST_VTBL struct ICLRGCManager2Vtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRGCManager2_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRGCManager2_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRGCManager2_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRGCManager2_Collect(This,Generation) \
+ ( (This)->lpVtbl -> Collect(This,Generation) )
+
+#define ICLRGCManager2_GetStats(This,pStats) \
+ ( (This)->lpVtbl -> GetStats(This,pStats) )
+
+#define ICLRGCManager2_SetGCStartupLimits(This,SegmentSize,MaxGen0Size) \
+ ( (This)->lpVtbl -> SetGCStartupLimits(This,SegmentSize,MaxGen0Size) )
+
+
+#define ICLRGCManager2_SetGCStartupLimitsEx(This,SegmentSize,MaxGen0Size) \
+ ( (This)->lpVtbl -> SetGCStartupLimitsEx(This,SegmentSize,MaxGen0Size) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRGCManager2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0007 */
+/* [local] */
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0007_0001
+ {
+ ePolicyLevelNone = 0,
+ ePolicyLevelRetargetable = 0x1,
+ ePolicyUnifiedToCLR = 0x2,
+ ePolicyLevelApp = 0x4,
+ ePolicyLevelPublisher = 0x8,
+ ePolicyLevelHost = 0x10,
+ ePolicyLevelAdmin = 0x20,
+ ePolicyPortability = 0x40
+ } EBindPolicyLevels;
+
+typedef struct _AssemblyBindInfo
+ {
+ DWORD dwAppDomainId;
+ LPCWSTR lpReferencedIdentity;
+ LPCWSTR lpPostPolicyIdentity;
+ DWORD ePolicyLevel;
+ } AssemblyBindInfo;
+
+typedef struct _ModuleBindInfo
+ {
+ DWORD dwAppDomainId;
+ LPCWSTR lpAssemblyIdentity;
+ LPCWSTR lpModuleName;
+ } ModuleBindInfo;
+
+typedef
+enum _HostApplicationPolicy
+ {
+ HOST_APPLICATION_BINDING_POLICY = 1
+ } EHostApplicationPolicy;
+
+STDAPI GetCLRIdentityManager(REFIID riid, IUnknown **ppManager);
+EXTERN_GUID(IID_IHostControl, 0x02CA073C, 0x7079, 0x4860, 0x88, 0x0A, 0xC2, 0xF7, 0xA4, 0x49, 0xC9, 0x91);
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0007_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0007_v0_0_s_ifspec;
+
+#ifndef __IHostControl_INTERFACE_DEFINED__
+#define __IHostControl_INTERFACE_DEFINED__
+
+/* interface IHostControl */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_IHostControl;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("02CA073C-7079-4860-880A-C2F7A449C991")
+ IHostControl : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetHostManager(
+ /* [in] */ REFIID riid,
+ /* [out] */ void **ppObject) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetAppDomainManager(
+ /* [in] */ DWORD dwAppDomainID,
+ /* [in] */ IUnknown *pUnkAppDomainManager) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IHostControlVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IHostControl * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IHostControl * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IHostControl * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetHostManager )(
+ IHostControl * This,
+ /* [in] */ REFIID riid,
+ /* [out] */ void **ppObject);
+
+ HRESULT ( STDMETHODCALLTYPE *SetAppDomainManager )(
+ IHostControl * This,
+ /* [in] */ DWORD dwAppDomainID,
+ /* [in] */ IUnknown *pUnkAppDomainManager);
+
+ END_INTERFACE
+ } IHostControlVtbl;
+
+ interface IHostControl
+ {
+ CONST_VTBL struct IHostControlVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IHostControl_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IHostControl_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IHostControl_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IHostControl_GetHostManager(This,riid,ppObject) \
+ ( (This)->lpVtbl -> GetHostManager(This,riid,ppObject) )
+
+#define IHostControl_SetAppDomainManager(This,dwAppDomainID,pUnkAppDomainManager) \
+ ( (This)->lpVtbl -> SetAppDomainManager(This,dwAppDomainID,pUnkAppDomainManager) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IHostControl_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0008 */
+/* [local] */
+
+EXTERN_GUID(IID_ICLRControl, 0x9065597E, 0xD1A1, 0x4fb2, 0xB6, 0xBA, 0x7E, 0x1F, 0xCE, 0x23, 0x0F, 0x61);
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0008_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0008_v0_0_s_ifspec;
+
+#ifndef __ICLRControl_INTERFACE_DEFINED__
+#define __ICLRControl_INTERFACE_DEFINED__
+
+/* interface ICLRControl */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRControl;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("9065597E-D1A1-4fb2-B6BA-7E1FCE230F61")
+ ICLRControl : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetCLRManager(
+ /* [in] */ REFIID riid,
+ /* [out] */ void **ppObject) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetAppDomainManagerType(
+ /* [in] */ LPCWSTR pwzAppDomainManagerAssembly,
+ /* [in] */ LPCWSTR pwzAppDomainManagerType) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRControlVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRControl * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRControl * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRControl * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCLRManager )(
+ ICLRControl * This,
+ /* [in] */ REFIID riid,
+ /* [out] */ void **ppObject);
+
+ HRESULT ( STDMETHODCALLTYPE *SetAppDomainManagerType )(
+ ICLRControl * This,
+ /* [in] */ LPCWSTR pwzAppDomainManagerAssembly,
+ /* [in] */ LPCWSTR pwzAppDomainManagerType);
+
+ END_INTERFACE
+ } ICLRControlVtbl;
+
+ interface ICLRControl
+ {
+ CONST_VTBL struct ICLRControlVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRControl_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRControl_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRControl_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRControl_GetCLRManager(This,riid,ppObject) \
+ ( (This)->lpVtbl -> GetCLRManager(This,riid,ppObject) )
+
+#define ICLRControl_SetAppDomainManagerType(This,pwzAppDomainManagerAssembly,pwzAppDomainManagerType) \
+ ( (This)->lpVtbl -> SetAppDomainManagerType(This,pwzAppDomainManagerAssembly,pwzAppDomainManagerType) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRControl_INTERFACE_DEFINED__ */
+
+
+#ifndef __ICLRRuntimeHost_INTERFACE_DEFINED__
+#define __ICLRRuntimeHost_INTERFACE_DEFINED__
+
+/* interface ICLRRuntimeHost */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRRuntimeHost;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("90F1A06C-7712-4762-86B5-7A5EBA6BDB02")
+ ICLRRuntimeHost : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE Start( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Stop( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetHostControl(
+ /* [in] */ IHostControl *pHostControl) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetCLRControl(
+ /* [out] */ ICLRControl **pCLRControl) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE UnloadAppDomain(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ BOOL fWaitUntilDone) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ExecuteInAppDomain(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ FExecuteInAppDomainCallback pCallback,
+ /* [in] */ void *cookie) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentAppDomainId(
+ /* [out] */ DWORD *pdwAppDomainId) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ExecuteApplication(
+ /* [in] */ LPCWSTR pwzAppFullName,
+ /* [in] */ DWORD dwManifestPaths,
+ /* [in] */ LPCWSTR *ppwzManifestPaths,
+ /* [in] */ DWORD dwActivationData,
+ /* [in] */ LPCWSTR *ppwzActivationData,
+ /* [out] */ int *pReturnValue) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ExecuteInDefaultAppDomain(
+ /* [in] */ LPCWSTR pwzAssemblyPath,
+ /* [in] */ LPCWSTR pwzTypeName,
+ /* [in] */ LPCWSTR pwzMethodName,
+ /* [in] */ LPCWSTR pwzArgument,
+ /* [out] */ DWORD *pReturnValue) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRRuntimeHostVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRRuntimeHost * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRRuntimeHost * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRRuntimeHost * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Start )(
+ ICLRRuntimeHost * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Stop )(
+ ICLRRuntimeHost * This);
+
+ HRESULT ( STDMETHODCALLTYPE *SetHostControl )(
+ ICLRRuntimeHost * This,
+ /* [in] */ IHostControl *pHostControl);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCLRControl )(
+ ICLRRuntimeHost * This,
+ /* [out] */ ICLRControl **pCLRControl);
+
+ HRESULT ( STDMETHODCALLTYPE *UnloadAppDomain )(
+ ICLRRuntimeHost * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ BOOL fWaitUntilDone);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteInAppDomain )(
+ ICLRRuntimeHost * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ FExecuteInAppDomainCallback pCallback,
+ /* [in] */ void *cookie);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCurrentAppDomainId )(
+ ICLRRuntimeHost * This,
+ /* [out] */ DWORD *pdwAppDomainId);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteApplication )(
+ ICLRRuntimeHost * This,
+ /* [in] */ LPCWSTR pwzAppFullName,
+ /* [in] */ DWORD dwManifestPaths,
+ /* [in] */ LPCWSTR *ppwzManifestPaths,
+ /* [in] */ DWORD dwActivationData,
+ /* [in] */ LPCWSTR *ppwzActivationData,
+ /* [out] */ int *pReturnValue);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteInDefaultAppDomain )(
+ ICLRRuntimeHost * This,
+ /* [in] */ LPCWSTR pwzAssemblyPath,
+ /* [in] */ LPCWSTR pwzTypeName,
+ /* [in] */ LPCWSTR pwzMethodName,
+ /* [in] */ LPCWSTR pwzArgument,
+ /* [out] */ DWORD *pReturnValue);
+
+ END_INTERFACE
+ } ICLRRuntimeHostVtbl;
+
+ interface ICLRRuntimeHost
+ {
+ CONST_VTBL struct ICLRRuntimeHostVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRRuntimeHost_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRRuntimeHost_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRRuntimeHost_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRRuntimeHost_Start(This) \
+ ( (This)->lpVtbl -> Start(This) )
+
+#define ICLRRuntimeHost_Stop(This) \
+ ( (This)->lpVtbl -> Stop(This) )
+
+#define ICLRRuntimeHost_SetHostControl(This,pHostControl) \
+ ( (This)->lpVtbl -> SetHostControl(This,pHostControl) )
+
+#define ICLRRuntimeHost_GetCLRControl(This,pCLRControl) \
+ ( (This)->lpVtbl -> GetCLRControl(This,pCLRControl) )
+
+#define ICLRRuntimeHost_UnloadAppDomain(This,dwAppDomainId,fWaitUntilDone) \
+ ( (This)->lpVtbl -> UnloadAppDomain(This,dwAppDomainId,fWaitUntilDone) )
+
+#define ICLRRuntimeHost_ExecuteInAppDomain(This,dwAppDomainId,pCallback,cookie) \
+ ( (This)->lpVtbl -> ExecuteInAppDomain(This,dwAppDomainId,pCallback,cookie) )
+
+#define ICLRRuntimeHost_GetCurrentAppDomainId(This,pdwAppDomainId) \
+ ( (This)->lpVtbl -> GetCurrentAppDomainId(This,pdwAppDomainId) )
+
+#define ICLRRuntimeHost_ExecuteApplication(This,pwzAppFullName,dwManifestPaths,ppwzManifestPaths,dwActivationData,ppwzActivationData,pReturnValue) \
+ ( (This)->lpVtbl -> ExecuteApplication(This,pwzAppFullName,dwManifestPaths,ppwzManifestPaths,dwActivationData,ppwzActivationData,pReturnValue) )
+
+#define ICLRRuntimeHost_ExecuteInDefaultAppDomain(This,pwzAssemblyPath,pwzTypeName,pwzMethodName,pwzArgument,pReturnValue) \
+ ( (This)->lpVtbl -> ExecuteInDefaultAppDomain(This,pwzAssemblyPath,pwzTypeName,pwzMethodName,pwzArgument,pReturnValue) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRRuntimeHost_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0010 */
+/* [local] */
+
+#define CORECLR_HOST_AUTHENTICATION_KEY 0x1C6CA6F94025800LL
+#define CORECLR_HOST_AUTHENTICATION_KEY_NONGEN 0x1C6CA6F94025801LL
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0010_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0010_v0_0_s_ifspec;
+
+#ifndef __ICLRRuntimeHost2_INTERFACE_DEFINED__
+#define __ICLRRuntimeHost2_INTERFACE_DEFINED__
+
+/* interface ICLRRuntimeHost2 */
+/* [local][unique][helpstring][version][uuid][object] */
+
+
+EXTERN_C const IID IID_ICLRRuntimeHost2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("712AB73F-2C22-4807-AD7E-F501D7B72C2D")
+ ICLRRuntimeHost2 : public ICLRRuntimeHost
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE CreateAppDomainWithManager(
+ /* [in] */ LPCWSTR wszFriendlyName,
+ /* [in] */ DWORD dwFlags,
+ /* [in] */ LPCWSTR wszAppDomainManagerAssemblyName,
+ /* [in] */ LPCWSTR wszAppDomainManagerTypeName,
+ /* [in] */ int nProperties,
+ /* [in] */ LPCWSTR *pPropertyNames,
+ /* [in] */ LPCWSTR *pPropertyValues,
+ /* [out] */ DWORD *pAppDomainID) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CreateDelegate(
+ /* [in] */ DWORD appDomainID,
+ /* [in] */ LPCWSTR wszAssemblyName,
+ /* [in] */ LPCWSTR wszClassName,
+ /* [in] */ LPCWSTR wszMethodName,
+ /* [out] */ INT_PTR *fnPtr) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Authenticate(
+ /* [in] */ ULONGLONG authKey) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE RegisterMacEHPort( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE SetStartupFlags(
+ /* [in] */ STARTUP_FLAGS dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE DllGetActivationFactory(
+ /* [in] */ DWORD appDomainID,
+ /* [in] */ LPCWSTR wszTypeName,
+ /* [out] */ IActivationFactory **factory) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ExecuteAssembly(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ LPCWSTR pwzAssemblyPath,
+ /* [in] */ int argc,
+ /* [in] */ LPCWSTR *argv,
+ /* [out] */ DWORD *pReturnValue) = 0;
+
+ };
+
+ MIDL_INTERFACE("64F6D366-D7C2-4F1F-B4B2-E8160CAC43AF")
+ ICLRRuntimeHost4 : public ICLRRuntimeHost2
+ {
+ virtual HRESULT STDMETHODCALLTYPE UnloadAppDomain2(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ BOOL fWaitUntilDone,
+ /* [out] */ int *pLatchedExitCode) = 0;
+ };
+
+#else /* C style interface */
+
+ typedef struct ICLRRuntimeHost2Vtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRRuntimeHost2 * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRRuntimeHost2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Start )(
+ ICLRRuntimeHost2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Stop )(
+ ICLRRuntimeHost2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *SetHostControl )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ IHostControl *pHostControl);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCLRControl )(
+ ICLRRuntimeHost2 * This,
+ /* [out] */ ICLRControl **pCLRControl);
+
+ HRESULT ( STDMETHODCALLTYPE *UnloadAppDomain )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ BOOL fWaitUntilDone);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteInAppDomain )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ FExecuteInAppDomainCallback pCallback,
+ /* [in] */ void *cookie);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCurrentAppDomainId )(
+ ICLRRuntimeHost2 * This,
+ /* [out] */ DWORD *pdwAppDomainId);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteApplication )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ LPCWSTR pwzAppFullName,
+ /* [in] */ DWORD dwManifestPaths,
+ /* [in] */ LPCWSTR *ppwzManifestPaths,
+ /* [in] */ DWORD dwActivationData,
+ /* [in] */ LPCWSTR *ppwzActivationData,
+ /* [out] */ int *pReturnValue);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteInDefaultAppDomain )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ LPCWSTR pwzAssemblyPath,
+ /* [in] */ LPCWSTR pwzTypeName,
+ /* [in] */ LPCWSTR pwzMethodName,
+ /* [in] */ LPCWSTR pwzArgument,
+ /* [out] */ DWORD *pReturnValue);
+
+ HRESULT ( STDMETHODCALLTYPE *CreateAppDomainWithManager )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ LPCWSTR wszFriendlyName,
+ /* [in] */ DWORD dwFlags,
+ /* [in] */ LPCWSTR wszAppDomainManagerAssemblyName,
+ /* [in] */ LPCWSTR wszAppDomainManagerTypeName,
+ /* [in] */ int nProperties,
+ /* [in] */ LPCWSTR *pPropertyNames,
+ /* [in] */ LPCWSTR *pPropertyValues,
+ /* [out] */ DWORD *pAppDomainID);
+
+ HRESULT ( STDMETHODCALLTYPE *CreateDelegate )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ DWORD appDomainID,
+ /* [in] */ LPCWSTR wszAssemblyName,
+ /* [in] */ LPCWSTR wszClassName,
+ /* [in] */ LPCWSTR wszMethodName,
+ /* [out] */ INT_PTR *fnPtr);
+
+ HRESULT ( STDMETHODCALLTYPE *Authenticate )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ ULONGLONG authKey);
+
+ HRESULT ( STDMETHODCALLTYPE *RegisterMacEHPort )(
+ ICLRRuntimeHost2 * This);
+
+ HRESULT ( STDMETHODCALLTYPE *SetStartupFlags )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ STARTUP_FLAGS dwFlags);
+
+ HRESULT ( STDMETHODCALLTYPE *DllGetActivationFactory )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ DWORD appDomainID,
+ /* [in] */ LPCWSTR wszTypeName,
+ /* [out] */ IActivationFactory **factory);
+
+ HRESULT ( STDMETHODCALLTYPE *ExecuteAssembly )(
+ ICLRRuntimeHost2 * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ LPCWSTR pwzAssemblyPath,
+ /* [in] */ int argc,
+ /* [in] */ LPCWSTR *argv,
+ /* [out] */ DWORD *pReturnValue);
+
+ END_INTERFACE
+ } ICLRRuntimeHost2Vtbl;
+
+ interface ICLRRuntimeHost2
+ {
+ CONST_VTBL struct ICLRRuntimeHost2Vtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRRuntimeHost2_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRRuntimeHost2_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRRuntimeHost2_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRRuntimeHost2_Start(This) \
+ ( (This)->lpVtbl -> Start(This) )
+
+#define ICLRRuntimeHost2_Stop(This) \
+ ( (This)->lpVtbl -> Stop(This) )
+
+#define ICLRRuntimeHost2_SetHostControl(This,pHostControl) \
+ ( (This)->lpVtbl -> SetHostControl(This,pHostControl) )
+
+#define ICLRRuntimeHost2_GetCLRControl(This,pCLRControl) \
+ ( (This)->lpVtbl -> GetCLRControl(This,pCLRControl) )
+
+#define ICLRRuntimeHost2_UnloadAppDomain(This,dwAppDomainId,fWaitUntilDone) \
+ ( (This)->lpVtbl -> UnloadAppDomain(This,dwAppDomainId,fWaitUntilDone) )
+
+#define ICLRRuntimeHost2_ExecuteInAppDomain(This,dwAppDomainId,pCallback,cookie) \
+ ( (This)->lpVtbl -> ExecuteInAppDomain(This,dwAppDomainId,pCallback,cookie) )
+
+#define ICLRRuntimeHost2_GetCurrentAppDomainId(This,pdwAppDomainId) \
+ ( (This)->lpVtbl -> GetCurrentAppDomainId(This,pdwAppDomainId) )
+
+#define ICLRRuntimeHost2_ExecuteApplication(This,pwzAppFullName,dwManifestPaths,ppwzManifestPaths,dwActivationData,ppwzActivationData,pReturnValue) \
+ ( (This)->lpVtbl -> ExecuteApplication(This,pwzAppFullName,dwManifestPaths,ppwzManifestPaths,dwActivationData,ppwzActivationData,pReturnValue) )
+
+#define ICLRRuntimeHost2_ExecuteInDefaultAppDomain(This,pwzAssemblyPath,pwzTypeName,pwzMethodName,pwzArgument,pReturnValue) \
+ ( (This)->lpVtbl -> ExecuteInDefaultAppDomain(This,pwzAssemblyPath,pwzTypeName,pwzMethodName,pwzArgument,pReturnValue) )
+
+
+#define ICLRRuntimeHost2_CreateAppDomainWithManager(This,wszFriendlyName,dwFlags,wszAppDomainManagerAssemblyName,wszAppDomainManagerTypeName,nProperties,pPropertyNames,pPropertyValues,pAppDomainID) \
+ ( (This)->lpVtbl -> CreateAppDomainWithManager(This,wszFriendlyName,dwFlags,wszAppDomainManagerAssemblyName,wszAppDomainManagerTypeName,nProperties,pPropertyNames,pPropertyValues,pAppDomainID) )
+
+#define ICLRRuntimeHost2_CreateDelegate(This,appDomainID,wszAssemblyName,wszClassName,wszMethodName,fnPtr) \
+ ( (This)->lpVtbl -> CreateDelegate(This,appDomainID,wszAssemblyName,wszClassName,wszMethodName,fnPtr) )
+
+#define ICLRRuntimeHost2_Authenticate(This,authKey) \
+ ( (This)->lpVtbl -> Authenticate(This,authKey) )
+
+#define ICLRRuntimeHost2_RegisterMacEHPort(This) \
+ ( (This)->lpVtbl -> RegisterMacEHPort(This) )
+
+#define ICLRRuntimeHost2_SetStartupFlags(This,dwFlags) \
+ ( (This)->lpVtbl -> SetStartupFlags(This,dwFlags) )
+
+#define ICLRRuntimeHost2_DllGetActivationFactory(This,appDomainID,wszTypeName,factory) \
+ ( (This)->lpVtbl -> DllGetActivationFactory(This,appDomainID,wszTypeName,factory) )
+
+#define ICLRRuntimeHost2_ExecuteAssembly(This,dwAppDomainId,pwzAssemblyPath,argc,argv,pReturnValue) \
+ ( (This)->lpVtbl -> ExecuteAssembly(This,dwAppDomainId,pwzAssemblyPath,argc,argv,pReturnValue) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRRuntimeHost2_INTERFACE_DEFINED__ */
+
+
+#ifndef __ICLRExecutionManager_INTERFACE_DEFINED__
+#define __ICLRExecutionManager_INTERFACE_DEFINED__
+
+/* interface ICLRExecutionManager */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_ICLRExecutionManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("1000A3E7-B420-4620-AE30-FB19B587AD1D")
+ ICLRExecutionManager : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE Pause(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ DWORD dwFlags) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Resume(
+ /* [in] */ DWORD dwAppDomainId) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRExecutionManagerVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRExecutionManager * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRExecutionManager * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRExecutionManager * This);
+
+ HRESULT ( STDMETHODCALLTYPE *Pause )(
+ ICLRExecutionManager * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [in] */ DWORD dwFlags);
+
+ HRESULT ( STDMETHODCALLTYPE *Resume )(
+ ICLRExecutionManager * This,
+ /* [in] */ DWORD dwAppDomainId);
+
+ END_INTERFACE
+ } ICLRExecutionManagerVtbl;
+
+ interface ICLRExecutionManager
+ {
+ CONST_VTBL struct ICLRExecutionManagerVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRExecutionManager_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRExecutionManager_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRExecutionManager_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRExecutionManager_Pause(This,dwAppDomainId,dwFlags) \
+ ( (This)->lpVtbl -> Pause(This,dwAppDomainId,dwFlags) )
+
+#define ICLRExecutionManager_Resume(This,dwAppDomainId) \
+ ( (This)->lpVtbl -> Resume(This,dwAppDomainId) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRExecutionManager_INTERFACE_DEFINED__ */
+
+
+#ifndef __IHostNetCFDebugControlManager_INTERFACE_DEFINED__
+#define __IHostNetCFDebugControlManager_INTERFACE_DEFINED__
+
+/* interface IHostNetCFDebugControlManager */
+/* [object][local][unique][helpstring][version][uuid] */
+
+
+EXTERN_C const IID IID_IHostNetCFDebugControlManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("F2833A0C-F944-48d8-940E-F59425EDBFCF")
+ IHostNetCFDebugControlManager : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE NotifyPause(
+ DWORD dwReserved) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE NotifyResume(
+ DWORD dwReserved) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IHostNetCFDebugControlManagerVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IHostNetCFDebugControlManager * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IHostNetCFDebugControlManager * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IHostNetCFDebugControlManager * This);
+
+ HRESULT ( STDMETHODCALLTYPE *NotifyPause )(
+ IHostNetCFDebugControlManager * This,
+ DWORD dwReserved);
+
+ HRESULT ( STDMETHODCALLTYPE *NotifyResume )(
+ IHostNetCFDebugControlManager * This,
+ DWORD dwReserved);
+
+ END_INTERFACE
+ } IHostNetCFDebugControlManagerVtbl;
+
+ interface IHostNetCFDebugControlManager
+ {
+ CONST_VTBL struct IHostNetCFDebugControlManagerVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IHostNetCFDebugControlManager_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IHostNetCFDebugControlManager_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IHostNetCFDebugControlManager_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IHostNetCFDebugControlManager_NotifyPause(This,dwReserved) \
+ ( (This)->lpVtbl -> NotifyPause(This,dwReserved) )
+
+#define IHostNetCFDebugControlManager_NotifyResume(This,dwReserved) \
+ ( (This)->lpVtbl -> NotifyResume(This,dwReserved) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IHostNetCFDebugControlManager_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0013 */
+/* [local] */
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0013_0001
+ {
+ eNoChecks = 0,
+ eSynchronization = 0x1,
+ eSharedState = 0x2,
+ eExternalProcessMgmt = 0x4,
+ eSelfAffectingProcessMgmt = 0x8,
+ eExternalThreading = 0x10,
+ eSelfAffectingThreading = 0x20,
+ eSecurityInfrastructure = 0x40,
+ eUI = 0x80,
+ eMayLeakOnAbort = 0x100,
+ eAll = 0x1ff
+ } EApiCategories;
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0013_0002
+ {
+ eInitializeNewDomainFlags_None = 0,
+ eInitializeNewDomainFlags_NoSecurityChanges = 0x2
+ } EInitializeNewDomainFlags;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0013_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0013_v0_0_s_ifspec;
+
+
+#ifndef __mscoree_LIBRARY_DEFINED__
+#define __mscoree_LIBRARY_DEFINED__
+
+/* library mscoree */
+/* [helpstring][version][uuid] */
+
+#define CCW_PTR int *
+
+EXTERN_C const IID LIBID_mscoree;
+
+#ifndef __ITypeName_INTERFACE_DEFINED__
+#define __ITypeName_INTERFACE_DEFINED__
+
+/* interface ITypeName */
+/* [unique][helpstring][uuid][oleautomation][object] */
+
+
+EXTERN_C const IID IID_ITypeName;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("B81FF171-20F3-11d2-8DCC-00A0C9B00522")
+ ITypeName : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetNameCount(
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetNames(
+ /* [in] */ DWORD count,
+ /* [out] */ BSTR *rgbszNames,
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetTypeArgumentCount(
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetTypeArguments(
+ /* [in] */ DWORD count,
+ /* [out] */ ITypeName **rgpArguments,
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetModifierLength(
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetModifiers(
+ /* [in] */ DWORD count,
+ /* [out] */ DWORD *rgModifiers,
+ /* [retval][out] */ DWORD *pCount) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetAssemblyName(
+ /* [retval][out] */ BSTR *rgbszAssemblyNames) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ITypeNameVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ITypeName * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ITypeName * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ITypeName * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetNameCount )(
+ ITypeName * This,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetNames )(
+ ITypeName * This,
+ /* [in] */ DWORD count,
+ /* [out] */ BSTR *rgbszNames,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetTypeArgumentCount )(
+ ITypeName * This,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetTypeArguments )(
+ ITypeName * This,
+ /* [in] */ DWORD count,
+ /* [out] */ ITypeName **rgpArguments,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetModifierLength )(
+ ITypeName * This,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetModifiers )(
+ ITypeName * This,
+ /* [in] */ DWORD count,
+ /* [out] */ DWORD *rgModifiers,
+ /* [retval][out] */ DWORD *pCount);
+
+ HRESULT ( STDMETHODCALLTYPE *GetAssemblyName )(
+ ITypeName * This,
+ /* [retval][out] */ BSTR *rgbszAssemblyNames);
+
+ END_INTERFACE
+ } ITypeNameVtbl;
+
+ interface ITypeName
+ {
+ CONST_VTBL struct ITypeNameVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ITypeName_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ITypeName_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ITypeName_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ITypeName_GetNameCount(This,pCount) \
+ ( (This)->lpVtbl -> GetNameCount(This,pCount) )
+
+#define ITypeName_GetNames(This,count,rgbszNames,pCount) \
+ ( (This)->lpVtbl -> GetNames(This,count,rgbszNames,pCount) )
+
+#define ITypeName_GetTypeArgumentCount(This,pCount) \
+ ( (This)->lpVtbl -> GetTypeArgumentCount(This,pCount) )
+
+#define ITypeName_GetTypeArguments(This,count,rgpArguments,pCount) \
+ ( (This)->lpVtbl -> GetTypeArguments(This,count,rgpArguments,pCount) )
+
+#define ITypeName_GetModifierLength(This,pCount) \
+ ( (This)->lpVtbl -> GetModifierLength(This,pCount) )
+
+#define ITypeName_GetModifiers(This,count,rgModifiers,pCount) \
+ ( (This)->lpVtbl -> GetModifiers(This,count,rgModifiers,pCount) )
+
+#define ITypeName_GetAssemblyName(This,rgbszAssemblyNames) \
+ ( (This)->lpVtbl -> GetAssemblyName(This,rgbszAssemblyNames) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ITypeName_INTERFACE_DEFINED__ */
+
+
+#ifndef __ITypeNameBuilder_INTERFACE_DEFINED__
+#define __ITypeNameBuilder_INTERFACE_DEFINED__
+
+/* interface ITypeNameBuilder */
+/* [unique][helpstring][uuid][oleautomation][object] */
+
+
+EXTERN_C const IID IID_ITypeNameBuilder;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("B81FF171-20F3-11d2-8DCC-00A0C9B00523")
+ ITypeNameBuilder : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE OpenGenericArguments( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CloseGenericArguments( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE OpenGenericArgument( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE CloseGenericArgument( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddName(
+ /* [in] */ LPCWSTR szName) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddPointer( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddByRef( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddSzArray( void) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddArray(
+ /* [in] */ DWORD rank) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE AddAssemblySpec(
+ /* [in] */ LPCWSTR szAssemblySpec) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE ToString(
+ /* [retval][out] */ BSTR *pszStringRepresentation) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE Clear( void) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ITypeNameBuilderVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ITypeNameBuilder * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ITypeNameBuilder * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *OpenGenericArguments )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *CloseGenericArguments )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *OpenGenericArgument )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *CloseGenericArgument )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *AddName )(
+ ITypeNameBuilder * This,
+ /* [in] */ LPCWSTR szName);
+
+ HRESULT ( STDMETHODCALLTYPE *AddPointer )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *AddByRef )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *AddSzArray )(
+ ITypeNameBuilder * This);
+
+ HRESULT ( STDMETHODCALLTYPE *AddArray )(
+ ITypeNameBuilder * This,
+ /* [in] */ DWORD rank);
+
+ HRESULT ( STDMETHODCALLTYPE *AddAssemblySpec )(
+ ITypeNameBuilder * This,
+ /* [in] */ LPCWSTR szAssemblySpec);
+
+ HRESULT ( STDMETHODCALLTYPE *ToString )(
+ ITypeNameBuilder * This,
+ /* [retval][out] */ BSTR *pszStringRepresentation);
+
+ HRESULT ( STDMETHODCALLTYPE *Clear )(
+ ITypeNameBuilder * This);
+
+ END_INTERFACE
+ } ITypeNameBuilderVtbl;
+
+ interface ITypeNameBuilder
+ {
+ CONST_VTBL struct ITypeNameBuilderVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ITypeNameBuilder_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ITypeNameBuilder_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ITypeNameBuilder_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ITypeNameBuilder_OpenGenericArguments(This) \
+ ( (This)->lpVtbl -> OpenGenericArguments(This) )
+
+#define ITypeNameBuilder_CloseGenericArguments(This) \
+ ( (This)->lpVtbl -> CloseGenericArguments(This) )
+
+#define ITypeNameBuilder_OpenGenericArgument(This) \
+ ( (This)->lpVtbl -> OpenGenericArgument(This) )
+
+#define ITypeNameBuilder_CloseGenericArgument(This) \
+ ( (This)->lpVtbl -> CloseGenericArgument(This) )
+
+#define ITypeNameBuilder_AddName(This,szName) \
+ ( (This)->lpVtbl -> AddName(This,szName) )
+
+#define ITypeNameBuilder_AddPointer(This) \
+ ( (This)->lpVtbl -> AddPointer(This) )
+
+#define ITypeNameBuilder_AddByRef(This) \
+ ( (This)->lpVtbl -> AddByRef(This) )
+
+#define ITypeNameBuilder_AddSzArray(This) \
+ ( (This)->lpVtbl -> AddSzArray(This) )
+
+#define ITypeNameBuilder_AddArray(This,rank) \
+ ( (This)->lpVtbl -> AddArray(This,rank) )
+
+#define ITypeNameBuilder_AddAssemblySpec(This,szAssemblySpec) \
+ ( (This)->lpVtbl -> AddAssemblySpec(This,szAssemblySpec) )
+
+#define ITypeNameBuilder_ToString(This,pszStringRepresentation) \
+ ( (This)->lpVtbl -> ToString(This,pszStringRepresentation) )
+
+#define ITypeNameBuilder_Clear(This) \
+ ( (This)->lpVtbl -> Clear(This) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ITypeNameBuilder_INTERFACE_DEFINED__ */
+
+
+#ifndef __ITypeNameFactory_INTERFACE_DEFINED__
+#define __ITypeNameFactory_INTERFACE_DEFINED__
+
+/* interface ITypeNameFactory */
+/* [unique][helpstring][uuid][oleautomation][object] */
+
+
+EXTERN_C const IID IID_ITypeNameFactory;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("B81FF171-20F3-11d2-8DCC-00A0C9B00521")
+ ITypeNameFactory : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE ParseTypeName(
+ /* [in] */ LPCWSTR szName,
+ /* [out] */ DWORD *pError,
+ /* [retval][out] */ ITypeName **ppTypeName) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetTypeNameBuilder(
+ /* [retval][out] */ ITypeNameBuilder **ppTypeBuilder) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ITypeNameFactoryVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ITypeNameFactory * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ITypeNameFactory * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ITypeNameFactory * This);
+
+ HRESULT ( STDMETHODCALLTYPE *ParseTypeName )(
+ ITypeNameFactory * This,
+ /* [in] */ LPCWSTR szName,
+ /* [out] */ DWORD *pError,
+ /* [retval][out] */ ITypeName **ppTypeName);
+
+ HRESULT ( STDMETHODCALLTYPE *GetTypeNameBuilder )(
+ ITypeNameFactory * This,
+ /* [retval][out] */ ITypeNameBuilder **ppTypeBuilder);
+
+ END_INTERFACE
+ } ITypeNameFactoryVtbl;
+
+ interface ITypeNameFactory
+ {
+ CONST_VTBL struct ITypeNameFactoryVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ITypeNameFactory_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ITypeNameFactory_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ITypeNameFactory_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ITypeNameFactory_ParseTypeName(This,szName,pError,ppTypeName) \
+ ( (This)->lpVtbl -> ParseTypeName(This,szName,pError,ppTypeName) )
+
+#define ITypeNameFactory_GetTypeNameBuilder(This,ppTypeBuilder) \
+ ( (This)->lpVtbl -> GetTypeNameBuilder(This,ppTypeBuilder) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ITypeNameFactory_INTERFACE_DEFINED__ */
+
+
+#ifndef __IManagedObject_INTERFACE_DEFINED__
+#define __IManagedObject_INTERFACE_DEFINED__
+
+/* interface IManagedObject */
+/* [proxy][unique][helpstring][uuid][oleautomation][object] */
+
+
+EXTERN_C const IID IID_IManagedObject;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4")
+ IManagedObject : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetSerializedBuffer(
+ /* [out] */ BSTR *pBSTR) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetObjectIdentity(
+ /* [out] */ BSTR *pBSTRGUID,
+ /* [out] */ int *AppDomainID,
+ /* [out] */ int *pCCW) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct IManagedObjectVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ IManagedObject * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ IManagedObject * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ IManagedObject * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetSerializedBuffer )(
+ IManagedObject * This,
+ /* [out] */ BSTR *pBSTR);
+
+ HRESULT ( STDMETHODCALLTYPE *GetObjectIdentity )(
+ IManagedObject * This,
+ /* [out] */ BSTR *pBSTRGUID,
+ /* [out] */ int *AppDomainID,
+ /* [out] */ int *pCCW);
+
+ END_INTERFACE
+ } IManagedObjectVtbl;
+
+ interface IManagedObject
+ {
+ CONST_VTBL struct IManagedObjectVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define IManagedObject_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define IManagedObject_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define IManagedObject_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define IManagedObject_GetSerializedBuffer(This,pBSTR) \
+ ( (This)->lpVtbl -> GetSerializedBuffer(This,pBSTR) )
+
+#define IManagedObject_GetObjectIdentity(This,pBSTRGUID,AppDomainID,pCCW) \
+ ( (This)->lpVtbl -> GetObjectIdentity(This,pBSTRGUID,AppDomainID,pCCW) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __IManagedObject_INTERFACE_DEFINED__ */
+
+
+EXTERN_C const CLSID CLSID_ComCallUnmarshal;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("3F281000-E95A-11d2-886B-00C04F869F04")
+ComCallUnmarshal;
+#endif
+
+EXTERN_C const CLSID CLSID_ComCallUnmarshalV4;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("45FB4600-E6E8-4928-B25E-50476FF79425")
+ComCallUnmarshalV4;
+#endif
+
+EXTERN_C const CLSID CLSID_CLRRuntimeHost;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("90F1A06E-7712-4762-86B5-7A5EBA6BDB02")
+CLRRuntimeHost;
+#endif
+
+EXTERN_C const CLSID CLSID_TypeNameFactory;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("B81FF171-20F3-11d2-8DCC-00A0C9B00525")
+TypeNameFactory;
+#endif
+#endif /* __mscoree_LIBRARY_DEFINED__ */
+
+/* interface __MIDL_itf_mscoree_0000_0014 */
+/* [local] */
+
+typedef /* [public] */
+enum __MIDL___MIDL_itf_mscoree_0000_0014_0001
+ {
+ eCurrentContext = 0,
+ eRestrictedContext = 0x1
+ } EContextType;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0014_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0014_v0_0_s_ifspec;
+
+#ifndef __ICLRAppDomainResourceMonitor_INTERFACE_DEFINED__
+#define __ICLRAppDomainResourceMonitor_INTERFACE_DEFINED__
+
+/* interface ICLRAppDomainResourceMonitor */
+/* [object][local][unique][helpstring][uuid][version] */
+
+
+EXTERN_C const IID IID_ICLRAppDomainResourceMonitor;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+
+ MIDL_INTERFACE("c62de18c-2e23-4aea-8423-b40c1fc59eae")
+ ICLRAppDomainResourceMonitor : public IUnknown
+ {
+ public:
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentAllocated(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pBytesAllocated) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentSurvived(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pAppDomainBytesSurvived,
+ /* [out] */ ULONGLONG *pTotalBytesSurvived) = 0;
+
+ virtual HRESULT STDMETHODCALLTYPE GetCurrentCpuTime(
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pMilliseconds) = 0;
+
+ };
+
+
+#else /* C style interface */
+
+ typedef struct ICLRAppDomainResourceMonitorVtbl
+ {
+ BEGIN_INTERFACE
+
+ HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
+ ICLRAppDomainResourceMonitor * This,
+ /* [in] */ REFIID riid,
+ /* [annotation][iid_is][out] */
+ _COM_Outptr_ void **ppvObject);
+
+ ULONG ( STDMETHODCALLTYPE *AddRef )(
+ ICLRAppDomainResourceMonitor * This);
+
+ ULONG ( STDMETHODCALLTYPE *Release )(
+ ICLRAppDomainResourceMonitor * This);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCurrentAllocated )(
+ ICLRAppDomainResourceMonitor * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pBytesAllocated);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCurrentSurvived )(
+ ICLRAppDomainResourceMonitor * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pAppDomainBytesSurvived,
+ /* [out] */ ULONGLONG *pTotalBytesSurvived);
+
+ HRESULT ( STDMETHODCALLTYPE *GetCurrentCpuTime )(
+ ICLRAppDomainResourceMonitor * This,
+ /* [in] */ DWORD dwAppDomainId,
+ /* [out] */ ULONGLONG *pMilliseconds);
+
+ END_INTERFACE
+ } ICLRAppDomainResourceMonitorVtbl;
+
+ interface ICLRAppDomainResourceMonitor
+ {
+ CONST_VTBL struct ICLRAppDomainResourceMonitorVtbl *lpVtbl;
+ };
+
+
+
+#ifdef COBJMACROS
+
+
+#define ICLRAppDomainResourceMonitor_QueryInterface(This,riid,ppvObject) \
+ ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
+
+#define ICLRAppDomainResourceMonitor_AddRef(This) \
+ ( (This)->lpVtbl -> AddRef(This) )
+
+#define ICLRAppDomainResourceMonitor_Release(This) \
+ ( (This)->lpVtbl -> Release(This) )
+
+
+#define ICLRAppDomainResourceMonitor_GetCurrentAllocated(This,dwAppDomainId,pBytesAllocated) \
+ ( (This)->lpVtbl -> GetCurrentAllocated(This,dwAppDomainId,pBytesAllocated) )
+
+#define ICLRAppDomainResourceMonitor_GetCurrentSurvived(This,dwAppDomainId,pAppDomainBytesSurvived,pTotalBytesSurvived) \
+ ( (This)->lpVtbl -> GetCurrentSurvived(This,dwAppDomainId,pAppDomainBytesSurvived,pTotalBytesSurvived) )
+
+#define ICLRAppDomainResourceMonitor_GetCurrentCpuTime(This,dwAppDomainId,pMilliseconds) \
+ ( (This)->lpVtbl -> GetCurrentCpuTime(This,dwAppDomainId,pMilliseconds) )
+
+#endif /* COBJMACROS */
+
+
+#endif /* C style interface */
+
+
+
+
+#endif /* __ICLRAppDomainResourceMonitor_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_mscoree_0000_0015 */
+/* [local] */
+
+#undef DEPRECATED_CLR_STDAPI
+#undef DECLARE_DEPRECATED
+#undef DEPRECATED_CLR_API_MESG
+
+
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0015_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_mscoree_0000_0015_v0_0_s_ifspec;
+
+/* Additional Prototypes for ALL interfaces */
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/lsapi/lsapi.vcxproj b/lsapi/lsapi.vcxproj
index 501c5d2..6f4d088 100644
--- a/lsapi/lsapi.vcxproj
+++ b/lsapi/lsapi.vcxproj
@@ -23,6 +23,7 @@
{2FECA0A4-CB2F-44CA-97AB-DE78EBBDECFA}
lsapi
Win32Proj
+ "Windows"
@@ -63,6 +64,9 @@
+
+ $(SolutionDir)bin\$(Configuration)_$(PlatformTarget)\
+
LSAPI_INTERNAL;LSAPI_PRIVATE;%(PreprocessorDefinitions)
diff --git a/lsapi/lsapiInit.cpp b/lsapi/lsapiInit.cpp
index e65af87..006fe7d 100755
--- a/lsapi/lsapiInit.cpp
+++ b/lsapi/lsapiInit.cpp
@@ -254,6 +254,7 @@ void LSAPIInit::setLitestepVars()
{ WINVER_WIN7, L"Win7" },
{ WINVER_WIN8, L"Win8" },
{ WINVER_WIN81, L"Win81" },
+ { WINVER_WIN10, L"Win10" },
{ WINVER_WIN2003, L"Win2003" },
{ WINVER_WHS, L"Win2003" }, // WHS is Win2003 in disguise
diff --git a/lsapi/lsapidefines.h b/lsapi/lsapidefines.h
index 1837747..a17cd13 100755
--- a/lsapi/lsapidefines.h
+++ b/lsapi/lsapidefines.h
@@ -326,6 +326,8 @@ typedef struct LSDESKTOPINFO
// ELD_MODULES: possible dwFlags values
#define LS_MODULE_THREADED 0x0001
// LS_MODULE_NOTPUMPED 0x0002 no longer used
+#define LS_MODULE_CLR 0x0003
+#define LS_MODULE_CORECLR 0x0004
typedef BOOL (CALLBACK* LSENUMBANGSPROCA)(LPCSTR, LPARAM);
typedef BOOL (CALLBACK* LSENUMBANGSPROCW)(LPCWSTR, LPARAM);
diff --git a/sdk/examples/HelloCLR/App.config b/sdk/examples/HelloCLR/App.config
new file mode 100644
index 0000000..e74de46
--- /dev/null
+++ b/sdk/examples/HelloCLR/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/examples/HelloCLR/HelloCLR.csproj b/sdk/examples/HelloCLR/HelloCLR.csproj
new file mode 100644
index 0000000..b073ca9
--- /dev/null
+++ b/sdk/examples/HelloCLR/HelloCLR.csproj
@@ -0,0 +1,74 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {2A700A3B-CEFB-488E-BC28-5679FB19712E}
+ Library
+ Properties
+ HelloCLR
+ HelloCLR
+ v2.0
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ x64
+ bin\x64\Debug\
+
+
+ x64
+ bin\x64\Release\
+
+
+ x86
+ bin\x86\Debug\
+
+
+ x86
+ bin\x86\Release\
+
+
+
+
+
+
+
+
+
+
+ {7f8140dc-7815-4368-94f8-a7ed7cf04a2a}
+ LsapiSharp
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/examples/HelloCLR/LSModule.cs b/sdk/examples/HelloCLR/LSModule.cs
new file mode 100644
index 0000000..3cf5d5e
--- /dev/null
+++ b/sdk/examples/HelloCLR/LSModule.cs
@@ -0,0 +1,67 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+using System;
+using System.Runtime.InteropServices;
+using static LsapiSharp.NativeMethods;
+
+namespace HelloCLR
+{
+ public static class LSModule
+ {
+ const string BANG_COMMAND = "!HelloClr";
+
+ // Implements the !Hello bang command
+ static BangCommandDelegate BangHello = (sender, cmd) =>
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "BangHello called");
+ MessageBox(IntPtr.Zero, "Hello, Litestep!", typeof(LSModule).FullName, 0);
+ };
+
+ ///
+ /// Litestep calls this function after it loads the module. This is where the
+ /// module should register bang commands and create windows. If initialization
+ /// succeeds, return zero. If an error occurs, return a nonzero value.
+ ///
+ ///
+ ///
+ public static void initModule(Int32 hWndMain, String appPath)
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "initModule called");
+ AddBangCommand(BANG_COMMAND, BangHello);
+ }
+
+ ///
+ /// Litestep calls this function before it unloads the module. This function
+ /// should unregister bang commands and destroy windows.
+ ///
+ public static void quitModule()
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "quitModule called");
+ RemoveBangCommand(BANG_COMMAND);
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
+ }
+
+}
diff --git a/sdk/examples/HelloCLR/Properties/AssemblyInfo.cs b/sdk/examples/HelloCLR/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..860b618
--- /dev/null
+++ b/sdk/examples/HelloCLR/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+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("HelloCLR")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HelloCLR")]
+[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("2a700a3b-cefb-488e-bc28-5679fb19712e")]
+
+// 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/sdk/examples/HelloCoreCLR/HelloCoreCLR.csproj b/sdk/examples/HelloCoreCLR/HelloCoreCLR.csproj
new file mode 100644
index 0000000..8934ec6
--- /dev/null
+++ b/sdk/examples/HelloCoreCLR/HelloCoreCLR.csproj
@@ -0,0 +1,12 @@
+
+
+
+ netcoreapp2.0
+ AnyCPU;x64;x86
+
+
+
+
+
+
+
diff --git a/sdk/examples/HelloCoreCLR/LSModule.cs b/sdk/examples/HelloCoreCLR/LSModule.cs
new file mode 100644
index 0000000..d5eab00
--- /dev/null
+++ b/sdk/examples/HelloCoreCLR/LSModule.cs
@@ -0,0 +1,67 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+using System;
+using System.Runtime.InteropServices;
+using static LsapiSharp.NativeMethods;
+
+namespace HelloCoreCLR
+{
+ public class LSModule
+ {
+ const string BANG_COMMAND = "!HelloCoreClr";
+
+ // Implements the !Hello bang command
+ static BangCommandDelegate BangHello = (sender, cmd) =>
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "BangHello called from .NET Core");
+ MessageBox(IntPtr.Zero, "Hello, Litestep from .NET Core!", typeof(LSModule).FullName, 0);
+ };
+
+ ///
+ /// Litestep calls this function after it loads the module. This is where the
+ /// module should register bang commands and create windows. If initialization
+ /// succeeds, return zero. If an error occurs, return a nonzero value.
+ ///
+ ///
+ ///
+ public static void initModule(Int32 hWndMain, String appPath)
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "initModule called");
+ AddBangCommand(BANG_COMMAND, BangHello);
+ }
+
+ ///
+ /// Litestep calls this function before it unloads the module. This function
+ /// should unregister bang commands and destroy windows.
+ ///
+ public static void quitModule()
+ {
+ LSLog(LS_LOG_DEBUG, typeof(LSModule).FullName, "quitModule called");
+ RemoveBangCommand(BANG_COMMAND);
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ static extern int MessageBox(IntPtr hWnd, String text, String caption, int options);
+ }
+
+}
diff --git a/sdk/lib/LsapiSharp.dll b/sdk/lib/LsapiSharp.dll
new file mode 100644
index 0000000..4cff2e7
Binary files /dev/null and b/sdk/lib/LsapiSharp.dll differ
diff --git a/sdk/lib/LsapiSharp64.dll b/sdk/lib/LsapiSharp64.dll
new file mode 100644
index 0000000..355d661
Binary files /dev/null and b/sdk/lib/LsapiSharp64.dll differ
diff --git a/sdk/lib/LsapiSharpCore64.dll b/sdk/lib/LsapiSharpCore64.dll
new file mode 100644
index 0000000..08b7bd5
Binary files /dev/null and b/sdk/lib/LsapiSharpCore64.dll differ
diff --git a/utility/safeutility.h b/utility/safeutility.h
new file mode 100644
index 0000000..2409cb9
--- /dev/null
+++ b/utility/safeutility.h
@@ -0,0 +1,59 @@
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// This is a part of the Litestep Shell source code.
+//
+// Copyright (C) 1997-2015 LiteStep Development Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#if !defined(SAFEUTILITY_H)
+#define SAFEUTILITY_H
+
+//
+// Typesafe method for releasing interface pointers and setting them
+// to NULL.
+//
+template inline LONG SafeRelease(T *&pUnk)
+{
+ LONG lr;
+
+ if (pUnk != NULL)
+ {
+ lr = pUnk->Release();
+ pUnk = nullptr;
+ }
+ else
+ {
+ lr = 0;
+ }
+
+ return lr;
+}
+
+//
+// Typesafe method for deleting things created with "new" and setting
+// them to NULL.
+//
+template inline void SafeDelete(T *&pT)
+{
+ if (pT != NULL)
+ {
+ delete pT;
+ pT = nullptr;
+ }
+}
+
+#endif
diff --git a/utility/utility.vcxproj b/utility/utility.vcxproj
index ea4a5f6..f22644a 100644
--- a/utility/utility.vcxproj
+++ b/utility/utility.vcxproj
@@ -87,6 +87,7 @@
+