Skip to content

Commit 7c86f95

Browse files
authored
Merge pull request #1074 from rickshaw5724/avoidReadingTimeStampCounter
Avoid reading time stamp counter
2 parents f416a78 + 743673a commit 7c86f95

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/NetMQ/Core/Utils/OpCode.cs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ internal static class Opcode
1111

1212
public static bool Open()
1313
{
14+
// Look for an environment variable: "NETQM_SUPPRESS_RDTSC" with any value.
15+
// The application can set this environment variable when this code is running in a system where
16+
// it is not desirable to read the processor's time stamp counter.
17+
// While this is supported in modern CPUs, the technique used for allocating executable memory, copying OP Code
18+
// for the read of the time stamp and invoking the OP Code can be detected as Malware by some anti-virus vendors.
19+
// https://github.com/zeromq/netmq/issues/1071
20+
string val = Environment.GetEnvironmentVariable("NETQM_SUPPRESS_RDTSC");
21+
if (!string.IsNullOrEmpty(val))
22+
return false;
1423
#if NETSTANDARD1_1_OR_GREATER || NET471_OR_GREATER
1524
if (RuntimeInformation.ProcessArchitecture != Architecture.X86 &&
1625
RuntimeInformation.ProcessArchitecture != Architecture.X64)

0 commit comments

Comments
 (0)