void NetRec() { try { byte[] buffer = new byte[BUFFER_SIZE]; byte[] data = new byte[BUFFER_LEN]; byte[] data2 = new byte[BUFFER_LEN2]; uint tmp; while (true) { sock.Receive(buffer); Array.Copy(buffer, 1, data, 0, BUFFER_LEN); Array.Copy(buffer, BUFFER_LEN + 1, data2, 0, BUFFER_LEN2); tmp = NET_ADDR + CAR_OFFSET * buffer[0]; mem.WriteByte(tmp, data, BUFFER_LEN); //Movement mem.WriteByte(tmp + CAR_DMG_OFFS, data2, BUFFER_LEN2); //Smoke } } catch (Exception e) { MessageBox.Show(e.Source + " - " + e.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); if (game != null && !game.HasExited) { game.Kill(); } Environment.Exit(0); } }
private void gkh_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F12) { if (mem == null) { if (MemoryEdit.Memory.IsProcessOpen("CMR5")) { mem = new MemoryEdit.Memory("CMR5", 0x001F0FFF); } } if (mem.ReadByte(0x00494916, 1) == 0x90) { code = BitConverter.GetBytes(opcode); snd.Stream = Properties.Resources.dis; } else { code = BitConverter.GetBytes(NOP); snd.Stream = Properties.Resources.eng; } snd.Play(); mem.WriteByte(0x00494916, code, 5); mem.WriteByte(0x00496626, code, 5); } }
void NetRec() { try { byte[] buffer = new byte[BUFFER_SIZE]; byte[] ped = new byte[BUFFER_PED]; byte[] veh = new byte[BUFFER_VEH]; float x, y, z; uint tmp; while (true) { sock.Receive(buffer); Array.Copy(buffer, 1, ped, 0, BUFFER_PED); Array.Copy(buffer, 1 + BUFFER_PED, veh, 0, BUFFER_VEH); if (buffer[0] >= id) { buffer[0]--; } //Ped x = BitConverter.ToSingle(ped, 0); if (x != 0) { y = BitConverter.ToSingle(ped, 4); z = BitConverter.ToSingle(ped, 8); if (GetDistance(ref x, ref y, ref z) > DD_PED) { continue; } tmp = (uint)(mem.Read(PTR_NET_PED) + OFS_NET_PED); mem.WriteByte(tmp + OFS_PED * buffer[0], ped, BUFFER_PED); continue; } //Vehicle x = BitConverter.ToSingle(veh, 0); if (x != 0) { y = BitConverter.ToSingle(veh, 4); z = BitConverter.ToSingle(veh, 8); if (GetDistance(ref x, ref y, ref z) > DD_VEH) { continue; } tmp = (uint)(mem.Read(PTR_NET_VEH) + OFS_NET_VEH); mem.WriteByte(tmp + OFS_VEH * (buffer[0] + 1u), veh, BUFFER_VEH); } } } catch (Exception e) { MessageBox.Show(e.Source + " - " + e.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); if (game != null && !game.HasExited) { game.Kill(); } Environment.Exit(0); } }
void bt_connect_Click(object sender, EventArgs e) { bt_connect.Enabled = false; tb_ip.Enabled = false; try { client = new TcpClient(tb_ip.Text, PORT); sw = new StreamWriter(FILE_IP, false, Encoding.Default); sw.Write(tb_ip.Text); sw.Close(); } catch (Exception ex) { MessageBox.Show(ex.Source + " - " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); bt_connect.Enabled = true; tb_ip.Enabled = true; return; } game = Process.Start(GAME_EXE); mem = new MemoryEdit.Memory(game, 0x001F0FFF); //V1.3 US PLAYER_ADDR = 0x00D86AB8; NET_ADDR = 0x00D86C00; TRAFFIC_ADDR = 0x00495EA9; MISSION_ADDR = 0x00570FF4; if (mem.ReadByte2(0x00571004) == 0x53) { //V1.2 US PLAYER_ADDR = (uint)(PLAYER_ADDR + OFFS_US12); NET_ADDR = (uint)(NET_ADDR + OFFS_US12); TRAFFIC_ADDR = 0x00495DB9; MISSION_ADDR = 0x00571004; } else if (mem.ReadByte2(0x00570FF4) != 0x53) { //V6.3w EU PLAYER_ADDR = (uint)(PLAYER_ADDR + OFFS_EU63); NET_ADDR = (uint)(NET_ADDR + OFFS_EU63); TRAFFIC_ADDR = 0x004951A9; MISSION_ADDR = 0x0056ED04; } //Disable Traffic mem.WriteByte(TRAFFIC_ADDR, ASM_MOV, ASM_MOV.Length); //Change mission script mem.WriteByte(MISSION_ADDR, ASCII_DIR, ASCII_DIR.Length); sock = client.Client; thd = new Thread(new ThreadStart(NetRec)); thd.Start(); thd2 = new Thread(new ThreadStart(NetSend)); thd2.Start(); }
void NetRec() { try { byte[] buffer = new byte[BUFFER_SIZE]; byte[] data = new byte[BUFFER_LEN]; while (true) { sock.Receive(buffer); Array.Copy(buffer, 1, data, 0, BUFFER_LEN); if (buffer[0] >= id) { buffer[0]--; } mem.WriteByte(NET_ADDR + CAR_OFFSET * buffer[0], data, BUFFER_LEN); } } catch (Exception e) { MessageBox.Show(e.Source + " - " + e.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); if (game != null && !game.HasExited) { game.Kill(); } Environment.Exit(0); } }
void Rec() { try { byte[] buffer = new byte[BUFFER_SIZE]; byte[] data = new byte[BUFFER_SIZE - GlobalInfo.BUFFER_DATA]; uint address, offset; int idx, len; Pointer ptr; while (true) { sock.Receive(buffer); if (buffer[0] >= id) { buffer[0]--; } idx = GlobalInfo.BUFFER_DATA; ptr = game_addrs[buffer[1]]; for (int adr = 0; adr < ptr.addresses.GetLength(1); adr++) { address = ptr.GetAddr(GlobalInfo.ADDR_NET, adr); offset = ptr.data[adr].adrr_offs; len = ptr.data[adr].data_len; Array.Copy(buffer, idx, data, 0, len); mem.WriteByte(address + offset * buffer[0], data, len); idx += len; } } } catch (Exception ex) { MsgBox(ex); if (game != null && !game.HasExited) { game.Kill(); } Environment.Exit(0); } }
void bt_connect_Click(object sender, EventArgs e) { bt_connect.Enabled = false; tb_ip.Enabled = false; try { byte[] buffer = new byte[1]; client = new TcpClient(tb_ip.Text, PORT); client.Client.Receive(buffer); id = buffer[0]; sw = new StreamWriter(lastip_file, false, Encoding.Default); sw.Write(tb_ip.Text); sw.Close(); } catch (Exception ex) { MessageBox.Show(ex.Source + " - " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); bt_connect.Enabled = true; tb_ip.Enabled = true; return; } game = Process.Start(game_exe); mem = new MemoryEdit.Memory(); while (!mem.Attach(game, 0x001F0FFF)) { ; } /*Movement not working properly * //Code injection * IntPtr tmp = mem.Allocate((uint)(movement_injection.Length + rotation_injection.Length)); * mem.WriteByte((uint)tmp, movement_injection, movement_injection.Length); * mem.WriteByte((uint)((uint)tmp + movement_injection.Length), movement2_injection, movement2_injection.Length); * mem.WriteByte((uint)((uint)tmp + movement_injection.Length + movement2_injection.Length), rotation_injection, rotation_injection.Length); * //Override movement * mem.WriteByte(movement_addr1, movement_ovrd, movement_ovrd.Length); * mem.WriteByte(movement_addr2, movement_ovrd, movement_ovrd.Length); * //Modify call * mem.WriteByte(movement_addr1 + offs_call, BitConverter.GetBytes(((uint)tmp - (movement_addr1 + offs_call + 4))), 4); * mem.WriteByte(movement_addr1 + offs_call2, BitConverter.GetBytes((((uint)tmp + movement_injection.Length) - (movement_addr1 + offs_call2 + 4))), 4); * // * mem.WriteByte(movement_addr2 + offs_call, BitConverter.GetBytes(((uint)tmp - (movement_addr2 + offs_call + 4))), 4); * mem.WriteByte(movement_addr2 + offs_call2, BitConverter.GetBytes((((uint)tmp + movement_injection.Length) - (movement_addr2 + offs_call2 + 4))), 4); * //Override rotation * mem.WriteByte(rotation_addr, rotation_ovrd, rotation_ovrd.Length); * //Modify call * mem.WriteByte(rotation_addr + offs_call, BitConverter.GetBytes((((uint)tmp + movement_injection.Length + movement2_injection.Length) - (rotation_addr + offs_call + 4))), 4); * //Code injection end */ //Code injection IntPtr tmp = mem.Allocate((uint)respawn_injection.Length); mem.WriteByte((uint)tmp, respawn_injection, respawn_injection.Length); //Override respawn mem.WriteByte(respawn_addr, respawn_ovrd, respawn_ovrd.Length); //Modify jmp mem.WriteByte(respawn_addr + offs_jmp0, BitConverter.GetBytes((uint)tmp - (respawn_addr + offs_jmp0 + 4)), 4); mem.WriteByte((uint)tmp + offs_jmp1, BitConverter.GetBytes(respawn3_addr - ((uint)tmp + offs_jmp1 + 4)), 4); mem.WriteByte((uint)tmp + offs_jmp2, BitConverter.GetBytes(respawn3_addr - ((uint)tmp + offs_jmp2 + 4)), 4); mem.WriteByte((uint)tmp + offs_jmp3, BitConverter.GetBytes(respawn2_addr - ((uint)tmp + offs_jmp3 + 4)), 4); //Code injection end sock = client.Client; thd = new Thread(new ThreadStart(NetRec)); thd.Start(); thd2 = new Thread(new ThreadStart(NetSend)); thd2.Start(); }
void bt_connect_Click(object sender, EventArgs e) { bt_connect.Enabled = false; tb_ip.Enabled = false; try { byte[] buffer = new byte[1]; client = new TcpClient(tb_ip.Text, PORT); client.Client.Receive(buffer); id = buffer[0]; sw = new StreamWriter(lastip_file, false, Encoding.Default); sw.Write(tb_ip.Text); sw.Close(); } catch (Exception ex) { MessageBox.Show(ex.Source + " - " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); bt_connect.Enabled = true; tb_ip.Enabled = true; return; } game = Process.Start(game_exe); mem = new MemoryEdit.Memory(); while (!mem.Attach(game, 0x001F0FFF)) { ; } //Code injection uint addr; IntPtr tmp = mem.Allocate((uint)inj_ptr_trc.Length); mem.WriteByte((uint)tmp, inj_ptr_trc, inj_ptr_trc.Length); //Pointer reset addr = 0x00448380; mem.WriteByte(addr, inj_ptr_res, inj_ptr_res.Length); mem.WriteByte(addr + 1, BitConverter.GetBytes((uint)tmp - (addr + LEN_JMP)), 4); //Ped pointer addr = 0x0050149B; mem.WriteByte(addr, inj_ptr_ped, inj_ptr_ped.Length); mem.WriteByte(addr + 3, BitConverter.GetBytes(((uint)tmp + inj_ofs_ped) - (addr + 2 + LEN_JMP)), 4); //Car pointer addr = 0x004E24C3; mem.WriteByte(addr, inj_ptr_car, inj_ptr_car.Length); mem.WriteByte(addr + 1, BitConverter.GetBytes(((uint)tmp + inj_ofs_car) - (addr + LEN_JMP)), 4); //JMP mem.WriteByte((uint)tmp + offs_jmp[0], BitConverter.GetBytes(0x00448386 - ((uint)tmp + offs_jmp[0] + 4)), 4); mem.WriteByte((uint)tmp + offs_jmp[1], BitConverter.GetBytes(0x005014A3 - ((uint)tmp + offs_jmp[1] + 4)), 4); mem.WriteByte((uint)tmp + offs_jmp[2], BitConverter.GetBytes(0x004E24C9 - ((uint)tmp + offs_jmp[2] + 4)), 4); //JNP mem.WriteByte((uint)tmp + offs_jnp, BitConverter.GetBytes(0x0050171F - ((uint)tmp + offs_jnp + 4)), 4); //CMP, MOV PTR_NET_PED = (uint)((uint)tmp + inj_ptr_trc.Length); PTR_NET_VEH = PTR_NET_PED + 4; mem.WriteByte((uint)tmp + offs_cmp[0], BitConverter.GetBytes(PTR_NET_PED), 4); mem.WriteByte((uint)tmp + offs_cmp[1], BitConverter.GetBytes(PTR_NET_VEH), 4); mem.WriteByte((uint)tmp + offs_cmp[2], BitConverter.GetBytes(PTR_NET_PED), 4); mem.WriteByte((uint)tmp + offs_cmp[3], BitConverter.GetBytes(PTR_NET_PED), 4); mem.WriteByte((uint)tmp + offs_cmp[4], BitConverter.GetBytes(PTR_NET_VEH), 4); mem.WriteByte((uint)tmp + offs_cmp[5], BitConverter.GetBytes(PTR_NET_VEH), 4); //Code injection end sock = client.Client; thd = new Thread(new ThreadStart(NetRec)); thd.Start(); thd2 = new Thread(new ThreadStart(NetSend)); thd2.Start(); }