Support for non-standard module base addresses
[reactos.git] / reactos / tools / rbuild / module.cpp
index 7f27702..47157e4 100644 (file)
@@ -82,6 +82,12 @@ Module::Module ( const Project& project,
        else\r
                entrypoint = GetDefaultModuleEntrypoint ();\r
 \r
+       att = moduleNode.GetAttribute ( "baseaddress", false );\r
+       if ( att != NULL )\r
+               baseaddress = att->value;\r
+       else\r
+               baseaddress = GetDefaultModuleBaseaddress ();\r
+\r
        att = moduleNode.GetAttribute ( "mangledsymbols", false );\r
        if ( att != NULL )\r
                mangledSymbols = att->value != "false";\r
@@ -365,6 +371,39 @@ Module::GetDefaultModuleEntrypoint () const
                                          __LINE__ );\r
 }\r
 \r
+string\r
+Module::GetDefaultModuleBaseaddress () const\r
+{\r
+       switch (type)\r
+       {\r
+               case Kernel:\r
+                       return "0xc0000000";\r
+               case KernelModeDLL:\r
+                       return "0x10000";\r
+               case NativeDLL:\r
+                       return "0x10000";\r
+               case NativeCUI:\r
+                       return "0x10000";\r
+               case Win32DLL:\r
+                       return "0x10000";\r
+               case Win32CUI:\r
+                       return "0x00400000";\r
+               case Win32GUI:\r
+                       return "0x00400000";\r
+               case KernelModeDriver:\r
+                       return "0x10000";\r
+               case BuildTool:\r
+               case StaticLibrary:\r
+               case ObjectLibrary:\r
+               case BootLoader:\r
+               case BootSector:\r
+               case Iso:\r
+                       return "";\r
+       }\r
+       throw InvalidOperationException ( __FILE__,\r
+                                         __LINE__ );\r
+}\r
+\r
 bool\r
 Module::HasImportLibrary () const\r
 {\r