- 博客(1)
- 资源 (4)
- 收藏
- 关注
原创 计算直线上距离某坐标最近的一个投影点
计算直线上距离某坐标最近的一个投影点 0x01 调用方式 var p = GetProjectivePoint(new Point(0,0), new Point(300,300), new Point(100,150)); Console.WriteLine(p); 0x02 源码 /// <summary> /// ...
2019-10-12 09:54:33 755
C# 优雅的 APIHOOK 支持X86+X64源码
using System;
using System.Runtime.InteropServices;
namespace NativeHook.Test
{
public delegate Int32 MessageBoxW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string lpText,
[MarshalAs(UnmanagedType.LPWStr)] string lpCaption, UInt32 uType);
public class MessageBoxHook : NtAPIHook
{
[DllHook("user32", EntryPoint = "MessageBoxW")]
public Int32 MessageBox(IntPtr owner, string text, string caption, UInt32 options)
{
//拦截信息
Console.Title = caption;
Console.WriteLine(text);
//调用源函数
return Origin.Invoke(owner, text, caption, options);
}
}
}
[STAThread]
static void Main(string[] args)
{
using (var hook = new MessageBoxHook())
{
//绕过Hook直接调用源函数
hook.Origin(IntPtr.Zero, "111", "222", 0);
//调用Api 被Hook
MessageBox.Show("Hello world", "666", MessageBoxButtons.YesNoCancel);
}
//Hook解除拦截不到
MessageBox.Show("Hello world", "666", MessageBoxButtons.YesNoCancel);
}
2018-09-21
C# 从内存加载动态链接库
纯C# 实现的 从内存加载动态链接库,支持加壳的DLL,使用方便
class Program
{
public delegate Int32 CompressHandle(ref Byte dest,ref Int32 len, Byte [] source,Int32 sourcelen);
static void Main(string[] args)
{
Byte[] source = new byte[10000];
Byte[] dest = new byte[10000];
Int32 len = source.Length;
Byte[] dllBin = File.ReadAllBytes("zlib1.dll");
using (var dll = new DllLoader())
{
if (dll.LoadLibrary(dllBin))
{
var Compress = dll.GetProcDelegate("compress");
if (Compress != null)
{
var result = Compress.Invoke(ref dest[0], ref len, source, len);
Console.WriteLine(result);
}
}
}
}
}
2018-09-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人