#include #include #include "storeinfo.h" #include "debug.h" HANDLE WINAPI OpenStore(LPCTSTR szDeviceName) { TCHAR szFileName[MAX_PATH]; memset( szFileName, 0, sizeof(szFileName)); wcscpy( szFileName, L"\\StoreMgr\\"); __try { wcsncat( szFileName, szDeviceName, MAX_PATH-15); } __except(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_BAD_ARGUMENTS); } return CreateFile( szFileName, 0, 0, NULL, 0, 0, NULL); } bool GetStorePartitionlist(HANDLE hStore, std::vector& list) { PARTINFO pi; memset(&pi, 0, sizeof(pi)); pi.cbSize= sizeof(PARTINFO); HANDLE hEnumPartitions = PSLFindFirstPartition(hStore, &pi); if (hEnumPartitions == INVALID_HANDLE_VALUE) { if (GetLastError()==ERROR_NO_MORE_ITEMS) { return true; } error("PSLFindFirstPartition"); return false; } list.push_back(pi); while (PSLFindNextPartition(hEnumPartitions, &pi)) list.push_back(pi); if (GetLastError()!=ERROR_NO_MORE_ITEMS) { error("PSLFindNextPartition"); return !list.empty(); } if (!PSLFindClosePartition(hEnumPartitions)) { error("PSLFindClosePartition"); return !list.empty(); } return true; } bool GetStoreInfo(HANDLE hStore, STOREINFO& si) { memset(&si, 0, sizeof(STOREINFO)); si.cbSize= sizeof(STOREINFO); if (!PSLGetStoreInfo(hStore, &si)) { error("PSLGetStoreInfo"); return false; } return true; } bool GetPartitionInfo(HANDLE hPartition, PARTINFO& pi) { memset(&pi, 0, sizeof(PARTINFO)); pi.cbSize= sizeof(PARTINFO); if (!PSLGetPartitionInfo(hPartition, &pi)) { error("PSLGetPartitionInfo"); return false; } return true; }