Besoin d'aide pour convertir du code C en C++ (Write Process Memory)
Bonjour à tous,
Comme dis dans le titre, j'ai besoin d'aide car j'ai du code en C et j'aurais besoin de le convertir en C++ sauf que ça fais 2 jours que je bloque...
C'est pour ecrire dans la memoire du pc (write process memory). Je suis même prêt a payer si quelqu'un peux m'aider.
Je ne sais pas si c'est la bonne section pour demander de l'aide?
j'aurais besoin de convertir:
Code:
1 2 3 4
| public void WriteArray(int Pointer, string Value)
{
m.WriteMemory((Pointer).ToString("x"), "bytes", Value);
} |
Code:
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
| public bool WriteMemory(string code, string type, string write, string file = "", Encoding stringEncoding = null, bool RemoveWriteProtection = true)
{
byte[] array = new byte[4];
int num = 4;
UIntPtr code2 = GetCode(code, file);
if (code2 == UIntPtr.Zero || code2.ToUInt64() < 65536)
{
return false;
}
if (type.ToLower() == "float")
{
write = Convert.ToString(float.Parse(write, CultureInfo.InvariantCulture));
array = BitConverter.GetBytes(Convert.ToSingle(write));
num = 4;
}
else if (type.ToLower() == "int")
{
array = BitConverter.GetBytes(Convert.ToInt64(write));
num = 4;
}
else if (type.ToLower() == "byte")
{
array = new byte[1] { Convert.ToByte(write, 16) };
num = 1;
}
else if (type.ToLower() == "2bytes")
{
array = new byte[2]
{
(byte)(Convert.ToInt32(write) % 256),
(byte)(Convert.ToInt32(write) / 256)
};
num = 2;
}
else if (type.ToLower() == "bytes")
{
if (write.Contains(",") || write.Contains(" "))
{
string[] array2 = ((!write.Contains(",")) ? write.Split(' ') : write.Split(','));
int num2 = array2.Count();
array = new byte[num2];
for (int i = 0; i < num2; i++)
{
array[i] = Convert.ToByte(array2[i], 16);
}
num = array2.Count();
}
else
{
array = new byte[1] { Convert.ToByte(write, 16) };
num = 1;
}
}
else if (type.ToLower() == "double")
{
array = BitConverter.GetBytes(Convert.ToDouble(write));
num = 8;
}
else if (type.ToLower() == "long")
{
array = BitConverter.GetBytes(Convert.ToInt64(write));
num = 8;
}
else if (type.ToLower() == "string")
{
array = ((stringEncoding != null) ? stringEncoding.GetBytes(write) : Encoding.UTF8.GetBytes(write));
num = array.Length;
}
Imps.MemoryProtection oldProtection = (Imps.MemoryProtection)0u;
bool flag = false;
if (RemoveWriteProtection)
{
ChangeProtection(code, Imps.MemoryProtection.ExecuteReadWrite, out oldProtection, file);
}
flag = Imps.WriteProcessMemory(mProc.Handle, code2, array, (UIntPtr)(ulong)num, IntPtr.Zero);
if (RemoveWriteProtection)
{
ChangeProtection(code, oldProtection, out var _, file);
}
return flag;
} |
Code:
WriteArray(obj + 0xc1781, "B1 0" + Convert.ToInt32(nmKill.Text).ToString("X") + " 00 00 00");
Infos: nmKill.Text = listbox dynamic qui donne les infos des joueurs en jeux