call dword ptr[ebp+8] // call 参数一 [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate IntPtr CallMethod(IntPtr ptr);
[STAThread]
static void Main(string[] args)
{
byte[] buf_asm = {
// push ebp
// mov ebp,esp
// sub esp,0C0h
// push ebx
// push esi
// push edi
// lea edi,[ebp-0C0h]
// mov ecx,30h
// mov eax,0CCCCCCCCh
// rep stos dword ptr es:[edi]
85, 139, 236, 129, 236, 192, 0, 0, 0, 83, 86, 87, 141, 189, 64,
255, 255, 255, 185, 48, 0, 0, 0, 184, 204, 204, 204, 204, 243, 171,
// call dword ptr[ebp+8]
255, 85, 8,
// pop edi
// pop esi
// pop ebx
// mov esp,ebp
// pop ebp
// ret
95, 94, 91, 139, 229, 93, 195
};
IntPtr ptr_asm = SetHandleCount(buf_asm);
VirtualProtect(ptr_asm, buf_asm.Length);
CallMethod call_method = Marshal.GetDelegateForFunctionPointer(ptr_asm, typeof(CallMethod)) as CallMethod;
call_method(Marshal.GetFunctionPointerForDelegate(new Action(Hello_x86)));
}
static void VirtualProtect(IntPtr ptr, int size)
{
int outMemProtect;
if (!VirtualProtect(ptr, size, 64, out outMemProtect))
throw new Exception("Unable to modify memory protection.");
}
static void Hello_x86()
{
Console.Title = ((new StackFrame()).GetMethod()).Name;
Console.WriteLine("I was x86 assembly call a test function.");
Console.ReadKey(false);
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SetHandleCount(byte[] value);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool VirtualProtect(IntPtr lpAddress, int dwSize, int flNewProtect, out int lpflOldProtect);
using System; using System.Runtime.InteropServices; using System.Diagnostics;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有