当前位置: 首页 > news >正文

IL汇编语言做一个窗体

网上看到一段代码,

.assembly extern

mscorlib {} .assembly Classes

{ .ver 1:0:1:0    } 

.namespace MyForm
{
    .class public TestForm extends 
        [System.Windows.Forms]System.Windows.Forms.Form
    {
        .field private class [System]System.ComponentModel.IContainer components
        .method public static void Main() cil managed
        {
            .entrypoint
            .maxstack  1
        
            //Create New Object of TestForm Class and Call the Constructor     
            newobj     instance void MyForm.TestForm::.ctor()
            call       void [System.Windows.Forms]
              System.Windows.Forms.Application::Run(
              class [System.Windows.Forms]System.Windows.Forms.Form)
             ret
        }
    }
}

似乎是做一个窗体出来;拿去构建一下,没什么效果;光有这一段应该是还不能做出窗体;

用VS做一个窗体exe,然后ildasm,加/text参数,获取全部的il代码保存下来;

看一下代码相当多;

逐步的删除一些,只要先构建通过,运行出现一个窗体即可;

资源相关的删掉;

.assembly test { ... } 整个这一段删掉;

 

可以构建成功,但是运行窗体不会出现;那保留这一段;

 

dispose删掉,销毁先不管;

 

资源Resource相关的删掉,应该没什么资源,

 

Culture相关的删掉,不知道是什么,

 

Settings相关的删掉,一个窗体没有用到,

 

一直删到这里,

 

下面看上去是Properties里有个Resources类,删掉,

 

.assembly test { ... } 里面看一下,版权和版本相关的删掉,

 

 

 到此剩下的代码如下,

.assembly extern System.Windows.Forms
{.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4...ver 4:0:0:0
}
.assembly extern mscorlib
{.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4...ver 4:0:0:0
}
.assembly extern System
{.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4...ver 4:0:0:0
}
.assembly test
{.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 ).custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 ).custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 00 00 00 ).custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 04 74 65 73 74 00 00 )                      // ...test...custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 ).custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ).custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 04 74 65 73 74 00 00 )                      // ...test...custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 ).hash algorithm 0x00008004.ver 1:0:0:0
}.module test.exe
// MVID: {AC8E5C6C-7768-4BFE-9524-E94CA472F376}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0002       // WINDOWS_GUI
.corflags 0x00020003    //  ILONLY 32BITREQUIRED
// Image base: 0x02460000// =============== CLASS MEMBERS DECLARATION ===================.class public auto ansi beforefieldinit test.Form1extends [System.Windows.Forms]System.Windows.Forms.Form
{.field private class [System]System.ComponentModel.IContainer components.method public hidebysig specialname rtspecialnameinstance void  .ctor() cil managed{// Code size       24 (0x18).maxstack  8IL_0000:  ldarg.0IL_0001:  ldnullIL_0002:  stfld      class [System]System.ComponentModel.IContainer test.Form1::componentsIL_0007:  ldarg.0IL_0008:  call       instance void [System.Windows.Forms]System.Windows.Forms.Form::.ctor()IL_000d:  nopIL_000e:  nopIL_000f:  ldarg.0IL_0010:  call       instance void test.Form1::InitializeComponent()IL_0015:  nopIL_0016:  nopIL_0017:  ret} // end of method Form1::.ctor.method private hidebysig instance voidInitializeComponent() cil managed{// Code size       33 (0x21).maxstack  8IL_0000:  nopIL_0001:  ldarg.0IL_0002:  newobj     instance void [System]System.ComponentModel.Container::.ctor()IL_0007:  stfld      class [System]System.ComponentModel.IContainer test.Form1::componentsIL_000c:  ldarg.0IL_000d:  ldc.i4.1IL_000e:  call       instance void [System.Windows.Forms]System.Windows.Forms.ContainerControl::set_AutoScaleMode(valuetype [System.Windows.Forms]System.Windows.Forms.AutoScaleMode)IL_0013:  nopIL_0014:  ldarg.0IL_0015:  ldstr      "Form1"IL_001a:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)IL_001f:  nopIL_0020:  ret} // end of method Form1::InitializeComponent} // end of class test.Form1.class private abstract auto ansi sealed beforefieldinit test.Programextends [mscorlib]System.Object
{.method private hidebysig static void  Main() cil managed{.entrypoint.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )// Code size       26 (0x1a).maxstack  8IL_0000:  nopIL_0001:  call       void [System.Windows.Forms]System.Windows.Forms.Application::EnableVisualStyles()IL_0006:  nopIL_0007:  ldc.i4.0IL_0008:  call       void [System.Windows.Forms]System.Windows.Forms.Application::SetCompatibleTextRenderingDefault(bool)IL_000d:  nopIL_000e:  newobj     instance void test.Form1::.ctor()IL_0013:  call       void [System.Windows.Forms]System.Windows.Forms.Application::Run(class [System.Windows.Forms]System.Windows.Forms.Form)IL_0018:  nopIL_0019:  ret} // end of method Program::Main} // end of class test.Program

ilasm一下,可以构建成功并运行出现一个窗体;下回继续;

http://www.lryc.cn/news/122926.html

相关文章:

  • 不用技术代码,分班查询系统怎么做?
  • 【Mybatis】调试查看执行的 SQL 语句
  • 【多视重建】从Zero-123到One-2-3-45:多视角生成
  • (四)Unity开发Vision Pro——参考文档
  • 【Linux】简单线程池的设计与实现 -- 单例模式
  • [RoarCTF 2019Online Proxy]sql巧妙盲注
  • flutter开发实战-just_audio实现播放音频暂停音频设置音量等
  • 【Bert101】最先进的 NLP 模型解释【01/4】
  • c语言经典例题讲解(输出菱形,喝汽水问题)
  • 【Flutter】【基础】CustomPaint 绘画功能(一)
  • iOS 实现图片高斯模糊效果
  • [保研/考研机试] KY7 质因数的个数 清华大学复试上机题 C++实现
  • 初识Redis
  • 每天一道leetcode:115. 不同的子序列(动态规划困难)
  • 服务器数据恢复-RAID5多块磁盘离线导致崩溃的数据恢复案例
  • NO.2 MyBatis框架:创建Mapper接口和映射文件,实现基本增删改查
  • 【JS】怎么提取object类的内容
  • 分布式系统的 38 个知识点
  • 机器学习基础(二)
  • Java 实现Rtsp 转rtmp,hls,flv
  • 机器学习基础(三)
  • Kubeadm安装K8s集群
  • 【C++】开源:spdlog跨平台日志库配置使用
  • [Azkaban] No active executors found
  • 无涯教程-Perl - recv函数
  • 算法练习-搜索 相关
  • PyQt5控件布局管理
  • TypeScript 一分钟让你理解泛型是什么
  • PatchMatchNet 训练dtu数据集、训练曲线查看、实操教程图图文详解、
  • 怎样制定测试计划和设计测试用例?