static void GenerateINI(INI_Reader ini) { ini.IniWriteValue("MCPatch", "gwpath", "Gw.exe"); ini.IniWriteValue("MCPatch", "enabled", "1"); ini.IniWriteValue("MCPatch", "datfix", "1"); ini.IniWriteValue("LoadDLL", "enabled", "0"); ini.IniWriteValue("LoadDLL", "dllpath", ""); }
static void Main() { INI_Reader settings = new INI_Reader(Environment.CurrentDirectory + "\\GWMC.ini"); if (!File.Exists(Environment.CurrentDirectory + "\\GWMC.ini")) { GenerateINI(settings); } string gwpath = settings.IniReadValue("MCPatch", "gwpath"); if (gwpath == "Gw.exe") { gwpath = Environment.CurrentDirectory + "\\Gw.exe"; } /* try * { * if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", null) != null) * { * Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(gwpath)); * Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(gwpath)); * } * * if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", null) != null) * { * Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(gwpath)); * Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(gwpath)); * } * } * catch (System.UnauthorizedAccessException) * { * MessageBox.Show("Insufficient access rights.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * }*/ if (!File.Exists(Environment.CurrentDirectory + "\\GWMC.ini")) { GenerateINI(settings); } STARTUPINFO startup = new STARTUPINFO(); PROCESS_INFORMATION procinfo; bool createprocessresult = CreateProcess( gwpath, Environment.CommandLine, IntPtr.Zero, IntPtr.Zero, false, ProcessCreationFlags.CREATE_SUSPENDED, IntPtr.Zero, null, ref startup, out procinfo); if (createprocessresult == false) { MessageBox.Show("Unable to launch Gw.exe.\nIs the path correct in the ini file?", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Process gwproc = Process.GetProcessById((int)procinfo.dwProcessId); GWCAMemory memmgr = new GWCAMemory(gwproc); MulticlientPatch patcher = new MulticlientPatch(memmgr); if (settings.IniReadValue("MCPatch", "enabled") == "1") { patcher.ApplyMulticlientPatch(); } if (settings.IniReadValue("MCPatch", "datfix") == "1") { patcher.ApplyDatFix(); } if (settings.IniReadValue("LoadDLL", "enabled") == "1") { memmgr.LoadModule(settings.IniReadValue("LoadDLL", "dllpath")); } ResumeThread(procinfo.hThread); }