Index: src/ch/Device IO.h =================================================================== diff -u -N -rd5c3edd0d167db9b5d47d04248820fda49499a5e -raa6bff57279b9f9cfc276e9adab2763e2900878d --- src/ch/Device IO.h (.../Device IO.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/Device IO.h (.../Device IO.h) (revision aa6bff57279b9f9cfc276e9adab2763e2900878d) @@ -83,15 +83,17 @@ // only NT bool GetSignature(LPCTSTR lpszDrive, LPTSTR lpszBuffer, int iSize) { - TCHAR szMapping[1024], szQuery[16384], szSymbolic[1024]; - + std::auto_ptr szMapping(new TCHAR[1024]); + std::auto_ptr szQuery(new TCHAR[16384]); + std::auto_ptr szSymbolic(new TCHAR[1024]); + // read mappings - if (QueryDosDevice(lpszDrive, szMapping, 1024) == 0) + if (QueryDosDevice(lpszDrive, szMapping.get(), 1024) == 0) return false; // search for all, to find out in which string is the signature int iCount, iCount2; - if ((iCount=QueryDosDevice(NULL, szQuery, 16384)) == 0) + if ((iCount=QueryDosDevice(NULL, szQuery.get(), 16384)) == 0) { TRACE("Encountered error #%lu @QueryDosDevice\n", GetLastError()); return false; @@ -102,22 +104,22 @@ TCHAR* pszOffset = NULL; while(iOffset < iCount) { - if(_tcsncmp(szQuery+iOffset, _T("STORAGE#Volume#"), _tcslen(_T("STORAGE#Volume#"))) == 0) + if(_tcsncmp(szQuery.get() + iOffset, _T("STORAGE#Volume#"), _tcslen(_T("STORAGE#Volume#"))) == 0) { - if((iCount2 = QueryDosDevice(szQuery+iOffset, szSymbolic, 1024)) == 0) + if((iCount2 = QueryDosDevice(szQuery.get() + iOffset, szSymbolic.get(), 1024)) == 0) return false; // now search for 'Signature' and extract (from szQuery+iOffset) - pszSignature=_tcsstr(szQuery+iOffset, _T("Signature")); + pszSignature=_tcsstr(szQuery.get() + iOffset, _T("Signature")); if (pszSignature == NULL) { - iOffset+=_tcslen(szQuery+iOffset)+1; + iOffset+=_tcslen(szQuery.get() + iOffset)+1; continue; } pszOffset=_tcsstr(pszSignature, _T("Offset")); if (pszOffset == NULL) { - iOffset+=_tcslen(szQuery+iOffset)+1; + iOffset+=_tcslen(szQuery.get() + iOffset)+1; continue; } @@ -129,19 +131,19 @@ while (iOffset2 < iCount2) { // compare szSymbolic+iOffset2 with szMapping - if (_tcscmp(szMapping, szSymbolic+iOffset2) == 0) + if (_tcscmp(szMapping.get(), szSymbolic.get() + iOffset2) == 0) { // found Signature & Offset - copy int iCnt=reinterpret_cast(pszOffset)-reinterpret_cast(pszSignature)+1; _tcsncpy(lpszBuffer, pszSignature, (iCnt > iSize) ? iSize : iCnt); return true; } - iOffset2+=_tcslen(szSymbolic)+1; + iOffset2+=_tcslen(szSymbolic.get())+1; } } - iOffset+=_tcslen(szQuery+iOffset)+1; + iOffset+=_tcslen(szQuery.get() + iOffset)+1; } return false;