Last active
June 28, 2017 09:51
-
-
Save Criteo-dotnet-blog/08600339ee3e7fd59a1b5d37534e0580 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private string BuildTimerCallbackMethodName(ClrRuntime runtime, ulong timerCallbackRef) | |
| { | |
| var heap = runtime.GetHeap(); | |
| var methodPtr = GetFieldValue(heap, timerCallbackRef, "_methodPtr"); | |
| if (methodPtr != null) | |
| { | |
| ClrMethod method = runtime.GetMethodByAddress((ulong)(long)methodPtr); | |
| if (method != null) | |
| { | |
| // figure out the real callback implementor type thanks to _target | |
| string thisTypeName = "?"; | |
| var thisPtr = GetFieldValue(heap, timerCallbackRef, "_target"); | |
| if ((thisPtr != null) && ((ulong) thisPtr) != 0) | |
| { | |
| ulong thisRef = (ulong) thisPtr; | |
| var thisType = heap.GetObjectType(thisRef); | |
| if (thisType != null) | |
| { | |
| thisTypeName = thisType.Name; | |
| } | |
| } | |
| else | |
| { | |
| thisTypeName = (method.Type != null) ? method.Type.Name : "?"; | |
| } | |
| return string.Format("{0}.{1}", thisTypeName, method.Name); | |
| } | |
| } | |
| return string.Empty; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment