private static unsafe _WinInetCache.Status MustRunGetAndLockFile(char* key, byte* entryPtr, ref int entryBufSize, SafeUnlockUrlCacheEntryFile handle)
 {
     _WinInetCache.Status success = _WinInetCache.Status.Success;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
     }
     finally
     {
         if (!UnsafeNclNativeMethods.SafeNetHandles.RetrieveUrlCacheEntryFileW(key, entryPtr, ref entryBufSize, 0))
         {
             success = (_WinInetCache.Status) Marshal.GetLastWin32Error();
             handle.SetHandleAsInvalid();
         }
         else
         {
             handle.SetHandle((IntPtr) 1);
         }
     }
     return success;
 }
Esempio n. 2
0
 private static unsafe _WinInetCache.Status MustRunGetAndLockFile(char *key, byte *entryPtr, ref int entryBufSize, SafeUnlockUrlCacheEntryFile handle)
 {
     _WinInetCache.Status success = _WinInetCache.Status.Success;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
     }
     finally
     {
         if (!UnsafeNclNativeMethods.SafeNetHandles.RetrieveUrlCacheEntryFileW(key, entryPtr, ref entryBufSize, 0))
         {
             success = (_WinInetCache.Status)Marshal.GetLastWin32Error();
             handle.SetHandleAsInvalid();
         }
         else
         {
             handle.SetHandle((IntPtr)1);
         }
     }
     return(success);
 }
        //
        // Whis will check the result from PInvoke and make a valid safeHandle on success
        //
        unsafe private static _WinInetCache.Status MustRunGetAndLockFile(char* key, byte* entryPtr, ref int entryBufSize, SafeUnlockUrlCacheEntryFile handle) {
            _WinInetCache.Status error = _WinInetCache.Status.Success;

            // Run the body of this method as a non-interruptible block.
            RuntimeHelpers.PrepareConstrainedRegions();
            try {} finally {

                if (!UnsafeNclNativeMethods.SafeNetHandles.RetrieveUrlCacheEntryFileW(key, entryPtr, ref entryBufSize, 0))
                {
                    error = (_WinInetCache.Status)Marshal.GetLastWin32Error();
                    handle.SetHandleAsInvalid();
                }
                else {
                    // Hack: that will return 1 in place of a handle
                    // The real handle here is a "key" string
                    handle.SetHandle((IntPtr)1);
                }
            }

            return error;
        }