| 307 | } |
| 308 | |
| 309 | static NTSTATUS DOKAN_CALLBACK |
| 310 | CryptCreateFile(LPCWSTR FileName, PDOKAN_IO_SECURITY_CONTEXT SecurityContext, |
| 311 | ACCESS_MASK DesiredAccess, ULONG FileAttributes, |
| 312 | ULONG ShareAccess, ULONG CreateDisposition, ULONG CreateOptions, |
| 313 | PDOKAN_FILE_INFO DokanFileInfo) { |
| 314 | |
| 315 | string actual_encrypted; |
| 316 | FileNameEnc filePath(DokanFileInfo, FileName, &actual_encrypted); |
| 317 | HANDLE handle = NULL; |
| 318 | DWORD fileAttr; |
| 319 | NTSTATUS status = STATUS_SUCCESS; |
| 320 | DWORD creationDisposition; |
| 321 | DWORD fileAttributesAndFlags; |
| 322 | DWORD error = 0; |
| 323 | SECURITY_ATTRIBUTES securityAttrib; |
| 324 | ACCESS_MASK genericDesiredAccess; |
| 325 | |
| 326 | bool is_virtual = rt_is_virtual_file(GetContext(), FileName); |
| 327 | |
| 328 | bool is_reverse_config = rt_is_reverse_config_file(GetContext(), FileName); |
| 329 | |
| 330 | securityAttrib.nLength = sizeof(securityAttrib); |
| 331 | securityAttrib.lpSecurityDescriptor = |
| 332 | SecurityContext->AccessState.SecurityDescriptor; |
| 333 | securityAttrib.bInheritHandle = FALSE; |
| 334 | |
| 335 | DokanMapKernelToUserCreateFileFlags( |
| 336 | DesiredAccess, FileAttributes, CreateOptions, CreateDisposition, |
| 337 | &genericDesiredAccess, &fileAttributesAndFlags, &creationDisposition); |
| 338 | |
| 339 | DbgPrint(L"CreateFile : %s\n", FileName); |
| 340 | |
| 341 | PrintUserName(DokanFileInfo); |
| 342 | |
| 343 | if (DenyOtherSession(GetContext(), DokanFileInfo)) { |
| 344 | DbgPrint(L"Denied other session or a service\n"); |
| 345 | return STATUS_ACCESS_DENIED; |
| 346 | } |
| 347 | |
| 348 | // the block of code below was also commented out in the mirror.c sample |
| 349 | // cppcryptfs modifies the flags after all the CheckFlag() stuff |
| 350 | |
| 351 | /* |
| 352 | if (ShareMode == 0 && AccessMode & FILE_WRITE_DATA) |
| 353 | ShareMode = FILE_SHARE_WRITE; |
| 354 | else if (ShareMode == 0) |
| 355 | ShareMode = FILE_SHARE_READ; |
| 356 | */ |
| 357 | |
| 358 | DbgPrint(L"\tShareMode = 0x%x\n", ShareAccess); |
| 359 | |
| 360 | CryptCheckFlag(ShareAccess, FILE_SHARE_READ); |
| 361 | CryptCheckFlag(ShareAccess, FILE_SHARE_WRITE); |
| 362 | CryptCheckFlag(ShareAccess, FILE_SHARE_DELETE); |
| 363 | |
| 364 | DbgPrint(L"DesiredAccess = 0x%x\n", DesiredAccess); |
| 365 | |
| 366 | CryptCheckFlag(DesiredAccess, GENERIC_READ); |
nothing calls this directly
no test coverage detected