static void EditSettings(Process proc, CodeVersion version, Session session) { using (ProcessStream ps = new ProcessStream(proc)) { ps.Write(0xB8); // mov eax, bool ps.WriteInt(Settings.ShowErrors ? 1 : 0); ps.WriteNops(6); ps.Inject(version.ShowErrAddress); ps.Reset(); ps.Write(0xB8); // mov eax, bool ps.WriteInt(Settings.WindowedMode ? 1 : 0); ps.WriteNops(6); ps.Inject(version.WindowedAddress); ps.Reset(); ps.Write(0xB8); // mov eax, bool ps.WriteInt(Settings.DisableAudio ? 1 : 0); ps.WriteNops(6); ps.Inject(version.NoAudioAddress); // set mod folder ps.Reset(); ps.Write(0xB8); // mov eax, modNameAddress ps.WriteInt(string.Equals(session.ModName, "Default", StringComparison.OrdinalIgnoreCase) ? 0 : ps.AllocString(session.ModName + '\0')); ps.WriteNops(6); ps.Inject(version.ModAddress); } }
static void EditStartNewCampaign(Process proc, CodeVersion version, Session session) { // set campaign using (ProcessStream ps = new ProcessStream(proc)) { ps.Write(0xB8); // mov eax, campaignNameAddress ps.WriteInt(ps.AllocString(session.CampaignName + '\0')); ps.WriteNops(6); ps.Inject(version.CampaignAddress); } proc.WriteInt(version.FactionAddress, session.GetCurrentFaction().RomeIndex); proc.WriteInt(version.CampaignDifficulty, session.Difficulty); // campaign difficulty proc.WriteInt(version.BattleDifficulty, session.Difficulty); // battle difficulty proc.Write(version.ArcadeBattles, (byte)(session.ArcadeBattles ? 1 : 0)); // arcade battles proc.Write(version.AutoManage, (byte)(session.AutoManage ? 1 : 0)); // auto manage proc.Write(version.NoBattleTimeLimit, (byte)(session.NoBattleTimeLimit ? 1 : 0)); // no battle time limit proc.Write(version.ShortCampaign, (byte)(session.ShortCampaign ? 1 : 0)); // short campaign }