.NET 関数を逆アセンブルすると、それらはすべて似たようなパターンで始まることに気付きます。この最初のコードは何をしますか?
このコードは、関数が実行するはずの実際のコードの前に表示されます。ある種のパラメーター数の検証ですか?
機能1
private static void Foo(int i)
{
Console.WriteLine("hello");
}
00000000 push ebp
00000001 mov ebp,esp
00000003 push eax
00000004 mov dword ptr [ebp-4],ecx
00000007 cmp dword ptr ds:[005C14A4h],0
0000000e je 00000015
00000010 call 65E0367F
//the console writleline code follows here and is not part of the question
機能2
static private void Bar()
{
for (int i = 0; i < 1000; i++)
{
Foo(i);
}
}
00000000 push ebp
00000001 mov ebp,esp
00000003 push eax
00000004 cmp dword ptr ds:[006914A4h],0
0000000b je 00000012
0000000d call 65CC36CF
// the for loop code follows here
func3
private static void Foo()
{
Console.WriteLine("hello");
}
00000000 push ebp
00000001 mov ebp,esp
00000003 cmp dword ptr ds:[005614A4h],0
0000000a je 00000011
0000000c call 65E3367F
[編集] では、これは正しい説明ですか?
//fix stackframe
00000000 push ebp
00000001 mov ebp,esp
//store eax so it can be used locally
00000003 push eax
//ensure static ctor have been called
00000004 cmp dword ptr ds:[006914A4h],0
//it has been called, ignore it
0000000b je 00000012
//it hasn't been called, call it now
0000000d call 65CC36CF
また?