Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * File path.c - managing path in debugging environments |
| 3 | * |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 4 | * Copyright (C) 2004,2008, Eric Pouech |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | #include <stdlib.h> |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | |
| 26 | #include "dbghelp_private.h" |
Eric Pouech | 7ea69cc | 2005-03-29 13:14:08 +0000 | [diff] [blame] | 27 | #include "winnls.h" |
Eric Pouech | 7ea69cc | 2005-03-29 13:14:08 +0000 | [diff] [blame] | 28 | #include "winternl.h" |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 29 | #include "wine/debug.h" |
| 30 | |
| 31 | WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); |
| 32 | |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 33 | static inline BOOL is_sep(char ch) {return ch == '/' || ch == '\\';} |
Eric Pouech | 8b86120 | 2007-02-21 21:55:30 +0100 | [diff] [blame] | 34 | static inline BOOL is_sepW(WCHAR ch) {return ch == '/' || ch == '\\';} |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 35 | |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 36 | static inline const char* file_name(const char* str) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 37 | { |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 38 | const char* p; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 39 | |
| 40 | for (p = str + strlen(str) - 1; p >= str && !is_sep(*p); p--); |
| 41 | return p + 1; |
| 42 | } |
| 43 | |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 44 | static inline const WCHAR* file_nameW(const WCHAR* str) |
| 45 | { |
| 46 | const WCHAR* p; |
| 47 | |
| 48 | for (p = str + strlenW(str) - 1; p >= str && !is_sepW(*p); p--); |
| 49 | return p + 1; |
| 50 | } |
| 51 | |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 52 | /****************************************************************** |
| 53 | * FindDebugInfoFile (DBGHELP.@) |
| 54 | * |
| 55 | */ |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 56 | HANDLE WINAPI FindDebugInfoFile(PCSTR FileName, PCSTR SymbolPath, PSTR DebugFilePath) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 57 | { |
| 58 | HANDLE h; |
| 59 | |
Eric van Beurden | 6929982 | 2008-01-17 17:21:00 -0500 | [diff] [blame] | 60 | h = CreateFileA(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 61 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 62 | if (h == INVALID_HANDLE_VALUE) |
| 63 | { |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 64 | if (!SearchPathA(SymbolPath, file_name(FileName), NULL, MAX_PATH, DebugFilePath, NULL)) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 65 | return NULL; |
| 66 | h = CreateFileA(DebugFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 67 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 68 | } |
| 69 | return (h == INVALID_HANDLE_VALUE) ? NULL : h; |
| 70 | } |
| 71 | |
| 72 | /****************************************************************** |
| 73 | * FindDebugInfoFileEx (DBGHELP.@) |
| 74 | * |
| 75 | */ |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 76 | HANDLE WINAPI FindDebugInfoFileEx(PCSTR FileName, PCSTR SymbolPath, |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 77 | PSTR DebugFilePath, |
| 78 | PFIND_DEBUG_FILE_CALLBACK Callback, |
| 79 | PVOID CallerData) |
| 80 | { |
| 81 | FIXME("(%s %s %p %p %p): stub\n", |
Eric van Beurden | 6929982 | 2008-01-17 17:21:00 -0500 | [diff] [blame] | 82 | debugstr_a(FileName), debugstr_a(SymbolPath), debugstr_a(DebugFilePath), Callback, CallerData); |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 83 | return NULL; |
| 84 | } |
| 85 | |
| 86 | /****************************************************************** |
Eric Pouech | bcc1913 | 2007-02-21 21:55:10 +0100 | [diff] [blame] | 87 | * FindExecutableImageExW (DBGHELP.@) |
| 88 | * |
| 89 | */ |
| 90 | HANDLE WINAPI FindExecutableImageExW(PCWSTR FileName, PCWSTR SymbolPath, PWSTR ImageFilePath, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 91 | PFIND_EXE_FILE_CALLBACKW Callback, PVOID user) |
Eric Pouech | bcc1913 | 2007-02-21 21:55:10 +0100 | [diff] [blame] | 92 | { |
| 93 | HANDLE h; |
| 94 | |
| 95 | if (Callback) FIXME("Unsupported callback yet\n"); |
| 96 | if (!SearchPathW(SymbolPath, FileName, NULL, MAX_PATH, ImageFilePath, NULL)) |
| 97 | return NULL; |
| 98 | h = CreateFileW(ImageFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 99 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 100 | return (h == INVALID_HANDLE_VALUE) ? NULL : h; |
| 101 | } |
| 102 | |
| 103 | /****************************************************************** |
| 104 | * FindExecutableImageEx (DBGHELP.@) |
| 105 | * |
| 106 | */ |
| 107 | HANDLE WINAPI FindExecutableImageEx(PCSTR FileName, PCSTR SymbolPath, PSTR ImageFilePath, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 108 | PFIND_EXE_FILE_CALLBACK Callback, PVOID user) |
Eric Pouech | bcc1913 | 2007-02-21 21:55:10 +0100 | [diff] [blame] | 109 | { |
| 110 | HANDLE h; |
| 111 | |
| 112 | if (Callback) FIXME("Unsupported callback yet\n"); |
| 113 | if (!SearchPathA(SymbolPath, FileName, NULL, MAX_PATH, ImageFilePath, NULL)) |
| 114 | return NULL; |
| 115 | h = CreateFileA(ImageFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 116 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 117 | return (h == INVALID_HANDLE_VALUE) ? NULL : h; |
| 118 | } |
| 119 | |
| 120 | /****************************************************************** |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 121 | * FindExecutableImage (DBGHELP.@) |
| 122 | * |
| 123 | */ |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 124 | HANDLE WINAPI FindExecutableImage(PCSTR FileName, PCSTR SymbolPath, PSTR ImageFilePath) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 125 | { |
Eric Pouech | bcc1913 | 2007-02-21 21:55:10 +0100 | [diff] [blame] | 126 | return FindExecutableImageEx(FileName, SymbolPath, ImageFilePath, NULL, NULL); |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /*********************************************************************** |
| 130 | * MakeSureDirectoryPathExists (DBGHELP.@) |
| 131 | */ |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 132 | BOOL WINAPI MakeSureDirectoryPathExists(PCSTR DirPath) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 133 | { |
Wolfgang Schwotzer | 0d4f4d9 | 2004-10-05 02:05:28 +0000 | [diff] [blame] | 134 | char path[MAX_PATH]; |
| 135 | const char *p = DirPath; |
| 136 | int n; |
| 137 | |
| 138 | if (p[0] && p[1] == ':') p += 2; |
| 139 | while (*p == '\\') p++; /* skip drive root */ |
| 140 | while ((p = strchr(p, '\\')) != NULL) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 141 | { |
Wolfgang Schwotzer | 0d4f4d9 | 2004-10-05 02:05:28 +0000 | [diff] [blame] | 142 | n = p - DirPath + 1; |
| 143 | memcpy(path, DirPath, n); |
| 144 | path[n] = '\0'; |
| 145 | if( !CreateDirectoryA(path, NULL) && |
| 146 | (GetLastError() != ERROR_ALREADY_EXISTS)) |
| 147 | return FALSE; |
| 148 | p++; |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 149 | } |
Wolfgang Schwotzer | 0d4f4d9 | 2004-10-05 02:05:28 +0000 | [diff] [blame] | 150 | if (GetLastError() == ERROR_ALREADY_EXISTS) |
| 151 | SetLastError(ERROR_SUCCESS); |
| 152 | |
| 153 | return TRUE; |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 154 | } |
| 155 | |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 156 | /****************************************************************** |
Eric Pouech | 8b86120 | 2007-02-21 21:55:30 +0100 | [diff] [blame] | 157 | * SymMatchFileNameW (DBGHELP.@) |
| 158 | * |
| 159 | */ |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 160 | BOOL WINAPI SymMatchFileNameW(PCWSTR file, PCWSTR match, |
| 161 | PWSTR* filestop, PWSTR* matchstop) |
Eric Pouech | 8b86120 | 2007-02-21 21:55:30 +0100 | [diff] [blame] | 162 | { |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 163 | PCWSTR fptr; |
| 164 | PCWSTR mptr; |
Eric Pouech | 8b86120 | 2007-02-21 21:55:30 +0100 | [diff] [blame] | 165 | |
| 166 | TRACE("(%s %s %p %p)\n", |
| 167 | debugstr_w(file), debugstr_w(match), filestop, matchstop); |
| 168 | |
| 169 | fptr = file + strlenW(file) - 1; |
| 170 | mptr = match + strlenW(match) - 1; |
| 171 | |
| 172 | while (fptr >= file && mptr >= match) |
| 173 | { |
| 174 | if (toupperW(*fptr) != toupperW(*mptr) && !(is_sepW(*fptr) && is_sepW(*mptr))) |
| 175 | break; |
| 176 | fptr--; mptr--; |
| 177 | } |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 178 | if (filestop) *filestop = (PWSTR)fptr; |
| 179 | if (matchstop) *matchstop = (PWSTR)mptr; |
Eric Pouech | 8b86120 | 2007-02-21 21:55:30 +0100 | [diff] [blame] | 180 | |
| 181 | return mptr == match - 1; |
| 182 | } |
| 183 | |
| 184 | /****************************************************************** |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 185 | * SymMatchFileName (DBGHELP.@) |
| 186 | * |
| 187 | */ |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 188 | BOOL WINAPI SymMatchFileName(PCSTR file, PCSTR match, |
| 189 | PSTR* filestop, PSTR* matchstop) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 190 | { |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 191 | PCSTR fptr; |
| 192 | PCSTR mptr; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 193 | |
Eric van Beurden | 6929982 | 2008-01-17 17:21:00 -0500 | [diff] [blame] | 194 | TRACE("(%s %s %p %p)\n", debugstr_a(file), debugstr_a(match), filestop, matchstop); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 195 | |
| 196 | fptr = file + strlen(file) - 1; |
| 197 | mptr = match + strlen(match) - 1; |
| 198 | |
| 199 | while (fptr >= file && mptr >= match) |
| 200 | { |
| 201 | if (toupper(*fptr) != toupper(*mptr) && !(is_sep(*fptr) && is_sep(*mptr))) |
| 202 | break; |
| 203 | fptr--; mptr--; |
| 204 | } |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 205 | if (filestop) *filestop = (PSTR)fptr; |
| 206 | if (matchstop) *matchstop = (PSTR)mptr; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 207 | |
| 208 | return mptr == match - 1; |
| 209 | } |
| 210 | |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 211 | static BOOL do_searchW(PCWSTR file, PWSTR buffer, BOOL recurse, |
| 212 | PENUMDIRTREE_CALLBACKW cb, PVOID user) |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 213 | { |
| 214 | HANDLE h; |
| 215 | WIN32_FIND_DATAW fd; |
| 216 | unsigned pos; |
| 217 | BOOL found = FALSE; |
| 218 | static const WCHAR S_AllW[] = {'*','.','*','\0'}; |
| 219 | static const WCHAR S_DotW[] = {'.','\0'}; |
Eric van Beurden | 6929982 | 2008-01-17 17:21:00 -0500 | [diff] [blame] | 220 | static const WCHAR S_DotDotW[] = {'.','.','\0'}; |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 221 | |
| 222 | pos = strlenW(buffer); |
| 223 | if (buffer[pos - 1] != '\\') buffer[pos++] = '\\'; |
| 224 | strcpyW(buffer + pos, S_AllW); |
| 225 | if ((h = FindFirstFileW(buffer, &fd)) == INVALID_HANDLE_VALUE) |
| 226 | return FALSE; |
| 227 | /* doc doesn't specify how the tree is enumerated... |
| 228 | * doing a depth first based on, but may be wrong |
| 229 | */ |
| 230 | do |
| 231 | { |
| 232 | if (!strcmpW(fd.cFileName, S_DotW) || !strcmpW(fd.cFileName, S_DotDotW)) continue; |
| 233 | |
| 234 | strcpyW(buffer + pos, fd.cFileName); |
| 235 | if (recurse && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) |
| 236 | found = do_searchW(file, buffer, TRUE, cb, user); |
Michael Stefaniuc | 3c3a9b5 | 2009-01-19 10:24:06 +0100 | [diff] [blame] | 237 | else if (SymMatchFileNameW(buffer, file, NULL, NULL)) |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 238 | { |
| 239 | if (!cb || cb(buffer, user)) found = TRUE; |
| 240 | } |
| 241 | } while (!found && FindNextFileW(h, &fd)); |
| 242 | if (!found) buffer[--pos] = '\0'; |
| 243 | FindClose(h); |
| 244 | |
| 245 | return found; |
| 246 | } |
| 247 | |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 248 | /*********************************************************************** |
Eric Pouech | 9e1f9ec | 2007-02-21 21:55:41 +0100 | [diff] [blame] | 249 | * SearchTreeForFileW (DBGHELP.@) |
| 250 | */ |
| 251 | BOOL WINAPI SearchTreeForFileW(PCWSTR root, PCWSTR file, PWSTR buffer) |
| 252 | { |
| 253 | TRACE("(%s, %s, %p)\n", |
| 254 | debugstr_w(root), debugstr_w(file), buffer); |
| 255 | strcpyW(buffer, root); |
| 256 | return do_searchW(file, buffer, TRUE, NULL, NULL); |
| 257 | } |
| 258 | |
| 259 | /*********************************************************************** |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 260 | * SearchTreeForFile (DBGHELP.@) |
| 261 | */ |
Eric Pouech | bdf32ee | 2006-01-23 16:37:48 +0100 | [diff] [blame] | 262 | BOOL WINAPI SearchTreeForFile(PCSTR root, PCSTR file, PSTR buffer) |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 263 | { |
Eric Pouech | 9e1f9ec | 2007-02-21 21:55:41 +0100 | [diff] [blame] | 264 | WCHAR rootW[MAX_PATH]; |
| 265 | WCHAR fileW[MAX_PATH]; |
| 266 | WCHAR bufferW[MAX_PATH]; |
| 267 | BOOL ret; |
| 268 | |
| 269 | MultiByteToWideChar(CP_ACP, 0, root, -1, rootW, MAX_PATH); |
| 270 | MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH); |
| 271 | ret = SearchTreeForFileW(rootW, fileW, bufferW); |
| 272 | if (ret) |
| 273 | WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_PATH, NULL, NULL); |
| 274 | return ret; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | /****************************************************************** |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 278 | * EnumDirTreeW (DBGHELP.@) |
| 279 | * |
| 280 | * |
| 281 | */ |
| 282 | BOOL WINAPI EnumDirTreeW(HANDLE hProcess, PCWSTR root, PCWSTR file, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 283 | PWSTR buffer, PENUMDIRTREE_CALLBACKW cb, PVOID user) |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 284 | { |
| 285 | TRACE("(%p %s %s %p %p %p)\n", |
| 286 | hProcess, debugstr_w(root), debugstr_w(file), buffer, cb, user); |
| 287 | |
| 288 | strcpyW(buffer, root); |
| 289 | return do_searchW(file, buffer, TRUE, cb, user); |
| 290 | } |
| 291 | |
| 292 | /****************************************************************** |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 293 | * EnumDirTree (DBGHELP.@) |
| 294 | * |
| 295 | * |
| 296 | */ |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 297 | struct enum_dir_treeWA |
| 298 | { |
| 299 | PENUMDIRTREE_CALLBACK cb; |
| 300 | void* user; |
| 301 | char name[MAX_PATH]; |
| 302 | }; |
| 303 | |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 304 | static BOOL CALLBACK enum_dir_treeWA(PCWSTR name, PVOID user) |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 305 | { |
| 306 | struct enum_dir_treeWA* edt = user; |
| 307 | |
| 308 | WideCharToMultiByte(CP_ACP, 0, name, -1, edt->name, MAX_PATH, NULL, NULL); |
| 309 | return edt->cb(edt->name, edt->user); |
| 310 | } |
| 311 | |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 312 | BOOL WINAPI EnumDirTree(HANDLE hProcess, PCSTR root, PCSTR file, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 313 | PSTR buffer, PENUMDIRTREE_CALLBACK cb, PVOID user) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 314 | { |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 315 | WCHAR rootW[MAX_PATH]; |
| 316 | WCHAR fileW[MAX_PATH]; |
| 317 | WCHAR bufferW[MAX_PATH]; |
| 318 | struct enum_dir_treeWA edt; |
| 319 | BOOL ret; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 320 | |
Eric Pouech | c0be003 | 2007-02-21 21:55:35 +0100 | [diff] [blame] | 321 | edt.cb = cb; |
| 322 | edt.user = user; |
| 323 | MultiByteToWideChar(CP_ACP, 0, root, -1, rootW, MAX_PATH); |
| 324 | MultiByteToWideChar(CP_ACP, 0, file, -1, fileW, MAX_PATH); |
| 325 | if ((ret = EnumDirTreeW(hProcess, rootW, fileW, bufferW, enum_dir_treeWA, &edt))) |
| 326 | WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_PATH, NULL, NULL); |
| 327 | return ret; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | struct sffip |
| 331 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 332 | PFINDFILEINPATHCALLBACKW cb; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 333 | void* user; |
| 334 | }; |
| 335 | |
Eric Pouech | 0f86dd9 | 2006-02-20 11:14:34 +0100 | [diff] [blame] | 336 | /* checks that buffer (as found by matching the name) matches the info |
| 337 | * (information is based on file type) |
| 338 | * returns TRUE when file is found, FALSE to continue searching |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 339 | * (NB this is the opposite convention of SymFindFileInPathProc) |
Eric Pouech | 0f86dd9 | 2006-02-20 11:14:34 +0100 | [diff] [blame] | 340 | */ |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 341 | static BOOL CALLBACK sffip_cb(PCWSTR buffer, PVOID user) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 342 | { |
Michael Stefaniuc | 3c3a9b5 | 2009-01-19 10:24:06 +0100 | [diff] [blame] | 343 | struct sffip* s = user; |
Eric Pouech | 0f86dd9 | 2006-02-20 11:14:34 +0100 | [diff] [blame] | 344 | |
Eric Pouech | 07baf69 | 2008-08-29 21:50:59 +0200 | [diff] [blame] | 345 | if (!s->cb) return TRUE; |
Eric Pouech | 7ea69cc | 2005-03-29 13:14:08 +0000 | [diff] [blame] | 346 | /* yes, EnumDirTree/do_search and SymFindFileInPath callbacks use the opposite |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 347 | * convention to stop/continue enumeration. sigh. |
| 348 | */ |
Michael Stefaniuc | 3c3a9b5 | 2009-01-19 10:24:06 +0100 | [diff] [blame] | 349 | return !(s->cb)(buffer, s->user); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | /****************************************************************** |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 353 | * SymFindFileInPathW (DBGHELP.@) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 354 | * |
| 355 | */ |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 356 | BOOL WINAPI SymFindFileInPathW(HANDLE hProcess, PCWSTR searchPath, PCWSTR full_path, |
| 357 | PVOID id, DWORD two, DWORD three, DWORD flags, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 358 | PWSTR buffer, PFINDFILEINPATHCALLBACKW cb, |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 359 | PVOID user) |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 360 | { |
| 361 | struct sffip s; |
| 362 | struct process* pcs = process_find_by_handle(hProcess); |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 363 | WCHAR tmp[MAX_PATH]; |
| 364 | WCHAR* ptr; |
| 365 | const WCHAR* filename; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 366 | |
Eric van Beurden | 6929982 | 2008-01-17 17:21:00 -0500 | [diff] [blame] | 367 | TRACE("(hProcess = %p, searchPath = %s, full_path = %s, id = %p, two = 0x%08x, three = 0x%08x, flags = 0x%08x, buffer = %p, cb = %p, user = %p)\n", |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 368 | hProcess, debugstr_w(searchPath), debugstr_w(full_path), |
| 369 | id, two, three, flags, buffer, cb, user); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 370 | |
| 371 | if (!pcs) return FALSE; |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 372 | if (!searchPath) searchPath = pcs->search_path; |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 373 | |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 374 | s.cb = cb; |
| 375 | s.user = user; |
| 376 | |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 377 | filename = file_nameW(full_path); |
Eric Pouech | 7ea69cc | 2005-03-29 13:14:08 +0000 | [diff] [blame] | 378 | |
| 379 | /* first check full path to file */ |
| 380 | if (sffip_cb(full_path, &s)) |
| 381 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 382 | strcpyW(buffer, full_path); |
Eric Pouech | 7ea69cc | 2005-03-29 13:14:08 +0000 | [diff] [blame] | 383 | return TRUE; |
| 384 | } |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 385 | |
| 386 | while (searchPath) |
| 387 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 388 | ptr = strchrW(searchPath, ';'); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 389 | if (ptr) |
| 390 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 391 | memcpy(tmp, searchPath, (ptr - searchPath) * sizeof(WCHAR)); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 392 | tmp[ptr - searchPath] = 0; |
| 393 | searchPath = ptr + 1; |
| 394 | } |
| 395 | else |
| 396 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 397 | strcpyW(tmp, searchPath); |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 398 | searchPath = NULL; |
| 399 | } |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 400 | if (do_searchW(filename, tmp, FALSE, sffip_cb, &s)) |
Eric Pouech | 0f86dd9 | 2006-02-20 11:14:34 +0100 | [diff] [blame] | 401 | { |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 402 | strcpyW(buffer, tmp); |
Raphael Junqueira | 92000a9 | 2005-05-18 09:42:17 +0000 | [diff] [blame] | 403 | return TRUE; |
| 404 | } |
Eric Pouech | eb25084 | 2004-06-14 17:58:31 +0000 | [diff] [blame] | 405 | } |
Eric Pouech | 800864a | 2004-04-05 22:21:27 +0000 | [diff] [blame] | 406 | return FALSE; |
| 407 | } |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 408 | |
| 409 | /****************************************************************** |
| 410 | * SymFindFileInPath (DBGHELP.@) |
| 411 | * |
| 412 | */ |
| 413 | BOOL WINAPI SymFindFileInPath(HANDLE hProcess, PCSTR searchPath, PCSTR full_path, |
| 414 | PVOID id, DWORD two, DWORD three, DWORD flags, |
Francois Gouget | 9d2f48d | 2007-08-03 00:51:09 +0200 | [diff] [blame] | 415 | PSTR buffer, PFINDFILEINPATHCALLBACK cb, |
Eric Pouech | 2f0ed90 | 2007-02-21 21:55:46 +0100 | [diff] [blame] | 416 | PVOID user) |
| 417 | { |
| 418 | WCHAR searchPathW[MAX_PATH]; |
| 419 | WCHAR full_pathW[MAX_PATH]; |
| 420 | WCHAR bufferW[MAX_PATH]; |
| 421 | struct enum_dir_treeWA edt; |
| 422 | BOOL ret; |
| 423 | |
| 424 | /* a PFINDFILEINPATHCALLBACK and a PENUMDIRTREE_CALLBACK have actually the |
| 425 | * same signature & semantics, hence we can reuse the EnumDirTree W->A |
| 426 | * conversion helper |
| 427 | */ |
| 428 | edt.cb = cb; |
| 429 | edt.user = user; |
| 430 | if (searchPath) |
| 431 | MultiByteToWideChar(CP_ACP, 0, searchPath, -1, searchPathW, MAX_PATH); |
| 432 | MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH); |
| 433 | if ((ret = SymFindFileInPathW(hProcess, searchPath ? searchPathW : NULL, full_pathW, |
| 434 | id, two, three, flags, |
| 435 | bufferW, enum_dir_treeWA, &edt))) |
| 436 | WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, MAX_PATH, NULL, NULL); |
| 437 | return ret; |
| 438 | } |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 439 | |
| 440 | struct module_find |
| 441 | { |
| 442 | enum module_type kind; |
| 443 | /* pe: dw1 DWORD:timestamp |
| 444 | * dw2 size of image (from PE header) |
| 445 | * pdb: guid PDB guid (if DS PDB file) |
| 446 | * or dw1 PDB timestamp (if JG PDB file) |
| 447 | * dw2 PDB age |
| 448 | * elf: dw1 DWORD:CRC 32 of ELF image (Wine only) |
| 449 | */ |
| 450 | const GUID* guid; |
| 451 | DWORD dw1; |
| 452 | DWORD dw2; |
| 453 | WCHAR filename[MAX_PATH]; |
| 454 | unsigned matched; |
| 455 | }; |
| 456 | |
| 457 | /* checks that buffer (as found by matching the name) matches the info |
| 458 | * (information is based on file type) |
| 459 | * returns TRUE when file is found, FALSE to continue searching |
| 460 | * (NB this is the opposite convention of SymFindFileInPathProc) |
| 461 | */ |
| 462 | static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) |
| 463 | { |
Michael Stefaniuc | 3c3a9b5 | 2009-01-19 10:24:06 +0100 | [diff] [blame] | 464 | struct module_find* mf = user; |
Eric Pouech | 2994e98 | 2008-08-29 21:50:53 +0200 | [diff] [blame] | 465 | DWORD size, checksum, timestamp; |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 466 | unsigned matched = 0; |
| 467 | |
| 468 | /* the matching weights: |
| 469 | * +1 if a file with same name is found and is a decent file of expected type |
| 470 | * +1 if first parameter and second parameter match |
| 471 | */ |
| 472 | |
| 473 | /* FIXME: should check that id/two match the file pointed |
| 474 | * by buffer |
| 475 | */ |
| 476 | switch (mf->kind) |
| 477 | { |
| 478 | case DMT_PE: |
| 479 | { |
| 480 | HANDLE hFile, hMap; |
| 481 | void* mapping; |
| 482 | DWORD timestamp; |
| 483 | |
| 484 | timestamp = ~mf->dw1; |
| 485 | size = ~mf->dw2; |
| 486 | hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 487 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 488 | if (hFile == INVALID_HANDLE_VALUE) return FALSE; |
| 489 | if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) |
| 490 | { |
| 491 | if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) |
| 492 | { |
| 493 | IMAGE_NT_HEADERS* nth = RtlImageNtHeader(mapping); |
| 494 | |
| 495 | matched++; |
| 496 | timestamp = nth->FileHeader.TimeDateStamp; |
| 497 | size = nth->OptionalHeader.SizeOfImage; |
| 498 | UnmapViewOfFile(mapping); |
| 499 | } |
| 500 | CloseHandle(hMap); |
| 501 | } |
| 502 | CloseHandle(hFile); |
| 503 | if (timestamp != mf->dw1) |
| 504 | WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer)); |
| 505 | if (size != mf->dw2) |
| 506 | WARN("Found %s, but wrong size\n", debugstr_w(buffer)); |
| 507 | if (timestamp == mf->dw1 && size == mf->dw2) matched++; |
| 508 | } |
| 509 | break; |
| 510 | case DMT_ELF: |
| 511 | if (elf_fetch_file_info(buffer, 0, &size, &checksum)) |
| 512 | { |
| 513 | matched++; |
| 514 | if (checksum == mf->dw1) matched++; |
| 515 | else |
| 516 | WARN("Found %s, but wrong checksums: %08x %08x\n", |
| 517 | debugstr_w(buffer), checksum, mf->dw1); |
| 518 | } |
| 519 | else |
| 520 | { |
| 521 | WARN("Couldn't read %s\n", debugstr_w(buffer)); |
| 522 | return FALSE; |
| 523 | } |
| 524 | break; |
Ken Thomases | d7466e0 | 2009-03-13 11:48:00 -0500 | [diff] [blame] | 525 | case DMT_MACHO: |
| 526 | if (macho_fetch_file_info(buffer, 0, &size, &checksum)) |
| 527 | { |
| 528 | matched++; |
| 529 | if (checksum == mf->dw1) matched++; |
| 530 | else |
| 531 | WARN("Found %s, but wrong checksums: %08x %08x\n", |
| 532 | debugstr_w(buffer), checksum, mf->dw1); |
| 533 | } |
| 534 | else |
| 535 | { |
| 536 | WARN("Couldn't read %s\n", debugstr_w(buffer)); |
| 537 | return FALSE; |
| 538 | } |
| 539 | break; |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 540 | case DMT_PDB: |
| 541 | { |
| 542 | struct pdb_lookup pdb_lookup; |
| 543 | char fn[MAX_PATH]; |
| 544 | |
| 545 | WideCharToMultiByte(CP_ACP, 0, buffer, -1, fn, MAX_PATH, NULL, NULL); |
| 546 | pdb_lookup.filename = fn; |
| 547 | |
| 548 | if (!pdb_fetch_file_info(&pdb_lookup)) return FALSE; |
| 549 | matched++; |
| 550 | switch (pdb_lookup.kind) |
| 551 | { |
| 552 | case PDB_JG: |
| 553 | if (mf->guid) |
| 554 | { |
| 555 | WARN("Found %s, but wrong PDB version\n", debugstr_w(buffer)); |
| 556 | } |
| 557 | else if (pdb_lookup.u.jg.timestamp == mf->dw1) |
| 558 | matched++; |
| 559 | else |
| 560 | WARN("Found %s, but wrong signature: %08x %08x\n", |
| 561 | debugstr_w(buffer), pdb_lookup.u.jg.timestamp, mf->dw1); |
| 562 | break; |
| 563 | case PDB_DS: |
| 564 | if (!mf->guid) |
| 565 | { |
| 566 | WARN("Found %s, but wrong PDB version\n", debugstr_w(buffer)); |
| 567 | } |
| 568 | else if (!memcmp(&pdb_lookup.u.ds.guid, mf->guid, sizeof(GUID))) |
| 569 | matched++; |
| 570 | else |
| 571 | WARN("Found %s, but wrong GUID: %s %s\n", |
| 572 | debugstr_w(buffer), debugstr_guid(&pdb_lookup.u.ds.guid), |
| 573 | debugstr_guid(mf->guid)); |
| 574 | break; |
| 575 | } |
| 576 | if (pdb_lookup.age != mf->dw2) |
| 577 | { |
| 578 | matched--; |
| 579 | WARN("Found %s, but wrong age: %08x %08x\n", |
| 580 | debugstr_w(buffer), pdb_lookup.age, mf->dw2); |
| 581 | } |
| 582 | } |
| 583 | break; |
Eric Pouech | 2994e98 | 2008-08-29 21:50:53 +0200 | [diff] [blame] | 584 | case DMT_DBG: |
| 585 | { |
| 586 | HANDLE hFile, hMap; |
| 587 | void* mapping; |
| 588 | |
| 589 | timestamp = ~mf->dw1; |
| 590 | hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 591 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 592 | if (hFile == INVALID_HANDLE_VALUE) return FALSE; |
| 593 | if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL) |
| 594 | { |
| 595 | if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) |
| 596 | { |
| 597 | const IMAGE_SEPARATE_DEBUG_HEADER* hdr; |
Michael Stefaniuc | 3c3a9b5 | 2009-01-19 10:24:06 +0100 | [diff] [blame] | 598 | hdr = mapping; |
Eric Pouech | 2994e98 | 2008-08-29 21:50:53 +0200 | [diff] [blame] | 599 | |
| 600 | if (hdr->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE) |
| 601 | { |
| 602 | matched++; |
| 603 | timestamp = hdr->TimeDateStamp; |
| 604 | } |
| 605 | UnmapViewOfFile(mapping); |
| 606 | } |
| 607 | CloseHandle(hMap); |
| 608 | } |
| 609 | CloseHandle(hFile); |
| 610 | if (timestamp == mf->dw1) matched++; |
| 611 | else WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer)); |
| 612 | } |
| 613 | break; |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 614 | default: |
| 615 | FIXME("What the heck??\n"); |
| 616 | return FALSE; |
| 617 | } |
| 618 | if (matched > mf->matched) |
| 619 | { |
| 620 | strcpyW(mf->filename, buffer); |
| 621 | mf->matched = matched; |
| 622 | } |
| 623 | /* yes, EnumDirTree/do_search and SymFindFileInPath callbacks use the opposite |
| 624 | * convention to stop/continue enumeration. sigh. |
| 625 | */ |
| 626 | return mf->matched == 2; |
| 627 | } |
| 628 | |
| 629 | BOOL path_find_symbol_file(const struct process* pcs, PCSTR full_path, |
Eric Pouech | 01e69c7 | 2008-10-18 09:15:03 +0200 | [diff] [blame] | 630 | const GUID* guid, DWORD dw1, DWORD dw2, PSTR buffer, |
| 631 | BOOL* is_unmatched) |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 632 | { |
| 633 | struct module_find mf; |
| 634 | WCHAR full_pathW[MAX_PATH]; |
| 635 | WCHAR tmp[MAX_PATH]; |
| 636 | WCHAR* ptr; |
| 637 | const WCHAR* filename; |
| 638 | WCHAR* searchPath = pcs->search_path; |
| 639 | |
| 640 | TRACE("(pcs = %p, full_path = %s, guid = %s, dw1 = 0x%08x, dw2 = 0x%08x, buffer = %p)\n", |
| 641 | pcs, debugstr_a(full_path), debugstr_guid(guid), dw1, dw2, buffer); |
| 642 | |
| 643 | mf.guid = guid; |
| 644 | mf.dw1 = dw1; |
| 645 | mf.dw2 = dw2; |
| 646 | mf.matched = 0; |
| 647 | |
| 648 | MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH); |
| 649 | filename = file_nameW(full_pathW); |
| 650 | mf.kind = module_get_type_by_name(filename); |
Eric Pouech | 01e69c7 | 2008-10-18 09:15:03 +0200 | [diff] [blame] | 651 | *is_unmatched = FALSE; |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 652 | |
| 653 | /* first check full path to file */ |
| 654 | if (module_find_cb(full_pathW, &mf)) |
| 655 | { |
| 656 | WideCharToMultiByte(CP_ACP, 0, full_pathW, -1, buffer, MAX_PATH, NULL, NULL); |
| 657 | return TRUE; |
| 658 | } |
| 659 | |
| 660 | while (searchPath) |
| 661 | { |
| 662 | ptr = strchrW(searchPath, ';'); |
| 663 | if (ptr) |
| 664 | { |
| 665 | memcpy(tmp, searchPath, (ptr - searchPath) * sizeof(WCHAR)); |
| 666 | tmp[ptr - searchPath] = '\0'; |
| 667 | searchPath = ptr + 1; |
| 668 | } |
| 669 | else |
| 670 | { |
| 671 | strcpyW(tmp, searchPath); |
| 672 | searchPath = NULL; |
| 673 | } |
| 674 | if (do_searchW(filename, tmp, FALSE, module_find_cb, &mf)) |
| 675 | { |
| 676 | /* return first fully matched file */ |
| 677 | WideCharToMultiByte(CP_ACP, 0, tmp, -1, buffer, MAX_PATH, NULL, NULL); |
| 678 | return TRUE; |
| 679 | } |
| 680 | } |
| 681 | /* if no fully matching file is found, return the best matching file if any */ |
| 682 | if ((dbghelp_options & SYMOPT_LOAD_ANYTHING) && mf.matched) |
| 683 | { |
| 684 | WideCharToMultiByte(CP_ACP, 0, mf.filename, -1, buffer, MAX_PATH, NULL, NULL); |
Eric Pouech | 01e69c7 | 2008-10-18 09:15:03 +0200 | [diff] [blame] | 685 | *is_unmatched = TRUE; |
Eric Pouech | d600115 | 2008-08-29 21:50:46 +0200 | [diff] [blame] | 686 | return TRUE; |
| 687 | } |
| 688 | return FALSE; |
| 689 | } |