我正在使用Windows Cloud Filter API创建虚拟驱动器。在Windows Home 21H1 19043.1165(cldflt.sys 10.0.19041.1110)上,删除回调不像预期的那样工作。如果我从CF_CALLBACK_TYPE_NOTIFY_DELETE返回错误代码,则脱水占位符将被删除,而不管我返回的错误代码是什么:
void CALLBACK FakeCloudProvider::OnNotifyDelete(
_In_ CONST CF_CALLBACK_INFO* callbackInfo,
_In_ CONST CF_CALLBACK_PARAMETERS* callbackParameters)
{
CF_OPERATION_INFO opInfo = { 0 };
opInfo.StructSize = sizeof(CF_OPERATION_INFO);
opInfo.Type = CF_OPERATION_TYPE_ACK_DELETE;
opInfo.ConnectionKey = callbackInfo->ConnectionKey;
opInfo.TransferKey = callbackInfo->TransferKey;
opInfo.CorrelationVector = callbackInfo->CorrelationVector;
opInfo.RequestKey = callbackInfo->RequestKey;
CF_SYNC_STATUS_MSG* syncStatus = new CF_SYNC_STATUS_MSG;
syncStatus->Code = STATUS_FILE_LOCKED_WITH_WRITERS;
syncStatus->SetMsg(L"MY TEST");
opInfo.SyncStatus = syncStatus;
CF_OPERATION_PARAMETERS params = {0};
params.ParamSize = sizeof(CF_OPERATION_PARAMETERS);
params.AckDelete.Flags = CF_OPERATION_ACK_DELETE_FLAG_NONE;
// I have also tested many other error codes.
params.AckDelete.CompletionStatus = STATUS_FILE_LOCKED_WITH_WRITERS;
HRESULT res = CfExecute(&opInfo, ¶ms);
}
我已经在Windows 21H1上通过Windows资源管理器和命令提示符进行了删除测试,结果是一样的-占位符被删除了。
我还在旧版本Windows 10 Pro 1909(18363.1556)(cldflt.sys 10.0.18362.1533)上重新进行了删除测试,一切按预期工作-如果我从删除回调中返回错误,则文件不会被删除。
我猜这是最新的Windows更新中的一个错误。有人能找到这种行为的解决方案吗?