| 1223 | |
| 1224 | #ifdef WIN_NT |
| 1225 | static void expand_share_name(tstring& share_name) |
| 1226 | { |
| 1227 | /************************************** |
| 1228 | * |
| 1229 | * e x p a n d _ s h a r e _ n a m e |
| 1230 | * |
| 1231 | ************************************** |
| 1232 | * |
| 1233 | * Functional description |
| 1234 | * Look for a Windows NT share name at the |
| 1235 | * beginning of a string having the form: |
| 1236 | * |
| 1237 | * \!share name!\file name |
| 1238 | * |
| 1239 | * If such a share name is found, expand it |
| 1240 | * and then append the file name to the |
| 1241 | * expanded path. |
| 1242 | * |
| 1243 | **************************************/ |
| 1244 | |
| 1245 | TEXT workspace[MAXPATHLEN]; |
| 1246 | |
| 1247 | const TEXT* p = share_name.c_str(); |
| 1248 | if (*p++ != '\\' || *p++ != '!') { |
| 1249 | return; |
| 1250 | } |
| 1251 | |
| 1252 | fb_utils::copy_terminate(workspace, p, sizeof(workspace)); |
| 1253 | // We test for *q, too, to avoid buffer overrun. |
| 1254 | TEXT* q; |
| 1255 | for (q = workspace; *q && *p && *p != '!'; p++, q++); |
| 1256 | // empty body loop |
| 1257 | *q = '\0'; |
| 1258 | if (*p++ != '!' || *p++ != '\\') { |
| 1259 | return; |
| 1260 | } |
| 1261 | |
| 1262 | HKEY hkey; |
| 1263 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares", |
| 1264 | 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) |
| 1265 | { |
| 1266 | return; |
| 1267 | } |
| 1268 | |
| 1269 | BYTE data_buf[MAXPATHLEN]; |
| 1270 | DWORD d_size = MAXPATHLEN; |
| 1271 | DWORD type_code; |
| 1272 | LPBYTE data = data_buf; |
| 1273 | |
| 1274 | DWORD ret = RegQueryValueEx(hkey, workspace, NULL, &type_code, data, &d_size); |
| 1275 | if (ret == ERROR_MORE_DATA) |
| 1276 | { |
| 1277 | d_size++; |
| 1278 | data = (LPBYTE) gds__alloc((SLONG) d_size); |
| 1279 | // FREE: unknown |
| 1280 | if (!data) |
| 1281 | { |
| 1282 | // NOMEM: |
no test coverage detected