Skip to content

Commit

Permalink
Merge 1a2314a into f416a78
Browse files Browse the repository at this point in the history
  • Loading branch information
rickshaw5724 authored Aug 31, 2023
2 parents f416a78 + 1a2314a commit 26b0253
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/NetMQ/Core/Utils/OpCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal static class Opcode

public static bool Open()
{
if (SocketOptions.DoNotUseRDTSC)
return false;
#if NETSTANDARD1_1_OR_GREATER || NET471_OR_GREATER
if (RuntimeInformation.ProcessArchitecture != Architecture.X86 &&
RuntimeInformation.ProcessArchitecture != Architecture.X64)
Expand Down
10 changes: 10 additions & 0 deletions src/NetMQ/SocketOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ namespace NetMQ
/// </summary>
public class SocketOptions
{
/// <summary>
/// If set, the time stamp counter is not read directly through opcode injection,
/// rather <see cref="System.Diagnostics.Stopwatch.GetTimestamp"/> is used.
/// When false, the time stamp counter is read by allocating a few bytes on the heap with
/// read/write/execute privilege. OpCode is copied to this allocated memory and invoked to read
/// the time stamp counter, (which is a register available on most modern CPUs). While this is
/// an accurate way to read the time stamp counter, because it injects code onto the heap, this
/// can be detected as a malware technique by some anti-virus defenders.
/// </summary>
public static bool DoNotUseRDTSC;
/// <summary>
/// The NetMQSocket that this SocketOptions is referencing.
/// </summary>
Expand Down

0 comments on commit 26b0253

Please sign in to comment.