/// <summary> /// Disassembles the given managed .Net assembly (dll or exe) into an array of strings /// of intermediate language (IL) code.</summary> /// <param name="assembly">fully qualified path of the assembly file</param> /// <returns>an array of strings for each line of the intermediate language version</returns> public static string[] Disassemble(string assembly) { string[] ilLines = new string[0]; // Determine the temporary directory (in case there are many resource files) and temporary file name. string assemblyDir = Path.GetDirectoryName(assembly); string tempDir = Path.Combine(assemblyDir, "TempDisassemblerFiles"); string ilPath = Path.Combine(tempDir, "output.il"); Directory.CreateDirectory(tempDir); try { // Run the disassembler, create a temporary *.il file, read it in. string disassembler = GetDisassemblerPath(); string arguments = string.Format("\"{0}\" /output=\"{1}\"", assembly, ilPath); Process process = Process.Start(disassembler, arguments); process.WaitForExit(); ilLines = File.ReadAllLines(ilPath); } finally { PathUtilities.DeleteDirectory(tempDir); } return(ilLines); }
/// <summary> /// Gets the path for the root directory of the ATF installation, ending with a '\'. For example: /// "C:\sceadev\wws_shared\sdk\trunk\components\wws_atf\"</summary> /// <returns></returns> public static string GetAtfRoot() { string dir = Directory.GetCurrentDirectory(); string[] dirElements = PathUtilities.GetPathElements(dir); int atfIndex = dirElements.Length - 1; for (; atfIndex >= 0; atfIndex--) { if (dirElements[atfIndex].ToLower().Contains("atf")) { break; } } if (atfIndex < 0) { throw new InvalidOperationException("Could not find root of ATF installation, like 'wws_atf'"); } return(PathUtilities.CreatePath(dirElements, 0, atfIndex, true)); }