Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using PackageIO;
- namespace exampleEditor
- {
- public partial class Form1 : Form
- {
- public IO io;
- public Form1()
- {
- InitializeComponent();
- //NumericUpDown uses some crazzy int thing, that is never used in real world. (I think)
- //So it is usually int or short. W/E your value is
- nudValue.Maximum = int.MaxValue;
- nudValue.Minimum = int.MinValue;
- }
- private void btnOpen_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();//blah
- if (ofd.ShowDialog() != DialogResult.OK)
- return;//if they click cancel GTFO
- io = new IO(ofd.FileName, Endian.Big);//Most on Xbox are big, but sometimes small.
- io.Position = 1337;//offset of useful info
- nudValue.Value = io.ReadInt32();//this can be cast fine, but not the other way
- }
- private void btnSave_Click(object sender, EventArgs e)
- {
- if (io == null)
- {//if it is still null, they haven't loaded a file
- MessageBox.Show("No file open gtfo");
- return;
- }
- io.Position = 1337;
- io.WriteInt32((int)nudValue.Value);//Now you actually have to cast it to an int
- //Now to fix the hash
- uint Len = (uint)io.Length - 48;//32 + 16 == 48, so this is just the length of the buffer
- uint Hash = 0;
- for (uint i = 0; i < Len; i++)
- Hash += io.ReadUInt8();
- io.Position = 20000;//go to the HashOffset and write it.
- io.WriteUInt32(Hash);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment