/* Retrieves a specific segment * Returns 1 if successful or -1 on error */ int libvslvm_logical_volume_values_get_segment( libvslvm_logical_volume_values_t *logical_volume_values, int segment_index, libvslvm_segment_t **segment, libcerror_error_t **error ) { static char *function = "libvslvm_logical_volume_values_get_segment"; if( logical_volume_values == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid logical volume values.", function ); return( -1 ); } if( segment == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid segment.", function ); return( -1 ); } if( *segment != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid segment value already set.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( logical_volume_values->segments_array, segment_index, (intptr_t **) segment, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve segment: %d.", function, segment_index ); return( -1 ); } return( 1 ); }
/* Read a buffer from a specific input file * Returns the number of bytes read if successful or -1 on error */ ssize_t mount_handle_read_buffer( mount_handle_t *mount_handle, int input_file_index, uint8_t *buffer, size_t size, libcerror_error_t **error ) { libvhdi_file_t *input_file = NULL; static char *function = "mount_handle_read_buffer"; ssize_t read_count = 0; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( mount_handle->input_files_array, input_file_index, (intptr_t **) &input_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve input file: %d.", function, input_file_index ); return( -1 ); } read_count = libvhdi_file_read_buffer( input_file, buffer, size, error ); if( read_count == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read buffer from input file: %d.", function, input_file_index ); return( -1 ); } return( read_count ); }
/* Seeks a specific offset in a specific input file * Returns the offset if successful or -1 on error */ off64_t mount_handle_seek_offset( mount_handle_t *mount_handle, int input_file_index, off64_t offset, int whence, libcerror_error_t **error ) { libvhdi_file_t *input_file = NULL; static char *function = "mount_handle_seek_offset"; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( mount_handle->input_files_array, input_file_index, (intptr_t **) &input_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve input file: %d.", function, input_file_index ); return( -1 ); } offset = libvhdi_file_seek_offset( input_file, offset, whence, error ); if( offset == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_SEEK_FAILED, "%s: unable to seek offset in input file: %d.", function, input_file_index ); return( -1 ); } return( offset ); }
/* Retrieves the volume size of the input handle * Returns 1 if successful or -1 on error */ int mount_handle_get_volume_size( mount_handle_t *mount_handle, int logical_volume_index, size64_t *volume_size, libcerror_error_t **error ) { libvslvm_logical_volume_t *logical_volume = NULL; static char *function = "mount_handle_get_volume_size"; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( mount_handle->logical_volumes_array, logical_volume_index, (intptr_t **) &logical_volume, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve logical volume: %d.", function, logical_volume_index ); return( -1 ); } if( libvslvm_logical_volume_get_size( logical_volume, volume_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve size from logical volume: %d.", function, logical_volume_index ); return( -1 ); } return( 1 ); }
/* Retrieves the media size of a specific input file * Returns 1 if successful or -1 on error */ int mount_handle_get_media_size( mount_handle_t *mount_handle, int input_file_index, size64_t *size, libcerror_error_t **error ) { libvhdi_file_t *input_file = NULL; static char *function = "mount_handle_get_media_size"; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( mount_handle->input_files_array, input_file_index, (intptr_t **) &input_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve input file: %d.", function, input_file_index ); return( -1 ); } if( libvhdi_file_get_media_size( input_file, size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve media size from input file: %d.", function, input_file_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific segment * Returns 1 if successful or -1 on error */ int libfdata_segments_array_get_segment_by_index( libcdata_array_t *segments_array, int segment_index, int *segment_file_index, off64_t *segment_offset, size64_t *segment_size, uint32_t *segment_flags, libcerror_error_t **error ) { libfdata_range_t *segment_data_range = NULL; static char *function = "libfdata_segments_array_get_segment_by_index"; if( libcdata_array_get_entry_by_index( segments_array, segment_index, (intptr_t **) &segment_data_range, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d from segments array.", function, segment_index ); return( -1 ); } if( libfdata_range_get( segment_data_range, segment_file_index, segment_offset, segment_size, segment_flags, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve segment: %d data range values.", function, segment_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific provider * Returns 1 if successful or -1 on error */ int libfwevt_manifest_get_provider( libfwevt_manifest_t *manifest, int provider_index, libfwevt_provider_t **provider, libcerror_error_t **error ) { libfwevt_internal_manifest_t *internal_manifest = NULL; static char *function = "libfwevt_manifest_get_provider"; if( manifest == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid manifest.", function ); return( -1 ); } internal_manifest = (libfwevt_internal_manifest_t *) manifest; if( libcdata_array_get_entry_by_index( internal_manifest->providers_array, provider_index, (intptr_t **) provider, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d.", function, provider_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific metadata area descriptor * Returns 1 if successful or -1 on error */ int libvslvm_physical_volume_get_metadata_area_descriptor( libvslvm_physical_volume_t *physical_volume, int data_area_descriptor_index, libvslvm_data_area_descriptor_t **data_area_descriptor, libcerror_error_t **error ) { libvslvm_internal_physical_volume_t *internal_physical_volume = NULL; static char *function = "libvslvm_physical_volume_get_metadata_area_descriptor"; if( physical_volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid physical volume.", function ); return( -1 ); } internal_physical_volume = (libvslvm_internal_physical_volume_t *) physical_volume; if( libcdata_array_get_entry_by_index( internal_physical_volume->metadata_area_descriptors_array, data_area_descriptor_index, (intptr_t **) data_area_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve metadata area descriptor: %d.", function, data_area_descriptor_index ); return( -1 ); } return( 1 ); }
/* Retrieves the cache value for the specific index * Returns 1 if successful or -1 on error */ int libfcache_cache_get_value_by_index( libfcache_cache_t *cache, int cache_entry_index, libfcache_cache_value_t **cache_value, libcerror_error_t **error ) { libfcache_internal_cache_t *internal_cache = NULL; static char *function = "libfcache_cache_get_value_by_index"; if( cache == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid cache.", function ); return( -1 ); } internal_cache = (libfcache_internal_cache_t *) cache; if( libcdata_array_get_entry_by_index( internal_cache->entries, cache_entry_index, (intptr_t **) cache_value, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve cache value: %d from entries array.", function, cache_entry_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific level 2 metadata block descriptor * Returns 1 if successful or -1 on error */ int libfsrefs_level1_metadata_get_level2_metadata_block_descriptor_by_index( libfsrefs_level1_metadata_t *level1_metadata, int block_descriptor_index, libfsrefs_block_descriptor_t **block_descriptor, libcerror_error_t **error ) { static char *function = "libfsrefs_level1_metadata_get_level2_metadata_block_descriptor_by_index"; if( level1_metadata == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid level 1 metadata.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( level1_metadata->level2_metadata_block_descriptors_array, block_descriptor_index, (intptr_t **) block_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d from array.", function, block_descriptor_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific handle * Returns 1 if successful or -1 on error */ int mount_file_system_get_handle_by_index( mount_file_system_t *file_system, int handle_index, libvmdk_handle_t **vmdk_handle, libcerror_error_t **error ) { static char *function = "mount_file_system_get_handle_by_index"; if( file_system == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file system.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( file_system->handles_array, handle_index, (intptr_t **) vmdk_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve handle: %d.", function, handle_index ); return( -1 ); } return( 1 ); }
/* Retrieves the hive bin cell at the index * Returns 1 if successful or -1 on error */ int libregf_hive_bin_get_cell( libregf_hive_bin_t *hive_bin, uint16_t cell_index, libregf_hive_bin_cell_t **hive_bin_cell, libcerror_error_t **error ) { static char *function = "libregf_hive_bin_get_cell"; if( hive_bin == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid hive bin.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( hive_bin->cells_array, (int) cell_index, (intptr_t **) hive_bin_cell, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve hive bin cell: %" PRIu16 ".", function, cell_index ); return( -1 ); } return( 1 ); }
/* Retrieves a specific value entry * Returns if successful or -1 on error */ int libfvalue_data_handle_get_value_entry( libfvalue_data_handle_t *data_handle, int value_entry_index, uint8_t **value_entry_data, size_t *value_entry_data_size, int *encoding, libcerror_error_t **error ) { libfvalue_internal_data_handle_t *internal_data_handle = NULL; libfvalue_value_entry_t *value_entry = NULL; static char *function = "libfvalue_data_handle_get_value_entry"; if( data_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid data handle.", function ); return( -1 ); } internal_data_handle = (libfvalue_internal_data_handle_t *) data_handle; if( internal_data_handle->data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid data handle - missing data.", function ); return( -1 ); } if( value_entry_data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid value entry data.", function ); return( -1 ); } if( value_entry_data_size == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid value entry data size.", function ); return( -1 ); } if( encoding == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid encoding.", function ); return( -1 ); } if( internal_data_handle->value_entries == NULL ) { if( value_entry_index != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid value index value out of bounds.", function ); return( -1 ); } *value_entry_data = internal_data_handle->data; *value_entry_data_size = internal_data_handle->data_size; } else { if( libcdata_array_get_entry_by_index( internal_data_handle->value_entries, value_entry_index, (intptr_t **) &value_entry, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d from values entries array.", function, value_entry_index ); return( -1 ); } if( value_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing value entry.", function ); return( -1 ); } if( value_entry->offset > internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: value entry offset: %d out of bounds.", function, value_entry_index ); return( -1 ); } if( ( value_entry->offset + value_entry->size ) > internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: value entry size: %d out of bounds.", function, value_entry_index ); return( -1 ); } if( value_entry->size != 0 ) { *value_entry_data = &( ( internal_data_handle->data )[ value_entry->offset ] ); } else { *value_entry_data = NULL; } *value_entry_data_size = value_entry->size; } *encoding = internal_data_handle->encoding; return( 1 ); }
/* Retrieves a specific store identifier * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_store_identifier( libvshadow_volume_t *volume, int store_index, uint8_t *guid, size_t size, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; libvshadow_store_descriptor_t *store_descriptor = NULL; static char *function = "libvshadow_volume_get_store_identifier"; if( volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } internal_volume = (libvshadow_internal_volume_t *) volume; #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for reading.", function ); return( -1 ); } #endif if( libcdata_array_get_entry_by_index( internal_volume->store_descriptors_array, store_index, (intptr_t **) &store_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve store descriptor: %d.", function, store_index ); goto on_error; } if( libvshadow_store_descriptor_get_identifier( store_descriptor, guid, size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve identifier from store descriptor: %d.", function, store_index ); goto on_error; } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for reading.", function ); return( -1 ); } #endif return( 1 ); on_error: #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_read( internal_volume->read_write_lock, NULL ); #endif return( -1 ); }
/* Closes the mount handle * Returns the 0 if succesful or -1 on error */ int mount_handle_close( mount_handle_t *mount_handle, libcerror_error_t **error ) { libvhdi_file_t *input_file = NULL; static char *function = "mount_handle_close"; int input_file_index = 0; int number_of_input_files = 0; if( mount_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid mount handle.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( mount_handle->input_files_array, &number_of_input_files, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of input files.", function ); return( -1 ); } for( input_file_index = number_of_input_files - 1; input_file_index > 0; input_file_index-- ) { if( libcdata_array_get_entry_by_index( mount_handle->input_files_array, input_file_index, (intptr_t **) &input_file, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve input file: %d.", function, input_file_index ); return( -1 ); } if( libvhdi_file_close( input_file, error ) != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_CLOSE_FAILED, "%s: unable to close input file: %d.", function, input_file_index ); return( -1 ); } } return( 0 ); }
/* Retrieves the handle for a specific path * Returns 1 if successful, 0 if no such handle or -1 on error */ int mount_file_system_get_handle_by_path( mount_file_system_t *file_system, const system_character_t *path, size_t path_length, libvmdk_handle_t **vmdk_handle, libcerror_error_t **error ) { static char *function = "mount_file_system_get_handle_by_path"; system_character_t character = 0; size_t path_index = 0; int handle_index = 0; int result = 0; if( file_system == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file system.", function ); return( -1 ); } if( file_system->path_prefix == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid file system - missing path prefix.", function ); return( -1 ); } if( path == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid path.", function ); return( -1 ); } if( path_length > (size_t) ( SSIZE_MAX - 1 ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid path length value exceeds maximum.", function ); return( -1 ); } if( vmdk_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid handle.", function ); return( -1 ); } path_length = system_string_length( path ); if( ( path_length == 1 ) && ( path[ 0 ] == file_system->path_prefix[ 0 ] ) ) { *vmdk_handle = NULL; return( 1 ); } if( ( path_length < file_system->path_prefix_size ) || ( path_length > ( file_system->path_prefix_size + 3 ) ) ) { return( 0 ); } #if defined( WINAPI ) result = system_string_compare_no_case( path, file_system->path_prefix, file_system->path_prefix_size - 1 ); #else result = system_string_compare( path, file_system->path_prefix, file_system->path_prefix_size - 1 ); #endif if( result != 0 ) { return( 0 ); } handle_index = 0; path_index = file_system->path_prefix_size - 1; while( path_index < path_length ) { character = path[ path_index++ ]; if( ( character < (system_character_t) '0' ) || ( character > (system_character_t) '9' ) ) { return( 0 ); } handle_index *= 10; handle_index += character - (system_character_t) '0'; } handle_index -= 1; if( libcdata_array_get_entry_by_index( file_system->handles_array, handle_index, (intptr_t **) vmdk_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve handle: %d.", function, handle_index ); return( -1 ); } return( 1 ); }
/* Signals the file system to abort * Returns 1 if successful or -1 on error */ int mount_file_system_signal_abort( mount_file_system_t *file_system, libcerror_error_t **error ) { libvmdk_handle_t *vmdk_handle = NULL; static char *function = "mount_file_system_signal_abort"; int handle_index = 0; int number_of_handles = 0; if( file_system == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file system.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( file_system->handles_array, &number_of_handles, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of handles.", function ); return( -1 ); } for( handle_index = number_of_handles - 1; handle_index > 0; handle_index-- ) { if( libcdata_array_get_entry_by_index( file_system->handles_array, handle_index, (intptr_t **) &vmdk_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve handle: %d.", function, handle_index ); return( -1 ); } if( libvmdk_handle_signal_abort( vmdk_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to signal handle: %d to abort.", function, handle_index ); return( -1 ); } } return( 1 ); }
/* Retrieves the hive bin cell at the offset * Returns 1 if successful, 0 if not available or -1 on error */ int libregf_hive_bin_get_cell_at_offset( libregf_hive_bin_t *hive_bin, uint32_t cell_offset, libregf_hive_bin_cell_t **hive_bin_cell, libcerror_error_t **error ) { static char *function = "libregf_hive_bin_get_cell_at_offset"; int entry_index = 0; int number_of_entries = 0; if( hive_bin == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid hive bin.", function ); return( -1 ); } if( hive_bin->cells_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid hive bin - missing cells array.", function ); return( -1 ); } if( hive_bin_cell == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid hive bin cell.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( hive_bin->cells_array, &number_of_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve the number of hive bin cells.", function ); return( -1 ); } for( entry_index = 0; entry_index < number_of_entries; entry_index++ ) { if( libcdata_array_get_entry_by_index( hive_bin->cells_array, entry_index, (intptr_t **) hive_bin_cell, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve hive bin cell: %d.", function, entry_index ); return( -1 ); } if( ( *hive_bin_cell )->offset == cell_offset ) { return( 1 ); } } *hive_bin_cell = NULL; return( 0 ); }
/* Reads the page values * Returns 1 if successful or -1 on error */ int libesedb_page_read_values( libesedb_page_t *page, libesedb_io_handle_t *io_handle, libcdata_array_t *page_tags_array, uint8_t *page_values_data, size_t page_values_data_size, size_t page_values_data_offset, libcerror_error_t **error ) { libesedb_page_tags_value_t *page_tags_value = NULL; libesedb_page_value_t *page_value = NULL; static char *function = "libesedb_page_read_values"; uint16_t page_tags_index = 0; int number_of_page_tags = 0; if( page == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid page.", function ); return( -1 ); } if( page->values_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid page - missing values array.", function ); return( -1 ); } if( io_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid IO handle.", function ); return( -1 ); } if( page_tags_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid page tags array.", function ); return( -1 ); } if( page_values_data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid page values data.", function ); return( -1 ); } if( page_values_data_size > (size_t) SSIZE_MAX ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid page values data size value exceeds maximum.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( page_tags_array, &number_of_page_tags, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of page tags.", function ); return( -1 ); } if( libcdata_array_resize( page->values_array, number_of_page_tags, (int (*)(intptr_t **, libcerror_error_t **)) &libesedb_page_value_free, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_RESIZE_FAILED, "%s: unable to resize page values array.", function ); goto on_error; } for( page_tags_index = 0; page_tags_index < number_of_page_tags; page_tags_index++ ) { if( libcdata_array_get_entry_by_index( page_tags_array, page_tags_index, (intptr_t **) &page_tags_value, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve page tag: %" PRIu16 ".", function, page_tags_index ); goto on_error; } if( page_tags_value == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid page tags value.", function ); goto on_error; } if( libesedb_page_value_initialize( &page_value, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create tags value.", function ); goto on_error; } if( page_tags_value->offset > page->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: unsupported page tags value offset value out of bounds.", function ); #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: page value: %03" PRIu16 " offset: % 5" PRIu16 ", size: % 5" PRIu16 "\n", function, page_tags_index, page_tags_value->offset, page_tags_value->size ); } #endif goto on_error; } if( page_tags_value->size > ( page->data_size - page_tags_value->offset ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: unsupported page tags value size value out of bounds.", function ); #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: page value: %03" PRIu16 " offset: % 5" PRIu16 ", size: % 5" PRIu16 "\n", function, page_tags_index, page_tags_value->offset, page_tags_value->size ); } #endif goto on_error; } if( ( io_handle->format_revision >= LIBESEDB_FORMAT_REVISION_EXTENDED_PAGE_HEADER ) && ( io_handle->page_size >= 16384 ) ) { /* The page tags flags are stored in the upper byte of the first 16-bit value */ page_tags_value->flags = page_values_data[ page_tags_value->offset + 1 ] >> 5; page_values_data[ page_tags_value->offset + 1 ] &= 0x1f; } #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: page value: %03" PRIu16 " offset: % 5" PRIu16 ", size: % 5" PRIu16 ", flags: 0x%02" PRIx8 "", function, page_tags_index, page_tags_value->offset, page_tags_value->size, page_tags_value->flags ); libesedb_debug_print_page_tag_flags( page_tags_value->flags ); libcnotify_printf( "\n" ); } #endif page_value->data = &( page_values_data[ page_tags_value->offset ] ); page_value->offset = (uint16_t) ( page_values_data_offset + page_tags_value->offset ); page_value->size = page_tags_value->size; page_value->flags = page_tags_value->flags; if( libcdata_array_set_entry_by_index( page->values_array, (int) page_tags_index, (intptr_t *) page_value, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set page value: %" PRIu16 ".", function, page_tags_index ); goto on_error; } page_value = NULL; }
/* Retrieves the extended ASCII encoded name of a certain cache directory * The size should include the end of string character * The cache directory name consists of 8 characters + end of string character * Returns 1 if successful or -1 on error */ int libmsiecf_file_get_cache_directory_name( libmsiecf_file_t *file, int cache_directory_index, char *cache_directory_name, size_t cache_directory_name_size, libcerror_error_t **error ) { libmsiecf_internal_file_t *internal_file = NULL; static char *function = "libmsiecf_file_get_cache_directory_name"; intptr_t *cache_directory_entry = 0; if( file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file.", function ); return( -1 ); } internal_file = (libmsiecf_internal_file_t *) file; if( internal_file->directory_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid file - missing directory array.", function ); return( -1 ); } if( cache_directory_name == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid cache directory name.", function ); return( -1 ); } if( cache_directory_name_size < 9 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: cache directory name too small.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( internal_file->directory_array, cache_directory_index, &cache_directory_entry, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve cache directory entry: %d.", function, cache_directory_index + 1 ); return( -1 ); } if( cache_directory_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing cache directory entry.", function ); return( -1 ); } /* Assumed that the directory name contains only basic ASCII characters */ if( memory_copy( cache_directory_name, ( (libmsiecf_directory_descriptor_t *) cache_directory_entry )->name, 9 ) == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_COPY_FAILED, "%s: unable to set cache directory name.", function ); return( -1 ); } return( 1 ); }
/* Retrieves a specific provider by identifier (GUID) * Returns 1 if successful, 0 if not available or -1 on error */ int libfwevt_manifest_get_provider_by_identifier( libfwevt_manifest_t *manifest, const uint8_t *provider_identifier, size_t provider_identifier_size, libfwevt_provider_t **provider, libcerror_error_t **error ) { libfwevt_internal_manifest_t *internal_manifest = NULL; static char *function = "libfwevt_manifest_get_provider_by_identifier"; int number_of_providers = 0; int provider_index = 0; int result = 0; if( manifest == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid manifest.", function ); return( -1 ); } internal_manifest = (libfwevt_internal_manifest_t *) manifest; if( provider_identifier == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid provider identifier.", function ); return( -1 ); } if( provider == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid provider.", function ); return( -1 ); } if( provider_identifier_size < 16 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: invalid provider identifier value too small.", function ); return( -1 ); } if( provider_identifier_size > (size_t) SSIZE_MAX ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid provider identifier size value exceeds maximum.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( internal_manifest->providers_array, &number_of_providers, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries.", function ); return( -1 ); } for( provider_index = 0; provider_index < number_of_providers; provider_index++ ) { if( libcdata_array_get_entry_by_index( internal_manifest->providers_array, provider_index, (intptr_t **) provider, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d.", function, provider_index ); goto on_error; } result = libfwevt_provider_compare_identifier( *provider, provider_identifier, 16, error ); if( result == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GENERIC, "%s: unable to compare identifier of provider: %d.", function, provider_index ); goto on_error; } else if( result != 0 ) { return( 1 ); } } *provider = NULL; return( 0 ); on_error: *provider = NULL; return( -1 ); }
/* Determines the database type * Returns 1 if successful or -1 on error */ int database_type_determine( int *database_type, libcdata_array_t *table_names, libcerror_error_t **error ) { int database_types[ NUMBER_OF_DATABASE_TYPES ]; database_type_descriptor_t *database_type_descriptor = NULL; const system_character_t *known_table_name = NULL; system_character_t *table_name = NULL; static char *function = "export_handle_determine_database_type"; size_t known_table_name_length = 0; size_t table_name_length = 0; int database_type_index = 0; int known_table_name_index = 0; int number_of_tables = 0; int table_index = 0; if( database_type == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid database type.", function ); return( -1 ); } for( database_type_index = 0; database_type_index < NUMBER_OF_DATABASE_TYPES; database_type_index++ ) { database_types[ database_type_index ] = 0; } if( libcdata_array_get_number_of_entries( table_names, &number_of_tables, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of tables.", function ); return( -1 ); } for( table_index = 0; table_index < number_of_tables; table_index++ ) { if( libcdata_array_get_entry_by_index( table_names, table_index, (intptr_t **) &table_name, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve the name of table: %d from array.", function, table_index ); return( -1 ); } if( table_name == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing name of table: %d.", function, table_index ); return( -1 ); } table_name_length = system_string_length( table_name ); database_type_index = 0; database_type_descriptor = &( database_type_descriptors[ database_type_index++ ] ); while( database_type_descriptor->database_type != DATABASE_TYPE_UNKNOWN ) { known_table_name_index = 0; known_table_name = database_type_descriptor->known_table_names[ known_table_name_index++ ]; while( known_table_name != NULL ) { known_table_name_length = system_string_length( known_table_name ); if( ( known_table_name_length == table_name_length ) && ( system_string_compare( known_table_name, table_name, known_table_name_length ) == 0 ) ) { database_types[ database_type_descriptor->database_type ] += 1; } known_table_name = database_type_descriptor->known_table_names[ known_table_name_index++ ]; } database_type_descriptor = &( database_type_descriptors[ database_type_index++ ] ); } } *database_type = DATABASE_TYPE_UNKNOWN; for( database_type_index = 0; database_type_index < NUMBER_OF_DATABASE_TYPES; database_type_index++ ) { if( database_types[ *database_type ] < database_types[ database_type_index ] ) { *database_type = database_type_index; } } return( 1 ); }
/* Reads the manifest * Returns 1 if successful or -1 on error */ int libfwevt_manifest_read( libfwevt_manifest_t *manifest, const uint8_t *data, size_t data_size, libcerror_error_t **error ) { libfwevt_internal_manifest_t *internal_manifest = NULL; libfwevt_provider_t *provider = NULL; fwevt_template_manifest_t *wevt_manifest = NULL; fwevt_template_provider_entry_t *provider_entry = NULL; static char *function = "libfwevt_manifest_read"; size_t data_offset = 0; uint32_t number_of_providers = 0; uint32_t provider_data_offset = 0; uint32_t provider_index = 0; #if defined( HAVE_DEBUG_OUTPUT ) system_character_t guid_string[ 48 ]; libfguid_identifier_t *guid = NULL; uint32_t value_32bit = 0; int result = 0; #endif if( manifest == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid manifest.", function ); return( -1 ); } internal_manifest = (libfwevt_internal_manifest_t *) manifest; if( data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid data.", function ); return( -1 ); } if( data_size > (size_t) SSIZE_MAX ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid data size value exceeds maximum.", function ); return( -1 ); } if( data_size < sizeof( fwevt_template_manifest_t ) ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, "%s: invalid data value too small.", function ); return( -1 ); } wevt_manifest = (fwevt_template_manifest_t *) data; #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: manifest data:\n", function ); libcnotify_print_data( (uint8_t *) wevt_manifest, sizeof( fwevt_template_manifest_t ), 0 ); } #endif byte_stream_copy_to_uint16_little_endian( wevt_manifest->major_version, internal_manifest->major_version ); byte_stream_copy_to_uint16_little_endian( wevt_manifest->minor_version, internal_manifest->minor_version ); byte_stream_copy_to_uint32_little_endian( wevt_manifest->number_of_providers, number_of_providers ); #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: signature\t\t\t\t\t: %c%c%c%c\n", function, wevt_manifest->signature[ 0 ], wevt_manifest->signature[ 1 ], wevt_manifest->signature[ 2 ], wevt_manifest->signature[ 3 ] ); byte_stream_copy_to_uint32_little_endian( wevt_manifest->size, value_32bit ); libcnotify_printf( "%s: size\t\t\t\t\t\t: %" PRIu32 "\n", function, value_32bit ); libcnotify_printf( "%s: major version\t\t\t\t\t: %" PRIu16 "\n", function, internal_manifest->major_version ); libcnotify_printf( "%s: minor version\t\t\t\t\t: %" PRIu16 "\n", function, internal_manifest->minor_version ); libcnotify_printf( "%s: number of providers\t\t\t\t: %" PRIu32 "\n", function, number_of_providers ); libcnotify_printf( "\n" ); } #endif if( memory_compare( wevt_manifest->signature, "CRIM", 4 ) != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, "%s: unsupported manifest signature.", function ); goto on_error; } data_offset = sizeof( fwevt_template_manifest_t ); if( libcdata_array_initialize( &( internal_manifest->providers_array ), number_of_providers, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create providers array.", function ); goto on_error; } for( provider_index = 0; provider_index < number_of_providers; provider_index++ ) { if( data_offset >= data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid data offset value out of bounds.", function ); goto on_error; } provider_entry = (fwevt_template_provider_entry_t *) &( data[ data_offset ] ); if( ( data_offset + sizeof( fwevt_template_provider_entry_t ) ) >= data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid data value too small.", function ); goto on_error; } byte_stream_copy_to_uint32_little_endian( provider_entry->data_offset, provider_data_offset ); #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { if( libfguid_identifier_initialize( &guid, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create GUID.", function ); goto on_error; } if( libfguid_identifier_copy_from_byte_stream( guid, provider_entry->identifier, 16, LIBFGUID_ENDIAN_LITTLE, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_COPY_FAILED, "%s: unable to copy byte stream to GUID.", function ); goto on_error; } #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) result = libfguid_identifier_copy_to_utf16_string( guid, (uint16_t *) guid_string, 48, LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE, error ); #else result = libfguid_identifier_copy_to_utf8_string( guid, (uint8_t *) guid_string, 48, LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE, error ); #endif if( result != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_COPY_FAILED, "%s: unable to copy GUID to string.", function ); goto on_error; } libcnotify_printf( "%s: provider entry: %02" PRIu32 " identifier\t\t\t: %" PRIs_SYSTEM "\n", function, provider_index, guid_string ); if( libfguid_identifier_free( &guid, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, "%s: unable to free GUID.", function ); goto on_error; } libcnotify_printf( "%s: provider entry: %02" PRIu32 " data offset\t\t\t: 0x%08" PRIx32 "\n", function, provider_index, provider_data_offset ); } #endif data_offset += sizeof( fwevt_template_provider_entry_t ); if( libfwevt_provider_initialize( &provider, provider_entry->identifier, 16, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create provider: %" PRIu32 ".", function, provider_index ); goto on_error; } if( libfwevt_provider_read( provider, data, data_size, (size_t) provider_data_offset, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read provider: %d.", function, provider_index ); goto on_error; } if( libcdata_array_set_entry_by_index( internal_manifest->providers_array, (int) provider_index, (intptr_t *) provider, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set provider: %" PRIu32 ".", function, provider_index ); goto on_error; } provider = NULL; } /* TODO refactor to read on demand ? */ for( provider_index = 0; provider_index < number_of_providers; provider_index++ ) { if( libcdata_array_get_entry_by_index( internal_manifest->providers_array, provider_index, (intptr_t **) &provider, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve provider: %d.", function, provider_index ); provider = NULL; goto on_error; } if( libfwevt_provider_read_channels( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read channels.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_events( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read events.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_keywords( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read keywords.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_levels( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read levels.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_maps( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read maps.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_opcodes( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read opcodes.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_tasks( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read tasks.", function ); provider = NULL; goto on_error; } if( libfwevt_provider_read_templates( provider, data, data_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read templates.", function ); provider = NULL; goto on_error; } } /* TODO end refactor */ #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { if( number_of_providers > 0 ) { libcnotify_printf( "\n" ); } } #endif return( 1 ); on_error: #if defined( HAVE_DEBUG_OUTPUT ) if( guid != NULL ) { libfguid_identifier_free( &guid, NULL ); } #endif if( provider != NULL ) { libfwevt_provider_free( &provider, NULL ); } if( internal_manifest->providers_array != NULL ) { libcdata_array_free( &( internal_manifest->providers_array ), (int (*)(intptr_t **, libcerror_error_t **)) &libfwevt_provider_free, NULL ); } return( -1 ); }
/* Retrieves a specific stripe * Returns 1 if successful or -1 on error */ int libvslvm_segment_get_stripe( libvslvm_segment_t *segment, int stripe_index, libvslvm_stripe_t **stripe, libcerror_error_t **error ) { libvslvm_internal_segment_t *internal_segment = NULL; static char *function = "libvslvm_segment_get_stripe"; if( segment == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid segment.", function ); return( -1 ); } internal_segment = (libvslvm_internal_segment_t *) segment; if( stripe == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid stripe.", function ); return( -1 ); } if( *stripe != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid stripe value already set.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( internal_segment->stripes_array, stripe_index, (intptr_t **) stripe, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve stripe: %d.", function, stripe_index ); return( -1 ); } return( 1 ); }
/* Retrieves the key name entry at the index * Returns 1 if successful or -1 on error */ int libcreg_data_block_get_entry_by_index( libcreg_data_block_t *data_block, int entry_index, libcreg_key_name_entry_t **key_name_entry, int ascii_codepage, libcerror_error_t **error ) { libcreg_data_block_entry_t *data_block_entry = NULL; static char *function = "libcreg_data_block_get_entry_by_index"; #if defined( HAVE_DEBUG_OUTPUT ) off64_t file_offset = 0; #endif if( data_block == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid data block.", function ); return( -1 ); } if( data_block->data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid data block - missing data.", function ); return( -1 ); } if( key_name_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid key name entry.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( data_block->entries_array, entry_index, (intptr_t **) &data_block_entry, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve data block entry: %d.", function, entry_index ); goto on_error; } if( data_block_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid data block - missing data block entry: %d.", function, entry_index ); goto on_error; } #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { file_offset = data_block->offset + sizeof( creg_data_block_header_t ) + data_block_entry->offset; libcnotify_printf( "%s: reading key name entry at offset: %" PRIi64 " (0x%08" PRIx64 ")\n", function, file_offset, file_offset ); } #endif if( libcreg_key_name_entry_initialize( key_name_entry, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create key name entry.", function ); goto on_error; } if( libcreg_key_name_entry_read_data( *key_name_entry, &( ( data_block->data )[ data_block_entry->offset ] ), data_block_entry->size, ascii_codepage, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read key name entry: %d.", function, entry_index ); goto on_error; } return( 1 ); on_error: if( *key_name_entry != NULL ) { libcreg_key_name_entry_free( key_name_entry, NULL ); } return( -1 ); }
/* Sets a specific value entry * Returns if successful or -1 on error */ int libfvalue_data_handle_set_value_entry( libfvalue_data_handle_t *data_handle, int value_entry_index, const uint8_t *value_entry_data, size_t value_entry_data_size, int encoding, libcerror_error_t **error ) { libfvalue_internal_data_handle_t *internal_data_handle = NULL; libfvalue_value_entry_t *value_entry = NULL; static char *function = "libfvalue_data_handle_set_value_entry"; if( data_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid data handle.", function ); return( -1 ); } internal_data_handle = (libfvalue_internal_data_handle_t *) data_handle; if( internal_data_handle->data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid data handle - missing data.", function ); return( -1 ); } if( value_entry_index != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid value entry index value out of bounds.", function ); return( -1 ); } if( value_entry_data == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid value entry data.", function ); return( -1 ); } if( value_entry_data_size > (size_t) SSIZE_MAX ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid value entry data size value exceeds maximum.", function ); return( -1 ); } if( encoding != internal_data_handle->encoding ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid encoding value out of bounds.", function ); return( -1 ); } if( internal_data_handle->value_entries == NULL ) { if( value_entry_index != 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid value index value out of bounds.", function ); return( -1 ); } if( value_entry_data_size != internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid value entry data size value out of bounds.", function ); return( -1 ); } if( internal_data_handle->data_size > 0 ) { if( memory_copy( internal_data_handle->data, value_entry_data, internal_data_handle->data_size ) == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_COPY_FAILED, "%s: unable to copy value entry data.", function ); return( -1 ); } } } else { if( libcdata_array_get_entry_by_index( internal_data_handle->value_entries, value_entry_index, (intptr_t **) &value_entry, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d from values entries array.", function, value_entry_index ); return( -1 ); } if( value_entry == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing value entry.", function ); return( -1 ); } if( value_entry->offset > internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: value entry offset: %d out of bounds.", function, value_entry_index ); return( -1 ); } if( ( value_entry->offset + value_entry->size ) > internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, "%s: value entry size: %d out of bounds.", function, value_entry_index ); return( -1 ); } if( value_entry->size != internal_data_handle->data_size ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid value entry data size value out of bounds.", function ); return( -1 ); } if( value_entry->size > 0 ) { if( memory_copy( &( ( internal_data_handle->data )[ value_entry->offset ] ), value_entry_data, value_entry->size ) == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_MEMORY, LIBCERROR_MEMORY_ERROR_COPY_FAILED, "%s: unable to copy value entry data.", function ); return( -1 ); } } } return( 1 ); }
/* Retrieves a specific section * Returns 1 if successful or -1 on error */ int libolecf_property_set_get_section_by_index( libolecf_property_set_t *property_set, int section_index, libolecf_property_section_t **property_section, libcerror_error_t **error ) { libolecf_internal_property_set_t *internal_property_set = NULL; static char *function = "libolecf_property_set_get_section_by_index"; if( property_set == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid property set.", function ); return( -1 ); } internal_property_set = (libolecf_internal_property_set_t *) property_set; if( property_section == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid property section.", function ); return( -1 ); } if( *property_section != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: property section already set.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( internal_property_set->sections, section_index, (intptr_t **) property_section, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve section: %d.", function, section_index ); return( -1 ); } return( 1 ); }
/* Opens a volume for reading * Returns 1 if successful or -1 on error */ int libvshadow_volume_open_read( libvshadow_internal_volume_t *internal_volume, libbfio_handle_t *file_io_handle, libcerror_error_t **error ) { libvshadow_store_descriptor_t *last_store_descriptor = NULL; libvshadow_store_descriptor_t *store_descriptor = NULL; static char *function = "libvshadow_volume_open_read"; off64_t catalog_offset = 0; int number_of_store_descriptors = 0; int store_descriptor_index = 0; if( internal_volume == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid volume.", function ); return( -1 ); } if( internal_volume->io_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid volume - missing IO handle.", function ); return( -1 ); } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_grab_for_write( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to grab read/write lock for writing.", function ); return( -1 ); } #endif #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "Reading NTFS volume header:\n" ); } #endif if( libvshadow_io_handle_read_ntfs_volume_header( internal_volume->io_handle, file_io_handle, &( internal_volume->size ), error ) == -1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read NTFS volume header.", function ); goto on_error; } #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "Reading VSS volume header:\n" ); } #endif if( libvshadow_io_handle_read_volume_header( internal_volume->io_handle, file_io_handle, (off64_t) 0x1e00, &catalog_offset, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read volume header.", function ); goto on_error; } if( catalog_offset > 0 ) { #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "Reading VSS catalog:\n" ); } #endif if( libvshadow_io_handle_read_catalog( internal_volume->io_handle, file_io_handle, catalog_offset, &( internal_volume->size ), internal_volume->store_descriptors_array, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read catalog.", function ); goto on_error; } if( libcdata_array_get_number_of_entries( internal_volume->store_descriptors_array, &number_of_store_descriptors, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of store descriptors from array.", function ); goto on_error; } for( store_descriptor_index = 0; store_descriptor_index < number_of_store_descriptors; store_descriptor_index++ ) { if( libcdata_array_get_entry_by_index( internal_volume->store_descriptors_array, store_descriptor_index, (intptr_t **) &store_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve store descriptor: %d.", function, store_descriptor_index ); goto on_error; } store_descriptor->index = store_descriptor_index; #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "Reading VSS store: %02d:\n", store_descriptor->index ); } #endif if( libvshadow_store_descriptor_read_store_header( store_descriptor, file_io_handle, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_IO, LIBCERROR_IO_ERROR_READ_FAILED, "%s: unable to read store: %d header.", function, store_descriptor->index ); goto on_error; } store_descriptor->previous_store_descriptor = last_store_descriptor; if( last_store_descriptor != NULL ) { last_store_descriptor->next_store_descriptor = store_descriptor; } last_store_descriptor = store_descriptor; store_descriptor = NULL; } } #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) if( libcthreads_read_write_lock_release_for_write( internal_volume->read_write_lock, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to release read/write lock for writing.", function ); return( -1 ); } #endif return( 1 ); on_error: internal_volume->size = 0; libcdata_array_empty( internal_volume->store_descriptors_array, (int (*)(intptr_t **, libcerror_error_t **)) &libvshadow_store_descriptor_free, NULL ); #if defined( HAVE_LIBVSHADOW_MULTI_THREAD_SUPPORT ) libcthreads_read_write_lock_release_for_write( internal_volume->read_write_lock, NULL ); #endif return( -1 ); }
/* Retrieves the recovered item for the specific index * Returns 1 if successful or -1 on error */ int libmsiecf_file_get_recovered_item( libmsiecf_file_t *file, int recovered_item_index, libmsiecf_item_t **recovered_item, libcerror_error_t **error ) { libmsiecf_internal_file_t *internal_file = NULL; libmsiecf_item_descriptor_t *item_descriptor = NULL; static char *function = "libmsiecf_file_get_recovered_item"; if( file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file.", function ); return( -1 ); } internal_file = (libmsiecf_internal_file_t *) file; if( internal_file->recovered_item_array == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid file - missing recovered item array.", function ); return( -1 ); } if( recovered_item == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid recovered item.", function ); return( -1 ); } if( *recovered_item != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: recovered item already set.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( internal_file->recovered_item_array, recovered_item_index, (intptr_t **) &item_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve recovered item descriptor.", function ); return( -1 ); } if( libmsiecf_item_initialize( recovered_item, internal_file->file_io_handle, internal_file->io_handle, item_descriptor, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create recovered item.", function ); return( -1 ); } return( 1 ); }
/* Retrieves a specific item * Returns 1 if successful or -1 on error */ int libnk2_file_get_item( libnk2_file_t *file, int item_index, libnk2_item_t **item, libcerror_error_t **error ) { libnk2_internal_file_t *internal_file = NULL; static char *function = "libnk2_file_get_item"; if( file == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid file.", function ); return( -1 ); } internal_file = (libnk2_internal_file_t *) file; if( internal_file->file_io_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: invalid file - missing file IO handle.", function ); return( -1 ); } if( item == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid item.", function ); return( -1 ); } if( *item != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid item value already set.", function ); return( -1 ); } if( libcdata_array_get_entry_by_index( internal_file->items_array, item_index, (intptr_t **) item, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve item: %d.", function, item_index ); return( -1 ); } return( 1 ); }