概要
ilasmでstack machineやってみた。
練習問題やってみた。
練習問題
ilasmでWindows.Formsを使え。
方針
- 窓のイベントを受ける。
写真
サンプルコード
.assembly extern System.Windows.Forms {
.publickeytoken = (B7 7A 5C 56 19 34 E0 89) .ver 2:0:0:0
}
.assembly extern mscorlib {
.publickeytoken = (B7 7A 5C 56 19 34 E0 89) .ver 2:0:0:0
}
.assembly extern System.Drawing {
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A) .ver 2:0:0:0
}
.assembly 'form1' {}
.class private auto ansi beforefieldinit form1 extends [System.Windows.Forms]System.Windows.Forms.Form {
.field private class [System.Windows.Forms]System.Windows.Forms.Button btnHello
.method public hidebysig static void Main() cil managed {
.entrypoint
newobj instance void form1::.ctor()
call void [System.Windows.Forms]System.Windows.Forms.Application::Run(class [System.Windows.Forms]System.Windows.Forms.Form)
ret
}
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed {
ldarg.0
call instance void [System.Windows.Forms]System.Windows.Forms.Form::.ctor()
ldarg.0
ldstr "form2"
callvirt instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
ldarg.0
newobj instance void [System.Windows.Forms]System.Windows.Forms.Button::.ctor()
stfld class [System.Windows.Forms]System.Windows.Forms.Button form1::btnHello
ldarg.0
ldfld class [System.Windows.Forms]System.Windows.Forms.Button form1::btnHello
ldc.i4.s 50
ldc.i4.s 50
newobj instance void [System.Drawing]System.Drawing.Point::.ctor(int32, int32)
callvirt instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Location(valuetype [System.Drawing]System.Drawing.Point)
ldarg.0
ldfld class [System.Windows.Forms]System.Windows.Forms.Button form1::btnHello
ldarg.0
ldftn instance void form1::btnHello_Click(object, class [mscorlib]System.EventArgs)
newobj instance void [mscorlib]System.EventHandler::.ctor(object, native int)
callvirt instance void [System.Windows.Forms]System.Windows.Forms.Control::add_Click(class [mscorlib]System.EventHandler)
ldarg.0
ldfld class [System.Windows.Forms]System.Windows.Forms.Button form1::btnHello
ldstr "Hello"
callvirt instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
ldarg.0
call instance class [System.Windows.Forms]System.Windows.Forms.Control/ControlCollection [System.Windows.Forms]System.Windows.Forms.Control::get_Controls()
ldarg.0
ldfld class [System.Windows.Forms]System.Windows.Forms.Button form1::btnHello
callvirt instance void [System.Windows.Forms]System.Windows.Forms.Control/ControlCollection::Add(class [System.Windows.Forms]System.Windows.Forms.Control)
ret
}
.method private hidebysig instance void btnHello_Click(object sender, class [mscorlib]System.EventArgs e) cil managed {
ldstr "Hello!!"
call valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
pop
ret
}
}
以上