本文整理汇总了C#中X360.IO.DJsIO.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DJsIO.Dispose方法的具体用法?C# DJsIO.Dispose怎么用?C# DJsIO.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X360.IO.DJsIO
的用法示例。
在下文中一共展示了DJsIO.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addFileToolStripMenuItem_Click
private void addFileToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
ofd.Title = "Open Xbox Live Packages";
ofd.Filter = "";
if (ofd.ShowDialog() != DialogResult.OK)
return;
menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false;
progressBarX1.Value = 0;
progressBarX1.Maximum = ofd.FileNames.Length;
foreach (string x in ofd.FileNames)
{
DJsIO y = null;
try { y = new DJsIO(x, DJFileMode.Open, true); }
catch { progressBarX1.Value++; continue; }
if (!y.Accessed)
{
progressBarX1.Value++;
continue;
}
y.Position = 0;
if (y.ReadUInt32() == (uint)AllMagic.CON)
listBox1.Items.Add(x);
y.Dispose();
if (checkBoxX3.Checked)
fix(listBox1.Items.Count - 1);
progressBarX1.Value++;
}
menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true;
}
示例2: IsFATX
/// <summary>
/// Determins if a Drive is FATX format
/// </summary>
/// <param name="xIO">Stream to check</param>
/// <param name="xType">Grabs the type of drive</param>
/// <returns></returns>
public static bool IsFATX(ref DJsIO xIO, out DriveTypes xType)
{
// Tries to read the offsets of Xbox 360 drives to see if the magic's match
xType = DriveTypes.Unknown;
try
{
if (xIO.IOType != DataType.Drive || ((DriveIO)xIO).xDrive.Type != DeviceType.LogicalDrive)
throw new Exception();
string dat0 = ((DriveIO)xIO).xDrive.DeviceName + @"\Xbox360\Data0000";
if (!File.Exists(dat0))
throw new Exception();
var fa = File.GetAttributes(dat0);
if ((fa & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
return false;
}
DJsIO xio = new DJsIO(dat0, DJFileMode.Open, true);
if (!xio.Accessed)
throw new Exception();
xio.Position = (long)USB.Partition1;
try
{
if (xio.ReadUInt32() == (uint)AllMagic.FATX)
{
xType = DriveTypes.USBFlashDrive;
xio.Dispose();
return true;
}
}
catch { }
xio.Dispose();
}
catch { }
try
{
xIO.Position = (long)MU.Partition2;
if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
{
xType = DriveTypes.MemoryUnit;
return true;
}
}
catch { }
try
{
xIO.Position = (long)HDD.Partition5;
if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
{
xType = DriveTypes.HardDrive;
return true;
}
}
catch { }
try
{
xIO.Position = 8;
xIO.Position = (xIO.ReadUInt32() * 0x200);
if (xIO.ReadUInt32() == (uint)AllMagic.FATX)
{
xType = DriveTypes.DevHardDrive;
return true;
}
}
catch { }
return false;
}
示例3: MusicFile
/// <summary>
/// Initializes this object
/// </summary>
/// <param name="FileLocale"></param>
public MusicFile(string FileLocale)
{
xActive = true;
DJsIO xIO = new DJsIO(FileLocale, DJFileMode.Open, true);
if (!xIO.Accessed)
throw STFSExcepts.ParseError;
try
{
xIO.Position = 0;
xIO.IsBigEndian = true;
if (xIO.ReadUInt32() != 0x464D494D)
throw MusicExcepts.NotMusic;
xIO.Position = 0xC;
so = xIO.ReadString(StringForm.Unicode, 0x100);
al = xIO.ReadString(StringForm.Unicode, 0x100);
ar = xIO.ReadString(StringForm.Unicode, 0x100);
xIO.Position += 0x200;
ge = xIO.ReadString(StringForm.Unicode, 0x100);
IO = xIO;
xActive = false;
}
catch { xIO.Dispose(); throw STFSExcepts.ParseError; }
}
示例4: listBox1_DragDrop
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = false;
string[] xfiles = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string x in xfiles)
{
DJsIO y = null;
try { y = new DJsIO(x, DJFileMode.Open, true); }
catch { continue; }
if (!y.Accessed)
continue;
y.Position = 0;
if (y.ReadUInt32() == (uint)AllMagic.CON)
listBox1.Items.Add(x);
y.Dispose();
listBox1.SelectedIndex = listBox1.Items.Count - 1;
Application.DoEvents();
if (checkBoxX3.Checked)
fix(listBox1.Items.Count - 1);
}
menuStrip1.Enabled = groupPanel1.Enabled = listBox1.Enabled = true;
}
示例5: xEncrypt
bool xEncrypt(ref DJsIO xNewPayload)
{
try
{
if (!xSuccess)
return false;
if (xIsLive)
{
byte[] xService = (ThisType == AccountType.Stock ?
new byte[] { 0x50, 0x52, 0x4F, 0x44 } : // PROD
new byte[] { 0x50, 0x41, 0x53, 0x54 }); // PART
xNewPayload.Position = 0x34;
xNewPayload.Write(xService);
xNewPayload.Flush();
}
List<byte> xReturn = new List<byte>();
byte[] xConfounder = xRC4.NewConfounder(8);
byte[] NewPay = xNewPayload.ReadStream();
xNewPayload.Dispose();
byte[] xHeaderKey = xComputeHeaderKey(xConfounder, NewPay);
xRC4.KeyBinary = xComputeRC4Key(xHeaderKey);
xReturn.AddRange(xHeaderKey);
xReturn.AddRange(xRC4.KerberosEncrypt(ref xConfounder, ref NewPay));
IO.Position = 0;
IO.Write(xReturn.ToArray());
IO.Flush();
return true;
}
catch { return false; }
}
示例6: Inject
/// <summary>
/// Overwrite the file
/// </summary>
/// <param name="FileLocale"></param>
/// <returns></returns>
public bool Inject(string FileLocale)
{
if (!xref.ActiveCheck())
return false;
DJsIO xIO = null;
bool success = false;
try
{
xIO = new DJsIO(FileLocale, DJFileMode.Open, true);
if (!xIO.Accessed)
throw new Exception();
success = xInject(xIO);
}
catch { success = false; }
if (xIO != null)
xIO.Dispose();
return (success & !(xref.xActive = false));
}
示例7: Replace
/// <summary>
/// Replace the file via File Location
/// </summary>
/// <param name="FileIn"></param>
/// <returns></returns>
public bool Replace(string FileIn)
{
DJsIO xIO = null;
try
{
xIO = new DJsIO(FileIn, DJFileMode.Open, true);
bool Success = Replace(xIO);
xIO.Dispose();
return Success;
}
catch
{
if (xIO != null)
xIO.Dispose();
return xPackage.xActive = false;
}
}
示例8: KerberosDecrypt
/// <summary>
/// Runs a Kerberos implemented RC4 decryption
/// </summary>
/// <param name="xConfounder">The confounder input</param>
/// <param name="xPayload">The payload input</param>
/// <param name="x">RC4 reference</param>
/// <param name="xData">Data to be decrypted</param>
/// <param name="xConLen">Length of the Confounder</param>
/// <returns></returns>
public static bool KerberosDecrypt(this RC4 x, byte[] xData, out byte[] xConfounder, int xConLen, out byte[] xPayload)
{
xPayload = new byte[0];
xConfounder = new byte[0];
try
{
DJsIO xOut = new DJsIO(x.RunAlgorithm(xData), true);
xOut.Position = 0;
xConfounder = xOut.ReadBytes(xConLen);
xPayload = xOut.ReadBytes(xData.Length - xConLen);
xOut.Dispose();
}
catch { return false; }
return true;
}
示例9: IncreaseXDBFCount
internal bool IncreaseXDBFCount()
{
DJsIO xtemp = new DJsIO(true);
try
{
xtemp.Position = (HeaderSize + (0xFF * 0x12));
xIO.Position = HeaderSize;
int len = (int)(xIO.Length - xIO.Position);
for (int i = 0; i < len; i++)
xtemp.Write(xIO.ReadByte());
xtemp.Position = 0;
xtemp.Write((uint)AllMagic.XDBF);
xtemp.Write((int)0x10000);
xEntryMax += 0xFF;
xtemp.Write((int)xEntryMax);
xtemp.Write((int)xEntryCurrent);
xtemp.Write((int)xFreeCurrent);
xtemp.Write((int)xFreeMax);
List<XDBFEntry> xEntries = GetEntries();
foreach (XDBFEntry x in xEntries)
{
xtemp.Write((ushort)x.NS);
xtemp.Write(x.ID);
xtemp.Write(x.xOffset);
xtemp.Write(x.Size);
}
xtemp.Write(new byte[0x12 * (xEntryMax - xEntries.Count)]);
foreach (FreeSpaceEntry x in xFreeEnts)
{
if (x.Size != 0)
{
xtemp.Write(x.offset);
xtemp.Write(x.Size);
}
}
int xdatasize = (int)(xtemp.Length - HeaderSize);
xtemp.Write(xdatasize);
xtemp.Write((int)(((-1) - xdatasize)));
xtemp.Write(new byte[0x8 * (xFreeMax - (xFreeEnts.Count + 1))]);
xtemp.Flush();
xtemp.Close();
xIO.Close();
VariousFunctions.MoveFile(xtemp.FileNameLong, xIO.FileNameLong);
xIO = new DJsIO(xIO.FileNameLong, DJFileMode.Open, true);
return true;
}
catch { xtemp.Dispose(true); return false; }
}
示例10: STFSPackage
//.........这里部分代码省略.........
x2.Write("AvatarLightingAmbient=0x" + xSession.ThemeSettings.AvatarLightingAmbient.ToString("X"));
x2.Write(new byte[] { 0xD, 0xA });
x2.Flush();
x2.Close();
if (!xSession.AddFile(x2.FileNameLong, "parameters.ini"))
throw STFSExcepts.ThemeError;
}
else if (xSession.HeaderData.ThisType == PackageType.GamesOnDemand ||
xSession.HeaderData.ThisType == PackageType.HDDInstalledGame ||
xSession.HeaderData.ThisType == PackageType.OriginalXboxGame ||
xSession.HeaderData.ThisType == PackageType.SocialTitle)
throw STFSExcepts.Game;
xLog = LogIn;
xHeader = xSession.HeaderData;
xSTFSStruct = new STFSDescriptor(xSession.STFSType, 0);
xIO = new DJsIO(true);
List<BlockRecord> DirectoryBlockz = new List<BlockRecord>();
// switched2 = true;
uint xcurblock = 0;
for (ushort i = 0; i < xSession.GetDirectoryCount; i++)
{
DirectoryBlockz.Add(new BlockRecord());
DirectoryBlockz[DirectoryBlockz.Count - 1].ThisBlock = xcurblock++;
/*if (!switched0.Contains((int)(xcurblock / Constants.BlockLevel[0])))
switched0.Add((int)(xcurblock / Constants.BlockLevel[0]));
if (!switched1.Contains((int)(xcurblock / Constants.BlockLevel[1])))
switched1.Add((int)(xcurblock / Constants.BlockLevel[1]));*/
}
xFileBlocks = DirectoryBlockz.ToArray();
xWriteChain(xFileBlocks);
xSTFSStruct.xDirectoryBlockCount = (ushort)xFileBlocks.Length;
ushort xCurID = 0;
xSession.xFolderDirectory.Sort(new Comparison<CFolderEntry>(sortpathct));
foreach (CFolderEntry x in xSession.xFolderDirectory)
{
ushort pointer = 0xFFFF;
if (x.xthispath.xPathCount() > 1)
pointer = xGetParentFolder(x.Path).EntryID;
xFolderDirectory.Add(new FolderEntry(x.Name, 0, xCurID++, pointer, this));
xFolderDirectory[xFolderDirectory.Count - 1].xFixOffset();
}
foreach (CFileEntry x in xSession.xFileDirectory)
{
ushort pointer = 0xFFFF;
if (x.xthispath.xPathCount() > 1)
pointer = xGetParentFolder(x.Path).EntryID;
xFileDirectory.Add(new FileEntry(x.Name, (int)x.GetLength(), false,xCurID++, pointer, this));
List<BlockRecord> xAlloc = new List<BlockRecord>();
for (uint i = 0; i < x.BlockCount(); i++)
{
xAlloc.Add(new BlockRecord());
xAlloc[xAlloc.Count - 1].ThisBlock = xcurblock++;
/*if (!switched0.Contains((int)(xcurblock / Constants.BlockLevel[0])))
switched0.Add((int)(xcurblock / Constants.BlockLevel[0]));
if (!switched1.Contains((int)(xcurblock / Constants.BlockLevel[1])))
switched1.Add((int)(xcurblock / Constants.BlockLevel[1]));*/
}
xFileDirectory[xFileDirectory.Count - 1].xBlockCount = (uint)xAlloc.Count;
xFileDirectory[xFileDirectory.Count - 1].xStartBlock = xAlloc[0].ThisBlock;
xFileDirectory[xFileDirectory.Count - 1].xPackage = this;
xFileDirectory[xFileDirectory.Count - 1].xFixOffset();
xWriteChain(xAlloc.ToArray());
}
AddToLog("Writing Entry Table");
DJsIO xent;
if (!xEntriesToFile(out xent))
throw new Exception();
xWriteTo(ref xent, xFileBlocks);
xent.Close();
VariousFunctions.DeleteFile(xent.FileNameLong);
AddToLog("Writing Files");
uint curblck = xSession.GetDirectoryCount;
foreach (CFileEntry z in xSession.xFileDirectory)
{
List<BlockRecord> w = new List<BlockRecord>();
uint ct = z.BlockCount();
for (uint y = 0; y < ct; y++)
{
w.Add(new BlockRecord());
w[w.Count - 1].ThisBlock = curblck++;
}
DJsIO x = null;
try
{
x = new DJsIO(z.FileLocale, DJFileMode.Open, true);
xWriteTo(ref x, w.ToArray());
}
catch { }
if (x != null)
x.Dispose();
}
xWriteTables();
xWriteHeader(xSigning);
xIO.Close();
VariousFunctions.MoveFile(xIO.FileNameLong, xOutPath);
xIO = new DJsIO(xOutPath, DJFileMode.Open, true);
xActive = false;
}
catch (Exception x) { xFileDirectory = null; xFolderDirectory = null; xIO.Dispose(); throw x; }
}
示例11: Inject
/// <summary>
/// Overwrites the data from a file location
/// </summary>
/// <param name="FileIn"></param>
/// <returns></returns>
public bool Inject(string FileIn)
{
DJsIO xIO = null;
//try
{
xIO = new DJsIO(FileIn, DJFileMode.Open, true);
bool Success = Inject(xIO);
xIO.Dispose();
return Success;
}
//catch
//{
// if (xIO != null)
// xIO.Dispose();
//return xPackage.xActive = false;
//}
}
示例12: STFSPackage
//.........这里部分代码省略.........
throw CryptoExcepts.ParamError;
if (xSession.xFileDirectory.Count == 0)
throw new Exception();
////try
{
//AddToLog("Setting Package variables");
xroot = new FolderEntry("", 0, 0xFFFF, 0xFFFF, this);
if (xSession.HeaderData.ThisType == PackageType.GamesOnDemand ||
xSession.HeaderData.ThisType == PackageType.HDDInstalledGame ||
xSession.HeaderData.ThisType == PackageType.OriginalXboxGame ||
xSession.HeaderData.ThisType == PackageType.SocialTitle)
throw STFSExcepts.Game;
xLog = LogIn;
xHeader = xSession.HeaderData;
xSTFSStruct = new STFSDescriptor(xSession.STFSType, 0);
xIO = new DJsIO();
var DirectoryBlockz = new List<BlockRecord>();
// switched2 = true;
uint xcurblock = 0;
for (ushort i = 0; i < xSession.GetDirectoryCount; i++)
{
DirectoryBlockz.Add(new BlockRecord());
DirectoryBlockz[DirectoryBlockz.Count - 1].ThisBlock = xcurblock++;
}
xFileBlocks = DirectoryBlockz.ToArray();
xWriteChain(xFileBlocks);
xSTFSStruct.xDirectoryBlockCount = (ushort)xFileBlocks.Length;
ushort xCurID = 0;
xSession.xFolderDirectory.Sort(new Comparison<CFolderEntry>(sortpathct));
foreach (var x in xSession.xFolderDirectory)
{
ushort pointer = 0xFFFF;
if (x.xthispath.xPathCount() > 1)
pointer = xGetParentFolder(x.Path).EntryID;
xFolderDirectory.Add(new FolderEntry(x.Name, 0, xCurID++, pointer, this));
xFolderDirectory[xFolderDirectory.Count - 1].xFixOffset();
}
foreach (CFileEntry x in xSession.xFileDirectory)
{
ushort pointer = 0xFFFF;
if (x.xthispath.xPathCount() > 1)
pointer = xGetParentFolder(x.Path).EntryID;
xFileDirectory.Add(new FileEntry(x.Name,
(int)x.GetLength(), false, xCurID++, pointer, this));
var xAlloc = new List<BlockRecord>();
for (uint i = 0; i < x.BlockCount(); i++)
{
xAlloc.Add(new BlockRecord());
xAlloc[xAlloc.Count - 1].ThisBlock = xcurblock++;
}
xFileDirectory[xFileDirectory.Count - 1].xBlockCount = (uint)xAlloc.Count;
xFileDirectory[xFileDirectory.Count - 1].xStartBlock = xAlloc[0].ThisBlock;
xFileDirectory[xFileDirectory.Count - 1].xPackage = this;
xFileDirectory[xFileDirectory.Count - 1].xFixOffset();
xWriteChain(xAlloc.ToArray());
}
//AddToLog("Writing Entry Table");
DJsIO xent;
if (!xEntriesToFile(out xent))
throw new Exception();
xWriteTo(ref xent, xFileBlocks);
xent.Close();
//VariousFunctions.DeleteFile(xent.FileNameLong);
//AddToLog("Writing Files");
uint curblck = xSession.GetDirectoryCount;
foreach (var z in xSession.xFileDirectory)
{
var w = new List<BlockRecord>();
uint ct = z.BlockCount();
for (uint y = 0; y < ct; y++)
{
w.Add(new BlockRecord());
w[w.Count - 1].ThisBlock = curblck++;
}
DJsIO x = null;
//try
{
x = new DJsIO(z.FileData, true);
xWriteTo(ref x, w.ToArray());
}
//catch { }
if (x != null)
x.Dispose();
}
xWriteTables();
xWriteHeader(xSigning);
ret = xIO.GetBytes();
xIO.Close();
//VariousFunctions.MoveFile(xIO.FileNameLong, xOutPath);
xActive = false;
}
////catch (Exception x) { xFileDirectory = null; xFolderDirectory = null; xIO.Dispose(); throw x; }
}
示例13: xWriteHeader
bool xWriteHeader(RSAParams xParams)
{
try
{
DJsIO xio = new DJsIO(true);
xHeaderData.Write(ref xio);
xio.SetLength(0xB000);
xio.Position = 0x340;
xio.Write((uint)0xAD0E);
xio.Position = 0x379;
xio.Write(new byte[] { 0x24, 5, 5, 0x11 });
IO.Position = 0x37D;
xio.Write(IO.ReadBytes(20));
xio.Write((byte)((xIsShifted ? 1 : 0) << 6));
xio.WriteUInt24(xBlockCount);
xio.Write(xDeviation);
xio.Flush();
xio.Position = 0x344;
byte[] xHash = SHA1Quick.ComputeHash(xio.ReadBytes((int)(xio.Length - 0x344)));
xio.Position = 0x32C;
xio.Write(xHash);
xio.Flush();
xio.Position = 0x22C;
xHash = SHA1Quick.ComputeHash(xio.ReadBytes(0x118));
xio.Position = 4;
if (xParams.Type == PackageMagic.CON)
{
xio.Write(xParams.Certificate);
xio.Write(ScrambleMethods.StockScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash), true));
}
else
{
xio.Write(ScrambleMethods.DevScramble(RSAQuick.SignatureGenerate(xParams.RSAKeys, xHash)));
xio.Write(new byte[0x128]);
}
xio.IsBigEndian = true;
xio.Position = 0;
xio.Write(((uint)xParams.Type));
xio.Flush();
xHeaderData.xMagic = xParams.Type;
IO.Position = 0;
IO.Write(xio.ReadStream());
IO.Flush();
xio.Dispose();
return true;
}
catch { return false; }
}
示例14: ExtractImage
/// <summary>
/// Extracts the image via a file location
/// </summary>
/// <param name="fileOut"></param>
/// <returns></returns>
public bool ExtractImage(string fileOut)
{
if (ActiveCheck())
return false;
DJsIO xIOOut = null;
try { xIOOut = new DJsIO(fileOut, DJFileMode.Create, true); }
catch { return xactive = false; }
if (!xIOOut.Accessed)
return xactive = false;
bool result = extractimg(xIOOut);
xIOOut.Dispose();
return result;
}
示例15: xExtractPayload
/// <summary>
/// Extracts via out locale
/// </summary>
/// <param name="xOutLocale"></param>
/// <param name="xIncludeSubItems"></param>
/// <param name="xIncludeHeader"></param>
/// <returns></returns>
bool xExtractPayload(string xOutLocale, bool xIncludeSubItems, bool xIncludeHeader)
{
try
{
AddToLog("Checking Directory");
xOutLocale.Replace("\\", "/");
if (xOutLocale[xOutLocale.Length - 1] == '/')
xOutLocale = xOutLocale.Substring(0, xOutLocale.Length - 1);
if (!VariousFunctions.xCheckDirectory(xOutLocale))
{
AddToLog("Directory error");
return false;
}
if (xIncludeHeader)
{
// Records the meta data
AddToLog("Noting Header Information");
DJsIO xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/" + dlcname() + ".txt")
, DJFileMode.Create, true);
xHeader.WriteText(ref xhead);
xhead.Dispose();
xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/Content Image.png")
, DJFileMode.Create, true);
xhead.Position = 0;
xhead.Write(xHeader.ContentImageBinary);
xhead.Dispose();
xhead = new DJsIO(VariousFunctions.xGetUnusedFile(xOutLocale + "/Package Image.png")
, DJFileMode.Create, true);
xhead.Position = 0;
xhead.Write(xHeader.PackageImageBinary);
xhead.Dispose();
}
xOutLocale += "/Root";
if (!VariousFunctions.xCheckDirectory(xOutLocale))
return (xActive = false);
// Runs a regular folder extract
AddToLog("Extracting payload");
RootDirectory.folderextract(xIncludeSubItems, xOutLocale);
AddToLog("Package Extracted");
return !(xActive = false);
}
catch { return (xActive = false); }
}