diff --git a/src/hosting/InjectedProgramContext.cs b/src/hosting/InjectedProgramContext.cs index 2ae029b..f1f4112 100644 --- a/src/hosting/InjectedProgramContext.cs +++ b/src/hosting/InjectedProgramContext.cs @@ -33,7 +33,7 @@ private InjectedProgramContext(int? injectorProcessId, uint mainThreadId, nint m [EditorBrowsable(EditorBrowsableState.Never)] [SuppressMessage("", "CA1031")] - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])] public static unsafe uint Initialize(void* parameter) { // Only meant to be called by the native module. diff --git a/src/injection/AssemblyInjectorOptions.cs b/src/injection/AssemblyInjectorOptions.cs index 91f4b53..81165d8 100644 --- a/src/injection/AssemblyInjectorOptions.cs +++ b/src/injection/AssemblyInjectorOptions.cs @@ -4,7 +4,7 @@ public sealed class AssemblyInjectorOptions { public string FileName { get; private set; } = null!; - public ImmutableArray Arguments { get; private set; } = ImmutableArray.Empty; + public ImmutableArray Arguments { get; private set; } = []; public string ModuleDirectory { get; private set; } = _defaultDirectory; diff --git a/src/injection/IO/ProcessMemoryStream.cs b/src/injection/IO/ProcessMemoryStream.cs index f75c751..9fdb4e7 100644 --- a/src/injection/IO/ProcessMemoryStream.cs +++ b/src/injection/IO/ProcessMemoryStream.cs @@ -173,6 +173,6 @@ public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationTo public override void WriteByte(byte value) { - Write(stackalloc[] { value }); + Write([value]); } } diff --git a/src/memory/Code/FunctionHookGate.cs b/src/memory/Code/FunctionHookGate.cs index 54d932f..e2e8032 100644 --- a/src/memory/Code/FunctionHookGate.cs +++ b/src/memory/Code/FunctionHookGate.cs @@ -117,7 +117,7 @@ public GateFrame(FunctionHook hook, void** stackAddress) [ThreadStatic] private static GateContext? _context; - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])] public static void* Enter(nint handle, void** rsp) { _context ??= new(); @@ -144,7 +144,7 @@ public GateFrame(FunctionHook hook, void** stackAddress) return hook.HookCode; } - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])] public static void* Exit() { _context ??= new(); diff --git a/src/memory/Diagnostics/CallTrace.cs b/src/memory/Diagnostics/CallTrace.cs index d334093..47564e5 100644 --- a/src/memory/Diagnostics/CallTrace.cs +++ b/src/memory/Diagnostics/CallTrace.cs @@ -206,13 +206,13 @@ private static CallTrace CaptureCore(IEnumerable symbolic // Use RtlLookupFunctionEntry on 64-bit since it can pick up JIT'd code. - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static void* FunctionTableAccess32(HANDLE process, ulong address) { return SymFunctionTableAccess64(process, address); } - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static void* FunctionTableAccess64(HANDLE process, ulong address) { ulong unused; @@ -220,13 +220,13 @@ private static CallTrace CaptureCore(IEnumerable symbolic return _rtlLookupFunctionEntry(address, &unused, null); } - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static ulong GetModuleBase32(HANDLE process, ulong address) { return SymGetModuleBase64(process, address); } - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static ulong GetModuleBase64(HANDLE process, ulong address) { ulong result; diff --git a/src/samples/hooking/InjectedProgram.cs b/src/samples/hooking/InjectedProgram.cs index d10e1cd..cecf8cb 100644 --- a/src/samples/hooking/InjectedProgram.cs +++ b/src/samples/hooking/InjectedProgram.cs @@ -103,7 +103,7 @@ private static unsafe int TestHooking() } } - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static unsafe void FlushProcessWriteBuffersHook() { _counter++; diff --git a/src/samples/trace/Program.cs b/src/samples/trace/Program.cs index 1905d70..dee64c4 100644 --- a/src/samples/trace/Program.cs +++ b/src/samples/trace/Program.cs @@ -33,7 +33,7 @@ public static int Main() } [SuppressMessage("", "CA1031")] - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] + [UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])] private static int SetThreadDescriptionHook(nint hThread, char* lpThreadDescription) { try diff --git a/src/system/ProcessObject.cs b/src/system/ProcessObject.cs index 8cf5f92..c76f300 100644 --- a/src/system/ProcessObject.cs +++ b/src/system/ProcessObject.cs @@ -109,7 +109,7 @@ static long ToTicks(FILETIME time) (nuint)length, VIRTUAL_ALLOCATION_TYPE.MEM_COMMIT | VIRTUAL_ALLOCATION_TYPE.MEM_RESERVE, (uint)(access == MemoryAccess.None ? PAGE_PROTECTION_FLAGS.PAGE_NOACCESS : (PAGE_PROTECTION_FLAGS)access), - Span.Empty) is var ptr and not null + []) is var ptr and not null ? ptr : throw new Win32Exception(); }