BOOL WINAPI NdasIdValidateExA( __in LPCSTR NdasId, __in_opt LPCSTR WriteKey, __in_opt const NDASID_EXT_KEY* ExtKey, __in_opt const NDASID_EXT_DATA* ExtData) { VALPARM(IsValidStringPtrA(NdasId, NDAS_DEVICE_STRING_ID_LEN + 1)); VALPARM(NdasId[NDAS_DEVICE_STRING_ID_LEN] == '\0'); VALPARM(IsValidOptionalStringPtrA(WriteKey, NDAS_DEVICE_STRING_KEY_LEN + 1)); VALPARM(0 == WriteKey || WriteKey[NDAS_DEVICE_STRING_KEY_LEN] == '\0'); VALPARM(IsValidOptionalReadPtr(ExtKey, sizeof(NDASID_EXT_KEY))); VALPARM(IsValidOptionalReadPtr(ExtData, sizeof(NDASID_EXT_DATA))); NDASID_EXT_DATA decryptedExtData; BOOL success = pNdasIdStringToDeviceA( NdasId, WriteKey, NULL, ExtKey, &decryptedExtData); if (!success) { return FALSE; } // VID, SEED, RANDOM check (only when ExtData is not null) // // Don't do this. This may affected by the alignment. // (not this case though) // // memcmp(&extData, &NDASID_EXT_KEY_DEFAULT, sizeof(NDASID_EXT_DATA)) // if (NULL != ExtData) { if (decryptedExtData.Seed != ExtData->Seed || decryptedExtData.VID != ExtData->VID || decryptedExtData.Reserved[0] != ExtData->Reserved[0] || decryptedExtData.Reserved[1] != ExtData->Reserved[1]) { return SetLastError(NDAS_ERROR_INVALID_ID_FORMAT), FALSE; } } return TRUE; }
BOOL WINAPI NdasIdStringToDeviceExA( __in LPCSTR NdasId, __out NDAS_DEVICE_ID* DeviceId, __in_opt const NDASID_EXT_KEY* ExtKey, __out_opt NDASID_EXT_DATA* ExtData) { VALPARM(IsValidStringPtrA(NdasId, NDAS_DEVICE_STRING_ID_LEN + 1)); VALPARM(NdasId[NDAS_DEVICE_STRING_ID_LEN] == '\0'); VALPARM(IsValidWritePtr(DeviceId, sizeof(NDAS_DEVICE_ID))); VALPARM(IsValidOptionalReadPtr(ExtKey, sizeof(NDASID_EXT_KEY))); VALPARM(IsValidOptionalWritePtr(ExtData, sizeof(NDASID_EXT_DATA))); if (!pNdasIdStringToDeviceA(NdasId, NULL, DeviceId, ExtKey, ExtData)) { return FALSE; } return TRUE; }
NDASVOL_LINKAGE BOOL NDASVOL_CALL NdasIsNdasPathA( IN LPCSTR FilePath) { CPARAM(IsValidStringPtrA(FilePath, UINT_PTR(-1))); XTLTRACE2(NdasVolTrace, 4, "NdasIsNdasPathA(%hs)\n", FilePath); int nChars = ::MultiByteToWideChar(CP_ACP, 0, FilePath, -1, NULL, 0); ++nChars; // additional terminating NULL char XTL::AutoProcessHeapPtr<WCHAR> wszFilePath = reinterpret_cast<LPWSTR>( ::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, nChars * sizeof(WCHAR))); if (wszFilePath.IsInvalid()) { ::SetLastError(ERROR_OUTOFMEMORY); return FALSE; } nChars = ::MultiByteToWideChar(CP_ACP, 0, FilePath, -1, wszFilePath, nChars); return NdasIsNdasPathW(wszFilePath); }