KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When disassembling .NET functions, I notice that they all start with a similair pattern. What does this initial code do? This code appear before the actual code for what the function is supposed to do. Is it some sort of parameter count verification? func1 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 func2 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 [Edit] So is this a correct description of it? //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 or?
Tags (comma-separated)
Save Edits
Cancel