This documentation is archived and is not being maintained.

IHostTaskManager::CallNeedsHostHook Method

Enables the host to specify whether the common language runtime (CLR) can inline the specified call to an unmanaged function.

HRESULT CallNeedsHostHook (
    [in]  SIZE_T target, 
    [out] BOOL   *pbCallNeedsHostHook


[in] The address within the mapped portable executable (PE) file of the unmanaged function that is to be called.


[out] A pointer to a Boolean value that indicates whether the host requires the call to be hooked.




CallNeedsHostHook returned successfully.


The CLR has not been loaded into a process, or the CLR is in a state in which it cannot run managed code or process the call successfully.


The call timed out.


The caller does not own the lock.


An event was canceled while a blocked thread or fiber was waiting on it.


An unknown catastrophic failure has occurred. When a method returns E_FAIL, the CLR is no longer usable within the process. Subsequent calls to hosting methods return HOST_E_CLRNOTAVAILABLE.

To help optimize code execution, the CLR performs an analysis of each platform invoke call during compilation to determine whether the call can be inlined. CallNeedsHostHook enables the host to override that decision by requiring that a call to an unmanaged function be hooked. If the host requires a hook, the runtime does not inline the call.

The host typically would require a hook where it must adjust a floating-point state, or upon receiving notification that a call is entering a state where the host cannot track the runtime's requests for memory or any locks taken. When the host requires that the call be hooked, the runtime notifies the host of transitions to and from managed code by using calls to EnterRuntime, LeaveRuntime, ReverseEnterRuntime, and ReverseLeaveRuntime.

Platforms: See .NET Framework System Requirements.

Header: MSCorEE.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0