void GainItems(object thisObj, object[] args) { if (args.Length > 1) { if (args[1] != null) { Pathea.ItemSystem.ItemObject[] items = (Pathea.ItemSystem.ItemObject[])args[1]; foreach (var item in items) { HookRegistry.Debug("GainItems item {0} id={1} ", item.ItemBase.Name, item.ItemBase.ID, item.Number); HookRegistry.Debug("GainItems args {0}", UnityEngine.JsonUtility.ToJson(item)); } } } }
object OnCall(string typeName, string methodName, object thisObj, object[] args, IntPtr[] refArgs, int[] refIdxMatch) { switch (typeName + "::" + methodName) { case "UILoader::OnInit": HookRegistry.Get().CtrlServer.Start(); return(null); case "UILoader::OnRelease": HookRegistry.Get().CtrlServer.Stop(); return(null); case "Pathea.RiderNs.RidableModuleManager::TryDecreaseLoyalty": //忠诚不减 return(false); case "Pathea.EG.EGMgr::StartEngagement": // 约会/玩耍直接满 { var egMgr = (EGMgr)thisObj; if (egMgr.IsEngagement()) { var th = new Thread(() => { HookRegistry.Debug("[StartEngagement] wait 3 second"); Thread.Sleep(3000); var mDate = (EGDate)HookRegistry.GetInstanceField(typeof(EGMgr), thisObj, "mDate"); mDate.SetMood(100); HookRegistry.Debug("[StartEngagement] set mood {0}", mDate.GetMood()); }); th.Start(); } } return(null); case "Pathea.EG.EGMgr::StopEngagement": //取消嫉妒 if ((EGStopType)args[0] == EGStopType.Jealous) { return(false); } else { return(null); } case "Pathea.FavorSystemNs.FavorUtility::GetFavorBehaviorInfo": //玫瑰花1颗心 if ((int)args[1] == 7000016) { return(new GiveGiftResult("75", 100, FeeLevelEnum.Excellent, GiftType.Normal)); } else { return(null); } default: return(null); } try { } catch (Exception e) { // Write meaningful information to the game output. string message = String.Format(HOOK_FAILED, e.Message); HookRegistry.Panic(message); } // Never return null after typeName check! return((object)true); }
public string DoCmd(IDictionary <string, string> args) { switch (args["cmd"]) { case "AddItem": string numStr; if (!args.TryGetValue("num", out numStr)) { numStr = "1"; } foreach (var idStr in args["ids"].Split(',')) { int id = Convert.ToInt32(idStr.Trim()); int num = Convert.ToInt32(numStr); if (HookRegistry.IsWithinUnity()) { HookRegistry.Debug("AddItem {0}", id); Module <Player> .Self.bag.AddItem(id, num, false, AddItemMode.ForceBag); } else { } } break; case "UnlockAchievement": { int id = Convert.ToInt32(args["id"].Trim()); if (HookRegistry.IsWithinUnity()) { if (Module <AchievementModule> .Self.IsAchievementUnlocked(id)) { return(String.Format("{0} is unlocked", id)); } Module <AchievementModule> .Self.UnlockAchievement(id); } } break; case "MissionAll": { StringBuilder sb = new StringBuilder(); foreach (MissionBaseInfo missionBaseInfo in MissionManager.allMissionBaseInfo.Values) { sb.Append(missionBaseInfo.InstanceID); sb.Append(", "); sb.Append(missionBaseInfo.MissionNO); sb.Append(", "); string name = TextMgr.GetOriginStr(missionBaseInfo.MissionNameId); sb.Append(name); sb.Append(", "); sb.AppendLine(); } return(sb.ToString()); } case "TransportMap": { MessageManager.Instance.Dispatch("TransportMap", new object[] { }, DispatchType.IMME, 2f); } break; case "RefreshPriceIndex": //更新物价指数 Module <StoreManagerV40> .Self.RefreshPriceIndex(); break; case "ItemBar": //修改物品数量 { int index = Convert.ToInt32(args["solt"].Trim()) - 1; int num = Convert.ToInt32(args["num"].Trim()); var item = Module <Player> .Self.bag.itemBar.itemBarItems.ElementAt(index); if (item != null) { num = Mathf.Clamp(num, 1, item.ItemBase.MaxNumber); item.ChangeNumber(num - item.Number); return(String.Format("slot {0} {2}({1}) => {3}", index + 1, item.ItemDataId, item.ItemBase.Name, item.Number)); } else { return("no item on bar"); } } case "Test": return("test"); } return("success"); }
object OnCall(string typeName, string methodName, object thisObj, object[] args, IntPtr[] refArgs, int[] refIdxMatch) { if (typeName != "System.Net.Sockets.Socket" || (methodName != "EndSend" && methodName != "EndReceive")) { return(null); } // Socket is a low-level construct so we must guard ourselves robustly against race conditions. if (!ReentrantEnter(thisObj)) { return(null); } /* Actual hook code */ bool isOutgoing = methodName.EndsWith("Send"); int OPResult = 0; var dumpServer = DumpServer.Get(); // True if we need to feedback the error code returned by the proxy method. bool feedbackErrorCode = false; var thisSocket = thisObj as Socket; if (thisSocket == null) { HookRegistry.Panic("SocketHook - `thisObj` is NOT a Socket object"); } // We expect 1 referenceArgument, which makes the total passed argument equal to 2. // The argument in question is `out SocketError` if (refArgs != null && refArgs.Length == 1) { if (args.Length != 2 || refIdxMatch == null || refIdxMatch[0] != 1) { string message = String.Format("SocketHook - {0} - Got 1 reference argument, but total arguments don't match: {1} <=> 2", thisSocket.GetHashCode(), args.Length); HookRegistry.Panic(message); } else { HookRegistry.Debug("SocketHook - {0} - Valid referenced argument!", thisSocket.GetHashCode()); feedbackErrorCode = true; } } dumpServer.PreparePartialBuffers(thisSocket, false); // Fetch the asyncModel early to prevent it being cleaned up // directly after operation end. var asyncResult = args[0] as IAsyncResult; if (asyncResult == null) { HookRegistry.Panic("SocketHook - asyncResult == null"); } if (isOutgoing) { int sentBytes = (int)ProxyEndWrite(thisObj, ref args); // buffer holds the transmitted contents. // requestedBytes holds the amount of bytes requested when starting the operation. // => This amount gets decreased, towards 0, each time bytes are sent. // => The actual amount of bytes sent are found inside sentBytes. // offset is the starting offset, within buffer, of data to be written when starting // the operation. // => This amount gets increased, towards orignal value of size, each time bytes are sent. // => The actual offset would then be (offset-sentBytes)! OPResult = sentBytes; //processedBytes = sentBytes; // Update offset parameter. //offset = offset-sentBytes; } else { int readBytes = (int)ProxyEndRead(thisObj, ref args); OPResult = readBytes; //processedBytes = readBytes; } // These variables have a different meaning depending on the operation; read or write. byte[] buffer = GetAsyncBuffer(asyncResult); // Offset in buffer where relevant data starts. int offset = GetAsyncOffset(asyncResult); int requestedBytes = GetAsyncRequestedBytes(asyncResult); // Amount of bytes actually processed by the operation. int processedBytes = OPResult; if (buffer != null) { if (offset + processedBytes > buffer.Length) { offset -= processedBytes; } // HookRegistry.Log("SocketHook - {0} - writing", thisSocket.GetHashCode()); dumpServer.PartialData(thisSocket, !isOutgoing, buffer, offset, processedBytes, isWrapping: false, singleDecode: false); } else { HookRegistry.Log("SocketHook - {0} - buffer == null", thisSocket.GetHashCode()); } if (feedbackErrorCode == true) { var errorCode = (SocketError)args[1]; IntPtr errorCodePtr = refArgs[0]; HookRegistry.Debug("SocketHook - {0} - Writing `{1}` to refPtr", thisSocket.GetHashCode(), errorCode.ToString()); Marshal.StructureToPtr(errorCode, errorCodePtr, true); } ReentrantLeave(thisObj); return(OPResult); }