private void RunDecrypt(DecryptOptions opt) { LogVerbose("Parsing and formatting save game JSON"); string formattedJson; try { formattedJson = _gs.ToFormattedJsonString(); } catch (Exception x) { throw new Exception(string.Format("Error formatting JSON (invalid save?): {0}", x.Message)); } LogVerbose("Writing formatted JSON to:\n {0}", opt.OutputPath); try { File.WriteAllText(opt.OutputPath, formattedJson); } catch (Exception x) { throw new Exception(string.Format("Error writing decrypted JSON: {0}", x.Message)); } Log("Wrote save game to formatted JSON file: {0}", opt.OutputPath); }
private void get_Click(object sender, RoutedEventArgs e) { NMST.Program nmstool = new NMST.Program(); NMST.DecryptOptions opt = new NMST.DecryptOptions(); opt.GameMode = NMST.GameModes.normal; opt.OutputPath = System.IO.Path.GetTempFileName(); opt.SaveDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HelloGames\\NMS\\DefaultUser"); opt.Verbose = false; nmstool.RunDecrypt(opt); }
public bool RunDecrypt(DecryptOptions opt) { DoCommon(opt); GameSaveDir gsd; try { gsd = new GameSaveDir(opt.SaveDir); } catch (Exception x) { LogError("Error locating game save file:\n{0}", x.Message); return(false); } object json; try { json = ReadLatestSaveFile(gsd, opt.GameMode); } catch (Exception x) { LogError("Error loading or parsing save file: {0}", x.Message); return(false); } LogVerbose("Parsing and formatting save game JSON"); string formattedJson; try { formattedJson = JsonConvert.SerializeObject(json, Formatting.Indented); } catch (Exception x) { LogError("Error formatting JSON (invalid save?): {0}", x.Message); return(false); } LogVerbose("Writing formatted JSON to:\n {0}", opt.OutputPath); try { File.WriteAllText(opt.OutputPath, formattedJson); } catch (Exception x) { LogError("Error writing decrypted JSON: {0}", x.Message); return(false); } return(true); }