CosmosOS / Cosmos

Cosmos is an operating system "construction kit". Build your own OS using managed languages such as C#, VB.NET, and more!
https://www.goCosmos.org
BSD 3-Clause "New" or "Revised" License
2.93k stars 553 forks source link

Char.ToString() returns invalid String #332

Closed fanoI closed 8 years ago

fanoI commented 8 years ago

The function ToString() of Char has a weird behavior the String returned does not returned the character converted in String but an invalid String (with all bits set to 0). Trying to print the resulting String gives yet weird results as containing the character 0x00 is interpreted as end of String and so text ends.

This example show the behavior:

char comma = ':';
Console.WriteLine($"comma= {comma}");  // comma=
Console.WriteLine($"comma= {comma} etcetera, etcetera..."); // comma= (yes nothing else is printed neither the NewLine!)
Console.WriteLine("comma=" + comma);   // Object.ToString() not implemented

In reality the problem seems to be in the String code, Char.ToString() does simply this:

public static string ToString(ref char aThis)
{
            char[] xResult = new char[1];
            xResult[0] = aThis;
            return new string(xResult);
}

This is the constructor of String that takes a Char[]:

        public static unsafe void Ctor(
            string aThis,
            char[] aChars,
            [FieldAccess(Name = "System.String System.String.Empty")] ref string aStringEmpty,
            [FieldAccess(Name = "System.Int32 System.String.m_stringLength")] ref int aStringLength,
            [FieldAccess(Name = "System.Char System.String.m_firstChar")] char* aFirstChar)
        {
            char[] xCharArray = new char[aChars.Length];
            fixed (char* xFirstChar = xCharArray)
            {
                for (int i = 0; i < aChars.Length; i++)
                {
                    xCharArray[i] = aChars[i];
                }
                aFirstChar = xFirstChar;
            }
            aStringEmpty = "";
            aStringLength = aChars.Length;
        }

I notice two things:

  1. No memory is allocated for the resulting String
  2. Fixed is used but then array operation are done
fanoI commented 8 years ago

This an extract of the assembler code generated:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0000:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0000.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001.00: ;Asm
            Int3 ; INT3
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001.01: ;Asm
            call SystemVoidSystemConsoleClear

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001.02: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001.03: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0006
            ; aStackSizeBeforeCall = 0
            ; aTotalArgumentSizeOfMethod = 0
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0001.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0006:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0006.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0007:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0007.00: ;Asm
            Int3 ; INT3
            ; LdStr
            ; String Value: Cursor size is 

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0007.01: ;Asm
            mov dword EAX, StringLiteral00DF__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0007.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.00: ;Asm
            sub dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.01: ;Asm
            call SystemInt32SystemConsoleget_CursorSize

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.02: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.03: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0011
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 0
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.04: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_000C.05: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011:
            ; Box

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.00: ;Asm
            push dword 0x10

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.01: ;Asm
            call SystemUInt32CosmosIL2CPUGCImplementationAllocNewObjectSystemUInt32

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.02: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.03: ;Asm
            mov dword ESI, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.04: ;Asm
            mov dword EBX, [VMT__TYPE_ID_HOLDER__System_Int32_ASM_IS__mscorlib]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.05: ;Asm
            mov dword [ESI], EBX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.06: ;Asm
            mov dword [ESI + 4], 0x3
            ; xSize is 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.07: ;Asm
            pop dword EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.08: ;Asm
            mov dword [ESI + 12], EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0011.09: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016.00: ;Asm
            call SystemStringSystemStringConcatSystemObjectSystemObject

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_001B
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016.03: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0016.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_001B:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_001B.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_001B.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_001B.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0020
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_001B.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0020:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0020.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0021:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0021.00: ;Asm
            Int3 ; INT3
            ; Ldc_I4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0021.01: ;Asm
            push dword 0x3A

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0023:
            ; Stloc
            ; EBPOffset = 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0023.00: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0023.01: ;Asm
            mov dword [EBP - 4], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0024:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0024.00: ;Asm
            NOP ; INT3
            ; LdStr
            ; String Value: comma= {0}

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0024.01: ;Asm
            mov dword EAX, StringLiteral00E0__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0024.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0029:
            ; Ldloc
            ; EBPOffset = 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0029.00: ;Asm
            movzx EAX, word [EBP - 4]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0029.01: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A:
            ; Box

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.00: ;Asm
            push dword 0x10

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.01: ;Asm
            call SystemUInt32CosmosIL2CPUGCImplementationAllocNewObjectSystemUInt32

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.02: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.03: ;Asm
            mov dword ESI, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.04: ;Asm
            mov dword EBX, [VMT__TYPE_ID_HOLDER__System_Char_ASM_IS__mscorlib]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.05: ;Asm
            mov dword [ESI], EBX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.06: ;Asm
            mov dword [ESI + 4], 0x3
            ; xSize is 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.07: ;Asm
            pop dword EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.08: ;Asm
            mov dword [ESI + 12], EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002A.09: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F.00: ;Asm
            call SystemStringSystemStringFormatSystemStringSystemObject

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0034
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F.03: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_002F.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0034:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0034.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0034.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0034.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0039
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0034.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0039:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0039.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003A:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003A.00: ;Asm
            Int3 ; INT3
            ; LdStr
            ; String Value: comma=

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003A.01: ;Asm
            mov dword EAX, StringLiteral00E1__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003A.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003F:
            ; Ldloca

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003F.00: ;Asm
            mov dword EAX, EBP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003F.01: ;Asm
            sub dword EAX, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_003F.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0041:
            ; Constrained

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047:
            ; Callvirt
            ; ThisOffset = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.00: ;Asm
            cmp dword [ESP], 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.01: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.AfterNullCheck

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.02: ;Asm
            cli

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.03: ;Asm
            call SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.NullCheck_GetCurrAddress

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.NullCheck_GetCurrAddress:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.04: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.05: ;Asm
            mov dword [DebugStub_CallerEIP], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.06: ;Asm
            call DebugStub_SendNullReferenceOccurred

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.07: ;Asm
            hlt

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.AfterNullCheck:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.08: ;Asm
            mov dword EAX, [ESP]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.09: ;Asm
            mov dword EAX, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0A: ;Asm
            push dword [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0B: ;Asm
            push dword 0x28

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0C: ;Asm
            call SystemInt32CosmosIL2CPUVTablesImplGetMethodAddressForTypeSystemUInt32SystemUInt32

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0D: ;Asm
            pop dword ECX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.AfterAddressCheck:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0E: ;Asm
            mov dword EAX, [ESP]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.0F: ;Asm
            mov dword EAX, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.10: ;Asm
            cmp dword [EAX + 4], 0x3

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.11: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.NotBoxedThis

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.12: ;Asm
            add dword EAX, 0xC

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.13: ;Asm
            mov dword [ESP], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.NotBoxedThis:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.14: ;Asm
            call ECX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.AfterNotBoxedThis:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.15: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.16: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_004C
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.17: ;Asm
            add dword ESP, 0x4
            ; Cleanup extra stack

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.18: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.19: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0047.NoExceptionAfterCall:
            ; Argument Count = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C.00: ;Asm
            call SystemStringSystemStringConcatSystemStringSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0051
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C.03: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_004C.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0051:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0051.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0051.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0051.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0056
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0051.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0056:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0056.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0057:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0057.00: ;Asm
            Int3 ; INT3
            ; Ldc_I4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0057.01: ;Asm
            push dword 0x2A

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0059:
            ; Stloc
            ; EBPOffset = 8

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0059.00: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0059.01: ;Asm
            mov dword [EBP - 8], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005A:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005A.00: ;Asm
            NOP ; INT3
            ; LdStr
            ; String Value: aNumber= {0}

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005A.01: ;Asm
            mov dword EAX, StringLiteral00E2__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005A.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005F:
            ; Ldloc
            ; EBPOffset = 8

        SystemVoidGuessKernelGuessOSBeforeRun.IL_005F.00: ;Asm
            push dword [EBP - 8]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060:
            ; Box

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.00: ;Asm
            push dword 0x10

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.01: ;Asm
            call SystemUInt32CosmosIL2CPUGCImplementationAllocNewObjectSystemUInt32

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.02: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.03: ;Asm
            mov dword ESI, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.04: ;Asm
            mov dword EBX, [VMT__TYPE_ID_HOLDER__System_Int32_ASM_IS__mscorlib]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.05: ;Asm
            mov dword [ESI], EBX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.06: ;Asm
            mov dword [ESI + 4], 0x3
            ; xSize is 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.07: ;Asm
            pop dword EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.08: ;Asm
            mov dword [ESI + 12], EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0060.09: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065.00: ;Asm
            call SystemStringSystemStringFormatSystemStringSystemObject

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_006A
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065.03: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0065.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006A:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006A.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006A.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006A.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_006F
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006A.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006F:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_006F.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0070:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0070.00: ;Asm
            Int3 ; INT3
            ; Ldarg
            ; Arg idx = 0
            ; Arg type = GuessKernel.GuessOS
            ; Arg real size = 4 aligned size = 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0070.01: ;Asm
            push dword [EBP + 8]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071:
            ; Ldfld
            ; Field: Cosmos.Debug.Kernel.Debugger GuessKernel.GuessOS.mDebugger
            ; Type: Cosmos.Debug.Kernel.Debugger
            ; Size: 4
            ; DeclaringType: GuessKernel.GuessOS
            ; TypeOnStack: GuessKernel.GuessOS
            ; Offset: 23 (includes object header)

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.00: ;Asm
            cmp dword [ESP], 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.01: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.AfterNullCheck

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.02: ;Asm
            cli

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.03: ;Asm
            call SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.NullCheck_GetCurrAddress

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.NullCheck_GetCurrAddress:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.04: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.05: ;Asm
            mov dword [DebugStub_CallerEIP], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.06: ;Asm
            call DebugStub_SendNullReferenceOccurred

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.07: ;Asm
            hlt

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.AfterNullCheck:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.08: ;Asm
            pop dword ECX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.09: ;Asm
            mov dword ECX, [ECX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.0A: ;Asm
            add dword ECX, 0x17

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.0B: ;Asm
            mov dword EAX, [ECX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.0C: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0071.0D: ;Asm
            mov dword EAX, 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0076:
            ; LdStr
            ; String Value: aNumber= {0}

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0076.00: ;Asm
            mov dword EAX, StringLiteral00E3__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0076.01: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007B:
            ; Ldloc
            ; EBPOffset = 8

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007B.00: ;Asm
            push dword [EBP - 8]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C:
            ; Box

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.00: ;Asm
            push dword 0x10

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.01: ;Asm
            call SystemUInt32CosmosIL2CPUGCImplementationAllocNewObjectSystemUInt32

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.02: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.03: ;Asm
            mov dword ESI, [EAX]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.04: ;Asm
            mov dword EBX, [VMT__TYPE_ID_HOLDER__System_Int32_ASM_IS__mscorlib]

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.05: ;Asm
            mov dword [ESI], EBX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.06: ;Asm
            mov dword [ESI + 4], 0x3
            ; xSize is 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.07: ;Asm
            pop dword EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.08: ;Asm
            mov dword [ESI + 12], EDX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_007C.09: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.00: ;Asm
            call SystemStringSystemStringFormatSystemStringSystemObject

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0086
            ; aStackSizeBeforeCall = 12
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.03: ;Asm
            add dword ESP, 0x4
            ; Cleanup extra stack

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.04: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0081.05: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086:
            ; Callvirt
            ; ThisOffset = 4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.00: ;Asm
            cmp dword [ESP + 4], 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.01: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.AfterNullCheck

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.02: ;Asm
            cli

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.03: ;Asm
            call SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.NullCheck_GetCurrAddress

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.NullCheck_GetCurrAddress:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.04: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.05: ;Asm
            mov dword [DebugStub_CallerEIP], EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.06: ;Asm
            call DebugStub_SendNullReferenceOccurred

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.07: ;Asm
            hlt

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.AfterNullCheck:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.08: ;Asm
            call SystemVoidCosmosDebugKernelDebuggerSendSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.09: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.0A: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_008B
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.0B: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0086.NoExceptionAfterCall:
            ; Argument Count = 1

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008B:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008B.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008C:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008C.00: ;Asm
            Int3 ; INT3
            ; LdStr
            ; String Value: The cursor is 

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008C.01: ;Asm
            mov dword EAX, StringLiteral00E4__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_008C.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.00: ;Asm
            sub dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.01: ;Asm
            call SystemBooleanSystemConsoleget_CursorVisible

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.02: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.03: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_0096
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 0
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.04: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0091.05: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0096:
            ; Branch

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0096.00: ;Asm
            pop dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0096.01: ;Asm
            cmp dword EAX, 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0096.02: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.IL_009F

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0098:
            ; LdStr
            ; String Value: not visible

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0098.00: ;Asm
            mov dword EAX, StringLiteral00E5__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_0098.01: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_009D:
            ; Br

        SystemVoidGuessKernelGuessOSBeforeRun.IL_009D.00: ;Asm
            jmp SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_009F:
            ; LdStr
            ; String Value: visible

        SystemVoidGuessKernelGuessOSBeforeRun.IL_009F.00: ;Asm
            mov dword EAX, StringLiteral00E6__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_009F.01: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4.00: ;Asm
            call SystemStringSystemStringConcatSystemStringSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9
            ; aStackSizeBeforeCall = 8
            ; aTotalArgumentSizeOfMethod = 8
            ; aReturnSize = 4
            ; Cleanup return

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4.03: ;Asm
            add dword ESP, 0x4

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A4.04: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_00AE
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00A9.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AE:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AE.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AF:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AF.00: ;Asm
            Int3 ; INT3
            ; LdStr
            ; String Value: Guess Demo

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AF.01: ;Asm
            mov dword EAX, StringLiteral00E7__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00AF.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B4:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B4.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B4.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B4.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_00B9
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B4.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B9:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00B9.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BA:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BA.00: ;Asm
            Int3 ; INT3
            ; LdStr
            ; String Value: Please guess a number from 1 to 100.

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BA.01: ;Asm
            mov dword EAX, StringLiteral00E8__Handle

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BA.02: ;Asm
            push dword EAX

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BF:
            ; Call

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BF.00: ;Asm
            call SystemVoidSystemConsoleWriteLineSystemString

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BF.01: ;Asm
            test dword ECX, 0x2

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BF.02: ;Asm
            je near SystemVoidGuessKernelGuessOSBeforeRun.IL_00C4
            ; aStackSizeBeforeCall = 4
            ; aTotalArgumentSizeOfMethod = 4
            ; aReturnSize = 0

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00BF.03: ;Asm
            jne near SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00C4:
            ; Nop

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00C4.00: ;Asm
            NOP

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00C5:

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00C5.00: ;Asm
            Int3 ; INT3
            ; Ret

        SystemVoidGuessKernelGuessOSBeforeRun.IL_00C5.01: ;Asm
            jmp SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_NORMAL
            ; End Method: BeforeRun

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_NORMAL:
            ; Following code is for debugging. Adjust accordingly!

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_NORMAL.02: ;Asm
            mov dword [static_field__Cosmos_Core_INTs_mLastKnownAddress], SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_NORMAL

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_NORMAL.03: ;Asm
            mov dword ECX, 0x0

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION:

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION.04: ;Asm
            add dword ESP, 0x8

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION__2:

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION__2.05: ;Asm
            pop dword EBP

        SystemVoidGuessKernelGuessOSBeforeRun.END__OF__METHOD_EXCEPTION__2.06: ;Asm
            ret 0x4
fanoI commented 8 years ago

Guess.zip

fanoI commented 8 years ago

Console.ReadLine() is not working anymore, I think for the same cause.

fanoI commented 8 years ago

The issue is partially fixed by: https://github.com/CosmosOS/Cosmos/commit/87da5be07bbaa0dc1a7ed3f6061e8c8ff1ef4883 but this continues to fail:

 Console.WriteLine("comma=" + comma);   // Object.ToString() not implemented
charlesbetros commented 8 years ago

I think that is due to the "constrained" il op not implemented.

On Feb 14, 2016, at 14:28, fanoI notifications@github.com wrote:

The issue is partially fixed by: 87da5be but this continues to fail:

Console.WriteLine("comma=" + comma); // Object.ToString() not implemented — Reply to this email directly or view it on GitHub.

charlesbetros commented 8 years ago

Works now.