Frost Posted December 27, 2013 Posted December 27, 2013 Hello everyone, im new here. Great site, i have to admit it. I've seen many sav editors, and as always, I need to create my own. I've been searching for 129012901221 hours (aprox.) on how to decrypt sav files. I've been lookin onto many source codes but i still don't get how im supposed to do it. Also every Lib i found was coded in C++, but i only use C#.. So what im asking is.. can one of you, creator of a sav editor, help me on my project? I'm banging my head against a wall right now, im only making interfaces... P.S: I know that to read sav files you need to read them as bytes and stuff, but i just dont know how to do that. also, i just restarted programming... took a 1 year long break from coding..
codemonkey85 Posted December 27, 2013 Posted December 27, 2013 Just out of curiosity, if you're "restarting" programming now, why not simply learn a language better suited for the job (i.e. C++)? Anyway, there are many different ways of reading binary files in C#. I think probably the easiest way to just get at the data itself is to use a BinaryReader class: http://msdn.microsoft.com/en-us/library/system.io.binaryreader(v=vs.110).aspx. However, my personal preference is binary serialization. You can check out this page for some info: http://stackoverflow.com/questions/3537583/properly-copy-c-sharp-structs-with-byte-arrays-in-them
Frost Posted December 27, 2013 Author Posted December 27, 2013 Because learning a new language takes time, and I don't really have that. School, friends, family, etc... I still don't get, once opened the sav file, how to read stuff from it. I've never used this kind of files in programming. Never ever used decryption, encryption... Well, actually i did once to edit Terraria sav files but it was done by copying a source code to see it in action, and I still don't get something: this.CharName = reader.ReadString(); This line of code should read from a sav file, the char's name. WHat i can't understand is: why reader.ReadString() ? I mean... no arguments for the reader to understand what it's supposed to read? I can't explain it, but that method seems very generic for me
codemonkey85 Posted December 27, 2013 Posted December 27, 2013 Because learning a new language takes time, and I don't really have that. This isn't meant aggressively, but software development isn't just some magic wand that you can wield to do your will. If you don't put in the time, you won't learn, and you won't really develop much of anything. Well, actually i did once to edit Terraria sav files but it was done by copying a source code to see it in action, and I still don't get something: this.CharName = reader.ReadString(); This line of code should read from a sav file, the char's name. WHat i can't understand is: why reader.ReadString() ? I mean... no arguments for the reader to understand what it's supposed to read? I can't explain it, but that method seems very generic for me There's no way to know for certain what "reader" is just from this snippet. However, my guess is it's the BinaryReader class I mentioned earlier: http://msdn.microsoft.com/en-us/library/system.io.binaryreader.readstring(v=vs.110).aspx Did you see the link I'd posted before? Not to sound like a broken record, but you have to put in some time and thought to be successful at development.
evandixon Posted December 27, 2013 Posted December 27, 2013 Just curious, what game do you want to make a save editor for?
Frost Posted December 27, 2013 Author Posted December 27, 2013 (edited) I know that, codemonkey.. actually to be honest, I learn more from source codes than tutorials. If i don't understand something, I follow tutorials then. btw yes, it's BinaryReader, and no, I haven't read that because I had to go. I replied as fast as I could.. also, now Im just checking this thread, so i might work on this tomorrow or later at night. evandixon: I thought about, for now, R/S/E sav editor since im playing it on my iPhone.In the future, if i get how to do this, I might update my program for the last Pokemon games. Edited December 27, 2013 by Frost
Zaz Posted February 16, 2014 Posted February 16, 2014 Hi, sorry for being very late to the party, but I've read through the thread and if you learn best by looking at source code, and want to code a Gen3 save editor in C#, you are very welcome to look at mine. https://github.com/Zazcallabah/PokeSave also, codemonkey85, I love your work but dude it is really backwards of you to consider C++ a superior choice in this instance.
codemonkey85 Posted February 17, 2014 Posted February 17, 2014 also, codemonkey85, I love your work but dude it is really backwards of you to consider C++ a superior choice in this instance. I suppose that's fair, although my opinion is different and I still stand by my statement about putting in time.
Metropolis Posted February 23, 2014 Posted February 23, 2014 Hello everyone, im new here. Great site, i have to admit it. I've seen many sav editors, and as always, I need to create my own. I've been searching for 129012901221 hours (aprox.) on how to decrypt sav files. I've been lookin onto many source codes but i still don't get how im supposed to do it. Also every Lib i found was coded in C++, but i only use C#..So what im asking is.. can one of you, creator of a sav editor, help me on my project? I'm banging my head against a wall right now, im only making interfaces... P.S: I know that to read sav files you need to read them as bytes and stuff, but i just dont know how to do that. also, i just restarted programming... took a 1 year long break from coding.. Gen1 and 2 games are stored big endian which means byte-for-byte your write it as it is as if you were writing it down pen on paper. In Gen3 you have reverse the order of the bytes. In Java, I defined two methods for Gen1/2 read/writing: public static int extractBytes(RandomAccessFile fileInput, final int numBytes) throws IOException { int readData = 0; for (int index = 0; index < numBytes; index++) { readData <<= 8; readData |= fileInput.read(); } return readData; } public static void insertBytes(RandomAccessFile fileOutput, final int writeData, final int numBytes) throws IOException { for (int index = 1; index <= numBytes; index++) { fileOutput.write((writeData >> 8 * (numBytes - index)) & 0xFF); } } Then in the rest of the code I can make calls like extractBytes(fileInput, 2); to read in two bytes of data as an integer. Java primitives are always signed, which annoyingly means things in the range 0 to 255 like friendship can't be stored as bytes in the memory, so I've simplified by making everything ints. Expect for actual 8-bits signed integers which need an unsigned long to store. For Gen3 you'll need code like this to reverse the bytes: public static int extractBytes(RandomAccessFile fileInput, int numBytes) throws IOException { int readData = 0; for (int index = 0; index < numBytes; index++) readData |= fileInput.read() << (index * 8); return readData; } There might be code libraries out there to do the right type of endian writing for you. The block-shuffling is a pain, but you'd need to get read/write for the unecrypted part first anyhow. My implementation uses the RandomAccessFile package, which is a standard in Java, there will be similar read/write functionality in C++ but I don't know it. You're best starting small and working up one step at a time, ie get "Hello World" written to a text file before thinking about how to handle PKM files. There's lots of good info on Bulbapedia about how the files are encrypted.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now