File tree 1 file changed +12
-1
lines changed
src/tests/nativeaot/SmokeTests/ControlFlowGuard
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -174,9 +174,11 @@ static IntPtr CreateNewMethod()
174
174
if ( s_armed )
175
175
flProtect |= 0x40000000 /* TARGETS_INVALID */ ;
176
176
177
+ uint allocSize = 4096 ;
178
+
177
179
IntPtr address = VirtualAlloc (
178
180
lpAddress : IntPtr . Zero ,
179
- dwSize : 4096 ,
181
+ dwSize : allocSize ,
180
182
flAllocationType : 0x00001000 | 0x00002000 /* COMMIT+RESERVE*/ ,
181
183
flProtect : flProtect ) ;
182
184
@@ -196,6 +198,15 @@ static IntPtr CreateNewMethod()
196
198
throw new NotSupportedException ( ) ;
197
199
}
198
200
201
+ [ DllImport ( "kernel32" , ExactSpelling = true ) ]
202
+ static extern IntPtr GetCurrentProcess ( ) ;
203
+
204
+ [ DllImport ( "kernel32" , ExactSpelling = true , SetLastError = true ) ]
205
+ static extern int FlushInstructionCache ( IntPtr hProcess , IntPtr lpBaseAddress , nuint dwSize ) ;
206
+
207
+ if ( FlushInstructionCache ( GetCurrentProcess ( ) , address , allocSize ) == 0 )
208
+ Console . WriteLine ( "FlushInstructionCache failed" ) ;
209
+
199
210
return address ;
200
211
}
201
212
}
You can’t perform that action at this time.
0 commit comments