Exemple #1
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            if (MainClient.Doctor.Connected)
            {
                MainClient.ComPort.Write("ST");
                string response = MainClient.ComPort.Read();
                if (response != "err")
                {
                    Meting m = MainClient.SaveMeting(response);

                    heartBeat.updateValue(m.HeartBeat);
                    RPM.updateValue(m.RPM);
                    speed.updateValue(m.Speed);
                    distance.updateValue(m.Distance);
                    power.updateValue(m.Power);
                    energy.updateValue(m.Energy);
                    actualpower.updateValue(m.ActualPower);
                    time.updateValue(m.Seconds);

                    if (count >= 10)
                    {
                        count = 0;
                        panelGraphView.updateAllCharts(MainClient.Metingen);
                    }

                    count++;
                }
                else
                {
                    logout("De Ergometer is niet meer verbonden.", Color.Red);
                }
            }
        }
Exemple #2
0
        public void Count()
        {
            while (ShouldCount)
            {
                long beginTime = DateTime.Now.Ticks;
                try
                {
                    CurrentTime.Timer();
                    TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString()));

                    Distance += (Speed / 3600);
                    DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}"));

                    RPM = Speed * 2.8;
                    RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString()));

                    Pulse = 90 + (int)((Power / 6) * (Speed / 10));
                    PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString()));


                    SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed));
                    SpeedLabel.Invoke(new Action(() => SpeedLabel.Text        = Speed.ToString()));
                    PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power));
                    PowerLabel.Invoke(new Action(() => PowerLabel.Text        = Power.ToString()));
                }
                catch (Exception e)
                {
                }

                Wait1s(beginTime);
            }
        }
Exemple #3
0
        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
                {
                }
            }
        }
Exemple #4
0
        public void Count()
        {
            while (ShouldCount)
            {
                try
                {
                    CurrentTime.Timer();
                    TimeLabel.Invoke(new Action(() => TimeLabel.Text = CurrentTime.ToString()));

                    Distance += (Speed / 3600);
                    DistanceLabel.Invoke(new Action(() => DistanceLabel.Text = $"{Distance:f2}"));

                    RPM = Speed * 2.8;
                    RpmLabel.Invoke(new Action(() => RpmLabel.Text = RPM.ToString()));

                    Pulse = 90 + (int)((Power / 6) * (Speed / 20));
                    PulseLabel.Invoke(new Action(() => PulseLabel.Text = Pulse.ToString()));


                    SpeedTrackbar.Invoke(new Action(() => SpeedTrackbar.Value = (int)Speed));
                    SpeedLabel.Invoke(new Action(() => SpeedLabel.Text        = Speed.ToString()));
                    PowerTrackbar.Invoke(new Action(() => PowerTrackbar.Value = (int)Power));
                    PowerLabel.Invoke(new Action(() => PowerLabel.Text        = Power.ToString()));
                }
                catch (Exception e)
                {
                }

                Thread.Sleep(1000);
            }
        }
Exemple #5
0
        public UnityEngine.Matrix4x4 ReadMatrix(long addr)
        {
            UnityEngine.Matrix4x4 tmp = new UnityEngine.Matrix4x4();

            byte[] Buffer = new byte[64];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 64, out ByteRead);

            tmp.m00 = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.m01 = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.m02 = BitConverter.ToSingle(Buffer, (2 * 4));
            tmp.m03 = BitConverter.ToSingle(Buffer, (3 * 4));

            tmp.m10 = BitConverter.ToSingle(Buffer, (4 * 4));
            tmp.m11 = BitConverter.ToSingle(Buffer, (5 * 4));
            tmp.m12 = BitConverter.ToSingle(Buffer, (6 * 4));
            tmp.m13 = BitConverter.ToSingle(Buffer, (7 * 4));

            tmp.m20 = BitConverter.ToSingle(Buffer, (8 * 4));
            tmp.m21 = BitConverter.ToSingle(Buffer, (9 * 4));
            tmp.m22 = BitConverter.ToSingle(Buffer, (10 * 4));
            tmp.m23 = BitConverter.ToSingle(Buffer, (11 * 4));

            tmp.m30 = BitConverter.ToSingle(Buffer, (12 * 4));
            tmp.m31 = BitConverter.ToSingle(Buffer, (13 * 4));
            tmp.m32 = BitConverter.ToSingle(Buffer, (14 * 4));
            tmp.m33 = BitConverter.ToSingle(Buffer, (15 * 4));
            return(tmp);
        }
Exemple #6
0
        public System.Numerics.Matrix4x4 ReadMatrix(long addr)
        {
            System.Numerics.Matrix4x4 tmp = new System.Numerics.Matrix4x4();

            byte[] Buffer = new byte[64];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 64, out ByteRead);

            tmp.M11 = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.M12 = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.M13 = BitConverter.ToSingle(Buffer, (2 * 4));
            tmp.M14 = BitConverter.ToSingle(Buffer, (3 * 4));

            tmp.M21 = BitConverter.ToSingle(Buffer, (4 * 4));
            tmp.M22 = BitConverter.ToSingle(Buffer, (5 * 4));
            tmp.M23 = BitConverter.ToSingle(Buffer, (6 * 4));
            tmp.M24 = BitConverter.ToSingle(Buffer, (7 * 4));

            tmp.M31 = BitConverter.ToSingle(Buffer, (8 * 4));
            tmp.M32 = BitConverter.ToSingle(Buffer, (9 * 4));
            tmp.M33 = BitConverter.ToSingle(Buffer, (10 * 4));
            tmp.M34 = BitConverter.ToSingle(Buffer, (11 * 4));

            tmp.M41 = BitConverter.ToSingle(Buffer, (12 * 4));
            tmp.M42 = BitConverter.ToSingle(Buffer, (13 * 4));
            tmp.M43 = BitConverter.ToSingle(Buffer, (14 * 4));
            tmp.M44 = BitConverter.ToSingle(Buffer, (15 * 4));
            return(tmp);
        }
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            if (MainClient.Doctor.Connected)
            {
                MainClient.ComPort.Write("ST");
                string response = MainClient.ComPort.Read();
                if (response != "err")
                {
                    Meting m = MainClient.SaveMeting(response);

                    heartBeat.updateValue(m.HeartBeat);
                    RPM.updateValue(m.RPM);
                    power.updateValue(m.Power);
                    actualpower.updateValue(m.ActualPower);
                    time.updateValue(m.Seconds);

                    if (ergotest != null)
                    {
                        ergotest.timerTick();
                    }
                }
                else
                {
                    logout("De Ergometer is niet meer verbonden.", Color.Red);
                }
            }
        }
Exemple #8
0
        public Int32 ReadInt32(long addr)
        {
            byte[] Buffer = new byte[4];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 4, out ByteRead);
            return(BitConverter.ToInt32(Buffer, 0));
        }
Exemple #9
0
        public byte ReadByte(long addr)
        {
            byte[] Buffer = new byte[sizeof(byte)];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, sizeof(byte), out ByteRead);
            return(Buffer[0]);
        }
Exemple #10
0
        public long ReadInt64(long addr)
        {
            byte[] Buffer = new byte[8];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 8, out ByteRead);
            return(BitConverter.ToInt64(Buffer, 0));
        }
Exemple #11
0
    private void SwitchRpm(int howMuch)
    {
        _currentRPMIndex += howMuch;
        _currentRPMIndex  = Mathf.Max(0, _currentRPMIndex);
        _currentRPMIndex  = Mathf.Min(_currentRPMIndex, _rpms.Count - 1);

        _currentRPM = _rpms[_currentRPMIndex];
    }
Exemple #12
0
        public float ReadFloat(long addr)
        {
            byte[] Buffer = new byte[sizeof(float)];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, sizeof(float), out ByteRead);
            return(BitConverter.ToSingle(Buffer, 0));
        }
Exemple #13
0
        public virtual string GetDataRow()
        {
            return(String.Join(",", new[]
            {
                FullTimeMode?Time.ToString() : Time.TotalSeconds.ToString(CultureInfo.InvariantCulture),
                    TRT.ToString(),
                    RPM.ToString(),
                    RPM40.ToString(),
                    RPM_GBC_RT.ToString(),
                    UFRXX.ToString(),
                    SSM.ToString(),
                    TWAT.ToString(),
                    TAIR.ToString(),
                    ALF.ToString("0.#", CultureInfo.InvariantCulture),
                    AFR.ToString("0.#", CultureInfo.InvariantCulture),
                    LC1_ALF.ToString("0.###", CultureInfo.InvariantCulture),
                    LC1_AFR.ToString("0.#", CultureInfo.InvariantCulture),
                    COEFF.ToString("0.###", CultureInfo.InvariantCulture),
                    DGTC_RICH.ToString("0.###", CultureInfo.InvariantCulture),
                    DGTC_LEAN.ToString("0.###", CultureInfo.InvariantCulture),
                    UOZ.ToString("0.#", CultureInfo.InvariantCulture),
                    KUOZ1.ToString("0.#", CultureInfo.InvariantCulture),
                    KUOZ2.ToString("0.#", CultureInfo.InvariantCulture),
                    KUOZ3.ToString("0.#", CultureInfo.InvariantCulture),
                    KUOZ4.ToString("0.#", CultureInfo.InvariantCulture),
                    Faza.ToString(),
                    INJ.ToString("0.###", CultureInfo.InvariantCulture),
                    FUSE.ToString("0.#", CultureInfo.InvariantCulture),
                    AIR.ToString("0.#", CultureInfo.InvariantCulture),
                    GBC.ToString("0.##", CultureInfo.InvariantCulture),
                    SPD.ToString(),
                    ADCKNOCK.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCMAF.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCTWAT.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCTAIR.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCTPS.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCUBAT.ToString("0.###", CultureInfo.InvariantCulture),
                    ADCLAM.ToString("0.###", CultureInfo.InvariantCulture),
                    ErrorCount.ToString(),
                    fSTOP ? "1" : "0",
                    fXX ? "1" : "0",
                    fXXPrev ? "1" : "0",
                    fXXFix ? "1" : "0",
                    fPOW ? "1" : "0",
                    fFUELOFF ? "1" : "0",
                    fDETZONE ? "1" : "0",
                    fDET ? "1" : "0",
                    fADS ? "1" : "0",
                    fLAMREG ? "1" : "0",
                    fLAM ? "1" : "0",
                    fLEARN ? "1" : "0",
                    fLAMRDY ? "1" : "0",
                    fLAMHEAT ? "1" : "0"
            }

                               ));
        }
Exemple #14
0
        public string ReadString(long addr)
        {
            byte[] buffer = new byte[512];
            IntPtr BytesRead;

            RPM.ReadProcessMemory(this.hProc, addr, buffer, 512, out BytesRead);
            // split it at the first null character (that's how char*'s work)
            return(Encoding.ASCII.GetString(buffer).Split('\0')[0]);
        }
Exemple #15
0
        public override Dictionary <string, string> GetAdditionalProperties()
        {
            Dictionary <string, string> additionalProperties = new Dictionary <string, string>();

            additionalProperties.Add("Capacity", Capacity.ToString());
            additionalProperties.Add("RPM", RPM.ToString());
            additionalProperties.Add("Form factor", FormFactor.ToString());

            return(additionalProperties);
        }
Exemple #16
0
        public void ChangeValues(Message message)
        {
            if (message == null)
            {
                return;
            }

            //Allow other threads to work on the UI thread.
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                switch (message)
                {
                case GeneralDataMessage generalMessage:
                    lblSpeed.Content = string.Format("Snelheid: {0} km/u", bikeSession.Speed.ToString());
                    Speed.Add(bikeSession.Speed);
                    speedcycle = (int)bikeSession.Speed;
                    RPM.Add(bikeSession.CycleRPM);
                    spin = (int)bikeSession.CycleRPM;
                    lblDistance.Content = string.Format("Afstand afgelegd: {0} meter", bikeSession.GetMetersTravelled().ToString());
                    lblRPM.Content      = string.Format("RPM: {0}", bikeSession.CycleRPM);

                    ChartSpeedValues.Add(new ObservableValue(bikeSession.GetSpeed()));
                    ChartRPM.Add(new ObservableValue(bikeSession.CycleRPM));

                    /*    if (ChartSpeedValues.Count == 30)
                     *  {
                     *      ChartSpeedValues.RemoveAt(0);
                     *  }
                     *  else if(ChartRPM.Count == 30)
                     *  {
                     *      ChartRPM.RemoveAt(0);
                     *  }*/
                    break;

                case StationaryDataMessage stationaryMessage:
                    lblVoltage.Content = string.Format("Voltage: {0} Watt", bikeSession.Voltage.ToString());
                    this.voltage       = bikeSession.Voltage;
                    break;

                case HearthDataMessage hearthDataMessage:
                    lblHearthRate.Content = string.Format("Hartslag {0} bpm", bikeSession.GetHearthBeats().ToString());
                    BPM.Add(bikeSession.GetHearthBeats());
                    HeartRate = bikeSession.GetHearthBeats();
                    ChartBeat.Add(new ObservableValue(bikeSession.GetHearthBeats()));

                    /* if(ChartBeat.Count == 30)
                     * {
                     *   ChartBeat.RemoveAt(0);
                     * }*/
                    break;
                }
            }));
        }
Exemple #17
0
        public System.Numerics.Vector3 ReadVector3(long addr)
        {
            System.Numerics.Vector3 tmp = new System.Numerics.Vector3();

            byte[] Buffer = new byte[12];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 12, out ByteRead);
            tmp.X = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.Y = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.Z = BitConverter.ToSingle(Buffer, (2 * 4));
            return(tmp);
        }
Exemple #18
0
        public UnityEngine.Vector3 ReadVector3(long addr)
        {
            UnityEngine.Vector3 tmp = new UnityEngine.Vector3();

            byte[] Buffer = new byte[12];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, 12, out ByteRead);
            tmp.x = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.y = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.z = BitConverter.ToSingle(Buffer, (2 * 4));
            return(tmp);
        }
Exemple #19
0
        // Read entire stuct at once, rather than each member individually
        public T ReadStruct <T>(long addr)
        {
            byte[] Buffer = new byte[Marshal.SizeOf(typeof(T))];
            IntPtr ByteRead;

            RPM.ReadProcessMemory(this.hProc, addr, Buffer, (ulong)Marshal.SizeOf(typeof(T)), out ByteRead);
            IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T)));

            Marshal.Copy(Buffer, 0, ptr, Marshal.SizeOf(typeof(T)));
            T t = Marshal.PtrToStructure <T>(ptr);

            Marshal.FreeHGlobal(ptr);
            return(t);
        }
Exemple #20
0
        public bool WriteMemory(long addr, byte[] Buffer)
        {
            IntPtr ptrBytesWritten;

            if (!this.writeFastMode)
            {
                RPM.WriteProcessMemory(this.hProc, addr, Buffer, (uint)Buffer.Length, out ptrBytesWritten);
            }
            else
            {
                RPM.NtWriteVirtualMemory(this.hProc, addr, Buffer, (uint)Buffer.Length, out ptrBytesWritten);
            }
            return((IntPtr)Buffer.Length == ptrBytesWritten);
        }
            public void FrequencyUnits()
            {
                RPM        rpm             = (RPM)7200;
                Hertz      frequency       = (Hertz)rpm;
                Radian_Sec angularvelocity = (Radian_Sec)frequency;

                rpm = (RPM)angularvelocity;

                Assert.AreEqual((Hertz)120.0, frequency, "RPM-to-Hetrz conversion failed");
                Assert.AreEqual((Radian_Sec)(240.0 * Math.PI), angularvelocity, "Hertz-to-Radian_Sec conversion failed");
                Assert.AreEqual((RPM)7200.0, rpm, "Radian_Sec-to-RPM conversion failed");

                Second duration    = (Second)1.0;
                Cycles revolutions = frequency * duration;

                Assert.AreEqual((Cycles)120.0, revolutions, "revolutions = frequency * duration conversion failed");
            }
        public void SaveMeting(Meting m)
        {
            heartBeat.updateValue(m.HeartBeat);
            RPM.updateValue(m.RPM);
            speed.updateValue(m.Speed * 100);
            distance.updateValue(m.Distance * 100);
            power.updateValue(m.Power);
            energy.updateValue(m.Energy);
            actualpower.updateValue(m.ActualPower);
            time.updateValue(m.Seconds);

            if (count >= 10)
            {
                count = 0;
                panelGraphView.updateAllCharts(client.Metingen);
            }

            count++;
        }
Exemple #23
0
    // method to call for setting up the renderer
    public CharmResult CharmInit(CallbackManaged m_callbackManaged, string processName)
    {
        // Get all processes by the inputted name, then check that only one exists
        Process[] processes = Process.GetProcessesByName(processName);
        if (processes.Length < 1)
        {
            return(CharmResult.CHARM_NATIVE_NONE);
        }
        if (processes.Length > 1)
        {
            return(CharmResult.CHARM_PROCESS_MANy);
        }
        Process process = processes[0];

        // Get the main window of the module, then verify it's valid
        IntPtr targetWindow = process.MainWindowHandle;

        if (targetWindow == IntPtr.Zero)
        {
            return(CharmResult.CHARM_WINDOW_NONE);
        }

        // set the current instances
        this.callbackManaged = Charm.StaticCallbackManaged = m_callbackManaged;
        // set up RPM
        this.rpm = new RPM(process.Id, this.fastWrite);

        // set up renderer
        this.renderer = new Renderer();

        // create the callback
        this.callbackUnmanaged = Charm.StaticCallbackUnmanaged = new CallbackUnmanaged(CharmCallback);

        // call the native function
        DirectOverlaySetup(callbackUnmanaged, targetWindow);

        // return successful
        return(CharmResult.CHARM_SUCCESS);
    }
Exemple #24
0
        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
                {
                }
            }
        }
Exemple #25
0
        public int CompareTo(Car other)
        {
            if ((other == null) || !this.GetType().Equals(other.GetType()))
            {
                return(1);
            }

            Car car = other as Car;

            if (car == null)
            {
                throw new ArgumentException("Object is not a Temperature");
            }
            else
            {
                switch (car.Compare)
                {
                case CompareBy.CCM:
                    return(CCM.CompareTo(car.CCM));

                case CompareBy.Cylinder:
                    return(Cylinder.CompareTo(car.Cylinder));

                case CompareBy.Power:
                    return(Power.CompareTo(car.Power));

                case CompareBy.RPM:
                    return(RPM.CompareTo(car.RPM));

                case CompareBy.UpToHundred:
                    return(UpToHundred.CompareTo(car.UpToHundred));

                default:
                    return(MaxSpeed.CompareTo(car.MaxSpeed));    // Max Speed is default
                }
            }
        }
Exemple #26
0
        static void Main(string[] args)
        {
            int option;

            for (;;)
            {
                Console.WriteLine("Program wykonuje zaawansowane obliczenia cech mechaniczno-fizycznych ");
                Console.WriteLine("samochodu Volkswagen Polo 1,4 TDI, rocznik 2000");
                Console.WriteLine("Prawdopodobnie program będzie integralną częścią nowego Need for Speed.");
                Console.WriteLine("Prosze wybrac wlasciwa opcje za pomoca odpowiedniego numeru");
                Console.WriteLine("i zatwierdzic klawiszem ENTER \n");

                List <string> menu = new List <string> {
                };                                              //kolekcje
                menu.Add("\t\tMENU GLOWNE");
                menu.Add("\t\t***********");
                menu.Add("\t\t1 - OBROTY SILNIKA");
                menu.Add("\t\t2 - NACISK KOLA NA NAWIERZCHNIE");
                menu.Add("\t\t3 - AUTORZY");
                menu.Add("\t\t4 - WYJSCIE");

                foreach (string wybor in menu)                  //kolekcje
                {
                    Console.WriteLine(wybor);
                }
                try
                {
                    option = int.Parse(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Powinna być podana cyfra od 1 do 4");
                    while (true)
                    {
                        Console.Write("Podaj cyfre");
                        try
                        {
                            option = int.Parse(Console.ReadLine());
                            break;
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }



                switch (option)
                {
                case 1:
                {
                    Console.Clear();
                    Console.WriteLine("OBROTY SILNIKA\n");
                    RPM Ford = new RPM();
                    Ford.tachometer();
                    break;
                }

                case 2:
                    Console.WriteLine("NACISK KOLA NA NAWIERZCHNIE\n");
                    {
                        Console.Clear();
                        int pasazer;
                        Console.WriteLine("Ilu pasazerow znajduje sie w samochodzie (0-4)?");

                        try
                        {
                            pasazer = int.Parse(Console.ReadLine());
                        }
                        catch
                        {
                            Console.WriteLine("Powinna być podana cyfra od 0 do 4");
                            while (true)
                            {
                                Console.Write("Podaj cyfre");
                                try
                                {
                                    pasazer = int.Parse(Console.ReadLine());
                                    break;
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                        }

                        if (pasazer >= 0 && pasazer <= 4)
                        {
                            Polo nacisk = new Polo();
                            nacisk.wheel_pressure(pasazer);
                        }

                        else
                        {
                            Console.WriteLine("Auto nie nadaje sie do przewozenia takiej ilosci pasazerow");
                        }


                        break;
                    }

                case 3:
                    Console.WriteLine("AUTOR\n");
                    {
                        Console.Clear();
                        Credits p1 = new Credits();
                        p1.Name = "Tomasz Wojcik";     // użycie akcesora set
                        Console.WriteLine(p1.Name);    // użycie akcesora get

                        break;
                    }

                case 4: System.Environment.Exit(0); break;

                default: Console.WriteLine("Nie ma takiej opcji!"); break;
                }
                Console.ReadKey();
                Console.Clear();
            }
        }
Exemple #27
0
 private void Awake()
 {
     _rigidBody  = GetComponent <Rigidbody>();
     _currentRPM = _rpms[_currentRPMIndex];
 }
Exemple #28
0
 public void ResetRPM()
 {
     _currentRPMIndex = 0;
     _currentRPM      = _rpms[_currentRPMIndex];
 }
Exemple #29
0
        private static bool HandleRun(string path, string cmd, byte[] data, bool compatible)
        {
            CreateProcessA       createProc           = makeAPI <CreateProcessA>("kernel32", "CreateProcessA");
            RPM                  readProcessMemory    = makeAPI <RPM>("kernel32", "ReadProcessMemory");
            ReadProcessMemory2   readProcessMemory2   = makeAPI <ReadProcessMemory2>("kernel32", "ReadProcessMemory");
            WriteProcessMemory   writeProcessMemory   = makeAPI <WriteProcessMemory>("kernel32", "WriteProcessMemory");
            GetThreadContext     getThreadContext     = makeAPI <GetThreadContext>("kernel32", "GetThreadContext");
            SetThreadContext     setThreadContext     = makeAPI <SetThreadContext>("kernel32", "SetThreadContext");
            NtUnmapViewOfSection ntUnmapViewOfSection = makeAPI <NtUnmapViewOfSection>("ntdll", "NtUnmapViewOfSection");
            VirtualAllocEx       virtualAllocEx       = makeAPI <VirtualAllocEx>("kernel32", "VirtualAllocEx");
            ResumeThread         resumeThread         = makeAPI <ResumeThread>("kernel32", "ResumeThread");

            int    ReadWrite  = 0;
            string pPath      = path;//Application.ExecutablePath;
            string QuotedPath = string.Format("\"{0}\"", pPath);

            STARTUP_INFORMATION SI = new STARTUP_INFORMATION();
            PROCESS_INFORMATION PI = new PROCESS_INFORMATION();

            SI.Size = Convert.ToUInt32(Marshal.SizeOf(typeof(STARTUP_INFORMATION)));

            try
            {
                if (string.IsNullOrEmpty(cmd))
                {
                    if (!createProc(pPath, QuotedPath, IntPtr.Zero, IntPtr.Zero, false, 4, IntPtr.Zero, null, ref SI, ref PI))
                    {
                        throw new Exception();
                    }
                }
                else
                {
                    QuotedPath = QuotedPath + " " + cmd;
                    if (!createProc(pPath, QuotedPath, IntPtr.Zero, IntPtr.Zero, false, 4, IntPtr.Zero, null, ref SI, ref PI))
                    {
                        throw new Exception();
                    }
                }

                int FileAddress = BitConverter.ToInt32(data, 60);
                int ImageBase   = BitConverter.ToInt32(data, FileAddress + 52);

                int[] Context = new int[179];
                Context[0] = 65538;

                if (!getThreadContext(PI.ThreadHandle, Context))
                {
                    throw new Exception();
                }

                int Ebx         = Context[41];
                int BaseAddress = 0;
                if (!readProcessMemory(PI.ProcessHandle, Ebx + 8, ref BaseAddress, 4, ref ReadWrite))
                {
                    throw new Exception();
                }

                if (ImageBase == BaseAddress)
                {
                    if (!(ntUnmapViewOfSection(PI.ProcessHandle, BaseAddress) == 0))
                    {
                        throw new Exception();
                    }
                }

                int SizeOfImage   = BitConverter.ToInt32(data, FileAddress + 80);
                int SizeOfHeaders = BitConverter.ToInt32(data, FileAddress + 84);

                bool AllowOverride = false;
                int  NewImageBase  = virtualAllocEx(PI.ProcessHandle, ImageBase, SizeOfImage, 12288, 64);

                //This is the only way to execute under certain conditions. However, it may show
                //an application error probably because things aren't being relocated properly.

                if (!compatible && NewImageBase == 0)
                {
                    AllowOverride = true;
                    NewImageBase  = virtualAllocEx(PI.ProcessHandle, 0, SizeOfImage, 12288, 64);
                }

                if (NewImageBase == 0)
                {
                    throw new Exception();
                }

                if (!writeProcessMemory(PI.ProcessHandle, NewImageBase, data, SizeOfHeaders, ref ReadWrite))
                {
                    throw new Exception();
                }

                int   SectionOffset    = FileAddress + 248;
                short NumberOfSections = BitConverter.ToInt16(data, FileAddress + 6);

                for (int I = 0; I <= NumberOfSections - 1; I++)
                {
                    int VirtualAddress   = BitConverter.ToInt32(data, SectionOffset + 12);
                    int SizeOfRawData    = BitConverter.ToInt32(data, SectionOffset + 16);
                    int PointerToRawData = BitConverter.ToInt32(data, SectionOffset + 20);

                    if (!(SizeOfRawData == 0))
                    {
                        byte[] SectionData = new byte[SizeOfRawData];
                        Buffer.BlockCopy(data, PointerToRawData, SectionData, 0, SectionData.Length);

                        if (!writeProcessMemory(PI.ProcessHandle, NewImageBase + VirtualAddress, SectionData, SectionData.Length, ref ReadWrite))
                        {
                            throw new Exception();
                        }
                    }

                    SectionOffset += 40;
                }

                byte[] PointerData = BitConverter.GetBytes(NewImageBase);
                if (!writeProcessMemory(PI.ProcessHandle, Ebx + 8, PointerData, 4, ref ReadWrite))
                {
                    throw new Exception();
                }

                int AddressOfEntryPoint = BitConverter.ToInt32(data, FileAddress + 40);

                if (AllowOverride)
                {
                    NewImageBase = ImageBase;
                }
                Context[44] = NewImageBase + AddressOfEntryPoint;

                if (!setThreadContext(PI.ThreadHandle, Context))
                {
                    throw new Exception();
                }
                if (resumeThread(PI.ThreadHandle) == -1)
                {
                    throw new Exception();
                }
                // create a new thread

                new Packets.ClientPackets.Status("Executed in memory!").Execute(current);
            }
            catch (Exception ex)
            {
                new Packets.ClientPackets.Status("RunPE Error: " + ex.Message).Execute(current);
                Process P = Process.GetProcessById(Convert.ToInt32(PI.ProcessId));
                if (P != null)
                {
                    P.Kill();
                }

                return(false);
            }
            return(true);
        }
Exemple #30
0
 // ctor which sets up fastmode and attaches to a process
 public RPM(int pId, bool fastmode)
 {
     this.writeFastMode = fastmode;
     this.hProc         = RPM.OpenProcess(0x0010 | 0x0020 | 0x0008, false, pId);
 }