public class Strings
{
static MainWindow MainWindow_Instance = MainWindow.Instance;
static Stopwatch FileLoadTimer = new Stopwatch();
static Header FileHeader = null;
public static byte[] RawBytes = null;
public static StringResource[] Data = null;
static int DataType = 0;
static int lastProgressValue = 0;
public static void ReadFile(string filePath)
{
string fileName = Path.GetFileNameWithoutExtension(filePath).ToLower();
using (BackgroundWorker loadWorker = new BackgroundWorker())
{
loadWorker.DoWork += (o, x) =>
{
FileLoadTimer.Start();
byte[] fieldBuffer = new byte[0];
int curRow = 0;
RawBytes = File.ReadAllBytes(filePath);
using (var ms = new MemoryStream(RawBytes))
{
FileHeader = new Header();
fieldBuffer = new byte[27];
ms.Read(fieldBuffer, 0, fieldBuffer.Length);
FileHeader.HeaderBytes = fieldBuffer;
ms.Position += 101;
fieldBuffer = new byte[4];
ms.Read(fieldBuffer, 0, 4);
FileHeader.FileRows = BitConverter.ToInt32(fieldBuffer, 0);
Data = new StringResource[FileHeader.FileRows];
loadWorker.ReportProgress(0);
int nameLen, valueLen;
while (true)
{
if (curRow == FileHeader.FileRows) { break; }
fieldBuffer = new byte[4];
ms.Read(fieldBuffer, 0, 4);
nameLen = BitConverter.ToInt32(fieldBuffer, 0);
fieldBuffer = new byte[4];
ms.Read(fieldBuffer, 0, 4);
valueLen = BitConverter.ToInt32(fieldBuffer, 0);
fieldBuffer = new byte[nameLen];
ms.Read(fieldBuffer, 0, fieldBuffer.Length);
Data[curRow].name = Encoding.Default.GetString(fieldBuffer);
fieldBuffer = new byte[valueLen];
ms.Read(fieldBuffer, 0, fieldBuffer.Length);
Data[curRow].value = Encoding.Default.GetString(fieldBuffer);
fieldBuffer = new byte[4];
ms.Read(fieldBuffer, 0, 4);
Data[curRow].code = BitConverter.ToInt32(fieldBuffer, 0);
fieldBuffer = new byte[4];
ms.Read(fieldBuffer, 0, 4);
Data[curRow].group_id = BitConverter.ToInt32(fieldBuffer, 0);
ms.Position += 16;
if (Math.Abs(curRow - lastProgressValue) > 2500) { loadWorker.ReportProgress(curRow); lastProgressValue = curRow; }
else if ((curRow + 1) == FileHeader.FileRows) { loadWorker.ReportProgress(curRow); lastProgressValue = curRow; }
curRow++;
}
}
};
loadWorker.WorkerReportsProgress = true;
loadWorker.ProgressChanged += (o, x) =>
{
if (x.ProgressPercentage == 0) { MainWindow_Instance.Progress.Maximum = FileHeader.FileRows; }
else { MainWindow_Instance.Progress.Value = x.ProgressPercentage; }
};
loadWorker.RunWorkerCompleted += (o, x) =>
{
FileLoadTimer.Stop();
MainWindow_Instance.Status.Text = string.Format("{0} Rows Loaded from {1} in: {2} ms", FileHeader.FileRows, fileName, FileLoadTimer.ElapsedMilliseconds);
GenerateTab(fileName);
};
MainWindow_Instance.Status.Text = string.Format("Loading: {0}", fileName);
loadWorker.RunWorkerAsync();
}
}
public static void ReadDB()
{
string connectionString = Settings.ConnectionString;
string selectStatement = "SELECT ";
int selectStatement_idx = 0;
PropertyInfo[] properties = typeof(StringResource).GetProperties();
foreach (PropertyInfo property in properties)
{
if (selectStatement_idx == properties.Length - 1) { selectStatement += string.Format("[{0}] ", property.Name); }
else { selectStatement += string.Format("[{0}], ", property.Name); }
selectStatement_idx++;
}
selectStatement += "FROM dbo.StringResource";
int rowCount = 0;
int curRow = 0;
using (BackgroundWorker loadWorker = new BackgroundWorker())
{
loadWorker.DoWork += (o, x) =>
{
FileLoadTimer = new Stopwatch();
FileLoadTimer.Start();
SqlConnection sqlCon = new SqlConnection(Settings.ConnectionString);
SqlCommand sqlCmd = new SqlCommand("SELECT COUNT(code) FROM dbo.StringResource", sqlCon);
SqlDataReader sqlRdr = null;
try
{
sqlCon.Open();
rowCount = (int)sqlCmd.ExecuteScalar();
Data = new StringResource[rowCount];
DataType = 1;
MainWindow_Instance.InitProgress(0, rowCount);
if (rowCount > 0)
{
sqlCmd = new SqlCommand(selectStatement, sqlCon);
sqlRdr = sqlCmd.ExecuteReader();
while (sqlRdr.Read())
{
Data[curRow].name = Convert.ToString(sqlRdr[0]);
Data[curRow].group_id = Convert.ToInt32(sqlRdr[1]);
Data[curRow].code = Convert.ToInt32(sqlRdr[2]);
Data[curRow].value = Convert.ToString(sqlRdr[3]);
curRow++;
if (Math.Abs(curRow - lastProgressValue) > 100) { loadWorker.ReportProgress(curRow); lastProgressValue = curRow; }
else if ((curRow + 1) == rowCount) { loadWorker.ReportProgress(curRow); lastProgressValue = curRow; }
}
}
}
catch (SqlException sqlEx)
{
MessageBox.Show(sqlEx.Message, "SQL Exception Occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception Occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
sqlCon.Close();
}
};
loadWorker.WorkerReportsProgress = true;
loadWorker.ProgressChanged += (o, x) =>
{
MainWindow_Instance.Progress.Value = x.ProgressPercentage;
};
loadWorker.RunWorkerCompleted += (o, x) =>
{
FileLoadTimer.Stop();
MainWindow_Instance.Status.Text = string.Format("{0} Rows loaded from {1} in: {2} ms", Data.Length, "db_string", FileLoadTimer.ElapsedMilliseconds);
GenerateTab("db_string");
};
loadWorker.RunWorkerAsync();
}
}
public static void SaveData()
{
string rdbName = "db_string";
string saveDir = Properties.Settings.Default.outputDirectory;
string saveName = rdbName;
if (Properties.Settings.Default.appendAscii) { saveName += "(ascii).rdb"; }
else { saveName += ".rdb"; }
if (Properties.Settings.Default.saveHashed) { saveName = FileNameCipher.Encode(saveName); }
string savePath = Path.Combine(saveDir, saveName);
if (!Directory.Exists(saveDir))
{
Directory.CreateDirectory(saveDir);
}
try
{
using (BackgroundWorker saveWorker = new BackgroundWorker())
{
saveWorker.DoWork += (o, x) =>
{
FileLoadTimer = new Stopwatch();
FileLoadTimer.Start();
using (BinaryWriter bw = new BinaryWriter(File.Create(savePath)))
{
if (DataType != 0)
{
FileHeader = new Header();
FileHeader.HeaderBytes = new byte[128];
FileHeader.FileRows = Data.Length;
}
byte[] HeaderBytes = Encoding.Default.GetBytes("Teal.Sky.Project.2015.rEDIT");
bw.Write(HeaderBytes);
bw.Write(new byte[128 - HeaderBytes.Length]);
bw.Write(FileHeader.FileRows);
for (int curRow = 0; curRow < FileHeader.FileRows; curRow++)
{
bw.Write(Convert.ToInt32(Data[curRow].name.Length));
bw.Write(Convert.ToInt32(Data[curRow].value.Length));
bw.Write(Encoding.Default.GetBytes(Data[curRow].name));
bw.Write(Encoding.Default.GetBytes(Data[curRow].value));
bw.Write(Data[curRow].code);
bw.Write(Data[curRow].group_id);
bw.Write(new byte[16]);
if (Math.Abs(curRow - lastProgressValue) > 2500) { saveWorker.ReportProgress(curRow); lastProgressValue = curRow; }
else if ((curRow + 1) == FileHeader.FileRows) { saveWorker.ReportProgress(curRow); lastProgressValue = curRow; }
}
}
};
saveWorker.WorkerReportsProgress = true;
saveWorker.ProgressChanged += (o, x) =>
{
if (x.ProgressPercentage == 0) { MainWindow_Instance.Progress.Maximum = FileHeader.FileRows; }
else { MainWindow_Instance.Progress.Value = x.ProgressPercentage; }
};
saveWorker.RunWorkerCompleted += (o, x) =>
{
FileLoadTimer.Stop();
MainWindow_Instance.Status.Text = string.Format("{0} Rows saved to {1} in: {2} ms", Data.Length, saveName, FileLoadTimer.ElapsedMilliseconds);
};
saveWorker.RunWorkerAsync();
}
}
catch (Exception ex)
{
}
}
public static void GenerateTab(string title)
{
if (MainWindow_Instance.TabControl.TabPages[title] == null)
{
TabPage newPage = new TabPage
{
Name = title,
Text = title
};
MainWindow_Instance.TabControl.TabPages.Add(newPage);
MainWindow_Instance.TabControl.TabPages[title].Controls.Add(new DataGridView { Name = string.Format("{0}_dgv", title), Dock = DockStyle.Fill });
DataGridView tmpDGV = MainWindow_Instance.TabControl.TabPages[title].Controls[string.Format("{0}_dgv", title)] as DataGridView;
tmpDGV.DataSource = Data;
}
}
public static void ClearAssets()
{
FileHeader = null;
Data = null;
DataType = 0;
lastProgressValue = 0;
}
}
StringResource structure class
Code:
public struct StringResource
{
public String name { get; set; }
public Int32 group_id { get; set; }
public Int32 code { get; set; }
public String value { get; set; }
}
p.s. you may have to remove some calls to the gui (MainWindow) and next time use help thread
How to read bin/dat files? 05/27/2012 - Florensia - 0 Replies hey guys,
because the bin/dat converter is offline, does anyone have any idea how I'm able to read florensia bin/dat files?
I guess it's binary data but how it is encoded?
thanks!
read this for who got the vsro files 09/04/2011 - SRO Private Server - 11 Replies well watch this :
Comet Elenin, Nibiru, Pole Shift, 2011 - YouTube
they can enjoy on that money only untill 16 september / 11 octomber , neah for me that thing is not a reliable true thing but I'm making fun of who get these files =))
so folks , release them fast if you want to be famous untill comete elenin come
I'm just making fun so for retarded people stay away from this topic ;)
[Question] How to read .dll files? 01/14/2011 - S4 League - 2 Replies Ohh gosh i really failed... Im sorry ^´´^ you can close this thread i found a solution to join the file again. Sorry if i made you lost time :$ :/
Do not read the problem x_x
Well, i downloaded a .dll few time ago, accidentaly i opened it with NotePad -.-
Now, it cannot be injected... i downloaded it 3 times again, but when i unzip it, this still has the NotePad sign.
Please, help how can i stop it?
[READ] Scanning Files 05/07/2009 - Soldier Front - 1 Replies There are more and more threads being posted here everyday of files which could be .exe's or .rar's before you do anything with them or execute them. I advise you to scan them first and send the scan to the thread to alert others if it is bad
VirusTotal - Free Online Virus and Malware Scan
Use the site I have posted above, it is very useful.
NOTE: IF YOU GET A BAD SCAN PLEASE "REPORT" THE THREAD, SO I CAN CLOSE IT
help read this (real TQ files) 01/09/2009 - CO2 Private Server - 2 Replies heey im furax
does somone know what client you need to have for the real TQ files
and what patch.
if you can help me send an mail or add me on msn [email protected]
or send an replay