Figure 1 Hello.Main in x86 Native Code
//Function Prologue
push ebp
mov ebp,esp
push esi
xor esi,esi
push esi
push ecx
push edx
//set stack frame to zero
mov ecx,1
addr_a:
push 0
loop addr_a
//load "Hello, World" and call Console.WriteLine
mov eax, <constant string table enty>
mov eax,dword ptr [eax]
mov ecx,eax
push ecx
mov eax, &Console.WriteLine
call dword ptr [eax]
add esp,4
//Sanity check: call check_stack in fjitdef.h
push esp
push ebp
mov eax,14h
push eax
mov eax, &check_stack
call eax
//function epilog
add esp,0Ch
mov esi,dword ptr [ebp-4]
mov esp,ebp
pop ebp
ret
Figure 3 The Shared Source CLI Class Libraries Summary
System.dll
|
Most of Microsoft.Win32
Most of System.ComponentModel
Most of System.Diagnostics
System.IO classes
System.Timers
|
237
|
274
|
System.runtime.remoting.dll
|
HttpRemotingHandler
|
25
|
3
|
System.xml.dll
|
No public classes changed
|
212
|
0
|
Mscorlib.dll
|
Microsoft.Win32.Registry Lots of System.Runtime.Interop-Services All of System.Security.Cryptography
|
867
|
188
|
System.runtime.Serial-ization.formatters
Soap.dll
|
Nothing
|
2
|
0
|
Figure 6 _CorExeMain2
__int32 STDMETHODCALLTYPE _CorExeMain2( // Executable exit code.
PBYTE pUnmappedPE, // -> memory mapped code
DWORD cUnmappedPE, // Size of memory mapped code
LPWSTR pImageNameIn, // -> Executable Name
LPWSTR pLoadersFileName, // -> Loaders Name
LPWSTR pCmdLine) // -> Command Line
{
BOOL bRetVal = 0;
PEFile *pFile = NULL;
HRESULT hr = E_FAIL;
if (!StrongNameSignatureVerification(pImageNameIn,
SN_INFLAG_INSTALL|SN_INFLAG_ALL_ACCESS|SN_INFLAG_RUNTIME, NULL) &&
StrongNameErrorInfo() != (DWORD) CORSEC_E_MISSING_STRONGNAME) {
LOG((LF_ALL, LL_INFO10, "Program exiting due to strong name
verification failure\n"));
return -1;
}
HRESULT result = CoInitializeEE(COINITEE_DEFAULT);
INSTALL_COMPLUS_EXCEPTION_HANDLER();
hr = PEFile::Create(pUnmappedPE, cUnmappedPE,
pImageNameIn,
pLoadersFileName,
NULL,
&pFile,
FALSE);
if (SUCCEEDED(hr)) {
hr = SystemDomain::ExecuteMainMethod(pFile, pImageNameIn);
bRetVal = SUCCEEDED(hr);
}
exit:
EEShutDown(FALSE);
SafeExitProcess(GetLatchedExitCode());
return (GetLatchedExitCode());
}
Figure 7 The Shared Source CLI Configuration Settings
BreakOnEELoad
|
0 | 1
|
Break on startup
|
BreakOnEEShutdown
|
0 | 1
|
Break on shutdown
|
BreakOnClassBuild
|
classname
|
Break when loading classname
|
JitBreak
|
class::method
|
Break before compiling method
|
JitHalt
|
class::method
|
Break when method executes
|
JitTrace
|
0 | 1
|
Log order of JIT compilation
|
LogEnable
|
0 | 1
|
Master log switch
|
LogLevel
|
1...10
|
Amount of log detail to generate
|
LogToFile
|
0 | 1
|
Dump log info to a file
|
LogFile
|
filename
|
Route logging info to filename
|
LogToDebugger
|
0 | 1
|
Route logging info to debugger
|
LogToConsole
|
0 | 1
|
Route logging info to console
|
JitOptimizeType
|
{ 0...3 }
|
Optimize for{both, size, speed, random}
|
Figure 8 Environment Variables
LogToDebugger
|
Routes output to OutputDebugString
|
LogToFile
|
Routes output to a file specified by the value of LogFile
|
LogToConsole
|
Routes output to the console
|
Figure 9 Configuration Settings
10
|
LL_EVERYTHING
|
31355 (2997KB)
|
9
|
LL_INFO1000000
|
10149 (925KB)
|
8
|
LL_INFO100000
|
10149 (925KB)
|
7
|
LL_INFO10000
|
4772 (417KB)
|
6
|
LL_INFO1000
|
2954 (282KB)
|
5
|
LL_INFO100
|
1273 (96KB)
|
4
|
LL_INFO10
|
564 (42KB)
|
3
|
LL_WARNING
|
0
|
2
|
LL_ERROR
|
0
|
1
|
LL_FATALERROR
|
0
|
Figure 10 Stepping into the Shared Source CLI with devenue/debugexe
Figure 11 Dumping the Hello Class
Method table summary for 'Hello':
Number of static fields: 0
Number of instance fields: 0
Number of static obj ref fields: 0
Number of declared fields: 0
Number of declared methods: 2
Vtable (with interface dupes) for 'Hello':
Total duplicate slots = 201
slot 0: System.Object[mscorlib.dll]::ToString 0x852073 (slot = 0)
slot 1: System.Object[mscorlib.dll]::Equals 0x852223 (slot = 1)
slot 2: System.Object[mscorlib.dll]::GetHashCode 0x852253 (slot = 2)
slot 3: System.Object[mscorlib.dll]::Finalize 0x852113 (slot = 3)
< vtable ends here
slot 4: Hello[hello.exe]::Main 0x8350AB (slot = 4)
slot 5: Hello[hello.exe]::.ctor 0x8350D3 (slot = 5)
Figure 16 Call Stack
•••
sscoree.dll!MethodDesc::DoPrestub
sscoree.dll!PreStubWorker
0x0008fcd5 < JIT
sscoree.dll!_CallDescrWorkerInternal@16
•••
sscoree.dll!MethodDesc::DoPrestub
sscoree.dll!PreStubWorker
0x0008fcd5 < JIT
0x02d42e05
sscoree.dll!_CallDescrWorkerInternal@16
•••
sscoree.dll!MethodDesc::Call
|