// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/**************************************************************************************
 **                                                                                  **
 ** clrinternal.idl - interface definitions for internal usage.                      **
 **                                                                                  **
 **************************************************************************************/

//
// Interface descriptions
//
import "unknwn.idl";

// import mscoree.idl for BucketParameters definition
import "mscoree.idl";

// This ID is embedded in the CLRDEBUGINFO resource so that the shim can differentiate dlls which happen to be named
// clr.dll from official Microsoft clr.dll implementations. This is not intended to authenticate a CLR in a strong
// security sense but short of deliberate 3rd party spoofing it should provide a good identity.
//
// Using a different ID allows us to completely hide different CLR SKUs from each other. The recommendation is to keep
// the ID constant between different versions of the same SKU and use mscordbi's logic to determine whether a given
// version is compatible. This allows debuggers to give different errors for 'future version of the CLR I don't
// support' vs. 'No CLR is loaded at all.'
//
// This guid first appears in version 4.0 of CLR on x86 and amd64 - earlier versions had no resource
// GUID CLR_ID_V4_DESKTOP :   uuid{267F3989-D786-4b9a-9AF6-D19E42D557EC}
cpp_quote("EXTERN_GUID(CLR_ID_V4_DESKTOP, 0x267f3989, 0xd786, 0x4b9a, 0x9a, 0xf6, 0xd1, 0x9e, 0x42, 0xd5, 0x57, 0xec);")

// This guid has been set aside for CoreCLR usage - at present CoreCLR doesn't use it though
// GUID CLR_ID_CORECLR :   uuid{8CB8E075-0A91-408E-9228-D66E00A3BFF6}
cpp_quote("EXTERN_GUID(CLR_ID_CORECLR, 0x8CB8E075, 0x0A91, 0x408E, 0x92, 0x28, 0xD6, 0x6E, 0x00, 0xA3, 0xBF, 0xF6 );")

// This guid first appears in the CoreCLR port to Windows Phone 8 - note that it is separate from the CoreCLR id because it will
// potentially have a different versioning lineage than CoreCLR
// GUID CLR_ID_PHONE_CLR :   uuid{E7237E9C-31C0-488C-AD48-324D3E7ED92A}
cpp_quote("EXTERN_GUID(CLR_ID_PHONE_CLR, 0xE7237E9C, 0x31C0, 0x488C, 0xAD, 0x48, 0x32, 0x4D, 0x3E, 0x7E, 0xD9, 0x2A);")

// This guid first appears 8/19/14 as CoreCLR evolves to OneCore, ProjectK, and versions of Phone after PhoneBlue
// The new guid intentionally creates a breaking change so we can simplify the file naming on mscordaccore.dll and mscordbi.dll
// in xplat hosting scenarios. Old versions of dbgshim.dll will not be able to support this.
// GUID CLR_ID_ONECORE_CLR :    uuid{B1EE760D-6C4A-4533-BA41-6F4F661FABAF}
cpp_quote("EXTERN_GUID(CLR_ID_ONECORE_CLR, 0xb1ee760d, 0x6c4a, 0x4533, 0xba, 0x41, 0x6f, 0x4f, 0x66, 0x1f, 0xab, 0xaf);")


// IID_IPrivateManagedExceptionReporting :     uuid{AD76A023-332D-4298-8001-07AA9350DCA4}
cpp_quote("EXTERN_GUID(IID_IPrivateManagedExceptionReporting, 0xad76a023, 0x332d, 0x4298, 0x80, 0x01, 0x07, 0xaa, 0x93, 0x50, 0xdc, 0xa4);")


//*****************************************************************************
// Interface for exposing services from the EE to other DLLs of the CLR.
//*****************************************************************************
typedef void * CRITSEC_COOKIE;

typedef enum {
    CRST_DEFAULT          = 0x0,
    CRST_REENTRANCY       = 0x1,  // allow same thread to take lock multiple times.
    CRST_UNSAFE_SAMELEVEL = 0x2,  // AVOID THIS! Can take other locks @ same level in
                                  //             any order.
    CRST_UNSAFE_COOPGC    = 0x4,  // AVOID THIS! Lock must be taken in cooperative mode.
    CRST_UNSAFE_ANYMODE   = 0x8,  // AVOID THIS! Lock can be taken in either GC mode.
    CRST_DEBUGGER_THREAD  = 0x10, // This lock can be taken on the debugger's helper thread.
    CRST_HOST_BREAKABLE   = 0x20, // This lock is held while running managed code.  It can be terminated by a host.
    // CRST_UNUSED        = 0x40,
    CRST_TAKEN_DURING_SHUTDOWN = 0x80, // This lock is taken during the shutdown sequence in EEShutdown(helper)
    CRST_GC_NOTRIGGER_WHEN_TAKEN = 0x100,
        // User of this lock cannot trigger GC, while it is locked.
        // Note that Enter on this lock can trigger GC if called from COOPERATIVE mode.
        // It is useful for locks which can be taken on GC or debugger threads.
    CRST_DEBUG_ONLY_CHECK_FORBID_SUSPEND_THREAD = 0x200,
        // Some rare locks should be taken only in ForbidSuspend region (i.e. profiler cannot walk the stack),
        // this option will assert it in debug mode.
} CrstFlags;

//********************************************************************************************
// Interface for exposing GetBucketParametersForCurrentException to Watson testing harness.
//********************************************************************************************
[
    uuid(AD76A023-332D-4298-8001-07AA9350DCA4),
    helpstring("Private Managed Exception Reporting Interface"),
    pointer_default(unique),
    local
]
interface IPrivateManagedExceptionReporting : IUnknown
{
    HRESULT GetBucketParametersForCurrentException([out]BucketParameters *pParams);
}
