public static bool DoInjection(string DllPath, IntPtr hwnd) { IntPtr hProcess = LoadDll.GetHwndProcess(hwnd); byte[] dllBytes = System.Text.Encoding.Default.GetBytes(DllPath); int BufSize = dllBytes.Length; IntPtr AllocAddr = VirtualAllocEx(hProcess, 0, BufSize, AllocationType.MEM_COMMIT, 0x04); LoadDll.WriteProcessMemory(hProcess, AllocAddr, dllBytes, BufSize, IntPtr.Zero); IntPtr pfnStartAddr = GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA"); IntPtr hRemoteThread = CreateRemoteThread(hProcess, 0, 0, pfnStartAddr, AllocAddr, 0, 0); // 等待远线程结束 WaitForSingleObject(hRemoteThread, 0xFFFFFFFF); // 取DLL在目标进程的句柄 int remoteModule = 0; GetExitCodeThread(hRemoteThread, ref remoteModule); LoadDll.Free(hProcess, hRemoteThread, AllocAddr); return(hRemoteThread.ToInt32() > 0); }
public static void clickWin(int hwnd, int x, int y) { IntPtr wnd = (IntPtr)hwnd; //int lx = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.ls, 0x64); //int ly = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.ls, 0x68); //double xx = (x - lx) * 0.92; //double yy = (y - ly) * 0.92; //int dx = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.bX); //int dy = LoadDll.ReadHwndMemoryOffsetValue(wnd, new IntPtr(Global.addr.bX + 4).ToInt32()); //int x1 = (int)xx + dx; //int y1 = (int)yy + dy; MouseMove(hwnd, x, y); //LoadDll.WriteMemoryHwndValue(wnd, Global.addr.bX, BitConverter.GetBytes(x1)); //LoadDll.WriteMemoryHwndValue(wnd, new IntPtr(Global.addr.bX + 4).ToInt32(), BitConverter.GetBytes(y1)); // 写入单击事件 LoadDll.WriteMemoryHwndValue(wnd, new IntPtr(Global.addr.bX - 8).ToInt32(), BitConverter.GetBytes(1)); System.Threading.Thread.Sleep(80); LoadDll.WriteMemoryHwndValue(wnd, new IntPtr(Global.addr.bX - 8).ToInt32(), BitConverter.GetBytes(0)); }
public static List <bean.Goods> itBag(int hwnd) { List <bean.Goods> goods = new List <bean.Goods>(); int addr = readBag(hwnd)[0]; for (int i = 0; i < 20; i++) { int addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addr + (i + 1) * 12); addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x40); addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x8); addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x8); addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x14); addrFlag = ReadOffset(hwnd, addrFlag); addrFlag = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0xC); int addrType = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x24); int addrNum = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x30); int addrID = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrFlag + 0x3C); int id = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrID + 0x8); int type = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrType + 0x8); int count = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addrNum + 0x8); if (id > 0) { goods.Add(new bean.Goods(id, type, count, i)); } } return(goods); }
public void registerFlight(int goodsID) { string cmd = ""; //注册读取飞行棋坐标信息 ex.RegMsgCallBack(0x3B, new MsgCallBack(false, delegate(int msgType, byte[] data) { //3B 3A 00 0D if (data[3] == 0x0D) { int mid = BitConverter.ToInt16(new byte[] { data[8], data[9] }, 0); if (mapID == mid) { int point = readAxis(data, this.toAxis); //发送飞行指令 cmd = "3B 07 0F {0} {1} 00"; cmd = String.Format(cmd, StringUtil.FormatIntToHexStyle(goodsID, true).Trim(), StringUtil.FormatIntToHexStyle(point, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); } } }, true, null)); //注册飞行棋使用信息 ex.RegMsgCallBack(0x37, new MsgCallBack(false, delegate(int msgType, byte[] data) { //37 04 00 C6 D4 27 40 if (data[1] == 0x04 && data[2] == 0x00) { int gid = BitConverter.ToInt32(new byte[] { data[3], data[4], data[5], data[6] }, 0); cmd = "33 05 {0} 00"; cmd = String.Format(cmd, StringUtil.FormatIntToHexStyle(gid, true).Trim()); //回应服务器已经到了 LoadDll.sendMsg((IntPtr)hwnd, cmd); } }, true, null)); }
public int getPID() { IntPtr pid = IntPtr.Zero; LoadDll.GetWindowThreadProcessId((IntPtr)this.hwnd, out pid); return(pid.ToInt32()); }
/// <summary> /// 获取屏幕大小 /// </summary> /// <param name="hwnd"></param> /// <returns></returns> public int[] GetMhxyScreen(int hwnd) { int[] ret = new int[2]; ret[0] = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, Screen); ret[1] = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, Screen + 4); return(ret); }
/// <summary> /// 鼠标移动 /// </summary> /// <param name="hwnd"></param> /// <param name="x"></param> /// <param name="y"></param> public static void MouseMove(int hwnd, int x, int y) { int x1 = Global.addr.bX - 4 ^ x; int y1 = Global.addr.bY - 12 ^ y; LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, Global.addr.bX, BitConverter.GetBytes(x1)); LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, Global.addr.bY, BitConverter.GetBytes(y1)); }
/// <summary> /// 隐藏验证窗口 /// </summary> /// <param name="hwnd"></param> public static void HideCheckWin(int hwnd) { int tmpPtr = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x04, 0x68); tmpPtr = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, tmpPtr) + 0x28; LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, tmpPtr, BitConverter.GetBytes(1)); }
/// <summary> /// 隐藏或者显示全部UI /// </summary> /// <param name="hwnd"></param> public static void UIShowStatus(int hwnd, bool show) { int UI = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8) + 0x28; //0显示 1隐藏 int s = show == true ? 0 : 1; show = LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, UI, BitConverter.GetBytes(s)); }
public int hookWay; //寻路钩子 public int GetPeopleID(int hwnd) { string str = LoadDll.GetWindowsName((IntPtr)hwnd).Replace(" ", ""); int start = str.LastIndexOf("[") + 1; int end = str.LastIndexOf("]"); str = str.Substring(start, end - start); return(Convert.ToInt32(str)); }
// группа пользователя из списка сотрудников (Шифр_отдела: АР, КР-МН, КР-СБ, ВК, ОВ, и т.д.) private static string getUserGroupFromServer(string pathToList) { string nameGroup = ""; // Определение группы по файлу списка пользователей на сервере try { var epplusDll = Path.Combine(_curDllLocation, "EPPlus.dll"); LoadDll.LoadTry(epplusDll); // Копирование файла списка пользователей string fileTemp = Path.GetTempFileName(); File.Copy(pathToList, fileTemp, true); using (var xlPackage = new ExcelPackage(new FileInfo(fileTemp))) { var worksheet = xlPackage.Workbook.Worksheets[1]; int numberRow = 2; while (worksheet.Cells[numberRow, 2].Text.Trim() != "") { if (worksheet.Cells[numberRow, 2].Text.Trim().ToUpper() == Environment.UserName.ToUpper()) { nameGroup = worksheet.Cells[numberRow, 3].Text; break; } numberRow++; } } } catch (Exception ex) { Log.Error(ex, $"Ошибка определена рабочей группы по файлу '{pathToList}'."); } if (string.IsNullOrEmpty(nameGroup)) { Log.Error($"Не определена рабочая группа по файлу UserGroup2.xlsx. {pathToList}"); // проверка была ли группа сохранена ранее в реестре nameGroup = loadUserGroupFromRegistry(); if (string.IsNullOrEmpty(nameGroup)) { // Определение группы по текущим папкам настроек nameGroup = getCurrentGroupFromLocal(); if (string.IsNullOrEmpty(nameGroup)) { Log.Error($"Не определена рабочая группа (Шифр отдела). {Environment.UserName}"); throw new Exception("IsNullOrEmpty(nameGroup)"); } } } else { saveUserGroupToRegistry(nameGroup); } Log.Info($"{Environment.UserName} Группа - {nameGroup}"); return(nameGroup); }
public static void CallDialog(int hwnd, int option, int type) { //获取对话框的x,y起点 int x = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, 0, 0x8); int y = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, 0, 0xC); //点击点位的x,y double nx = x + 86; double ny = y + 48; clickWin(hwnd, (int)nx, (int)ny); }
/// <summary> /// 读取人物面板属性 /// </summary> /// <param name="hwnd"></param> public static bean.AttrsPanel ReadAttrsPanel(int hwnd) { IntPtr wnd = (IntPtr)hwnd; bean.AttrsPanel attr = new bean.AttrsPanel(); int offset = 0; for (int i = 0; i < 100; i++) { int addr = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0x00); int x = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0x8); int y = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xc); //人物气血 if (x == 582 && y == 5 && attr.peopleHP == 0) { attr.peopleHP = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } //人物蓝 if (x == 582 && y == 17 && attr.peopleMP == 0) { attr.peopleMP = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } //人物怒气 if (x == 582 && y == 29 && attr.anger == 0) { attr.anger = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } if (x == 582 && y == 41 && attr.peopleExp == 0) { attr.peopleExp = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } //宠物血 if (x == 462 && y == 5 && attr.bbHP == 0) { attr.bbHP = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } //宠物蓝 if (x == 462 && y == 17 && attr.bbMP == 0) { attr.bbMP = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } //宝宝经验 if (x == 462 && y == 29 && attr.bbExp == 0) { attr.bbExp = LoadDll.ReadHwndMemoryOffsetValue(wnd, Global.addr.win, 0x68, 0x8, 0x68, offset, 0xF4) / 10; } offset += 4; } return(attr); }
/// <summary> /// 任务点击 /// </summary> /// <param name="hwnd"></param> /// <param name="x"></param> /// <param name="y"></param> public static void taskClick(int hwnd, int x, int y) { Global.mouseMx.WaitOne(); //获取窗口焦点 LoadDll.SetForegroundWindow((IntPtr)hwnd); //设置窗口显示状态 LoadDll.SetWindowPos((IntPtr)hwnd, -2, 0, 0, 0, 0, 3); System.Threading.Thread.Sleep(1500); MouseMove(hwnd, x, y); // 写入单击事件 LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, new IntPtr(Global.addr.bX - 8).ToInt32(), BitConverter.GetBytes(1)); System.Threading.Thread.Sleep(80); LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, new IntPtr(Global.addr.bX - 8).ToInt32(), BitConverter.GetBytes(0)); Global.mouseMx.ReleaseMutex(); }
/// <summary> /// 获得角色名称 /// </summary> /// <param name="hwnd"></param> /// <returns></returns> public static string GetMHName(int hwnd) { //加载角色名称 string str = LoadDll.GetWindowsName((IntPtr)hwnd).Replace(" ", ""); int start = str.LastIndexOf("-") + 1; if (start == 0) { return("mh"); } int end = str.LastIndexOf("["); str = str.Substring(start, end - start); return(str); }
/// <summary> /// 关闭对话 /// </summary> /// <param name="hwnd"></param> public static void CloseDia(int hwnd) { for (int i = 0; i < 10; i++) { int show = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, (i * 4), 0x28); int type = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, (i * 4), 0x18); if (show == 0) { if (type == 641 || type == 579 || type == 465 || type == 544 || type == 550 || type == 278 || type == 370 || type == 290 || type == 641 || type == 581 || type == 544 || type == 425 || type == 360 || type == 362 || type == 190 || type == 500 || type == 560 || type == 410) { int addr = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, (i * 4)) + 0x28; LoadDll.WriteMemoryHwndValue((IntPtr)hwnd, addr, BitConverter.GetBytes(1)); } } } }
/// <summary> /// 发货 /// </summary> public void sendDelivery(int t) { if (t == 1) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3001); //镖货的种类ID if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3002); } if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3003); } if (biaoID == 0) { biaoID = mhxy.CallFunc.GetBagTypeID(hwnd, 3004); } //封包发货 if (biaoID > 0) { string cmd = String.Format("33 05 {0} 00", StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); //先发包告诉是手动给予 LoadDll.sendMsg((IntPtr)hwnd, cmd); System.Threading.Thread.Sleep(1500); //物品ID1075273487->0F 5F 17 40 //FA 0C 16 00 00 00 D4 01 00 0F 5F 17 40 00 cmd = String.Format("FA 0C 16 00 00 00 D4 01 00 {0} 00", StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); Log.WriteLine("发送货物给NPC:{0}", cmd); } } if (t == 2 && biaoID > 0) { string cmd = String.Format("89 18 {0} {1} 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", StringUtil.FormatIntToHexStyle(NPC_ID, true).Trim(), StringUtil.FormatIntToHexStyle(biaoID, true).Trim()); LoadDll.sendMsg((IntPtr)hwnd, cmd); Log.WriteLine("收到回应,发出确认:{0}", cmd); //交货结束 is_play = false; System.Threading.Thread.Sleep(3000); toChangAn(); Log.WriteLine("回到长安找郑镖头!"); } }
/// <summary> /// 获取梦幻西游的全部句柄信息 /// </summary> /// <returns></returns> public static Dictionary <IntPtr, string> GetMHWindows() { Dictionary <IntPtr, string> wins = new Dictionary <IntPtr, string>(); IntPtr ws = LoadDll.FindWindow(Global.mh_class, null); if (ws.ToInt32() > 0) { wins[ws] = LoadDll.GetWindowsName(ws); while (ws.ToInt32() > 0) { ws = LoadDll.FindWindowEx(IntPtr.Zero, ws, Global.mh_class, null); if (ws.ToInt32() > 0) { wins[ws] = LoadDll.GetWindowsName(ws); } } } return(wins); }
/// <summary> /// 游戏过出口 /// </summary> /// <param name="hwnd">句柄</param> /// <param name="x">出口X</param> /// <param name="y">出口Y</param> /// <returns></returns> public static int[] MhxyToExit(int hwnd, int x, int y) { int[] ret = new int[2]; int mapY = Global.addr.GetMapY(hwnd); //屏幕宽高 int[] scr = Global.addr.GetMhxyScreen(hwnd); //目的地址坐标 int s_x = x * 20 + 10; int s_y = mapY - ((y * 20) + 10); //////计算两点的距离 //int[] xy = Global.addr.getPeopleXY(hwnd); ////换算为原始坐标 //int p_x = xy[0] * 20 + 10; //int p_y = mapY - ((xy[1] * 20) + 10); //拿到渲染的中心点,计算显示区域 int c_x = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.MapAddr, 0xCC); int c_y = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.MapAddr, 0xD0); int x_min = c_x - scr[0] / 2; int x_max = c_x + scr[0] / 2; int y_min = c_y - scr[1] / 2; int y_max = c_y + scr[1] / 2; // Log.WriteLine("屏幕区间坐标【{0},{1}】,【{2},{3}】", x_min, y_min, x_max, y_max); //鼠标点击该坐标 Log.WriteLine("过出口【{0},{1}】", x, y); // Log.WriteLine("当前【{0},{1}】,目标地址【{2},{3}】", p_x, p_y, s_x, s_y); //关闭对话框 CloseDia(hwnd); UIShowStatus(hwnd, false); System.Threading.Thread.Sleep(300); CallFunc.clickWin(hwnd, s_x - x_min, s_y - y_min); System.Threading.Thread.Sleep(200); UIShowStatus(hwnd, true); return(ret); }
/// <summary> /// 申请内存 /// </summary> /// <param name="hwnd"></param> /// <returns></returns> public static IntPtr MallocMemory(IntPtr hwnd, int size) { IntPtr pid = IntPtr.Zero; //获取窗口句柄 LoadDll.GetWindowThreadProcessId(hwnd, out pid); //获取进程句柄 IntPtr prohWnd = LoadDll.OpenProcess(0x1F0FFF, false, pid.ToInt32()); if (prohWnd != IntPtr.Zero) { //执行VirtualProtectEx函数 IntPtr addr = VirtualAllocEx(prohWnd, 0, size, AllocationType.MEM_COMMIT, 64); LoadDll.CloseHandle(prohWnd); return(addr); } return(IntPtr.Zero); }
/// <summary> /// 获得地图最大的XY坐标 /// 第一个是x /// 第二个是y /// </summary> /// <param name="hwnd"></param> /// <returns></returns> public int[] GetMapMaxXY(int hwnd) { int[] xy = new int[2]; IntPtr pid = IntPtr.Zero; LoadDll.GetWindowThreadProcessId((IntPtr)hwnd, out pid); byte[] buffer = new byte[4]; IntPtr byteAddress = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); IntPtr hProcess = LoadDll.OpenProcess(0x1F0FFF, false, pid.ToInt32()); //读取x坐标上限 xy[0] = LoadDll.ReadMemoryOffsetValue(pid.ToInt32(), MapAddr, 0x60, 0x10); //读取y坐标上限 xy[1] = LoadDll.ReadMemoryOffsetValue(pid.ToInt32(), MapAddr, 0x60, 0x14); //日狗的游戏算法*20 xy[0] = (int)(xy[0] / 20); xy[1] = (int)(xy[1] / 20); //换算游戏坐标 return(xy); }
public static int ReadOffset(int hwnd, int addr) { int offset = 1364; for (int i = 0; i < 2; i++) { if (i == 1) { offset = 92; } int addr1 = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addr + offset); int addr2 = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addr1 + 12); addr2 = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addr2 + 60); addr2 = LoadDll.ReadHwndMemoryValue((IntPtr)hwnd, addr2 + 8); if (addr2 > 1000000000 && addr2 < 1200000000) { return(addr1); } } return(0); }
/// <summary> /// 飞到城市 /// </summary> /// <returns></returns> public bool GoToCity() { List <bean.Goods> goods = mhxy.CallFunc.itBag(hwnd); for (int i = 0; i < goods.Count; i++) { if (goods[i].type == 673 && flag == false) { string cmd = String.Format("32 09 {0} 00 00 00 00 00", StringUtil.FormatIntToHexStyle(goods[i].id, true).Trim()); int goodsID = goods[i].id; registerFlight(goodsID); //发送飞行棋指令 LoadDll.sendMsg((IntPtr)hwnd, cmd); flag = true; } //System.Threading.Thread.Sleep(3000); } return(false); }
//气血检测线程 public override void AddHPMP(IntPtr hwnd) { if (Global.mh_cfg[hwnd].hp_mp_auto == 0) { return; } bean.AttrsPanel attr = mhxy.CallFunc.ReadAttrsPanel(hwnd.ToInt32()); if (attr.peopleMP < Global.mh_cfg[hwnd].mp) { Log.WriteLine("人物加满蓝"); //蓝加满 LoadDll.sendMsg(hwnd, "35 06 00 00 00 00 02 00"); } if (attr.peopleHP < Global.mh_cfg[hwnd].hp) { //血加满 Log.WriteLine("人物加满气血"); LoadDll.sendMsg(hwnd, "35 06 00 00 00 00 01 00"); } }
/// <summary> /// 接货 /// </summary> public void recvDelivery() { //注册,一级对话回复被打开 //FA 47 01 3E 00 00 00 05 ex.RegMsgCallBack(0xFA, new MsgCallBack(false, delegate(int msgType, byte[] data) { CallNPCOpen = true; System.Threading.Thread.Sleep(1000); regBiao(); bean.Axis ax = mhxy.CallFunc.ReadDialogOption(hwnd, goodsLv); mhxy.CallFunc.taskClick(hwnd, ax.x, ax.y); }, true, new Dictionary <int, int>() { { 3, 0x3E }, { 4, 0x00 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x05 } })); //打开郑镖头对话框 while (!CallNPCOpen) { mxCheck.WaitOne(); string cmd = mhxy.CallNPC.GetNpcDialog(536871314, 0, 0); LoadDll.sendMsg((IntPtr)hwnd, cmd); mxCheck.ReleaseMutex(); Log.WriteLine("NPC郑镖头放锁"); System.Threading.Thread.Sleep(4000); } //判断身上有没有货物,如果没有继续回调 System.Threading.Thread.Sleep(20000); if (GetBiaoYinID() == 0) { recvDelivery(); } }
//延迟发送 void delaySend() { if (prevFunc != null) { this.prevFunc(); } if (random) { Random r = new Random(); int m = r.Next(s, e); System.Threading.Thread.Sleep(m * 1000); } else { System.Threading.Thread.Sleep(s * 1000); } LoadDll.sendMsg((IntPtr)hwnd, cmd); if (lastFunc != null) { this.lastFunc(); } Log.WriteLine("延迟发送报文:{0}", cmd); }
/// <summary> /// 返回人物坐标 /// 第一个是x /// 第二个是y /// </summary> /// <param name="hwnd"></param> /// <returns></returns> public int[] getPeopleXY(int hwnd) { int[] xy = new int[2]; IntPtr pid = IntPtr.Zero; LoadDll.GetWindowThreadProcessId((IntPtr)hwnd, out pid); byte[] buffer = new byte[4]; IntPtr byteAddress = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0); IntPtr hProcess = LoadDll.OpenProcess(0x1F0FFF, false, pid.ToInt32()); //读取x坐标 bool ret = LoadDll.ReadProcessMemory(hProcess, new IntPtr(this.x), byteAddress, 4, IntPtr.Zero); double val = BitConverter.ToSingle(buffer, 0); xy[0] = (int)Math.Floor(val / 20); //读取y坐标 int mapY = LoadDll.ReadMemoryOffsetValue(pid.ToInt32(), this.MapAddr, 0x50, 0x14); LoadDll.ReadProcessMemory(hProcess, new IntPtr(this.y), byteAddress, 4, IntPtr.Zero); val = BitConverter.ToSingle(buffer, 0); xy[1] = (int)Math.Floor((mapY - val) / 20); LoadDll.CloseHandle(hProcess); return(xy); }
/// <summary> /// 读取对话选项 /// </summary> /// <param name="hwnd">句柄</param> /// <param name="option">第几个选项</param> /// <returns></returns> public static bean.Axis ReadDialogOption(int hwnd, int option) { bean.Axis a = null; int idx = 0; Random r = new Random(); for (int i = 0; i < 20; i++) { //获取对话框的x,y起点 int x = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x08); int y = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x0C); int type = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x18); int show = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x28); if (type != 550 || show == 1) { continue; } for (int n = 0; n < 10; n++) { int tz = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x00); int nx = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x08); if (nx == 30) { idx++; if (idx == option) { int ny = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x0C); x = nx + x + r.Next(10, 20); y = ny + y; a = new bean.Axis(x, y); } } } } return(a); }
public override void AddHPMP(IntPtr hwnd) { if (Global.mh_cfg[hwnd].bb_hp_mp_auto == 0) { return; } bean.AttrsPanel attr = mhxy.CallFunc.ReadAttrsPanel(hwnd.ToInt32()); if (attr.bbHP == 0 || id <= 0) { return; } if (attr.bbHP < Global.mh_cfg[hwnd].bb_hp) { byte[] b = BitConverter.GetBytes(id); LoadDll.sendMsg(hwnd, String.Format("35 06 {0} 01 00", StringUtil.FormatBytesToHex(b).Trim())); Log.WriteLine("宝宝满血"); } if (attr.bbMP < Global.mh_cfg[hwnd].bb_mp) { byte[] b = BitConverter.GetBytes(id); LoadDll.sendMsg(hwnd, String.Format("35 06 {0} 02 00", StringUtil.FormatBytesToHex(b).Trim())); Log.WriteLine("宝宝满蓝"); } }
/// <summary> /// 攻击指令 /// 存在同步和等待的情况 /// </summary> public void attackEnemy() { mxMonster.WaitOne(); if (monster.Count > 0) { System.Threading.Thread.Sleep(1000); Monster mon = GetRandomMonsterPosIndx(); int peopleCode = 0x00;//普通攻击 //检查有没有宝宝 int bb_pos = checkBB(); //判断是否自动释放技能 if (Global.mh_cfg.ContainsKey(hwnd) == true && Global.mh_cfg[hwnd].skill_auto == 1) { peopleCode = Global.mh_cfg[hwnd].skill; string cmd = ""; //没有宝宝发动攻击,或者魔法不够直接攻击 if (bb_pos == -1 || ex.mySelf.mp < 26) { //检测自己使用魔法时气血和所剩魔法是否满足,不够使用普通攻击 if (ex.mySelf.mp < Global.skill_map[peopleCode].mp || ex.mySelf.hp < Global.skill_map[peopleCode].hp || peopleCode <= 0) { cmd = mhxy.GameCmd.CmdBattleAttack(0, mon.postion, 0, 0x61, 0); } else { cmd = mhxy.GameCmd.CmdBattleAttack(0, mon.postion, 0, 0x62, peopleCode); //技能附着随机码 Console.WriteLine("技能附着随机码【{0}】:【{1}】", skill_first, skill_random); if (skill_first && skill_random) { Random rm = new Random(); cmd = cmd.Substring(0, cmd.Length - 3); //获取怪物的个数 if (monster.Count > 1) { //两个怪物 随机码两个,加长 cmd = cmd.Replace("04", "06"); cmd = String.Format(cmd + " {0} {1} 00", StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false), StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false)); } else { //1个怪物 随机码1个,加长 cmd = cmd.Replace("04", "05"); cmd = String.Format(cmd + " {0} 00", StringUtil.FormatIntToHexStyle(rm.Next(60, 235), false)); } skill_first = false; } } } else { //抓宝宝 cmd = mhxy.GameCmd.CmdBattleAttack(0, bb_pos, 0, 0x6F, 0); } Console.WriteLine("【{0}】:【{1}】", masterName, cmd); LoadDll.sendMsg(hwnd, cmd); if (baby) { System.Threading.Thread.Sleep(1000); cmd = mhxy.GameCmd.CmdBattleAttack(babyPos, mon.postion, 1, 0, 0); int bb_code = Global.mh_cfg[hwnd].bb_skill; //判断宝宝魔法是否够发出技能 if (ex.myBaby.mp >= Global.skill_map[bb_code].mp && ex.mySelf.hp >= Global.skill_map[bb_code].hp && bb_code > 0) { cmd = mhxy.GameCmd.CmdBattleAttack(babyPos, mon.postion, 1, 0x6B, bb_code); } Console.WriteLine("【宝宝技能】:【{0}】", cmd); LoadDll.sendMsg(hwnd, cmd); } } } mxMonster.ReleaseMutex(); }