Commits

Swyter committed 007b700

*1st

  • Participants

Comments (0)

Files changed (7)

+:: Build file for scotools -- by swyter
+:: Requires windres (from GCC's binutils) and TCC <bellard.org/tcc/>
+@echo off && cls && title [swybuild] && goto :init
+
+:build
+
+  windres -v res/%1.rc res/%1.rc.o                                                       && echo.  ~Resources processed... && echo. 
+  tcc -v %1-loader.c %1-inject.c %1-helper.c res/%1.rc.o -o _%1.exe -luser32 -ladvapi32  && echo.  ~Compilation done...    && echo. 
+  goto :EOF
+  
+:init
+
+  call :build swconquest
+  copy _swconquest.exe R:\Juegos\swconquest\modules\swconquest-branch
+
+  echo Completed! Press any key to rebuild...
+  pause > nul && echo. 
+                 echo -------------  
+                 echo.   
+                 goto :init

res/swc_icon.ico

Added
New image

res/swc_icon_mini.ico

Added
New image

res/swconquest.rc

+100 ICON "swc_icon_mini.ico"
+
+1 VERSIONINFO
+FILEVERSION 0,9,4,0
+PRODUCTVERSION 0,9,4,0
+FILEOS 0x4
+FILETYPE 0x1
+{
+BLOCK "StringFileInfo"
+{
+	BLOCK "040904b0"
+	{
+		VALUE "CompanyName",      "SWC Dev Team <getconquest.net>"
+		VALUE "FileDescription",  "Star Wars Conquest Launcher"
+		VALUE "FileVersion",      "0.9.4"
+		VALUE "InternalName",     "swconquest.exe"
+		VALUE "LegalCopyright",   "� 2012 Created by Swyter"
+		VALUE "OriginalFilename", "swconquest.exe"
+		VALUE "ProductName",      "swconquest"
+		VALUE "ProductVersion",   "0.9.4"
+	}
+}
+BLOCK "VarFileInfo"
+{
+	VALUE "Translation", 0x0800, 0xFDE9
+}
+}

swconquest-helper.c

+#define WIN32_LEAN_AND_MEAN
+#define WIN32_EXTRA_LEAN
+
+#include <windows.h>
+
+BOOL FileExists(LPCTSTR szPath)
+{
+  DWORD dwAttrib = GetFileAttributes(szPath);
+
+  return (dwAttrib != INVALID_FILE_ATTRIBUTES && 
+         !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
+}
+
+char* GetCurrentFolderName()
+{
+  extern static char filename[MAX_PATH];
+  GetModuleFileName( NULL, filename, MAX_PATH );
+
+  //find the latest slash, get the string until that and return the pointer following the next occurence
+  char*lslash = strrchr(filename, '\\');
+  filename[(lslash-filename)]=0;
+
+  return (char*)(strrchr(filename, '\\')+1);
+}
+
+BOOL SetActiveMod(const char*szModName){
+  // some undefined constants in TinyCC's headers
+  #define KEY_WOW64_64KEY 0x0100
+  #define KEY_WOW64_32KEY 0x0200
+
+  PHKEY*keyThingie;
+  RegOpenKeyEx(
+    HKEY_CURRENT_USER,
+   "Software\\MountAndBladeKeys",
+    0,
+    KEY_READ|KEY_WRITE|KEY_WOW64_32KEY,
+    &keyThingie
+    );
+    
+  if(keyThingie){
+    RegSetValueEx(
+        keyThingie,
+       "last_module",
+        0,
+        REG_SZ,
+        szModName,
+        strlen(szModName)
+        );
+    RegCloseKey(keyThingie);
+    return 1;
+  }
+  
+  return 0;
+}
+
+
+HANDLE LaunchGame(){
+	STARTUPINFO Startup = {0};
+	PROCESS_INFORMATION processInformation = {0};
+	
+	int proc = CreateProcess("../../mount&blade.exe",
+                           NULL,
+                           NULL,
+                           NULL,
+                           FALSE,
+                           HIGH_PRIORITY_CLASS,//|CREATE_SUSPENDED,
+                           NULL,
+                           "../..",
+                           &Startup,
+                           &processInformation
+                           );
+	
+  if(proc){
+    WaitForInputIdle(
+      processInformation.hProcess,
+      INFINITE
+    );
+    return processInformation.hProcess;
+    
+  }else{
+    return 0;
+  }
+}

swconquest-inject.c

+#define WIN32_LEAN_AND_MEAN
+#define WIN32_EXTRA_LEAN
+
+#include <windows.h>
+
+
+InjectString(HANDLE hProcess, char*string){
+  return 0;
+}
+
+ReplaceMem(char*find, char*replace){
+
+}

swconquest-loader.c

+/* swconquest-loader -- created by swyter -- licensed under MIT-like terms.
+ * * * * * * * * * *
+ * launches mount and blade with our module selected plus injecting our own font paths in memory,
+ * so we don't have to hot-swap files physically.
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#define WIN32_EXTRA_LEAN
+
+#include <windows.h>
+
+main(){
+
+	//checking if the game exists
+	printf("locating mount and blade 1011: ");
+	
+	if(!FileExists("../../mount&blade.exe"))
+		printf("[not found] ");
+	else
+		printf("[found] ");
+	
+	
+	printf("\n");
+  
+  
+	//selecting default module
+  char*modname;
+  modname=GetCurrentFolderName(modname);
+  
+  extern static char filename[MAX_PATH];
+  strcpy(filename,modname);
+  
+	printf("selecting '%s' as default module: ", modname); SetActiveMod(filename);
+	printf("[done]\n");
+  
+  
+	//launching the game
+	printf("launching the game: "); LaunchGame();
+	printf("[done]\n");
+  
+  
+	//injecting paths in memory
+	printf("injecting paths in memory: ");
+	printf("done\n");
+	
+	getchar();
+	return 0;
+}