refactor: move dll loading into c# client

This commit is contained in:
k0t9i
2023-01-26 02:03:08 +04:00
parent 7ad3ff4081
commit 54a4514a53
6 changed files with 20 additions and 222 deletions

View File

@@ -1,12 +1,27 @@
using System.IO;
using System.IO.Pipes;
using System.Runtime.InteropServices;
using System.Text;
internal class Program
{
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", SetLastError = true)]
static extern int LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpLibFileName);
private static void Main(string[] args)
{
int hDll = LoadLibrary("L2BotDll.dll");
if (hDll == 0)
{
Console.WriteLine("Unable to load library L2BotDll.dll: " + Marshal.GetLastWin32Error().ToString());
Console.ReadLine();
return;
}
Console.WriteLine("L2BotDll.dll loaded\n");
while (true)
{
var clientPipe = new NamedPipeClientStream("PipeL2Bot");
@@ -27,7 +42,7 @@ internal class Program
mainPipe.Connect();
mainPipe.ReadMode = PipeTransmissionMode.Message;
Console.WriteLine("Connected to main pipe");
Console.WriteLine("Connected to main pipe\n");
while (true)
{
@@ -41,8 +56,8 @@ internal class Program
}
else
{
Console.WriteLine("Disconnected from main pipe");
Console.WriteLine("Disconnected from connection pipe");
Console.WriteLine("\nDisconnected from main pipe");
Console.WriteLine("Disconnected from connection pipe\n\n");
mainPipe.Close();
mainPipe.Dispose();

View File

@@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
</Project>