/// <summary> /// Invoke this library's PROCESS_DETACH handlers, if it has any. /// </summary> private unsafe void Detach() { LibraryLoader libraryLoader = new LibraryLoader(0, null); Image image = new Image((byte *)BaseAddress, AlignedImageSize); libraryLoader.ExecuteTlsFunctions(image, DllCallType.PROCESS_DETACH); if (Kind == HarmonyLibraryKind.Dll) { libraryLoader.ExecuteDllMain(image, DllCallType.PROCESS_DETACH); } }