c# - Is the result of MethodBody.GetILAsByteArray Method being cached? If so, how to clear the cache? -


as android game developer, using methodbody.getilasbytearray method il codes detect if given method has been modified (injected) user using other app (e.g. cheat engine). example,

class {     public foo()     {         // here.     }      public static byte[] getilbytecode() {         return typeof(a).getmethodinfo("foo").getmethodbody().getilasbytearray();     } } 

i can injected version of function "foo" if call function a.getilbytecode() after function "foo" being injected.

if call a.getilbytecode() first, , inject code in "foo". when call a.getilbytecode() again, return origin version of function "foo" instead of injected version.

it seems result of getilasbytearray() cached.

so question is, can clear cache of getilasbytearray(), , updated il code of target method?

since reflection expensive. .net runtime caches types pulled reflection, , in each 1 of these caches members called reflection.

i believe can try exhausting type cache, has few members (i think 16 members). member cache might unlimited.

however, if using cheatengine, don't think changing il changing actual jitted code. don't think there can here.

clr jit compiles every method gets called, don't know if mono offers interpretation mode.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -