using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace PBSS_Viewer
{
static public class ScreenShotData
{
static public void GetSSInfo(string filePath, TextBox guid, TextBox player)
{
//Open the file up into a stream
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
//Now use that stream to create a binaryreader
BinaryReader br = new BinaryReader(fs);
//Move to the position of our choice
br.BaseStream.Position = 0x21;
//Read the length of the data block
int size = readBigEndianInt(br);
//Read the data string
string data = new string(br.ReadChars(size));
//Now close the stream which closes the br as well
fs.Close();
//Now lets remove up until we get the real data
int indexOfNull = data.IndexOf('\0') + 1;
data = data.Substring(indexOfNull, data.Length - indexOfNull);
//Break up the string into parts
string[] parts = data.Split('\n');
//We know that the user will always be at part 3 so lets get that
string user = parts[2];
//Now lets split that up beacuse there is a id and there is a name
string[] userinfo = user.Split(' ');
if (userinfo.Length == 3)
{
player.Text = userinfo[1] + userinfo[2];
}
else player.Text = userinfo[1];
guid.Text = userinfo[0];
}
static int readBigEndianInt(BinaryReader br)
{
byte[] buffer = br.ReadBytes(4);
Array.Reverse(buffer);
return BitConverter.ToInt32(buffer, 0);
}
}
}