一个C#内联汇编的类.docx
- 文档编号:10799620
- 上传时间:2023-02-23
- 格式:DOCX
- 页数:43
- 大小:18.09KB
一个C#内联汇编的类.docx
《一个C#内联汇编的类.docx》由会员分享,可在线阅读,更多相关《一个C#内联汇编的类.docx(43页珍藏版)》请在冰豆网上搜索。
一个C#内联汇编的类
一个C#内联汇编的类
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingSystem.Runtime.InteropServices;
namespaceAsmClassLibrary
{
publicclassClass1
{
[DllImport("kernel32.dll",EntryPoint="CloseHandle")]
publicstaticexternintCloseHandle(inthObject);
[DllImport("kernel32.dll")]
publicstaticexternInt32WriteProcessMemory(
IntPtrhProcess,
IntPtrlpBaseAddress,
[In,Out]byte[]buffer,
intsize,
outIntPtrlpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
publicstaticexternInt32WriteProcessMemory(
inthProcess,
intlpBaseAddress,
byte[]buffer,
intsize,
intlpNumberOfBytesWritten);
[DllImport("kernel32",EntryPoint="CreateRemoteThread")]
publicstaticexternintCreateRemoteThread(
inthProcess,
intlpThreadAttributes,
intdwStackSize,
intlpStartAddress,
intlpParameter,
intdwCreationFlags,
refintlpThreadId
);
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualAllocEx(
System.IntPtrhProcess,
System.Int32lpAddress,
System.Int32dwSize,
System.Int16flAllocationType,
System.Int16flProtect
);
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualAllocEx(
inthProcess,
intlpAddress,
intdwSize,
intflAllocationType,
intflProtect
);
[DllImport("Kernel32.dll")]
publicstaticexternSystem.Int32VirtualFreeEx(
inthProcess,
intlpAddress,
intdwSize,
intflAllocationType
);
[DllImport("kernel32.dll",EntryPoint="OpenProcess")]
publicstaticexternintOpenProcess(
intdwDesiredAccess,
intbInheritHandle,
intdwProcessId
);
privateconstintPAGE_EXECUTE_READWRITE=0x4;
privateconstintMEM_COMMIT=4096;
privateconstintMEM_RELEASE=0x8000;
privateconstintMEM_DECOMMIT=0x4000;
privateconstintPROCESS_ALL_ACCESS=0x1F0FFF;
privateconstintPROCESS_CREATE_THREAD=0x2;
privateconstintPROCESS_VM_OPERATION=0x8;
privateconstintPROCESS_VM_WRITE=0x20;
publicstringAsmcode="";
privatestringhex(intaddress)
{
stringstr=address.ToString("X");
returnstr;
}
publicstringintTohex(intvalue,intnum)
{
stringstr1;
stringstr2="";
str1="0000000"+this.hex(value);
str1=str1.Substring(str1.Length-num,num);
for(inti=0;i { str2=str2+str1.Substring(str1.Length-2-2*i,2); } returnstr2; } publicvoidSUB_ESP(intaddre) { if((addre<=127)&&(addre>=-128)) { this.Asmcode=this.Asmcode+"83EC"+intTohex(addre,2); } else { this.Asmcode=this.Asmcode+"81EC"+intTohex(addre,8); } } publicvoidNop() { this.Asmcode=this.Asmcode+"90"; } publicvoidRetA(intaddre) { this.Asmcode=this.Asmcode+intTohex(addre,4); } publicvoidIN_AL_DX() { this.Asmcode=this.Asmcode+"EC"; } publicvoidTEST_EAX_EAX() { this.Asmcode=this.Asmcode+"85C0"; } publicvoidLeave() { this.Asmcode=this.Asmcode+"C9"; } publicvoidPushad() { this.Asmcode=this.Asmcode+"60"; } publicvoidPopad() { this.Asmcode=this.Asmcode+"61"; } publicvoidRet() { this.Asmcode=this.Asmcode+"C3"; } #regionADD publicvoidAdd_EAX_EDX() { this.Asmcode=this.Asmcode+"03C2"; } publicvoidAdd_EBX_EAX() { this.Asmcode=this.Asmcode+"03D8"; } publicvoidAdd_EAX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"0305"+intTohex(addre,8); } publicvoidAdd_EBX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"031D"+intTohex(addre,8); } publicvoidAdd_EBP_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"032D"+intTohex(addre,8); } publicvoidAdd_EAX(intaddre) { this.Asmcode=this.Asmcode+"05"+intTohex(addre,8); } publicvoidAdd_EBX(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"83C3"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"81C3"+intTohex(addre,8); } publicvoidAdd_ECX(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"83C1"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"81C1"+intTohex(addre,8); } publicvoidAdd_EDX(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"83C2"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"81C2"+intTohex(addre,8); } publicvoidAdd_ESI(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"83C6"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"81C6"+intTohex(addre,8); } publicvoidAdd_ESP(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"83C4"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"81C4"+intTohex(addre,8); } #endregion #regionmov publicvoidMov_DWORD_Ptr_EAX_ADD(intaddre,intaddre1) { if((addre<=127)&&(addre>=-128)) { this.Asmcode=this.Asmcode+"C740"+intTohex(addre,2)+intTohex(addre1,8); } else { this.Asmcode=this.Asmcode+"C780"+intTohex(addre,8)+intTohex(addre1,8); } } publicvoidMov_DWORD_Ptr_ESP_ADD(intaddre,intaddre1) { if((addre<=127)&&(addre>=-128)) { this.Asmcode=this.Asmcode+"C74424"+intTohex(addre,2)+intTohex(addre1,8); } else { this.Asmcode=this.Asmcode+"C78424"+intTohex(addre,8)+intTohex(addre1,8); } } publicvoidMov_DWORD_Ptr_ESP_ADD_EAX(intaddre) { if((addre<=127)&&(addre>=-128)) { this.Asmcode=this.Asmcode+"894424"+intTohex(addre,2); } else { this.Asmcode=this.Asmcode+"898424"+intTohex(addre,8); } } publicvoidMov_DWORD_Ptr_ESP(intaddre) { this.Asmcode=this.Asmcode+"C70424"+intTohex(addre,8); } publicvoidMov_DWORD_Ptr_EAX(intaddre) { this.Asmcode=this.Asmcode+"A3"+intTohex(addre,8); } publicvoidMov_EBX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B1D"+intTohex(addre,8); } publicvoidMov_ECX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B0D"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"A1"+intTohex(addre,8); } publicvoidMov_EDX_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B15"+intTohex(addre,8); } publicvoidMov_ESI_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B35"+intTohex(addre,8); } publicvoidMov_ESP_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B25"+intTohex(addre,8); } publicvoidMov_EBP_DWORD_Ptr(intaddre) { this.Asmcode=this.Asmcode+"8B2D"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_EAX(intaddre) { this.Asmcode=this.Asmcode+"8B00"; } publicvoidMov_EAX_DWORD_Ptr_EAX() { this.Asmcode=this.Asmcode+"8B00"; } publicvoidMov_EAX_DWORD_Ptr_EBP() { this.Asmcode=this.Asmcode+"8B4500"; } publicvoidMov_EAX_DWORD_Ptr_EBX() { this.Asmcode=this.Asmcode+"8B03"; } publicvoidMov_EAX_DWORD_Ptr_ECX() { this.Asmcode=this.Asmcode+"8B01"; } publicvoidMov_EAX_DWORD_Ptr_EDX() { this.Asmcode=this.Asmcode+"8B02"; } publicvoidMov_EAX_DWORD_Ptr_EDI() { this.Asmcode=this.Asmcode+"8B07"; } publicvoidMov_EAX_DWORD_Ptr_ESP() { this.Asmcode=this.Asmcode+"8B0424"; } publicvoidMov_EAX_DWORD_Ptr_ESI() { this.Asmcode=this.Asmcode+"8B06"; } publicvoidMov_EAX_DWORD_Ptr_EAX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) { this.Asmcode=this.Asmcode+"8B40"+intTohex(addre,2); } else { this.Asmcode=this.Asmcode+"8B80"+intTohex(addre,8); } } publicvoidMov_EAX_DWORD_Ptr_ESP_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B4424"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B8424"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_EBX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B43"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B83"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_ECX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B41"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B81"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_EDX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B42"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B82"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_EDI_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B47"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B87"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_EBP_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B45"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B85"+intTohex(addre,8); } publicvoidMov_EAX_DWORD_Ptr_ESI_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B46"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B86"+intTohex(addre,8); } publicvoidMov_EBX_DWORD_Ptr_EAX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B58"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B98"+intTohex(addre,8); } publicvoidMov_EBX_DWORD_Ptr_ESP_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B5C24"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B9C24"+intTohex(addre,8); } publicvoidMov_EBX_DWORD_Ptr_EBX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B5B"+intTohex(addre,2); else this.Asmcode=this.Asmcode+"8B9B"+intTohex(addre,8); } publicvoidMov_EBX_DWORD_Ptr_ECX_Add(intaddre) { if((addre<=127)&&(addre>=-128)) this.Asmcode=this.Asmcode+"8B59"+intTohex(addre
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 一个 C# 内联 汇编
![提示](https://static.bdocx.com/images/bang_tan.gif)