mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
DllExporter: Move under Build\ directory
Also makes InputText use an architecture specific version of DllExporter.
This commit is contained in:
parent
580d6de303
commit
351fcbce5d
@ -1,7 +1,7 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
[assembly: AssemblyCopyright("© 2013 - Birunthan Mohanathas")]
|
[assembly: AssemblyCopyright("© 2013 - Birunthan Mohanathas")]
|
||||||
[assembly: AssemblyVersion("1.0.1.0")]
|
[assembly: AssemblyVersion("1.0.1.0")]
|
||||||
[assembly: AssemblyProduct("Rainmeter")]
|
[assembly: AssemblyProduct("Rainmeter")]
|
@ -1,94 +1,82 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
<ProductVersion>8.0.30703</ProductVersion>
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
<ProjectGuid>{49D56CA5-54AB-45C9-A245-EAE588FCBFE1}</ProjectGuid>
|
<ProjectGuid>{49D56CA5-54AB-45C9-A245-EAE588FCBFE1}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>DllExporter</RootNamespace>
|
<RootNamespace>DllExporter</RootNamespace>
|
||||||
<AssemblyName>DllExporter</AssemblyName>
|
<AssemblyName>DllExporter</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
<UpdateEnabled>false</UpdateEnabled>
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
<UpdateMode>Foreground</UpdateMode>
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
<UpdateInterval>7</UpdateInterval>
|
<UpdateInterval>7</UpdateInterval>
|
||||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
<UpdatePeriodically>false</UpdatePeriodically>
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
<UpdateRequired>false</UpdateRequired>
|
<UpdateRequired>false</UpdateRequired>
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
<OutputPath Condition=" '$(Platform)' == 'x86' ">$(SolutionDir)x32-$(Configuration)\Tools\</OutputPath>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<OutputPath Condition=" '$(Platform)' == 'x64' ">$(SolutionDir)x64-$(Configuration)\Tools\</OutputPath>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
</PropertyGroup>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<DebugType>full</DebugType>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<Optimize>false</Optimize>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<DebugType>full</DebugType>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<Optimize>false</Optimize>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<WarningLevel>4</WarningLevel>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<NoWarn>1607</NoWarn>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
<NoWarn>1607</NoWarn>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
</PropertyGroup>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
<DebugType>none</DebugType>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
<Optimize>true</Optimize>
|
<DebugType>none</DebugType>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<Optimize>true</Optimize>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<NoWarn>1607</NoWarn>
|
<NoWarn>1607</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DebugType>full</DebugType>
|
||||||
<DebugType>full</DebugType>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<NoWarn>1607</NoWarn>
|
||||||
<NoWarn>1607</NoWarn>
|
</PropertyGroup>
|
||||||
</PropertyGroup>
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<OutputPath>bin\x64\Release\</OutputPath>
|
<Optimize>true</Optimize>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<DebugType>none</DebugType>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<NoWarn>1607</NoWarn>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
</PropertyGroup>
|
||||||
<NoWarn>1607</NoWarn>
|
<ItemGroup>
|
||||||
</PropertyGroup>
|
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
||||||
<ItemGroup>
|
<Reference Include="System" />
|
||||||
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Data" />
|
</ItemGroup>
|
||||||
<Reference Include="System.Xml" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Compile Include="Program.cs" />
|
||||||
<ItemGroup>
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
<Compile Include="Program.cs" />
|
</ItemGroup>
|
||||||
<Compile Include="AssemblyInfo.cs" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<PostBuildEvent>if not exist "$(SolutionDir)Plugins\API\DllExporter.exe" (move "$(TargetPath)" "$(SolutionDir)Plugins\API\DllExporter.exe")</PostBuildEvent>
|
|
||||||
</PropertyGroup>
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
</Project>
|
@ -1,233 +1,241 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2011 Birunthan Mohanathas
|
Copyright (C) 2011 Birunthan Mohanathas
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.Build.Utilities;
|
using Microsoft.Build.Utilities;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace DllExporter
|
namespace DllExporter
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static int Main(string[] args)
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
string configurationName = args[0];
|
if (args.Length < 4)
|
||||||
string platformTarget = args[1];
|
{
|
||||||
string targetDirectory = args[2];
|
Console.WriteLine("DllExporter error: Invalid arguments");
|
||||||
string targetDllName = targetDirectory + args[3];
|
return 1;
|
||||||
string targetIlName = targetDllName + ".il";
|
}
|
||||||
string targetResName = targetDllName + ".res";
|
|
||||||
|
string configurationName = args[0];
|
||||||
bool is64 = platformTarget.ToLower().Equals("x64");
|
string platformTarget = args[1];
|
||||||
bool isDebug = configurationName.ToLower().Equals("debug");
|
string targetDirectory = args[2];
|
||||||
|
string targetDllName = targetDirectory + args[3];
|
||||||
string ilasmPath = FindIlasmPath(is64);
|
string targetIlName = targetDllName + ".il";
|
||||||
if (ilasmPath == null)
|
string targetResName = targetDllName + ".res";
|
||||||
{
|
|
||||||
Console.WriteLine("DllExporter error: ilasm.exe not found");
|
bool is64 = platformTarget.ToLower().Equals("x64");
|
||||||
return 1;
|
bool isDebug = configurationName.ToLower().Equals("debug");
|
||||||
}
|
|
||||||
|
string ilasmPath = FindIlasmPath(is64);
|
||||||
string ildasmPath = FindIldasmPath();
|
if (ilasmPath == null)
|
||||||
if (ildasmPath == null)
|
{
|
||||||
{
|
Console.WriteLine("DllExporter error: ilasm.exe not found");
|
||||||
Console.WriteLine("DllExporter error: ildasm.exe not found");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
string ildasmPath = FindIldasmPath();
|
||||||
Directory.SetCurrentDirectory(targetDirectory);
|
if (ildasmPath == null)
|
||||||
|
{
|
||||||
// Disassemble
|
Console.WriteLine("DllExporter error: ildasm.exe not found");
|
||||||
Process ildasmProc = new Process();
|
return 1;
|
||||||
string ildasmArgs = string.Format(
|
}
|
||||||
"/nobar {0} /output=\"{1}\" \"{2}\"",
|
|
||||||
isDebug ? "/linenum" : "",
|
Directory.SetCurrentDirectory(targetDirectory);
|
||||||
targetIlName,
|
|
||||||
targetDllName);
|
// Disassemble
|
||||||
|
Process ildasmProc = new Process();
|
||||||
ildasmProc.StartInfo = new ProcessStartInfo(ildasmPath, ildasmArgs);
|
string ildasmArgs = string.Format(
|
||||||
ildasmProc.StartInfo.UseShellExecute = false;
|
"/nobar {0} /output=\"{1}\" \"{2}\"",
|
||||||
ildasmProc.StartInfo.CreateNoWindow = false;
|
isDebug ? "/linenum" : "",
|
||||||
ildasmProc.StartInfo.RedirectStandardOutput = true;
|
targetIlName,
|
||||||
ildasmProc.Start();
|
targetDllName);
|
||||||
ildasmProc.WaitForExit();
|
|
||||||
|
ildasmProc.StartInfo = new ProcessStartInfo(ildasmPath, ildasmArgs);
|
||||||
if (ildasmProc.ExitCode != 0)
|
ildasmProc.StartInfo.UseShellExecute = false;
|
||||||
{
|
ildasmProc.StartInfo.CreateNoWindow = false;
|
||||||
Console.WriteLine("DllExporter error: Unable to disassemble!");
|
ildasmProc.StartInfo.RedirectStandardOutput = true;
|
||||||
Console.WriteLine(ildasmProc.StandardOutput.ReadToEnd());
|
ildasmProc.Start();
|
||||||
return ildasmProc.ExitCode;
|
ildasmProc.WaitForExit();
|
||||||
}
|
|
||||||
|
if (ildasmProc.ExitCode != 0)
|
||||||
bool hasResource = File.Exists(targetResName);
|
{
|
||||||
|
Console.WriteLine("DllExporter error: Unable to disassemble!");
|
||||||
// Read disassembly and find methods marked with DllExport attribute
|
Console.WriteLine(ildasmProc.StandardOutput.ReadToEnd());
|
||||||
List<string> lines = new List<string>(File.ReadAllLines(targetIlName));
|
return ildasmProc.ExitCode;
|
||||||
int attributeIndex = 0;
|
}
|
||||||
int exportCount = 0;
|
|
||||||
while (true)
|
bool hasResource = File.Exists(targetResName);
|
||||||
{
|
|
||||||
attributeIndex = lines.FindIndex(attributeIndex, new Predicate<string>(x => x.Contains(".custom instance void") && x.Contains("DllExport::.ctor()")));
|
// Read disassembly and find methods marked with DllExport attribute
|
||||||
if (attributeIndex < 8) break;
|
List<string> lines = new List<string>(File.ReadAllLines(targetIlName));
|
||||||
|
int attributeIndex = 0;
|
||||||
int methodIndex = lines.FindLastIndex(attributeIndex, attributeIndex, new Predicate<string>(x => x.Contains(".method")));
|
int exportCount = 0;
|
||||||
if (methodIndex == -1)
|
while (true)
|
||||||
{
|
{
|
||||||
Console.WriteLine("DllExporter error: Unable to parse disassembly (.method not found)!");
|
attributeIndex = lines.FindIndex(attributeIndex, new Predicate<string>(x => x.Contains(".custom instance void") && x.Contains("DllExport::.ctor()")));
|
||||||
return 1;
|
if (attributeIndex < 8) break;
|
||||||
}
|
|
||||||
|
int methodIndex = lines.FindLastIndex(attributeIndex, attributeIndex, new Predicate<string>(x => x.Contains(".method")));
|
||||||
int functionIndex = lines.FindIndex(methodIndex, new Predicate<string>(x => x.Contains("(")));
|
if (methodIndex == -1)
|
||||||
if (functionIndex == -1)
|
{
|
||||||
{
|
Console.WriteLine("DllExporter error: Unable to parse disassembly (.method not found)!");
|
||||||
Console.WriteLine("DllExporter error: Unable to parse disassembly (bracket not found)!");
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
|
int functionIndex = lines.FindIndex(methodIndex, new Predicate<string>(x => x.Contains("(")));
|
||||||
int bracketPos = lines[functionIndex].IndexOf('(');
|
if (functionIndex == -1)
|
||||||
int functionNamePos = lines[functionIndex].LastIndexOf(' ', bracketPos);
|
{
|
||||||
string functionName = lines[functionIndex].Substring(functionNamePos, bracketPos - functionNamePos);
|
Console.WriteLine("DllExporter error: Unable to parse disassembly (bracket not found)!");
|
||||||
|
return 1;
|
||||||
// Change calling convention to cdecl
|
}
|
||||||
lines[functionIndex] = string.Format("{0} modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) {1}", lines[functionIndex].Substring(0, functionNamePos - 1), lines[functionIndex].Substring(functionNamePos));
|
|
||||||
|
int bracketPos = lines[functionIndex].IndexOf('(');
|
||||||
int attributeBeginPos = lines[attributeIndex].IndexOf('.');
|
int functionNamePos = lines[functionIndex].LastIndexOf(' ', bracketPos);
|
||||||
string spaces = new string(' ', attributeBeginPos);
|
string functionName = lines[functionIndex].Substring(functionNamePos, bracketPos - functionNamePos);
|
||||||
|
|
||||||
// Replace attribute with export
|
// Change calling convention to cdecl
|
||||||
++exportCount;
|
lines[functionIndex] = string.Format("{0} modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) {1}", lines[functionIndex].Substring(0, functionNamePos - 1), lines[functionIndex].Substring(functionNamePos));
|
||||||
lines[attributeIndex] = string.Format("{0}.export [{1}] as {2}", spaces, exportCount, functionName);
|
|
||||||
|
int attributeBeginPos = lines[attributeIndex].IndexOf('.');
|
||||||
++attributeIndex;
|
string spaces = new string(' ', attributeBeginPos);
|
||||||
}
|
|
||||||
|
// Replace attribute with export
|
||||||
if (exportCount == 0)
|
++exportCount;
|
||||||
{
|
lines[attributeIndex] = string.Format("{0}.export [{1}] as {2}", spaces, exportCount, functionName);
|
||||||
Console.WriteLine("DllExporter warning: Nothing found to export.");
|
|
||||||
}
|
++attributeIndex;
|
||||||
|
}
|
||||||
// Remove the DllExport class
|
|
||||||
int classIndex = lines.FindIndex(new Predicate<string>(x => x.Contains(".class ") && x.EndsWith(".DllExport")));
|
if (exportCount == 0)
|
||||||
if (classIndex == -1)
|
{
|
||||||
{
|
Console.WriteLine("DllExporter warning: Nothing found to export.");
|
||||||
Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class not found)!");
|
}
|
||||||
return 1;
|
|
||||||
}
|
// Remove the DllExport class
|
||||||
else
|
int classIndex = lines.FindIndex(new Predicate<string>(x => x.Contains(".class ") && x.EndsWith(".DllExport")));
|
||||||
{
|
if (classIndex == -1)
|
||||||
int classEndIndex = lines.FindIndex(classIndex, new Predicate<string>(x => x.Contains("} // end of class") && x.EndsWith(".DllExport")));
|
{
|
||||||
if (classEndIndex == -1)
|
Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class not found)!");
|
||||||
{
|
return 1;
|
||||||
Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class end not found)!");
|
}
|
||||||
return 1;
|
else
|
||||||
}
|
{
|
||||||
|
int classEndIndex = lines.FindIndex(classIndex, new Predicate<string>(x => x.Contains("} // end of class") && x.EndsWith(".DllExport")));
|
||||||
lines.RemoveRange(classIndex, classEndIndex - classIndex + 2);
|
if (classEndIndex == -1)
|
||||||
}
|
{
|
||||||
|
Console.WriteLine("DllExporter error: Unable to parse disassembly (DllExport class end not found)!");
|
||||||
// Write everything back
|
return 1;
|
||||||
File.WriteAllLines(targetIlName, lines.ToArray());
|
}
|
||||||
|
|
||||||
// Reassemble
|
lines.RemoveRange(classIndex, classEndIndex - classIndex + 2);
|
||||||
Process ilasmProc = new Process();
|
}
|
||||||
string resource = hasResource ? string.Format("/resource=\"{0}\"", targetResName) : "";
|
|
||||||
string ilasmArgs = string.Format("/nologo /quiet /dll {0} {1} /output=\"{2}\" {3} \"{4}\"", isDebug ? "/debug /pdb" : "/optimize", is64 ? "/x64 /PE64" : "", targetDllName, resource, targetIlName);
|
// Write everything back
|
||||||
ilasmProc.StartInfo = new ProcessStartInfo(ilasmPath, ilasmArgs);
|
File.WriteAllLines(targetIlName, lines.ToArray());
|
||||||
ilasmProc.StartInfo.UseShellExecute = false;
|
|
||||||
ilasmProc.StartInfo.CreateNoWindow = false;
|
// Reassemble
|
||||||
ilasmProc.StartInfo.RedirectStandardOutput = true;
|
Process ilasmProc = new Process();
|
||||||
ilasmProc.Start();
|
string resource = hasResource ? string.Format("/resource=\"{0}\"", targetResName) : "";
|
||||||
ilasmProc.WaitForExit();
|
string ilasmArgs = string.Format("/nologo /quiet /dll {0} {1} /output=\"{2}\" {3} \"{4}\"", isDebug ? "/debug /pdb" : "/optimize", is64 ? "/x64 /PE64" : "", targetDllName, resource, targetIlName);
|
||||||
|
ilasmProc.StartInfo = new ProcessStartInfo(ilasmPath, ilasmArgs);
|
||||||
if (ilasmProc.ExitCode != 0)
|
ilasmProc.StartInfo.UseShellExecute = false;
|
||||||
{
|
ilasmProc.StartInfo.CreateNoWindow = false;
|
||||||
Console.WriteLine("DllExporter error: Unable to assemble!");
|
ilasmProc.StartInfo.RedirectStandardOutput = true;
|
||||||
Console.WriteLine(ilasmProc.StandardOutput.ReadToEnd());
|
ilasmProc.Start();
|
||||||
return ilasmProc.ExitCode;
|
ilasmProc.WaitForExit();
|
||||||
}
|
|
||||||
|
if (ilasmProc.ExitCode != 0)
|
||||||
// Cleanup
|
{
|
||||||
File.Delete(targetIlName);
|
Console.WriteLine("DllExporter error: Unable to assemble!");
|
||||||
File.Delete(targetResName);
|
Console.WriteLine(ilasmProc.StandardOutput.ReadToEnd());
|
||||||
|
return ilasmProc.ExitCode;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
// Cleanup
|
||||||
/// <summary>
|
File.Delete(targetIlName);
|
||||||
/// Finds path to ilasm.exe.
|
File.Delete(targetResName);
|
||||||
/// </summary>
|
|
||||||
private static string FindIlasmPath(bool x64)
|
Console.WriteLine("DllExporter: Processed {0}", args[3]);
|
||||||
{
|
|
||||||
var arch = x64 ? DotNetFrameworkArchitecture.Bitness64 : DotNetFrameworkArchitecture.Bitness32;
|
return 0;
|
||||||
var path = ToolLocationHelper.GetPathToDotNetFrameworkFile(
|
}
|
||||||
"ilasm.exe", TargetDotNetFrameworkVersion.Version20, arch);
|
|
||||||
return File.Exists(path) ? path : null;
|
/// <summary>
|
||||||
}
|
/// Finds path to ilasm.exe.
|
||||||
|
/// </summary>
|
||||||
/// <summary>
|
private static string FindIlasmPath(bool x64)
|
||||||
/// Finds path to ildasm.exe.
|
{
|
||||||
/// </summary>
|
var arch = x64 ? DotNetFrameworkArchitecture.Bitness64 : DotNetFrameworkArchitecture.Bitness32;
|
||||||
private static string FindIldasmPath()
|
var path = ToolLocationHelper.GetPathToDotNetFrameworkFile(
|
||||||
{
|
"ilasm.exe", TargetDotNetFrameworkVersion.Version20, arch);
|
||||||
var sdkPath = Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\Microsoft SDKs\Windows\");
|
return File.Exists(path) ? path : null;
|
||||||
if (!Directory.Exists(sdkPath))
|
}
|
||||||
{
|
|
||||||
sdkPath = Environment.ExpandEnvironmentVariables(@"%ProgramFiles(x86)%\Microsoft SDKs\Windows\");
|
/// <summary>
|
||||||
}
|
/// Finds path to ildasm.exe.
|
||||||
|
/// </summary>
|
||||||
if (!Directory.Exists(sdkPath))
|
private static string FindIldasmPath()
|
||||||
{
|
{
|
||||||
throw new DirectoryNotFoundException("'Microsoft SDKs' directory not found");
|
var sdkPath = Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\Microsoft SDKs\Windows\");
|
||||||
}
|
if (!Directory.Exists(sdkPath))
|
||||||
|
{
|
||||||
// Get the version directories.
|
sdkPath = Environment.ExpandEnvironmentVariables(@"%ProgramFiles(x86)%\Microsoft SDKs\Windows\");
|
||||||
var sdkVersionDirectories = Directory.GetDirectories(sdkPath);
|
}
|
||||||
foreach (var sdkVersionDirectory in sdkVersionDirectories)
|
|
||||||
{
|
if (!Directory.Exists(sdkPath))
|
||||||
var binDirectory = Path.Combine(sdkVersionDirectory, @"bin");
|
{
|
||||||
if (!Directory.Exists(binDirectory))
|
throw new DirectoryNotFoundException("'Microsoft SDKs' directory not found");
|
||||||
{
|
}
|
||||||
continue;
|
|
||||||
}
|
// Get the version directories.
|
||||||
|
var sdkVersionDirectories = Directory.GetDirectories(sdkPath);
|
||||||
// Check for e.g. 'Microsoft SDKs\v8.0A\bin\ildasm.exe'.
|
foreach (var sdkVersionDirectory in sdkVersionDirectories)
|
||||||
var ildasmPath = Path.Combine(binDirectory, @"ildasm.exe");
|
{
|
||||||
if (File.Exists(ildasmPath))
|
var binDirectory = Path.Combine(sdkVersionDirectory, @"bin");
|
||||||
{
|
if (!Directory.Exists(binDirectory))
|
||||||
return ildasmPath;
|
{
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
// Check for e.g. 'Microsoft SDKs\v8.0A\bin\NETFX 4.0 Tools\ildasm.exe'.
|
|
||||||
var toolsDirectories = Directory.GetDirectories(binDirectory, "NETFX*Tools");
|
// Check for e.g. 'Microsoft SDKs\v8.0A\bin\ildasm.exe'.
|
||||||
foreach (var toolDirectory in toolsDirectories)
|
var ildasmPath = Path.Combine(binDirectory, @"ildasm.exe");
|
||||||
{
|
if (File.Exists(ildasmPath))
|
||||||
ildasmPath = Path.Combine(toolDirectory, @"ildasm.exe");
|
{
|
||||||
if (File.Exists(ildasmPath))
|
return ildasmPath;
|
||||||
{
|
}
|
||||||
return ildasmPath;
|
|
||||||
}
|
// Check for e.g. 'Microsoft SDKs\v8.0A\bin\NETFX 4.0 Tools\ildasm.exe'.
|
||||||
}
|
var toolsDirectories = Directory.GetDirectories(binDirectory, "NETFX*Tools");
|
||||||
}
|
foreach (var toolDirectory in toolsDirectories)
|
||||||
|
{
|
||||||
return null;
|
ildasmPath = Path.Combine(toolDirectory, @"ildasm.exe");
|
||||||
}
|
if (File.Exists(ildasmPath))
|
||||||
}
|
{
|
||||||
}
|
return ildasmPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -97,9 +97,9 @@
|
|||||||
<DependentUpon>InputBox.cs</DependentUpon>
|
<DependentUpon>InputBox.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cs.props"/>
|
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cs.props" />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>"$(SolutionDir)Plugins\API\DllExporter.exe" "$(ConfigurationName)" "$(PlatformName)" "$(TargetDir)\" "$(TargetFileName)"</PostBuildEvent>
|
<PostBuildEvent>"$(RmOutDirRoot)Tools\DllExporter.exe" "$(ConfigurationName)" "$(PlatformName)" "$(TargetDir)\" "$(TargetFileName)"</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Common\Common.vcx
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common_Test", "Common\Common_Test.vcxproj", "{442084A6-2069-4927-B0C9-51525A720CB2}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common_Test", "Common\Common_Test.vcxproj", "{442084A6-2069-4927-B0C9-51525A720CB2}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DllExporter", "Build\DllExporter\DllExporter.csproj", "{49D56CA5-54AB-45C9-A245-EAE588FCBFE1}"
|
||||||
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Installer", "Installer\Installer.vcxproj", "{2FCFBFD2-2720-4BDD-B620-4BDD3DBB8D3D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Installer", "Installer\Installer.vcxproj", "{2FCFBFD2-2720-4BDD-B620-4BDD3DBB8D3D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Language", "Language\Language.vcxproj", "{6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Language", "Language\Language.vcxproj", "{6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}"
|
||||||
@ -32,8 +34,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SkinInstallerLauncher", "Sk
|
|||||||
{6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA} = {6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA}
|
{6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA} = {6F5D4C4A-C8C3-41DA-BF44-6D42B76464DA}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DllExporter", "Plugins\API\DllExporter\DllExporter.csproj", "{49D56CA5-54AB-45C9-A245-EAE588FCBFE1}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugins\PluginAdvancedCPU\PluginAdvancedCPU.vcxproj", "{EE8EC522-8430-4B46-86A3-D943D77F9E4B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugins\PluginAdvancedCPU\PluginAdvancedCPU.vcxproj", "{EE8EC522-8430-4B46-86A3-D943D77F9E4B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginCoreTemp", "Plugins\PluginCoreTemp\PluginCoreTemp.vcxproj", "{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginCoreTemp", "Plugins\PluginCoreTemp\PluginCoreTemp.vcxproj", "{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}"
|
||||||
@ -43,6 +43,9 @@ EndProject
|
|||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFolderInfo", "Plugins\PluginFolderInfo\PluginFolderInfo.vcxproj", "{A221819D-4263-42AA-B22A-C022924842A7}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFolderInfo", "Plugins\PluginFolderInfo\PluginFolderInfo.vcxproj", "{A221819D-4263-42AA-B22A-C022924842A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInputText", "Plugins\PluginInputText\PluginInputText.csproj", "{2CFEC79A-E39E-4FFD-ABC2-C4A69DD1E44D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInputText", "Plugins\PluginInputText\PluginInputText.csproj", "{2CFEC79A-E39E-4FFD-ABC2-C4A69DD1E44D}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{49D56CA5-54AB-45C9-A245-EAE588FCBFE1} = {49D56CA5-54AB-45C9-A245-EAE588FCBFE1}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginiTunes", "Plugins\PluginiTunes\PluginiTunes.vcxproj", "{A2DD3CBE-B140-4892-A875-24107FA52518}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginiTunes", "Plugins\PluginiTunes\PluginiTunes.vcxproj", "{A2DD3CBE-B140-4892-A875-24107FA52518}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Loading…
Reference in New Issue
Block a user