|
|
|
@ -9,53 +9,61 @@ using System.Net.Sockets; |
|
|
|
|
using System.Runtime.InteropServices; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Text.RegularExpressions; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.Timers; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
|
|
|
|
|
namespace rabiribi_splitter |
|
|
|
|
{ |
|
|
|
|
public partial class Form1 : Form |
|
|
|
|
{ |
|
|
|
|
[DllImport("kernel32.dll")] |
|
|
|
|
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); |
|
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll")] |
|
|
|
|
public static extern bool ReadProcessMemory(int hProcess, |
|
|
|
|
int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead); |
|
|
|
|
|
|
|
|
|
const int PROCESS_WM_READ = 0x0010; |
|
|
|
|
|
|
|
|
|
private static TcpClient tcpclient; |
|
|
|
|
private static NetworkStream networkStream; |
|
|
|
|
private static System.Threading.Timer timer; |
|
|
|
|
// private int MapAddress = 0xA3353C; |
|
|
|
|
// private int PtrAddr = 0x00940EE0; |
|
|
|
|
// private int EnitiyOffset = 0x4e4; |
|
|
|
|
// private int EntitySize = 0x6F4; |
|
|
|
|
// private int MaxEntityEntry = 50; |
|
|
|
|
private static System.Timers.Timer timer; |
|
|
|
|
private bool bossbattle = false; |
|
|
|
|
private int bossmusicid; |
|
|
|
|
private int lastmusicid; |
|
|
|
|
private Regex titleReg = new Regex(@"ver.*?(\d+\.?\d+.*)$"); |
|
|
|
|
private Thread memoryThread; |
|
|
|
|
private int lastmoney; |
|
|
|
|
private bool rabiribiready; |
|
|
|
|
private string rabiribititle; |
|
|
|
|
private string rabiver; |
|
|
|
|
private int veridx; |
|
|
|
|
public Form1() |
|
|
|
|
{ |
|
|
|
|
InitializeComponent(); |
|
|
|
|
timer = new System.Threading.Timer(readmemory, null, 0, 10); |
|
|
|
|
|
|
|
|
|
memoryThread=new Thread(() => |
|
|
|
|
{ |
|
|
|
|
while (true) |
|
|
|
|
{ |
|
|
|
|
readmemory(); |
|
|
|
|
Thread.Sleep(10); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
memoryThread.IsBackground = true; |
|
|
|
|
memoryThread.Start(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void readmemory(object state) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void readmemory() |
|
|
|
|
{ |
|
|
|
|
string rabiver=""; |
|
|
|
|
|
|
|
|
|
var processlist = Process.GetProcessesByName("rabiribi"); |
|
|
|
|
if (processlist.Length > 0) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
Process process = processlist[0]; |
|
|
|
|
if (process.MainWindowTitle != rabiribititle) |
|
|
|
|
{ |
|
|
|
|
var result = titleReg.Match(process.MainWindowTitle); |
|
|
|
|
if (result.Success) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
rabiver = result.Groups[1].Value; |
|
|
|
|
if (!StaticData.VerNames.Contains(rabiver)) |
|
|
|
|
veridx = Array.IndexOf(StaticData.VerNames, rabiver); |
|
|
|
|
if (veridx < 0) |
|
|
|
|
{ |
|
|
|
|
this.Invoke(new Action(() => |
|
|
|
|
{ |
|
|
|
@ -67,9 +75,12 @@ namespace rabiribi_splitter |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
veridx = -1; |
|
|
|
|
this.Invoke(new Action(() => |
|
|
|
|
{ |
|
|
|
|
rbStatus.Text = rabiver + " Running (not support)"; |
|
|
|
@ -78,65 +89,98 @@ namespace rabiribi_splitter |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.Invoke(new Action(() => rbStatus.Text = rabiver + " Running")); |
|
|
|
|
int addr = StaticData.MusicAddr[rabiver]; |
|
|
|
|
byte[] buffer = new byte[4] {0, 0, 0, 0}; |
|
|
|
|
int bytesRead = 0; |
|
|
|
|
IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id); |
|
|
|
|
ReadProcessMemory((int) processHandle, process.MainModule.BaseAddress.ToInt32() + addr, buffer, |
|
|
|
|
4, ref bytesRead); |
|
|
|
|
if (buffer[0] < StaticData.MusicNames.Length) |
|
|
|
|
rabiribititle = process.MainWindowTitle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (veridx < 0) return; |
|
|
|
|
|
|
|
|
|
#region CheckMoney |
|
|
|
|
|
|
|
|
|
if (cbComputer.Checked) |
|
|
|
|
{ |
|
|
|
|
var newmoney = MemoryHelper.GetMemoryValue<int>(process, StaticData.MoneyAddress[veridx]); |
|
|
|
|
if (newmoney - lastmoney == 17500) |
|
|
|
|
{ |
|
|
|
|
sendsplit(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
lastmoney = newmoney; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
int musicid = BitConverter.ToInt32(buffer,0); |
|
|
|
|
#region Music |
|
|
|
|
|
|
|
|
|
int musicaddr = StaticData.MusicAddr[veridx]; |
|
|
|
|
int musicid = MemoryHelper.GetMemoryValue<int>(process, musicaddr); |
|
|
|
|
if (musicid < StaticData.MusicNames.Length) |
|
|
|
|
{ |
|
|
|
|
if (lastmusicid != musicid) |
|
|
|
|
{ |
|
|
|
|
this.Invoke(new Action(() => this.musicLabel.Text = StaticData.MusicNames[musicid])); |
|
|
|
|
|
|
|
|
|
var flag = StaticData.BossMusics.Contains(musicid); |
|
|
|
|
if (flag) |
|
|
|
|
var bossmusicflag = StaticData.BossMusics.Contains(musicid); |
|
|
|
|
if (bossmusicflag) |
|
|
|
|
{ |
|
|
|
|
if (bossmusicid > 0 && bossmusicid != musicid) |
|
|
|
|
if (bossbattle) |
|
|
|
|
{ |
|
|
|
|
//直接换boss曲 |
|
|
|
|
if (cbBossStart.Checked || cbBossEnd.Checked) |
|
|
|
|
{ |
|
|
|
|
sendsplit(); |
|
|
|
|
} |
|
|
|
|
bossbattle = true; |
|
|
|
|
|
|
|
|
|
this.Invoke(new Action(() => cbBoss.Checked = bossbattle)); |
|
|
|
|
bossmusicid = musicid; |
|
|
|
|
lastmusicid = musicid; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (flag != bossbattle) |
|
|
|
|
if (!bossbattle) |
|
|
|
|
{ |
|
|
|
|
if (flag) |
|
|
|
|
if (bossmusicflag) //boss music start! |
|
|
|
|
{ |
|
|
|
|
bossbattle = true; |
|
|
|
|
if (cbBossStart.Checked) |
|
|
|
|
{ |
|
|
|
|
sendsplit(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
bossmusicid = musicid; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
} |
|
|
|
|
if (bossbattle) |
|
|
|
|
{ |
|
|
|
|
if (!bossmusicflag) //boss music end! |
|
|
|
|
{ |
|
|
|
|
bossbattle = false; |
|
|
|
|
if (cbBossEnd.Checked) |
|
|
|
|
{ |
|
|
|
|
sendsplit(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bossbattle = flag; |
|
|
|
|
this.Invoke(new Action(() => cbBoss.Checked = bossbattle)); |
|
|
|
|
lastmusicid = musicid; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
this.Invoke(new Action(() => this.musicLabel.Text = "N/A")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion Music |
|
|
|
|
|
|
|
|
|
#region SpecialBOSS |
|
|
|
|
|
|
|
|
|
#endregion SpecialBOSS |
|
|
|
|
|
|
|
|
|
this.Invoke(new Action(() => cbBoss.Checked = bossbattle)); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
rabiribititle = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Invoke(new Action(() => |
|
|
|
|
{ |
|
|
|
|
rbStatus.Text = "Not Found"; |
|
|
|
|