Annotation of truecrypt/boot/windows/bootmemory.cpp, revision 1.1.1.2

1.1       root        1: /*
                      2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
                      3: 
1.1.1.2 ! root        4:  Governed by the TrueCrypt License 2.5 the full text of which is contained
1.1       root        5:  in the file License.txt included in TrueCrypt binary and source code
                      6:  distribution packages.
                      7: */
                      8: 
                      9: #include "BootMemory.h"
                     10: 
                     11: static uint32 MemoryMapContValue;
                     12: 
                     13: static bool GetMemoryMapEntry (BiosMemoryMapEntry &entry)
                     14: {
                     15:        static const uint32 function = 0x0000E820UL;
                     16:        static const uint32 magic = 0x534D4150UL;
                     17:        static const uint32 bufferSize = sizeof (BiosMemoryMapEntry);
                     18: 
                     19:        bool carry = false;
                     20:        uint32 resultMagic;
                     21:        uint32 resultSize;
                     22: 
                     23:        __asm
                     24:        {
                     25:                lea di, function
                     26:                TC_ASM_MOV_EAX_DI
                     27:                lea di, MemoryMapContValue
                     28:                TC_ASM_MOV_EBX_DI
                     29:                lea di, bufferSize
                     30:                TC_ASM_MOV_ECX_DI
                     31:                lea di, magic
                     32:                TC_ASM_MOV_EDX_DI
                     33:                lea di, MemoryMapContValue
                     34:                TC_ASM_MOV_DI_ECX
                     35: 
                     36:                lea di, entry
                     37:                mov di, [entry]
                     38: 
                     39:                int 0x15
                     40:                jnc no_carry
                     41:                mov carry, true
                     42:        no_carry:
                     43: 
                     44:                lea di, resultMagic
                     45:                TC_ASM_MOV_DI_EAX
                     46:                lea di, MemoryMapContValue
                     47:                TC_ASM_MOV_DI_EBX
                     48:                lea di, resultSize
                     49:                TC_ASM_MOV_DI_ECX
                     50:        }
                     51: 
                     52:        // BIOS may set CF at the end of the list
                     53:        if (carry)
                     54:                MemoryMapContValue = 0;
                     55: 
                     56:        return resultMagic == magic && resultSize == bufferSize;
                     57: }
                     58: 
                     59: 
                     60: bool GetFirstBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
                     61: {
                     62:        MemoryMapContValue = 0;
                     63:        return GetMemoryMapEntry (entry);
                     64: }
                     65: 
                     66: 
                     67: bool GetNextBiosMemoryMapEntry (BiosMemoryMapEntry &entry)
                     68: {
                     69:        if (MemoryMapContValue == 0)
                     70:                return false;
                     71: 
                     72:        return GetMemoryMapEntry (entry);
                     73: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.