MCPcopy Create free account
hub / github.com/NoMercy-ac/NoMercy / DosDevicePath2LogicalPath

Method DosDevicePath2LogicalPath

Source/Client/NM_Engine/ProcessFunctions.cpp:290–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290std::string CProcessFunctions::DosDevicePath2LogicalPath(LPCSTR lpszDosPath)
291{
292 std::string strResult;
293 char szTemp[MAX_PATH];
294 szTemp[0] = '\0';
295
296 if (lpszDosPath == NULL || strlen(lpszDosPath) == NULL || !GetLogicalDriveStringsA(_countof(szTemp) - 1, szTemp))
297 return strResult;
298
299 char szName[MAX_PATH];
300 char szDrive[3] = " :";
301 BOOL bFound = FALSE;
302 char* p = szTemp;
303
304 do {
305 // Copy the drive letter to the template string
306 *szDrive = *p;
307
308 // Look up each device name
309 if (QueryDosDeviceA(szDrive, szName, _countof(szName)))
310 {
311 UINT uNameLen = (UINT)strlen(szName);
312
313 if (uNameLen < MAX_PATH)
314 {
315 bFound = strncmp(lpszDosPath, szName, uNameLen) == 0;
316
317 if (bFound) {
318 // Reconstruct pszFilename using szTemp
319 // Replace device path with DOS path
320 char szTempFile[MAX_PATH];
321 sprintf_s(szTempFile, xorstr("%s%s").crypt_get(), szDrive, lpszDosPath + uNameLen);
322 strResult = szTempFile;
323 }
324 }
325 }
326
327 // Go to the next NULL character.
328 while (*p++);
329 } while (!bFound && *p); // end of string
330
331 return strResult;
332}
333

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected