From 196c46400b1ce03225932408c2f4ac668b81e93d Mon Sep 17 00:00:00 2001 From: dsdevuk Date: Sun, 16 Aug 2026 21:58:02 +0100 Subject: [PATCH 1/2] Fix for "LINK : fatal error LNK1181: cannot open input file '..\release\bzip2.lib'" in MSVSCPP build. Fix is to add 'libbz2.def' module defintion (.def) file so that the MSVSCPP project will emit required LIB file. Also modified project output filename to match bzip2/libbzip2 default of "LIBBZ2.dll". This is a partial fix for the DLL name issue. The full fix would be to rename the project "LIBBZ2", however, this may have other implications so I have not touched this. --- msvscpp/bzip2/bzip2.vcproj | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/msvscpp/bzip2/bzip2.vcproj b/msvscpp/bzip2/bzip2.vcproj index a98ff6c2f..666cb6245 100644 --- a/msvscpp/bzip2/bzip2.vcproj +++ b/msvscpp/bzip2/bzip2.vcproj @@ -56,8 +56,9 @@ /> + + From 57b6e464954b291cb65f5f35758d4403712942fb Mon Sep 17 00:00:00 2001 From: dsdevuk Date: Sun, 16 Aug 2026 22:11:29 +0100 Subject: [PATCH 2/2] Add missing libewf_extent_get_values() to support multi-extent files. This will allow existing code to stop using deprecated methods get_media_data_offset()/get_media_data_size(). An extra bonus is that data_flags comes back per-extent , so per-extent sparse detection now becomes possible. --- include/libewf.h.in | 11 ++++++ libewf/libewf_extent.c | 86 ++++++++++++++++++++++++++++++++++++++++++ libewf/libewf_extent.h | 8 ++++ 3 files changed, 105 insertions(+) diff --git a/include/libewf.h.in b/include/libewf.h.in index 80d5412b6..50c4dfaa2 100644 --- a/include/libewf.h.in +++ b/include/libewf.h.in @@ -2215,6 +2215,17 @@ int libewf_extent_free( libewf_extent_t **extent, libewf_error_t **error ); +/* Retrieves the extent offset, size and flags + * Returns 1 if successful or -1 on error + */ +LIBEWF_EXTERN \ +int libewf_extent_get_values( + libewf_extent_t *extent, + off64_t *offset, + size64_t *size, + uint32_t *flags, + libewf_error_t **error ); + /* ------------------------------------------------------------------------- * Source functions * ------------------------------------------------------------------------- */ diff --git a/libewf/libewf_extent.c b/libewf/libewf_extent.c index 287a47310..93857dcfd 100644 --- a/libewf/libewf_extent.c +++ b/libewf/libewf_extent.c @@ -183,3 +183,89 @@ int libewf_extent_free( return( result ); } +/* Retrieves the extent offset, size and flags + * Returns 1 if successful or -1 on error + */ +int libewf_extent_get_values( + libewf_extent_t *extent, + off64_t *offset, + size64_t *size, + uint32_t *flags, + libcerror_error_t **error ) +{ + libewf_internal_extent_t *internal_extent = NULL; + static char *function = "libewf_extent_get_values"; + + if( extent == NULL ) + { + libcerror_error_set( + error, + LIBCERROR_ERROR_DOMAIN_ARGUMENTS, + LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, + "%s: invalid extent.", + function ); + + return( -1 ); + } + if( ( offset == NULL ) + || ( size == NULL ) + || ( flags == NULL ) ) + { + libcerror_error_set( + error, + LIBCERROR_ERROR_DOMAIN_ARGUMENTS, + LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, + "%s: invalid offset, size or flags.", + function ); + + return( -1 ); + } + internal_extent = (libewf_internal_extent_t *) extent; + + if( internal_extent->lef_extent == NULL ) + { + libcerror_error_set( + error, + LIBCERROR_ERROR_DOMAIN_RUNTIME, + LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, + "%s: invalid extent - missing LEF extent.", + function ); + + return( -1 ); + } +#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) + if( libcthreads_read_write_lock_grab_for_read( + internal_extent->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 + *offset = internal_extent->lef_extent->data_offset; + *size = internal_extent->lef_extent->data_size; + *flags = internal_extent->lef_extent->data_flags; + +#if defined( HAVE_LIBEWF_MULTI_THREAD_SUPPORT ) + if( libcthreads_read_write_lock_release_for_read( + internal_extent->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 ); +} diff --git a/libewf/libewf_extent.h b/libewf/libewf_extent.h index 0bdcbfcc4..4f3195a30 100644 --- a/libewf/libewf_extent.h +++ b/libewf/libewf_extent.h @@ -60,6 +60,14 @@ int libewf_extent_free( libewf_extent_t **extent, libcerror_error_t **error ); +LIBEWF_EXTERN \ +int libewf_extent_get_values( + libewf_extent_t *extent, + off64_t *offset, + size64_t *size, + uint32_t *flags, + libcerror_error_t **error ); + #if defined( __cplusplus ) } #endif