- if(!fgets(buf, 1000, f)) goto bad_rev;
- if(!fgets(buf, 1000, f)) goto bad_rev;
- if(!fgets(buf, 1000, f)) goto bad_rev;
- if(!fgets(buf, 1000, f)) goto bad_rev;
- int rev = atoi(buf);
- if(rev == 0) goto bad_rev;
- sprintf(buffer, "%u", rev);
- fclose(f);
+ 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;
+ }
- printf_c("\033[0mBase install path:\033[1;32m %s\n", base_path);
- printf_c("\033[0mConfig path:\033[1;32m %s\n", config_file);
- printf_c("\033[0mModule path:\033[1;32m %s\n", mod_path);
- printf_c("\033[0mLibrary path:\033[1;32m %s\n", library_dir);
- printf_c("\033[0mSocket Engine:\033[1;32m %s\n", use_iocp ? "iocp" : "select");
- printf_c("\033[0mMax nickname length:\033[1;32m %u\n", nicklen);
- printf_c("\033[0mMax channel length:\033[1;32m %u\n", chanlen);
- printf_c("\033[0mMax mode length:\033[1;32m %u\n", modechanges);
- printf_c("\033[0mMax ident length:\033[1;32m %u\n", identlen);
- printf_c("\033[0mMax quit length:\033[1;32m %u\n", quitlen);
- printf_c("\033[0mMax topic length:\033[1;32m %u\n", topiclen);
- printf_c("\033[0mMax kick length:\033[1;32m %u\n", kicklen);
- printf_c("\033[0mMax name length:\033[1;32m %u\n", rllen);
- printf_c("\033[0mMax away length:\033[1;32m %u\n", awaylen);
+ printf_c("\033[0mBase install path:\033[1;32m %s\n", base_path);
+ printf_c("\033[0mConfig path:\033[1;32m %s\n", config_file);
+ printf_c("\033[0mModule path:\033[1;32m %s\n", mod_path);
+ printf_c("\033[0mLibrary path:\033[1;32m %s\n", library_dir);
+ printf_c("\033[0mSocket Engine:\033[1;32m %s\n", use_iocp ? "iocp" : "select");
+ printf_c("\033[0mMax nickname length:\033[1;32m %u\n", nicklen);
+ printf_c("\033[0mMax channel length:\033[1;32m %u\n", chanlen);
+ printf_c("\033[0mMax mode length:\033[1;32m %u\n", modechanges);
+ printf_c("\033[0mMax ident length:\033[1;32m %u\n", identlen);
+ printf_c("\033[0mMax quit length:\033[1;32m %u\n", quitlen);
+ printf_c("\033[0mMax topic length:\033[1;32m %u\n", topiclen);
+ printf_c("\033[0mMax kick length:\033[1;32m %u\n", kicklen);
+ printf_c("\033[0mMax name length:\033[1;32m %u\n", rllen);
+ printf_c("\033[0mMax away length:\033[1;32m %u\n", awaylen);
+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 11000000 -c baseaddr_modules.txt %s", dest);
+ printf("%s\n", command);
+ system(command);
+
+ FindClose(fh);
+
+}
+
CreateDirectory("..\\src\\debug", NULL);
CreateDirectory("..\\bin\\debug\\bin", NULL);
CreateDirectory("..\\bin\\debug\\lib", NULL);
CreateDirectory("..\\src\\debug", NULL);
CreateDirectory("..\\bin\\debug\\bin", NULL);
CreateDirectory("..\\bin\\debug\\lib", NULL);
CreateDirectory("..\\src\\debug", NULL);
CreateDirectory("..\\bin\\debug\\bin", NULL);
CreateDirectory("..\\bin\\debug\\lib", NULL);
CreateDirectory("..\\src\\debug", NULL);
CreateDirectory("..\\bin\\debug\\bin", NULL);
CreateDirectory("..\\bin\\debug\\lib", NULL);
CreateDirectory("..\\src\\modules\\debug_x64", NULL);
#else
fprintf(f, " cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release_x64\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\release_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\release_x64\\modules\\$*.lib\"\n\n");
CreateDirectory("..\\src\\modules\\debug_x64", NULL);
#else
fprintf(f, " cl /nologo /LD /Od /I \".\" /I \"../../include\" /I \"../../include/modes\" /I \"../../include/modules\" /I \"../../win\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"DLL_BUILD\" /EHsc /Gm /MT /Fo\"Release/\" /Fd\"Release/vc70.pdb\" /W2 /Wp64 /Zi /TP $*.cpp ..\\..\\win\\inspircd_memory_functions.cpp /link ..\\..\\bin\\release_x64\\bin\\inspircd.lib ws2_32.lib /OUT:\"..\\..\\bin\\release_x64\\modules\\$*.so\" /PDB:\"..\\..\\bin\\release_x64\\modules\\$*.pdb\" /MACHINE:X64 /IMPLIB:\"..\\..\\bin\\release_x64\\modules\\$*.lib\"\n\n");
CreateDirectory("..\\src\\modules\\debug", NULL);
CreateDirectory("..\\src\\modules\\debug\\lib", NULL);
CreateDirectory("..\\src\\modules\\debug\\modules", NULL);
CreateDirectory("..\\src\\modules\\debug", NULL);
CreateDirectory("..\\src\\modules\\debug\\lib", NULL);
CreateDirectory("..\\src\\modules\\debug\\modules", NULL);