protected override CLRTypeDebugInfo CreateDebugInfo(CorDebugStartDebuggingOptions options) { var dncOptions = (DotNetStartDebuggingOptions)options; string?hostFilename; if (!dncOptions.UseHost) { hostFilename = null; } else if (string.IsNullOrWhiteSpace(dncOptions.Host)) { hostFilename = DotNetHelpers.GetPathToDotNetExeHost(Bitness); if (!File.Exists(hostFilename)) { throw new Exception(string.Format(dnSpy_Debugger_DotNet_CorDebug_Resources.Error_CouldNotFindDotNetCoreHost, DotNetHelpers.DotNetExeName)); } } else { hostFilename = dncOptions.Host; } var hostCommandLine = dncOptions.HostArguments ?? string.Empty; return(new CoreCLRTypeDebugInfo(GetDbgShimAndVerify(), hostFilename, hostCommandLine)); }
//////////////// internal bool UpdateForEventsBeginnings(VanillaEventFlag eventFlags) { bool eventsChanged = false; IEnumerable <VanillaEventFlag> eventFlagSet = DotNetHelpers.FlagsToCollection <VanillaEventFlag>((int)eventFlags); foreach (VanillaEventFlag flag in eventFlagSet) { if (this.CurrentEvents.Contains(flag)) { continue; } switch (flag) { case VanillaEventFlag.Sandstorm: case VanillaEventFlag.BloodMoon: case VanillaEventFlag.SlimeRain: case VanillaEventFlag.SolarEclipse: case VanillaEventFlag.LunarApocalypse: break; default: if (RewardsMod.Instance.SettingsConfig.DebugModeInfo) { LogHelpers.Alert("Event added: " + Enum.GetName(typeof(VanillaEventFlag), flag)); } eventsChanged = true; this.CurrentEvents.Add(flag); break; } } return(eventsChanged); }
//////////////// /// @private public override void Action(CommandCaller caller, string input, string[] args) { if (Main.netMode == 1) { LogHelpers.Warn("Not supposed to run on client."); return; } if (Main.netMode == 2 && caller.CommandType != CommandType.Console) { if (!UserHelpers.HasBasicServerPrivilege(caller.Player)) { caller.Reply("Access denied.", Color.Red); return; } } if (!ModHelpersMod.Config.ModCallCommandEnabled) { throw new UsageException("Mod.Call() command disabled by settings."); } if (args.Length < 2) { if (args.Length == 0) { throw new UsageException("No arguments given."); } else { throw new UsageException("More arguments needed."); } } Mod callmod = null; try { callmod = ModLoader.GetMod(args[0]); if (callmod == null) { throw new ModHelpersException("Bad call mod."); } } catch (Exception) { throw new UsageException("Invald mod name " + args[0]); } try { object[] callArgs = new object[args.Length - 1]; for (int i = 1; i < args.Length; i++) { callArgs[i - 1] = DotNetHelpers.ParseToInferredPrimitiveType(args[i]); } callmod.Call(callArgs); } catch (Exception e) { caller.Reply(e.Message, Color.Red); } }
string GetDbgShimAndVerify() { var dbgShimFilename = DotNetHelpers.GetDebugShimFilename(Bitness); if (!File.Exists(dbgShimFilename)) { throw new Exception("Couldn't find dbgshim.dll: " + dbgShimFilename); } return(dbgShimFilename); }
IEnumerable <DotNetAttachProgramOptions> TryGetCoreCLRInfos(Process process) { // We can only debug processes with the same bitness int bitness = IntPtr.Size * 8; var dbgShimFilename = DotNetHelpers.GetDebugShimFilename(bitness); foreach (var ccInfo in CoreCLRHelper.GetCoreCLRInfos(process.Id, null, dbgShimFilename)) { yield return(new DotNetAttachProgramOptions(process.Id, ccInfo.CoreCLRTypeInfo.Version, ccInfo.CoreCLRTypeInfo.CoreCLRFilename)); } }
//////////////// public WorldLogic() { var flags = NPCInvasionHelpers.GetCurrentEventTypeSet(); /*this.CurrentEvents = new ConcurrentDictionary<VanillaEventFlag, byte>( * DotNetHelpers.FlagsToList<VanillaEventFlag>( (int)flags ) * .Select( t => new KeyValuePair<VanillaEventFlag, byte>(t, 0) ) * );*/ this.CurrentEvents = new HashSet <VanillaEventFlag>( DotNetHelpers.FlagsToCollection <VanillaEventFlag>((int)flags) ); }
public override bool IsSupported(string filename, out ProcessStarterResult result) { result = ProcessStarterResult.None; if (!DotNetHelpers.IsDotNetExecutable(filename) || GetPathToDotNetExeHost() is null) { return(false); } var extension = Path.GetExtension(filename); if (!StringComparer.OrdinalIgnoreCase.Equals(extension, ".exe") && !StringComparer.OrdinalIgnoreCase.Equals(extension, ".dll")) { result |= ProcessStarterResult.WrongExtension; } return(true); }
private static void ReadStreamIntoContainer(BinaryReader reader, PacketProtocolData fieldContainer) { var mymod = ModHelpersMod.Instance; IOrderedEnumerable <FieldInfo> orderedFields = fieldContainer.OrderedFields; int i = 0; if (mymod.Config.DebugModePacketInfo) { LogHelpers.Log(" Begun reading packet " + fieldContainer.GetType().Name + " (" + fieldContainer.FieldCount + " fields)"); } foreach (FieldInfo field in orderedFields) { i++; Type fieldType = field.FieldType; object fieldData = PacketProtocolData.ReadStreamValue(reader, fieldType); if (Main.netMode == 1) { if (Attribute.IsDefined(field, typeof(PacketProtocolWriteIgnoreServerAttribute))) { continue; } } else if (Main.netMode == 2) { if (Attribute.IsDefined(field, typeof(PacketProtocolWriteIgnoreClientAttribute))) { continue; } } if (mymod.Config.DebugModePacketInfo) { LogHelpers.Log(" * Reading packet " + fieldContainer.GetType().Name + " field (" + i + " of " + fieldContainer.FieldCount + ") " + field.Name + ": " + DotNetHelpers.Stringify(fieldData, 32)); } //LogHelpers.Log( "READ "+ fieldContainer.GetType().Name + " FIELD " + field + " VALUE " + fieldData ); field.SetValue(fieldContainer, fieldData); } }
private static void WriteStreamFromContainer(BinaryWriter writer, PacketProtocolData fieldContainer) { var mymod = ModHelpersMod.Instance; IOrderedEnumerable <FieldInfo> orderedFields = fieldContainer.OrderedFields; int i = 0; if (!PacketProtocolData.ValidateConstructor(fieldContainer.GetType())) { throw new HamstarException("Invalid default constructor for " + fieldContainer.GetType().Name); } if (mymod.Config.DebugModePacketInfo) { LogHelpers.Log(" Begun writing packet " + fieldContainer.GetType().Name + " (" + fieldContainer.FieldCount + " fields)"); } foreach (FieldInfo field in orderedFields) { i++; if (Main.netMode == 1 && Attribute.IsDefined(field, typeof(PacketProtocolWriteIgnoreClientAttribute))) { continue; } else if (Main.netMode == 2 && Attribute.IsDefined(field, typeof(PacketProtocolWriteIgnoreServerAttribute))) { continue; } object rawFieldVal = field.GetValue(fieldContainer); //LogHelpers.Log( "WRITE "+ data.GetType().Name+ " FIELD " + field + " VALUE "+(rawFieldVal??"null")); if (mymod.Config.DebugModePacketInfo) { LogHelpers.Log(" * Writing packet " + fieldContainer.GetType().Name + " field (" + i + " of " + fieldContainer.FieldCount + ") " + field.Name + ": " + DotNetHelpers.Stringify(rawFieldVal, 32)); } PacketProtocolData.WriteStreamValue(writer, field.FieldType, rawFieldVal); } }
string?GetPathToDotNetExeHost() => DotNetHelpers.GetPathToDotNetExeHost(IntPtr.Size * 8);