internal static unsafe _WinInetCache.Status GetAndLockFile(string key, byte* entryPtr, ref int entryBufSize, out SafeUnlockUrlCacheEntryFile handle)
 {
     if (ValidationHelper.IsBlankString(key))
     {
         throw new ArgumentNullException("key");
     }
     handle = new SafeUnlockUrlCacheEntryFile(key);
     fixed (char* str = ((char*) key))
     {
         char* chPtr = str;
         return MustRunGetAndLockFile(chPtr, entryPtr, ref entryBufSize, handle);
     }
 }
Exemplo n.º 2
0
        internal static unsafe _WinInetCache.Status GetAndLockFile(string key, byte *entryPtr, ref int entryBufSize, out SafeUnlockUrlCacheEntryFile handle)
        {
            if (ValidationHelper.IsBlankString(key))
            {
                throw new ArgumentNullException("key");
            }
            handle = new SafeUnlockUrlCacheEntryFile(key);
            fixed(char *str = ((char *)key))
            {
                char *chPtr = str;

                return(MustRunGetAndLockFile(chPtr, entryPtr, ref entryBufSize, handle));
            }
        }
 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;
        }
 internal ReadStream(_WinInetCache.Entry entry, SafeUnlockUrlCacheEntryFile handle, bool async) : base(entry.Filename, FileMode.Open, FileAccess.Read, ComNetOS.IsWinNt ? (FileShare.Delete | FileShare.Read) : FileShare.Read, 0x1000, async)
 {
     this.m_Key = entry.Key;
     this.m_Handle = handle;
     this.m_ReadTimeout = this.m_WriteTimeout = -1;
 }
Exemplo n.º 6
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);
 }
 internal ReadStream(_WinInetCache.Entry entry, SafeUnlockUrlCacheEntryFile handle, bool async)
         : base(entry.Filename, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete, 4096, async)
 {
     m_Key = entry.Key;
     m_Handle = handle;
     m_ReadTimeout = m_WriteTimeout = System.Threading.Timeout.Infinite;
 }