public static byte[] CreatePasteTextBlackMarkData(Emulation emulation, LocalizeReceipt localizeReceipt, string pasteText, bool doubleHeight, BlackMarkType type, bool utf8) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); builder.AppendBlackMark(type); if (doubleHeight) { builder.AppendMultipleHeight(2); localizeReceipt.AppendPasteTextLabelData(builder, pasteText, utf8); builder.AppendMultipleHeight(1); } else { localizeReceipt.AppendPasteTextLabelData(builder, pasteText, utf8); } builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public static void TamperFields2(ModuleDefMD module) { //Console.WriteLine("[!] Finding Field And Its Value"); var cctor = module.GlobalType.FindOrCreateStaticConstructor(); if (cctor.Body.Instructions[0].OpCode == OpCodes.Call && cctor.Body.Instructions[0].Operand.ToString().Contains("Koi")) { cctor = (MethodDef)cctor.Body.Instructions[0].Operand; } foreach (var t1 in cctor.Body.Instructions) { if (t1.OpCode == OpCodes.Call || t1.Operand is MethodDef) { var methodDef = (MethodDef)t1.Operand; if (!methodDef.HasBody) { continue; } if (!methodDef.Body.Instructions[0].IsLdcI4() && methodDef.Body.Instructions[1].OpCode != OpCodes.Dup) { continue; } var intEnd = FindEnd(methodDef); var insEmu = new Emulation(methodDef); insEmu.Emulate2(methodDef.Body.Instructions, 0, intEnd); allFields = insEmu.ValueStack.Fields; return; } } }
private void Start_Click(object sender, EventArgs e) { if (RepaintThread == null) { ICourier courier = GetCourier(); if (courier == null) { return; } List <Shop> shops = GetShops(); Coordinates min = new Coordinates(0, panel1.Height - 100); Coordinates max = new Coordinates(panel1.Width - 100, (int)(panel1.Height * 0.3)); Emulation = new Emulation(shops, courier, min, max); Emulation.Start(); RepaintThread = new Thread(PanelRepaint); RepaintThread.Start(); start.Text = "Stop"; } else { AllStop(); } }
private void AllStop() { Emulation.Stop(); RepaintThread.Abort(); RepaintThread = null; start.Text = "Start"; }
public static byte[] CreateTextReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool utf8, bool receipt, bool info, bool qrCode) { ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); localizeReceipt.AppendTextReceiptData(builder, utf8); builder.EndDocument(); byte[] receiptsData = builder.Commands; byte[] urlData = SMCSAllReceipts.UploadData(receiptsData, emulation, localizeReceipt.CharacterCode, width); ICommandBuilder printDataBuilder = StarIoExt.CreateCommandBuilder(emulation); printDataBuilder.BeginDocument(); if (receipt) { localizeReceipt.AppendTextReceiptData(printDataBuilder, utf8); } byte[] allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode); printDataBuilder.AppendRaw(allReceiptsData); printDataBuilder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); printDataBuilder.EndDocument(); return(printDataBuilder.Commands); }
public static byte[] CreateScaleRasterReceiptData(Emulation emulation, LocalizeReceipt localizeReceipt, int width, bool bothScale, bool receipt, bool info, bool qrCode) { Bitmap image = localizeReceipt.CreateScaleRasterReceiptImage(); byte[] urlData = SMCSAllReceipts.UploadBitmap(image); ICommandBuilder builder = StarIoExt.CreateCommandBuilder(emulation); builder.BeginDocument(); if (receipt) { builder.AppendBitmap(image, false, width, bothScale); } byte[] allReceiptsData; if (emulation == Emulation.StarGraphic) { allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode, width); // Support to centering in Star Graphic. } else { allReceiptsData = SMCSAllReceipts.GenerateAllReceipts(urlData, emulation, info, qrCode);// Non support to centering in Star Graphic. } builder.AppendRaw(allReceiptsData); builder.AppendCutPaper(CutPaperAction.PartialCutWithFeed); builder.EndDocument(); return(builder.Commands); }
public void SendEmail_KeyNotInConfig_Error() { bool error = false; int? preCount = null; int? postCount = null; try { Emulation.InitDDBB(); var logger = (OwnLogger)Global.Resolve <ILogger>(); preCount = OwnLogger.AllLogs.Count(); var mailSenderManager = Global.Resolve <IMailSenderManager>(); mailSenderManager.SendEmail("*****@*****.**", "Just some subject", "just some body"); postCount = OwnLogger.AllLogs.Count(); } catch (Exception e) { error = true; } Assert.IsTrue(error); Assert.IsNotNull(preCount); Assert.IsNull(postCount); Assert.IsTrue(preCount.Value == 0); }
public void Load(string path) { using(var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { CurrentEmulation = serializer.Deserialize<Emulation>(stream); CurrentEmulation.BlobManager.Load(stream); } }
internal static void Cleaner() { var cctor = ModuleDefMD.GlobalType.FindOrCreateStaticConstructor(); if (cctor.Body.Instructions[0].OpCode == OpCodes.Call && cctor.Body.Instructions[0].Operand.ToString().Contains("Koi")) { cctor = (MethodDef)cctor.Body.Instructions[0].Operand; } foreach (Instruction t in cctor.Body.Instructions) { if (t.OpCode == OpCodes.Call && t.Operand is MethodDef) { var methodDef = (MethodDef)t.Operand; if (!methodDef.HasBody) { continue; } if (methodDef.Body.Instructions.Count < 9) { continue; } if (methodDef.Body.Instructions[0].IsLdcI4() && methodDef.Body.Instructions.Count == 9 && methodDef.Body.Instructions[3].OpCode == OpCodes.Ldtoken && methodDef.Body.Instructions[7].OpCode == OpCodes.Stsfld) { var field = methodDef.Body.Instructions[3].Operand as FieldDef; var cflowFieldArray = methodDef.Body.Instructions[7].Operand as FieldDef; var arrrr = field.InitialValue; var tester = IChannelReceiverHook.ParseNumbers(arrrr, methodDef.Body.Instructions[5].GetLdcI4Value()); FieldReplaace(ModuleDefMD, cflowFieldArray, tester); Base.methodsToRemove.Add(methodDef); } else if (methodDef.Body.Instructions[1].IsLdcI4() && methodDef.Body.Instructions.Count == 10 && methodDef.Body.Instructions[4].OpCode == OpCodes.Ldtoken && methodDef.Body.Instructions[8].OpCode == OpCodes.Stsfld) { var field = methodDef.Body.Instructions[4].Operand as FieldDef; var cflowFieldArray = methodDef.Body.Instructions[8].Operand as FieldDef; var arrrr = field.InitialValue; var tester = IChannelReceiverHook.ParseNumbers(arrrr, methodDef.Body.Instructions[6].GetLdcI4Value()); FieldReplaace(ModuleDefMD, cflowFieldArray, tester); if (methodDef.Body.Instructions[0].OpCode == OpCodes.Call) { MethodDef methods2 = (MethodDef)methodDef.Body.Instructions[0].Operand; Emulation emu = new Emulation(methods2); emu.Emulate(); FieldsInFirstCall.allFields = emu.ValueStack.Fields; FieldsInFirstCall.FieldReplacer(ModuleDefMD); FieldsInFirstCall.allFields = null; Base.methodsToRemove.Add(methodDef); } } } } }
public SyncPointHookPythonEngine(string script, Emulation emulation) { this.script = script; this.emulation = emulation; InnerInit(); Hook = new Action <long>(syncCount => { Scope.SetVariable("syncCount", syncCount); Source.Value.Execute(Scope); }); }
public void Clear() { CurrentEmulation = new Emulation(); }
private EmulationManager() { var settings = new Antmicro.Migrant.Customization.Settings(Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldAddition | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldRemoval | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowGuidChange | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowAssemblyVersionChange); serializer = new Serializer(settings); serializer.ForObject<PythonDictionary>().SetSurrogate(x => new PythonDictionarySurrogate(x)); serializer.ForSurrogate<PythonDictionarySurrogate>().SetObject(x => x.Restore()); currentEmulation = new Emulation(); ProgressMonitor = new ProgressMonitor(); stopwatch = new Stopwatch(); }