| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <common.h> |
| 23 |
#include <memory.h> |
| 24 |
#include <types.h> |
| 25 |
#include <wide_string.h> |
| 26 |
|
| 27 |
#include "mount_dokan.h" |
| 28 |
#include "mount_file_entry.h" |
| 29 |
#include "mount_handle.h" |
| 30 |
#include "vhditools_libcerror.h" |
| 31 |
#include "vhditools_libcnotify.h" |
| 32 |
#include "vhditools_libvhdi.h" |
| 33 |
#include "vhditools_unused.h" |
| 34 |
|
| 35 |
extern mount_handle_t *vhdimount_mount_handle; |
| 36 |
|
| 37 |
#if defined( HAVE_LIBDOKAN ) |
| 38 |
|
| 39 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 40 |
#define MOUNT_DOKAN_ERROR_BAD_ARGUMENTS -ERROR_BAD_ARGUMENTS |
| 41 |
#define MOUNT_DOKAN_ERROR_FILE_NOT_FOUND -ERROR_FILE_NOT_FOUND |
| 42 |
#define MOUNT_DOKAN_ERROR_GENERIC_FAILURE -ERROR_GEN_FAILURE |
| 43 |
#define MOUNT_DOKAN_ERROR_READ_FAULT -ERROR_READ_FAULT |
| 44 |
|
| 45 |
#else |
| 46 |
#define MOUNT_DOKAN_ERROR_BAD_ARGUMENTS STATUS_UNSUCCESSFUL |
| 47 |
#define MOUNT_DOKAN_ERROR_FILE_NOT_FOUND STATUS_OBJECT_NAME_NOT_FOUND |
| 48 |
#define MOUNT_DOKAN_ERROR_GENERIC_FAILURE STATUS_UNSUCCESSFUL |
| 49 |
#define MOUNT_DOKAN_ERROR_READ_FAULT STATUS_UNEXPECTED_IO_ERROR |
| 50 |
|
| 51 |
#endif |
| 52 |
|
| 53 |
#if defined( HAVE_DOKAN_LONG_PATHS ) |
| 54 |
#define DOKAN_MAX_PATH 32768 |
| 55 |
#else |
| 56 |
#define DOKAN_MAX_PATH MAX_PATH |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
int mount_dokan_set_file_information( |
| 64 |
BY_HANDLE_FILE_INFORMATION *file_information, |
| 65 |
size64_t size, |
| 66 |
uint16_t file_mode, |
| 67 |
uint64_t creation_time, |
| 68 |
uint64_t access_time, |
| 69 |
uint64_t modification_time, |
| 70 |
libcerror_error_t **error ) |
| 71 |
{ |
| 72 |
static char *function = "mount_dokan_set_file_information"; |
| 73 |
|
| 74 |
if( file_information == NULL ) |
| 75 |
{ |
| 76 |
libcerror_error_set( |
| 77 |
error, |
| 78 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 79 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 80 |
"%s: invalid file information.", |
| 81 |
function ); |
| 82 |
|
| 83 |
return( -1 ); |
| 84 |
} |
| 85 |
if( size > 0 ) |
| 86 |
{ |
| 87 |
file_information->nFileSizeHigh = (DWORD) ( size >> 32 ); |
| 88 |
file_information->nFileSizeLow = (DWORD) ( size & 0xffffffffUL ); |
| 89 |
} |
| 90 |
if( ( file_mode & 0x4000 ) != 0 ) |
| 91 |
{ |
| 92 |
file_information->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; |
| 93 |
} |
| 94 |
else |
| 95 |
{ |
| 96 |
file_information->dwFileAttributes = FILE_ATTRIBUTE_NORMAL; |
| 97 |
} |
| 98 |
file_information->ftCreationTime.dwLowDateTime = (uint32_t) ( creation_time & 0x00000000ffffffffULL ); |
| 99 |
file_information->ftCreationTime.dwHighDateTime = creation_time >> 32; |
| 100 |
|
| 101 |
file_information->ftLastAccessTime.dwLowDateTime = (uint32_t) ( access_time & 0x00000000ffffffffULL ); |
| 102 |
file_information->ftLastAccessTime.dwHighDateTime = access_time >> 32; |
| 103 |
|
| 104 |
file_information->ftLastWriteTime.dwLowDateTime = (uint32_t) ( modification_time & 0x00000000ffffffffULL ); |
| 105 |
file_information->ftLastWriteTime.dwHighDateTime = modification_time >> 32; |
| 106 |
|
| 107 |
return( 1 ); |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
int mount_dokan_set_find_data( |
| 115 |
WIN32_FIND_DATAW *find_data, |
| 116 |
size64_t size, |
| 117 |
uint16_t file_mode, |
| 118 |
uint64_t creation_time, |
| 119 |
uint64_t access_time, |
| 120 |
uint64_t modification_time, |
| 121 |
libcerror_error_t **error ) |
| 122 |
{ |
| 123 |
static char *function = "mount_dokan_set_find_data"; |
| 124 |
|
| 125 |
if( find_data == NULL ) |
| 126 |
{ |
| 127 |
libcerror_error_set( |
| 128 |
error, |
| 129 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 130 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 131 |
"%s: invalid find data.", |
| 132 |
function ); |
| 133 |
|
| 134 |
return( -1 ); |
| 135 |
} |
| 136 |
if( size > 0 ) |
| 137 |
{ |
| 138 |
find_data->nFileSizeHigh = (DWORD) ( size >> 32 ); |
| 139 |
find_data->nFileSizeLow = (DWORD) ( size & 0xffffffffUL ); |
| 140 |
} |
| 141 |
if( ( file_mode & 0x4000 ) != 0 ) |
| 142 |
{ |
| 143 |
find_data->dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; |
| 144 |
} |
| 145 |
else |
| 146 |
{ |
| 147 |
find_data->dwFileAttributes = FILE_ATTRIBUTE_NORMAL; |
| 148 |
} |
| 149 |
find_data->ftCreationTime.dwLowDateTime = (uint32_t) ( creation_time & 0x00000000ffffffffULL ); |
| 150 |
find_data->ftCreationTime.dwHighDateTime = creation_time >> 32; |
| 151 |
|
| 152 |
find_data->ftLastAccessTime.dwLowDateTime = (uint32_t) ( access_time & 0x00000000ffffffffULL ); |
| 153 |
find_data->ftLastAccessTime.dwHighDateTime = access_time >> 32; |
| 154 |
|
| 155 |
find_data->ftLastWriteTime.dwLowDateTime = (uint32_t) ( modification_time & 0x00000000ffffffffULL ); |
| 156 |
find_data->ftLastWriteTime.dwHighDateTime = modification_time >> 32; |
| 157 |
|
| 158 |
return( 1 ); |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
int mount_dokan_filldir( |
| 165 |
PFillFindData fill_find_data, |
| 166 |
DOKAN_FILE_INFO *file_info, |
| 167 |
wchar_t *name, |
| 168 |
size_t name_size, |
| 169 |
WIN32_FIND_DATAW *find_data, |
| 170 |
mount_file_entry_t *file_entry, |
| 171 |
libcerror_error_t **error ) |
| 172 |
{ |
| 173 |
static char *function = "mount_dokan_filldir"; |
| 174 |
size64_t file_size = 0; |
| 175 |
uint64_t access_time = 0; |
| 176 |
uint64_t creation_time = 0; |
| 177 |
uint64_t modification_time = 0; |
| 178 |
uint16_t file_mode = 0; |
| 179 |
|
| 180 |
if( fill_find_data == NULL ) |
| 181 |
{ |
| 182 |
libcerror_error_set( |
| 183 |
error, |
| 184 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 185 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 186 |
"%s: invalid fill find data.", |
| 187 |
function ); |
| 188 |
|
| 189 |
return( -1 ); |
| 190 |
} |
| 191 |
if( name == NULL ) |
| 192 |
{ |
| 193 |
libcerror_error_set( |
| 194 |
error, |
| 195 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 196 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 197 |
"%s: invalid name.", |
| 198 |
function ); |
| 199 |
|
| 200 |
return( -1 ); |
| 201 |
} |
| 202 |
if( name_size > (size_t) DOKAN_MAX_PATH ) |
| 203 |
{ |
| 204 |
libcerror_error_set( |
| 205 |
error, |
| 206 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 207 |
LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, |
| 208 |
"%s: invalid name size value out of bounds.", |
| 209 |
function ); |
| 210 |
|
| 211 |
return( -1 ); |
| 212 |
} |
| 213 |
if( file_entry != NULL ) |
| 214 |
{ |
| 215 |
if( mount_file_entry_get_size( |
| 216 |
file_entry, |
| 217 |
&file_size, |
| 218 |
error ) != 1 ) |
| 219 |
{ |
| 220 |
libcerror_error_set( |
| 221 |
error, |
| 222 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 223 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 224 |
"%s: unable to retrieve file entry size.", |
| 225 |
function ); |
| 226 |
|
| 227 |
return( -1 ); |
| 228 |
} |
| 229 |
if( mount_file_entry_get_file_mode( |
| 230 |
file_entry, |
| 231 |
&file_mode, |
| 232 |
error ) != 1 ) |
| 233 |
{ |
| 234 |
libcerror_error_set( |
| 235 |
error, |
| 236 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 237 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 238 |
"%s: unable to retrieve file mode.", |
| 239 |
function ); |
| 240 |
|
| 241 |
return( -1 ); |
| 242 |
} |
| 243 |
if( mount_file_entry_get_creation_time( |
| 244 |
file_entry, |
| 245 |
&creation_time, |
| 246 |
error ) != 1 ) |
| 247 |
{ |
| 248 |
libcerror_error_set( |
| 249 |
error, |
| 250 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 251 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 252 |
"%s: unable to retrieve creation time.", |
| 253 |
function ); |
| 254 |
|
| 255 |
return( -1 ); |
| 256 |
} |
| 257 |
if( mount_file_entry_get_access_time( |
| 258 |
file_entry, |
| 259 |
&access_time, |
| 260 |
error ) != 1 ) |
| 261 |
{ |
| 262 |
libcerror_error_set( |
| 263 |
error, |
| 264 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 265 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 266 |
"%s: unable to retrieve access time.", |
| 267 |
function ); |
| 268 |
|
| 269 |
return( -1 ); |
| 270 |
} |
| 271 |
if( mount_file_entry_get_modification_time( |
| 272 |
file_entry, |
| 273 |
&modification_time, |
| 274 |
error ) != 1 ) |
| 275 |
{ |
| 276 |
libcerror_error_set( |
| 277 |
error, |
| 278 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 279 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 280 |
"%s: unable to retrieve modification time.", |
| 281 |
function ); |
| 282 |
|
| 283 |
return( -1 ); |
| 284 |
} |
| 285 |
} |
| 286 |
if( memory_set( |
| 287 |
find_data, |
| 288 |
0, |
| 289 |
sizeof( WIN32_FIND_DATAW ) ) == NULL ) |
| 290 |
{ |
| 291 |
libcerror_error_set( |
| 292 |
error, |
| 293 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 294 |
LIBCERROR_MEMORY_ERROR_SET_FAILED, |
| 295 |
"%s: unable to clear find data.", |
| 296 |
function ); |
| 297 |
|
| 298 |
return( -1 ); |
| 299 |
} |
| 300 |
if( wide_string_copy( |
| 301 |
find_data->cFileName, |
| 302 |
name, |
| 303 |
name_size ) == NULL ) |
| 304 |
{ |
| 305 |
libcerror_error_set( |
| 306 |
error, |
| 307 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 308 |
LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
| 309 |
"%s: unable to copy filename.", |
| 310 |
function ); |
| 311 |
|
| 312 |
return( -1 ); |
| 313 |
} |
| 314 |
if( name_size <= (size_t) 14 ) |
| 315 |
{ |
| 316 |
if( wide_string_copy( |
| 317 |
find_data->cAlternateFileName, |
| 318 |
name, |
| 319 |
name_size ) == NULL ) |
| 320 |
{ |
| 321 |
libcerror_error_set( |
| 322 |
error, |
| 323 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 324 |
LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
| 325 |
"%s: unable to copy alternate filename.", |
| 326 |
function ); |
| 327 |
|
| 328 |
return( -1 ); |
| 329 |
} |
| 330 |
} |
| 331 |
if( mount_dokan_set_find_data( |
| 332 |
find_data, |
| 333 |
file_size, |
| 334 |
file_mode, |
| 335 |
creation_time, |
| 336 |
access_time, |
| 337 |
modification_time, |
| 338 |
error ) != 1 ) |
| 339 |
{ |
| 340 |
libcerror_error_set( |
| 341 |
error, |
| 342 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 343 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 344 |
"%s: unable to set find data.", |
| 345 |
function ); |
| 346 |
|
| 347 |
return( -1 ); |
| 348 |
} |
| 349 |
if( fill_find_data( |
| 350 |
find_data, |
| 351 |
file_info ) != 0 ) |
| 352 |
{ |
| 353 |
libcerror_error_set( |
| 354 |
error, |
| 355 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 356 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 357 |
"%s: unable to set directory entry.", |
| 358 |
function ); |
| 359 |
|
| 360 |
return( -1 ); |
| 361 |
} |
| 362 |
return( 1 ); |
| 363 |
} |
| 364 |
|
| 365 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
int __stdcall mount_dokan_CreateFile( |
| 371 |
const wchar_t *path, |
| 372 |
DWORD desired_access, |
| 373 |
DWORD share_mode VHDITOOLS_ATTRIBUTE_UNUSED, |
| 374 |
DWORD creation_disposition, |
| 375 |
DWORD attribute_flags VHDITOOLS_ATTRIBUTE_UNUSED, |
| 376 |
DOKAN_FILE_INFO *file_info ) |
| 377 |
{ |
| 378 |
libcerror_error_t *error = NULL; |
| 379 |
static char *function = "mount_dokan_CreateFile"; |
| 380 |
int result = 0; |
| 381 |
|
| 382 |
VHDITOOLS_UNREFERENCED_PARAMETER( share_mode ) |
| 383 |
VHDITOOLS_UNREFERENCED_PARAMETER( attribute_flags ) |
| 384 |
|
| 385 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 386 |
if( libcnotify_verbose != 0 ) |
| 387 |
{ |
| 388 |
libcnotify_printf( |
| 389 |
"%s: %ls\n", |
| 390 |
function, |
| 391 |
path ); |
| 392 |
} |
| 393 |
#endif |
| 394 |
if( path == NULL ) |
| 395 |
{ |
| 396 |
libcerror_error_set( |
| 397 |
&error, |
| 398 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 399 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 400 |
"%s: invalid path.", |
| 401 |
function ); |
| 402 |
|
| 403 |
result = -ERROR_BAD_ARGUMENTS; |
| 404 |
|
| 405 |
goto on_error; |
| 406 |
} |
| 407 |
if( ( desired_access & GENERIC_WRITE ) != 0 ) |
| 408 |
{ |
| 409 |
return( -ERROR_WRITE_PROTECT ); |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
if( creation_disposition == CREATE_NEW ) |
| 414 |
{ |
| 415 |
return( -ERROR_FILE_EXISTS ); |
| 416 |
} |
| 417 |
else if( creation_disposition == CREATE_ALWAYS ) |
| 418 |
{ |
| 419 |
return( -ERROR_ALREADY_EXISTS ); |
| 420 |
} |
| 421 |
else if( creation_disposition == OPEN_ALWAYS ) |
| 422 |
{ |
| 423 |
return( -ERROR_FILE_NOT_FOUND ); |
| 424 |
} |
| 425 |
else if( creation_disposition == TRUNCATE_EXISTING ) |
| 426 |
{ |
| 427 |
return( -ERROR_FILE_NOT_FOUND ); |
| 428 |
} |
| 429 |
else if( creation_disposition != OPEN_EXISTING ) |
| 430 |
{ |
| 431 |
libcerror_error_set( |
| 432 |
&error, |
| 433 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 434 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 435 |
"%s: invalid creation disposition.", |
| 436 |
function ); |
| 437 |
|
| 438 |
result = -ERROR_BAD_ARGUMENTS; |
| 439 |
|
| 440 |
goto on_error; |
| 441 |
} |
| 442 |
if( file_info == NULL ) |
| 443 |
{ |
| 444 |
libcerror_error_set( |
| 445 |
&error, |
| 446 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 447 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 448 |
"%s: invalid file information.", |
| 449 |
function ); |
| 450 |
|
| 451 |
result = -ERROR_BAD_ARGUMENTS; |
| 452 |
|
| 453 |
goto on_error; |
| 454 |
} |
| 455 |
if( file_info->Context != (ULONG64) NULL ) |
| 456 |
{ |
| 457 |
libcerror_error_set( |
| 458 |
&error, |
| 459 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 460 |
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
| 461 |
"%s: invalid file information - context already set.", |
| 462 |
function ); |
| 463 |
|
| 464 |
result = -ERROR_BAD_ARGUMENTS; |
| 465 |
|
| 466 |
goto on_error; |
| 467 |
} |
| 468 |
if( mount_handle_get_file_entry_by_path( |
| 469 |
vhdimount_mount_handle, |
| 470 |
path, |
| 471 |
(mount_file_entry_t **) &( file_info->Context ), |
| 472 |
&error ) != 1 ) |
| 473 |
{ |
| 474 |
libcerror_error_set( |
| 475 |
&error, |
| 476 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 477 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 478 |
"%s: unable to retrieve file entry for path: %ls.", |
| 479 |
function, |
| 480 |
path ); |
| 481 |
|
| 482 |
result = -ERROR_FILE_NOT_FOUND; |
| 483 |
|
| 484 |
goto on_error; |
| 485 |
} |
| 486 |
return( 0 ); |
| 487 |
|
| 488 |
on_error: |
| 489 |
if( error != NULL ) |
| 490 |
{ |
| 491 |
libcnotify_print_error_backtrace( |
| 492 |
error ); |
| 493 |
libcerror_error_free( |
| 494 |
&error ); |
| 495 |
} |
| 496 |
return( result ); |
| 497 |
} |
| 498 |
|
| 499 |
#else |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
NTSTATUS __stdcall mount_dokan_ZwCreateFile( |
| 505 |
const wchar_t *path, |
| 506 |
DOKAN_IO_SECURITY_CONTEXT *security_context VHDITOOLS_ATTRIBUTE_UNUSED, |
| 507 |
ACCESS_MASK desired_access, |
| 508 |
ULONG file_attributes VHDITOOLS_ATTRIBUTE_UNUSED, |
| 509 |
ULONG share_access VHDITOOLS_ATTRIBUTE_UNUSED, |
| 510 |
ULONG creation_disposition, |
| 511 |
ULONG creation_options VHDITOOLS_ATTRIBUTE_UNUSED, |
| 512 |
DOKAN_FILE_INFO *file_info ) |
| 513 |
{ |
| 514 |
libcerror_error_t *error = NULL; |
| 515 |
static char *function = "mount_dokan_ZwCreateFile"; |
| 516 |
int result = 0; |
| 517 |
|
| 518 |
VHDITOOLS_UNREFERENCED_PARAMETER( security_context ) |
| 519 |
VHDITOOLS_UNREFERENCED_PARAMETER( file_attributes ) |
| 520 |
VHDITOOLS_UNREFERENCED_PARAMETER( share_access ) |
| 521 |
VHDITOOLS_UNREFERENCED_PARAMETER( creation_options ) |
| 522 |
|
| 523 |
if( path == NULL ) |
| 524 |
{ |
| 525 |
libcerror_error_set( |
| 526 |
&error, |
| 527 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 528 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 529 |
"%s: invalid path.", |
| 530 |
function ); |
| 531 |
|
| 532 |
result = STATUS_UNSUCCESSFUL; |
| 533 |
|
| 534 |
goto on_error; |
| 535 |
} |
| 536 |
if( ( desired_access & GENERIC_WRITE ) != 0 ) |
| 537 |
{ |
| 538 |
return( STATUS_MEDIA_WRITE_PROTECTED ); |
| 539 |
} |
| 540 |
|
| 541 |
|
| 542 |
if( creation_disposition == FILE_CREATE ) |
| 543 |
{ |
| 544 |
return( STATUS_OBJECT_NAME_COLLISION ); |
| 545 |
} |
| 546 |
else if( ( creation_disposition != FILE_OPEN ) |
| 547 |
&& ( creation_disposition != FILE_OPEN_IF ) ) |
| 548 |
{ |
| 549 |
return( STATUS_ACCESS_DENIED ); |
| 550 |
} |
| 551 |
if( file_info == NULL ) |
| 552 |
{ |
| 553 |
libcerror_error_set( |
| 554 |
&error, |
| 555 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 556 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 557 |
"%s: invalid file information.", |
| 558 |
function ); |
| 559 |
|
| 560 |
result = STATUS_UNSUCCESSFUL; |
| 561 |
|
| 562 |
goto on_error; |
| 563 |
} |
| 564 |
if( file_info->Context != (ULONG64) NULL ) |
| 565 |
{ |
| 566 |
libcerror_error_set( |
| 567 |
&error, |
| 568 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 569 |
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
| 570 |
"%s: invalid file information - context already set.", |
| 571 |
function ); |
| 572 |
|
| 573 |
result = STATUS_UNSUCCESSFUL; |
| 574 |
|
| 575 |
goto on_error; |
| 576 |
} |
| 577 |
if( mount_handle_get_file_entry_by_path( |
| 578 |
vhdimount_mount_handle, |
| 579 |
path, |
| 580 |
(mount_file_entry_t **) &( file_info->Context ), |
| 581 |
&error ) != 1 ) |
| 582 |
{ |
| 583 |
libcerror_error_set( |
| 584 |
&error, |
| 585 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 586 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 587 |
"%s: unable to retrieve file entry for path: %ls.", |
| 588 |
function, |
| 589 |
path ); |
| 590 |
|
| 591 |
result = STATUS_OBJECT_NAME_NOT_FOUND; |
| 592 |
|
| 593 |
goto on_error; |
| 594 |
} |
| 595 |
return( STATUS_SUCCESS ); |
| 596 |
|
| 597 |
on_error: |
| 598 |
if( error != NULL ) |
| 599 |
{ |
| 600 |
libcnotify_print_error_backtrace( |
| 601 |
error ); |
| 602 |
libcerror_error_free( |
| 603 |
&error ); |
| 604 |
} |
| 605 |
return( result ); |
| 606 |
} |
| 607 |
|
| 608 |
#endif |
| 609 |
|
| 610 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
int __stdcall mount_dokan_OpenDirectory( |
| 616 |
const wchar_t *path, |
| 617 |
DOKAN_FILE_INFO *file_info ) |
| 618 |
{ |
| 619 |
libcerror_error_t *error = NULL; |
| 620 |
static char *function = "mount_dokan_OpenDirectory"; |
| 621 |
int result = 0; |
| 622 |
|
| 623 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 624 |
if( libcnotify_verbose != 0 ) |
| 625 |
{ |
| 626 |
libcnotify_printf( |
| 627 |
"%s: %ls\n", |
| 628 |
function, |
| 629 |
path ); |
| 630 |
} |
| 631 |
#endif |
| 632 |
if( path == NULL ) |
| 633 |
{ |
| 634 |
libcerror_error_set( |
| 635 |
&error, |
| 636 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 637 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 638 |
"%s: invalid path.", |
| 639 |
function ); |
| 640 |
|
| 641 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 642 |
|
| 643 |
goto on_error; |
| 644 |
} |
| 645 |
if( file_info == NULL ) |
| 646 |
{ |
| 647 |
libcerror_error_set( |
| 648 |
&error, |
| 649 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 650 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 651 |
"%s: invalid file information.", |
| 652 |
function ); |
| 653 |
|
| 654 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 655 |
|
| 656 |
goto on_error; |
| 657 |
} |
| 658 |
if( file_info->Context != (ULONG64) NULL ) |
| 659 |
{ |
| 660 |
libcerror_error_set( |
| 661 |
&error, |
| 662 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 663 |
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
| 664 |
"%s: invalid file information - context already set.", |
| 665 |
function ); |
| 666 |
|
| 667 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 668 |
|
| 669 |
goto on_error; |
| 670 |
} |
| 671 |
if( mount_handle_get_file_entry_by_path( |
| 672 |
vhdimount_mount_handle, |
| 673 |
path, |
| 674 |
(mount_file_entry_t **) &( file_info->Context ), |
| 675 |
&error ) != 1 ) |
| 676 |
{ |
| 677 |
libcerror_error_set( |
| 678 |
&error, |
| 679 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 680 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 681 |
"%s: unable to retrieve file entry for path: %ls.", |
| 682 |
function, |
| 683 |
path ); |
| 684 |
|
| 685 |
result = MOUNT_DOKAN_ERROR_FILE_NOT_FOUND; |
| 686 |
|
| 687 |
goto on_error; |
| 688 |
} |
| 689 |
return( 0 ); |
| 690 |
|
| 691 |
on_error: |
| 692 |
if( error != NULL ) |
| 693 |
{ |
| 694 |
libcnotify_print_error_backtrace( |
| 695 |
error ); |
| 696 |
libcerror_error_free( |
| 697 |
&error ); |
| 698 |
} |
| 699 |
return( result ); |
| 700 |
} |
| 701 |
|
| 702 |
#endif |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 708 |
int __stdcall mount_dokan_CloseFile( |
| 709 |
const wchar_t *path, |
| 710 |
DOKAN_FILE_INFO *file_info ) |
| 711 |
#else |
| 712 |
NTSTATUS __stdcall mount_dokan_CloseFile( |
| 713 |
const wchar_t *path, |
| 714 |
DOKAN_FILE_INFO *file_info ) |
| 715 |
#endif |
| 716 |
{ |
| 717 |
libcerror_error_t *error = NULL; |
| 718 |
static char *function = "mount_dokan_CloseFile"; |
| 719 |
int result = 0; |
| 720 |
|
| 721 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 722 |
if( libcnotify_verbose != 0 ) |
| 723 |
{ |
| 724 |
libcnotify_printf( |
| 725 |
"%s: %ls\n", |
| 726 |
function, |
| 727 |
path ); |
| 728 |
} |
| 729 |
#endif |
| 730 |
if( path == NULL ) |
| 731 |
{ |
| 732 |
libcerror_error_set( |
| 733 |
&error, |
| 734 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 735 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 736 |
"%s: invalid path.", |
| 737 |
function ); |
| 738 |
|
| 739 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 740 |
|
| 741 |
goto on_error; |
| 742 |
} |
| 743 |
if( file_info == NULL ) |
| 744 |
{ |
| 745 |
libcerror_error_set( |
| 746 |
&error, |
| 747 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 748 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 749 |
"%s: invalid file information.", |
| 750 |
function ); |
| 751 |
|
| 752 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 753 |
|
| 754 |
goto on_error; |
| 755 |
} |
| 756 |
if( file_info->Context != (ULONG64) NULL ) |
| 757 |
{ |
| 758 |
if( mount_file_entry_free( |
| 759 |
(mount_file_entry_t **) &( file_info->Context ), |
| 760 |
&error ) != 1 ) |
| 761 |
{ |
| 762 |
libcerror_error_set( |
| 763 |
&error, |
| 764 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 765 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 766 |
"%s: unable to free file entry.", |
| 767 |
function ); |
| 768 |
|
| 769 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 770 |
|
| 771 |
goto on_error; |
| 772 |
} |
| 773 |
} |
| 774 |
return( 0 ); |
| 775 |
|
| 776 |
on_error: |
| 777 |
if( error != NULL ) |
| 778 |
{ |
| 779 |
libcnotify_print_error_backtrace( |
| 780 |
error ); |
| 781 |
libcerror_error_free( |
| 782 |
&error ); |
| 783 |
} |
| 784 |
return( result ); |
| 785 |
} |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 791 |
int __stdcall mount_dokan_ReadFile( |
| 792 |
const wchar_t *path, |
| 793 |
void *buffer, |
| 794 |
DWORD number_of_bytes_to_read, |
| 795 |
DWORD *number_of_bytes_read, |
| 796 |
LONGLONG offset, |
| 797 |
DOKAN_FILE_INFO *file_info ) |
| 798 |
#else |
| 799 |
NTSTATUS __stdcall mount_dokan_ReadFile( |
| 800 |
const wchar_t *path, |
| 801 |
void *buffer, |
| 802 |
DWORD number_of_bytes_to_read, |
| 803 |
DWORD *number_of_bytes_read, |
| 804 |
LONGLONG offset, |
| 805 |
DOKAN_FILE_INFO *file_info ) |
| 806 |
#endif |
| 807 |
{ |
| 808 |
libcerror_error_t *error = NULL; |
| 809 |
static char *function = "mount_dokan_ReadFile"; |
| 810 |
ssize_t read_count = 0; |
| 811 |
int result = 0; |
| 812 |
|
| 813 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 814 |
if( libcnotify_verbose != 0 ) |
| 815 |
{ |
| 816 |
libcnotify_printf( |
| 817 |
"%s: %ls\n", |
| 818 |
function, |
| 819 |
path ); |
| 820 |
} |
| 821 |
#endif |
| 822 |
if( path == NULL ) |
| 823 |
{ |
| 824 |
libcerror_error_set( |
| 825 |
&error, |
| 826 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 827 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 828 |
"%s: invalid path.", |
| 829 |
function ); |
| 830 |
|
| 831 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 832 |
|
| 833 |
goto on_error; |
| 834 |
} |
| 835 |
if( number_of_bytes_to_read > (DWORD) INT32_MAX ) |
| 836 |
{ |
| 837 |
libcerror_error_set( |
| 838 |
&error, |
| 839 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 840 |
LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
| 841 |
"%s: invalid number of bytes to read value exceeds maximum.", |
| 842 |
function ); |
| 843 |
|
| 844 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 845 |
|
| 846 |
goto on_error; |
| 847 |
} |
| 848 |
if( number_of_bytes_read == NULL ) |
| 849 |
{ |
| 850 |
libcerror_error_set( |
| 851 |
&error, |
| 852 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 853 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 854 |
"%s: invalid number of bytes read.", |
| 855 |
function ); |
| 856 |
|
| 857 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 858 |
|
| 859 |
goto on_error; |
| 860 |
} |
| 861 |
if( file_info == NULL ) |
| 862 |
{ |
| 863 |
libcerror_error_set( |
| 864 |
&error, |
| 865 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 866 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 867 |
"%s: invalid file information.", |
| 868 |
function ); |
| 869 |
|
| 870 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 871 |
|
| 872 |
goto on_error; |
| 873 |
} |
| 874 |
if( file_info->Context == (ULONG64) NULL ) |
| 875 |
{ |
| 876 |
libcerror_error_set( |
| 877 |
&error, |
| 878 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 879 |
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
| 880 |
"%s: invalid file information - missing context.", |
| 881 |
function ); |
| 882 |
|
| 883 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 884 |
|
| 885 |
goto on_error; |
| 886 |
} |
| 887 |
read_count = mount_file_entry_read_buffer_at_offset( |
| 888 |
(mount_file_entry_t *) file_info->Context, |
| 889 |
buffer, |
| 890 |
(size_t) number_of_bytes_to_read, |
| 891 |
(off64_t) offset, |
| 892 |
&error ); |
| 893 |
|
| 894 |
if( read_count < 0 ) |
| 895 |
{ |
| 896 |
libcerror_error_set( |
| 897 |
&error, |
| 898 |
LIBCERROR_ERROR_DOMAIN_IO, |
| 899 |
LIBCERROR_IO_ERROR_READ_FAILED, |
| 900 |
"%s: unable to read from file entry.", |
| 901 |
function ); |
| 902 |
|
| 903 |
result = MOUNT_DOKAN_ERROR_READ_FAULT; |
| 904 |
|
| 905 |
goto on_error; |
| 906 |
} |
| 907 |
if( read_count > (size_t) INT32_MAX ) |
| 908 |
{ |
| 909 |
libcerror_error_set( |
| 910 |
&error, |
| 911 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 912 |
LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
| 913 |
"%s: invalid read count value exceeds maximum.", |
| 914 |
function ); |
| 915 |
|
| 916 |
result = MOUNT_DOKAN_ERROR_READ_FAULT; |
| 917 |
|
| 918 |
goto on_error; |
| 919 |
} |
| 920 |
|
| 921 |
|
| 922 |
*number_of_bytes_read = (DWORD) read_count; |
| 923 |
|
| 924 |
return( 0 ); |
| 925 |
|
| 926 |
on_error: |
| 927 |
if( error != NULL ) |
| 928 |
{ |
| 929 |
libcnotify_print_error_backtrace( |
| 930 |
error ); |
| 931 |
libcerror_error_free( |
| 932 |
&error ); |
| 933 |
} |
| 934 |
return( result ); |
| 935 |
} |
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 941 |
int __stdcall mount_dokan_FindFiles( |
| 942 |
const wchar_t *path, |
| 943 |
PFillFindData fill_find_data, |
| 944 |
DOKAN_FILE_INFO *file_info ) |
| 945 |
#else |
| 946 |
NTSTATUS __stdcall mount_dokan_FindFiles( |
| 947 |
const wchar_t *path, |
| 948 |
PFillFindData fill_find_data, |
| 949 |
DOKAN_FILE_INFO *file_info ) |
| 950 |
#endif |
| 951 |
{ |
| 952 |
WIN32_FIND_DATAW find_data; |
| 953 |
|
| 954 |
libcerror_error_t *error = NULL; |
| 955 |
mount_file_entry_t *file_entry = NULL; |
| 956 |
mount_file_entry_t *parent_file_entry = NULL; |
| 957 |
mount_file_entry_t *sub_file_entry = NULL; |
| 958 |
wchar_t *name = NULL; |
| 959 |
static char *function = "mount_dokan_FindFiles"; |
| 960 |
size_t name_size = 0; |
| 961 |
int number_of_sub_file_entries = 0; |
| 962 |
int result = 0; |
| 963 |
int sub_file_entry_index = 0; |
| 964 |
|
| 965 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 966 |
if( libcnotify_verbose != 0 ) |
| 967 |
{ |
| 968 |
libcnotify_printf( |
| 969 |
"%s: %ls\n", |
| 970 |
function, |
| 971 |
path ); |
| 972 |
} |
| 973 |
#endif |
| 974 |
if( path == NULL ) |
| 975 |
{ |
| 976 |
libcerror_error_set( |
| 977 |
&error, |
| 978 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 979 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 980 |
"%s: invalid path.", |
| 981 |
function ); |
| 982 |
|
| 983 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 984 |
|
| 985 |
goto on_error; |
| 986 |
} |
| 987 |
if( mount_handle_get_file_entry_by_path( |
| 988 |
vhdimount_mount_handle, |
| 989 |
path, |
| 990 |
&file_entry, |
| 991 |
&error ) != 1 ) |
| 992 |
{ |
| 993 |
libcerror_error_set( |
| 994 |
&error, |
| 995 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 996 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 997 |
"%s: unable to retrieve file entry for path: %ls.", |
| 998 |
function, |
| 999 |
path ); |
| 1000 |
|
| 1001 |
result = MOUNT_DOKAN_ERROR_FILE_NOT_FOUND; |
| 1002 |
|
| 1003 |
goto on_error; |
| 1004 |
} |
| 1005 |
if( mount_dokan_filldir( |
| 1006 |
fill_find_data, |
| 1007 |
file_info, |
| 1008 |
L".", |
| 1009 |
2, |
| 1010 |
&find_data, |
| 1011 |
file_entry, |
| 1012 |
&error ) != 1 ) |
| 1013 |
{ |
| 1014 |
libcerror_error_set( |
| 1015 |
&error, |
| 1016 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1017 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 1018 |
"%s: unable to set self find data.", |
| 1019 |
function ); |
| 1020 |
|
| 1021 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1022 |
|
| 1023 |
goto on_error; |
| 1024 |
} |
| 1025 |
result = mount_file_entry_get_parent_file_entry( |
| 1026 |
file_entry, |
| 1027 |
&parent_file_entry, |
| 1028 |
&error ); |
| 1029 |
|
| 1030 |
if( result == -1 ) |
| 1031 |
{ |
| 1032 |
libcerror_error_set( |
| 1033 |
&error, |
| 1034 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1035 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1036 |
"%s: unable to retrieve parent file entry.", |
| 1037 |
function ); |
| 1038 |
|
| 1039 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1040 |
|
| 1041 |
goto on_error; |
| 1042 |
} |
| 1043 |
if( mount_dokan_filldir( |
| 1044 |
fill_find_data, |
| 1045 |
file_info, |
| 1046 |
L"..", |
| 1047 |
3, |
| 1048 |
&find_data, |
| 1049 |
parent_file_entry, |
| 1050 |
&error ) != 1 ) |
| 1051 |
{ |
| 1052 |
libcerror_error_set( |
| 1053 |
&error, |
| 1054 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1055 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 1056 |
"%s: unable to set parent find data.", |
| 1057 |
function ); |
| 1058 |
|
| 1059 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1060 |
|
| 1061 |
goto on_error; |
| 1062 |
} |
| 1063 |
if( mount_file_entry_free( |
| 1064 |
&parent_file_entry, |
| 1065 |
&error ) != 1 ) |
| 1066 |
{ |
| 1067 |
libcerror_error_set( |
| 1068 |
&error, |
| 1069 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1070 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1071 |
"%s: unable to free parent file entry.", |
| 1072 |
function ); |
| 1073 |
|
| 1074 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1075 |
|
| 1076 |
goto on_error; |
| 1077 |
} |
| 1078 |
if( mount_file_entry_get_number_of_sub_file_entries( |
| 1079 |
file_entry, |
| 1080 |
&number_of_sub_file_entries, |
| 1081 |
&error ) != 1 ) |
| 1082 |
{ |
| 1083 |
libcerror_error_set( |
| 1084 |
&error, |
| 1085 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1086 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1087 |
"%s: unable to retrieve number of sub file entries.", |
| 1088 |
function ); |
| 1089 |
|
| 1090 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1091 |
|
| 1092 |
goto on_error; |
| 1093 |
} |
| 1094 |
for( sub_file_entry_index = 0; |
| 1095 |
sub_file_entry_index < number_of_sub_file_entries; |
| 1096 |
sub_file_entry_index++ ) |
| 1097 |
{ |
| 1098 |
if( mount_file_entry_get_sub_file_entry_by_index( |
| 1099 |
file_entry, |
| 1100 |
sub_file_entry_index, |
| 1101 |
&sub_file_entry, |
| 1102 |
&error ) != 1 ) |
| 1103 |
{ |
| 1104 |
libcerror_error_set( |
| 1105 |
&error, |
| 1106 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1107 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1108 |
"%s: unable to retrieve sub file entry: %d.", |
| 1109 |
function, |
| 1110 |
sub_file_entry_index ); |
| 1111 |
|
| 1112 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1113 |
|
| 1114 |
goto on_error; |
| 1115 |
} |
| 1116 |
if( mount_file_entry_get_name_size( |
| 1117 |
sub_file_entry, |
| 1118 |
&name_size, |
| 1119 |
&error ) != 1 ) |
| 1120 |
{ |
| 1121 |
libcerror_error_set( |
| 1122 |
&error, |
| 1123 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1124 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1125 |
"%s: unable to retrieve sub file entry: %d name size.", |
| 1126 |
function, |
| 1127 |
sub_file_entry_index ); |
| 1128 |
|
| 1129 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1130 |
|
| 1131 |
goto on_error; |
| 1132 |
} |
| 1133 |
name = wide_string_allocate( |
| 1134 |
name_size ); |
| 1135 |
|
| 1136 |
if( name == NULL ) |
| 1137 |
{ |
| 1138 |
libcerror_error_set( |
| 1139 |
&error, |
| 1140 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 1141 |
LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
| 1142 |
"%s: unable to create sub file entry: %d name.", |
| 1143 |
function ); |
| 1144 |
|
| 1145 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1146 |
|
| 1147 |
goto on_error; |
| 1148 |
} |
| 1149 |
if( mount_file_entry_get_name( |
| 1150 |
sub_file_entry, |
| 1151 |
name, |
| 1152 |
name_size, |
| 1153 |
&error ) != 1 ) |
| 1154 |
{ |
| 1155 |
libcerror_error_set( |
| 1156 |
&error, |
| 1157 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1158 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1159 |
"%s: unable to retrieve sub file entry: %d name.", |
| 1160 |
function, |
| 1161 |
sub_file_entry_index ); |
| 1162 |
|
| 1163 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1164 |
|
| 1165 |
goto on_error; |
| 1166 |
} |
| 1167 |
if( mount_dokan_filldir( |
| 1168 |
fill_find_data, |
| 1169 |
file_info, |
| 1170 |
name, |
| 1171 |
name_size, |
| 1172 |
&find_data, |
| 1173 |
sub_file_entry, |
| 1174 |
&error ) != 1 ) |
| 1175 |
{ |
| 1176 |
libcerror_error_set( |
| 1177 |
&error, |
| 1178 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1179 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 1180 |
"%s: unable to set sub file entry: %d find data.", |
| 1181 |
function, |
| 1182 |
sub_file_entry_index ); |
| 1183 |
|
| 1184 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1185 |
|
| 1186 |
goto on_error; |
| 1187 |
} |
| 1188 |
memory_free( |
| 1189 |
name ); |
| 1190 |
|
| 1191 |
name = NULL; |
| 1192 |
|
| 1193 |
if( mount_file_entry_free( |
| 1194 |
&sub_file_entry, |
| 1195 |
&error ) != 1 ) |
| 1196 |
{ |
| 1197 |
libcerror_error_set( |
| 1198 |
&error, |
| 1199 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1200 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1201 |
"%s: unable to free sub file entry: %d.", |
| 1202 |
function, |
| 1203 |
sub_file_entry_index ); |
| 1204 |
|
| 1205 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1206 |
|
| 1207 |
goto on_error; |
| 1208 |
} |
| 1209 |
} |
| 1210 |
if( mount_file_entry_free( |
| 1211 |
&file_entry, |
| 1212 |
&error ) != 1 ) |
| 1213 |
{ |
| 1214 |
libcerror_error_set( |
| 1215 |
&error, |
| 1216 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1217 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1218 |
"%s: unable to free file entry.", |
| 1219 |
function ); |
| 1220 |
|
| 1221 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1222 |
|
| 1223 |
goto on_error; |
| 1224 |
} |
| 1225 |
return( 0 ); |
| 1226 |
|
| 1227 |
on_error: |
| 1228 |
if( error != NULL ) |
| 1229 |
{ |
| 1230 |
libcnotify_print_error_backtrace( |
| 1231 |
error ); |
| 1232 |
libcerror_error_free( |
| 1233 |
&error ); |
| 1234 |
} |
| 1235 |
if( name != NULL ) |
| 1236 |
{ |
| 1237 |
memory_free( |
| 1238 |
name ); |
| 1239 |
} |
| 1240 |
if( sub_file_entry != NULL ) |
| 1241 |
{ |
| 1242 |
mount_file_entry_free( |
| 1243 |
&sub_file_entry, |
| 1244 |
NULL ); |
| 1245 |
} |
| 1246 |
if( parent_file_entry != NULL ) |
| 1247 |
{ |
| 1248 |
mount_file_entry_free( |
| 1249 |
&parent_file_entry, |
| 1250 |
NULL ); |
| 1251 |
} |
| 1252 |
if( file_entry != NULL ) |
| 1253 |
{ |
| 1254 |
mount_file_entry_free( |
| 1255 |
&file_entry, |
| 1256 |
NULL ); |
| 1257 |
} |
| 1258 |
return( result ); |
| 1259 |
} |
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 1265 |
int __stdcall mount_dokan_GetFileInformation( |
| 1266 |
const wchar_t *path, |
| 1267 |
BY_HANDLE_FILE_INFORMATION *file_information, |
| 1268 |
DOKAN_FILE_INFO *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1269 |
#else |
| 1270 |
NTSTATUS __stdcall mount_dokan_GetFileInformation( |
| 1271 |
const wchar_t *path, |
| 1272 |
BY_HANDLE_FILE_INFORMATION *file_information, |
| 1273 |
DOKAN_FILE_INFO *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1274 |
#endif |
| 1275 |
{ |
| 1276 |
libcerror_error_t *error = NULL; |
| 1277 |
mount_file_entry_t *file_entry = NULL; |
| 1278 |
static char *function = "mount_dokan_GetFileInformation"; |
| 1279 |
size64_t file_size = 0; |
| 1280 |
uint64_t access_time = 0; |
| 1281 |
uint64_t creation_time = 0; |
| 1282 |
uint64_t modification_time = 0; |
| 1283 |
uint16_t file_mode = 0; |
| 1284 |
int result = 0; |
| 1285 |
|
| 1286 |
VHDITOOLS_UNREFERENCED_PARAMETER( file_info ) |
| 1287 |
|
| 1288 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1289 |
if( libcnotify_verbose != 0 ) |
| 1290 |
{ |
| 1291 |
libcnotify_printf( |
| 1292 |
"%s: %ls\n", |
| 1293 |
function, |
| 1294 |
path ); |
| 1295 |
} |
| 1296 |
#endif |
| 1297 |
if( path == NULL ) |
| 1298 |
{ |
| 1299 |
libcerror_error_set( |
| 1300 |
&error, |
| 1301 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 1302 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 1303 |
"%s: invalid path.", |
| 1304 |
function ); |
| 1305 |
|
| 1306 |
result = MOUNT_DOKAN_ERROR_BAD_ARGUMENTS; |
| 1307 |
|
| 1308 |
goto on_error; |
| 1309 |
} |
| 1310 |
if( mount_handle_get_file_entry_by_path( |
| 1311 |
vhdimount_mount_handle, |
| 1312 |
path, |
| 1313 |
&file_entry, |
| 1314 |
&error ) != 1 ) |
| 1315 |
{ |
| 1316 |
libcerror_error_set( |
| 1317 |
&error, |
| 1318 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1319 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1320 |
"%s: unable to retrieve file entry for path: %ls.", |
| 1321 |
function, |
| 1322 |
path ); |
| 1323 |
|
| 1324 |
result = MOUNT_DOKAN_ERROR_FILE_NOT_FOUND; |
| 1325 |
|
| 1326 |
goto on_error; |
| 1327 |
} |
| 1328 |
if( file_entry != NULL ) |
| 1329 |
{ |
| 1330 |
if( mount_file_entry_get_size( |
| 1331 |
file_entry, |
| 1332 |
&file_size, |
| 1333 |
&error ) != 1 ) |
| 1334 |
{ |
| 1335 |
libcerror_error_set( |
| 1336 |
&error, |
| 1337 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1338 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1339 |
"%s: unable to retrieve file entry size.", |
| 1340 |
function ); |
| 1341 |
|
| 1342 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1343 |
|
| 1344 |
goto on_error; |
| 1345 |
} |
| 1346 |
if( mount_file_entry_get_file_mode( |
| 1347 |
file_entry, |
| 1348 |
&file_mode, |
| 1349 |
&error ) != 1 ) |
| 1350 |
{ |
| 1351 |
libcerror_error_set( |
| 1352 |
&error, |
| 1353 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1354 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1355 |
"%s: unable to retrieve file mode.", |
| 1356 |
function ); |
| 1357 |
|
| 1358 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1359 |
|
| 1360 |
goto on_error; |
| 1361 |
} |
| 1362 |
if( mount_file_entry_get_creation_time( |
| 1363 |
file_entry, |
| 1364 |
&creation_time, |
| 1365 |
&error ) != 1 ) |
| 1366 |
{ |
| 1367 |
libcerror_error_set( |
| 1368 |
&error, |
| 1369 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1370 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1371 |
"%s: unable to retrieve creation time.", |
| 1372 |
function ); |
| 1373 |
|
| 1374 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1375 |
|
| 1376 |
goto on_error; |
| 1377 |
} |
| 1378 |
if( mount_file_entry_get_access_time( |
| 1379 |
file_entry, |
| 1380 |
&access_time, |
| 1381 |
&error ) != 1 ) |
| 1382 |
{ |
| 1383 |
libcerror_error_set( |
| 1384 |
&error, |
| 1385 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1386 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1387 |
"%s: unable to retrieve access time.", |
| 1388 |
function ); |
| 1389 |
|
| 1390 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1391 |
|
| 1392 |
goto on_error; |
| 1393 |
} |
| 1394 |
if( mount_file_entry_get_modification_time( |
| 1395 |
file_entry, |
| 1396 |
&modification_time, |
| 1397 |
&error ) != 1 ) |
| 1398 |
{ |
| 1399 |
libcerror_error_set( |
| 1400 |
&error, |
| 1401 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1402 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1403 |
"%s: unable to retrieve modification time.", |
| 1404 |
function ); |
| 1405 |
|
| 1406 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1407 |
|
| 1408 |
goto on_error; |
| 1409 |
} |
| 1410 |
} |
| 1411 |
if( mount_dokan_set_file_information( |
| 1412 |
file_information, |
| 1413 |
file_size, |
| 1414 |
file_mode, |
| 1415 |
creation_time, |
| 1416 |
access_time, |
| 1417 |
modification_time, |
| 1418 |
&error ) != 1 ) |
| 1419 |
{ |
| 1420 |
libcerror_error_set( |
| 1421 |
&error, |
| 1422 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1423 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 1424 |
"%s: unable to set file information.", |
| 1425 |
function ); |
| 1426 |
|
| 1427 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1428 |
|
| 1429 |
goto on_error; |
| 1430 |
} |
| 1431 |
if( mount_file_entry_free( |
| 1432 |
&file_entry, |
| 1433 |
&error ) != 1 ) |
| 1434 |
{ |
| 1435 |
libcerror_error_set( |
| 1436 |
&error, |
| 1437 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1438 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1439 |
"%s: unable to free file entry.", |
| 1440 |
function ); |
| 1441 |
|
| 1442 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1443 |
|
| 1444 |
goto on_error; |
| 1445 |
} |
| 1446 |
return( 0 ); |
| 1447 |
|
| 1448 |
on_error: |
| 1449 |
if( error != NULL ) |
| 1450 |
{ |
| 1451 |
libcnotify_print_error_backtrace( |
| 1452 |
error ); |
| 1453 |
libcerror_error_free( |
| 1454 |
&error ); |
| 1455 |
} |
| 1456 |
if( file_entry != NULL ) |
| 1457 |
{ |
| 1458 |
mount_file_entry_free( |
| 1459 |
&file_entry, |
| 1460 |
NULL ); |
| 1461 |
} |
| 1462 |
return( result ); |
| 1463 |
} |
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 1469 |
int __stdcall mount_dokan_GetVolumeInformation( |
| 1470 |
wchar_t *volume_name, |
| 1471 |
DWORD volume_name_size, |
| 1472 |
DWORD *volume_serial_number, |
| 1473 |
DWORD *maximum_filename_length, |
| 1474 |
DWORD *file_system_flags, |
| 1475 |
wchar_t *file_system_name, |
| 1476 |
DWORD file_system_name_size, |
| 1477 |
DOKAN_FILE_INFO *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1478 |
#else |
| 1479 |
NTSTATUS __stdcall mount_dokan_GetVolumeInformation( |
| 1480 |
wchar_t *volume_name, |
| 1481 |
DWORD volume_name_size, |
| 1482 |
DWORD *volume_serial_number, |
| 1483 |
DWORD *maximum_filename_length, |
| 1484 |
DWORD *file_system_flags, |
| 1485 |
wchar_t *file_system_name, |
| 1486 |
DWORD file_system_name_size, |
| 1487 |
DOKAN_FILE_INFO *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1488 |
#endif |
| 1489 |
{ |
| 1490 |
libcerror_error_t *error = NULL; |
| 1491 |
const wchar_t *name = NULL; |
| 1492 |
static char *function = "mount_dokan_GetVolumeInformation"; |
| 1493 |
size_t name_size = 0; |
| 1494 |
int result = 0; |
| 1495 |
|
| 1496 |
VHDITOOLS_UNREFERENCED_PARAMETER( file_info ) |
| 1497 |
|
| 1498 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1499 |
if( libcnotify_verbose != 0 ) |
| 1500 |
{ |
| 1501 |
libcnotify_printf( |
| 1502 |
"%s: %ls\n", |
| 1503 |
function, |
| 1504 |
volume_name ); |
| 1505 |
} |
| 1506 |
#endif |
| 1507 |
name = L"VHDI"; |
| 1508 |
name_size = 1 + wide_string_length( |
| 1509 |
name ); |
| 1510 |
|
| 1511 |
if( ( volume_name != NULL ) |
| 1512 |
&& ( volume_name_size > (DWORD) name_size ) ) |
| 1513 |
{ |
| 1514 |
|
| 1515 |
|
| 1516 |
if( memory_copy( |
| 1517 |
volume_name, |
| 1518 |
name, |
| 1519 |
name_size * sizeof( wchar_t ) ) == NULL ) |
| 1520 |
{ |
| 1521 |
libcerror_error_set( |
| 1522 |
&error, |
| 1523 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 1524 |
LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
| 1525 |
"%s: unable to copy volume name.", |
| 1526 |
function ); |
| 1527 |
|
| 1528 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1529 |
|
| 1530 |
goto on_error; |
| 1531 |
} |
| 1532 |
} |
| 1533 |
if( volume_serial_number != NULL ) |
| 1534 |
{ |
| 1535 |
|
| 1536 |
|
| 1537 |
*volume_serial_number = 0x19831116; |
| 1538 |
} |
| 1539 |
if( maximum_filename_length != NULL ) |
| 1540 |
{ |
| 1541 |
*maximum_filename_length = 256; |
| 1542 |
} |
| 1543 |
if( file_system_flags != NULL ) |
| 1544 |
{ |
| 1545 |
*file_system_flags = FILE_CASE_SENSITIVE_SEARCH |
| 1546 |
| FILE_CASE_PRESERVED_NAMES |
| 1547 |
| FILE_UNICODE_ON_DISK |
| 1548 |
| FILE_READ_ONLY_VOLUME; |
| 1549 |
} |
| 1550 |
name = L"Dokan"; |
| 1551 |
name_size = 1 + wide_string_length( |
| 1552 |
name ); |
| 1553 |
|
| 1554 |
if( ( file_system_name != NULL ) |
| 1555 |
&& ( file_system_name_size > (DWORD) name_size ) ) |
| 1556 |
{ |
| 1557 |
|
| 1558 |
|
| 1559 |
if( memory_copy( |
| 1560 |
file_system_name, |
| 1561 |
name, |
| 1562 |
name_size * sizeof( wchar_t ) ) == NULL ) |
| 1563 |
{ |
| 1564 |
libcerror_error_set( |
| 1565 |
&error, |
| 1566 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 1567 |
LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
| 1568 |
"%s: unable to copy file system name.", |
| 1569 |
function ); |
| 1570 |
|
| 1571 |
result = MOUNT_DOKAN_ERROR_GENERIC_FAILURE; |
| 1572 |
|
| 1573 |
goto on_error; |
| 1574 |
} |
| 1575 |
} |
| 1576 |
return( 0 ); |
| 1577 |
|
| 1578 |
on_error: |
| 1579 |
if( error != NULL ) |
| 1580 |
{ |
| 1581 |
libcnotify_print_error_backtrace( |
| 1582 |
error ); |
| 1583 |
libcerror_error_free( |
| 1584 |
&error ); |
| 1585 |
} |
| 1586 |
return( result ); |
| 1587 |
} |
| 1588 |
|
| 1589 |
#if ( DOKAN_VERSION >= 600 ) && ( DOKAN_VERSION < 800 ) |
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
int __stdcall mount_dokan_Unmount( |
| 1595 |
DOKAN_FILE_INFO *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1596 |
{ |
| 1597 |
static char *function = "mount_dokan_Unmount"; |
| 1598 |
|
| 1599 |
VHDITOOLS_UNREFERENCED_PARAMETER( file_info ) |
| 1600 |
|
| 1601 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1602 |
if( libcnotify_verbose != 0 ) |
| 1603 |
{ |
| 1604 |
libcnotify_printf( |
| 1605 |
"%s\n", |
| 1606 |
function ); |
| 1607 |
} |
| 1608 |
#endif |
| 1609 |
return( 0 ); |
| 1610 |
} |
| 1611 |
|
| 1612 |
#endif |
| 1613 |
|
| 1614 |
#endif |
| 1615 |
|