Esempio n. 1
0
 public static void RunFunctionWithConservativelyReportedBuffer <T, U>(int cbBuffer, IntPtr pfnTargetToInvoke, ref T context, ref U context2)
 {
     RuntimeImports.ConservativelyReportedRegionDesc regionDesc = new RuntimeImports.ConservativelyReportedRegionDesc();
     RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref context2, ref regionDesc);
     System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
 }
Esempio n. 2
0
        private static unsafe void RunFunctionWithConservativelyReportedBufferInternal <T, U>(int cbBuffer, IntPtr pfnTargetToInvoke, ref T context, ref U context2, ref RuntimeImports.ConservativelyReportedRegionDesc regionDesc)
        {
            fixed(RuntimeImports.ConservativelyReportedRegionDesc *pRegionDesc = &regionDesc)
            {
                int cbBufferAligned = (cbBuffer + (sizeof(IntPtr) - 1)) & ~(sizeof(IntPtr) - 1);
                // The conservative region must be IntPtr aligned, and a multiple of IntPtr in size
                void *region = stackalloc IntPtr[cbBufferAligned / sizeof(IntPtr)];

                RuntimeImports.RhInitializeConservativeReportingRegion(pRegionDesc, region, cbBufferAligned);

                RawCalliHelper.Call <T, U>(pfnTargetToInvoke, region, ref context, ref context2);
                System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();

                RuntimeImports.RhDisableConservativeReportingRegion(pRegionDesc);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// This method creates a conservatively reported region and calls a function
 /// while that region is conservatively reported.
 /// </summary>
 /// <param name="cbBuffer">size of buffer to allocated (buffer size described in bytes)</param>
 /// <param name="pfnTargetToInvoke">function pointer to execute. Must have the calling convention void(void* pBuffer, ref T context)</param>
 /// <param name="context">context to pass to inner function. Passed by-ref to allow for efficient use of a struct as a context.</param>
 public static void RunFunctionWithConservativelyReportedBuffer <T>(int cbBuffer, IntPtr pfnTargetToInvoke, ref T context)
 {
     RuntimeImports.ConservativelyReportedRegionDesc regionDesc = new RuntimeImports.ConservativelyReportedRegionDesc();
     RunFunctionWithConservativelyReportedBufferInternal(cbBuffer, pfnTargetToInvoke, ref context, ref regionDesc);
 }