1 module bootstrapper; 2 version( Bootstrapper ): 3 4 import core.runtime; 5 import std.stdio; 6 7 version( Windows ) 8 import std.c.windows.windows; 9 else 10 import core.sys.posix.dlfcn; 11 12 enum RunResult : uint 13 { 14 Exit = 0, 15 Reset = 1 16 } 17 18 void main() 19 { 20 RunResult result; 21 string libPath; 22 23 version( Windows ) 24 libPath = "dash.dll"; 25 else 26 libPath = "libdvelop.so"; 27 28 write( "If you want to debug, attach to bootstrapper.exe, then press enter." ); 29 readln(); 30 31 do 32 { 33 auto lib = Runtime.loadLibrary( libPath ); 34 35 if( lib is null ) 36 { 37 writeln( "Unable to find library: ", libPath ); 38 break; 39 } 40 41 uint function() dGameEntry; 42 43 version( Windows ) 44 { 45 dGameEntry = cast(uint function())GetProcAddress( lib, "_D4core4main10DGameEntryFZk" ); 46 } 47 else version( Posix ) 48 { 49 dGameEntry = cast(uint function())dlsym( lib, "_D4core4main10DGameEntryFZk" ); 50 } 51 52 result = cast(RunResult)dGameEntry(); 53 54 Runtime.unloadLibrary( lib ); 55 56 final switch( result ) 57 { 58 case RunResult.Exit: 59 // Exited successfully. 60 break; 61 case RunResult.Reset: 62 // Need to reset; 63 write( "Press enter to continue resetting." ); 64 readln(); 65 break; 66 } 67 } while( result == RunResult.Reset ); 68 }