未验证 提交 97de75b5 编写于 作者: M Michal Strehovský 提交者: GitHub

Call FlushInstructionCache in CFG test (#83168)

Should address https://github.com/dotnet/runtime/pull/82307#discussion_r1111436978.
上级 5a45085c
......@@ -174,9 +174,11 @@ static IntPtr CreateNewMethod()
if (s_armed)
flProtect |= 0x40000000 /* TARGETS_INVALID */;
uint allocSize = 4096;
IntPtr address = VirtualAlloc(
lpAddress: IntPtr.Zero,
dwSize: 4096,
dwSize: allocSize,
flAllocationType: 0x00001000 | 0x00002000 /* COMMIT+RESERVE*/,
flProtect: flProtect);
......@@ -196,6 +198,15 @@ static IntPtr CreateNewMethod()
throw new NotSupportedException();
}
[DllImport("kernel32", ExactSpelling = true)]
static extern IntPtr GetCurrentProcess();
[DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
static extern int FlushInstructionCache(IntPtr hProcess, IntPtr lpBaseAddress, nuint dwSize);
if (FlushInstructionCache(GetCurrentProcess(), address, allocSize) == 0)
Console.WriteLine("FlushInstructionCache failed");
return address;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册