/* Retrieves the number of stores * Returns 1 if successful or -1 on error */ int mount_file_system_get_number_of_stores( mount_file_system_t *file_system, int *number_of_stores, libcerror_error_t **error ) { static char *function = "mount_file_system_get_number_of_stores"; 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->stores_array, number_of_stores, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of stores.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of input files * Returns 1 if successful or -1 on error */ int mount_handle_get_number_of_input_files( mount_handle_t *mount_handle, int *number_of_input_files, libcerror_error_t **error ) { static char *function = "mount_handle_get_number_of_input_files"; 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 ); } return( 1 ); }
/* Retrieves the number of key name entries * Returns 1 if successful or -1 on error */ int libcreg_data_block_get_number_of_entries( libcreg_data_block_t *data_block, int *number_of_entries, libcerror_error_t **error ) { static char *function = "libcreg_data_block_get_number_of_entries"; 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( libcdata_array_get_number_of_entries( data_block->entries_array, number_of_entries, 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 ); } return( 1 ); }
/* Retrieves the number of level 2 metadata block descriptors * Returns 1 if successful or -1 on error */ int libfsrefs_level1_metadata_get_number_of_level2_metadata_block_descriptors( libfsrefs_level1_metadata_t *level1_metadata, int *number_of_block_descriptors, libcerror_error_t **error ) { static char *function = "libfsrefs_level1_metadata_get_number_of_level2_metadata_block_descriptors"; 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_number_of_entries( level1_metadata->level2_metadata_block_descriptors_array, number_of_block_descriptors, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries from array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of segments * Returns 1 if successful or -1 on error */ int libvslvm_logical_volume_values_get_number_of_segments( libvslvm_logical_volume_values_t *logical_volume_values, int *number_of_segments, libcerror_error_t **error ) { static char *function = "libvslvm_logical_volume_values_get_number_of_segments"; 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( libcdata_array_get_number_of_entries( logical_volume_values->segments_array, number_of_segments, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of elements from segments array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of hive bin cells * Returns 1 if successful or -1 on error */ int libregf_hive_bin_get_number_of_cells( libregf_hive_bin_t *hive_bin, uint16_t *number_of_cells, libcerror_error_t **error ) { static char *function = "libregf_hive_bin_get_number_of_cells"; 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( number_of_cells == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid number of cells.", 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 number of entries.", function ); return( -1 ); } if( number_of_entries > (int) UINT16_MAX ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, "%s: invalid number of entries value exceeds maximum.", function ); return( -1 ); } *number_of_cells = (uint16_t) number_of_entries; return( 1 ); }
/* Retrieves the number of value entries * Returns if successful or -1 on error */ int libfvalue_data_handle_get_number_of_value_entries( libfvalue_data_handle_t *data_handle, int *number_of_value_entries, libcerror_error_t **error ) { libfvalue_internal_data_handle_t *internal_data_handle = NULL; static char *function = "libfvalue_data_handle_get_number_of_value_entries"; 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( number_of_value_entries == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid number of value entries.", function ); return( -1 ); } if( internal_data_handle->data == NULL ) { *number_of_value_entries = 0; } else if( internal_data_handle->value_entries == NULL ) { *number_of_value_entries = 1; } else { if( libcdata_array_get_number_of_entries( internal_data_handle->value_entries, number_of_value_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries from value entries array.", function ); return( -1 ); } } return( 1 ); }
/* Retrieves the number of items * Returns 1 if successful or -1 on error */ int libnk2_file_get_number_of_items( libnk2_file_t *file, int *number_of_items, libcerror_error_t **error ) { libnk2_internal_file_t *internal_file = NULL; static char *function = "libnk2_file_get_number_of_items"; 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( libcdata_array_get_number_of_entries( internal_file->items_array, number_of_items, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of items.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of entries of the cache * Returns 1 if successful or -1 on error */ int libfcache_cache_get_number_of_entries( libfcache_cache_t *cache, int *number_of_entries, libcerror_error_t **error ) { libfcache_internal_cache_t *internal_cache = NULL; static char *function = "libfcache_cache_get_number_of_entries"; 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_number_of_entries( internal_cache->entries, number_of_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries from entries array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of data area descriptors * Returns 1 if successful or -1 on error */ int libvslvm_physical_volume_get_number_of_data_area_descriptors( libvslvm_physical_volume_t *physical_volume, int *number_of_data_area_descriptors, libcerror_error_t **error ) { libvslvm_internal_physical_volume_t *internal_physical_volume = NULL; static char *function = "libvslvm_physical_volume_get_number_of_data_area_descriptors"; 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_number_of_entries( internal_physical_volume->data_area_descriptors_array, number_of_data_area_descriptors, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of data area descriptors from array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of stripes * Returns 1 if successful or -1 on error */ int libvslvm_segment_get_number_of_stripes( libvslvm_segment_t *segment, int *number_of_stripes, libcerror_error_t **error ) { libvslvm_internal_segment_t *internal_segment = NULL; static char *function = "libvslvm_segment_get_number_of_stripes"; 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( libcdata_array_get_number_of_entries( internal_segment->stripes_array, number_of_stripes, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of elements from stripes array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of segments of the area * Returns 1 if successful or -1 on error */ int libfdata_area_get_number_of_segments( libfdata_area_t *area, int *number_of_segments, libcerror_error_t **error ) { libfdata_internal_area_t *internal_area = NULL; static char *function = "libfdata_area_get_number_of_segments"; if( area == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid area.", function ); return( -1 ); } internal_area = (libfdata_internal_area_t *) area; if( libcdata_array_get_number_of_entries( internal_area->segments_array, number_of_segments, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries from segments array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of recovered items * Returns 1 if successful or -1 on error */ int libmsiecf_file_get_number_of_recovered_items( libmsiecf_file_t *file, int *number_of_recovered_items, libcerror_error_t **error ) { libmsiecf_internal_file_t *internal_file = NULL; static char *function = "libmsiecf_file_get_number_of_recovered_items"; 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( libcdata_array_get_number_of_entries( internal_file->recovered_item_array, number_of_recovered_items, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of elements from recovered item array.", function ); return( -1 ); } return( 1 ); }
/* Retrieves the number of providers * Returns 1 if successful or -1 on error */ int libfwevt_manifest_get_number_of_providers( libfwevt_manifest_t *manifest, int *number_of_providers, libcerror_error_t **error ) { libfwevt_internal_manifest_t *internal_manifest = NULL; static char *function = "libfwevt_manifest_get_number_of_providers"; 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_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 ); } return( 1 ); }
/* Retrieves the number of sections in the property set * Returns 1 if successful or -1 on error */ int libolecf_property_set_get_number_of_sections( libolecf_property_set_t *property_set, int *number_of_sections, libcerror_error_t **error ) { libolecf_internal_property_set_t *internal_property_set = NULL; static char *function = "libolecf_property_set_get_number_of_sections"; 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( libcdata_array_get_number_of_entries( internal_property_set->sections, number_of_sections, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries in sections array.", function ); return( -1 ); } return( 1 ); }
/* Calculates the mapped ranges from the segments * Returns 1 if successful or -1 on error */ int libfdata_segments_array_calculate_mapped_ranges( libcdata_array_t *segments_array, libcdata_array_t *mapped_ranges_array, libcerror_error_t **error ) { libfdata_mapped_range_t *mapped_range = NULL; libfdata_range_t *segment_data_range = NULL; static char *function = "libfdata_segments_array_calculate_mapped_ranges"; off64_t mapped_offset = 0; off64_t segment_offset = 0; size64_t segment_size = 0; uint32_t segment_flags = 0; int number_of_segments = 0; int segment_file_index = 0; int segment_index = 0; if( libcdata_array_get_number_of_entries( segments_array, &number_of_segments, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of entries from segments array.", function ); return( -1 ); } for( segment_index = 0; segment_index < number_of_segments; segment_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( libcdata_array_get_entry_by_index( mapped_ranges_array, segment_index, (intptr_t **) &mapped_range, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve entry: %d from mapped ranges 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 ); } #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "%s: segment: %03d\tfile index: %03d offset: 0x%08" PRIx64 " - 0x%08" PRIx64 " (size: %" PRIu64 ")\n", function, segment_index, segment_file_index, segment_offset, segment_offset + segment_size, segment_size ); libcnotify_printf( "%s: segment: %03d\tmapped range: 0x%08" PRIx64 " - 0x%08" PRIx64 " (size: %" PRIu64 ")\n", function, segment_index, mapped_offset, mapped_offset + segment_size, segment_size ); } #endif if( libfdata_mapped_range_set( mapped_range, mapped_offset, segment_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_SET_FAILED, "%s: unable to set mapped range: %d values.", function, segment_index ); return( -1 ); } mapped_offset += (off64_t) segment_size; } #if defined( HAVE_DEBUG_OUTPUT ) if( libcnotify_verbose != 0 ) { libcnotify_printf( "\n" ); } #endif return( 1 ); }
/* 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 data area descriptor for a specific offset * Returns 1 if successful, 0 if no such data area descriptor or -1 on error */ int libvslvm_physical_volume_get_data_area_descriptor_by_offset( libvslvm_physical_volume_t *physical_volume, uint64_t offset, 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_data_area_descriptor_by_offset"; int data_area_descriptor_index = 0; int number_of_data_area_descriptors = 0; 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( data_area_descriptor == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid data area descriptor.", function ); return( -1 ); } if( *data_area_descriptor != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: invalid data area descriptor value already set.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( internal_physical_volume->data_area_descriptors_array, &number_of_data_area_descriptors, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of data area descriptors from array.", function ); return( -1 ); } for( data_area_descriptor_index = 0; data_area_descriptor_index < number_of_data_area_descriptors; data_area_descriptor_index++ ) { if( libcdata_array_get_entry_by_index( internal_physical_volume->data_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 data area descriptor: %d.", function, data_area_descriptor_index ); return( -1 ); } if( *data_area_descriptor == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, "%s: missing data area descriptor: %d.", function, data_area_descriptor_index ); return( -1 ); } if( ( *data_area_descriptor )->size == 0 ) { return( 1 ); } offset -= ( *data_area_descriptor )->size; } return( 0 ); }
/* Clones (duplicates) the cache, not the cache values * Returns 1 if successful or -1 on error */ int libfcache_cache_clone( libfcache_cache_t **destination_cache, libfcache_cache_t *source_cache, libcerror_error_t **error ) { libfcache_internal_cache_t *internal_source_cache = NULL; static char *function = "libfcache_cache_clone"; int number_of_cache_entries = 0; if( destination_cache == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid destination cache.", function ); return( -1 ); } if( *destination_cache != NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, "%s: destination cache already set.", function ); return( -1 ); } if( source_cache == NULL ) { *destination_cache = NULL; return( 1 ); } internal_source_cache = (libfcache_internal_cache_t *) source_cache; if( libcdata_array_get_number_of_entries( internal_source_cache->entries, &number_of_cache_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of cache entries from source entries array.", function ); return( -1 ); } if( libfcache_cache_initialize( destination_cache, number_of_cache_entries, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, "%s: unable to create destination cache.", function ); return( -1 ); } 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 ); }
/* 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 number of stores * Returns 1 if successful or -1 on error */ int libvshadow_volume_get_number_of_stores( libvshadow_volume_t *volume, int *number_of_stores, libcerror_error_t **error ) { libvshadow_internal_volume_t *internal_volume = NULL; static char *function = "libvshadow_volume_get_number_of_stores"; int result = 1; 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_number_of_entries( internal_volume->store_descriptors_array, number_of_stores, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of store descriptors.", function ); result = -1; } #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( result ); }
/* 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 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 ); }
/* 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 ); }
/* Retrieves the segment data range for a specific offset * Returns 1 if successful or -1 on error */ int libfdata_segments_array_get_data_range_at_offset( libcdata_array_t *segments_array, off64_t value_offset, off64_t *segment_data_offset, libfdata_range_t **segment_data_range, libcerror_error_t **error ) { static char *function = "libfdata_segments_array_get_data_range_at_offset"; size64_t segment_size = 0; int number_of_segments = 0; int segment_index = 0; if( segment_data_offset == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid segment data offset.", function ); return( -1 ); } if( segment_data_range == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid segment data range.", function ); return( -1 ); } if( libcdata_array_get_number_of_entries( segments_array, &number_of_segments, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve number of segments.", function ); return( -1 ); } if( number_of_segments <= 0 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid number of segments value out of bounds.", function ); return( -1 ); } for( segment_index = 0; segment_index < number_of_segments; segment_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 segment data range: %d from array.", function, segment_index ); return( -1 ); } if( libfdata_range_get_size( *segment_data_range, &segment_size, error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_GET_FAILED, "%s: unable to retrieve size from segment data range: %d.", function, segment_index ); return( -1 ); } /* TODO what about compressed data ranges */ if( (size64_t) value_offset < segment_size ) { *segment_data_offset = value_offset; break; } value_offset -= segment_size; } if( segment_index >= number_of_segments ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS, "%s: invalid segment index value out of bounds.", function ); return( -1 ); } 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 ); }