none
MSFT API QueryChangesVirtualDisk retruns ACCESS_DENIED error 0x5 RRS feed

  • Question

  • After converting a production check point to a reference point I am attempting to query changes to a virtual disk using API

    QueryChangesVirtualDisk. The handle to the disk is opened with access mask VIRTUAL_DISK_ACCESS_READ. But the API is continuously faling with same error.

    ret = ::OpenVirtualDisk(&storageType, diskFileNameW.c_str(), VIRTUAL_DISK_ACCESS_READ, OPEN_VIRTUAL_DISK_FLAG_NONE, NULL, &diskHandle);
    if (ret != ERROR_SUCCESS)
    {
    m_evEvent.Error(__FUNCTION__, "OpenVirtualDisk failed for %s. Err %lu", diskPath.c_str(), ret);
    return false;
    }

    // Load the VirtDisk.dll and call QueryChangeVirtualDisk
    LPFN_QUERY_CHANGES_VIRTUALDISK_API pQueryChangesVirtualDisk = NULL;
    HMODULE hVirtDiskDll = ::LoadLibrary("VirtDisk.dll");
    if (NULL == hVirtDiskDll)
    {
    m_evEvent.Error(__FUNCTION__, "Failed to load library VirtDisk.dll");
    CloseHandle(diskHandle);
    return false;
    }

    pQueryChangesVirtualDisk = (LPFN_QUERY_CHANGES_VIRTUALDISK_API)GetProcAddress(hVirtDiskDll, QUERY_CHANGES_VIRTUALDISK_API);
    if (NULL == pQueryChangesVirtualDisk)
    {
    m_evEvent.Error(__FUNCTION__, "Failed to get load proc address for [%s]", QUERY_CHANGES_VIRTUALDISK_API);
    FreeLibrary(hVirtDiskDll);
    CloseHandle(diskHandle);
    return false;
    }

    processedLength = 0;

                ::SecureZeroMemory(&queryChangeRange, sizeof(queryChangeRange));
    ret = pQueryChangesVirtualDisk( diskHandle, // A handle to the open VHD
    wchangeID.c_str(), // A pointer to a string that specifies the change tracking identifier
    startOffset, // specifies the distance from the start of the VHD to the beginning of the area of the VHD
    diskSize, // specifies the length of the area of the VHD that you want to check for changes
    QUERY_CHANGES_VIRTUAL_DISK_FLAG_NONE, // Reserved
    (PQUERY_CHANGES_VIRTUAL_DISK_RANGE)&queryChangeRange, // indicates the areas of the virtual disk that have changed
    &rangeCount, // number of QUERY_CHANGES_VIRTUAL_DISK_RANGE that the Ranges parameter can hold
    &processedLength); // Total number of bytes that the method processed,
    if (ret != ERROR_SUCCESS)
    {
    m_evEvent.Error(__FUNCTION__, "Failed to query changes to virtual disk [%s] StartOff [%I64u] EndOffset [%I64u] Err [%lu]", diskPath.c_str(), startOffset + processedLength, diskSize, ret);
    FreeLibrary(hVirtDiskDll);
    CloseHandle(diskHandle);
    return false;
    }

    Friday, November 4, 2016 10:12 PM

All replies