godzcheater

exampleEditor [Raza]

Sep 16th, 2013
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using PackageIO;
  9.  
  10. namespace exampleEditor
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public IO io;
  15.  
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.             //NumericUpDown uses some crazzy int thing, that is never used in real world. (I think)
  20.             //So it is usually int or short. W/E your value is
  21.             nudValue.Maximum = int.MaxValue;
  22.             nudValue.Minimum = int.MinValue;
  23.         }
  24.  
  25.         private void btnOpen_Click(object sender, EventArgs e)
  26.         {
  27.             OpenFileDialog ofd = new OpenFileDialog();//blah
  28.             if (ofd.ShowDialog() != DialogResult.OK)
  29.                 return;//if they click cancel GTFO
  30.             io = new IO(ofd.FileName, Endian.Big);//Most on Xbox are big, but sometimes small.
  31.             io.Position = 1337;//offset of useful info
  32.             nudValue.Value = io.ReadInt32();//this can be cast fine, but not the other way
  33.         }
  34.         private void btnSave_Click(object sender, EventArgs e)
  35.         {
  36.             if (io == null)
  37.             {//if it is still null, they haven't loaded a file
  38.                 MessageBox.Show("No file open gtfo");
  39.                 return;
  40.             }
  41.             io.Position = 1337;
  42.             io.WriteInt32((int)nudValue.Value);//Now you actually have to cast it to an int
  43.  
  44.             //Now to fix the hash
  45.             uint Len = (uint)io.Length - 48;//32 + 16 == 48, so this is just the length of the buffer
  46.             uint Hash = 0;
  47.             for (uint i = 0; i < Len; i++)
  48.                 Hash += io.ReadUInt8();
  49.             io.Position = 20000;//go to the HashOffset and write it.
  50.             io.WriteUInt32(Hash);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment