追加 WSAConnect

This commit is contained in:
sin365 2024-06-18 17:57:37 +08:00
parent 72126fb782
commit a9fde2d2bf

View File

@ -1,18 +1,18 @@
using System;
using System.Text;
using System.Runtime.InteropServices;
using ClassLibrary1;
using EasyHook;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using ClassLibrary1;
using System.Collections.Generic;
using System.Xml.Linq;
using static AxibugInject.ws2_32;
namespace AxibugInject
{
[Serializable]
public class HookParameter
{
@ -27,6 +27,7 @@ namespace AxibugInject
public LocalHook GetHostByAddrHook = null;
public LocalHook gethostnameHook = null;
public LocalHook connectHook = null;
public LocalHook WSAConnectHook = null;
public static Dictionary<string, string> mDictHostToIP = new Dictionary<string, string>();
public Main(
@ -94,6 +95,14 @@ namespace AxibugInject
new Dconnect(connect_Hooked),
this);
connectHook.ThreadACL.SetExclusiveACL(new int[1]);
ConsoleShow.Log($"Hook函数ws2_32.dll->WSAConnect");
WSAConnectHook = LocalHook.Create(
LocalHook.GetProcAddress("ws2_32.dll", "WSAConnect"),
new DWSAConnect(WSAConnect_Hooked),
this);
WSAConnectHook.ThreadACL.SetExclusiveACL(new int[1]);
}
catch (Exception ex)
@ -243,6 +252,40 @@ namespace AxibugInject
}
#endregion
#region
[DllImport("ws2_32.dll", SetLastError = true)]
internal static extern SocketError WSAConnect(
[In] IntPtr socketHandle,
[In] byte[] socketAddress,
[In] int socketAddressSize,
[In] IntPtr inBuffer,
[In] IntPtr outBuffer,
[In] IntPtr sQOS,
[In] IntPtr gQOS);
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)]
delegate SocketError DWSAConnect([In] IntPtr socketHandle,
[In] byte[] socketAddress,
[In] int socketAddressSize,
[In] IntPtr inBuffer,
[In] IntPtr outBuffer,
[In] IntPtr sQOS,
[In] IntPtr gQOS);
static SocketError WSAConnect_Hooked(
[In] IntPtr socketHandle,
[In] byte[] socketAddress,
[In] int socketAddressSize,
[In] IntPtr inBuffer,
[In] IntPtr outBuffer,
[In] IntPtr sQOS,
[In] IntPtr gQOS)
{
ConsoleShow.Log($"WSAConnect[调用]socketAddress.lenght->{socketAddress.Length} socketAddressSize->{socketAddressSize} inBuffer->{inBuffer}" +
$" outBuffer->{outBuffer} sQOS->{sQOS} ->{gQOS}");
return WSAConnect(socketHandle,socketAddress,socketAddressSize,inBuffer,outBuffer,sQOS,gQOS);
}
#endregion
}
}