Compare commits
20 Commits
Author | SHA1 | Date |
---|---|---|
Alexei Stukov | 4707671795 | |
Alexei Stukov | 222c2347fd | |
Alexei Stukov | 0d81028a3c | |
Alexei Stukov | 7b99b7d7f1 | |
Modder4869 | fa20c57f86 | |
Alexei Stukov | 884ea57c14 | |
Alexei Stukov | a6d81c2f25 | |
Alexei Stukov | e85e3a49d9 | |
Alexei Stukov | b62ab6259e | |
Alexei Stukov | 82232fa9c6 | |
Modder4869 | 57e16e3b43 | |
Modder4869 | 7f6cd474fd | |
Alexei Stukov | 718ab4fb7d | |
Modder4869 | c187ed3127 | |
Alexei Stukov | 4966be2020 | |
Samuel Elliott | 1d7627bce7 | |
Jiiks | e9e3627339 | |
Jiiks | 8688a9ea7d | |
Jiiks | 2a29984950 | |
Jiiks | cf1a9ecb91 |
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
name: Issue template
|
||||
about: Template for all future issues
|
||||
|
||||
---
|
||||
|
||||
*Before* you create an issue, make sure you have:
|
||||
|
||||
1. Checked that that issue hasn't already been submitted. You can search open issues [here](https://github.com/Jiiks/BetterDiscordApp/issues).
|
||||
2. Checked that there isn't an answer in either of the Discord servers (if you can access them - don't complain if you can't).
|
||||
3. Checked that it isn't in the following list of frequently asked questions.
|
||||
|
||||
If none of that helps you, delete the prefilled contents of this issue and ask whatever question you may have *in English so we can understand it*.
|
||||
|
||||
### FAQ
|
||||
|
||||
> *BetterDiscord doesn't work.*
|
||||
> *BetterDiscord won't install.*
|
||||
> *BetterDiscord doesn't support macOS.*
|
||||
|
||||
This branch isn't being updated anymore. Until BetterDiscord v2 is released you can use [Zach Rauen's fork](https://github.com/rauenzi/BetterDiscordApp).
|
||||
|
||||
> *BetterDiscord doesn't support Linux.*
|
||||
|
||||
There's an installer script for BetterDiscord on Linux available [here](https://github.com/bb010g/betterdiscordctl).
|
||||
|
||||
> *BetterDiscord doesn't work in my browser.*
|
||||
|
||||
The browser version doesn't exist anymore. Use the desktop client.
|
||||
|
||||
> *BetterDiscord doesn't work on my phone.*
|
||||
|
||||
... and never will. BetterDiscord is a client modification for Discord's desktop Electron client. (Electron is a framework for making cross platform apps using web technologies. Basically the desktop client is just the web client in a specialised web browser.)
|
||||
|
||||
> *Is there any security risks involved with installing BetterDiscord?*
|
||||
> *My friend was hacked after he/she installed BetterDiscord.*
|
||||
|
||||
*Not by itself.* However, BetterDiscord allows loading plugins. Discord, BetterDiscord, and any plugins you install (even without enabling) have full access to your system as your local user account. (Including full access to your Discord account.) So, make sure you only download plugins from sources you trust.
|
||||
|
||||
Also, please note that [BetterDocs](https://betterdocs.net) and other third-party sources by definition *are not* affiliated with BetterDiscord or it's developers.
|
||||
|
||||
> *How do I install plugin [x]?*
|
||||
> *Is there a plugin to [x]?*
|
||||
> *Does [x] theme exist?*
|
||||
|
||||
https://imgur.com/lczPQxW
|
||||
|
||||
> *Minimal mode broke everything.*
|
||||
|
||||
You can get back into Discord's settings to disable it by pressing `Control + ,` on Windows and Linux or `Command + ,` on macOS.
|
||||
|
||||
> *How do I completely hide messages from people I've blocked?*
|
||||
|
||||
Add this to your custom CSS:
|
||||
|
||||
```css
|
||||
.message-group-blocked {
|
||||
display: none !important;
|
||||
}
|
||||
```
|
||||
|
||||
> *How do I remove BetterDiscord?*
|
||||
|
||||
BetterDiscord is installed to the following locations:
|
||||
|
||||
Platform | Discord path
|
||||
-------------|---------------
|
||||
Windows | `%APPDATA%`\discord\0.0.`*`\modules\discord_desktop_core
|
||||
macOS | ~/Library/Application Support/discord/0.0.`*`/modules/discord_desktop_core
|
||||
Linux | ~/.config/discord/0.0.`*`/modules/discord_desktop_core
|
||||
|
||||
To remove BetterDiscord, open the file `index.js` in that directory and make sure only this line exists:
|
||||
|
||||
```js
|
||||
module.exports = require('./core');
|
||||
```
|
||||
|
||||
Then, delete the `core` directory.
|
||||
|
||||
BetterDiscord's data is stored in the following locations:
|
||||
|
||||
Platform | BetterDiscord data path
|
||||
-------------|---------------
|
||||
Windows | `%APPDATA%`\BetterDiscord
|
||||
macOS | ~/Library/Preferences/BetterDiscord
|
||||
Linux | ~/.config/BetterDiscord
|
||||
|
||||
To remove all of BetterDiscord's data, just delete that directory.
|
||||
|
||||
> *BetterDiscord v2?*
|
||||
|
||||
[BetterDiscord v2 is the new version of BetterDiscord currently in development.](https://github.com/JsSucks/BetterDiscordApp) If you'd like to help out with BetterDiscord v2, join the JsSucks Discord server. (Invite code `KYKwv4R`.) The only requirement is JavaScript/ES6 knowledge.
|
|
@ -14,4 +14,8 @@ Installers/dotNet/bin/
|
|||
Installers/dotNet/packages/
|
||||
Installers/dotNet/dlls/
|
||||
v2/dist/vendor/
|
||||
v2/lib/static.js
|
||||
v2/lib/static.js
|
||||
**/*.suo
|
||||
Installers/**/*/bin
|
||||
Installers/**/*/obj
|
||||
Installers/**/*/packages
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
*Before* you create an issue, make sure you have:
|
||||
|
||||
1. Checked that that issue hasn't already been submitted. You can search open issues [here](https://github.com/Jiiks/BetterDiscordApp/issues).
|
||||
2. Checked that there isn't an answer in either of the Discord servers (if you can access them - don't complain if you can't).
|
||||
3. Checked that it isn't in the following list of frequently asked questions.
|
||||
|
||||
If none of that helps you, delete the prefilled contents of this issue and ask whatever question you may have *in English so we can understand it*.
|
||||
|
||||
### FAQ
|
||||
|
||||
> *BetterDiscord doesn't work.*
|
||||
> *BetterDiscord won't install.*
|
||||
> *BetterDiscord doesn't support macOS.*
|
||||
|
||||
This branch isn't being updated anymore. Until BetterDiscord v2 is released you can use [Zach Rauen's fork](https://github.com/rauenzi/BetterDiscordApp).
|
||||
|
||||
> *BetterDiscord doesn't support Linux.*
|
||||
|
||||
There's an installer script for BetterDiscord on Linux available [here](https://github.com/bb010g/betterdiscordctl).
|
||||
|
||||
> *BetterDiscord doesn't work in my browser.*
|
||||
|
||||
The browser version doesn't exist anymore. Use the desktop client.
|
||||
|
||||
> *BetterDiscord doesn't work on my phone.*
|
||||
|
||||
... and never will. BetterDiscord is a client modification for Discord's desktop Electron client. (Electron is a framework for making cross platform apps using web technologies. Basically the desktop client is just the web client in a specialised web browser.)
|
||||
|
||||
> *Is there any security risks involved with installing BetterDiscord?*
|
||||
> *My friend was hacked after he/she installed BetterDiscord.*
|
||||
|
||||
*Not by itself.* However, BetterDiscord allows loading plugins. Discord, BetterDiscord, and any plugins you install (even without enabling) have full access to your system as your local user account. (Including full access to your Discord account.) So, make sure you only download plugins from sources you trust.
|
||||
|
||||
Also, please note that [BetterDocs](https://betterdocs.net) and other third-party sources by definition *are not* affiliated with BetterDiscord or it's developers.
|
||||
|
||||
> *How do I install plugin [x]?*
|
||||
> *Is there a plugin to [x]?*
|
||||
> *Does [x] theme exist?*
|
||||
|
||||
https://imgur.com/lczPQxW
|
||||
|
||||
> *Minimal mode broke everything.*
|
||||
|
||||
You can get back into Discord's settings to disable it by pressing `Control + ,` on Windows and Linux or `Command + ,` on macOS.
|
||||
|
||||
> *How do I completely hide messages from people I've blocked?*
|
||||
|
||||
Add this to your custom CSS:
|
||||
|
||||
```css
|
||||
.message-group-blocked {
|
||||
display: none !important;
|
||||
}
|
||||
```
|
||||
|
||||
> *How do I remove BetterDiscord?*
|
||||
|
||||
BetterDiscord is installed to the following locations:
|
||||
|
||||
Platform | Discord path
|
||||
-------------|---------------
|
||||
Windows | `%APPDATA%`\discord\0.0.`*`\modules\discord_desktop_core
|
||||
macOS | ~/Library/Application Support/discord/0.0.`*`/modules/discord_desktop_core
|
||||
Linux | ~/.config/discord/0.0.`*`/modules/discord_desktop_core
|
||||
|
||||
To remove BetterDiscord, open the file `index.js` in that directory and make sure only this line exists:
|
||||
|
||||
```js
|
||||
module.exports = require('./core');
|
||||
```
|
||||
|
||||
Then, delete the `core` directory.
|
||||
|
||||
BetterDiscord's data is stored in the following locations:
|
||||
|
||||
Platform | BetterDiscord data path
|
||||
-------------|---------------
|
||||
Windows | `%APPDATA%`\BetterDiscord
|
||||
macOS | ~/Library/Preferences/BetterDiscord
|
||||
Linux | ~/.config/BetterDiscord
|
||||
|
||||
To remove all of BetterDiscord's data, just delete that directory.
|
||||
|
||||
> *BetterDiscord v2?*
|
||||
|
||||
[BetterDiscord v2 is the new version of BetterDiscord currently in development.](https://github.com/JsSucks/BetterDiscordApp) If you'd like to help out with BetterDiscord v2, join the JsSucks Discord server. (Invite code `KYKwv4R`.) The only requirement is JavaScript/ES6 knowledge.
|
Binary file not shown.
|
@ -42,14 +42,14 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="asardotnetasync">
|
||||
<HintPath>..\..\..\..\..\..\Projects\C#\asardotnetasync\asardotnetasync\bin\Release\asardotnetasync.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\Projects\C#\asardotnetasync\asardotnetasync\bin\Release\asardotnetasync.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\..\..\..\..\libs\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath>..\..\..\..\..\libs\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
</configuration>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
</configuration>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,15 +0,0 @@
|
|||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\BetterDiscordWI.exe.config
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\BetterDiscordWI.exe
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\BetterDiscordWI.pdb
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.csprojResolveAssemblyReference.cache
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.FormMain.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.Properties.Resources.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.csproj.GenerateResource.Cache
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.exe
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.pdb
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.panels.LicensePanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.panels.ConfigPanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Debug\BetterDiscordWI.panels.InstallPanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\Newtonsoft.Json.dll
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\asardotnetasync.dll
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Debug\asardotnetasync.pdb
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
9ed8cc2d0146708e9135d42f9b545d4d9dc45abd
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,12 +0,0 @@
|
|||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Release\BetterDiscordWI.exe.config
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Release\BetterDiscordWI.exe
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\bin\Release\BetterDiscordWI.pdb
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.FormMain.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.panels.ConfigPanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.panels.InstallPanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.panels.LicensePanel.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.Properties.Resources.resources
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.csproj.GenerateResource.Cache
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.exe
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.pdb
|
||||
G:\Github\BetterDiscordApp\Installers\dotNet2\BetterDiscordWI\BetterDiscordWI\obj\Release\BetterDiscordWI.csprojResolveAssemblyReference.cache
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,297 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
static class Common
|
||||
{
|
||||
private const int DelayUntilReboot = 4;
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags);
|
||||
|
||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool SetDllDirectory(string lpPathName);
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public static void Log(string format, params object[] args)
|
||||
{
|
||||
// Should this be trace?
|
||||
Debug.WriteLine("=== COSTURA === " + string.Format(format, args));
|
||||
}
|
||||
|
||||
static void CopyTo(Stream source, Stream destination)
|
||||
{
|
||||
var array = new byte[81920];
|
||||
int count;
|
||||
while ((count = source.Read(array, 0, array.Length)) != 0)
|
||||
{
|
||||
destination.Write(array, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
static void CreateDirectory(string tempBasePath)
|
||||
{
|
||||
if (!Directory.Exists(tempBasePath))
|
||||
{
|
||||
Directory.CreateDirectory(tempBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
static byte[] ReadStream(Stream stream)
|
||||
{
|
||||
var data = new Byte[stream.Length];
|
||||
stream.Read(data, 0, data.Length);
|
||||
return data;
|
||||
}
|
||||
|
||||
public static string CalculateChecksum(string filename)
|
||||
{
|
||||
using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
|
||||
using (var bs = new BufferedStream(fs))
|
||||
using (var sha1 = new SHA1CryptoServiceProvider())
|
||||
{
|
||||
var hash = sha1.ComputeHash(bs);
|
||||
var formatted = new StringBuilder(2 * hash.Length);
|
||||
foreach (var b in hash)
|
||||
{
|
||||
formatted.AppendFormat("{0:X2}", b);
|
||||
}
|
||||
return formatted.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static Assembly ReadExistingAssembly(AssemblyName name)
|
||||
{
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
var assemblies = currentDomain.GetAssemblies();
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
var currentName = assembly.GetName();
|
||||
if (string.Equals(currentName.Name, name.Name, StringComparison.InvariantCultureIgnoreCase) &&
|
||||
string.Equals(CultureToString(currentName.CultureInfo), CultureToString(name.CultureInfo), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Log("Assembly '{0}' already loaded, returning existing assembly", assembly.FullName);
|
||||
|
||||
return assembly;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static string CultureToString(CultureInfo culture)
|
||||
{
|
||||
if (culture == null)
|
||||
return "";
|
||||
|
||||
return culture.Name;
|
||||
}
|
||||
|
||||
public static Assembly ReadFromDiskCache(string tempBasePath, AssemblyName requestedAssemblyName)
|
||||
{
|
||||
var name = requestedAssemblyName.Name.ToLowerInvariant();
|
||||
|
||||
if (requestedAssemblyName.CultureInfo != null && !String.IsNullOrEmpty(requestedAssemblyName.CultureInfo.Name))
|
||||
name = $"{requestedAssemblyName.CultureInfo.Name}.{name}";
|
||||
|
||||
var bittyness = IntPtr.Size == 8 ? "64" : "32";
|
||||
var assemblyTempFilePath = Path.Combine(tempBasePath, String.Concat(name, ".dll"));
|
||||
if (File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
return Assembly.LoadFile(assemblyTempFilePath);
|
||||
}
|
||||
assemblyTempFilePath = Path.ChangeExtension(assemblyTempFilePath, "exe");
|
||||
if (File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
return Assembly.LoadFile(assemblyTempFilePath);
|
||||
}
|
||||
assemblyTempFilePath = Path.Combine(Path.Combine(tempBasePath, bittyness), String.Concat(name, ".dll"));
|
||||
if (File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
return Assembly.LoadFile(assemblyTempFilePath);
|
||||
}
|
||||
assemblyTempFilePath = Path.ChangeExtension(assemblyTempFilePath, "exe");
|
||||
if (File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
return Assembly.LoadFile(assemblyTempFilePath);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Assembly ReadFromEmbeddedResources(Dictionary<string, string> assemblyNames, Dictionary<string, string> symbolNames, AssemblyName requestedAssemblyName)
|
||||
{
|
||||
var name = requestedAssemblyName.Name.ToLowerInvariant();
|
||||
|
||||
if (requestedAssemblyName.CultureInfo != null && !String.IsNullOrEmpty(requestedAssemblyName.CultureInfo.Name))
|
||||
name = $"{requestedAssemblyName.CultureInfo.Name}.{name}";
|
||||
|
||||
byte[] assemblyData;
|
||||
using (var assemblyStream = LoadStream(assemblyNames, name))
|
||||
{
|
||||
if (assemblyStream == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
assemblyData = ReadStream(assemblyStream);
|
||||
}
|
||||
|
||||
using (var pdbStream = LoadStream(symbolNames, name))
|
||||
{
|
||||
if (pdbStream != null)
|
||||
{
|
||||
var pdbData = ReadStream(pdbStream);
|
||||
return Assembly.Load(assemblyData, pdbData);
|
||||
}
|
||||
}
|
||||
|
||||
return Assembly.Load(assemblyData);
|
||||
}
|
||||
|
||||
static Stream LoadStream(Dictionary<string, string> resourceNames, string name)
|
||||
{
|
||||
string value;
|
||||
if (resourceNames.TryGetValue(name, out value))
|
||||
return LoadStream(value);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Stream LoadStream(string fullname)
|
||||
{
|
||||
var executingAssembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
if (fullname.EndsWith(".compressed"))
|
||||
{
|
||||
using (var stream = executingAssembly.GetManifestResourceStream(fullname))
|
||||
using (var compressStream = new DeflateStream(stream, CompressionMode.Decompress))
|
||||
{
|
||||
var memStream = new MemoryStream();
|
||||
CopyTo(compressStream, memStream);
|
||||
memStream.Position = 0;
|
||||
return memStream;
|
||||
}
|
||||
}
|
||||
|
||||
return executingAssembly.GetManifestResourceStream(fullname);
|
||||
}
|
||||
|
||||
// Mutex code from http://stackoverflow.com/questions/229565/what-is-a-good-pattern-for-using-a-global-mutex-in-c
|
||||
public static void PreloadUnmanagedLibraries(string hash, string tempBasePath, IEnumerable<string> libs, Dictionary<string, string> checksums)
|
||||
{
|
||||
var mutexId = $"Global\\Costura{hash}";
|
||||
|
||||
using (var mutex = new Mutex(false, mutexId))
|
||||
{
|
||||
var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
|
||||
var securitySettings = new MutexSecurity();
|
||||
securitySettings.AddAccessRule(allowEveryoneRule);
|
||||
mutex.SetAccessControl(securitySettings);
|
||||
|
||||
var hasHandle = false;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
hasHandle = mutex.WaitOne(60000, false);
|
||||
if (hasHandle == false)
|
||||
throw new TimeoutException("Timeout waiting for exclusive access");
|
||||
}
|
||||
catch (AbandonedMutexException)
|
||||
{
|
||||
hasHandle = true;
|
||||
}
|
||||
|
||||
var bittyness = IntPtr.Size == 8 ? "64" : "32";
|
||||
CreateDirectory(Path.Combine(tempBasePath, bittyness));
|
||||
InternalPreloadUnmanagedLibraries(tempBasePath, libs, checksums);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hasHandle)
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void InternalPreloadUnmanagedLibraries(string tempBasePath, IEnumerable<string> libs, Dictionary<string, string> checksums)
|
||||
{
|
||||
string name;
|
||||
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
name = ResourceNameToPath(lib);
|
||||
|
||||
var assemblyTempFilePath = Path.Combine(tempBasePath, name);
|
||||
|
||||
if (File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
var checksum = CalculateChecksum(assemblyTempFilePath);
|
||||
if (checksum != checksums[lib])
|
||||
File.Delete(assemblyTempFilePath);
|
||||
}
|
||||
|
||||
if (!File.Exists(assemblyTempFilePath))
|
||||
{
|
||||
using (var copyStream = LoadStream(lib))
|
||||
using (var assemblyTempFile = File.OpenWrite(assemblyTempFilePath))
|
||||
{
|
||||
CopyTo(copyStream, assemblyTempFile);
|
||||
}
|
||||
if (!MoveFileEx(assemblyTempFilePath, null, DelayUntilReboot))
|
||||
{
|
||||
//TODO: for now we ignore the return value.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetDllDirectory(tempBasePath);
|
||||
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
name = ResourceNameToPath(lib);
|
||||
|
||||
if (name.EndsWith(".dll"))
|
||||
{
|
||||
var assemblyTempFilePath = Path.Combine(tempBasePath, name);
|
||||
|
||||
LoadLibrary(assemblyTempFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static string ResourceNameToPath(string lib)
|
||||
{
|
||||
var bittyness = IntPtr.Size == 8 ? "64" : "32";
|
||||
|
||||
var name = lib;
|
||||
|
||||
if (lib.StartsWith(String.Concat("costura", bittyness, ".")))
|
||||
{
|
||||
name = Path.Combine(bittyness, lib.Substring(10));
|
||||
}
|
||||
else if (lib.StartsWith("costura."))
|
||||
{
|
||||
name = lib.Substring(8);
|
||||
}
|
||||
|
||||
if (name.EndsWith(".compressed"))
|
||||
{
|
||||
name = name.Substring(0, name.Length - 11);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
003befe214f35e255c343afecd5f5dea062bb193
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,63 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
|
||||
static class ILTemplate
|
||||
{
|
||||
static readonly object nullCacheLock = new object();
|
||||
static readonly Dictionary<string, bool> nullCache = new Dictionary<string, bool>();
|
||||
|
||||
static readonly Dictionary<string, string> assemblyNames = new Dictionary<string, string>();
|
||||
static readonly Dictionary<string, string> symbolNames = new Dictionary<string, string>();
|
||||
|
||||
static int isAttached = 0;
|
||||
|
||||
public static void Attach()
|
||||
{
|
||||
if (Interlocked.Exchange(ref isAttached, 1) == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += ResolveAssembly;
|
||||
}
|
||||
|
||||
public static Assembly ResolveAssembly(object sender, ResolveEventArgs e)
|
||||
{
|
||||
lock (nullCacheLock)
|
||||
{
|
||||
if (nullCache.ContainsKey(e.Name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var requestedAssemblyName = new AssemblyName(e.Name);
|
||||
|
||||
var assembly = Common.ReadExistingAssembly(requestedAssemblyName);
|
||||
if (assembly != null)
|
||||
{
|
||||
return assembly;
|
||||
}
|
||||
|
||||
Common.Log("Loading assembly '{0}' into the AppDomain", requestedAssemblyName);
|
||||
|
||||
assembly = Common.ReadFromEmbeddedResources(assemblyNames, symbolNames, requestedAssemblyName);
|
||||
if (assembly == null)
|
||||
{
|
||||
lock (nullCacheLock)
|
||||
{
|
||||
nullCache[e.Name] = true;
|
||||
}
|
||||
|
||||
// Handles retargeted assemblies like PCL
|
||||
if (requestedAssemblyName.Flags == AssemblyNameFlags.Retargetable)
|
||||
{
|
||||
assembly = Assembly.Load(requestedAssemblyName);
|
||||
}
|
||||
}
|
||||
return assembly;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<CosturaPath Condition="$(CosturaPath) == '' Or $(CosturaPath) == '*Undefined*'">$(MSBuildThisFileDirectory)..\..\</CosturaPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask
|
||||
TaskName="Costura.Tasks.FilterReferenceCopyLocalPaths"
|
||||
AssemblyFile="$(CosturaPath)\Costura.Tasks.dll" />
|
||||
|
||||
<Target Name="CosturaFilterReferenceCopyLocalPaths" BeforeTargets="_CopyFilesMarkedCopyLocal" DependsOnTargets="FodyTarget">
|
||||
|
||||
<Costura.Tasks.FilterReferenceCopyLocalPaths
|
||||
ProjectDirectory="$(ProjectDir)"
|
||||
SolutionDir="$(FodySolutionDir)"
|
||||
References="@(ReferencePath)"
|
||||
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
|
||||
>
|
||||
<Output TaskParameter="FilteredReferenceCopyLocalPaths" ItemName="FilteredReferenceCopyLocalPaths" />
|
||||
</Costura.Tasks.FilterReferenceCopyLocalPaths>
|
||||
|
||||
<ItemGroup>
|
||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
|
||||
<ReferenceCopyLocalPaths Include="@(FilteredReferenceCopyLocalPaths)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Target>
|
||||
</Project>
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<CosturaPath Condition="$(CosturaPath) == '' Or $(CosturaPath) == '*Undefined*'">$(MSBuildThisFileDirectory)..\..\</CosturaPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask
|
||||
TaskName="Costura.Tasks.FilterReferenceCopyLocalPaths"
|
||||
AssemblyFile="$(CosturaPath)\Costura.Tasks.dll" />
|
||||
|
||||
<Target Name="CosturaFilterReferenceCopyLocalPaths" BeforeTargets="_CopyFilesMarkedCopyLocal" DependsOnTargets="FodyTarget">
|
||||
|
||||
<Costura.Tasks.FilterReferenceCopyLocalPaths
|
||||
ProjectDirectory="$(ProjectDir)"
|
||||
SolutionDir="$(FodySolutionDir)"
|
||||
References="@(ReferencePath)"
|
||||
ReferenceCopyLocalPaths="@(ReferenceCopyLocalPaths)"
|
||||
>
|
||||
<Output TaskParameter="FilteredReferenceCopyLocalPaths" ItemName="FilteredReferenceCopyLocalPaths" />
|
||||
</Costura.Tasks.FilterReferenceCopyLocalPaths>
|
||||
|
||||
<ItemGroup>
|
||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" />
|
||||
<ReferenceCopyLocalPaths Include="@(FilteredReferenceCopyLocalPaths)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Target>
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,94 +0,0 @@
|
|||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
|
||||
function RemoveForceProjectLevelHack($project)
|
||||
{
|
||||
Write-Host "RemoveForceProjectLevelHack"
|
||||
Foreach ($item in $project.ProjectItems)
|
||||
{
|
||||
if ($item.Name -eq "Fody_ToBeDeleted.txt")
|
||||
{
|
||||
$item.Delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function FlushVariables()
|
||||
{
|
||||
Write-Host "Flushing environment variables"
|
||||
$env:FodyLastProjectPath = ""
|
||||
$env:FodyLastWeaverName = ""
|
||||
$env:FodyLastXmlContents = ""
|
||||
}
|
||||
|
||||
function Update-FodyConfig($addinName, $project)
|
||||
{
|
||||
Write-Host "Update-FodyConfig"
|
||||
$fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml")
|
||||
|
||||
$FodyLastProjectPath = $env:FodyLastProjectPath
|
||||
$FodyLastWeaverName = $env:FodyLastWeaverName
|
||||
$FodyLastXmlContents = $env:FodyLastXmlContents
|
||||
|
||||
if (
|
||||
($FodyLastProjectPath -eq $project.FullName) -and
|
||||
($FodyLastWeaverName -eq $addinName))
|
||||
{
|
||||
Write-Host "Upgrade detected. Restoring content for $addinName"
|
||||
[System.IO.File]::WriteAllText($fodyWeaversPath, $FodyLastXmlContents)
|
||||
FlushVariables
|
||||
return
|
||||
}
|
||||
|
||||
FlushVariables
|
||||
|
||||
$xml = [xml](get-content $fodyWeaversPath)
|
||||
|
||||
$weavers = $xml["Weavers"]
|
||||
$node = $weavers.SelectSingleNode($addinName)
|
||||
|
||||
if (-not $node)
|
||||
{
|
||||
Write-Host "Appending node"
|
||||
$newNode = $xml.CreateElement($addinName)
|
||||
$weavers.AppendChild($newNode)
|
||||
}
|
||||
|
||||
$xml.Save($fodyWeaversPath)
|
||||
}
|
||||
|
||||
function Fix-ReferencesCopyLocal($package, $project)
|
||||
{
|
||||
Write-Host "Fix-ReferencesCopyLocal $($package.Id)"
|
||||
$asms = $package.AssemblyReferences | %{$_.Name}
|
||||
|
||||
foreach ($reference in $project.Object.References)
|
||||
{
|
||||
if ($asms -contains $reference.Name + ".dll")
|
||||
{
|
||||
if($reference.CopyLocal -eq $true)
|
||||
{
|
||||
$reference.CopyLocal = $false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UnlockWeaversXml($project)
|
||||
{
|
||||
$fodyWeaversProjectItem = $project.ProjectItems.Item("FodyWeavers.xml");
|
||||
if ($fodyWeaversProjectItem)
|
||||
{
|
||||
$fodyWeaversProjectItem.Open("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}")
|
||||
$fodyWeaversProjectItem.Save()
|
||||
$fodyWeaversProjectItem.Document.Close()
|
||||
}
|
||||
}
|
||||
|
||||
UnlockWeaversXml($project)
|
||||
|
||||
RemoveForceProjectLevelHack $project
|
||||
|
||||
Update-FodyConfig $package.Id.Replace(".Fody", "") $project
|
||||
|
||||
Fix-ReferencesCopyLocal $package $project
|
|
@ -1,47 +0,0 @@
|
|||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
|
||||
function Update-FodyConfig($addinName, $project)
|
||||
{
|
||||
$fodyWeaversPath = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($project.FullName), "FodyWeavers.xml")
|
||||
|
||||
if (!(Test-Path ($fodyWeaversPath)))
|
||||
{
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Caching variables for possible update"
|
||||
$env:FodyLastProjectPath = $project.FullName
|
||||
$env:FodyLastWeaverName = $addinName
|
||||
$env:FodyLastXmlContents = [IO.File]::ReadAllText($fodyWeaversPath)
|
||||
|
||||
|
||||
$xml = [xml](get-content $fodyWeaversPath)
|
||||
|
||||
$weavers = $xml["Weavers"]
|
||||
$node = $weavers.SelectSingleNode($addinName)
|
||||
|
||||
if ($node)
|
||||
{
|
||||
Write-Host "Removing node from FodyWeavers.xml"
|
||||
$weavers.RemoveChild($node)
|
||||
}
|
||||
|
||||
$xml.Save($fodyWeaversPath)
|
||||
}
|
||||
|
||||
|
||||
function UnlockWeaversXml($project)
|
||||
{
|
||||
$fodyWeaversProjectItem = $project.ProjectItems.Item("FodyWeavers.xml");
|
||||
if ($fodyWeaversProjectItem)
|
||||
{
|
||||
$fodyWeaversProjectItem.Open("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}")
|
||||
$fodyWeaversProjectItem.Save()
|
||||
$fodyWeaversProjectItem.Document.Close()
|
||||
}
|
||||
}
|
||||
|
||||
UnlockWeaversXml($project)
|
||||
|
||||
Update-FodyConfig $package.Id.Replace(".Fody", "") $project
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Weavers>
|
||||
|
||||
</Weavers>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue