Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Tag
- {
- public uint tagType;
- public uint tagSize;
- };
- struct TagMemoryMap
- {
- public uint tagType;
- public uint tagSize;
- public uint entrySize;
- public uint entryVersion;
- public struct Entry
- {
- align(1):
- ulong baseAddress;
- ulong length;
- uint memoryType;
- uint zero;
- }
- public Entry entries[0];
- };
- @property
- {
- public static TagMemoryMap* memoryMap()
- {
- TagMemoryMap* memMap = getTag!( TagMemoryMap* )( tagType.MEMMAP );
- ulong entryAddr = cast(ulong)(memMap + memMap.tagType.sizeof + memMap.tagSize.sizeof + memMap.entrySize.sizeof + memMap.entryVersion.sizeof);
- ulong entrylimit = cast(ulong)(memMap + memMap.tagSize);
- TagMemoryMap.Entry* mmapEntries;
- while( entryAddr < entrylimit ) {
- TagMemoryMap.Entry* entry = cast(TagMemoryMap.Entry*) entryAddr;
- if( entry.memoryType < memoryType.UNKNOWN ) {
- Trace.printf( " * * %s memory: %x; length: %d\n", memoryTypeNames[entry.memoryType], entry.baseAddress, entry.length );
- }
- entryAddr += memMap.entrySize;
- }
- return memMap;
- }
- }
- private static T getTag( T )( uint tType )
- {
- if( tType <= tagType.TERMINATOR || tType > tagType.NETWORK ) {
- return null;
- }
- for( Tag* tag = cast(Tag*)(infoAddr + 8); tag.tagType != tagType.TERMINATOR; tag = cast(Tag*)( (cast(ubyte*)tag) + ((tag.tagSize + 7) & ~7))) {
- if( tType == tag.tagType ) {
- return cast(T)(tag);
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement