Skip to content

Commit

Permalink
Fix some analyzer violations.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Nov 15, 2023
1 parent 0a1c3ec commit 48968cd
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/hosting/InjectedProgramContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/injection/AssemblyInjectorOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public sealed class AssemblyInjectorOptions
{
public string FileName { get; private set; } = null!;

public ImmutableArray<string> Arguments { get; private set; } = ImmutableArray<string>.Empty;
public ImmutableArray<string> Arguments { get; private set; } = [];

public string ModuleDirectory { get; private set; } = _defaultDirectory;

Expand Down
2 changes: 1 addition & 1 deletion src/injection/IO/ProcessMemoryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationTo

public override void WriteByte(byte value)
{
Write(stackalloc[] { value });
Write([value]);
}
}
4 changes: 2 additions & 2 deletions src/memory/Code/FunctionHookGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/memory/Diagnostics/CallTrace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,27 @@ private static CallTrace CaptureCore(IEnumerable<CallFrameSymbolicator> 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;

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;
Expand Down
2 changes: 1 addition & 1 deletion src/samples/hooking/InjectedProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static unsafe int TestHooking()
}
}

[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
private static unsafe void FlushProcessWriteBuffersHook()
{
_counter++;
Expand Down
2 changes: 1 addition & 1 deletion src/samples/trace/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/system/ProcessObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MEM_EXTENDED_PARAMETER>.Empty) is var ptr and not null
[]) is var ptr and not null
? ptr
: throw new Win32Exception();
}
Expand Down

0 comments on commit 48968cd

Please sign in to comment.