From 6ef9fba15a779af7104f9a51d60f2f40066e3ffe Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 16 Apr 2008 21:31:24 +0000 Subject: 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 --- win/configure.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++ win/m_spanningtreeVC80.vcproj | 2 ++ win/rebase.bat | 3 +++ 3 files changed, 63 insertions(+) create mode 100644 win/rebase.bat 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 @@ />