/// <summary> /// Generate corresponding XML code. /// </summary> protected override string GenerateStringCode(string inputFileContent) { try { BinaryFile file = new WindowsPortableExecutable(); WindowsPortableExecutableLoadArgs args = new WindowsPortableExecutableLoadArgs(false); XmlDocumentWrapper xml; XmlNode mainNode; bool[] externalParams; args.LoadImports = true; args.LoadExports = true; // load the file: file.Load(InputFilePath, args); // check integrity: if (file.Count < 2) { return(string.Format(CoffComments.InvalidContent, InputFilePath)); } // create output XML document: xml = new XmlDocumentWrapper(); xml.DeclareDocument(); xml.Append(mainNode = DefineMainElement(xml)); // interprete extenal parameters: InterpreteArguments((string.IsNullOrEmpty(FileNamespace.Trim()) ? null : FileNamespace.Split(';')), out externalParams); // serialize proper sections: if (externalParams == null || externalParams.Length <= 1 || externalParams[1]) { AppendSection(xml, mainNode, file[ExportFunctionSection.DefaultName] as ExportFunctionSection); } if (externalParams == null || externalParams.Length <= 2 || externalParams[2]) { AppendSection(xml, mainNode, file[ImportFunctionSection.DefaultName] as ImportFunctionSection); } // and return data as a string: return(XmlHelper.ToString(xml, true)); } catch (Exception ex) { return(string.Format(CoffComments.InvalidOperation, InputFilePath, ex.Message)); } }
public void LoadDLL_NanoStorm() { BinaryFile file = new WindowsPortableExecutable(); BinaryLoadArgs arg = new WindowsPortableExecutableLoadArgs(true); file.Load("NanoStorm.exe", arg); // dump all data: DumpSections(file); DumpExportSection(file); DumpImportSection(file); // validate: Assert.IsNotNull(file.Sections); ValidateSections(file); }
public void LoadDLL_NtDLL() { BinaryFile file = new WindowsPortableExecutable(); BinaryLoadArgs arg = new WindowsPortableExecutableLoadArgs(true); file.Load(@"c:\windows\system32\NTDLL.DLL", arg); // dump all data: DumpSections(file); DumpExportSection(file); DumpImportSection(file); // validate: Assert.IsNotNull(file.Sections); ValidateSections(file); }
public void LoadDLL_NanoHooks() { BinaryFile file = new WindowsPortableExecutable(); BinaryLoadArgs arg = new WindowsPortableExecutableLoadArgs(true); file.Load("NanoHooks.dll", arg); //file.Load("NanoStorm.exe", null); //file.Load("AdvSection.obj", null); //file.Load(@"E:\a.txt", null); // dump sections: DumpSections(file); DumpExportSection(file); DumpImportSection(file); // validate if something has been read: Assert.IsNotNull(file.Sections); ValidateSections(file); }