diff --git a/ExamplePlugin/ExamplePlugin.csproj b/ExamplePlugin/ExamplePlugin.csproj
index 93b4545..974288a 100644
--- a/ExamplePlugin/ExamplePlugin.csproj
+++ b/ExamplePlugin/ExamplePlugin.csproj
@@ -1,60 +1,61 @@
-
-
-
-
- Debug
- AnyCPU
- {F4082EAF-1C0B-42C8-8859-B4CF3055677E}
- Library
- Properties
- ExamplePlugin
- ExamplePlugin
- v4.7.2
- 512
- true
-
-
- true
- full
- false
- bin\x64\Debug\
- DEBUG;TRACE
- prompt
- 4
- x64
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- x64
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {992169F7-40F2-49FF-9F74-75463C30740F}
- MultiInstanceManager
-
-
-
-
- if $(ConfigurationName)==Debug (
+
+
+
+
+ Debug
+ AnyCPU
+ {F4082EAF-1C0B-42C8-8859-B4CF3055677E}
+ Library
+ Properties
+ ExamplePlugin
+ ExamplePlugin
+ v4.7.2
+ 512
+ true
+
+
+ true
+ full
+ false
+ bin\x64\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {992169F7-40F2-49FF-9F74-75463C30740F}
+ MultiInstanceManager
+
+
+
+
+ if not exist "$(TargetDir)\plugins" mkdir "$(TargetDir)\plugins"
+if $(ConfigurationName)==Debug (
echo "Copying to Debug"
if exist "$(TargetDir)\..\\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Debug\\plugins\\ExamplePlugin.dll" ( Del "$(TargetDir)\..\\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Debug\\plugins\\ExamplePlugin.dll" )
copy /Y "$(TargetDir)\\ExamplePlugin.dll" "$(TargetDir)\\..\\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Debug\\plugins\\"
@@ -63,6 +64,6 @@ echo "Copying to Release"
if exist "$(TargetDir)\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Release\\plugins\\ExamplePlugin.dll" ( Del "$(TargetDir)\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Release\\plugins\\ExamplePlugin.dll" )
copy /Y "$(TargetDir)\\ExamplePlugin.dll" "$(TargetDir)\..\\..\\..\\MultiInstanceManager\\bin\\x64\\Release\\plugins\\"
)
-
-
+
+
\ No newline at end of file
diff --git a/MultiInstanceManager/Modules/MultiHandler.cs b/MultiInstanceManager/Modules/MultiHandler.cs
index 56d835f..839a404 100644
--- a/MultiInstanceManager/Modules/MultiHandler.cs
+++ b/MultiInstanceManager/Modules/MultiHandler.cs
@@ -8,6 +8,8 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -124,6 +126,31 @@ public ActiveWindow SwapFocus(Profile account)
}
return activeWindow;
}
+
+ private static readonly byte[] Entropy = { 0xc8, 0x76, 0xf4, 0xae, 0x4c, 0x95, 0x2e, 0xfe, 0xf2, 0xfa, 0x0f, 0x54, 0x19, 0xc0, 0x9c, 0x43 };
+
+ public bool SetupWithBrowser(string displayName = "")
+ {
+ Log.Clear();
+ if (displayName.Length == 0)
+ {
+ displayName = Prompt.ShowDialog("Enter desired displayname for this account:", "Add Account");
+ }
+ RefreshAccountToken refresher = new RefreshAccountToken();
+ var result = refresher.ShowDialog();
+ if (result == DialogResult.OK)
+ {
+ //this is what we store in WEB_TOKEN
+ byte[] protectedKey = ProtectedData.Protect(Encoding.UTF8.GetBytes(refresher.Token), Entropy, DataProtectionScope.CurrentUser);
+ File.WriteAllBytes($"{displayName}.bin", protectedKey);
+ }
+ else
+ {
+ MessageBox.Show("No login token found.", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+ }
+ return result == DialogResult.OK;
+ }
+
public bool Setup(string displayName = "", Boolean killProcessesWhenDone = true)
{
Log.Clear();
@@ -232,7 +259,7 @@ public bool Setup(string displayName = "", Boolean killProcessesWhenDone = true)
freneticClickingCTS.Dispose();
}
// Export the received key using the name of the recipient
- ExportToken(displayName + ".bin");
+ //ExportToken(displayName + ".bin");
Log.Debug("Successfully saved new token for " + displayName);
Log.Debug("Closing launcher and client mutex handles");
@@ -377,7 +404,7 @@ public async Task LaunchWithAccount(string accountName, string cmdArgs = "")
{
WindowHelper.SetWindowPosition(process.MainWindowHandle, profile.LaunchOptions.WindowX, profile.LaunchOptions.WindowY);
}
- ExportToken(accountName + ".bin");
+ //ExportToken(accountName + ".bin");
// Log.Debug("Closing mutex handles");
activeWindows?.Add(new ActiveWindow { Process = process, Profile = profile });
// ProcessManager.CloseExternalHandles(process.ProcessName); // kill all D2R mutex handles
@@ -585,15 +612,7 @@ private void WaitForNewToken(Process process, Boolean timeout = false)
Log.Debug("Token remains the same");
}
}
- public void DumpCurrentRegKey()
- {
- ExportToken("dump.bin");
- }
- private void ExportToken(string fileName)
- {
- Log.Debug("Writing to file: " + fileName);
- File.WriteAllBytes(fileName, (byte[])Registry.GetValue(Constants.accountRegKey[0], Constants.accountRegKey[1], ""));
- }
+
private void UseAccountToken(string accountName)
{
Log.Debug("Reading from file: " + accountName + ".bin");
diff --git a/MultiInstanceManager/MultiInstanceManager.cs b/MultiInstanceManager/MultiInstanceManager.cs
index 566a759..0875e84 100644
--- a/MultiInstanceManager/MultiInstanceManager.cs
+++ b/MultiInstanceManager/MultiInstanceManager.cs
@@ -234,13 +234,14 @@ public void forceExit_Changed(object sender, EventArgs e)
}
private void dumpRegKeyButton_Click(object sender, EventArgs e)
{
- MH.DumpCurrentRegKey();
+ //MH.DumpCurrentRegKey();
}
private async void addAccountButton_Click(object sender, EventArgs e)
{
DisableButtons();
- var task = Task.Factory.StartNew(() => MH.Setup());
- var result = await task;
+ //var task = Task.Factory.StartNew(() => MH.Setup());
+ //var result = await task;
+ MH.SetupWithBrowser();
EnableButtons();
MH.LoadProfiles();
}
@@ -319,8 +320,7 @@ private async void refreshButton_Click(object sender, System.EventArgs e)
{
var checkedItem = accountList.CheckedItems[x].ToString().Split('|');
DisableButtons();
- var task = Task.Factory.StartNew(() => MH.Setup(checkedItem[0].Trim(' '), true));
- var result = await task;
+ MH.SetupWithBrowser(checkedItem[0].Trim(' '));
EnableButtons();
}
catch (Exception ex)
diff --git a/MultiInstanceManager/MultiInstanceManager.csproj b/MultiInstanceManager/MultiInstanceManager.csproj
index 1f23ee1..ad41415 100644
--- a/MultiInstanceManager/MultiInstanceManager.csproj
+++ b/MultiInstanceManager/MultiInstanceManager.csproj
@@ -1,247 +1,276 @@
-
-
-
-
- Debug
- AnyCPU
- {992169F7-40F2-49FF-9F74-75463C30740F}
- WinExe
- MultiInstanceManager
- MultiInstanceManager
- v4.7.2
- 9.0
- 512
- true
- false
- false
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- app.manifest
-
-
- true
- bin\x64\Debug\
- DEBUG;TRACE
- full
- x64
- 9.0
- prompt
- true
-
-
- bin\x64\Release\
- TRACE
- true
- pdbonly
- x64
- 9.0
- prompt
- true
-
-
- Resources\D2R_102-6-blue.ico
-
-
-
- ..\packages\CredentialManagement.1.0.2\lib\net35\CredentialManagement.dll
-
-
- ..\packages\Dfust.Hotkeys.1.2.6206.24906\lib\net452\Dfust.Hotkeys.dll
-
-
- ..\packages\Dfust.Hotkeys.1.2.6206.24906\lib\net452\Dfust.Hotkeys.Util.dll
-
-
- ..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll
-
-
- ..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll
-
-
- ..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll
-
-
-
- ..\packages\protobuf-net.3.0.101\lib\net461\protobuf-net.dll
-
-
- ..\packages\protobuf-net.Core.3.0.101\lib\net461\protobuf-net.Core.dll
-
-
-
- ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
-
-
- ..\packages\System.Collections.Immutable.1.7.1\lib\net461\System.Collections.Immutable.dll
-
-
-
-
- ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
-
-
-
- ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
-
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- ProfileConfigurator.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- MultiInstanceManager.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
- ProfileConfigurator.cs
-
-
- MultiInstanceManager.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
-
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
-
-
-
- False
- Microsoft .NET Framework 4.7.2 %28x86 and x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ AnyCPU
+ {992169F7-40F2-49FF-9F74-75463C30740F}
+ WinExe
+ MultiInstanceManager
+ MultiInstanceManager
+ v4.7.2
+ 9.0
+ 512
+ true
+ false
+ false
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ true
+
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ app.manifest
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 9.0
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 9.0
+ prompt
+ true
+
+
+ Resources\D2R_102-6-blue.ico
+
+
+
+ ..\packages\CredentialManagement.1.0.2\lib\net35\CredentialManagement.dll
+
+
+ ..\packages\Dfust.Hotkeys.1.2.6206.24906\lib\net452\Dfust.Hotkeys.dll
+
+
+ ..\packages\Dfust.Hotkeys.1.2.6206.24906\lib\net452\Dfust.Hotkeys.Util.dll
+
+
+ ..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll
+
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1210.30\lib\net45\Microsoft.Web.WebView2.Core.dll
+
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1210.30\lib\net45\Microsoft.Web.WebView2.WinForms.dll
+
+
+ ..\packages\Microsoft.Web.WebView2.1.0.1210.30\lib\net45\Microsoft.Web.WebView2.Wpf.dll
+
+
+ ..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll
+
+
+ ..\packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll
+
+
+
+ ..\packages\protobuf-net.3.0.101\lib\net461\protobuf-net.dll
+
+
+ ..\packages\protobuf-net.Core.3.0.101\lib\net461\protobuf-net.Core.dll
+
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+ ..\packages\System.Collections.Immutable.1.7.1\lib\net461\System.Collections.Immutable.dll
+
+
+
+
+ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ ProfileConfigurator.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ RefreshAccountToken.cs
+
+
+
+
+ Form
+
+
+ MultiInstanceManager.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProfileConfigurator.cs
+
+
+ MultiInstanceManager.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ RefreshAccountToken.cs
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.7.2 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
$(PostBuildEventDependsOn);
PostBuildMacros;
-
- copy /Y "$(SolutionDir)\\README.*" "$(TargetDir)"
+
+ if not exist "$(TargetDir)\plugins" mkdir "$(TargetDir)\plugins"
+copy /Y "$(SolutionDir)\\README.*" "$(TargetDir)"
if exist D2RMIM-Release-@(VersionNumber).zip ( Del D2RMIM-Release-@(VersionNumber).zip )
-powershell.exe -command Compress-Archive -Path plugins,*.dll,README.*,MultiInstanceManager.exe,MultiInstanceManager.exe.config -DestinationPath D2RMIM-Release-@(VersionNumber).zip
-
+powershell.exe -command Compress-Archive -Path runtimes,plugins,*.dll,README.*,MultiInstanceManager.exe,MultiInstanceManager.exe.config -DestinationPath D2RMIM-Release-@(VersionNumber).zip
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
\ No newline at end of file
diff --git a/MultiInstanceManager/RefreshAccountToken.Designer.cs b/MultiInstanceManager/RefreshAccountToken.Designer.cs
new file mode 100644
index 0000000..7b0a3d8
--- /dev/null
+++ b/MultiInstanceManager/RefreshAccountToken.Designer.cs
@@ -0,0 +1,67 @@
+
+namespace MultiInstanceManager
+{
+ partial class RefreshAccountToken
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.webView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
+ ((System.ComponentModel.ISupportInitialize)(this.webView2)).BeginInit();
+ this.SuspendLayout();
+ //
+ // webView2
+ //
+ this.webView2.AllowExternalDrop = true;
+ this.webView2.CreationProperties = null;
+ this.webView2.DefaultBackgroundColor = System.Drawing.Color.White;
+ this.webView2.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.webView2.Location = new System.Drawing.Point(0, 0);
+ this.webView2.Name = "webView2";
+ this.webView2.Size = new System.Drawing.Size(592, 309);
+ this.webView2.TabIndex = 0;
+ this.webView2.ZoomFactor = 1D;
+ this.webView2.CoreWebView2InitializationCompleted += new System.EventHandler(this.webView2_CoreWebView2InitializationCompleted);
+ this.webView2.NavigationCompleted += new System.EventHandler(this.webView2_NavigationCompleted);
+ //
+ // RefreshAccountToken
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(592, 309);
+ this.Controls.Add(this.webView2);
+ this.Name = "RefreshAccountToken";
+ this.Text = "RefreshAccountToken";
+ ((System.ComponentModel.ISupportInitialize)(this.webView2)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Microsoft.Web.WebView2.WinForms.WebView2 webView2;
+ }
+}
\ No newline at end of file
diff --git a/MultiInstanceManager/RefreshAccountToken.cs b/MultiInstanceManager/RefreshAccountToken.cs
new file mode 100644
index 0000000..58c142c
--- /dev/null
+++ b/MultiInstanceManager/RefreshAccountToken.cs
@@ -0,0 +1,64 @@
+using Microsoft.Web.WebView2.Core;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace MultiInstanceManager
+{
+ public partial class RefreshAccountToken : Form
+ {
+ public string Token { get; set; } = null;
+
+ public RefreshAccountToken()
+ {
+ InitializeComponent();
+ InitializeWebView2();
+ DialogResult = DialogResult.Cancel;
+ }
+
+ public async void InitializeWebView2()
+ {
+ var userDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "D2RMIM");
+ var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder);
+ await webView2.EnsureCoreWebView2Async(env);
+ }
+
+ private void webView2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
+ {
+ webView2.CoreWebView2.CookieManager.DeleteAllCookies();
+ webView2.CoreWebView2.DOMContentLoaded += webView2_DOMContentLoaded;
+ //region doesnt matter, token is reusable on all regions
+ webView2.CoreWebView2.Navigate(@"https://us.battle.net/login/en/?externalChallenge=login&app=OSI");
+ }
+
+ private async void webView2_DOMContentLoaded(object sender, CoreWebView2DOMContentLoadedEventArgs e)
+ {
+ if (webView2.Source.ToString().Contains("battle.net/login"))
+ {
+ //could autopopulate the form here to quickly refresh tokens...
+ await webView2.ExecuteScriptAsync($"document.querySelector('#accountName').value = 'noreply@example.com'");
+ await webView2.ExecuteScriptAsync($"document.querySelector('#password').value = 'Password'");
+ }
+ }
+
+ private void webView2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
+ {
+ //after a successful login you are redirected to localhost. the token is a query param 'ST'
+ if (webView2.Source.ToString().Contains("localhost"))
+ {
+ var query = webView2.Source.Query;
+ int idx = query.IndexOf("ST=");
+ //tokens are 44 chars, format US-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxx
+ Token = query.Substring(idx + 3, 44);
+ DialogResult = DialogResult.OK;
+ }
+ }
+ }
+}
diff --git a/MultiInstanceManager/RefreshAccountToken.resx b/MultiInstanceManager/RefreshAccountToken.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/MultiInstanceManager/RefreshAccountToken.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/MultiInstanceManager/packages.config b/MultiInstanceManager/packages.config
index 0909a02..aca956e 100644
--- a/MultiInstanceManager/packages.config
+++ b/MultiInstanceManager/packages.config
@@ -1,15 +1,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file