August 23rd, 2012, 14:35
August 23rd, 2012, 15:08
August 23rd, 2012, 15:26
August 23rd, 2012, 15:34
August 23rd, 2012, 15:42
namespace GetID
{
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
internal class Program
{
private static byte[] _RoylCode = Encoding.ASCII.GetBytes("ROYL");
private static void FindIdInFile(string path)
{
long num;
string str;
if (FindIdInFile(path, out num, out str))
{
Console.WriteLine(string.Concat(new object[] { "Found ID at offset ", num, " [0x", num.ToString("X"), "]: ", str }));
}
else
{
Console.WriteLine("ID not found!");
}
}
private static bool FindIdInFile(string path, out long offset, out string id)
{
using (FileStream stream = File.OpenRead(path))
{
while (stream.CanRead)
{
if (((stream.ReadByte() == _RoylCode[0]) && (stream.ReadByte() == _RoylCode[1])) && ((stream.ReadByte() == _RoylCode[2]) && (stream.ReadByte() == _RoylCode[3])))
{
offset = stream.Seek(12L, SeekOrigin.Current);
byte[] buffer = new byte[8];
if (stream.Read(buffer, 0, 8) == 8)
{
id = Encoding.ASCII.GetString(buffer);
return true;
}
}
}
offset = -1L;
id = null;
return false;
}
}
private static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("No file path specified.");
Environment.ExitCode = -1;
}
else
{
string path = args[0];
if (path.StartsWith("\"") && path.EndsWith("\""))
{
path = path.Substring(1, path.Length - 2);
}
if (!File.Exists(path))
{
Console.WriteLine("'" + args[0] + "' is not a valid file path.");
Environment.ExitCode = -1;
}
else
{
FindIdInFile(args[0]);
}
}
}
}
}
August 23rd, 2012, 15:43
August 23rd, 2012, 15:44
einstein9 wrote:not bad idea i guess?
August 23rd, 2012, 15:51
August 23rd, 2012, 15:59
heheheh (this is the intro.. - just kidding)
heheheh (this is the end.. - just kidding)
August 23rd, 2012, 16:02
August 23rd, 2012, 16:03
August 23rd, 2012, 16:04
August 23rd, 2012, 16:08
August 23rd, 2012, 16:17
August 23rd, 2012, 18:18
einstein9 wrote:did u find this useful as an idea? or not?
November 3rd, 2012, 5:53
Powered by phpBB © phpBB Group.