| 120 | } |
| 121 | |
| 122 | fn parse_sym_srv(symbol_path: &str, default_store: String) -> Result<impl Iterator<Item = String>> { |
| 123 | // https://docs.microsoft.com/en-us/windows/win32/debug/using-symsrv |
| 124 | // Why |
| 125 | |
| 126 | // ... the symbol path (_NT_SYMBOL_PATH environment variable) can be made up of several path |
| 127 | // elements separated by semicolons. If any one or more of these path elements begins with |
| 128 | // the text "srv*", then the element is a symbol server and will use SymSrv to locate |
| 129 | // symbol files. |
| 130 | |
| 131 | // If the "srv*" text is not specified but the actual path element is a symbol server store, |
| 132 | // then the symbol handler will act as if "srv*" were specified. The symbol handler makes |
| 133 | // this determination by searching for the existence of a file called "pingme.txt" in |
| 134 | // the root directory of the specified path. |
| 135 | |
| 136 | // ... symbol servers are made up of symbol store elements separated by asterisks. There can |
| 137 | // be up to 10 symbol stores after the "srv*" prefix. |
| 138 | |
| 139 | let mut sym_srv_results: Vec<String> = vec![]; |
| 140 | |
| 141 | // 'path elements separated by semicolons' |
| 142 | for path_element in symbol_path.split(';') { |
| 143 | // 'begins with the text "srv*"' |
| 144 | if path_element.to_lowercase().starts_with("srv*") { |
| 145 | // 'symbol store elements separated by asterisks' |
| 146 | for store_element in path_element[4..].split('*') { |
| 147 | if store_element.is_empty() { |
| 148 | sym_srv_results.push(default_store.clone()); |
| 149 | } else { |
| 150 | sym_srv_results.push(store_element.to_string()); |
| 151 | } |
| 152 | } |
| 153 | } else if PathBuf::from(path_element).exists() { |
| 154 | // 'searching for the existence of a file called "pingme.txt" in the root directory' |
| 155 | let pingme_txt = path_element.to_string() + "/" + "pingme.txt"; |
| 156 | if PathBuf::from(pingme_txt).exists() { |
| 157 | sym_srv_results.push(path_element.to_string()); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | Ok(sym_srv_results.into_iter()) |
| 163 | } |
| 164 | |
| 165 | fn read_from_sym_store(bv: &BinaryView, path: &str) -> Result<(bool, Vec<u8>)> { |
| 166 | if !path.contains("://") { |