This commit is contained in:
sin365 2024-06-18 18:28:38 +08:00
parent a9fde2d2bf
commit d1954b7da6
2 changed files with 129 additions and 5 deletions

View File

@ -1,6 +1,7 @@
using ClassLibrary1;
using EasyHook;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Runtime.InteropServices;
@ -250,10 +251,11 @@ namespace AxibugInject
ushort newT = (ushort)(gao | di << 8);
return newT;
}
#endregion
#endregion
#region
[DllImport("ws2_32.dll", SetLastError = true)]
#region WSAConnect
[DllImport("ws2_32.dll", SetLastError = true)]
internal static extern SocketError WSAConnect(
[In] IntPtr socketHandle,
[In] byte[] socketAddress,
@ -280,8 +282,15 @@ namespace AxibugInject
[In] IntPtr outBuffer,
[In] IntPtr sQOS,
[In] IntPtr gQOS)
{
ConsoleShow.Log($"WSAConnect[调用]socketAddress.lenght->{socketAddress.Length} socketAddressSize->{socketAddressSize} inBuffer->{inBuffer}" +
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
//猜测
for (int i = 0; i < socketAddress.Length; i++)
{
hex.AppendFormat("{0:x2}", socketAddress[i]);
}
ConsoleShow.Log($"WSAConnect[调用]socketAddress.lenght->{socketAddress.Length} byteHex->[{hex}] socketAddressSize->{socketAddressSize} inBuffer->{inBuffer}" +
$" outBuffer->{outBuffer} sQOS->{sQOS} ->{gQOS}");
return WSAConnect(socketHandle,socketAddress,socketAddressSize,inBuffer,outBuffer,sQOS,gQOS);
}

115
AxibugInject/Utils.cs Normal file
View File

@ -0,0 +1,115 @@
using EasyHook;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace AxibugInject
{
public class Utils
{
public static string HexDump(byte[] bytes, int bytesPerLine = 16)
{
if (bytes == null) return "<null>";
int bytesLength = bytes.Length;
char[] HexChars = "0123456789ABCDEF".ToCharArray();
int firstHexColumn =
8 // 8 characters for the address
+ 3; // 3 spaces
int firstCharColumn = firstHexColumn
+ bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space
+ (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
+ 2; // 2 spaces
int lineLength = firstCharColumn
+ bytesPerLine // - characters to show the ascii value
+ Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
StringBuilder result = new StringBuilder(expectedLines * lineLength);
for (int i = 0; i < bytesLength; i += bytesPerLine)
{
line[0] = HexChars[(i >> 28) & 0xF];
line[1] = HexChars[(i >> 24) & 0xF];
line[2] = HexChars[(i >> 20) & 0xF];
line[3] = HexChars[(i >> 16) & 0xF];
line[4] = HexChars[(i >> 12) & 0xF];
line[5] = HexChars[(i >> 8) & 0xF];
line[6] = HexChars[(i >> 4) & 0xF];
line[7] = HexChars[(i >> 0) & 0xF];
int hexColumn = firstHexColumn;
int charColumn = firstCharColumn;
for (int j = 0; j < bytesPerLine; j++)
{
if (j > 0 && (j & 7) == 0) hexColumn++;
if (i + j >= bytesLength)
{
line[hexColumn] = ' ';
line[hexColumn + 1] = ' ';
line[charColumn] = ' ';
}
else
{
byte b = bytes[i + j];
line[hexColumn] = HexChars[(b >> 4) & 0xF];
line[hexColumn + 1] = HexChars[b & 0xF];
line[charColumn] = (b < 32 ? '·' : (char)b);
}
hexColumn += 3;
charColumn++;
}
result.Append(line);
}
return result.ToString();
}
const int WM_GETTEXT = 0x000D; const int WM_GETTEXTLENGTH = 0x000E;
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, Byte[] lParam);
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public static bool GetTextValueByHandle(IntPtr HwndStatue,out string str)
{
if (HwndStatue != IntPtr.Zero)
{
int TextLen;
TextLen = SendMessage(HwndStatue, WM_GETTEXTLENGTH, 0, 0);
Byte[] byt = new Byte[TextLen];
SendMessage(HwndStatue, WM_GETTEXT, TextLen + 1, byt);
str = Encoding.Default.GetString(byt);
return true;
}
str = string.Empty;
return false;
}
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32.dll ")]
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childe, string strclass, string FrmText);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam);
}
}