.Net 같은 경우 어셈블러 코드가 좀 달라서 참고용으로 간단히 설명해 보려고 합니다.
아래와 같이 VB.Net 을 이용해서 프로그램을 짰습니다.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim bool As Boolean Dim num As Integer Dim str As String bool = rRutnreTrue() bool = rRutnreFalse() bool = True bool = False num = 1 num = 2 num = rReturnNum1() num = rReturnNum1() str = "Test" str = rReturnString() End Sub Function rRutnreTrue() As Boolean Return True End Function Function rRutnreFalse() As Boolean Return False End Function Function rReturnNum1() As Integer Return 1 End Function Function rReturnNum2() As Integer Return 2 End Function Function rReturnString() As String Return "TEST" End Function이 경우 어셈블러 코드는 다음과 같습니다.
.method private instance void Form1_Load(object sender, class [mscorlib]System.EventArgs e) // DATA XREF: WindowsApplication1.Form1__.ctor+A r { .maxstack 1 .locals init (bool V0, int32 V1, string V2) nop ldarg.0 callvirt instance bool WindowsApplication1.Form1::rRutnreTrue() stloc.0 ldarg.0 callvirt instance bool WindowsApplication1.Form1::rRutnreFalse() stloc.0 ldc.i4.1 stloc.0 ldc.i4.0 stloc.0 ldc.i4.1 stloc.1 ldc.i4.2 stloc.1 ldarg.0 callvirt instance int32 WindowsApplication1.Form1::rReturnNum1() stloc.1 ldarg.0 callvirt instance int32 WindowsApplication1.Form1::rReturnNum1() stloc.1 ldstr aTest // "Test" stloc.2 ldarg.0 callvirt instance string WindowsApplication1.Form1::rReturnString() stloc.2 nop ret } .method public instance bool rRutnreTrue() // CODE XREF: WindowsApplication1.Form1__Form1_Load+2 p { .maxstack 1 .locals init (bool V0) nop ldc.i4.1 stloc.0 br.s loc_D35 loc_D35: // CODE XREF: WindowsApplication1.Form1__rRutnreTrue+3 j ldloc.0 ret } .method public instance bool rRutnreFalse() // CODE XREF: WindowsApplication1.Form1__Form1_Load+9 p { .maxstack 1 .locals init (bool V0) nop ldc.i4.0 stloc.0 br.s loc_D45 loc_D45: // CODE XREF: WindowsApplication1.Form1__rRutnreFalse+3 j ldloc.0 ret } .method public instance int32 rReturnNum1() // CODE XREF: WindowsApplication1.Form1__Form1_Load+18 p // WindowsApplication1.Form1__Form1_Load+1F p { .maxstack 1 .locals init (int32 V0) nop ldc.i4.1 stloc.0 br.s loc_D55 loc_D55: // CODE XREF: WindowsApplication1.Form1__rReturnNum1+3 j ldloc.0 ret } .method public instance int32 rReturnNum2() { .maxstack 1 .locals init (int32 V0) nop ldc.i4.2 stloc.0 br.s loc_D65 loc_D65: // CODE XREF: WindowsApplication1.Form1__rReturnNum2+3 j ldloc.0 ret } .method public instance string rReturnString() // CODE XREF: WindowsApplication1.Form1__Form1_Load+2C p { .maxstack 1 .locals init (string V0) nop ldstr aTest_0 // "TEST" stloc.0 br.s loc_D79 loc_D79: // CODE XREF: WindowsApplication1.Form1__rReturnString+7 j ldloc.0 ret }보통 특정 연산을 하고 True 나 False 를 반환 하는 함수를 만들어 쓴다고 할때...
연산과정 다 무시하고...무조건 TRUE를 반환 하게 한다면...
코드 시작 부분에서 바로 Return True 를 하면 되겠죠...
HEX 코드로 보면 다음과 같습니다.
ldc.i4.1 에 해당하는 HEX 코드는 0x17 입니다.
댓글 없음:
댓글 쓰기