Esempio n. 1
0
        public bool TryGetFile(string fileName, string indexString, SymStoreResult result, out Stream fileData)
        {
            // try and get the file from this store
            if (TryGetFileLocal(fileName, indexString, result, out fileData))
            {
                return(true);
            }

            // if there is backing store try getting it from there and cache it in this store
            if (BackingStore != null)
            {
                Stream backingFileData;
                if (BackingStore.TryGetFile(fileName, indexString, result, out backingFileData))
                {
                    WriteFile(fileName, indexString, backingFileData);
                    if (backingFileData != null)
                    {
                        backingFileData.Dispose();
                    }
                    if (TryGetFileLocal(fileName, indexString, result, out fileData))
                    {
                        return(true);
                    }
                }
            }

            // if nothing has worked yet, fail
            return(false);
        }
Esempio n. 2
0
        public bool TryGetFile(string fileName, string indexString, SymStoreResult result)
        {
            Stream unused;
            bool   ret = TryGetFile(fileName, indexString, result, out unused);

            if (unused != null)
            {
                unused.Dispose();
            }
            return(ret);
        }
Esempio n. 3
0
        static string GetPdbFileForModule(string fileName)
        {
            string retVal;

            // look in the "cache" of already successfully opened
            if (s_pdbFileForModule.TryGetValue(fileName, out retVal))
            {
                return(retVal);
            }

            retVal = null;
            CodeViewDebugData cvdd = CvDataFromPE(fileName);

            if (cvdd != null)
            {
                if (s_symStore == null)
                {
                    s_symStore = SymStore.FromPath(s_symbolServerPath);
                }

                if (s_symStore != null)
                {
                    Stream         pdbStream;
                    string         indexString   = cvdd.Signature.ToString().Replace("-", "").ToUpper() + cvdd.Age.ToString();
                    string         localFileName = Path.GetFileName(cvdd.PdbPath);
                    SymStoreResult symResult     = new SymStoreResult();
                    if (s_symStore.TryGetFile(localFileName, indexString, symResult, out pdbStream))
                    {
                        retVal = symResult.CachedPath;
                    }
                }
            }

            s_pdbFileForModule.Add(fileName, retVal);
            return(retVal);
        }
Esempio n. 4
0
        private bool TryGetFileLocal(string fileName, string indexString, SymStoreResult result, out Stream fileData)
        {
            fileData = null;
            string errorMessage = null;
            Uri request = new Uri(StoreRootAddress, fileName + "/" + indexString + "/" + fileName);

            //We could do better and actually calculate the backing path
            if (result.OriginalPath == null)
                result.OriginalPath = request.ToString();

            if (TryGetDataForUri(request, out fileData, out errorMessage))
            {
                result.CachedPath = request.AbsolutePath;
                result.MessageLog.Add("Retrieved " + request);
                return true;
            }
            else
            {
                result.MessageLog.Add(request.ToString() + " [" + errorMessage + "]");
            }

            string fileNameUnderBar = fileName.Substring(0, fileName.Length - 1) + "_";
            Uri requestUnderBar = new Uri(StoreRootAddress, fileName + "/" + indexString + "/" + fileNameUnderBar);
            Stream compressedFileData = null;
            if (TryGetDataForUri(requestUnderBar, out compressedFileData, out errorMessage))
            {
                fileData = CabUnpacker.Unpack(compressedFileData);
                result.CachedPath = requestUnderBar.AbsolutePath;
                result.MessageLog.Add("Retrieved " + requestUnderBar);
                return true;
            }
            else
            {
                result.MessageLog.Add(requestUnderBar.ToString() + " [" + errorMessage + "]");
            }

            Uri requestPtr = new Uri(StoreRootAddress, fileName + "/" + indexString + "/file.ptr");
            Stream ptrFileData;
            PtrFile ptr;
            if (!TryGetDataForUri(requestPtr, out ptrFileData, out errorMessage))
            {
                result.MessageLog.Add(requestPtr.ToString() + " [" + errorMessage + "]");
                return false;
            }
            else if (!PtrFile.TryParse(new StreamReader(ptrFileData).ReadToEnd(), out ptr))
            {
                result.MessageLog.Add(requestPtr.ToString() + " [Unable to parse]");
                return false;
            }
            else
            {
                result.MessageLog.Add(requestPtr.ToString() + " [Redirecting search]");
                result.MessageLog.Add("    Path: " + ptr.Path);
                if (!string.IsNullOrWhiteSpace(ptr.Message))
                {
                    result.MessageLog.Add("    Msg: " + ptr.Message);
                }
            }
            try
            {
                fileData = File.OpenRead(ptr.Path);
                result.CachedPath = ptr.Path;
            }
            catch (IOException e)
            {
                result.MessageLog.Add(ptr.Path + " [" + e.ToString() + "]");
                return false;
            }

            return true;
        }
Esempio n. 5
0
        public bool TryGetFile(string fileName, string indexString, SymStoreResult result, out Stream fileData)
        {
            // try and get the file from this store
            if (TryGetFileLocal(fileName, indexString, result, out fileData))
            {
                return true;
            }

            // if there is backing store try getting it from there and cache it in this store
            if (BackingStore != null)
            {
                Stream backingFileData;
                if (BackingStore.TryGetFile(fileName, indexString, result, out backingFileData))
                {
                    WriteFile(fileName, indexString, backingFileData);
                    if (backingFileData != null)
                        backingFileData.Dispose();
                    if (TryGetFileLocal(fileName, indexString, result, out fileData))
                        return true;
                }
            }

            // if nothing has worked yet, fail
            return false;
        }
Esempio n. 6
0
 public bool TryGetFile(string fileName, string indexString, SymStoreResult result)
 {
     Stream unused;
     bool ret = TryGetFile(fileName, indexString, result, out unused);
     if (unused != null)
         unused.Dispose();
     return ret;
 }
Esempio n. 7
0
        static string GetPdbFileForModule(string fileName)
        {
            string retVal;

            // look in the "cache" of already successfully opened
            if (s_pdbFileForModule.TryGetValue(fileName, out retVal))
            {
                return retVal;
            }

            retVal = null;
            CodeViewDebugData cvdd = CvDataFromPE(fileName);

            if (cvdd != null)
            {
                if (s_symStore == null)
                    s_symStore = SymStore.FromPath(s_symbolServerPath);

                if (s_symStore != null)
                {
                    Stream pdbStream;
                    string indexString = cvdd.Signature.ToString().Replace("-", "").ToUpper() + cvdd.Age.ToString();
                    string localFileName = Path.GetFileName(cvdd.PdbPath);
                    SymStoreResult symResult = new SymStoreResult();
                    if (s_symStore.TryGetFile(localFileName, indexString, symResult, out pdbStream))
                    {
                        retVal = symResult.CachedPath;
                    }
                }

            }

            s_pdbFileForModule.Add(fileName, retVal);
            return retVal;
        }
Esempio n. 8
0
        private bool TryGetFileLocal(string fileName, string indexString, SymStoreResult result, out Stream fileData)
        {
            fileData = null;
            string errorMessage = null;
            Uri    request      = new Uri(StoreRootAddress, fileName + "/" + indexString + "/" + fileName);

            //We could do better and actually calculate the backing path
            if (result.OriginalPath == null)
            {
                result.OriginalPath = request.ToString();
            }

            if (TryGetDataForUri(request, out fileData, out errorMessage))
            {
                result.CachedPath = request.AbsolutePath;
                result.MessageLog.Add("Retrieved " + request);
                return(true);
            }
            else
            {
                result.MessageLog.Add(request.ToString() + " [" + errorMessage + "]");
            }

            string fileNameUnderBar   = fileName.Substring(0, fileName.Length - 1) + "_";
            Uri    requestUnderBar    = new Uri(StoreRootAddress, fileName + "/" + indexString + "/" + fileNameUnderBar);
            Stream compressedFileData = null;

            if (TryGetDataForUri(requestUnderBar, out compressedFileData, out errorMessage))
            {
                fileData          = CabUnpacker.Unpack(compressedFileData);
                result.CachedPath = requestUnderBar.AbsolutePath;
                result.MessageLog.Add("Retrieved " + requestUnderBar);
                return(true);
            }
            else
            {
                result.MessageLog.Add(requestUnderBar.ToString() + " [" + errorMessage + "]");
            }

            Uri     requestPtr = new Uri(StoreRootAddress, fileName + "/" + indexString + "/file.ptr");
            Stream  ptrFileData;
            PtrFile ptr;

            if (!TryGetDataForUri(requestPtr, out ptrFileData, out errorMessage))
            {
                result.MessageLog.Add(requestPtr.ToString() + " [" + errorMessage + "]");
                return(false);
            }
            else if (!PtrFile.TryParse(new StreamReader(ptrFileData).ReadToEnd(), out ptr))
            {
                result.MessageLog.Add(requestPtr.ToString() + " [Unable to parse]");
                return(false);
            }
            else
            {
                result.MessageLog.Add(requestPtr.ToString() + " [Redirecting search]");
                result.MessageLog.Add("    Path: " + ptr.Path);
                if (!string.IsNullOrWhiteSpace(ptr.Message))
                {
                    result.MessageLog.Add("    Msg: " + ptr.Message);
                }
            }
            try
            {
                fileData          = File.OpenRead(ptr.Path);
                result.CachedPath = ptr.Path;
            }
            catch (IOException e)
            {
                result.MessageLog.Add(ptr.Path + " [" + e.ToString() + "]");
                return(false);
            }

            return(true);
        }