diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-16 21:31:24 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-16 21:31:24 +0000 |
commit | 6ef9fba15a779af7104f9a51d60f2f40066e3ffe (patch) | |
tree | 49941141ead4ddb1847b150e3e46776683b3c765 /win | |
parent | 75d17f67a472d04ff899513fcb9987c387161d71 (diff) |
Automatic rebasing of load addresses for .so files on windows, thanks to GreenReaper for the hints and tips
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9519 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'win')
-rw-r--r-- | win/configure.cpp | 58 | ||||
-rw-r--r-- | win/m_spanningtreeVC80.vcproj | 2 | ||||
-rw-r--r-- | win/rebase.bat | 3 |
3 files changed, 63 insertions, 0 deletions
diff --git a/win/configure.cpp b/win/configure.cpp index 94d1b898c..1b097da06 100644 --- a/win/configure.cpp +++ b/win/configure.cpp @@ -26,6 +26,7 @@ void Run(); void Banner(); void WriteCompileModules(); void WriteCompileCommands(); +void Rebase(); /* detects if we are running windows xp or higher (5.1) */ bool iswinxp() @@ -143,6 +144,17 @@ int get_svn_revision(char * buffer, size_t len) int __stdcall WinMain(IN HINSTANCE hInstance, IN HINSTANCE hPrevInstance, IN LPSTR lpCmdLine, IN int nShowCmd ) { + if (!strcmp(lpCmdLine, "/rebase")) + { + AllocConsole(); + // pipe standard handles to this console + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + Rebase(); + FreeConsole(); + return 0; + } FILE * j = fopen("inspircd_config.h", "r"); if (j) { @@ -412,6 +424,52 @@ void Run() printf("\nconfigure is done.. exiting!\n"); } +void Rebase() +{ + char dest[65535]; + char command[65535]; + + *dest = 0; + + WIN32_FIND_DATA fd; + HANDLE fh = FindFirstFile("..\\bin\\release\\lib\\*.so", &fd); + if(fh == INVALID_HANDLE_VALUE) + return; + + do + { + strcat(dest, " ..\\bin\\release\\lib\\"); + strcat(dest, fd.cFileName); + } + while (FindNextFile(fh, &fd)); + + FindClose(fh); + + sprintf(command, "rebase.exe -v -b 10000000 -c baseaddr_commands.txt %s", dest); + printf("%s\n", command); + system(command); + + fh = FindFirstFile("..\\bin\\release\\modules\\*.so", &fd); + if(fh == INVALID_HANDLE_VALUE) + return; + + *dest = 0; + + do + { + strcat(dest, " ..\\bin\\release\\modules\\"); + strcat(dest, fd.cFileName); + } + while (FindNextFile(fh, &fd)); + + sprintf(command, "rebase.exe -v -b 10000000 -c baseaddr_modules.txt %s", dest); + printf("%s\n", command); + system(command); + + FindClose(fh); + +} + void WriteCompileCommands() { char commands[300][100]; diff --git a/win/m_spanningtreeVC80.vcproj b/win/m_spanningtreeVC80.vcproj index db0552de7..59b2e1ca4 100644 --- a/win/m_spanningtreeVC80.vcproj +++ b/win/m_spanningtreeVC80.vcproj @@ -180,6 +180,8 @@ />
<Tool
Name="VCPostBuildEventTool"
+ Description="Re-basing shared objects..."
+ CommandLine="$(InputDir)\rebase.bat
"
/>
</Configuration>
<Configuration
diff --git a/win/rebase.bat b/win/rebase.bat new file mode 100644 index 000000000..e954f0a46 --- /dev/null +++ b/win/rebase.bat @@ -0,0 +1,3 @@ +rem just in case +set PATH=%PATH%;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin +configure.exe /rebase |