Delphi - Convertir de C# a Delphi

 
Vista:
sin imagen de perfil

Convertir de C# a Delphi

Publicado por Yosley (3 intervenciones) el 08/12/2016 15:16:13
Hola tengo un problemote, necesito convertir un codigo de c# a delphi y no tengo ni idea de c# pero si algo de delphi, algien q me ayude!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
private Mutex mutex;
    private IntPtr thread;
    internal RunProc Window;
 
 
 private void threadi()
    {
      STARTUPINFO lpStartupInfo = new STARTUPINFO();
      PROCESS_INFORMATION lpProcessInformation = new PROCESS_INFORMATION();
      byte[] arrayToSearchThrough = File.ReadAllBytes(this.ExecutableName);
      byte[] input1 = new byte[4];
      Array.Copy((Array) arrayToSearchThrough, 60, (Array) input1, 0, 2);
      byte[] input2 = new byte[4];
      int num1 = RunProc.BytesToInt(input1);
      int sourceIndex1 = num1 + 296;
      int sourceIndex2 = num1 + 300;
      int sourceIndex3 = num1 + 304;
      int sourceIndex4 = num1 + 308;
      Array.Copy((Array) arrayToSearchThrough, sourceIndex3, (Array) input2, 0, 4);
      int num2 = RunProc.BytesToInt(input2);
      Array.Copy((Array) arrayToSearchThrough, sourceIndex4, (Array) input2, 0, 4);
      int num3 = RunProc.BytesToInt(input2);
      Array.Copy((Array) arrayToSearchThrough, sourceIndex2, (Array) input2, 0, 4);
      int num4 = RunProc.BytesToInt(input2) + 4194304;
      Array.Copy((Array) arrayToSearchThrough, sourceIndex1, (Array) input2, 0, 4);
      int num5 = RunProc.Round1000(RunProc.BytesToInt(input2));
      int num6 = RunProc.IndexOf(arrayToSearchThrough, Encoding.ASCII.GetBytes("steam_api.dll"));
      if (num6 < num3 && num6 > num3 + num2)
      {
        int num7 = (int) MessageBox.Show("Cannot find steam_api.dll string in executable, make sure you have the proper original files!");
      }
      else
      {
        int num8 = num6 - num3;
        if (!Win32Apis.CreateProcess(this.ExecutableName, this.Commandargs, IntPtr.Zero, IntPtr.Zero, false, 516U, IntPtr.Zero, (string) null, ref lpStartupInfo, out lpProcessInformation))
        {
          int num9 = (int) MessageBox.Show("Cannot create process!");
        }
        else
        {
          this.thread = lpProcessInformation.hThread;
          uint lpflOldProtect1;
          Win32Apis.VirtualProtectEx(lpProcessInformation.hProcess, new IntPtr(num4), new UIntPtr((uint) num5), 64U, out lpflOldProtect1);
          UIntPtr lpNumberOfBytesWritten;
          Win32Apis.WriteProcessMemory(lpProcessInformation.hProcess, new IntPtr(num4 + num8), Encoding.ASCII.GetBytes("teknomw3.dll"), 13U, out lpNumberOfBytesWritten);
          uint lpflOldProtect2;
          Win32Apis.VirtualProtectEx(lpProcessInformation.hProcess, new IntPtr(num4), new UIntPtr((uint) num5), lpflOldProtect1, out lpflOldProtect2);
          if (lpNumberOfBytesWritten == (UIntPtr) 0U)
          {
            int num10 = (int) MessageBox.Show("Cannot write to process memory!");
            Win32Apis.TerminateProcess(lpProcessInformation.hProcess, 0U);
            Win32Apis.TerminateThread(lpProcessInformation.hThread, 0U);
          }
          else
          {
            this.mutex = new Mutex(false, "TeknoMW3" + (lpProcessInformation.dwProcessId ^ 87U).ToString("X8"));
            int num10 = (int) Win32Apis.ResumeThread(lpProcessInformation.hThread);
          }
        }
      }
    }
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Convertir de C# a Delphi

Publicado por Nacho (19 intervenciones) el 09/12/2016 10:14:05
Ya, no te queda más remedio que pasar un inline hook para un juego de c# a delphi. Haz un com con eso y lo usas desde delphi
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Convertir de C# a Delphi

Publicado por Yosley (3 intervenciones) el 09/12/2016 14:22:48
estaba pensando en hacer una dll en c# pa levanatarla desde delphi, pinchar?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Convertir de C# a Delphi

Publicado por Yosley (3 intervenciones) el 09/12/2016 17:27:07
ya rate de hacer la dll este es el codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
 
 
 
namespace TeknoMW3
{
    public partial class RunProc
    {
 
        private Mutex mutex;
        private IntPtr thread;
        internal RunProc Window;
 
 
 
        public string Commandargs { get; set; }
 
        public string ExecutableName { get; set; }
 
        public  RunProc(string exe, string parame)
 
        {
            ExecutableName = exe;
            Commandargs = parame;
 
            MessageBox.Show(ExecutableName);
            new Thread(new ThreadStart(this.threadi)).Start();
        }
 
        public static int BytesToInt(byte[] input)
        {
            return int.Parse(input[3].ToString("X2") + input[2].ToString("X2") + input[1].ToString("X2") + input[0].ToString("X2"), NumberStyles.HexNumber);
        }
 
        public static int IndexOf(byte[] arrayToSearchThrough, byte[] patternToFind)
        {
            if (patternToFind.Length > arrayToSearchThrough.Length)
                return -1;
            for (int index1 = 0; index1 < arrayToSearchThrough.Length - patternToFind.Length; ++index1)
            {
                bool flag = true;
                for (int index2 = 0; index2 < patternToFind.Length; ++index2)
                {
                    if ((int)arrayToSearchThrough[index1 + index2] != (int)patternToFind[index2])
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                    return index1;
            }
            return -1;
        }
 
        private static int Round1000(int a)
        {
            return (a / 4096 + (a % 4096 > 0 ? 1 : 0)) * 4096;
        }
 
 
 
 
 
 
 
        private void threadi()
        {
            STARTUPINFO lpStartupInfo = new STARTUPINFO();
            PROCESS_INFORMATION lpProcessInformation = new PROCESS_INFORMATION();
            byte[] arrayToSearchThrough = File.ReadAllBytes(this.ExecutableName);
            byte[] input1 = new byte[4];
            Array.Copy((Array)arrayToSearchThrough, 60, (Array)input1, 0, 2);
            byte[] input2 = new byte[4];
            int num1 = RunProc.BytesToInt(input1);
            int sourceIndex1 = num1 + 296;
            int sourceIndex2 = num1 + 300;
            int sourceIndex3 = num1 + 304;
            int sourceIndex4 = num1 + 308;
            Array.Copy((Array)arrayToSearchThrough, sourceIndex3, (Array)input2, 0, 4);
            int num2 = RunProc.BytesToInt(input2);
            Array.Copy((Array)arrayToSearchThrough, sourceIndex4, (Array)input2, 0, 4);
            int num3 = RunProc.BytesToInt(input2);
            Array.Copy((Array)arrayToSearchThrough, sourceIndex2, (Array)input2, 0, 4);
            int num4 = RunProc.BytesToInt(input2) + 4194304;
            Array.Copy((Array)arrayToSearchThrough, sourceIndex1, (Array)input2, 0, 4);
            int num5 = RunProc.Round1000(RunProc.BytesToInt(input2));
            int num6 = RunProc.IndexOf(arrayToSearchThrough, Encoding.ASCII.GetBytes("steam_api.dll"));
            if (num6 < num3 && num6 > num3 + num2)
            {
                int num7 = (int)MessageBox.Show("Cannot find steam_api.dll string in executable, make sure you have the proper original files!");
            }
            else
            {
                int num8 = num6 - num3;
                if (!Win32Apis.CreateProcess(this.ExecutableName, this.Commandargs, IntPtr.Zero, IntPtr.Zero, false, 516U, IntPtr.Zero, (string)null, ref lpStartupInfo, out lpProcessInformation))
                {
                    int num9 = (int)MessageBox.Show("Cannot create process!");
                }
                else
                {
                    this.thread = lpProcessInformation.hThread;
                    uint lpflOldProtect1;
                    Win32Apis.VirtualProtectEx(lpProcessInformation.hProcess, new IntPtr(num4), new UIntPtr((uint)num5), 64U, out lpflOldProtect1);
                    UIntPtr lpNumberOfBytesWritten;
                    Win32Apis.WriteProcessMemory(lpProcessInformation.hProcess, new IntPtr(num4 + num8), Encoding.ASCII.GetBytes("teknomw3.dll"), 13U, out lpNumberOfBytesWritten);
                    uint lpflOldProtect2;
                    Win32Apis.VirtualProtectEx(lpProcessInformation.hProcess, new IntPtr(num4), new UIntPtr((uint)num5), lpflOldProtect1, out lpflOldProtect2);
                    if (lpNumberOfBytesWritten == (UIntPtr)0U)
                    {
                        int num10 = (int)MessageBox.Show("Cannot write to process memory!");
                        Win32Apis.TerminateProcess(lpProcessInformation.hProcess, 0U);
                        Win32Apis.TerminateThread(lpProcessInformation.hThread, 0U);
                    }
                    else
                    {
                        this.mutex = new Mutex(false, "TeknoMW3" + (lpProcessInformation.dwProcessId ^ 87U).ToString("X8"));
                        int num10 = (int)Win32Apis.ResumeThread(lpProcessInformation.hThread);
                    }
                }
            }
        }
 
 
 
 
 
 
    }
}



Como puedo llamar la funcion RunProc(String exe, String parame) en delphi?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar