/// <summary> /// Converts the instruction with a frame of reference at a specific address to raw bytes. /// </summary> /// <param name="assembly">The assembly code to disassemble.</param> /// <param name="address">The base address of the assembly code.</param> /// <returns>The disassembled bytes of the assembly code.</returns> public Byte[] GetAssemblyBytes(String assembly, UInt64 address) { this.PrintDebugTag(); assembly = this.ResolveKeywords(assembly); AssemblerResult result = Assembler.Default.Assemble(assembly, Processes.Default.IsOpenedProcess32Bit(), address); Logger.Log(LogLevel.Info, result.Message, result.InnerMessage); return(result.Bytes); }
public bool AssembleFile(RiscVAssembler assembler, string outputFilePath) { Logger.ClearLogCommand.Execute(null); var options = new AssemblerOptions(new[] { FilePath }, new[] { outputFilePath }); // clear any errors beforehand. FileErrors.Clear(); AssemblerResult result = assembler.AssembleFile(FilePath, outputFilePath, Logger.Logger, options); if (!result.OperationSuccessful) { foreach (AssemblyException ex in result.UserErrors) { FileErrors.Add(ex); } } return(result.OperationSuccessful); }
/// <summary> /// Task for assembling one individual file. /// </summary> /// <param name="inputFile">The input file to assemble.</param> /// <param name="logger">The logging implementation to log errors/info to.</param> /// <param name="options">The options to use while assembling.</param> /// <returns>True if the assembler could successfully generate code for the file; otherwise returns false.</returns> public AssemblerResult AssembleFile(string inputFile, string outputFile, ILogger logger, AssemblerOptions options) { var result = new AssemblerResult(); logger.Log(LogLevel.Info, "Invoking assembler for file " + inputFile); try { bool furtherProcessingNeeded = true; if (File.Exists(inputFile) && File.Exists(outputFile)) { DateTime inputFileWriteTime = File.GetLastWriteTimeUtc(inputFile); DateTime outputFileWriteTime = File.GetLastWriteTimeUtc(outputFile); if (outputFileWriteTime > inputFileWriteTime) { logger.Log(LogLevel.Info, "Nothing to do for file " + inputFile); furtherProcessingNeeded = false; } } if (furtherProcessingNeeded) { using (var reader = new StreamReader(File.OpenRead(inputFile))) { var symTable = new SymbolTable(); // build the symbol table var instructionProcFac = new InstructionProcessorFactory(symTable); var symTableBuilder = new SymbolTableBuilder(logger, instructionProcFac); symTableBuilder.GenerateSymbolTableForSegment(reader, SegmentType.Data, symTable); symTableBuilder.GenerateSymbolTableForSegment(reader, SegmentType.Text, symTable); // use the symbol table to generate code with references resolved. var objFile = new BasicObjectFile(inputFile, symTable); var codeGenerator = new CodeGenerator(logger, symTable, instructionProcFac); codeGenerator.GenerateCode(inputFile, reader, objFile); if (!objFile.TextElements.Any()) { logger.Log(LogLevel.Warning, "No .text segment to assemble. Stop."); result.OperationSuccessful = false; } else { // write the object file out. var writerFac = new ObjectFileWriterFactory(); IObjectFileWriter writer = writerFac.GetWriterForOutputFile(outputFile); writer.WriteObjectFile(outputFile, objFile); } } } } catch (AggregateAssemblyError ex) { foreach (AssemblyException asEx in ex.AssemblyErrors) { logger.Log(LogLevel.Critical, "In file \"" + inputFile + "\" (line " + asEx.LineNumber + "):\n\t"); logger.Log(LogLevel.Critical, asEx.Message); result.AddUserAssemblyError(asEx); } } catch (Exception ex) { logger.Log(LogLevel.Critical, ex.StackTrace); logger.Log(LogLevel.Critical, ex.Message); if (ex.InnerException != null) { logger.Log(LogLevel.Critical, ex.InnerException.StackTrace); logger.Log(LogLevel.Critical, ex.InnerException.Message); } result.AddInternalAssemblerError(ex); } return(result); }
//[WebMethod] public string test2() { List <ConcatFile> pole = new List <ConcatFile>(); ConcatOptions conOptions = new ConcatOptions(); //[] seynam; = new ConcatFile[](); ConcatFile source = new ConcatFile(); ConcatFile att = new ConcatFile(); source.Data = System.IO.File.ReadAllBytes(@"C:\Users\mz311858\Documents\VSinventura.pdf");; source.Name = "VSinventura.pdf"; att.Data = System.IO.File.ReadAllBytes(@"E:\Sdělení soudu o odvolání.TXT");; att.Name = "Sdělení soudu o odvolání.TXT"; pole.Add(source); pole.Add(att); string StatusText = ""; //public BLOB invoke() { AssemblerResult outAsembler = new AssemblerResult(); BLOB outBlob = new BLOB(); ConvertOptions ConvertOptions = new ConvertOptions(); //dokumentu převedu do PDF //Je li tisk prosty, tak se přidá hlavička a patička //není li tisk, tak se vystup spoji se šablonou //Render_PDF_From_XML:<druh>A-D-69</druh> - actipn_upload_to_db.asp //Render_PDF_From_XML:<druh>D-A-69</druh> - prevedeni_dle_69 //Render_PDF_From_XML:<druh>D-zmena-69</druh> - prevod_formatu //stavOUT = ""; error = ""; ConvertOptions.PdfFormat = PdfFormat.PDF; //ConvertOptions. service.Url = "http://10.85.68.11:8081/ltd/ltd.asmx"; try { vysledek = service.Concat(pole.ToArray(), conOptions, ConvertOptions, out output, out report); } catch (Exception ddd) { StatusText = ddd.Message; return(StatusText); } OperationContext context = OperationContext.Current; if (context != null && context.RequestContext != null) { //Message msg = context.RequestContext.RequestMessage; //string reqXML = msg.ToString(); } if (vysledek == 0) { System.IO.File.WriteAllBytes(@"e:\602_out_1.pdf", output); } else { StatusText = report; return(StatusText); } return(StatusText); }
public AssemblerResult konverze_DA(BLOB docIN_form, BLOB docIN_orig, string text_1, string text_2, string text_3, int tisk_prosty, [System.Xml.Serialization.XmlIgnoreAttribute()] bool tisk_prostySpecified, string typ, out string StatusKod, out string StatusText, out BLOB docOUT, out int muj_vystup) { if (logovani) { XmlDocument xmlSoapRequest = new XmlDocument(); // Get raw request body using (Stream receiveStream = HttpContext.Current.Request.InputStream) { receiveStream.Position = 0; using (StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.UTF8)) { xmlSoapRequest.Load(readStream); } xmlSoapRequest.Save(@"C:\Sluzby\602\konverze_DA_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xml"); } } //public BLOB invoke() { AssemblerResult outAsembler = new AssemblerResult(); StatusText = ""; docOUT = new BLOB(); muj_vystup = 0; StatusKod = "0000"; BLOB outBlob = new BLOB(); try { WS602Info = Database.getWS602Info(); } catch (Exception ddd) { StatusText = ddd.Message; StatusKod = "1111"; return(outAsembler); } if (WS602Info.URL == "") { StatusText = "Není vyplněna URL adresa pro webovou službu Software602 LTD!"; StatusKod = "2222"; return(outAsembler); } if (WS602Info.Certifikat == "") { //StatusText = "Není cesta k podepisujícímu systémovému certifikátu (značce / pečeti)!"; //StatusKod = "3333"; //return outAsembler; } ConvertOptions ConvertOptions = new ConvertOptions(); //dokumentu převedu do PDF //Je li tisk prosty, tak se přidá hlavička a patička //není li tisk, tak se vystup spoji se šablonou //Render_PDF_From_XML:<druh>A-D-69</druh> - actipn_upload_to_db.asp //Render_PDF_From_XML:<druh>D-A-69</druh> - prevedeni_dle_69 //Render_PDF_From_XML:<druh>D-zmena-69</druh> - prevod_formatu if (tisk_prosty == 1) { //přidám k tomu hlavicku a paticku HF_Options hlavicka = new HF_Options(); HF_Options paticka = new HF_Options(); //hlavicka. hlavicka.HorizontalAlignment = HorizontalPosition.Center; hlavicka.Mode = PlacementMode.AllPages; hlavicka.VerticalAlignment = VerticalPosition.Top; hlavicka.Text = text_1 + "\n" + text_2 + "\n" + text_3; hlavicka.FontSize = 8; paticka.HorizontalAlignment = HorizontalPosition.Center; paticka.Mode = PlacementMode.AllPages; paticka.VerticalAlignment = VerticalPosition.Bottom; paticka.Text = text_1 + "\n" + text_2 + "\n" + text_3; paticka.FontSize = 8; ConvertOptions.Header = hlavicka; ConvertOptions.Footer = paticka; ConvertOptions.PdfFormat = PdfFormat.PDF; //ConvertOptions. service.Url = WS602Info.URL; try { vysledek = service.ConvertFileEx(docIN_orig.binaryData, "test." + typ, ConvertOptions, "", out output, out report, out error); } catch (Exception ddd) { StatusText = ddd.Message; StatusKod = "4444"; return(outAsembler); } } else { List <ConcatFile> pole = new List <ConcatFile>(); ConcatOptions conOptions = new ConcatOptions(); ConcatFile source = new ConcatFile(); ConcatFile att = new ConcatFile(); source.Data = docIN_orig.binaryData; source.Name = "original." + typ; att.Data = docIN_form.binaryData; att.Name = "sablona.rtf"; pole.Add(source); pole.Add(att); ConvertOptions.PdfFormat = PdfFormat.PDF; //ConvertOptions. service.Url = WS602Info.URL; try { vysledek = service.Concat(pole.ToArray(), conOptions, ConvertOptions, out output, out report); } catch (Exception ddd) { StatusText = ddd.Message; StatusKod = "4555"; return(outAsembler); } } error = ""; OperationContext context = OperationContext.Current; if (context != null && context.RequestContext != null) { //Message msg = context.RequestContext.RequestMessage; //string reqXML = msg.ToString(); } if (vysledek == 0) { List <mapItem> itmMap = new List <mapItem>(); mapItem itmmm = new mapItem(); BLOB ret = new BLOB(); ret.contentType = "application/pdf"; ret.binaryData = output; List <mapItem> atributes = new List <mapItem>(); mapItem attmmm = new mapItem(); attmmm.key = (string)"basename"; attmmm.value = (string)"DocumentOUT.pdf"; atributes.Add(attmmm); attmmm.key = (string)"basename"; attmmm.value = (string)"DocumentOUT.pdf"; atributes.Add(attmmm); attmmm.key = (string)"file"; attmmm.value = (string)"DocumentOUT.pdf"; atributes.Add(attmmm); attmmm.key = (string)"wsfilename"; attmmm.value = (string)"DocumentOUT.pdf"; atributes.Add(attmmm); attmmm.key = (string)"ADOBE_SAVE_MODE_ATTRIBUTE"; attmmm.value = (string)"INCREMENTAL"; atributes.Add(attmmm); ret.attributes = atributes.ToArray(); itmmm.key = (string)"DocumentOUT"; itmmm.value = (BLOB)ret; //itmmm. itmMap.Add(itmmm); outAsembler.documents = itmMap.ToArray(); } else { StatusText = report; StatusKod = "5555"; return(outAsembler); } return(outAsembler); }
//[WebMethod] public string test1() { byte[] xx_file_con = System.IO.File.ReadAllBytes(@"C:\Users\mz311858\Documents\VSinventura.pdf"); string StatusText = ""; string text_1 = "Prostý převod dokumentu z digitální do analogové podoby"; string text_2 = "Vyhotovil: 30.01.2019 09:26:00 Martin Zvonek"; string text_3 = ""; int tisk_prosty = 1; //public BLOB invoke() { AssemblerResult outAsembler = new AssemblerResult(); BLOB outBlob = new BLOB(); ConvertOptions ConvertOptions = new ConvertOptions(); //dokumentu převedu do PDF //Je li tisk prosty, tak se přidá hlavička a patička //není li tisk, tak se vystup spoji se šablonou //Render_PDF_From_XML:<druh>A-D-69</druh> - actipn_upload_to_db.asp //Render_PDF_From_XML:<druh>D-A-69</druh> - prevedeni_dle_69 //Render_PDF_From_XML:<druh>D-zmena-69</druh> - prevod_formatu if (tisk_prosty == 1) { //přidám k tomu hlavicku a paticku HF_Options hlavicka = new HF_Options(); HF_Options paticka = new HF_Options(); //hlavicka. hlavicka.HorizontalAlignment = HorizontalPosition.Center; hlavicka.Mode = PlacementMode.AllPages; hlavicka.VerticalAlignment = VerticalPosition.Top; hlavicka.Text = text_1 + "\n" + text_2 + "\n" + text_3; hlavicka.FontSize = 8; paticka.HorizontalAlignment = HorizontalPosition.Center; paticka.Mode = PlacementMode.AllPages; paticka.VerticalAlignment = VerticalPosition.Bottom; paticka.Text = text_1 + "\n" + text_2 + "\n" + text_3; paticka.FontSize = 9; ConvertOptions.Header = hlavicka; ConvertOptions.Footer = paticka; } else { //provedu sloučení //docIN_orig - hlavni //docIN_form - přilepuju tuto šablonu //ConvertOptions.EnableMerge = true; //ConvertOptions.Merge = new PdfMerge(); //ConvertOptions.Merge.Mode = MergeMode.End; } //stavOUT = ""; error = ""; ConvertOptions.PdfFormat = PdfFormat.PDF; //ConvertOptions. service.Url = "http://10.85.68.11:8081/ltd/ltd.asmx"; try { vysledek = service.ConvertFileEx(xx_file_con, "VSinventura.pdf", ConvertOptions, "", out output, out report, out error); } catch (Exception ddd) { StatusText = ddd.Message; return(StatusText); } OperationContext context = OperationContext.Current; if (context != null && context.RequestContext != null) { //Message msg = context.RequestContext.RequestMessage; //string reqXML = msg.ToString(); } if (vysledek == 0) { System.IO.File.WriteAllBytes(@"e:\602_out.pdf", output); } else { StatusText = report; return(StatusText); } return(StatusText); }