Skip to content

Commit

Permalink
Merge pull request #416 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.9.16
  • Loading branch information
Aragas authored Oct 4, 2024
2 parents e2efdb2 + 84feb3b commit f9eacc6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<BaseGameVersion>1.0.0</BaseGameVersion>
<!--Module Version-->
<Version>2.9.15</Version>
<Version>2.9.16</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 2.9.16
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Some crashes were not intercepted without BLSE
---------------------------------------------------------------------------------------------------
Version: 2.9.15
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Fixed a regression that prevented crash reports from being shown
Expand Down
11 changes: 6 additions & 5 deletions src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,22 @@ internal static void Enable(Harmony harmony)
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
// ScreenManager.Tick
harmony.TryPatch(
AccessTools2.Method("ManagedCallbacks.EngineCallbacksGenerated.ScreenManager_Tick"),
AccessTools2.Method("ManagedCallbacks.EngineCallbacksGenerated:ScreenManager_Tick") ??
AccessTools2.Method("ManagedCallbacks.EngineCallbacksGenerated:EngineScreenManager_Tick"),
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
// ManagedScriptHolder.TickComponents
harmony.TryPatch(
AccessTools2.Method("ManagedCallbacks.EngineCallbacksGenerated.ManagedScriptHolder_TickComponents"),
AccessTools2.Method("ManagedCallbacks.EngineCallbacksGenerated:ManagedScriptHolder_TickComponents"),
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
// Mission.Tick
harmony.TryPatch(
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState.FinishMissionLoading"),
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState:FinishMissionLoading"),
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
harmony.TryPatch(
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState.TickMissionAux"),
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState:TickMissionAux"),
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
harmony.TryPatch(
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState.TickMission"),
AccessTools2.Method("TaleWorlds.MountAndBlade.MissionState:TickMission"),
transpiler: AccessTools2.Method(typeof(BEWPatch), nameof(BlankTranspiler)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Security;
using JetBrains.Annotations;

namespace Bannerlord.ButterLib.ExceptionHandler;

Expand Down Expand Up @@ -147,6 +148,7 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
}

// BLSE Duck typed method
[UsedImplicitly]
private static void OnInitializeSubModulesPrefix()
{
_wasButrLoaderInterceptorCalled = true;
Expand Down
27 changes: 22 additions & 5 deletions src/Bannerlord.ButterLib/ExceptionHandler/Utils/MiniDump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ public struct MINIDUMP_EXCEPTION_INFORMATION

public struct MINIDUMP_USER_STREAM
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint Type;
public uint BufferSize;
public IntPtr Buffer;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_USER_STREAM_INFORMATION
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint UserStreamCount;
public MINIDUMP_USER_STREAM[] UserStreamArray;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public enum MINIDUMP_CALLBACK_TYPE
Expand All @@ -116,6 +120,7 @@ public enum MINIDUMP_CALLBACK_TYPE

public struct VS_FIXEDFILEINFO
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint dwSignature;
public uint dwStrucVersion;
public uint dwFileVersionMS;
Expand All @@ -129,21 +134,25 @@ public struct VS_FIXEDFILEINFO
public uint dwFileSubtype;
public uint dwFileDateMS;
public uint dwFileDateLS;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_THREAD_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint ThreadId;
public IntPtr ThreadHandle;
public uint Pad;
//public CONTEXT Context;
//public uint SizeOfContext;
//public ulong StackBase;
//public ulong StackEnd;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_THREAD_EX_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint ThreadId;
public IntPtr ThreadHandle;
public uint Pad;
Expand All @@ -153,10 +162,12 @@ public struct MINIDUMP_THREAD_EX_CALLBACK
//public ulong StackEnd;
//public ulong BackingStoreBase;
//public ulong BackingStoreEnd;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_MODULE_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public IntPtr FullPath;
public ulong BaseOfImage;
public uint SizeOfImage;
Expand All @@ -167,24 +178,31 @@ public struct MINIDUMP_MODULE_CALLBACK
public uint SizeOfCvRecord;
public IntPtr MiscRecord;
public uint SizeOfMiscRecord;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_INCLUDE_THREAD_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint ThreadId;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_INCLUDE_MODULE_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public ulong BaseOfImage;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_IO_CALLBACK
{
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public IntPtr Handle;
public ulong Offset;
public IntPtr Buffer;
public uint BufferBytes;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

public struct MINIDUMP_CALLBACK_INPUT
Expand All @@ -208,10 +226,12 @@ public struct UNION
public MINIDUMP_IO_CALLBACK Io;
}

#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
public uint ProcessId;
public IntPtr ProcessHandle;
public MINIDUMP_CALLBACK_TYPE CallbackType;
public UNION Union;
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
}

[Flags]
Expand Down Expand Up @@ -306,7 +326,7 @@ public static bool TryDump([NotNullWhen(true)] out MemoryStream? dataStream)
return true;
}
}
catch (Exception) { }
catch (Exception) { /* ignore */ }

dataStream = null;
return false;
Expand Down Expand Up @@ -366,10 +386,7 @@ private static bool Write(SafeHandle file, MINIDUMP_TYPE dumpType, MINIDUMP_CALL
#endif
ClientPointers = true,
};
var userStream = new MINIDUMP_USER_STREAM_INFORMATION
{

};
var userStream = new MINIDUMP_USER_STREAM_INFORMATION();
var infoPtr = Marshal.AllocHGlobal(Marshal.SizeOf<Info>());
Marshal.StructureToPtr(new Info
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;

// ReSharper disable once CheckNamespace
namespace Bannerlord.BLSE;

[AttributeUsage(AttributeTargets.Class)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Bannerlord.BUTR.Shared.Helpers;

using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down
8 changes: 4 additions & 4 deletions src/Bannerlord.ButterLib/Logger/LoggerTraceListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ internal class LoggerTraceListener : TraceListener
{
private record ParseResult
{
public string Process { get; init; } = default!;
public TraceEventType Level { get; init; } = default!;
public int EventId { get; init; } = default!;
public string Message { get; init; } = default!;
public required string Process { get; init; }
public required TraceEventType Level { get; init; }
public required int EventId { get; init; }
public required string Message { get; init; }
}

// There are some cases when System.Numerics.Vectors is not found
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.ButterLib/Logger/ReverseTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ReverseTextReader(Stream stream, Encoding encoding)
// Make a new buffer but append the previous leftovers
var buffer = new byte[count + _leftoverBuffer.Length];
// Read the next buffer
_stream.Read(buffer, 0, count);
_ = _stream.Read(buffer, 0, count);
// Move the position of the stream back
_stream.Position = newPosition;
// And copy in the leftovers from the last buffer
Expand Down

0 comments on commit f9eacc6

Please sign in to comment.