├── .codecov.yml ├── .github └── workflows │ ├── build.yml │ ├── build_freebsd.yml │ ├── build_ossfuzz.yml │ └── build_shared.yml ├── .gitignore ├── AUTHORS ├── COPYING ├── COPYING.LESSER ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── acinclude.m4 ├── appveyor.yml ├── autogen.ps1 ├── autogen.sh ├── build.ps1 ├── builddokan.ps1 ├── common ├── Makefile.am ├── byte_stream.h ├── common.h ├── config_borlandc.h ├── config_msc.h ├── config_winapi.h ├── file_stream.h ├── memory.h ├── narrow_string.h ├── system_string.h ├── types.h.in └── wide_string.h ├── configure.ac ├── documentation └── Windows Hibernation File (hiberfil.sys) format.asciidoc ├── dpkg ├── changelog.in ├── compat ├── control ├── copyright ├── libhibr-dev.install ├── libhibr-tools.install ├── libhibr.install ├── rules └── source │ └── format ├── hibrtools ├── Makefile.am ├── hibrinfo.c ├── hibrmount.c ├── hibrtools_getopt.c ├── hibrtools_getopt.h ├── hibrtools_i18n.h ├── hibrtools_libbfio.h ├── hibrtools_libcdata.h ├── hibrtools_libcerror.h ├── hibrtools_libclocale.h ├── hibrtools_libcnotify.h ├── hibrtools_libcpath.h ├── hibrtools_libhibr.h ├── hibrtools_libuna.h ├── hibrtools_output.c ├── hibrtools_output.h ├── hibrtools_signal.c ├── hibrtools_signal.h ├── hibrtools_unused.h ├── info_handle.c ├── info_handle.h ├── mount_dokan.c ├── mount_dokan.h ├── mount_file_entry.c ├── mount_file_entry.h ├── mount_file_system.c ├── mount_file_system.h ├── mount_fuse.c ├── mount_fuse.h ├── mount_handle.c └── mount_handle.h ├── include ├── Makefile.am ├── libhibr.h.in └── libhibr │ ├── codepage.h │ ├── definitions.h.in │ ├── error.h │ ├── extern.h │ ├── features.h.in │ └── types.h.in ├── libhibr.ini ├── libhibr.pc.in ├── libhibr.spec.in ├── libhibr ├── Makefile.am ├── hibr_compressed_page_data.h ├── hibr_compressed_page_map.h ├── hibr_memory_image_information.h ├── libhibr.c ├── libhibr.rc.in ├── libhibr_compressed_page_data.c ├── libhibr_compressed_page_data.h ├── libhibr_compressed_page_map.c ├── libhibr_compressed_page_map.h ├── libhibr_debug.c ├── libhibr_debug.h ├── libhibr_definitions.h.in ├── libhibr_error.c ├── libhibr_error.h ├── libhibr_extern.h ├── libhibr_file.c ├── libhibr_file.h ├── libhibr_i18n.c ├── libhibr_i18n.h ├── libhibr_io_handle.c ├── libhibr_io_handle.h ├── libhibr_libbfio.h ├── libhibr_libcdata.h ├── libhibr_libcerror.h ├── libhibr_libclocale.h ├── libhibr_libcnotify.h ├── libhibr_libfcache.h ├── libhibr_libfdata.h ├── libhibr_libfdatetime.h ├── libhibr_libfwnt.h ├── libhibr_libuna.h ├── libhibr_notify.c ├── libhibr_notify.h ├── libhibr_support.c ├── libhibr_support.h ├── libhibr_types.h └── libhibr_unused.h ├── m4 ├── common.m4 ├── libbfio.m4 ├── libcdata.m4 ├── libcerror.m4 ├── libcfile.m4 ├── libclocale.m4 ├── libcnotify.m4 ├── libcpath.m4 ├── libcsplit.m4 ├── libcthreads.m4 ├── libfcache.m4 ├── libfdata.m4 ├── libfdatetime.m4 ├── libfuse.m4 ├── libfwnt.m4 ├── libuna.m4 ├── pthread.m4 ├── tests.m4 └── types.m4 ├── manuals ├── Makefile.am ├── hibrinfo.1 └── libhibr.3 ├── msvscpp ├── Makefile.am ├── hibr_test_compressed_page_data │ └── hibr_test_compressed_page_data.vcproj ├── hibr_test_compressed_page_map │ └── hibr_test_compressed_page_map.vcproj ├── hibr_test_error │ └── hibr_test_error.vcproj ├── hibr_test_file │ └── hibr_test_file.vcproj ├── hibr_test_io_handle │ └── hibr_test_io_handle.vcproj ├── hibr_test_notify │ └── hibr_test_notify.vcproj ├── hibr_test_support │ └── hibr_test_support.vcproj ├── hibrinfo │ └── hibrinfo.vcproj ├── hibrmount │ └── hibrmount.vcproj ├── libbfio │ └── libbfio.vcproj ├── libcdata │ └── libcdata.vcproj ├── libcerror │ └── libcerror.vcproj ├── libcfile │ └── libcfile.vcproj ├── libclocale │ └── libclocale.vcproj ├── libcnotify │ └── libcnotify.vcproj ├── libcpath │ └── libcpath.vcproj ├── libcsplit │ └── libcsplit.vcproj ├── libcthreads │ └── libcthreads.vcproj ├── libfcache │ └── libfcache.vcproj ├── libfdata │ └── libfdata.vcproj ├── libfdatetime │ └── libfdatetime.vcproj ├── libfwnt │ └── libfwnt.vcproj ├── libhibr.sln ├── libhibr │ └── libhibr.vcproj └── libuna │ └── libuna.vcproj ├── ossfuzz ├── Makefile.am ├── file_fuzzer.cc ├── ossfuzz_libbfio.h └── ossfuzz_libhibr.h ├── po ├── ChangeLog ├── Makevars.in └── POTFILES.in ├── runtests.ps1 ├── runtests.sh ├── syncdokan.ps1 ├── synclibs.ps1 ├── synclibs.sh └── tests ├── Makefile.am ├── build.sh ├── hibr_test_compressed_page_data.c ├── hibr_test_compressed_page_map.c ├── hibr_test_error.c ├── hibr_test_file.c ├── hibr_test_functions.c ├── hibr_test_functions.h ├── hibr_test_getopt.c ├── hibr_test_getopt.h ├── hibr_test_io_handle.c ├── hibr_test_libbfio.h ├── hibr_test_libcerror.h ├── hibr_test_libclocale.h ├── hibr_test_libcnotify.h ├── hibr_test_libhibr.h ├── hibr_test_libuna.h ├── hibr_test_macros.h ├── hibr_test_memory.c ├── hibr_test_memory.h ├── hibr_test_notify.c ├── hibr_test_support.c ├── hibr_test_unused.h ├── lsan.suppressions ├── pkgbuild.sh ├── runtests.sh ├── syncsharedlibs.sh ├── test_hibrinfo.ps1 ├── test_hibrinfo.sh ├── test_library.ps1 ├── test_library.sh ├── test_manpage.sh └── test_runner.sh /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: down 4 | range: 70...100 5 | status: 6 | project: true 7 | patch: true 8 | changes: false 9 | ignore: 10 | - "libbfio/*" 11 | - "libcdata/*" 12 | - "libcerror/*" 13 | - "libcfile/*" 14 | - "libclocale/*" 15 | - "libcnotify/*" 16 | - "libcpath/*" 17 | - "libcsplit/*" 18 | - "libcthreads/*" 19 | - "libfcache/*" 20 | - "libfdata/*" 21 | - "libfdatetime/*" 22 | - "libfwnt/*" 23 | - "libuna/*" 24 | - "tests/*" 25 | -------------------------------------------------------------------------------- /.github/workflows/build_freebsd.yml: -------------------------------------------------------------------------------- 1 | # Build from source on FreeBSD. 2 | name: build_freebsd 3 | on: [push] 4 | permissions: read-all 5 | jobs: 6 | build_freebsd: 7 | runs-on: ubuntu-22.04 8 | steps: 9 | - uses: actions/checkout@v4 10 | - name: Building from source 11 | id: build_freebsd 12 | uses: vmactions/freebsd-vm@v1 13 | with: 14 | usesh: true 15 | mem: 4096 16 | # Note that the test scripts require bash 17 | prepare: | 18 | pkg install -y autoconf automake bash fusefs-libs gettext git libtool pkgconf 19 | run: | 20 | tests/build.sh 21 | tests/runtests.sh 22 | -------------------------------------------------------------------------------- /.github/workflows/build_ossfuzz.yml: -------------------------------------------------------------------------------- 1 | # Build OSSFuzz fuzz targets from source. 2 | name: build_ossfuzz 3 | on: 4 | push: 5 | branches: [main] 6 | permissions: read-all 7 | jobs: 8 | build_ossfuzz: 9 | runs-on: ubuntu-22.04 10 | strategy: 11 | matrix: 12 | include: 13 | - architecture: 'x64' 14 | compiler: 'gcc' 15 | configure_options: '' 16 | steps: 17 | - name: Install build dependencies 18 | run: | 19 | sudo apt-get -y install git 20 | - uses: actions/checkout@v4 21 | with: 22 | repository: google/oss-fuzz 23 | path: oss-fuzz 24 | - name: Build OSSFuzz fuzz targets 25 | working-directory: oss-fuzz 26 | run: | 27 | mkdir -p projects/libhibr 28 | cp projects/libyal/build.sh projects/libhibr/ 29 | cp projects/libyal/project.yaml projects/libhibr/ 30 | head -n 20 projects/libyal/Dockerfile > projects/libhibr/Dockerfile 31 | echo "RUN git clone --depth 1 https://github.com/libyal/libhibr.git libhibr" >> projects/libhibr/Dockerfile 32 | tail -n 3 projects/libyal/Dockerfile >> projects/libhibr/Dockerfile 33 | python3 infra/helper.py build_image --pull libhibr 34 | python3 infra/helper.py build_fuzzers --sanitizer address libhibr 35 | python3 infra/helper.py check_build libhibr 36 | -------------------------------------------------------------------------------- /.github/workflows/build_shared.yml: -------------------------------------------------------------------------------- 1 | # Build from source with libyal dependencies as shared libraries. 2 | name: build_shared 3 | on: 4 | push: 5 | branches: [main] 6 | permissions: read-all 7 | jobs: 8 | build_shared_ubuntu: 9 | runs-on: ubuntu-22.04 10 | strategy: 11 | matrix: 12 | include: 13 | - architecture: 'x64' 14 | compiler: 'gcc' 15 | configure_options: '--enable-wide-character-type' 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Install build dependencies 19 | run: | 20 | sudo apt-get -y install autoconf automake autopoint build-essential git libfuse3-dev libtool pkg-config 21 | - name: Download test data 22 | run: | 23 | if test -x "synctestdata.sh"; then ./synctestdata.sh; fi 24 | - name: Prepare shared libraries 25 | run: | 26 | tests/syncsharedlibs.sh --use-head 27 | - name: Building from source 28 | env: 29 | CC: ${{ matrix.compiler }} 30 | run: | 31 | tests/build.sh ${{ matrix.configure_options }} 32 | - name: Run tests 33 | run: | 34 | tests/runtests.sh 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files to ignore by git 2 | # 3 | # Version: 20231119 4 | 5 | # Generic auto-generated build files 6 | *~ 7 | *.a 8 | *.gcda 9 | *.gcno 10 | *.gcov 11 | *.la 12 | *.lai 13 | *.lib 14 | *.lineno 15 | *.lo 16 | *.log 17 | *.loT 18 | *.o 19 | *.obj 20 | *.Plo 21 | *.Po 22 | *.so 23 | *.so.[0-9][0-9]* 24 | *.so.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]* 25 | *.swp 26 | *.Tpo 27 | *.trs 28 | *.whl 29 | /*.egg-info/ 30 | __pycache__ 31 | .deps 32 | .dirstamp 33 | .libs 34 | .tox 35 | INSTALL 36 | Makefile 37 | Makefile.bcc 38 | Makefile.in 39 | stamp-h[1-9] 40 | 41 | # Specific auto-generated build files 42 | /ABOUT-NLS 43 | /aclocal.m4 44 | /autom4te.cache/ 45 | /build 46 | /compile 47 | /confdefs.h 48 | /config.cache 49 | /config.guess 50 | /config.log 51 | /config.rpath 52 | /config.status 53 | /config.sub 54 | /configure 55 | /conftest.c 56 | /depcomp 57 | /dist 58 | /install-sh 59 | /libtool 60 | /ltmain.sh 61 | /m4/codeset.m4 62 | /m4/extern-inline.m4 63 | /m4/fcntl-o.m4 64 | /m4/gettext.m4 65 | /m4/glibc21.m4 66 | /m4/glibc2.m4 67 | /m4/host-cpu-c-abi.m4 68 | /m4/iconv.m4 69 | /m4/intdiv0.m4 70 | /m4/intldir.m4 71 | /m4/intl.m4 72 | /m4/intlmacosx.m4 73 | /m4/intmax.m4 74 | /m4/inttypes_h.m4 75 | /m4/inttypes-pri.m4 76 | /m4/lcmessage.m4 77 | /m4/lib-ld.m4 78 | /m4/lib-link.m4 79 | /m4/lib-prefix.m4 80 | /m4/libtool.m4 81 | /m4/lock.m4 82 | /m4/longlong.m4 83 | /m4/lt~obsolete.m4 84 | /m4/ltoptions.m4 85 | /m4/ltsugar.m4 86 | /m4/ltversion.m4 87 | /m4/nls.m4 88 | /m4/pkg.m4 89 | /m4/po.m4 90 | /m4/printf-posix.m4 91 | /m4/progtest.m4 92 | /m4/size_max.m4 93 | /m4/stdint_h.m4 94 | /m4/threadlib.m4 95 | /m4/uintmax_t.m4 96 | /m4/visibility.m4 97 | /m4/wchar_t.m4 98 | /m4/wint_t.m4 99 | /m4/xsize.m4 100 | /MANIFEST 101 | /missing 102 | /po/boldquot.sed 103 | /po/en@boldquot.header 104 | /po/en@quot.header 105 | /po/insert-header.sin 106 | /po/Makefile.in.in 107 | /po/Makevars 108 | /po/Makevars.template 109 | /po/POTFILES 110 | /po/quot.sed 111 | /po/remove-potcdate.sed 112 | /po/remove-potcdate.sin 113 | /po/Rules-quot 114 | /test-driver 115 | /ylwrap 116 | 117 | # Project specific files 118 | /common/config.h 119 | /common/config.h.in 120 | /common/types.h 121 | /dpkg/changelog 122 | /include/libhibr.h 123 | /include/libhibr/definitions.h 124 | /include/libhibr/features.h 125 | /include/libhibr/types.h 126 | /libhibr.pc 127 | /libhibr.spec 128 | /libhibr/libhibr.rc 129 | /libhibr/libhibr_definitions.h 130 | /hibrtools/*.exe 131 | /hibrtools/hibrinfo 132 | /hibrtools/hibrmount 133 | /tests/*.exe 134 | /tests/hibr_test_compressed_page_data 135 | /tests/hibr_test_compressed_page_map 136 | /tests/hibr_test_error 137 | /tests/hibr_test_file 138 | /tests/hibr_test_io_handle 139 | /tests/hibr_test_notify 140 | /tests/hibr_test_support 141 | /tests/input 142 | /tests/notify_stream.log 143 | /tests/tmp* 144 | 145 | # Local library dependencies specific files 146 | /libbfio 147 | /libcdata 148 | /libcerror 149 | /libcfile 150 | /libclocale 151 | /libcnotify 152 | /libcpath 153 | /libcsplit 154 | /libcthreads 155 | /libfcache 156 | /libfdata 157 | /libfdatetime 158 | /libfwnt 159 | /libuna 160 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Acknowledgements: libhibr 2 | 3 | Copyright (C) 2012-2024, Joachim Metz 4 | 5 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | TODO 2 | * update manuals 3 | 4 | 20141129 5 | * see `git log' for more recent change log 6 | * code clean up and changes for project move 7 | 8 | 20141021 9 | * changes for deployment 10 | * removed README.macosx 11 | 12 | 20140703 13 | * updated dependencies 14 | * added libfwnt 15 | 16 | 20140119 17 | * 2014 update 18 | * updated dependencies 19 | * added libcthreads 20 | 21 | 20130831 22 | * updated dependencies 23 | 24 | 20121206 25 | * worked on initial version 26 | 27 | 20121205 28 | * initial version based on libvhdi 29 | 30 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | SUBDIRS = \ 4 | include \ 5 | common \ 6 | libcerror \ 7 | libcthreads \ 8 | libcdata \ 9 | libclocale \ 10 | libcnotify \ 11 | libcsplit \ 12 | libuna \ 13 | libcfile \ 14 | libcpath \ 15 | libbfio \ 16 | libfcache \ 17 | libfdata \ 18 | libfdatetime \ 19 | libfwnt \ 20 | libhibr \ 21 | hibrtools \ 22 | po \ 23 | manuals \ 24 | tests \ 25 | ossfuzz \ 26 | msvscpp 27 | 28 | DPKG_FILES = \ 29 | dpkg/changelog \ 30 | dpkg/changelog.in \ 31 | dpkg/compat \ 32 | dpkg/control \ 33 | dpkg/copyright \ 34 | dpkg/rules \ 35 | dpkg/libhibr-dev.install \ 36 | dpkg/libhibr.install \ 37 | dpkg/libhibr-tools.install \ 38 | dpkg/source/format 39 | 40 | GETTEXT_FILES = \ 41 | config.rpath \ 42 | po/Makevars.in 43 | 44 | PKGCONFIG_FILES = \ 45 | libhibr.pc.in 46 | 47 | SPEC_FILES = \ 48 | libhibr.spec \ 49 | libhibr.spec.in 50 | 51 | EXTRA_DIST = \ 52 | $(DPKG_FILES) \ 53 | $(GETTEXT_FILES) \ 54 | $(PKGCONFIG_FILES) \ 55 | $(SPEC_FILES) 56 | 57 | DISTCLEANFILES = \ 58 | config.status \ 59 | config.cache \ 60 | config.log \ 61 | libhibr.pc \ 62 | libhibr.spec \ 63 | Makefile \ 64 | Makefile.in \ 65 | po/Makevars 66 | 67 | pkgconfigdir = $(libdir)/pkgconfig 68 | 69 | pkgconfig_DATA = \ 70 | libhibr.pc 71 | 72 | libtool: @LIBTOOL_DEPS@ 73 | cd $(srcdir) && $(SHELL) ./config.status --recheck 74 | 75 | lib: library 76 | 77 | library: 78 | (cd $(srcdir)/common && $(MAKE) $(AM_MAKEFLAGS)) 79 | (cd $(srcdir)/libcerror && $(MAKE) $(AM_MAKEFLAGS)) 80 | (cd $(srcdir)/libcthreads && $(MAKE) $(AM_MAKEFLAGS)) 81 | (cd $(srcdir)/libcdata && $(MAKE) $(AM_MAKEFLAGS)) 82 | (cd $(srcdir)/libclocale && $(MAKE) $(AM_MAKEFLAGS)) 83 | (cd $(srcdir)/libcnotify && $(MAKE) $(AM_MAKEFLAGS)) 84 | (cd $(srcdir)/libcsplit && $(MAKE) $(AM_MAKEFLAGS)) 85 | (cd $(srcdir)/libuna && $(MAKE) $(AM_MAKEFLAGS)) 86 | (cd $(srcdir)/libcfile && $(MAKE) $(AM_MAKEFLAGS)) 87 | (cd $(srcdir)/libcpath && $(MAKE) $(AM_MAKEFLAGS)) 88 | (cd $(srcdir)/libbfio && $(MAKE) $(AM_MAKEFLAGS)) 89 | (cd $(srcdir)/libfcache && $(MAKE) $(AM_MAKEFLAGS)) 90 | (cd $(srcdir)/libfdata && $(MAKE) $(AM_MAKEFLAGS)) 91 | (cd $(srcdir)/libfdatetime && $(MAKE) $(AM_MAKEFLAGS)) 92 | (cd $(srcdir)/libfwnt && $(MAKE) $(AM_MAKEFLAGS)) 93 | (cd $(srcdir)/libhibr && $(MAKE) $(AM_MAKEFLAGS)) 94 | (cd $(srcdir)/po && $(MAKE) $(AM_MAKEFLAGS)) 95 | 96 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libyal/libhibr/84eb534e66e70a752657741ccf4a8dd06e4bc9bf/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | libhibr is a library to access the Windows Hibernation File (hiberfil.sys) format. 2 | 3 | Note that this project currently only focuses on the analysis of the format. 4 | 5 | Project information: 6 | 7 | * Status: experimental 8 | * Licence: LGPLv3+ 9 | 10 | Planned: 11 | 12 | * Finish library 13 | 14 | For more information see: 15 | 16 | * Project documentation: https://github.com/libyal/libhibr/wiki/Home 17 | * How to build from source: https://github.com/libyal/libhibr/wiki/Building 18 | 19 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl Checks for required headers and functions 2 | dnl 3 | dnl Version: 20200713 4 | 5 | dnl Function to detect if libhibr dependencies are available 6 | AC_DEFUN([AX_LIBHIBR_CHECK_LOCAL], 7 | [dnl Check for internationalization functions in libhibr/libhibr_i18n.c 8 | AC_CHECK_FUNCS([bindtextdomain]) 9 | ]) 10 | 11 | dnl Function to detect if hibrtools dependencies are available 12 | AC_DEFUN([AX_HIBRTOOLS_CHECK_LOCAL], 13 | [AC_CHECK_HEADERS([signal.h sys/signal.h unistd.h]) 14 | 15 | AC_CHECK_FUNCS([close getopt setvbuf]) 16 | 17 | AS_IF( 18 | [test "x$ac_cv_func_close" != xyes], 19 | [AC_MSG_FAILURE( 20 | [Missing function: close], 21 | [1]) 22 | ]) 23 | 24 | dnl Headers included in hibrtools/hibrmount.c 25 | AC_CHECK_HEADERS([errno.h sys/time.h]) 26 | 27 | dnl Functions included in hibrtools/mount_file_system.c and hibrtools/mount_file_entry.c 28 | AS_IF( 29 | [test "x$ac_cv_enable_winapi" = xno], 30 | [AC_CHECK_FUNCS([clock_gettime getegid geteuid time]) 31 | ]) 32 | ]) 33 | 34 | dnl Function to check if DLL support is needed 35 | AC_DEFUN([AX_LIBHIBR_CHECK_DLL_SUPPORT], 36 | [AS_IF( 37 | [test "x$enable_shared" = xyes && test "x$ac_cv_enable_static_executables" = xno], 38 | [AS_CASE( 39 | [$host], 40 | [*cygwin* | *mingw* | *msys*], 41 | [AC_DEFINE( 42 | [HAVE_DLLMAIN], 43 | [1], 44 | [Define to 1 to enable the DllMain function.]) 45 | AC_SUBST( 46 | [HAVE_DLLMAIN], 47 | [1]) 48 | 49 | AC_SUBST( 50 | [LIBHIBR_DLL_EXPORT], 51 | ["-DLIBHIBR_DLL_EXPORT"]) 52 | 53 | AC_SUBST( 54 | [LIBHIBR_DLL_IMPORT], 55 | ["-DLIBHIBR_DLL_IMPORT"]) 56 | ]) 57 | ]) 58 | ]) 59 | 60 | -------------------------------------------------------------------------------- /autogen.ps1: -------------------------------------------------------------------------------- 1 | # Script to generate the necessary files for a msvscpp build 2 | # 3 | # Version: 20240306 4 | 5 | $WinFlex = "..\win_flex_bison\win_flex.exe" 6 | $WinBison = "..\win_flex_bison\win_bison.exe" 7 | 8 | $Library = Get-Content -Path configure.ac | select -skip 3 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 9 | $Version = Get-Content -Path configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 10 | $Prefix = ${Library}.Substring(3) 11 | 12 | Get-Content -Path "include\${Library}.h.in" | Out-File -Encoding ascii "include\${Library}.h" 13 | Get-Content -Path "include\${Library}\definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "include\${Library}\definitions.h" 14 | Get-Content -Path "include\${Library}\features.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\features.h" 15 | Get-Content -Path "include\${Library}\types.h.in" | % { $_ -Replace "@[A-Z0-9_]*@","0" } | Out-File -Encoding ascii "include\${Library}\types.h" 16 | Get-Content -Path "common\types.h.in" | % { $_ -Replace "@PACKAGE@","${Library}" } | Out-File -Encoding ascii "common\types.h" 17 | Get-Content -Path "${Library}\${Library}_definitions.h.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}_definitions.h" 18 | Get-Content -Path "${Library}\${Library}.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Library}\${Library}.rc" 19 | 20 | If (Test-Path "setup.cfg.in") 21 | { 22 | Get-Content -Path "setup.cfg.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "setup.cfg" 23 | } 24 | 25 | If (Test-Path "${Prefix}.net") 26 | { 27 | Get-Content -Path "${Prefix}.net\${Prefix}.net.rc.in" | % { $_ -Replace "@VERSION@","${Version}" } | Out-File -Encoding ascii "${Prefix}.net\${Prefix}.net.rc" 28 | } 29 | 30 | $NamePrefix = "" 31 | 32 | ForEach (${Library} in Get-ChildItem -Directory -Path "lib*") 33 | { 34 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.l") 35 | { 36 | $OutputFile = ${DirectoryElement} -Replace ".l$",".c" 37 | 38 | $NamePrefix = Split-Path -path ${DirectoryElement} -leaf 39 | $NamePrefix = ${NamePrefix} -Replace ".l$","_" 40 | 41 | Write-Host "Running: ${WinFlex} -Cf ${DirectoryElement}" 42 | 43 | # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr 44 | # therefore 2>&1 is added and the output is stored in a variable. 45 | $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" 46 | Write-Host ${Output} 47 | 48 | # Moving manually since `win_flex -o filename' does not provide the expected behavior. 49 | Move-Item "lex.yy.c" ${OutputFile} -force 50 | } 51 | 52 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${Library}\*.y") 53 | { 54 | $OutputFile = ${DirectoryElement} -Replace ".y$",".c" 55 | 56 | Write-Host "Running: ${WinBison} -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement}" 57 | 58 | # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr 59 | # therefore 2>&1 is added and the output is stored in a variable. 60 | $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" 61 | Write-Host ${Output} 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to generate ./configure using the autotools 3 | # 4 | # Version: 20230405 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | 9 | BINDIR="/usr/bin"; 10 | 11 | if ! test -x "${BINDIR}/aclocal"; 12 | then 13 | BINDIR="/usr/local/bin"; 14 | fi 15 | if ! test -x "${BINDIR}/aclocal"; 16 | then 17 | BINDIR="/usr/local/bin"; 18 | fi 19 | if ! test -x "${BINDIR}/aclocal"; 20 | then 21 | # Default location of MacPorts installed binaries. 22 | BINDIR="/opt/local/bin"; 23 | fi 24 | if ! test -x "${BINDIR}/aclocal"; 25 | then 26 | # Default location of 32-bit MSYS2-MinGW installed binaries. 27 | BINDIR="/mingw32/bin"; 28 | fi 29 | if ! test -x "${BINDIR}/aclocal"; 30 | then 31 | # Default location of 64-bit MSYS2-MinGW installed binaries. 32 | BINDIR="/mingw64/bin"; 33 | fi 34 | 35 | if ! test -x "${BINDIR}/aclocal"; 36 | then 37 | echo "Unable to find autotools"; 38 | 39 | exit ${EXIT_FAILURE}; 40 | fi 41 | 42 | ACLOCAL="${BINDIR}/aclocal"; 43 | AUTOCONF="${BINDIR}/autoconf"; 44 | AUTOHEADER="${BINDIR}/autoheader"; 45 | AUTOMAKE="${BINDIR}/automake"; 46 | AUTOPOINT="${BINDIR}/autopoint"; 47 | AUTORECONF="${BINDIR}/autoreconf"; 48 | LIBTOOLIZE="${BINDIR}/libtoolize"; 49 | PKGCONFIG="${BINDIR}/pkg-config"; 50 | 51 | if test "${OSTYPE}" = "msys"; 52 | then 53 | # Work-around for autopoint failing to detect gettext version 54 | # using func_trace (which is not available) on MSYS by writing 55 | # the gettext version to intl/VERSION. 56 | if ! test -d intl; 57 | then 58 | mkdir intl; 59 | fi 60 | GETTEXT_VERSION=`gettext --version | head -n1 | sed 's/^.* //'`; 61 | 62 | echo "gettext-${GETTEXT_VERSION}" > intl/VERSION; 63 | 64 | elif ! test -x "${PKGCONFIG}"; 65 | then 66 | if test "${BINDIR}" != "/usr/bin"; 67 | then 68 | # On OpenBSD most of the autotools are located in 69 | # /usr/local/bin while pkg-config is located in /usr/bin 70 | PKGCONFIG="/usr/bin/pkg-config"; 71 | fi 72 | if ! test -x "${PKGCONFIG}"; 73 | then 74 | echo "Unable to find: pkg-config"; 75 | 76 | exit ${EXIT_FAILURE}; 77 | fi 78 | fi 79 | 80 | if test -x "${AUTORECONF}"; 81 | then 82 | ${AUTORECONF} --force --install 83 | if test $? -ne 0; 84 | then 85 | exit $?; 86 | fi 87 | else 88 | if ! test -x "${ACLOCAL}"; 89 | then 90 | echo "Unable to find: aclocal"; 91 | 92 | exit ${EXIT_FAILURE}; 93 | fi 94 | 95 | if ! test -x "${AUTOCONF}"; 96 | then 97 | echo "Unable to find: autoconf"; 98 | 99 | exit ${EXIT_FAILURE}; 100 | fi 101 | 102 | if ! test -x "${AUTOHEADER}"; 103 | then 104 | echo "Unable to find: autoheader"; 105 | 106 | exit ${EXIT_FAILURE}; 107 | fi 108 | 109 | if ! test -x "${AUTOMAKE}"; 110 | then 111 | echo "Unable to find: automake"; 112 | 113 | exit ${EXIT_FAILURE}; 114 | fi 115 | 116 | if ! test -x "${AUTOPOINT}"; 117 | then 118 | echo "Unable to find: autopoint"; 119 | 120 | exit ${EXIT_FAILURE}; 121 | fi 122 | 123 | if ! test -x "${LIBTOOLIZE}"; 124 | then 125 | echo "Unable to find: libtoolize"; 126 | 127 | exit ${EXIT_FAILURE}; 128 | fi 129 | 130 | ${AUTOPOINT} --force; 131 | if test $? -ne 0; 132 | then 133 | exit $?; 134 | fi 135 | 136 | ${ACLOCAL} --force --install -I m4; 137 | if test $? -ne 0; 138 | then 139 | exit $?; 140 | fi 141 | 142 | ${LIBTOOLIZE} --force; 143 | if test $? -ne 0; 144 | then 145 | exit $?; 146 | fi 147 | 148 | ${AUTOHEADER} --force; 149 | if test $? -ne 0; 150 | then 151 | exit $?; 152 | fi 153 | 154 | ${AUTOCONF} --force; 155 | if test $? -ne 0; 156 | then 157 | exit $?; 158 | fi 159 | 160 | ${AUTOMAKE} --force --add-missing; 161 | if test $? -ne 0; 162 | then 163 | exit $?; 164 | fi 165 | 166 | fi 167 | 168 | exit ${EXIT_SUCCESS}; 169 | 170 | -------------------------------------------------------------------------------- /builddokan.ps1: -------------------------------------------------------------------------------- 1 | # Script that builds dokan 2 | # 3 | # Version: 20180322 4 | 5 | Param ( 6 | [string]$Configuration = ${Env:Configuration}, 7 | [string]$Platform = ${Env:Platform}, 8 | [switch]$UseLegacyVersion = $false 9 | ) 10 | 11 | If (-not ${Configuration}) 12 | { 13 | $Configuration = "Release" 14 | } 15 | If (-not ${Platform}) 16 | { 17 | $Platform = "Win32" 18 | } 19 | 20 | If (${Env:AppVeyor} -eq "True") 21 | { 22 | $MSBuild = "MSBuild.exe" 23 | } 24 | ElseIf (${Env:VisualStudioVersion} -eq "15.0") 25 | { 26 | $MSBuild = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe" 27 | } 28 | ElseIf (${Env:VisualStudioVersion} -eq "9.0") 29 | { 30 | $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe" 31 | } 32 | Else 33 | { 34 | $MSBuild = "C:\\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 35 | } 36 | $MSBuildOptions = "/verbosity:quiet /target:Build /property:Configuration=${Configuration},Platform=${Platform}" 37 | 38 | If ($UseLegacyVersion) 39 | { 40 | $DokanPath = "../dokan" 41 | $ProjectFile = "msvscpp\dokan.sln" 42 | } 43 | Else 44 | { 45 | $DokanPath = "../dokany" 46 | $ProjectFile = "dokan\dokan.vcxproj" 47 | } 48 | 49 | Push-Location ${DokanPath} 50 | 51 | Try 52 | { 53 | Write-Host "${MSBuild} ${MSBuildOptions} ${ProjectFile}" 54 | 55 | Invoke-Expression -Command "& '${MSBuild}' ${MSBuildOptions} ${ProjectFile}" 56 | } 57 | Finally 58 | { 59 | Pop-Location 60 | } 61 | 62 | -------------------------------------------------------------------------------- /common/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include 3 | 4 | EXTRA_DIST = \ 5 | byte_stream.h \ 6 | common.h \ 7 | config.h \ 8 | config_borlandc.h \ 9 | config_msc.h \ 10 | config_winapi.h \ 11 | file_stream.h \ 12 | memory.h \ 13 | narrow_string.h \ 14 | system_string.h \ 15 | types.h \ 16 | types.h.in \ 17 | wide_string.h 18 | 19 | DISTCLEANFILES = \ 20 | config.h \ 21 | types.h \ 22 | Makefile \ 23 | Makefile.in 24 | 25 | -------------------------------------------------------------------------------- /common/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Common include file 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _COMMON_H ) 23 | #define _COMMON_H 24 | 25 | #if defined( HAVE_CONFIG_H ) 26 | #include "config.h" 27 | #endif 28 | 29 | /* Include the Borland/CodeGear C++ Builder compiler specific configuration 30 | */ 31 | #if defined( __BORLANDC__ ) 32 | #include "config_borlandc.h" 33 | 34 | /* Include the Microsoft Visual Studio C++ compiler specific configuration 35 | */ 36 | #elif defined( _MSC_VER ) 37 | #include "config_msc.h" 38 | #endif 39 | 40 | #include "config_winapi.h" 41 | 42 | #endif /* !defined( _COMMON_H ) */ 43 | 44 | -------------------------------------------------------------------------------- /common/config_borlandc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration for the Borland/CodeGear C++ Builder compiler 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_BORLANDC_H ) 23 | #define _CONFIG_BORLANDC_H 24 | 25 | #endif /* !defined( _CONFIG_BORLANDC_H ) */ 26 | 27 | -------------------------------------------------------------------------------- /common/config_msc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration for the Microsoft Visual Studio C++ compiler 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_MSC_H ) 23 | #define _CONFIG_MSC_H 24 | 25 | /* Disable warning C4127: conditional expression is constant 26 | */ 27 | #pragma warning( disable : 4127 ) 28 | 29 | /* Disable warning C4201: nonstandard extension used : nameless struct/union 30 | */ 31 | #pragma warning( disable : 4201 ) 32 | 33 | #endif /* !defined( _CONFIG_MSC_H ) */ 34 | 35 | -------------------------------------------------------------------------------- /common/config_winapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Configuration file for WINAPI 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _CONFIG_WINAPI_H ) 23 | #define _CONFIG_WINAPI_H 24 | 25 | /* Define the earliest supported WINAPI version 26 | #define WINVER 0x0501 27 | */ 28 | 29 | /* If necessary make sure WINAPI is defined 30 | */ 31 | #if defined( HAVE_WINDOWS_H ) || defined( __BORLANDC__ ) || defined( _MSC_VER ) 32 | #include 33 | #endif 34 | 35 | #if defined( WINAPI ) 36 | 37 | /* Define to the address where bug reports for this package should be sent. 38 | */ 39 | #define PACKAGE_BUGREPORT "joachim.metz@gmail.com" 40 | 41 | /* Define the size of the integer for WINAPI 42 | */ 43 | #if !defined( SIZEOF_INT ) 44 | #define SIZEOF_INT 4 45 | #endif 46 | 47 | /* Define the size of size_t for WINAPI 48 | * Do not define when pyconfig.h has been included via python.h 49 | */ 50 | #if !defined( HAVE_PYCONFIG_H ) 51 | 52 | #if !defined( SIZEOF_SIZE_T ) 53 | #if __WORDSIZE == 64 54 | #define SIZEOF_SIZE_T 8 55 | #else 56 | #define SIZEOF_SIZE_T 4 57 | #endif 58 | #endif 59 | 60 | #endif /* !defined( HAVE_PYCONFIG_H ) */ 61 | 62 | /* Define the size of the wide character for WINAPI 63 | */ 64 | #if !defined( SIZEOF_WCHAR_T ) 65 | #define SIZEOF_WCHAR_T 2 66 | #endif 67 | 68 | /* Enable the DllMain function 69 | */ 70 | #define HAVE_DLLMAIN 1 71 | 72 | /* Enable verbose output 73 | #define HAVE_VERBOSE_OUTPUT 1 74 | */ 75 | 76 | /* Enable debug output 77 | #define HAVE_DEBUG_OUTPUT 1 78 | */ 79 | 80 | /* Enable both the narrow and wide character functions 81 | */ 82 | #if !defined( HAVE_WIDE_CHARACTER_TYPE ) 83 | #define HAVE_WIDE_CHARACTER_TYPE 1 84 | #endif 85 | 86 | /* If not controlled by config.h enable multi-thread support 87 | */ 88 | #if !defined( HAVE_CONFIG_H ) && !defined( HAVE_MULTI_THREAD_SUPPORT ) 89 | #define HAVE_MULTI_THREAD_SUPPORT 1 90 | #endif 91 | 92 | #endif /* defined( WINAPI ) */ 93 | 94 | #endif /* !defined( _CONFIG_WINAPI_H ) */ 95 | 96 | -------------------------------------------------------------------------------- /common/file_stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FILE stream functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _FILE_STREAM_H ) 23 | #define _FILE_STREAM_H 24 | 25 | #include "common.h" 26 | 27 | #if defined( HAVE_GLIB_H ) 28 | #include 29 | #include 30 | #endif 31 | 32 | #include 33 | 34 | #if defined( __cplusplus ) 35 | extern "C" { 36 | #endif 37 | 38 | #define FILE_STREAM_OPEN_APPEND "a" 39 | #define FILE_STREAM_OPEN_READ "r" 40 | #define FILE_STREAM_OPEN_WRITE "w" 41 | 42 | #if defined( WINAPI ) 43 | #define FILE_STREAM_BINARY_OPEN_APPEND "ab" 44 | #define FILE_STREAM_BINARY_OPEN_READ "rb" 45 | #define FILE_STREAM_BINARY_OPEN_WRITE "wb" 46 | 47 | #else 48 | #define FILE_STREAM_BINARY_OPEN_APPEND "a" 49 | #define FILE_STREAM_BINARY_OPEN_READ "r" 50 | #define FILE_STREAM_BINARY_OPEN_WRITE "w" 51 | 52 | #endif 53 | 54 | /* narrow character FILE stream open 55 | */ 56 | #if defined( HAVE_GLIB_H ) 57 | #define file_stream_open( filename, mode ) \ 58 | g_fopen( filename, mode ) 59 | 60 | #elif defined( HAVE_FOPEN ) || defined( WINAPI ) 61 | #define file_stream_open( filename, mode ) \ 62 | fopen( filename, mode ) 63 | #endif 64 | 65 | /* wide character FILE stream open 66 | */ 67 | #if defined( WINAPI ) 68 | #define file_stream_open_wide( filename, mode ) \ 69 | _wfopen( filename, mode ) 70 | #endif 71 | 72 | /* FILE stream close 73 | */ 74 | #if defined( HAVE_FCLOSE ) || defined( WINAPI ) 75 | #define file_stream_close( stream ) \ 76 | fclose( stream ) 77 | #endif 78 | 79 | /* FILE stream read 80 | */ 81 | #if defined( HAVE_FREAD ) || defined( WINAPI ) 82 | #define file_stream_read( stream, data, size ) \ 83 | fread( data, 1, size, stream ) 84 | #endif 85 | 86 | /* FILE stream write 87 | */ 88 | #if defined( HAVE_FWRITE ) || defined( WINAPI ) 89 | #define file_stream_write( stream, data, size ) \ 90 | fwrite( data, 1, size, stream ) 91 | #endif 92 | 93 | /* FILE stream seek 94 | */ 95 | #if defined( WINAPI ) 96 | #define file_stream_seek_offset( stream, offset, whence ) \ 97 | fseek( stream, offset, whence ) 98 | 99 | #elif defined( HAVE_FSEEKO ) 100 | #define file_stream_seek_offset( stream, offset, whence ) \ 101 | fseeko( stream, offset, whence ) 102 | 103 | #elif defined( HAVE_FSEEKO64 ) 104 | #define file_stream_seek_offset( stream, offset, whence ) \ 105 | fseeko64( stream, offset, whence ) 106 | #endif 107 | 108 | /* End of FILE stream 109 | */ 110 | #if defined( HAVE_FEOF ) || defined( WINAPI ) 111 | #define file_stream_at_end( stream ) \ 112 | feof( stream ) 113 | #endif 114 | 115 | /* Get narrow character string from FILE stream 116 | */ 117 | #if defined( HAVE_FGETS ) || defined( WINAPI ) 118 | #define file_stream_get_string( stream, string, size ) \ 119 | fgets( string, size, stream ) 120 | #endif 121 | 122 | /* Get wide characters string from FILE stream 123 | */ 124 | #if defined( HAVE_FGETWS ) || defined( WINAPI ) 125 | #define file_stream_get_string_wide( stream, string, size ) \ 126 | fgetws( string, size, stream ) 127 | #endif 128 | 129 | /* Variable arguments formatted print to stream function 130 | */ 131 | #if defined( HAVE_GLIB_H ) 132 | #define file_stream_vfprintf( stream, format, ... ) \ 133 | g_vfprintf( stream, format, __VA_ARGS__ ) 134 | 135 | /* Borland BCC previous to version 5.6.0 cannot handle the macro form: MACRO( ... ) 136 | */ 137 | #elif defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x0560 ) 138 | #define file_stream_vfprintf \ 139 | vfprintf 140 | 141 | #elif defined( HAVE_VFPRINTF ) || defined( WINAPI ) 142 | #define file_stream_vfprintf( stream, format, ... ) \ 143 | vfprintf( stream, format, __VA_ARGS__ ) 144 | #endif 145 | 146 | #if defined( __cplusplus ) 147 | } 148 | #endif 149 | 150 | #endif /* !defined( _FILE_STREAM_H ) */ 151 | 152 | -------------------------------------------------------------------------------- /common/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MEMORY_H ) 23 | #define _MEMORY_H 24 | 25 | #include "common.h" 26 | 27 | #if defined( HAVE_GLIB_H ) 28 | #include 29 | #endif 30 | 31 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 32 | #include 33 | #endif 34 | 35 | #if defined( HAVE_STRING_H ) || defined( WINAPI ) 36 | #include 37 | #endif 38 | 39 | #if defined( __cplusplus ) 40 | extern "C" { 41 | #endif 42 | 43 | /* Note that 128 MiB is an arbitrary selected upper limit here 44 | */ 45 | #define MEMORY_MAXIMUM_ALLOCATION_SIZE \ 46 | ( 128 * 1024 * 1024 ) 47 | 48 | /* Memory allocation 49 | */ 50 | #if defined( HAVE_GLIB_H ) 51 | #define memory_allocate( size ) \ 52 | g_malloc( (gsize) size ) 53 | 54 | #elif defined( WINAPI ) 55 | #define memory_allocate( size ) \ 56 | HeapAlloc( GetProcessHeap(), 0, (SIZE_T) size ) 57 | 58 | #elif defined( HAVE_MALLOC ) 59 | #define memory_allocate( size ) \ 60 | malloc( size ) 61 | #endif 62 | 63 | #define memory_allocate_structure( type ) \ 64 | (type *) memory_allocate( sizeof( type ) ) 65 | 66 | #define memory_allocate_structure_as_value( type ) \ 67 | (intptr_t *) memory_allocate( sizeof( type ) ) 68 | 69 | /* Memory reallocation 70 | */ 71 | #if defined( HAVE_GLIB_H ) 72 | #define memory_reallocate( buffer, size ) \ 73 | g_realloc( (gpointer) buffer, (gsize) size ) 74 | 75 | #elif defined( WINAPI ) 76 | /* HeapReAlloc does not allocate empty (NULL) buffers as realloc does 77 | */ 78 | #define memory_reallocate( buffer, size ) \ 79 | ( buffer == NULL ) ? \ 80 | HeapAlloc( GetProcessHeap(), 0, (SIZE_T) size ) : \ 81 | HeapReAlloc( GetProcessHeap(), 0, (LPVOID) buffer, (SIZE_T) size ) 82 | 83 | #elif defined( HAVE_REALLOC ) 84 | #define memory_reallocate( buffer, size ) \ 85 | realloc( (void *) buffer, size ) 86 | #endif 87 | 88 | /* Memory free 89 | */ 90 | #if defined( HAVE_GLIB_H ) 91 | #define memory_free( buffer ) \ 92 | g_free( (gpointer) buffer ) 93 | 94 | #elif defined( WINAPI ) 95 | #define memory_free( buffer ) \ 96 | ( buffer == NULL ) ? TRUE : HeapFree( GetProcessHeap(), 0, (LPVOID) buffer ) 97 | 98 | #elif defined( HAVE_FREE ) 99 | #define memory_free( buffer ) \ 100 | free( (void *) buffer ) 101 | #endif 102 | 103 | /* Memory compare 104 | */ 105 | #if defined( HAVE_MEMCMP ) || defined( WINAPI ) 106 | #define memory_compare( buffer1, buffer2, size ) \ 107 | memcmp( (const void *) buffer1, (const void *) buffer2, size ) 108 | #endif 109 | 110 | /* Memory copy 111 | */ 112 | #if defined( HAVE_MEMCPY ) || defined( WINAPI ) 113 | #define memory_copy( destination, source, count ) \ 114 | memcpy( (void *) destination, (void *) source, count ) 115 | #endif 116 | 117 | /* Memory set 118 | */ 119 | #if defined( HAVE_MEMSET ) || defined( WINAPI ) 120 | #define memory_set( buffer, value, count ) \ 121 | memset( (void *) buffer, (int) value, count ) 122 | #endif 123 | 124 | #if defined( __cplusplus ) 125 | } 126 | #endif 127 | 128 | #endif /* !defined( _MEMORY_H ) */ 129 | 130 | -------------------------------------------------------------------------------- /dpkg/changelog.in: -------------------------------------------------------------------------------- 1 | libhibr (@VERSION@-1) unstable; urgency=low 2 | 3 | * Auto-generated 4 | 5 | -- Joachim Metz @DPKG_DATE@ 6 | -------------------------------------------------------------------------------- /dpkg/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /dpkg/control: -------------------------------------------------------------------------------- 1 | Source: libhibr 2 | Priority: extra 3 | Maintainer: Joachim Metz 4 | Build-Depends: debhelper (>= 9), dh-autoreconf, pkg-config, libfuse-dev 5 | Standards-Version: 4.1.4 6 | Section: libs 7 | Homepage: https://github.com/libyal/libhibr 8 | Vcs-Git: https://github.com/libyal/libhibr.git 9 | 10 | Package: libhibr 11 | Architecture: any 12 | Depends: ${shlibs:Depends}, ${misc:Depends} 13 | Conflicts: libhibr1 14 | Replaces: libhibr1 15 | Suggests: libhibr-dbg 16 | Description: Library to access the Windows Hibernation File (hiberfil.sys) format 17 | libhibr is a library to access the Windows Hibernation File (hiberfil.sys) format. 18 | 19 | Package: libhibr-dbg 20 | Architecture: any 21 | Section: debug 22 | Depends: libhibr (= ${binary:Version}), ${misc:Depends} 23 | Description: Debugging symbols for libhibr 24 | Debugging symbols for libhibr. 25 | 26 | Package: libhibr-dev 27 | Section: libdevel 28 | Architecture: any 29 | Depends: libhibr (= ${binary:Version}), ${misc:Depends} 30 | Description: Header files and libraries for developing applications for libhibr 31 | Header files and libraries for developing applications for libhibr. 32 | 33 | Package: libhibr-tools 34 | Section: utils 35 | Architecture: any 36 | Depends: libhibr (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} 37 | Conflicts: libhibr-utils 38 | Replaces: libhibr-utils 39 | Description: Several tools for reading Windows Hibernation Files (hiberfil.sys) 40 | Several tools for reading Windows Hibernation Files (hiberfil.sys). 41 | 42 | Package: libhibr-tools-dbg 43 | Section: debug 44 | Architecture: any 45 | Depends: libhibr-tools (= ${binary:Version}), ${misc:Depends} 46 | Description: Debugging symbols for libhibr-tools 47 | Debugging symbols for libhibr-tools. 48 | 49 | -------------------------------------------------------------------------------- /dpkg/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: libhibr 3 | Source: https://github.com/libyal/libhibr 4 | 5 | Files: * 6 | Copyright: 2012-2024, Joachim Metz 7 | License: LGPL-3.0+ 8 | 9 | License: LGPL-3.0+ 10 | This package is free software; you can redistribute it and/or 11 | modify it under the terms of the GNU Lesser General Public 12 | License as published by the Free Software Foundation; either 13 | version 3 of the License, or (at your option) any later version. 14 | . 15 | This package is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | Lesser General Public License for more details. 19 | . 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | . 23 | On Debian systems, the complete text of the GNU Lesser General 24 | Public License can be found in "/usr/share/common-licenses/LGPL-3". 25 | 26 | -------------------------------------------------------------------------------- /dpkg/libhibr-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/* 2 | usr/lib/*-*/lib*.a 3 | usr/lib/*-*/lib*.so 4 | usr/lib/*-*/pkgconfig/* 5 | usr/share/man/man3 6 | -------------------------------------------------------------------------------- /dpkg/libhibr-tools.install: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/share/man/man1 3 | -------------------------------------------------------------------------------- /dpkg/libhibr.install: -------------------------------------------------------------------------------- 1 | usr/lib/*-*/lib*.so.* 2 | -------------------------------------------------------------------------------- /dpkg/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment for debhelper verbose output. 5 | # export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ --buildsystem=autoconf --with=autoreconf 9 | 10 | .PHONY: override_dh_auto_configure 11 | override_dh_auto_configure: 12 | dh_auto_configure -- CFLAGS="-g" 13 | 14 | .PHONY: override_dh_install 15 | override_dh_install: 16 | dh_install --fail-missing -X.la 17 | 18 | .PHONY: override_dh_strip 19 | override_dh_strip: 20 | ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS))) 21 | dh_strip -plibhibr --dbg-package=libhibr-dbg 22 | dh_strip -plibhibr-tools --dbg-package=libhibr-tools-dbg 23 | endif 24 | 25 | -------------------------------------------------------------------------------- /dpkg/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /hibrtools/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include \ 3 | -I../common -I$(top_srcdir)/common \ 4 | @LIBCERROR_CPPFLAGS@ \ 5 | @LIBCDATA_CPPFLAGS@ \ 6 | @LIBCLOCALE_CPPFLAGS@ \ 7 | @LIBCNOTIFY_CPPFLAGS@ \ 8 | @LIBCSPLIT_CPPFLAGS@ \ 9 | @LIBUNA_CPPFLAGS@ \ 10 | @LIBCFILE_CPPFLAGS@ \ 11 | @LIBCPATH_CPPFLAGS@ \ 12 | @LIBBFIO_CPPFLAGS@ \ 13 | @LIBFCACHE_CPPFLAGS@ \ 14 | @LIBFDATA_CPPFLAGS@ \ 15 | @LIBFWNT_CPPFLAGS@ \ 16 | @LIBFUSE_CPPFLAGS@ \ 17 | @LIBHIBR_DLL_IMPORT@ 18 | 19 | AM_LDFLAGS = @STATIC_LDFLAGS@ 20 | 21 | bin_PROGRAMS = \ 22 | hibrinfo \ 23 | hibrmount 24 | 25 | hibrinfo_SOURCES = \ 26 | hibrinfo.c \ 27 | hibrtools_getopt.c hibrtools_getopt.h \ 28 | hibrtools_i18n.h \ 29 | hibrtools_libbfio.h \ 30 | hibrtools_libcerror.h \ 31 | hibrtools_libclocale.h \ 32 | hibrtools_libcnotify.h \ 33 | hibrtools_libhibr.h \ 34 | hibrtools_libuna.h \ 35 | hibrtools_output.c hibrtools_output.h \ 36 | hibrtools_signal.c hibrtools_signal.h \ 37 | hibrtools_unused.h \ 38 | info_handle.c info_handle.h 39 | 40 | hibrinfo_LDADD = \ 41 | @LIBCNOTIFY_LIBADD@ \ 42 | @LIBCLOCALE_LIBADD@ \ 43 | ../libhibr/libhibr.la \ 44 | @LIBCERROR_LIBADD@ \ 45 | @LIBINTL@ 46 | 47 | hibrmount_SOURCES = \ 48 | hibrmount.c \ 49 | hibrtools_getopt.c hibrtools_getopt.h \ 50 | hibrtools_i18n.h \ 51 | hibrtools_libcdata.h \ 52 | hibrtools_libcerror.h \ 53 | hibrtools_libclocale.h \ 54 | hibrtools_libcnotify.h \ 55 | hibrtools_libcpath.h \ 56 | hibrtools_libhibr.h \ 57 | hibrtools_output.c hibrtools_output.h \ 58 | hibrtools_signal.c hibrtools_signal.h \ 59 | hibrtools_unused.h \ 60 | mount_dokan.c mount_dokan.h \ 61 | mount_file_entry.c mount_file_entry.h \ 62 | mount_file_system.c mount_file_system.h \ 63 | mount_fuse.c mount_fuse.h \ 64 | mount_handle.c mount_handle.h 65 | 66 | hibrmount_LDADD = \ 67 | @LIBFUSE_LIBADD@ \ 68 | @LIBUNA_LIBADD@ \ 69 | @LIBCNOTIFY_LIBADD@ \ 70 | @LIBCLOCALE_LIBADD@ \ 71 | @LIBCDATA_LIBADD@ \ 72 | ../libhibr/libhibr.la \ 73 | @LIBCERROR_LIBADD@ \ 74 | @LIBINTL@ 75 | 76 | DISTCLEANFILES = \ 77 | Makefile \ 78 | Makefile.in 79 | 80 | splint-local: 81 | @echo "Running splint on hibrinfo ..." 82 | -splint -preproc -redef $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(hibrinfo_SOURCES) 83 | @echo "Running splint on hibrmount ..." 84 | -splint -preproc -redef $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(hibrmount_SOURCES) 85 | 86 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GetOpt functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_GETOPT_H ) 23 | #define _HIBRTOOLS_GETOPT_H 24 | 25 | #include 26 | #include 27 | 28 | /* unistd.h is included here to export getopt, optarg, optind and optopt 29 | */ 30 | #if defined( HAVE_UNISTD_H ) 31 | #include 32 | #endif 33 | 34 | #if defined( __cplusplus ) 35 | extern "C" { 36 | #endif 37 | 38 | #if defined( HAVE_GETOPT ) 39 | #define hibrtools_getopt( argument_count, argument_values, options_string ) \ 40 | getopt( argument_count, argument_values, options_string ) 41 | 42 | #else 43 | 44 | #if !defined( __CYGWIN__ ) 45 | extern int optind; 46 | extern system_character_t *optarg; 47 | extern system_integer_t optopt; 48 | 49 | #else 50 | int optind; 51 | system_character_t *optarg; 52 | system_integer_t optopt; 53 | 54 | #endif /* !defined( __CYGWIN__ ) */ 55 | 56 | system_integer_t hibrtools_getopt( 57 | int argument_count, 58 | system_character_t * const argument_values[], 59 | const system_character_t *options_string ); 60 | 61 | #endif /* defined( HAVE_GETOPT ) */ 62 | 63 | #if defined( __cplusplus ) 64 | } 65 | #endif 66 | 67 | #endif /* !defined( _HIBRTOOLS_GETOPT_H ) */ 68 | 69 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_i18n.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internationalization (i18n) functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_I18N_H ) 23 | #define _HIBRTOOLS_I18N_H 24 | 25 | #include 26 | 27 | #if defined( HAVE_LIBINTL_H ) 28 | #include 29 | #endif 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | /* TODO for now do nothing i18n-like 36 | #define _( string ) \ 37 | gettext( string ) 38 | */ 39 | 40 | #define _( string ) \ 41 | string 42 | 43 | #if defined( __cplusplus ) 44 | } 45 | #endif 46 | 47 | #endif /* !defined( _HIBRTOOLS_I18N_H ) */ 48 | 49 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libbfio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libbfio header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBBFIO_H ) 23 | #define _HIBRTOOLS_LIBBFIO_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBBFIO for local use of libbfio 28 | */ 29 | #if defined( HAVE_LOCAL_LIBBFIO ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBBFIO_DLL_IMPORT 43 | * before including libbfio.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 46 | #define LIBBFIO_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( LIBBFIO_HAVE_MULTI_THREAD_SUPPORT ) 52 | #error Multi-threading support requires libbfio with multi-threading support 53 | #endif 54 | 55 | #endif /* defined( HAVE_LOCAL_LIBBFIO ) */ 56 | 57 | #endif /* !defined( _HIBRTOOLS_LIBBFIO_H ) */ 58 | 59 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libcdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcdata header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBCDATA_H ) 23 | #define _HIBRTOOLS_LIBCDATA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCDATA for local use of libcdata 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCDATA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBCDATA_DLL_IMPORT 43 | * before including libcdata.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 46 | #define LIBCDATA_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #endif /* defined( HAVE_LOCAL_LIBCDATA ) */ 52 | 53 | #endif /* !defined( _HIBRTOOLS_LIBCDATA_H ) */ 54 | 55 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libcerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcerror header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBCERROR_H ) 23 | #define _HIBRTOOLS_LIBCERROR_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCERROR for local use of libcerror 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCERROR ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCERROR_DLL_IMPORT 39 | * before including libcerror.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 42 | #define LIBCERROR_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCERROR ) */ 48 | 49 | #endif /* !defined( _HIBRTOOLS_LIBCERROR_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libclocale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libclocale header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBCLOCALE_H ) 23 | #define _HIBRTOOLS_LIBCLOCALE_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCLOCALE for local use of libclocale 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCLOCALE ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCLOCALE_DLL_IMPORT 39 | * before including libclocale.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 42 | #define LIBCLOCALE_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCLOCALE ) */ 48 | 49 | #endif /* !defined( _HIBRTOOLS_LIBCLOCALE_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libcnotify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcnotify header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBCNOTIFY_H ) 23 | #define _HIBRTOOLS_LIBCNOTIFY_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCNOTIFY for local use of libcnotify 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCNOTIFY ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCNOTIFY_DLL_IMPORT 39 | * before including libcnotify.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 42 | #define LIBCNOTIFY_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCNOTIFY ) */ 48 | 49 | #endif /* !defined( _HIBRTOOLS_LIBCNOTIFY_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libcpath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcpath header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBCPATH_H ) 23 | #define _HIBRTOOLS_LIBCPATH_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCPATH for local use of libcpath 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCPATH ) 30 | 31 | #include 32 | #include 33 | 34 | #else 35 | 36 | /* If libtool DLL support is enabled set LIBCPATH_DLL_IMPORT 37 | * before including libcpath.h 38 | */ 39 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 40 | #define LIBCPATH_DLL_IMPORT 41 | #endif 42 | 43 | #include 44 | 45 | #endif /* defined( HAVE_LOCAL_LIBCPATH ) */ 46 | 47 | #endif /* !defined( _HIBRTOOLS_LIBCPATH_H ) */ 48 | 49 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libhibr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libhibr header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBHIBR_H ) 23 | #define _HIBRTOOLS_LIBHIBR_H 24 | 25 | #include 26 | 27 | #include 28 | 29 | #endif /* !defined( _HIBRTOOLS_LIBHIBR_H ) */ 30 | 31 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_libuna.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libuna header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_LIBUNA_H ) 23 | #define _HIBRTOOLS_LIBUNA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBUNA for local use of libuna 28 | */ 29 | #if defined( HAVE_LOCAL_LIBUNA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #else 47 | 48 | /* If libtool DLL support is enabled set LIBUNA_DLL_IMPORT 49 | * before including libuna.h 50 | */ 51 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 52 | #define LIBUNA_DLL_IMPORT 53 | #endif 54 | 55 | #include 56 | 57 | #endif /* defined( HAVE_LOCAL_LIBUNA ) */ 58 | 59 | #endif /* !defined( _HIBRTOOLS_LIBUNA_H ) */ 60 | 61 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Common output functions for the hibrtools 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_OUTPUT_H ) 23 | #define _HIBRTOOLS_OUTPUT_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "hibrtools_libcerror.h" 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | int hibrtools_output_initialize( 36 | int stdio_mode, 37 | libcerror_error_t **error ); 38 | 39 | void hibrtools_output_copyright_fprint( 40 | FILE *stream ); 41 | 42 | void hibrtools_output_version_fprint( 43 | FILE *stream, 44 | const char *program ); 45 | 46 | void hibrtools_output_version_detailed_fprint( 47 | FILE *stream, 48 | const char *program ); 49 | 50 | #if defined( __cplusplus ) 51 | } 52 | #endif 53 | 54 | #endif /* !defined( _HIBRTOOLS_OUTPUT_H ) */ 55 | 56 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_signal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Signal handling functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_SIGNAL_H ) 23 | #define _HIBRTOOLS_SIGNAL_H 24 | 25 | #include 26 | #include 27 | 28 | #include "hibrtools_libcerror.h" 29 | 30 | #if defined( __cplusplus ) 31 | extern "C" { 32 | #endif 33 | 34 | #if !defined( HAVE_SIGNAL_H ) && !defined( WINAPI ) 35 | #error missing signal functions 36 | #endif 37 | 38 | #if defined( WINAPI ) 39 | typedef unsigned long hibrtools_signal_t; 40 | 41 | #else 42 | typedef int hibrtools_signal_t; 43 | 44 | #endif /* defined( WINAPI ) */ 45 | 46 | #if defined( WINAPI ) 47 | 48 | BOOL WINAPI hibrtools_signal_handler( 49 | hibrtools_signal_t signal ); 50 | 51 | #if defined( _MSC_VER ) 52 | 53 | void hibrtools_signal_initialize_memory_debug( 54 | void ); 55 | 56 | #endif /* defined( _MSC_VER ) */ 57 | 58 | #endif /* defined( WINAPI ) */ 59 | 60 | int hibrtools_signal_attach( 61 | void (*signal_handler)( hibrtools_signal_t ), 62 | libcerror_error_t **error ); 63 | 64 | int hibrtools_signal_detach( 65 | libcerror_error_t **error ); 66 | 67 | #if defined( __cplusplus ) 68 | } 69 | #endif 70 | 71 | #endif /* !defined( _HIBRTOOLS_SIGNAL_H ) */ 72 | 73 | -------------------------------------------------------------------------------- /hibrtools/hibrtools_unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to silence compiler warnings about unused function attributes/parameters. 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBRTOOLS_UNUSED_H ) 23 | #define _HIBRTOOLS_UNUSED_H 24 | 25 | #include 26 | 27 | #if !defined( HIBRTOOLS_ATTRIBUTE_UNUSED ) 28 | 29 | #if defined( __GNUC__ ) && __GNUC__ >= 3 30 | #define HIBRTOOLS_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 31 | 32 | #else 33 | #define HIBRTOOLS_ATTRIBUTE_UNUSED 34 | 35 | #endif /* defined( __GNUC__ ) && __GNUC__ >= 3 */ 36 | 37 | #endif /* !defined( HIBRTOOLS_ATTRIBUTE_UNUSED ) */ 38 | 39 | #if defined( _MSC_VER ) 40 | #define HIBRTOOLS_UNREFERENCED_PARAMETER( parameter ) \ 41 | UNREFERENCED_PARAMETER( parameter ); 42 | 43 | #else 44 | #define HIBRTOOLS_UNREFERENCED_PARAMETER( parameter ) \ 45 | /* parameter */ 46 | 47 | #endif /* defined( _MSC_VER ) */ 48 | 49 | #endif /* !defined( _HIBRTOOLS_UNUSED_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /hibrtools/info_handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Info handle 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _INFO_HANDLE_H ) 23 | #define _INFO_HANDLE_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "hibrtools_libcerror.h" 30 | #include "hibrtools_libcnotify.h" 31 | #include "hibrtools_libhibr.h" 32 | 33 | #if defined( __cplusplus ) 34 | extern "C" { 35 | #endif 36 | 37 | typedef struct info_handle info_handle_t; 38 | 39 | struct info_handle 40 | { 41 | /* The libhibr input file 42 | */ 43 | libhibr_file_t *input_file; 44 | 45 | /* The notification output stream 46 | */ 47 | FILE *notify_stream; 48 | }; 49 | 50 | int info_handle_initialize( 51 | info_handle_t **info_handle, 52 | libcerror_error_t **error ); 53 | 54 | int info_handle_free( 55 | info_handle_t **info_handle, 56 | libcerror_error_t **error ); 57 | 58 | int info_handle_signal_abort( 59 | info_handle_t *info_handle, 60 | libcerror_error_t **error ); 61 | 62 | int info_handle_open_input( 63 | info_handle_t *info_handle, 64 | const system_character_t *filename, 65 | libcerror_error_t **error ); 66 | 67 | int info_handle_close( 68 | info_handle_t *info_handle, 69 | libcerror_error_t **error ); 70 | 71 | int info_handle_file_fprint( 72 | info_handle_t *info_handle, 73 | libcerror_error_t **error ); 74 | 75 | #if defined( __cplusplus ) 76 | } 77 | #endif 78 | 79 | #endif /* !defined( _INFO_HANDLE_H ) */ 80 | 81 | -------------------------------------------------------------------------------- /hibrtools/mount_file_entry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount file entry 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MOUNT_FILE_ENTRY_H ) 23 | #define _MOUNT_FILE_ENTRY_H 24 | 25 | #include 26 | #include 27 | 28 | #include "hibrtools_libcerror.h" 29 | #include "hibrtools_libhibr.h" 30 | #include "mount_file_system.h" 31 | 32 | #if defined( __cplusplus ) 33 | extern "C" { 34 | #endif 35 | 36 | typedef struct mount_file_entry mount_file_entry_t; 37 | 38 | struct mount_file_entry 39 | { 40 | /* The file system 41 | */ 42 | mount_file_system_t *file_system; 43 | 44 | /* The name 45 | */ 46 | system_character_t *name; 47 | 48 | /* The name size 49 | */ 50 | size_t name_size; 51 | 52 | /* The file 53 | */ 54 | libhibr_file_t *hibr_file; 55 | }; 56 | 57 | int mount_file_entry_initialize( 58 | mount_file_entry_t **file_entry, 59 | mount_file_system_t *file_system, 60 | const system_character_t *name, 61 | size_t name_length, 62 | libhibr_file_t *hibr_file, 63 | libcerror_error_t **error ); 64 | 65 | int mount_file_entry_free( 66 | mount_file_entry_t **file_entry, 67 | libcerror_error_t **error ); 68 | 69 | int mount_file_entry_get_parent_file_entry( 70 | mount_file_entry_t *file_entry, 71 | mount_file_entry_t **parent_file_entry, 72 | libcerror_error_t **error ); 73 | 74 | int mount_file_entry_get_creation_time( 75 | mount_file_entry_t *file_entry, 76 | uint64_t *creation_time, 77 | libcerror_error_t **error ); 78 | 79 | int mount_file_entry_get_access_time( 80 | mount_file_entry_t *file_entry, 81 | uint64_t *access_time, 82 | libcerror_error_t **error ); 83 | 84 | int mount_file_entry_get_modification_time( 85 | mount_file_entry_t *file_entry, 86 | uint64_t *modification_time, 87 | libcerror_error_t **error ); 88 | 89 | int mount_file_entry_get_inode_change_time( 90 | mount_file_entry_t *file_entry, 91 | uint64_t *inode_change_time, 92 | libcerror_error_t **error ); 93 | 94 | int mount_file_entry_get_file_mode( 95 | mount_file_entry_t *file_entry, 96 | uint16_t *file_mode, 97 | libcerror_error_t **error ); 98 | 99 | int mount_file_entry_get_name_size( 100 | mount_file_entry_t *file_entry, 101 | size_t *string_size, 102 | libcerror_error_t **error ); 103 | 104 | int mount_file_entry_get_name( 105 | mount_file_entry_t *file_entry, 106 | system_character_t *string, 107 | size_t string_size, 108 | libcerror_error_t **error ); 109 | 110 | int mount_file_entry_get_number_of_sub_file_entries( 111 | mount_file_entry_t *file_entry, 112 | int *number_of_sub_entries, 113 | libcerror_error_t **error ); 114 | 115 | int mount_file_entry_get_sub_file_entry_by_index( 116 | mount_file_entry_t *file_entry, 117 | int sub_file_entry_index, 118 | mount_file_entry_t **sub_file_entry, 119 | libcerror_error_t **error ); 120 | 121 | ssize_t mount_file_entry_read_buffer_at_offset( 122 | mount_file_entry_t *file_entry, 123 | void *buffer, 124 | size_t buffer_size, 125 | off64_t offset, 126 | libcerror_error_t **error ); 127 | 128 | int mount_file_entry_get_size( 129 | mount_file_entry_t *file_entry, 130 | size64_t *size, 131 | libcerror_error_t **error ); 132 | 133 | #if defined( __cplusplus ) 134 | } 135 | #endif 136 | 137 | #endif /* !defined( _MOUNT_FILE_ENTRY_H ) */ 138 | 139 | -------------------------------------------------------------------------------- /hibrtools/mount_file_system.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount file system 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MOUNT_FILE_SYSTEM_H ) 23 | #define _MOUNT_FILE_SYSTEM_H 24 | 25 | #include 26 | #include 27 | 28 | #include "hibrtools_libcdata.h" 29 | #include "hibrtools_libcerror.h" 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | typedef struct mount_file_system mount_file_system_t; 36 | 37 | struct mount_file_system 38 | { 39 | /* The mounted timestamp 40 | */ 41 | uint64_t mounted_timestamp; 42 | 43 | /* The path prefix 44 | */ 45 | system_character_t *path_prefix; 46 | 47 | /* The path prefix size 48 | */ 49 | size_t path_prefix_size; 50 | 51 | /* The files array 52 | */ 53 | libcdata_array_t *files_array; 54 | }; 55 | 56 | int mount_file_system_initialize( 57 | mount_file_system_t **file_system, 58 | libcerror_error_t **error ); 59 | 60 | int mount_file_system_free( 61 | mount_file_system_t **file_system, 62 | libcerror_error_t **error ); 63 | 64 | int mount_file_system_signal_abort( 65 | mount_file_system_t *file_system, 66 | libcerror_error_t **error ); 67 | 68 | int mount_file_system_set_path_prefix( 69 | mount_file_system_t *file_system, 70 | const system_character_t *path_prefix, 71 | size_t path_prefix_size, 72 | libcerror_error_t **error ); 73 | 74 | int mount_file_system_get_mounted_timestamp( 75 | mount_file_system_t *file_system, 76 | uint64_t *mounted_timestamp, 77 | libcerror_error_t **error ); 78 | 79 | int mount_file_system_get_number_of_files( 80 | mount_file_system_t *file_system, 81 | int *number_of_files, 82 | libcerror_error_t **error ); 83 | 84 | int mount_file_system_get_file_by_index( 85 | mount_file_system_t *file_system, 86 | int file_index, 87 | libhibr_file_t **hibr_file, 88 | libcerror_error_t **error ); 89 | 90 | int mount_file_system_get_file_by_path( 91 | mount_file_system_t *file_system, 92 | const system_character_t *path, 93 | size_t path_length, 94 | libhibr_file_t **hibr_file, 95 | libcerror_error_t **error ); 96 | 97 | int mount_file_system_append_file( 98 | mount_file_system_t *file_system, 99 | libhibr_file_t *hibr_file, 100 | libcerror_error_t **error ); 101 | 102 | int mount_file_system_get_path_from_file_index( 103 | mount_file_system_t *file_system, 104 | int file_index, 105 | system_character_t *path, 106 | size_t path_size, 107 | libcerror_error_t **error ); 108 | 109 | #if defined( __cplusplus ) 110 | } 111 | #endif 112 | 113 | #endif /* !defined( _MOUNT_FILE_SYSTEM_H ) */ 114 | 115 | -------------------------------------------------------------------------------- /hibrtools/mount_fuse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount tool fuse functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MOUNT_FUSE_H ) 23 | #define _MOUNT_FUSE_H 24 | 25 | #include 26 | #include 27 | 28 | #if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) 29 | 30 | #if !defined( FUSE_USE_VERSION ) && !defined( CYGFUSE ) 31 | 32 | /* Ensure FUSE_USE_VERSION is defined before including fuse.h 33 | */ 34 | #if defined( HAVE_LIBFUSE3 ) 35 | #define FUSE_USE_VERSION 30 36 | #else 37 | #define FUSE_USE_VERSION 26 38 | #endif 39 | 40 | #endif /* !defined( FUSE_USE_VERSION ) && !defined( CYGFUSE ) */ 41 | 42 | #if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) 43 | #include 44 | #elif defined( HAVE_LIBOSXFUSE ) 45 | #include 46 | #endif 47 | 48 | #endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */ 49 | 50 | #include "hibrtools_libcerror.h" 51 | #include "hibrtools_libhibr.h" 52 | #include "mount_file_entry.h" 53 | #include "mount_handle.h" 54 | 55 | #if defined( __cplusplus ) 56 | extern "C" { 57 | #endif 58 | 59 | #if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) 60 | 61 | int mount_fuse_set_stat_info( 62 | struct stat *stat_info, 63 | size64_t size, 64 | uint16_t file_mode, 65 | int64_t access_time, 66 | int64_t inode_change_time, 67 | int64_t modification_time, 68 | libcerror_error_t **error ); 69 | 70 | int mount_fuse_filldir( 71 | void *buffer, 72 | fuse_fill_dir_t filler, 73 | const char *name, 74 | struct stat *stat_info, 75 | mount_file_entry_t *file_entry, 76 | libcerror_error_t **error ); 77 | 78 | int mount_fuse_open( 79 | const char *path, 80 | struct fuse_file_info *file_info ); 81 | 82 | int mount_fuse_read( 83 | const char *path, 84 | char *buffer, 85 | size_t size, 86 | off_t offset, 87 | struct fuse_file_info *file_info ); 88 | 89 | int mount_fuse_release( 90 | const char *path, 91 | struct fuse_file_info *file_info ); 92 | 93 | int mount_fuse_opendir( 94 | const char *path, 95 | struct fuse_file_info *file_info ); 96 | 97 | #if defined( HAVE_LIBFUSE3 ) 98 | int mount_fuse_readdir( 99 | const char *path, 100 | void *buffer, 101 | fuse_fill_dir_t filler, 102 | off_t offset, 103 | struct fuse_file_info *file_info, 104 | enum fuse_readdir_flags flags ); 105 | #else 106 | int mount_fuse_readdir( 107 | const char *path, 108 | void *buffer, 109 | fuse_fill_dir_t filler, 110 | off_t offset, 111 | struct fuse_file_info *file_info ); 112 | #endif 113 | 114 | int mount_fuse_releasedir( 115 | const char *path, 116 | struct fuse_file_info *file_info ); 117 | 118 | #if defined( HAVE_LIBFUSE3 ) 119 | int mount_fuse_getattr( 120 | const char *path, 121 | struct stat *stat_info, 122 | struct fuse_file_info *file_info ); 123 | #else 124 | int mount_fuse_getattr( 125 | const char *path, 126 | struct stat *stat_info ); 127 | #endif 128 | 129 | void mount_fuse_destroy( 130 | void *private_data ); 131 | 132 | #endif /* defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) */ 133 | 134 | #if defined( __cplusplus ) 135 | } 136 | #endif 137 | 138 | #endif /* !defined( _MOUNT_FUSE_H ) */ 139 | 140 | -------------------------------------------------------------------------------- /hibrtools/mount_handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Mount handle 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _MOUNT_HANDLE_H ) 23 | #define _MOUNT_HANDLE_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "hibrtools_libcerror.h" 30 | #include "hibrtools_libhibr.h" 31 | #include "mount_file_entry.h" 32 | #include "mount_file_system.h" 33 | 34 | #if defined( __cplusplus ) 35 | extern "C" { 36 | #endif 37 | 38 | typedef struct mount_handle mount_handle_t; 39 | 40 | struct mount_handle 41 | { 42 | /* The file system 43 | */ 44 | mount_file_system_t *file_system; 45 | 46 | /* The notification output stream 47 | */ 48 | FILE *notify_stream; 49 | }; 50 | 51 | int mount_handle_initialize( 52 | mount_handle_t **mount_handle, 53 | libcerror_error_t **error ); 54 | 55 | int mount_handle_free( 56 | mount_handle_t **mount_handle, 57 | libcerror_error_t **error ); 58 | 59 | int mount_handle_signal_abort( 60 | mount_handle_t *mount_handle, 61 | libcerror_error_t **error ); 62 | 63 | int mount_handle_set_path_prefix( 64 | mount_handle_t *mount_handle, 65 | const system_character_t *path_prefix, 66 | size_t path_prefix_size, 67 | libcerror_error_t **error ); 68 | 69 | int mount_handle_open( 70 | mount_handle_t *mount_handle, 71 | const system_character_t *filename, 72 | libcerror_error_t **error ); 73 | 74 | int mount_handle_close( 75 | mount_handle_t *mount_handle, 76 | libcerror_error_t **error ); 77 | 78 | int mount_handle_get_file_entry_by_path( 79 | mount_handle_t *mount_handle, 80 | const system_character_t *path, 81 | mount_file_entry_t **file_entry, 82 | libcerror_error_t **error ); 83 | 84 | #if defined( __cplusplus ) 85 | } 86 | #endif 87 | 88 | #endif /* !defined( _MOUNT_HANDLE_H ) */ 89 | 90 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | include_HEADERS = \ 2 | libhibr.h 3 | 4 | pkginclude_HEADERS = \ 5 | libhibr/codepage.h \ 6 | libhibr/definitions.h \ 7 | libhibr/error.h \ 8 | libhibr/extern.h \ 9 | libhibr/features.h \ 10 | libhibr/types.h 11 | 12 | EXTRA_DIST = \ 13 | libhibr.h.in \ 14 | libhibr/definitions.h.in \ 15 | libhibr/features.h.in \ 16 | libhibr/types.h.in 17 | 18 | DISTCLEANFILES = \ 19 | libhibr.h \ 20 | libhibr/definitions.h \ 21 | libhibr/features.h \ 22 | libhibr/types.h \ 23 | Makefile \ 24 | Makefile.in 25 | 26 | -------------------------------------------------------------------------------- /include/libhibr/definitions.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions for libhibr 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_DEFINITIONS_H ) 23 | #define _LIBHIBR_DEFINITIONS_H 24 | 25 | #include 26 | 27 | #define LIBHIBR_VERSION @VERSION@ 28 | 29 | /* The version string 30 | */ 31 | #define LIBHIBR_VERSION_STRING "@VERSION@" 32 | 33 | /* The access flags definitions 34 | * bit 1 set to 1 for read access 35 | * bit 2 set to 1 for write access 36 | * bit 3-8 not used 37 | */ 38 | enum LIBHIBR_ACCESS_FLAGS 39 | { 40 | LIBHIBR_ACCESS_FLAG_READ = 0x01, 41 | /* Reserved: not supported yet */ 42 | LIBHIBR_ACCESS_FLAG_WRITE = 0x02 43 | }; 44 | 45 | /* The file access macros 46 | */ 47 | #define LIBHIBR_OPEN_READ ( LIBHIBR_ACCESS_FLAG_READ ) 48 | /* Reserved: not supported yet */ 49 | #define LIBHIBR_OPEN_WRITE ( LIBHIBR_ACCESS_FLAG_WRITE ) 50 | /* Reserved: not supported yet */ 51 | #define LIBHIBR_OPEN_READ_WRITE ( LIBHIBR_ACCESS_FLAG_READ | LIBHIBR_ACCESS_FLAG_WRITE ) 52 | 53 | /* The file type definitions 54 | */ 55 | enum LIBHIBR_FILE_TYPES 56 | { 57 | LIBHIBR_FILE_TYPE_UNDEFINED, 58 | LIBHIBR_FILE_TYPE_WINDOWS_XP_32BIT, 59 | LIBHIBR_FILE_TYPE_WINDOWS_XP_64BIT, 60 | LIBHIBR_FILE_TYPE_WINDOWS_7_32BIT, 61 | LIBHIBR_FILE_TYPE_WINDOWS_7_64BIT, 62 | }; 63 | 64 | #define LIBHIBR_FILE_TYPE_WINDOWS_2003_32BIT LIBHIBR_FILE_TYPE_WINDOWS_XP_32BIT 65 | #define LIBHIBR_FILE_TYPE_WINDOWS_2003_64BIT LIBHIBR_FILE_TYPE_WINDOWS_XP_64BIT 66 | 67 | #endif /* !defined( _LIBHIBR_DEFINITIONS_H ) */ 68 | 69 | -------------------------------------------------------------------------------- /include/libhibr/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The extern definition 3 | * 4 | * This header should be included in header files that export or import 5 | * library functions 6 | * 7 | * Copyright (C) 2012-2024, Joachim Metz 8 | * 9 | * Refer to AUTHORS for acknowledgements. 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #if !defined( _LIBHIBR_EXTERN_H ) 26 | #define _LIBHIBR_EXTERN_H 27 | 28 | /* To export functions from the libhibr DLL define LIBHIBR_DLL_EXPORT 29 | * To import functions from the libhibr DLL define LIBHIBR_DLL_IMPORT 30 | * Otherwise use default extern statement 31 | */ 32 | #if defined( LIBHIBR_DLL_EXPORT ) 33 | #define LIBHIBR_EXTERN __declspec(dllexport) 34 | 35 | #elif defined( LIBHIBR_DLL_IMPORT ) 36 | #define LIBHIBR_EXTERN extern __declspec(dllimport) 37 | 38 | #else 39 | #define LIBHIBR_EXTERN extern 40 | 41 | #endif 42 | 43 | #endif /* !defined( _LIBHIBR_EXTERN_H ) */ 44 | 45 | -------------------------------------------------------------------------------- /include/libhibr/features.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Features of libhibr 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_FEATURES_H ) 23 | #define _LIBHIBR_FEATURES_H 24 | 25 | /* The libhibr type support features 26 | */ 27 | #if defined( WINAPI ) || @HAVE_WIDE_CHARACTER_TYPE@ 28 | #define LIBHIBR_HAVE_WIDE_CHARACTER_TYPE 1 29 | #endif 30 | 31 | #if defined( WINAPI ) || @HAVE_MULTI_THREAD_SUPPORT@ 32 | #define LIBHIBR_HAVE_MULTI_THREAD_SUPPORT 1 33 | #endif 34 | 35 | #if defined( HAVE_LIBBFIO ) || ( !defined( WINAPI ) && @HAVE_LIBBFIO@ ) 36 | #define LIBHIBR_HAVE_BFIO 1 37 | #endif 38 | 39 | #if !defined( LIBHIBR_DEPRECATED ) 40 | #if defined( __GNUC__ ) && __GNUC__ >= 3 41 | #define LIBHIBR_DEPRECATED __attribute__ ((__deprecated__)) 42 | #elif defined( _MSC_VER ) 43 | #define LIBHIBR_DEPRECATED __declspec(deprecated) 44 | #else 45 | #define LIBHIBR_DEPRECATED 46 | #endif 47 | #endif 48 | 49 | #endif /* !defined( _LIBHIBR_FEATURES_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libhibr.ini: -------------------------------------------------------------------------------- 1 | [project] 2 | name: "libhibr" 3 | status: "experimental" 4 | year_of_creation: "2012" 5 | data_format: "Windows Hibernation File (hiberfil.sys)" 6 | features: ["debug_output", "ossfuzz", "tools"] 7 | 8 | [library] 9 | features: ["pthread", "wide_character_type"] 10 | public_types: ["file"] 11 | 12 | [tools] 13 | build_dependencies: ["fuse"] 14 | description: "Several tools for reading Windows Hibernation Files (hiberfil.sys)" 15 | names: ["hibrinfo", "hibrmount"] 16 | 17 | [info_tool] 18 | source_description: "a Windows Hibernation File (hiberfil.sys)" 19 | source_type: "file" 20 | 21 | [mount_tool] 22 | file_entry_type: "file" 23 | file_entry_type_size_value: "media_size" 24 | mounted_description: "a device file that provides the RAW data contained in the hiberfil.sys file" 25 | source: "hiberfil.sys" 26 | source_description: "a hiberfil.sys file" 27 | source_description_long: "a Windows Hibernation File (hiberfil.sys)" 28 | source_type: "file" 29 | 30 | [troubleshooting] 31 | example: "hibrinfo hiberfil.sys" 32 | 33 | [tests] 34 | profiles: ["libhibr", "pyhibr", "hibrinfo"] 35 | info_tool_options_per_profile: [""] 36 | info_tool_profiles: ["hibrinfo"] 37 | example_filename1: "hiberfil.sys" 38 | example_filename2: "backup_hiberfil.sys" 39 | 40 | -------------------------------------------------------------------------------- /libhibr.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libhibr 7 | Description: Library to access the Windows Hibernation File (hiberfil.sys) format 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lhibr 10 | Libs.private: @ax_libbfio_pc_libs_private@ @ax_libcdata_pc_libs_private@ @ax_libcerror_pc_libs_private@ @ax_libcfile_pc_libs_private@ @ax_libclocale_pc_libs_private@ @ax_libcnotify_pc_libs_private@ @ax_libcpath_pc_libs_private@ @ax_libcsplit_pc_libs_private@ @ax_libfcache_pc_libs_private@ @ax_libfdata_pc_libs_private@ @ax_libfdatetime_pc_libs_private@ @ax_libfwnt_pc_libs_private@ @ax_libuna_pc_libs_private@ 11 | Cflags: -I${includedir} 12 | 13 | -------------------------------------------------------------------------------- /libhibr.spec.in: -------------------------------------------------------------------------------- 1 | Name: libhibr 2 | Version: @VERSION@ 3 | Release: 1 4 | Summary: Library to access the Windows Hibernation File (hiberfil.sys) format 5 | Group: System Environment/Libraries 6 | License: LGPL-3.0-or-later 7 | Source: %{name}-%{version}.tar.gz 8 | URL: https://github.com/libyal/libhibr 9 | @libhibr_spec_requires@ @ax_libbfio_spec_requires@ @ax_libcdata_spec_requires@ @ax_libcerror_spec_requires@ @ax_libcfile_spec_requires@ @ax_libclocale_spec_requires@ @ax_libcnotify_spec_requires@ @ax_libcpath_spec_requires@ @ax_libcsplit_spec_requires@ @ax_libcthreads_spec_requires@ @ax_libfcache_spec_requires@ @ax_libfdata_spec_requires@ @ax_libfdatetime_spec_requires@ @ax_libfwnt_spec_requires@ @ax_libuna_spec_requires@ 10 | BuildRequires: gcc @ax_libbfio_spec_build_requires@ @ax_libcdata_spec_build_requires@ @ax_libcerror_spec_build_requires@ @ax_libcfile_spec_build_requires@ @ax_libclocale_spec_build_requires@ @ax_libcnotify_spec_build_requires@ @ax_libcpath_spec_build_requires@ @ax_libcsplit_spec_build_requires@ @ax_libcthreads_spec_build_requires@ @ax_libfcache_spec_build_requires@ @ax_libfdata_spec_build_requires@ @ax_libfdatetime_spec_build_requires@ @ax_libfwnt_spec_build_requires@ @ax_libuna_spec_build_requires@ 11 | 12 | %description -n libhibr 13 | Library to access the Windows Hibernation File (hiberfil.sys) format 14 | 15 | %package -n libhibr-static 16 | Summary: Library to access the Windows Hibernation File (hiberfil.sys) format 17 | Group: Development/Libraries 18 | Requires: libhibr = %{version}-%{release} 19 | 20 | %description -n libhibr-static 21 | Static library version of libhibr. 22 | 23 | %package -n libhibr-devel 24 | Summary: Header files and libraries for developing applications for libhibr 25 | Group: Development/Libraries 26 | Requires: libhibr = %{version}-%{release} 27 | 28 | %description -n libhibr-devel 29 | Header files and libraries for developing applications for libhibr. 30 | 31 | %package -n libhibr-tools 32 | Summary: Several tools for reading Windows Hibernation Files (hiberfil.sys) 33 | Group: Applications/System 34 | Requires: libhibr = %{version}-%{release} @ax_libfuse_spec_requires@ 35 | @libhibr_spec_tools_build_requires@ @ax_libfuse_spec_build_requires@ 36 | 37 | %description -n libhibr-tools 38 | Several tools for reading Windows Hibernation Files (hiberfil.sys) 39 | 40 | %prep 41 | %setup -q 42 | 43 | %build 44 | %configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir} 45 | make %{?_smp_mflags} 46 | 47 | %install 48 | rm -rf %{buildroot} 49 | %make_install 50 | 51 | %clean 52 | rm -rf %{buildroot} 53 | 54 | %post -p /sbin/ldconfig 55 | 56 | %postun -p /sbin/ldconfig 57 | 58 | %files -n libhibr 59 | %license COPYING COPYING.LESSER 60 | %doc AUTHORS README 61 | %{_libdir}/*.so.* 62 | 63 | %files -n libhibr-static 64 | %license COPYING COPYING.LESSER 65 | %doc AUTHORS README 66 | %{_libdir}/*.a 67 | 68 | %files -n libhibr-devel 69 | %license COPYING COPYING.LESSER 70 | %doc AUTHORS README 71 | %{_libdir}/*.so 72 | %{_libdir}/pkgconfig/libhibr.pc 73 | %{_includedir}/* 74 | %{_mandir}/man3/* 75 | 76 | %files -n libhibr-tools 77 | %license COPYING COPYING.LESSER 78 | %doc AUTHORS README 79 | %{_bindir}/* 80 | %{_mandir}/man1/* 81 | 82 | %changelog 83 | * @SPEC_DATE@ Joachim Metz @VERSION@-1 84 | - Auto-generated 85 | 86 | -------------------------------------------------------------------------------- /libhibr/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -DLOCALEDIR=\"$(datadir)/locale\" \ 3 | -I../include -I$(top_srcdir)/include \ 4 | -I../common -I$(top_srcdir)/common \ 5 | @LIBCERROR_CPPFLAGS@ \ 6 | @LIBCTHREADS_CPPFLAGS@ \ 7 | @LIBCDATA_CPPFLAGS@ \ 8 | @LIBCLOCALE_CPPFLAGS@ \ 9 | @LIBCNOTIFY_CPPFLAGS@ \ 10 | @LIBCSPLIT_CPPFLAGS@ \ 11 | @LIBUNA_CPPFLAGS@ \ 12 | @LIBCFILE_CPPFLAGS@ \ 13 | @LIBCPATH_CPPFLAGS@ \ 14 | @LIBBFIO_CPPFLAGS@ \ 15 | @LIBFCACHE_CPPFLAGS@ \ 16 | @LIBFDATA_CPPFLAGS@ \ 17 | @LIBFDATETIME_CPPFLAGS@ \ 18 | @LIBFWNT_CPPFLAGS@ \ 19 | @PTHREAD_CPPFLAGS@ \ 20 | @LIBHIBR_DLL_EXPORT@ 21 | 22 | lib_LTLIBRARIES = libhibr.la 23 | 24 | libhibr_la_SOURCES = \ 25 | hibr_compressed_page_data.h \ 26 | hibr_compressed_page_map.h \ 27 | hibr_memory_image_information.h \ 28 | libhibr.c \ 29 | libhibr_compressed_page_data.c libhibr_compressed_page_data.h \ 30 | libhibr_compressed_page_map.c libhibr_compressed_page_map.h \ 31 | libhibr_debug.c libhibr_debug.h \ 32 | libhibr_definitions.h \ 33 | libhibr_error.c libhibr_error.h \ 34 | libhibr_extern.h \ 35 | libhibr_file.c libhibr_file.h \ 36 | libhibr_i18n.c libhibr_i18n.h \ 37 | libhibr_io_handle.c libhibr_io_handle.h \ 38 | libhibr_libbfio.h \ 39 | libhibr_libcdata.h \ 40 | libhibr_libcerror.h \ 41 | libhibr_libclocale.h \ 42 | libhibr_libcnotify.h \ 43 | libhibr_libfcache.h \ 44 | libhibr_libfdata.h \ 45 | libhibr_libfdatetime.h \ 46 | libhibr_libfwnt.h \ 47 | libhibr_libuna.h \ 48 | libhibr_notify.c libhibr_notify.h \ 49 | libhibr_support.c libhibr_support.h \ 50 | libhibr_types.h \ 51 | libhibr_unused.h 52 | 53 | libhibr_la_LIBADD = \ 54 | @LIBCERROR_LIBADD@ \ 55 | @LIBCDATA_LIBADD@ \ 56 | @LIBCLOCALE_LIBADD@ \ 57 | @LIBCNOTIFY_LIBADD@ \ 58 | @LIBCSPLIT_LIBADD@ \ 59 | @LIBUNA_LIBADD@ \ 60 | @LIBCFILE_LIBADD@ \ 61 | @LIBCPATH_LIBADD@ \ 62 | @LIBBFIO_LIBADD@ \ 63 | @LIBFCACHE_LIBADD@ \ 64 | @LIBFDATA_LIBADD@ \ 65 | @LIBFDATETIME_LIBADD@ \ 66 | @LIBFWNT_LIBADD@ 67 | 68 | libhibr_la_LDFLAGS = -no-undefined -version-info 1:0:0 69 | 70 | EXTRA_DIST = \ 71 | libhibr_definitions.h.in \ 72 | libhibr.rc \ 73 | libhibr.rc.in 74 | 75 | DISTCLEANFILES = \ 76 | libhibr_definitions.h \ 77 | libhibr.rc \ 78 | Makefile \ 79 | Makefile.in 80 | 81 | sources-local: $(BUILT_SOURCES) 82 | 83 | splint-local: 84 | @echo "Running splint on libhibr ..." 85 | -splint -preproc -redef $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(libhibr_la_SOURCES) 86 | 87 | -------------------------------------------------------------------------------- /libhibr/hibr_compressed_page_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The compressed page data definition of a Windows Hibernation File (hiberfil.sys) 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_COMPRESSED_PAGE_DATA_H ) 23 | #define _HIBR_COMPRESSED_PAGE_DATA_H 24 | 25 | #include 26 | #include 27 | 28 | #if defined( __cplusplus ) 29 | extern "C" { 30 | #endif 31 | 32 | typedef struct hibr_compressed_page_data_header hibr_compressed_page_data_header_t; 33 | 34 | struct hibr_compressed_page_data_header 35 | { 36 | /* The signature 37 | * Consists of 8 bytes 38 | * Contains: \x81\x81xpress 39 | */ 40 | uint8_t signature[ 8 ]; 41 | 42 | /* The number of pages 43 | * Consists of 1 byte 44 | */ 45 | uint8_t number_of_pages; 46 | 47 | /* The compressed data size 48 | * Consists of 4 bytes 49 | */ 50 | uint8_t compressed_data_size[ 4 ]; 51 | 52 | /* Unknown 53 | * Consists of 19 bytes 54 | */ 55 | uint8_t unknown1[ 19 ]; 56 | }; 57 | 58 | #if defined( __cplusplus ) 59 | } 60 | #endif 61 | 62 | #endif /* !defined( _HIBR_COMPRESSED_PAGE_DATA_H ) */ 63 | 64 | -------------------------------------------------------------------------------- /libhibr/hibr_compressed_page_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The compressed page map definition of a Windows Hibernation File (hiberfil.sys) 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_COMPRESSED_PAGE_MAP_H ) 23 | #define _HIBR_COMPRESSED_PAGE_MAP_H 24 | 25 | #include 26 | #include 27 | 28 | #if defined( __cplusplus ) 29 | extern "C" { 30 | #endif 31 | 32 | typedef struct hibr_compressed_page_map_header_winxp_sp3_32bit hibr_compressed_page_map_header_winxp_sp3_32bit_t; 33 | 34 | struct hibr_compressed_page_map_header_winxp_sp3_32bit 35 | { 36 | /* Unknown 37 | * Consists of 4 bytes 38 | */ 39 | uint8_t unknown1[ 4 ]; 40 | 41 | /* The next (memory block) page number 42 | * Consists of 4 bytes 43 | */ 44 | uint8_t next_page_number[ 4 ]; 45 | 46 | /* Unknown 47 | * Consists of 4 bytes 48 | */ 49 | uint8_t unknown2[ 4 ]; 50 | 51 | /* The number of entries 52 | * Consists of 4 bytes 53 | */ 54 | uint8_t number_of_entries[ 4 ]; 55 | }; 56 | 57 | typedef struct hibr_compressed_page_map_header_win7_sp1_64bit hibr_compressed_page_map_header_win7_sp1_64bit_t; 58 | 59 | struct hibr_compressed_page_map_header_win7_sp1_64bit 60 | { 61 | /* The next (memory block) page number 62 | * Consists of 4 bytes 63 | */ 64 | uint8_t next_page_number[ 4 ]; 65 | 66 | /* Unknown 67 | * Consists of 4 bytes 68 | */ 69 | uint8_t unknown1[ 4 ]; 70 | 71 | /* The number of entries 72 | * Consists of 4 bytes 73 | */ 74 | uint8_t number_of_entries[ 4 ]; 75 | 76 | /* Unknown 77 | * Consists of 4 bytes 78 | */ 79 | uint8_t unknown2[ 4 ]; 80 | }; 81 | 82 | typedef struct hibr_compressed_page_map_entry hibr_compressed_page_map_entry_t; 83 | 84 | struct hibr_compressed_page_map_entry 85 | { 86 | /* Unknown 87 | * Consists of 8 bytes 88 | */ 89 | uint8_t unknown1[ 8 ]; 90 | 91 | /* Unknown 92 | * Consists of 8 bytes 93 | */ 94 | uint8_t unknown2[ 8 ]; 95 | }; 96 | 97 | #if defined( __cplusplus ) 98 | } 99 | #endif 100 | 101 | #endif /* !defined( _HIBR_COMPRESSED_PAGE_MAP_H ) */ 102 | 103 | -------------------------------------------------------------------------------- /libhibr/libhibr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library to access the Windows Hibernation File (hiberfil.sys) format 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | 24 | #if defined( WINAPI ) 25 | #include 26 | #endif 27 | 28 | #include "libhibr_unused.h" 29 | 30 | /* Define HAVE_LOCAL_LIBHIBR for local use of libhibr 31 | */ 32 | #if !defined( HAVE_LOCAL_LIBHIBR ) 33 | 34 | #if defined( WINAPI ) && defined( HAVE_DLLMAIN ) 35 | 36 | #if defined( _MANAGED ) 37 | #pragma managed( push, off ) 38 | #endif 39 | 40 | /* Defines the entry point for the DLL 41 | */ 42 | BOOL WINAPI DllMain( 43 | HINSTANCE hinstDLL, 44 | DWORD fdwReason, 45 | LPVOID lpvReserved ) 46 | { 47 | LIBHIBR_UNREFERENCED_PARAMETER( lpvReserved ) 48 | 49 | switch( fdwReason ) 50 | { 51 | case DLL_PROCESS_ATTACH: 52 | DisableThreadLibraryCalls( 53 | hinstDLL ); 54 | break; 55 | 56 | case DLL_THREAD_ATTACH: 57 | break; 58 | 59 | case DLL_THREAD_DETACH: 60 | break; 61 | 62 | case DLL_PROCESS_DETACH: 63 | break; 64 | } 65 | return( TRUE ); 66 | } 67 | 68 | /* Function that indicates the library is a DLL 69 | * Returns 1 70 | */ 71 | int libhibr_is_dll( 72 | void ) 73 | { 74 | return( 1 ); 75 | } 76 | 77 | #endif /* defined( WINAPI ) && defined( HAVE_DLLMAIN ) */ 78 | 79 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 80 | 81 | -------------------------------------------------------------------------------- /libhibr/libhibr.rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef GCC_WINDRES 4 | VS_VERSION_INFO VERSIONINFO 5 | #else 6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 7 | #endif 8 | FILEVERSION 1,0,0,0 9 | PRODUCTVERSION 1,0,0,0 10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 11 | #ifdef _DEBUG 12 | FILEFLAGS 0x1L 13 | #else 14 | FILEFLAGS 0x0L 15 | #endif 16 | FILEOS VOS__WINDOWS32 17 | FILETYPE VFT_DLL 18 | FILESUBTYPE 0x0L 19 | BEGIN 20 | BLOCK "StringFileInfo" 21 | BEGIN 22 | BLOCK "040904E4" 23 | BEGIN 24 | VALUE "FileDescription", "Library to access the Windows Hibernation File (hiberfil.sys) format\0" 25 | VALUE "FileVersion", "@VERSION@" "\0" 26 | VALUE "InternalName", "libhibr.dll\0" 27 | VALUE "LegalCopyright", "(C) 2012-2024, Joachim Metz \0" 28 | VALUE "OriginalFilename", "libhibr.dll\0" 29 | VALUE "ProductName", "libhibr\0" 30 | VALUE "ProductVersion", "@VERSION@" "\0" 31 | VALUE "Comments", "For more information visit https://github.com/libyal/libhibr/\0" 32 | END 33 | END 34 | BLOCK "VarFileInfo" 35 | BEGIN 36 | VALUE "Translation", 0x0409, 1200 37 | END 38 | END 39 | -------------------------------------------------------------------------------- /libhibr/libhibr_compressed_page_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Compressed page data functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_COMPRESSED_PAGE_DATA_H ) 23 | #define _LIBHIBR_COMPRESSED_PAGE_DATA_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libhibr_libbfio.h" 29 | #include "libhibr_libcerror.h" 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | typedef struct libhibr_compressed_page_data libhibr_compressed_page_data_t; 36 | 37 | struct libhibr_compressed_page_data 38 | { 39 | /* The data 40 | */ 41 | uint8_t *data; 42 | 43 | /* The data size 44 | */ 45 | size_t data_size; 46 | 47 | /* The number of pages 48 | */ 49 | uint8_t number_of_pages; 50 | 51 | /* The compressed data size 52 | */ 53 | size_t compressed_data_size; 54 | 55 | /* The (alignment) padding size 56 | */ 57 | size_t padding_size; 58 | }; 59 | 60 | int libhibr_compressed_page_data_initialize( 61 | libhibr_compressed_page_data_t **compressed_page_data, 62 | libcerror_error_t **error ); 63 | 64 | int libhibr_compressed_page_data_free( 65 | libhibr_compressed_page_data_t **compressed_page_data, 66 | libcerror_error_t **error ); 67 | 68 | int libhibr_compressed_page_data_read_header( 69 | libhibr_compressed_page_data_t *compressed_page_data, 70 | libbfio_handle_t *file_io_handle, 71 | off64_t file_offset, 72 | libcerror_error_t **error ); 73 | 74 | int libhibr_compressed_page_data_read_file_io_handle( 75 | libhibr_compressed_page_data_t *compressed_page_data, 76 | libbfio_handle_t *file_io_handle, 77 | off64_t file_offset, 78 | libcerror_error_t **error ); 79 | 80 | #if defined( __cplusplus ) 81 | } 82 | #endif 83 | 84 | #endif /* !defined( _LIBHIBR_COMPRESSED_PAGE_DATA_H ) */ 85 | 86 | -------------------------------------------------------------------------------- /libhibr/libhibr_compressed_page_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Compressed page map functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_COMPRESSED_PAGE_MAP_H ) 23 | #define _LIBHIBR_COMPRESSED_PAGE_MAP_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libhibr_io_handle.h" 29 | #include "libhibr_libbfio.h" 30 | #include "libhibr_libcdata.h" 31 | #include "libhibr_libcerror.h" 32 | 33 | #if defined( __cplusplus ) 34 | extern "C" { 35 | #endif 36 | 37 | typedef struct libhibr_compressed_page_map libhibr_compressed_page_map_t; 38 | 39 | struct libhibr_compressed_page_map 40 | { 41 | /* The next (memory block) page number 42 | */ 43 | uint64_t next_page_number; 44 | 45 | /* The entries array 46 | */ 47 | libcdata_array_t *entries_array; 48 | }; 49 | 50 | int libhibr_compressed_page_map_initialize( 51 | libhibr_compressed_page_map_t **compressed_page_map, 52 | libcerror_error_t **error ); 53 | 54 | int libhibr_compressed_page_map_free( 55 | libhibr_compressed_page_map_t **compressed_page_map, 56 | libcerror_error_t **error ); 57 | 58 | int libhibr_compressed_page_map_read_data( 59 | libhibr_compressed_page_map_t *compressed_page_map, 60 | libhibr_io_handle_t *io_handle, 61 | const uint8_t *data, 62 | size_t data_size, 63 | libcerror_error_t **error ); 64 | 65 | int libhibr_compressed_page_map_read_file_io_handle( 66 | libhibr_compressed_page_map_t *compressed_page_map, 67 | libhibr_io_handle_t *io_handle, 68 | libbfio_handle_t *file_io_handle, 69 | off64_t file_offset, 70 | libcerror_error_t **error ); 71 | 72 | #if defined( __cplusplus ) 73 | } 74 | #endif 75 | 76 | #endif /* !defined( _LIBHIBR_COMPRESSED_PAGE_MAP_H ) */ 77 | 78 | -------------------------------------------------------------------------------- /libhibr/libhibr_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Debug functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "libhibr_debug.h" 26 | #include "libhibr_libbfio.h" 27 | #include "libhibr_libcerror.h" 28 | #include "libhibr_libcnotify.h" 29 | 30 | #if defined( HAVE_DEBUG_OUTPUT ) 31 | 32 | /* Prints the read offsets 33 | * Returns 1 if successful or -1 on error 34 | */ 35 | int libhibr_debug_print_read_offsets( 36 | libbfio_handle_t *file_io_handle, 37 | libcerror_error_t **error ) 38 | { 39 | static char *function = "libhibr_debug_print_read_offsets"; 40 | off64_t offset = 0; 41 | size64_t size = 0; 42 | int number_of_offsets = 0; 43 | int offset_iterator = 0; 44 | 45 | if( file_io_handle == NULL ) 46 | { 47 | libcerror_error_set( 48 | error, 49 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, 50 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, 51 | "%s: invalid file IO handle.", 52 | function ); 53 | 54 | return( -1 ); 55 | } 56 | if( libbfio_handle_get_number_of_offsets_read( 57 | file_io_handle, 58 | &number_of_offsets, 59 | error ) != 1 ) 60 | { 61 | libcerror_error_set( 62 | error, 63 | LIBCERROR_ERROR_DOMAIN_RUNTIME, 64 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, 65 | "%s: unable to retrieve number of offsets read.", 66 | function ); 67 | 68 | return( -1 ); 69 | } 70 | libcnotify_printf( 71 | "Offsets read:\n" ); 72 | 73 | for( offset_iterator = 0; 74 | offset_iterator < number_of_offsets; 75 | offset_iterator++ ) 76 | { 77 | if( libbfio_handle_get_offset_read( 78 | file_io_handle, 79 | offset_iterator, 80 | &offset, 81 | &size, 82 | error ) != 1 ) 83 | { 84 | libcerror_error_set( 85 | error, 86 | LIBCERROR_ERROR_DOMAIN_RUNTIME, 87 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, 88 | "%s: unable to retrieve offset: %d.", 89 | function, 90 | offset_iterator ); 91 | 92 | return( -1 ); 93 | } 94 | libcnotify_printf( 95 | "%08" PRIi64 " ( 0x%08" PRIx64 " ) - %08" PRIi64 " ( 0x%08" PRIx64 " ) size: %" PRIi64 "\n", 96 | offset, 97 | offset, 98 | offset + (off64_t) size, 99 | offset + (off64_t) size, 100 | size ); 101 | } 102 | libcnotify_printf( 103 | "\n" ); 104 | 105 | return( 1 ); 106 | } 107 | 108 | #endif 109 | 110 | -------------------------------------------------------------------------------- /libhibr/libhibr_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Debug functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_DEBUG_H ) 23 | #define _LIBHIBR_DEBUG_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libhibr_libbfio.h" 29 | #include "libhibr_libcerror.h" 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | #if defined( HAVE_DEBUG_OUTPUT ) 36 | 37 | int libhibr_debug_print_read_offsets( 38 | libbfio_handle_t *file_io_handle, 39 | libcerror_error_t **error ); 40 | 41 | #endif 42 | 43 | #if defined( __cplusplus ) 44 | } 45 | #endif 46 | 47 | #endif /* !defined( _LIBHIBR_DEBUG_H ) */ 48 | 49 | -------------------------------------------------------------------------------- /libhibr/libhibr_definitions.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal definitions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_INTERNAL_DEFINITIONS_H ) 23 | #define _LIBHIBR_INTERNAL_DEFINITIONS_H 24 | 25 | #include 26 | #include 27 | 28 | #define LIBHIBR_ENDIAN_BIG _BYTE_STREAM_ENDIAN_BIG 29 | #define LIBHIBR_ENDIAN_LITTLE _BYTE_STREAM_ENDIAN_LITTLE 30 | 31 | /* Define HAVE_LOCAL_LIBHIBR for local use of libhibr 32 | */ 33 | #if !defined( HAVE_LOCAL_LIBHIBR ) 34 | #include 35 | 36 | /* The definitions in are copied here 37 | * for local use of libhibr 38 | */ 39 | #else 40 | #define LIBHIBR_VERSION @VERSION@ 41 | 42 | /* The version string 43 | */ 44 | #define LIBHIBR_VERSION_STRING "@VERSION@" 45 | 46 | /* The access flags definitions 47 | * bit 1 set to 1 for read access 48 | * bit 2 set to 1 for write access 49 | * bit 3-8 not used 50 | */ 51 | enum LIBHIBR_ACCESS_FLAGS 52 | { 53 | LIBHIBR_ACCESS_FLAG_READ = 0x01, 54 | /* Reserved: not supported yet */ 55 | LIBHIBR_ACCESS_FLAG_WRITE = 0x02 56 | }; 57 | 58 | /* The file access macros 59 | */ 60 | #define LIBHIBR_OPEN_READ ( LIBHIBR_ACCESS_FLAG_READ ) 61 | /* Reserved: not supported yet */ 62 | #define LIBHIBR_OPEN_WRITE ( LIBHIBR_ACCESS_FLAG_WRITE ) 63 | /* Reserved: not supported yet */ 64 | #define LIBHIBR_OPEN_READ_WRITE ( LIBHIBR_ACCESS_FLAG_READ | LIBHIBR_ACCESS_FLAG_WRITE ) 65 | 66 | /* The file type definitions 67 | */ 68 | enum LIBHIBR_FILE_TYPES 69 | { 70 | LIBHIBR_FILE_TYPE_UNDEFINED, 71 | LIBHIBR_FILE_TYPE_WINDOWS_XP_32BIT, 72 | LIBHIBR_FILE_TYPE_WINDOWS_XP_64BIT, 73 | LIBHIBR_FILE_TYPE_WINDOWS_7_32BIT, 74 | LIBHIBR_FILE_TYPE_WINDOWS_7_64BIT, 75 | }; 76 | 77 | #define LIBHIBR_FILE_TYPE_WINDOWS_2003_32BIT LIBHIBR_FILE_TYPE_WINDOWS_XP_32BIT 78 | #define LIBHIBR_FILE_TYPE_WINDOWS_2003_64BIT LIBHIBR_FILE_TYPE_WINDOWS_XP_64BIT 79 | 80 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 81 | 82 | /* The maximum number of cache entries definitions 83 | */ 84 | #define LIBHIBR_MAXIMUM_CACHE_ENTRIES_COMPRESSED_PAGE_DATA 1024 85 | 86 | #endif 87 | 88 | -------------------------------------------------------------------------------- /libhibr/libhibr_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Error functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "libhibr_error.h" 27 | #include "libhibr_libcerror.h" 28 | 29 | #if !defined( HAVE_LOCAL_LIBHIBR ) 30 | 31 | /* Free an error and its elements 32 | */ 33 | void libhibr_error_free( 34 | libhibr_error_t **error ) 35 | { 36 | libcerror_error_free( 37 | (libcerror_error_t **) error ); 38 | } 39 | 40 | /* Prints a descriptive string of the error to the stream 41 | * Returns the number of printed characters if successful or -1 on error 42 | */ 43 | int libhibr_error_fprint( 44 | libhibr_error_t *error, 45 | FILE *stream ) 46 | { 47 | int print_count = 0; 48 | 49 | print_count = libcerror_error_fprint( 50 | (libcerror_error_t *) error, 51 | stream ); 52 | 53 | return( print_count ); 54 | } 55 | 56 | /* Prints a descriptive string of the error to the string 57 | * The end-of-string character is not included in the return value 58 | * Returns the number of printed characters if successful or -1 on error 59 | */ 60 | int libhibr_error_sprint( 61 | libhibr_error_t *error, 62 | char *string, 63 | size_t size ) 64 | { 65 | int print_count = 0; 66 | 67 | print_count = libcerror_error_sprint( 68 | (libcerror_error_t *) error, 69 | string, 70 | size ); 71 | 72 | return( print_count ); 73 | } 74 | 75 | /* Prints a backtrace of the error to the stream 76 | * Returns the number of printed characters if successful or -1 on error 77 | */ 78 | int libhibr_error_backtrace_fprint( 79 | libhibr_error_t *error, 80 | FILE *stream ) 81 | { 82 | int print_count = 0; 83 | 84 | print_count = libcerror_error_backtrace_fprint( 85 | (libcerror_error_t *) error, 86 | stream ); 87 | 88 | return( print_count ); 89 | } 90 | 91 | /* Prints a backtrace of the error to the string 92 | * The end-of-string character is not included in the return value 93 | * Returns the number of printed characters if successful or -1 on error 94 | */ 95 | int libhibr_error_backtrace_sprint( 96 | libhibr_error_t *error, 97 | char *string, 98 | size_t size ) 99 | { 100 | int print_count = 0; 101 | 102 | print_count = libcerror_error_backtrace_sprint( 103 | (libcerror_error_t *) error, 104 | string, 105 | size ); 106 | 107 | return( print_count ); 108 | } 109 | 110 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 111 | 112 | -------------------------------------------------------------------------------- /libhibr/libhibr_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Error functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_INTERNAL_ERROR_H ) 23 | #define _LIBHIBR_INTERNAL_ERROR_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #if !defined( HAVE_LOCAL_LIBHIBR ) 30 | #include 31 | #endif 32 | 33 | #include "libhibr_extern.h" 34 | 35 | #if defined( __cplusplus ) 36 | extern "C" { 37 | #endif 38 | 39 | #if !defined( HAVE_LOCAL_LIBHIBR ) 40 | 41 | LIBHIBR_EXTERN \ 42 | void libhibr_error_free( 43 | libhibr_error_t **error ); 44 | 45 | LIBHIBR_EXTERN \ 46 | int libhibr_error_fprint( 47 | libhibr_error_t *error, 48 | FILE *stream ); 49 | 50 | LIBHIBR_EXTERN \ 51 | int libhibr_error_sprint( 52 | libhibr_error_t *error, 53 | char *string, 54 | size_t size ); 55 | 56 | LIBHIBR_EXTERN \ 57 | int libhibr_error_backtrace_fprint( 58 | libhibr_error_t *error, 59 | FILE *stream ); 60 | 61 | LIBHIBR_EXTERN \ 62 | int libhibr_error_backtrace_sprint( 63 | libhibr_error_t *error, 64 | char *string, 65 | size_t size ); 66 | 67 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 68 | 69 | #if defined( __cplusplus ) 70 | } 71 | #endif 72 | 73 | #endif /* !defined( _LIBHIBR_INTERNAL_ERROR_H ) */ 74 | 75 | -------------------------------------------------------------------------------- /libhibr/libhibr_extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal extern definition 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_INTERNAL_EXTERN_H ) 23 | #define _LIBHIBR_INTERNAL_EXTERN_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBHIBR for local use of libhibr 28 | */ 29 | #if !defined( HAVE_LOCAL_LIBHIBR ) 30 | 31 | #include 32 | 33 | #if defined( __CYGWIN__ ) || defined( __MINGW32__ ) 34 | #define LIBHIBR_EXTERN_VARIABLE extern 35 | #else 36 | #define LIBHIBR_EXTERN_VARIABLE LIBHIBR_EXTERN 37 | #endif 38 | 39 | #else 40 | #define LIBHIBR_EXTERN /* extern */ 41 | #define LIBHIBR_EXTERN_VARIABLE extern 42 | 43 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 44 | 45 | #endif /* !defined( _LIBHIBR_INTERNAL_EXTERN_H ) */ 46 | 47 | -------------------------------------------------------------------------------- /libhibr/libhibr_i18n.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Internationalization (i18n) functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #if defined( HAVE_LIBINTL_H ) && defined( ENABLE_NLS ) 26 | #include 27 | #endif 28 | 29 | #include "libhibr_i18n.h" 30 | #include "libhibr_libcerror.h" 31 | 32 | static int libhibr_i18n_initialized = 0; 33 | 34 | /* Initializes library internationalization functions 35 | */ 36 | int libhibr_i18n_initialize( 37 | libcerror_error_t **error ) 38 | { 39 | static char *function = "libhibr_i18n_initialize"; 40 | 41 | if( libhibr_i18n_initialized == 0 ) 42 | { 43 | #if defined( HAVE_BINDTEXTDOMAIN ) && defined( LOCALEDIR ) 44 | if( bindtextdomain( 45 | "libhibr", 46 | LOCALEDIR ) == NULL ) 47 | { 48 | libcerror_error_set( 49 | error, 50 | LIBCERROR_ERROR_DOMAIN_RUNTIME, 51 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, 52 | "%s: unable to bind text domain.", 53 | function ); 54 | 55 | return( -1 ); 56 | } 57 | #endif /* defined( HAVE_BINDTEXTDOMAIN ) && defined( LOCALEDIR ) */ 58 | 59 | libhibr_i18n_initialized = 1; 60 | } 61 | return( 1 ); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /libhibr/libhibr_i18n.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internationalization (i18n) functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_I18N_H ) 23 | #define _LIBHIBR_I18N_H 24 | 25 | #include 26 | #include 27 | 28 | #if defined( HAVE_LIBINTL_H ) && defined( ENABLE_NLS ) 29 | #include 30 | #endif 31 | 32 | #include "libhibr_libcerror.h" 33 | 34 | /* TODO 35 | #include 36 | 37 | #define _( string ) \ 38 | dgettext( "libhibr", string ) 39 | */ 40 | #define _( string ) \ 41 | string 42 | 43 | #if defined( __cplusplus ) 44 | extern "C" { 45 | #endif 46 | 47 | int libhibr_i18n_initialize( 48 | libcerror_error_t **error ); 49 | 50 | #if defined( __cplusplus ) 51 | } 52 | #endif 53 | 54 | #endif /* !defined( _LIBHIBR_I18N_H ) */ 55 | 56 | -------------------------------------------------------------------------------- /libhibr/libhibr_io_handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Input/Output (IO) handle functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_IO_HANDLE_H ) 23 | #define _LIBHIBR_IO_HANDLE_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libhibr_libbfio.h" 29 | #include "libhibr_libcerror.h" 30 | #include "libhibr_libfdata.h" 31 | 32 | #if defined( __cplusplus ) 33 | extern "C" { 34 | #endif 35 | 36 | extern const uint8_t *hibr_file_signature; 37 | 38 | typedef struct libhibr_io_handle libhibr_io_handle_t; 39 | 40 | struct libhibr_io_handle 41 | { 42 | /* The file type 43 | */ 44 | int file_type; 45 | 46 | /* The page size 47 | */ 48 | size_t page_size; 49 | 50 | /* The compressed hibernated memory blocks page number 51 | */ 52 | uint32_t memory_blocks_page_number; 53 | }; 54 | 55 | int libhibr_io_handle_initialize( 56 | libhibr_io_handle_t **io_handle, 57 | libcerror_error_t **error ); 58 | 59 | int libhibr_io_handle_free( 60 | libhibr_io_handle_t **io_handle, 61 | libcerror_error_t **error ); 62 | 63 | int libhibr_io_handle_clear( 64 | libhibr_io_handle_t *io_handle, 65 | libcerror_error_t **error ); 66 | 67 | int libhibr_io_handle_read_memory_image_information( 68 | libhibr_io_handle_t *io_handle, 69 | libbfio_handle_t *file_io_handle, 70 | libcerror_error_t **error ); 71 | 72 | int libhibr_io_handle_read_compressed_page_data( 73 | intptr_t *io_handle, 74 | libbfio_handle_t *file_io_handle, 75 | libfdata_list_element_t *list_element, 76 | libfdata_cache_t *cache, 77 | int element_data_file_index, 78 | off64_t element_data_offset, 79 | size64_t element_data_size, 80 | uint32_t element_data_flags, 81 | uint8_t read_flags, 82 | libcerror_error_t **error ); 83 | 84 | #if defined( __cplusplus ) 85 | } 86 | #endif 87 | 88 | #endif /* !defined( _LIBHIBR_IO_HANDLE_H ) */ 89 | 90 | -------------------------------------------------------------------------------- /libhibr/libhibr_libbfio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libbfio header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBBFIO_H ) 23 | #define _LIBHIBR_LIBBFIO_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBBFIO for local use of libbfio 28 | */ 29 | #if defined( HAVE_LOCAL_LIBBFIO ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBBFIO_DLL_IMPORT 43 | * before including libbfio.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 46 | #define LIBBFIO_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( LIBBFIO_HAVE_MULTI_THREAD_SUPPORT ) 52 | #error Multi-threading support requires libbfio with multi-threading support 53 | #endif 54 | 55 | #endif /* defined( HAVE_LOCAL_LIBBFIO ) */ 56 | 57 | #endif /* !defined( _LIBHIBR_LIBBFIO_H ) */ 58 | 59 | -------------------------------------------------------------------------------- /libhibr/libhibr_libcdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcdata header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBCDATA_H ) 23 | #define _LIBHIBR_LIBCDATA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCDATA for local use of libcdata 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCDATA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBCDATA_DLL_IMPORT 43 | * before including libcdata.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 46 | #define LIBCDATA_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #endif /* defined( HAVE_LOCAL_LIBCDATA ) */ 52 | 53 | #endif /* !defined( _LIBHIBR_LIBCDATA_H ) */ 54 | 55 | -------------------------------------------------------------------------------- /libhibr/libhibr_libcerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcerror header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBCERROR_H ) 23 | #define _LIBHIBR_LIBCERROR_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCERROR for local use of libcerror 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCERROR ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCERROR_DLL_IMPORT 39 | * before including libcerror.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCERROR_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCERROR ) */ 48 | 49 | #endif /* !defined( _LIBHIBR_LIBCERROR_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libhibr/libhibr_libclocale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libclocale header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBCLOCALE_H ) 23 | #define _LIBHIBR_LIBCLOCALE_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCLOCALE for local use of libclocale 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCLOCALE ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCLOCALE_DLL_IMPORT 39 | * before including libclocale.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCLOCALE_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCLOCALE ) */ 48 | 49 | #endif /* !defined( _LIBHIBR_LIBCLOCALE_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libhibr/libhibr_libcnotify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcnotify header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBCNOTIFY_H ) 23 | #define _LIBHIBR_LIBCNOTIFY_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCNOTIFY for local use of libcnotify 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCNOTIFY ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCNOTIFY_DLL_IMPORT 39 | * before including libcnotify.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCNOTIFY_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCNOTIFY ) */ 48 | 49 | #endif /* !defined( _LIBHIBR_LIBCNOTIFY_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libhibr/libhibr_libfcache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libfcache header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBFCACHE_H ) 23 | #define _LIBHIBR_LIBFCACHE_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBFCACHE for local use of libfcache 28 | */ 29 | #if defined( HAVE_LOCAL_LIBFCACHE ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBFCACHE_DLL_IMPORT 39 | * before including libfcache.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBFCACHE_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBFCACHE ) */ 48 | 49 | #endif /* !defined( _LIBHIBR_LIBFCACHE_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /libhibr/libhibr_libfdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libfdata header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBFDATA_H ) 23 | #define _LIBHIBR_LIBFDATA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBFDATA for local use of libfdata 28 | */ 29 | #if defined( HAVE_LOCAL_LIBFDATA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBFDATA_DLL_IMPORT 43 | * before including libfdata.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 46 | #define LIBFDATA_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #endif /* defined( HAVE_LOCAL_LIBFDATA ) */ 52 | 53 | #endif /* !defined( _LIBHIBR_LIBFDATA_H ) */ 54 | 55 | -------------------------------------------------------------------------------- /libhibr/libhibr_libfdatetime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libfdatetime header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBFDATETIME_H ) 23 | #define _LIBHIBR_LIBFDATETIME_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBFDATETIME for local use of libfdatetime 28 | */ 29 | #if defined( HAVE_LOCAL_LIBFDATETIME ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #else 43 | 44 | /* If libtool DLL support is enabled set LIBFDATETIME_DLL_IMPORT 45 | * before including libfdatetime.h 46 | */ 47 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 48 | #define LIBFDATETIME_DLL_IMPORT 49 | #endif 50 | 51 | #include 52 | 53 | #endif /* defined( HAVE_LOCAL_LIBFDATETIME ) */ 54 | 55 | #endif /* !defined( _LIBHIBR_LIBFDATETIME_H ) */ 56 | 57 | -------------------------------------------------------------------------------- /libhibr/libhibr_libfwnt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libfwnt header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBFWNT_H ) 23 | #define _LIBHIBR_LIBFWNT_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBFWNT for local use of libfwnt 28 | */ 29 | #if defined( HAVE_LOCAL_LIBFWNT ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #else 45 | 46 | /* If libtool DLL support is enabled set LIBFWNT_DLL_IMPORT 47 | * before including libfwnt.h 48 | */ 49 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 50 | #define LIBFWNT_DLL_IMPORT 51 | #endif 52 | 53 | #include 54 | 55 | #endif /* defined( HAVE_LOCAL_LIBFWNT ) */ 56 | 57 | #endif /* !defined( _LIBHIBR_LIBFWNT_H ) */ 58 | 59 | -------------------------------------------------------------------------------- /libhibr/libhibr_libuna.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libuna header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_LIBUNA_H ) 23 | #define _LIBHIBR_LIBUNA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBUNA for local use of libuna 28 | */ 29 | #if defined( HAVE_LOCAL_LIBUNA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #else 47 | 48 | /* If libtool DLL support is enabled set LIBUNA_DLL_IMPORT 49 | * before including libuna.h 50 | */ 51 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 52 | #define LIBUNA_DLL_IMPORT 53 | #endif 54 | 55 | #include 56 | 57 | #endif /* defined( HAVE_LOCAL_LIBUNA ) */ 58 | 59 | #endif /* !defined( _LIBHIBR_LIBUNA_H ) */ 60 | 61 | -------------------------------------------------------------------------------- /libhibr/libhibr_notify.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Notification functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 27 | #include 28 | #endif 29 | 30 | #include "libhibr_libcerror.h" 31 | #include "libhibr_libcnotify.h" 32 | #include "libhibr_notify.h" 33 | 34 | #if !defined( HAVE_LOCAL_LIBHIBR ) 35 | 36 | /* Sets the verbose notification 37 | */ 38 | void libhibr_notify_set_verbose( 39 | int verbose ) 40 | { 41 | libcnotify_verbose_set( 42 | verbose ); 43 | } 44 | 45 | /* Sets the notification stream 46 | * Returns 1 if successful or -1 on error 47 | */ 48 | int libhibr_notify_set_stream( 49 | FILE *stream, 50 | libcerror_error_t **error ) 51 | { 52 | static char *function = "libhibr_notify_set_stream"; 53 | 54 | if( libcnotify_stream_set( 55 | stream, 56 | error ) != 1 ) 57 | { 58 | libcerror_error_set( 59 | error, 60 | LIBCERROR_ERROR_DOMAIN_RUNTIME, 61 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, 62 | "%s: unable to set stream.", 63 | function ); 64 | 65 | return( -1 ); 66 | } 67 | return( 1 ); 68 | } 69 | 70 | /* Opens the notification stream using a filename 71 | * The stream is opened in append mode 72 | * Returns 1 if successful or -1 on error 73 | */ 74 | int libhibr_notify_stream_open( 75 | const char *filename, 76 | libcerror_error_t **error ) 77 | { 78 | static char *function = "libhibr_notify_stream_open"; 79 | 80 | if( libcnotify_stream_open( 81 | filename, 82 | error ) != 1 ) 83 | { 84 | libcerror_error_set( 85 | error, 86 | LIBCERROR_ERROR_DOMAIN_IO, 87 | LIBCERROR_IO_ERROR_OPEN_FAILED, 88 | "%s: unable to open stream.", 89 | function ); 90 | 91 | return( -1 ); 92 | } 93 | return( 1 ); 94 | } 95 | 96 | /* Closes the notification stream if opened using a filename 97 | * Returns 0 if successful or -1 on error 98 | */ 99 | int libhibr_notify_stream_close( 100 | libcerror_error_t **error ) 101 | { 102 | static char *function = "libhibr_notify_stream_close"; 103 | 104 | if( libcnotify_stream_close( 105 | error ) != 0 ) 106 | { 107 | libcerror_error_set( 108 | error, 109 | LIBCERROR_ERROR_DOMAIN_IO, 110 | LIBCERROR_IO_ERROR_OPEN_FAILED, 111 | "%s: unable to open stream.", 112 | function ); 113 | 114 | return( -1 ); 115 | } 116 | return( 0 ); 117 | } 118 | 119 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 120 | 121 | -------------------------------------------------------------------------------- /libhibr/libhibr_notify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Notification functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_NOTIFY_H ) 23 | #define _LIBHIBR_NOTIFY_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "libhibr_extern.h" 30 | #include "libhibr_libcerror.h" 31 | 32 | #if defined( __cplusplus ) 33 | extern "C" { 34 | #endif 35 | 36 | #if !defined( HAVE_LOCAL_LIBHIBR ) 37 | 38 | LIBHIBR_EXTERN \ 39 | void libhibr_notify_set_verbose( 40 | int verbose ); 41 | 42 | LIBHIBR_EXTERN \ 43 | int libhibr_notify_set_stream( 44 | FILE *stream, 45 | libcerror_error_t **error ); 46 | 47 | LIBHIBR_EXTERN \ 48 | int libhibr_notify_stream_open( 49 | const char *filename, 50 | libcerror_error_t **error ); 51 | 52 | LIBHIBR_EXTERN \ 53 | int libhibr_notify_stream_close( 54 | libcerror_error_t **error ); 55 | 56 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 57 | 58 | #if defined( __cplusplus ) 59 | } 60 | #endif 61 | 62 | #endif /* !defined( _LIBHIBR_NOTIFY_H ) */ 63 | 64 | -------------------------------------------------------------------------------- /libhibr/libhibr_support.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Support functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_SUPPORT_H ) 23 | #define _LIBHIBR_SUPPORT_H 24 | 25 | #include 26 | #include 27 | 28 | #include "libhibr_extern.h" 29 | #include "libhibr_libbfio.h" 30 | #include "libhibr_libcerror.h" 31 | 32 | #if defined( __cplusplus ) 33 | extern "C" { 34 | #endif 35 | 36 | #if !defined( HAVE_LOCAL_LIBHIBR ) 37 | 38 | LIBHIBR_EXTERN \ 39 | const char *libhibr_get_version( 40 | void ); 41 | 42 | LIBHIBR_EXTERN \ 43 | int libhibr_get_access_flags_read( 44 | void ); 45 | 46 | LIBHIBR_EXTERN \ 47 | int libhibr_get_access_flags_read_write( 48 | void ); 49 | 50 | LIBHIBR_EXTERN \ 51 | int libhibr_get_access_flags_write( 52 | void ); 53 | 54 | LIBHIBR_EXTERN \ 55 | int libhibr_get_codepage( 56 | int *codepage, 57 | libcerror_error_t **error ); 58 | 59 | LIBHIBR_EXTERN \ 60 | int libhibr_set_codepage( 61 | int codepage, 62 | libcerror_error_t **error ); 63 | 64 | #endif /* !defined( HAVE_LOCAL_LIBHIBR ) */ 65 | 66 | LIBHIBR_EXTERN \ 67 | int libhibr_check_file_signature( 68 | const char *filename, 69 | libcerror_error_t **error ); 70 | 71 | #if defined( HAVE_WIDE_CHARACTER_TYPE ) 72 | LIBHIBR_EXTERN \ 73 | int libhibr_check_file_signature_wide( 74 | const wchar_t *filename, 75 | libcerror_error_t **error ); 76 | #endif 77 | 78 | LIBHIBR_EXTERN \ 79 | int libhibr_check_file_signature_file_io_handle( 80 | libbfio_handle_t *file_io_handle, 81 | libcerror_error_t **error ); 82 | 83 | #if defined( __cplusplus ) 84 | } 85 | #endif 86 | 87 | #endif /* !defined( _LIBHIBR_SUPPORT_H ) */ 88 | 89 | -------------------------------------------------------------------------------- /libhibr/libhibr_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The internal type definitions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_INTERNAL_TYPES_H ) 23 | #define _LIBHIBR_INTERNAL_TYPES_H 24 | 25 | #include 26 | #include 27 | 28 | /* Define HAVE_LOCAL_LIBHIBR for local use of libhibr 29 | * The definitions in are copied here 30 | * for local use of libhibr 31 | */ 32 | #if defined( HAVE_LOCAL_LIBHIBR ) 33 | 34 | /* The following type definitions hide internal data structures 35 | */ 36 | #if defined( HAVE_DEBUG_OUTPUT ) && !defined( WINAPI ) 37 | typedef struct libhibr_file {} libhibr_file_t; 38 | 39 | #else 40 | typedef intptr_t libhibr_file_t; 41 | 42 | #endif /* defined( HAVE_DEBUG_OUTPUT ) && !defined( WINAPI ) */ 43 | 44 | #endif /* defined( HAVE_LOCAL_LIBHIBR ) */ 45 | 46 | #endif /* !defined( _LIBHIBR_INTERNAL_TYPES_H ) */ 47 | 48 | -------------------------------------------------------------------------------- /libhibr/libhibr_unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to silence compiler warnings about unused function attributes/parameters. 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _LIBHIBR_UNUSED_H ) 23 | #define _LIBHIBR_UNUSED_H 24 | 25 | #include 26 | 27 | #if !defined( LIBHIBR_ATTRIBUTE_UNUSED ) 28 | #if defined( __GNUC__ ) && __GNUC__ >= 3 29 | #define LIBHIBR_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 30 | #else 31 | #define LIBHIBR_ATTRIBUTE_UNUSED 32 | #endif 33 | #endif 34 | 35 | #if defined( _MSC_VER ) 36 | #define LIBHIBR_UNREFERENCED_PARAMETER( parameter ) \ 37 | UNREFERENCED_PARAMETER( parameter ); 38 | #else 39 | #define LIBHIBR_UNREFERENCED_PARAMETER( parameter ) \ 40 | /* parameter */ 41 | #endif 42 | 43 | #endif /* !defined( _LIBHIBR_UNUSED_H ) */ 44 | 45 | -------------------------------------------------------------------------------- /m4/pthread.m4: -------------------------------------------------------------------------------- 1 | dnl Functions for pthread 2 | dnl 3 | dnl Version: 20240513 4 | 5 | dnl Function to detect if pthread is available 6 | AC_DEFUN([AX_PTHREAD_CHECK_LIB], 7 | [AS_IF( 8 | [test "x$ac_cv_enable_shared_libs" = xno || test "x$ac_cv_with_pthread" = xno], 9 | [ac_cv_pthread=no], 10 | [ac_cv_pthread=check 11 | dnl Check if parameters were provided 12 | dnl For both --with-pthread which returns "yes" and --with-pthread= which returns "" 13 | dnl treat them as auto-detection. 14 | AS_IF( 15 | [test "x$ac_cv_with_pthread" != x && test "x$ac_cv_with_pthread" != xauto-detect && test "x$ac_cv_with_pthread" != xyes], 16 | [AX_CHECK_LIB_DIRECTORY_EXISTS([pthread])]) 17 | ]) 18 | 19 | AS_IF( 20 | [test "x$ac_cv_pthread" = xcheck], 21 | [dnl Check for headers 22 | AC_CHECK_HEADERS([pthread.h]) 23 | 24 | AS_IF( 25 | [test "x$ac_cv_header_pthread_h" = xno], 26 | [ac_cv_pthread=no], 27 | [ac_cv_pthread=yes 28 | 29 | AX_CHECK_LIB_FUNCTIONS( 30 | [pthread], 31 | [pthread], 32 | [[pthread_create], 33 | [pthread_exit], 34 | [pthread_join], 35 | [pthread_cond_init], 36 | [pthread_cond_destroy], 37 | [pthread_cond_broadcast], 38 | [pthread_cond_signal], 39 | [pthread_cond_wait], 40 | [pthread_mutex_init], 41 | [pthread_mutex_destroy], 42 | [pthread_mutex_lock], 43 | [pthread_mutex_trylock], 44 | [pthread_mutex_unlock], 45 | [pthread_rwlock_init], 46 | [pthread_rwlock_destroy], 47 | [pthread_rwlock_rdlock], 48 | [pthread_rwlock_wrlock], 49 | [pthread_rwlock_unlock]]) 50 | 51 | ac_cv_pthread_LIBADD="-lpthread" 52 | ]) 53 | 54 | AX_CHECK_LIB_DIRECTORY_MSG_ON_FAILURE([pthread]) 55 | ]) 56 | 57 | AS_IF( 58 | [test "x$ac_cv_pthread" = xpthread], 59 | [AC_DEFINE( 60 | [HAVE_PTHREAD], 61 | [1], 62 | [Define to 1 if you have the 'pthread' library (-lpthread).]) 63 | ]) 64 | 65 | AS_IF( 66 | [test "x$ac_cv_pthread" != xno], 67 | [AC_SUBST( 68 | [HAVE_PTHREAD], 69 | [1]) ], 70 | [AC_SUBST( 71 | [HAVE_PTHREAD], 72 | [0]) 73 | ]) 74 | ]) 75 | 76 | dnl Function to detect how to enable pthread 77 | AC_DEFUN([AX_PTHREAD_CHECK_ENABLE], 78 | [AX_COMMON_ARG_WITH( 79 | [pthread], 80 | [pthread], 81 | [search for pthread in includedir and libdir or in the specified DIR, or no if not to use pthread], 82 | [auto-detect], 83 | [DIR]) 84 | 85 | dnl Check for a shared library version 86 | AX_PTHREAD_CHECK_LIB 87 | 88 | AS_IF( 89 | [test "x$ac_cv_pthread_CPPFLAGS" != "x"], 90 | [AC_SUBST( 91 | [PTHREAD_CPPFLAGS], 92 | [$ac_cv_pthread_CPPFLAGS]) 93 | ]) 94 | AS_IF( 95 | [test "x$ac_cv_pthread_LIBADD" != "x"], 96 | [AC_SUBST( 97 | [PTHREAD_LIBADD], 98 | [$ac_cv_pthread_LIBADD]) 99 | ]) 100 | 101 | AS_IF( 102 | [test "x$ac_cv_pthread" = xpthread], 103 | [AC_SUBST( 104 | [ax_pthread_pc_libs_private], 105 | [-lpthread]) 106 | ]) 107 | ]) 108 | 109 | -------------------------------------------------------------------------------- /m4/tests.m4: -------------------------------------------------------------------------------- 1 | dnl Functions for testing 2 | dnl 3 | dnl Version: 20200712 4 | 5 | dnl Function to detect if tests dependencies are available 6 | AC_DEFUN([AX_TESTS_CHECK_LOCAL], 7 | [AC_CHECK_HEADERS([dlfcn.h]) 8 | 9 | AC_CHECK_FUNCS([fmemopen getopt mkstemp setenv tzset unlink]) 10 | 11 | AC_CHECK_LIB( 12 | dl, 13 | dlsym) 14 | 15 | AS_IF( 16 | [test "x$lt_cv_prog_gnu_ld" = xyes && test "x$ac_cv_lib_dl_dlsym" = xyes], 17 | [AC_DEFINE( 18 | [HAVE_GNU_DL_DLSYM], 19 | [1], 20 | [Define to 1 if dlsym function is available in GNU dl.]) 21 | ]) 22 | ]) 23 | 24 | dnl Function to detect if OSS-Fuzz build environment is available 25 | AC_DEFUN([AX_TESTS_CHECK_OSSFUZZ], 26 | [AM_CONDITIONAL( 27 | HAVE_LIB_FUZZING_ENGINE, 28 | [test "x${LIB_FUZZING_ENGINE}" != x]) 29 | AC_SUBST( 30 | [LIB_FUZZING_ENGINE], 31 | ["${LIB_FUZZING_ENGINE}"]) 32 | ]) 33 | 34 | -------------------------------------------------------------------------------- /m4/types.m4: -------------------------------------------------------------------------------- 1 | dnl Functions for type definitions 2 | dnl 3 | dnl Version: 20180727 4 | 5 | dnl Function to detect if type definitions are available 6 | AC_DEFUN([AX_TYPES_CHECK_LOCAL], 7 | [AS_IF( 8 | [test "x$ac_cv_enable_winapi" = xyes], 9 | [ac_cv_enable_wide_character_type=yes]) 10 | 11 | AS_IF( 12 | [test "x$ac_cv_enable_wide_character_type" = xyes], 13 | [AC_DEFINE( 14 | [HAVE_WIDE_CHARACTER_TYPE], 15 | [1], 16 | [Define to 1 if wide character type should be used.]) 17 | AC_SUBST( 18 | [HAVE_WIDE_CHARACTER_TYPE], 19 | [1]) ], 20 | [AC_SUBST( 21 | [HAVE_WIDE_CHARACTER_TYPE], 22 | [0]) 23 | ]) 24 | 25 | AC_CHECK_HEADERS([sys/types.h inttypes.h stdint.h wchar.h]) 26 | 27 | AS_IF( 28 | [test "x$ac_cv_header_sys_types_h" = xyes], 29 | [AC_SUBST( 30 | [HAVE_SYS_TYPES_H], 31 | [1])], 32 | [AC_SUBST( 33 | [HAVE_SYS_TYPES_H], 34 | [0]) 35 | ]) 36 | 37 | AS_IF( 38 | [test "x$ac_cv_header_inttypes_h" = xyes], 39 | [AC_SUBST( 40 | [HAVE_INTTYPES_H], 41 | [1])], 42 | [AC_SUBST( 43 | [HAVE_INTTYPES_H], 44 | [0]) 45 | ]) 46 | 47 | AS_IF( 48 | [test "x$ac_cv_header_stdint_h" = xyes], 49 | [AC_SUBST( 50 | [HAVE_STDINT_H], 51 | [1])], 52 | [AC_SUBST( 53 | [HAVE_STDINT_H], 54 | [0]) 55 | ]) 56 | 57 | AS_IF( 58 | [test "x$ac_cv_header_wchar_h" = xyes], 59 | [AC_SUBST( 60 | [HAVE_WCHAR_H], 61 | [1]) ], 62 | [AC_SUBST( 63 | [HAVE_WCHAR_H], 64 | [0]) 65 | ]) 66 | 67 | AC_TYPE_MODE_T 68 | AC_TYPE_OFF_T 69 | AC_TYPE_SIZE_T 70 | 71 | AC_CHECK_TYPE( 72 | [size32_t], 73 | [AC_SUBST( 74 | [HAVE_SIZE32_T], 75 | [1])], 76 | [AC_SUBST( 77 | [HAVE_SIZE32_T], 78 | [0]) 79 | ]) 80 | 81 | AC_CHECK_TYPE( 82 | [ssize32_t], 83 | [AC_SUBST( 84 | [HAVE_SSIZE32_T], 85 | [1])], 86 | [AC_SUBST( 87 | [HAVE_SSIZE32_T], 88 | [0]) 89 | ]) 90 | 91 | AC_CHECK_TYPE( 92 | [size64_t], 93 | [AC_SUBST( 94 | [HAVE_SIZE64_T], 95 | [1])], 96 | [AC_SUBST( 97 | [HAVE_SIZE64_T], 98 | [0]) 99 | ]) 100 | 101 | AC_CHECK_TYPE( 102 | [ssize64_t], 103 | [AC_SUBST( 104 | [HAVE_SSIZE64_T], 105 | [1])], 106 | [AC_SUBST( 107 | [HAVE_SSIZE64_T], 108 | [0]) 109 | ]) 110 | 111 | AC_CHECK_TYPE( 112 | [off64_t], 113 | [AC_SUBST( 114 | [HAVE_OFF64_T], 115 | [1])], 116 | [AC_SUBST( 117 | [HAVE_OFF64_T], 118 | [0]) 119 | ]) 120 | 121 | AC_CHECK_TYPE([ssize_t]) 122 | AC_CHECK_TYPE([u64]) 123 | 124 | AC_CHECK_SIZEOF([int]) 125 | AC_CHECK_SIZEOF([long]) 126 | AC_CHECK_SIZEOF([off_t]) 127 | AC_CHECK_SIZEOF([size_t]) 128 | 129 | AS_IF( 130 | [test "x$ac_cv_header_wchar_h" = xyes], 131 | [AC_CHECK_SIZEOF([wchar_t])]) 132 | ]) 133 | 134 | -------------------------------------------------------------------------------- /manuals/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS = \ 2 | hibrinfo.1 \ 3 | libhibr.3 4 | 5 | EXTRA_DIST = \ 6 | hibrinfo.1 \ 7 | libhibr.3 8 | 9 | DISTCLEANFILES = \ 10 | Makefile \ 11 | Makefile.in 12 | 13 | -------------------------------------------------------------------------------- /manuals/hibrinfo.1: -------------------------------------------------------------------------------- 1 | .Dd September 20, 2019 2 | .Dt hibrinfo 3 | .Os libhibr 4 | .Sh NAME 5 | .Nm hibrinfo 6 | .Nd determines information about a Windows Hibernation File (hiberfil.sys) 7 | .Sh SYNOPSIS 8 | .Nm hibrinfo 9 | .Op Fl hvV 10 | .Ar source 11 | .Sh DESCRIPTION 12 | .Nm hibrinfo 13 | is a utility to determine information about a Windows Hibernation File (hiberfil.sys) 14 | .Pp 15 | .Nm hibrinfo 16 | is part of the 17 | .Nm libhibr 18 | package. 19 | .Nm libhibr 20 | is a library to access the Windows Hibernation File (hiberfil.sys) format 21 | .Pp 22 | .Ar source 23 | is the source file. 24 | .Pp 25 | The options are as follows: 26 | .Bl -tag -width Ds 27 | .It Fl h 28 | shows this help 29 | .It Fl v 30 | verbose output to stderr 31 | .It Fl V 32 | print version 33 | .El 34 | .Sh ENVIRONMENT 35 | None 36 | .Sh FILES 37 | None 38 | .Sh EXAMPLES 39 | .Bd -literal 40 | # hibrinfo hiberfil.sys 41 | hibrinfo 20120915 42 | .sp 43 | Windows Hibernation File information: 44 | .Dl ... 45 | .sp 46 | .Ed 47 | .Sh DIAGNOSTICS 48 | Errors, verbose and debug output are printed to stderr when verbose output \-v is enabled. 49 | Verbose and debug output are only printed when enabled at compilation. 50 | .Sh BUGS 51 | Please report bugs of any kind to or on the project website: 52 | https://github.com/libyal/libhibr/ 53 | .Sh AUTHOR 54 | These man pages were written by Joachim Metz. 55 | .Sh COPYRIGHT 56 | Copyright (C) 2012-2024, Joachim Metz . 57 | .Sh SEE ALSO 58 | -------------------------------------------------------------------------------- /msvscpp/Makefile.am: -------------------------------------------------------------------------------- 1 | MSVSCPP_FILES = \ 2 | hibr_test_compressed_page_data/hibr_test_compressed_page_data.vcproj \ 3 | hibr_test_compressed_page_map/hibr_test_compressed_page_map.vcproj \ 4 | hibr_test_error/hibr_test_error.vcproj \ 5 | hibr_test_file/hibr_test_file.vcproj \ 6 | hibr_test_io_handle/hibr_test_io_handle.vcproj \ 7 | hibr_test_notify/hibr_test_notify.vcproj \ 8 | hibr_test_support/hibr_test_support.vcproj \ 9 | hibrinfo/hibrinfo.vcproj \ 10 | hibrmount/hibrmount.vcproj \ 11 | libbfio/libbfio.vcproj \ 12 | libcdata/libcdata.vcproj \ 13 | libcerror/libcerror.vcproj \ 14 | libcfile/libcfile.vcproj \ 15 | libclocale/libclocale.vcproj \ 16 | libcnotify/libcnotify.vcproj \ 17 | libcpath/libcpath.vcproj \ 18 | libcsplit/libcsplit.vcproj \ 19 | libcthreads/libcthreads.vcproj \ 20 | libfcache/libfcache.vcproj \ 21 | libfdata/libfdata.vcproj \ 22 | libfdatetime/libfdatetime.vcproj \ 23 | libfwnt/libfwnt.vcproj \ 24 | libhibr/libhibr.vcproj \ 25 | libuna/libuna.vcproj \ 26 | libhibr.sln 27 | 28 | EXTRA_DIST = \ 29 | $(MSVSCPP_FILES) 30 | 31 | DISTCLEANFILES = \ 32 | Makefile \ 33 | Makefile.in 34 | 35 | -------------------------------------------------------------------------------- /ossfuzz/Makefile.am: -------------------------------------------------------------------------------- 1 | if HAVE_LIB_FUZZING_ENGINE 2 | AM_CPPFLAGS = \ 3 | -I../include -I$(top_srcdir)/include \ 4 | -I../common -I$(top_srcdir)/common \ 5 | @LIBCERROR_CPPFLAGS@ \ 6 | @LIBCDATA_CPPFLAGS@ \ 7 | @LIBCLOCALE_CPPFLAGS@ \ 8 | @LIBCNOTIFY_CPPFLAGS@ \ 9 | @LIBUNA_CPPFLAGS@ \ 10 | @LIBCFILE_CPPFLAGS@ \ 11 | @LIBCPATH_CPPFLAGS@ \ 12 | @LIBBFIO_CPPFLAGS@ 13 | 14 | bin_PROGRAMS = \ 15 | file_fuzzer 16 | 17 | file_fuzzer_SOURCES = \ 18 | file_fuzzer.cc \ 19 | ossfuzz_libbfio.h \ 20 | ossfuzz_libhibr.h 21 | 22 | file_fuzzer_LDADD = \ 23 | @LIB_FUZZING_ENGINE@ \ 24 | @LIBBFIO_LIBADD@ \ 25 | @LIBCPATH_LIBADD@ \ 26 | @LIBCFILE_LIBADD@ \ 27 | @LIBUNA_LIBADD@ \ 28 | @LIBCDATA_LIBADD@ \ 29 | ../libhibr/libhibr.la \ 30 | @LIBCNOTIFY_LIBADD@ \ 31 | @LIBCLOCALE_LIBADD@ \ 32 | @LIBCERROR_LIBADD@ \ 33 | @LIBINTL@ 34 | endif 35 | 36 | DISTCLEANFILES = \ 37 | Makefile \ 38 | Makefile.in 39 | 40 | splint-local: 41 | @echo "Running splint on file_fuzzer ..." 42 | -splint -preproc -redef $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(file_fuzzer_SOURCES) 43 | 44 | -------------------------------------------------------------------------------- /ossfuzz/file_fuzzer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * OSS-Fuzz target for libhibr file type 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | /* Note that some of the OSS-Fuzz engines use C++ 26 | */ 27 | extern "C" { 28 | 29 | #include "ossfuzz_libhibr.h" 30 | #include "ossfuzz_libbfio.h" 31 | 32 | #if !defined( LIBHIBR_HAVE_BFIO ) 33 | 34 | /* Opens a file using a Basic File IO (bfio) handle 35 | * Returns 1 if successful or -1 on error 36 | */ 37 | LIBHIBR_EXTERN \ 38 | int libhibr_file_open_file_io_handle( 39 | libhibr_file_t *file, 40 | libbfio_handle_t *file_io_handle, 41 | int access_flags, 42 | libhibr_error_t **error ); 43 | 44 | #endif /* !defined( LIBHIBR_HAVE_BFIO ) */ 45 | 46 | int LLVMFuzzerTestOneInput( 47 | const uint8_t *data, 48 | size_t size ) 49 | { 50 | libbfio_handle_t *file_io_handle = NULL; 51 | libhibr_file_t *file = NULL; 52 | 53 | if( libbfio_memory_range_initialize( 54 | &file_io_handle, 55 | NULL ) != 1 ) 56 | { 57 | return( 0 ); 58 | } 59 | if( libbfio_memory_range_set( 60 | file_io_handle, 61 | (uint8_t *) data, 62 | size, 63 | NULL ) != 1 ) 64 | { 65 | goto on_error_libbfio; 66 | } 67 | if( libhibr_file_initialize( 68 | &file, 69 | NULL ) != 1 ) 70 | { 71 | goto on_error_libbfio; 72 | } 73 | if( libhibr_file_open_file_io_handle( 74 | file, 75 | file_io_handle, 76 | LIBHIBR_OPEN_READ, 77 | NULL ) != 1 ) 78 | { 79 | goto on_error_libhibr; 80 | } 81 | libhibr_file_close( 82 | file, 83 | NULL ); 84 | 85 | on_error_libhibr: 86 | libhibr_file_free( 87 | &file, 88 | NULL ); 89 | 90 | on_error_libbfio: 91 | libbfio_handle_free( 92 | &file_io_handle, 93 | NULL ); 94 | 95 | return( 0 ); 96 | } 97 | 98 | } /* extern "C" */ 99 | 100 | -------------------------------------------------------------------------------- /ossfuzz/ossfuzz_libbfio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libbfio header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _OSSFUZZ_LIBBFIO_H ) 23 | #define _OSSFUZZ_LIBBFIO_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBBFIO for local use of libbfio 28 | */ 29 | #if defined( HAVE_LOCAL_LIBBFIO ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBBFIO_DLL_IMPORT 43 | * before including libbfio.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) && !defined( HAVE_STATIC_EXECUTABLES ) 46 | #define LIBBFIO_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( LIBBFIO_HAVE_MULTI_THREAD_SUPPORT ) 52 | #error Multi-threading support requires libbfio with multi-threading support 53 | #endif 54 | 55 | #endif /* defined( HAVE_LOCAL_LIBBFIO ) */ 56 | 57 | #endif /* !defined( _OSSFUZZ_LIBBFIO_H ) */ 58 | 59 | -------------------------------------------------------------------------------- /ossfuzz/ossfuzz_libhibr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libhibr header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _OSSFUZZ_LIBHIBR_H ) 23 | #define _OSSFUZZ_LIBHIBR_H 24 | 25 | #include 26 | 27 | #include 28 | 29 | #endif /* !defined( _OSSFUZZ_LIBHIBR_H ) */ 30 | 31 | -------------------------------------------------------------------------------- /po/ChangeLog: -------------------------------------------------------------------------------- 1 | 2016-11-09 gettextize 2 | -------------------------------------------------------------------------------- /po/Makevars.in: -------------------------------------------------------------------------------- 1 | # Makefile variables for PO directory in any package using GNU gettext. 2 | 3 | # Usually the message domain is the same as the package name. 4 | DOMAIN = @PACKAGE@ 5 | 6 | # These two variables depend on the location of this directory. 7 | subdir = po 8 | top_builddir = .. 9 | 10 | # These options get passed to xgettext. 11 | XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ 12 | 13 | # This is the copyright holder that gets inserted into the header of the 14 | # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 15 | # package. (Note that the msgstr strings, extracted from the package's 16 | # sources, belong to the copyright holder of the package.) Translators are 17 | # expected to transfer the copyright for their translations to this person 18 | # or entity, or to disclaim their copyright. The empty string stands for 19 | # the public domain; in this case the translators are expected to disclaim 20 | # their copyright. 21 | COPYRIGHT_HOLDER = Joachim Metz 22 | 23 | # This is the email address or URL to which the translators shall report 24 | # bugs in the untranslated strings: 25 | # - Strings which are not entire sentences, see the maintainer guidelines 26 | # in the GNU gettext documentation, section 'Preparing Strings'. 27 | # - Strings which use unclear terms or require additional context to be 28 | # understood. 29 | # - Strings which make invalid assumptions about notation of date, time or 30 | # money. 31 | # - Pluralisation problems. 32 | # - Incorrect English spelling. 33 | # - Incorrect formatting. 34 | # It can be your email address, or a mailing list address where translators 35 | # can write to without being subscribed, or the URL of a web page through 36 | # which the translators can contact you. 37 | MSGID_BUGS_ADDRESS = @PACKAGE_BUGREPORT@ 38 | 39 | # This is the list of locale categories, beyond LC_MESSAGES, for which the 40 | # message catalogs shall be used. It is usually empty. 41 | EXTRA_LOCALE_CATEGORIES = 42 | 43 | # Additional make targets. 44 | sources splint: 45 | 46 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of source files which contain translatable strings. 2 | -------------------------------------------------------------------------------- /runtests.ps1: -------------------------------------------------------------------------------- 1 | # Script that runs the tests 2 | # 3 | # Version: 20220103 4 | 5 | $ExitSuccess = 0 6 | $ExitFailure = 1 7 | $ExitIgnore = 77 8 | 9 | Set-Location -Path "tests" 10 | 11 | $Result = ${ExitSuccess} 12 | 13 | $Lines = Get-Content "Makefile.am" 14 | $InTests = $FALSE 15 | 16 | Foreach (${Line} in ${Lines}) 17 | { 18 | If (${InTests}) 19 | { 20 | If (-Not ${Line}) 21 | { 22 | ${InTests} = $FALSE 23 | 24 | Continue 25 | } 26 | ${Line} = ${Line}.TrimStart() 27 | 28 | If (${Line}.EndsWith(" \")) 29 | { 30 | ${Line} = ${Line}.Substring(0, ${Line}.Length - 2) 31 | } 32 | If (-Not (${Line}.EndsWith(".sh"))) 33 | { 34 | Continue 35 | } 36 | ${Line} = ${Line}.Substring(0, ${Line}.Length - 3) 37 | ${Line} = ".\${Line}.ps1" 38 | 39 | Try 40 | { 41 | Invoke-Expression ${Line} 42 | } 43 | Catch 44 | { 45 | $LastExitCode = ${ExitIgnore} 46 | } 47 | If (${LastExitCode} -eq ${ExitFailure}) 48 | { 49 | $Result = ${ExitFailure} 50 | Write-Host "FAIL" -foreground Red -nonewline 51 | } 52 | ElseIf (${LastExitCode} -eq ${ExitIgnore}) 53 | { 54 | Write-Host "SKIP" -foreground Cyan -nonewline 55 | } 56 | Else 57 | { 58 | Write-Host "PASS" -foreground Green -nonewline 59 | } 60 | Write-Host ": ${Line}" 61 | } 62 | ElseIf (${Line}.StartsWith("TESTS = ")) 63 | { 64 | ${InTests} = $TRUE 65 | } 66 | } 67 | 68 | Set-Location -Path ".." 69 | 70 | Exit ${Result} 71 | -------------------------------------------------------------------------------- /syncdokan.ps1: -------------------------------------------------------------------------------- 1 | # Script that synchronizes dokan 2 | # 3 | # Version: 20190810 4 | 5 | Param ( 6 | [switch]$UseHead = $false, 7 | [switch]$UseLegacyVersion = $false 8 | ) 9 | 10 | $Git = "git" 11 | 12 | If (${UseLegacyVersion}) 13 | { 14 | # Patched version of dokan 0.6.0 15 | $GitUrl = "https://github.com/joachimmetz/dokan.git" 16 | $Destination = "..\dokan" 17 | } 18 | Else 19 | { 20 | $GitUrl = "https://github.com/dokan-dev/dokany.git" 21 | $Destination = "..\dokany" 22 | } 23 | 24 | # PowerShell will raise NativeCommandError if git writes to stdout or stderr 25 | # therefore 2>&1 is added and the output is stored in a variable. 26 | $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${Destination} 2>&1" 27 | 28 | Push-Location ${Destination} 29 | 30 | Try 31 | { 32 | $Output = Invoke-Expression -Command "${Git} fetch --quiet --all --tags --prune 2>&1" 33 | 34 | $LatestTag = Invoke-Expression -Command "${Git} describe --tags --abbrev=0 2>&1" 35 | 36 | If (${LatestTag} -and -not ${UseHead}) 37 | { 38 | Write-Host "Synchronizing: dokan from ${GitUrl} tag ${LatestTag}" 39 | 40 | $Output = Invoke-Expression -Command "${Git} checkout --quiet tags/${LatestTag} 2>&1" 41 | } 42 | Else 43 | { 44 | Write-Host "Synchronizing: dokan from ${GitUrl} HEAD" 45 | } 46 | If (-Not ${UseLegacyVersion}) 47 | { 48 | # AppVeyor does not come with platform toolset version 142 49 | ((Get-Content -Path "..\dokany\dokan\dokan.vcxproj" -Raw) -Replace 'v142','v141') | Set-Content -Path "..\dokany\dokan\dokan.vcxproj" 50 | } 51 | } 52 | Finally 53 | { 54 | Pop-Location 55 | } 56 | 57 | -------------------------------------------------------------------------------- /synclibs.ps1: -------------------------------------------------------------------------------- 1 | # Script that synchronizes the local library dependencies 2 | # 3 | # Version: 20180125 4 | 5 | Param ( 6 | [switch]$UseHead = $false 7 | ) 8 | 9 | $GitUrlPrefix = "https://github.com/libyal" 10 | $LocalLibs = "libbfio libcdata libcerror libcfile libclocale libcnotify libcpath libcsplit libcthreads libfcache libfdata libfdatetime libfwnt libuna" 11 | $LocalLibs = ${LocalLibs} -split " " 12 | 13 | $Git = "git" 14 | $WinFlex = "..\win_flex_bison\win_flex.exe" 15 | $WinBison = "..\win_flex_bison\win_bison.exe" 16 | 17 | ForEach (${LocalLib} in ${LocalLibs}) 18 | { 19 | # Split will return an array of a single empty string when LocalLibs is empty. 20 | If (-Not (${LocalLib})) 21 | { 22 | Continue 23 | } 24 | $GitUrl = "${GitUrlPrefix}/${LocalLib}.git" 25 | 26 | # PowerShell will raise NativeCommandError if git writes to stdout or stderr 27 | # therefore 2>&1 is added and the output is stored in a variable. 28 | $Output = Invoke-Expression -Command "${Git} clone ${GitUrl} ${LocalLib}-${pid} 2>&1" 29 | 30 | Push-Location "${LocalLib}-${pid}" 31 | 32 | Try 33 | { 34 | $Output = Invoke-Expression -Command "${Git} fetch --quiet --all --tags --prune 2>&1" 35 | 36 | $LatestTag = Invoke-Expression -Command "${Git} describe --tags --abbrev=0 2>&1" 37 | 38 | If (${LatestTag} -and -not ${UseHead}) 39 | { 40 | Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} tag ${LatestTag}" 41 | 42 | $Output = Invoke-Expression -Command "${Git} checkout --quiet tags/${LatestTag} 2>&1" 43 | } 44 | Else 45 | { 46 | Write-Host "Synchronizing: ${LocalLib} from ${GitUrl} HEAD" 47 | } 48 | } 49 | Finally 50 | { 51 | Pop-Location 52 | } 53 | If (Test-Path ${LocalLib}-${pid}) 54 | { 55 | $LocalLibVersion = Get-Content -Path ${LocalLib}-${pid}\configure.ac | select -skip 4 -first 1 | % { $_ -Replace " \[","" } | % { $_ -Replace "\],","" } 56 | 57 | If (Test-Path ${LocalLib}) 58 | { 59 | Remove-Item -Path ${LocalLib} -Force -Recurse 60 | } 61 | New-Item -ItemType directory -Path ${LocalLib} -Force | Out-Null 62 | 63 | If (Test-Path ${LocalLib}) 64 | { 65 | Copy-Item -Path ${LocalLib}-${pid}\${LocalLib}\*.[chly] -Destination ${LocalLib}\ 66 | Get-Content -Path ${LocalLib}-${pid}\${LocalLib}\${LocalLib}_definitions.h.in | % { $_ -Replace "@VERSION@",${LocalLibVersion} } > ${LocalLib}\${LocalLib}_definitions.h 67 | } 68 | Remove-Item -Path ${LocalLib}-${pid} -Force -Recurse 69 | 70 | $NamePrefix = "" 71 | 72 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.l") 73 | { 74 | $OutputFile = ${DirectoryElement} -Replace ".l$",".c" 75 | 76 | $NamePrefix = Split-Path -path ${DirectoryElement} -leaf 77 | $NamePrefix = ${NamePrefix} -Replace "^${LocalLib}_","" 78 | $NamePrefix = ${NamePrefix} -Replace ".l$","_" 79 | 80 | # PowerShell will raise NativeCommandError if win_flex writes to stdout or stderr 81 | # therefore 2>&1 is added and the output is stored in a variable. 82 | $Output = Invoke-Expression -Command "& '${WinFlex}' -Cf ${DirectoryElement} 2>&1" 83 | Write-Host ${Output} 84 | 85 | # Moving manually sicne win_flex -o does not provide the expected behavior. 86 | Move-Item "lex.yy.c" ${OutputFile} -force 87 | } 88 | 89 | ForEach (${DirectoryElement} in Get-ChildItem -Path "${LocalLib}\*.y") 90 | { 91 | $OutputFile = ${DirectoryElement} -Replace ".y$",".c" 92 | 93 | # PowerShell will raise NativeCommandError if win_bison writes to stdout or stderr 94 | # therefore 2>&1 is added and the output is stored in a variable. 95 | $Output = Invoke-Expression -Command "& '${WinBison}' -d -v -l -p ${NamePrefix} -o ${OutputFile} ${DirectoryElement} 2>&1" 96 | Write-Host ${Output} 97 | } 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = \ 2 | -I../include -I$(top_srcdir)/include \ 3 | -I../common -I$(top_srcdir)/common \ 4 | @LIBCERROR_CPPFLAGS@ \ 5 | @LIBCTHREADS_CPPFLAGS@ \ 6 | @LIBCDATA_CPPFLAGS@ \ 7 | @LIBCLOCALE_CPPFLAGS@ \ 8 | @LIBCNOTIFY_CPPFLAGS@ \ 9 | @LIBCSPLIT_CPPFLAGS@ \ 10 | @LIBUNA_CPPFLAGS@ \ 11 | @LIBCFILE_CPPFLAGS@ \ 12 | @LIBCPATH_CPPFLAGS@ \ 13 | @LIBBFIO_CPPFLAGS@ \ 14 | @LIBFCACHE_CPPFLAGS@ \ 15 | @LIBFDATA_CPPFLAGS@ \ 16 | @LIBFDATETIME_CPPFLAGS@ \ 17 | @LIBFWNT_CPPFLAGS@ \ 18 | @PTHREAD_CPPFLAGS@ \ 19 | @LIBHIBR_DLL_IMPORT@ 20 | 21 | TESTS = \ 22 | test_library.sh \ 23 | test_hibrinfo.sh 24 | 25 | check_SCRIPTS = \ 26 | test_hibrinfo.sh \ 27 | test_library.sh \ 28 | test_manpage.sh \ 29 | test_runner.sh 30 | 31 | EXTRA_DIST = \ 32 | $(check_SCRIPTS) 33 | 34 | check_PROGRAMS = \ 35 | hibr_test_compressed_page_data \ 36 | hibr_test_compressed_page_map \ 37 | hibr_test_error \ 38 | hibr_test_file \ 39 | hibr_test_io_handle \ 40 | hibr_test_notify \ 41 | hibr_test_support 42 | 43 | hibr_test_compressed_page_data_SOURCES = \ 44 | hibr_test_compressed_page_data.c \ 45 | hibr_test_libcerror.h \ 46 | hibr_test_libhibr.h \ 47 | hibr_test_macros.h \ 48 | hibr_test_memory.c hibr_test_memory.h \ 49 | hibr_test_unused.h 50 | 51 | hibr_test_compressed_page_data_LDADD = \ 52 | ../libhibr/libhibr.la \ 53 | @LIBCERROR_LIBADD@ 54 | 55 | hibr_test_compressed_page_map_SOURCES = \ 56 | hibr_test_compressed_page_map.c \ 57 | hibr_test_libcerror.h \ 58 | hibr_test_libhibr.h \ 59 | hibr_test_macros.h \ 60 | hibr_test_memory.c hibr_test_memory.h \ 61 | hibr_test_unused.h 62 | 63 | hibr_test_compressed_page_map_LDADD = \ 64 | ../libhibr/libhibr.la \ 65 | @LIBCERROR_LIBADD@ 66 | 67 | hibr_test_error_SOURCES = \ 68 | hibr_test_error.c \ 69 | hibr_test_libhibr.h \ 70 | hibr_test_macros.h \ 71 | hibr_test_unused.h 72 | 73 | hibr_test_error_LDADD = \ 74 | ../libhibr/libhibr.la 75 | 76 | hibr_test_file_SOURCES = \ 77 | hibr_test_file.c \ 78 | hibr_test_functions.c hibr_test_functions.h \ 79 | hibr_test_getopt.c hibr_test_getopt.h \ 80 | hibr_test_libcerror.h \ 81 | hibr_test_libclocale.h \ 82 | hibr_test_libcnotify.h \ 83 | hibr_test_libhibr.h \ 84 | hibr_test_libuna.h \ 85 | hibr_test_macros.h \ 86 | hibr_test_memory.c hibr_test_memory.h 87 | 88 | hibr_test_file_LDADD = \ 89 | @LIBBFIO_LIBADD@ \ 90 | @LIBCPATH_LIBADD@ \ 91 | @LIBCFILE_LIBADD@ \ 92 | @LIBUNA_LIBADD@ \ 93 | @LIBCSPLIT_LIBADD@ \ 94 | @LIBCNOTIFY_LIBADD@ \ 95 | @LIBCLOCALE_LIBADD@ \ 96 | @LIBCDATA_LIBADD@ \ 97 | ../libhibr/libhibr.la \ 98 | @LIBCTHREADS_LIBADD@ \ 99 | @LIBCERROR_LIBADD@ \ 100 | @PTHREAD_LIBADD@ 101 | 102 | hibr_test_io_handle_SOURCES = \ 103 | hibr_test_io_handle.c \ 104 | hibr_test_libcerror.h \ 105 | hibr_test_libhibr.h \ 106 | hibr_test_macros.h \ 107 | hibr_test_memory.c hibr_test_memory.h \ 108 | hibr_test_unused.h 109 | 110 | hibr_test_io_handle_LDADD = \ 111 | ../libhibr/libhibr.la \ 112 | @LIBCERROR_LIBADD@ 113 | 114 | hibr_test_notify_SOURCES = \ 115 | hibr_test_libcerror.h \ 116 | hibr_test_libhibr.h \ 117 | hibr_test_macros.h \ 118 | hibr_test_notify.c \ 119 | hibr_test_unused.h 120 | 121 | hibr_test_notify_LDADD = \ 122 | ../libhibr/libhibr.la \ 123 | @LIBCERROR_LIBADD@ 124 | 125 | hibr_test_support_SOURCES = \ 126 | hibr_test_functions.c hibr_test_functions.h \ 127 | hibr_test_getopt.c hibr_test_getopt.h \ 128 | hibr_test_libbfio.h \ 129 | hibr_test_libcerror.h \ 130 | hibr_test_libclocale.h \ 131 | hibr_test_libcnotify.h \ 132 | hibr_test_libhibr.h \ 133 | hibr_test_libuna.h \ 134 | hibr_test_macros.h \ 135 | hibr_test_memory.c hibr_test_memory.h \ 136 | hibr_test_support.c 137 | 138 | hibr_test_support_LDADD = \ 139 | @LIBBFIO_LIBADD@ \ 140 | @LIBCPATH_LIBADD@ \ 141 | @LIBCFILE_LIBADD@ \ 142 | @LIBUNA_LIBADD@ \ 143 | @LIBCSPLIT_LIBADD@ \ 144 | @LIBCNOTIFY_LIBADD@ \ 145 | @LIBCLOCALE_LIBADD@ \ 146 | @LIBCDATA_LIBADD@ \ 147 | ../libhibr/libhibr.la \ 148 | @LIBCERROR_LIBADD@ 149 | 150 | DISTCLEANFILES = \ 151 | Makefile \ 152 | Makefile.in \ 153 | notify_stream.log 154 | 155 | -------------------------------------------------------------------------------- /tests/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to build from source 3 | # 4 | # Version: 20201121 5 | 6 | set -e 7 | 8 | ./synclibs.sh --use-head 9 | ./autogen.sh 10 | ./configure "$@" 11 | make > /dev/null 12 | 13 | -------------------------------------------------------------------------------- /tests/hibr_test_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library error functions test program 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined( HAVE_STDLIB_H ) || defined( WINAPI ) 27 | #include 28 | #endif 29 | 30 | #include "hibr_test_libhibr.h" 31 | #include "hibr_test_macros.h" 32 | #include "hibr_test_unused.h" 33 | 34 | /* Tests the libhibr_error_free function 35 | * Returns 1 if successful or 0 if not 36 | */ 37 | int hibr_test_error_free( 38 | void ) 39 | { 40 | /* Test invocation of function only 41 | */ 42 | libhibr_error_free( 43 | NULL ); 44 | 45 | return( 1 ); 46 | } 47 | 48 | /* Tests the libhibr_error_fprint function 49 | * Returns 1 if successful or 0 if not 50 | */ 51 | int hibr_test_error_fprint( 52 | void ) 53 | { 54 | /* Test invocation of function only 55 | */ 56 | libhibr_error_fprint( 57 | NULL, 58 | NULL ); 59 | 60 | return( 1 ); 61 | } 62 | 63 | /* Tests the libhibr_error_sprint function 64 | * Returns 1 if successful or 0 if not 65 | */ 66 | int hibr_test_error_sprint( 67 | void ) 68 | { 69 | /* Test invocation of function only 70 | */ 71 | libhibr_error_sprint( 72 | NULL, 73 | NULL, 74 | 0 ); 75 | 76 | return( 1 ); 77 | } 78 | 79 | /* Tests the libhibr_error_backtrace_fprint function 80 | * Returns 1 if successful or 0 if not 81 | */ 82 | int hibr_test_error_backtrace_fprint( 83 | void ) 84 | { 85 | /* Test invocation of function only 86 | */ 87 | libhibr_error_backtrace_fprint( 88 | NULL, 89 | NULL ); 90 | 91 | return( 1 ); 92 | } 93 | 94 | /* Tests the libhibr_error_backtrace_sprint function 95 | * Returns 1 if successful or 0 if not 96 | */ 97 | int hibr_test_error_backtrace_sprint( 98 | void ) 99 | { 100 | /* Test invocation of function only 101 | */ 102 | libhibr_error_backtrace_sprint( 103 | NULL, 104 | NULL, 105 | 0 ); 106 | 107 | return( 1 ); 108 | } 109 | 110 | /* The main program 111 | */ 112 | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) 113 | int wmain( 114 | int argc HIBR_TEST_ATTRIBUTE_UNUSED, 115 | wchar_t * const argv[] HIBR_TEST_ATTRIBUTE_UNUSED ) 116 | #else 117 | int main( 118 | int argc HIBR_TEST_ATTRIBUTE_UNUSED, 119 | char * const argv[] HIBR_TEST_ATTRIBUTE_UNUSED ) 120 | #endif 121 | { 122 | HIBR_TEST_UNREFERENCED_PARAMETER( argc ) 123 | HIBR_TEST_UNREFERENCED_PARAMETER( argv ) 124 | 125 | HIBR_TEST_RUN( 126 | "libhibr_error_free", 127 | hibr_test_error_free ); 128 | 129 | HIBR_TEST_RUN( 130 | "libhibr_error_fprint", 131 | hibr_test_error_fprint ); 132 | 133 | HIBR_TEST_RUN( 134 | "libhibr_error_sprint", 135 | hibr_test_error_sprint ); 136 | 137 | HIBR_TEST_RUN( 138 | "libhibr_error_backtrace_fprint", 139 | hibr_test_error_backtrace_fprint ); 140 | 141 | HIBR_TEST_RUN( 142 | "libhibr_error_backtrace_sprint", 143 | hibr_test_error_backtrace_sprint ); 144 | 145 | return( EXIT_SUCCESS ); 146 | 147 | on_error: 148 | return( EXIT_FAILURE ); 149 | } 150 | 151 | -------------------------------------------------------------------------------- /tests/hibr_test_functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Functions for testing 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_FUNCTIONS_H ) 23 | #define _HIBR_TEST_FUNCTIONS_H 24 | 25 | #include 26 | #include 27 | 28 | #include "hibr_test_libbfio.h" 29 | #include "hibr_test_libcerror.h" 30 | 31 | #if defined( __cplusplus ) 32 | extern "C" { 33 | #endif 34 | 35 | int hibr_test_get_narrow_source( 36 | const system_character_t *source, 37 | char *narrow_string, 38 | size_t narrow_string_size, 39 | libcerror_error_t **error ); 40 | 41 | #if defined( HAVE_WIDE_CHARACTER_TYPE ) 42 | 43 | int hibr_test_get_wide_source( 44 | const system_character_t *source, 45 | wchar_t *wide_string, 46 | size_t wide_string_size, 47 | libcerror_error_t **error ); 48 | 49 | #endif /* defined( HAVE_WIDE_CHARACTER_TYPE ) */ 50 | 51 | int hibr_test_open_file_io_handle( 52 | libbfio_handle_t **file_io_handle, 53 | uint8_t *data, 54 | size_t data_size, 55 | libcerror_error_t **error ); 56 | 57 | int hibr_test_close_file_io_handle( 58 | libbfio_handle_t **file_io_handle, 59 | libcerror_error_t **error ); 60 | 61 | #if defined( __cplusplus ) 62 | } 63 | #endif 64 | 65 | #endif /* !defined( _HIBR_TEST_FUNCTIONS_H ) */ 66 | 67 | -------------------------------------------------------------------------------- /tests/hibr_test_getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * GetOpt functions 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_GETOPT_H ) 23 | #define _HIBR_TEST_GETOPT_H 24 | 25 | #include 26 | #include 27 | 28 | /* unistd.h is included here to export getopt, optarg, optind and optopt 29 | */ 30 | #if defined( HAVE_UNISTD_H ) 31 | #include 32 | #endif 33 | 34 | #if defined( __cplusplus ) 35 | extern "C" { 36 | #endif 37 | 38 | #if defined( HAVE_GETOPT ) 39 | #define hibr_test_getopt( argument_count, argument_values, options_string ) \ 40 | getopt( argument_count, argument_values, options_string ) 41 | 42 | #else 43 | 44 | #if !defined( __CYGWIN__ ) 45 | extern int optind; 46 | extern system_character_t *optarg; 47 | extern system_integer_t optopt; 48 | 49 | #else 50 | int optind; 51 | system_character_t *optarg; 52 | system_integer_t optopt; 53 | 54 | #endif /* !defined( __CYGWIN__ ) */ 55 | 56 | system_integer_t hibr_test_getopt( 57 | int argument_count, 58 | system_character_t * const argument_values[], 59 | const system_character_t *options_string ); 60 | 61 | #endif /* defined( HAVE_GETOPT ) */ 62 | 63 | #if defined( __cplusplus ) 64 | } 65 | #endif 66 | 67 | #endif /* !defined( _HIBR_TEST_GETOPT_H ) */ 68 | 69 | -------------------------------------------------------------------------------- /tests/hibr_test_libbfio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libbfio header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBBFIO_H ) 23 | #define _HIBR_TEST_LIBBFIO_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBBFIO for local use of libbfio 28 | */ 29 | #if defined( HAVE_LOCAL_LIBBFIO ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #else 41 | 42 | /* If libtool DLL support is enabled set LIBBFIO_DLL_IMPORT 43 | * before including libbfio.h 44 | */ 45 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 46 | #define LIBBFIO_DLL_IMPORT 47 | #endif 48 | 49 | #include 50 | 51 | #if defined( HAVE_MULTI_THREAD_SUPPORT ) && !defined( LIBBFIO_HAVE_MULTI_THREAD_SUPPORT ) 52 | #error Multi-threading support requires libbfio with multi-threading support 53 | #endif 54 | 55 | #endif /* defined( HAVE_LOCAL_LIBBFIO ) */ 56 | 57 | #endif /* !defined( _HIBR_TEST_LIBBFIO_H ) */ 58 | 59 | -------------------------------------------------------------------------------- /tests/hibr_test_libcerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcerror header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBCERROR_H ) 23 | #define _HIBR_TEST_LIBCERROR_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCERROR for local use of libcerror 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCERROR ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCERROR_DLL_IMPORT 39 | * before including libcerror.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCERROR_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCERROR ) */ 48 | 49 | #endif /* !defined( _HIBR_TEST_LIBCERROR_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/hibr_test_libclocale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libclocale header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBCLOCALE_H ) 23 | #define _HIBR_TEST_LIBCLOCALE_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCLOCALE for local use of libclocale 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCLOCALE ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCLOCALE_DLL_IMPORT 39 | * before including libclocale.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCLOCALE_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCLOCALE ) */ 48 | 49 | #endif /* !defined( _HIBR_TEST_LIBCLOCALE_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/hibr_test_libcnotify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libcnotify header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBCNOTIFY_H ) 23 | #define _HIBR_TEST_LIBCNOTIFY_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBCNOTIFY for local use of libcnotify 28 | */ 29 | #if defined( HAVE_LOCAL_LIBCNOTIFY ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #else 37 | 38 | /* If libtool DLL support is enabled set LIBCNOTIFY_DLL_IMPORT 39 | * before including libcnotify.h 40 | */ 41 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 42 | #define LIBCNOTIFY_DLL_IMPORT 43 | #endif 44 | 45 | #include 46 | 47 | #endif /* defined( HAVE_LOCAL_LIBCNOTIFY ) */ 48 | 49 | #endif /* !defined( _HIBR_TEST_LIBCNOTIFY_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/hibr_test_libhibr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libhibr header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBHIBR_H ) 23 | #define _HIBR_TEST_LIBHIBR_H 24 | 25 | #include 26 | 27 | #include 28 | 29 | #endif /* !defined( _HIBR_TEST_LIBHIBR_H ) */ 30 | 31 | -------------------------------------------------------------------------------- /tests/hibr_test_libuna.h: -------------------------------------------------------------------------------- 1 | /* 2 | * The libuna header wrapper 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_LIBUNA_H ) 23 | #define _HIBR_TEST_LIBUNA_H 24 | 25 | #include 26 | 27 | /* Define HAVE_LOCAL_LIBUNA for local use of libuna 28 | */ 29 | #if defined( HAVE_LOCAL_LIBUNA ) 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #else 47 | 48 | /* If libtool DLL support is enabled set LIBUNA_DLL_IMPORT 49 | * before including libuna.h 50 | */ 51 | #if defined( _WIN32 ) && defined( DLL_IMPORT ) 52 | #define LIBUNA_DLL_IMPORT 53 | #endif 54 | 55 | #include 56 | 57 | #endif /* defined( HAVE_LOCAL_LIBUNA ) */ 58 | 59 | #endif /* !defined( _HIBR_TEST_LIBUNA_H ) */ 60 | 61 | -------------------------------------------------------------------------------- /tests/hibr_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Memory allocation functions for testing 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_MEMORY_H ) 23 | #define _HIBR_TEST_MEMORY_H 24 | 25 | #include 26 | 27 | #if defined( __cplusplus ) 28 | extern "C" { 29 | #endif 30 | 31 | #if defined( HAVE_GNU_DL_DLSYM ) && defined( __GNUC__ ) && !defined( LIBHIBR_DLL_IMPORT ) && !defined( __arm__ ) && !defined( __clang__ ) && !defined( __CYGWIN__ ) && !defined( __hppa__ ) && !defined( __loongarch__ ) && !defined( __mips__ ) && !defined( __riscv ) && !defined( __sparc__ ) && !defined( HAVE_ASAN ) 32 | #define HAVE_HIBR_TEST_MEMORY 1 33 | #endif 34 | 35 | #if defined( HAVE_HIBR_TEST_MEMORY ) 36 | 37 | extern int hibr_test_malloc_attempts_before_fail; 38 | 39 | extern int hibr_test_memcpy_attempts_before_fail; 40 | 41 | extern int hibr_test_memset_attempts_before_fail; 42 | 43 | extern int hibr_test_realloc_attempts_before_fail; 44 | 45 | #endif /* defined( HAVE_HIBR_TEST_MEMORY ) */ 46 | 47 | #if defined( __cplusplus ) 48 | } 49 | #endif 50 | 51 | #endif /* !defined( _HIBR_TEST_MEMORY_H ) */ 52 | 53 | -------------------------------------------------------------------------------- /tests/hibr_test_unused.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions to silence compiler warnings about unused function attributes/parameters. 3 | * 4 | * Copyright (C) 2012-2024, Joachim Metz 5 | * 6 | * Refer to AUTHORS for acknowledgements. 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation, either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program. If not, see . 20 | */ 21 | 22 | #if !defined( _HIBR_TEST_UNUSED_H ) 23 | #define _HIBR_TEST_UNUSED_H 24 | 25 | #include 26 | 27 | #if !defined( HIBR_TEST_ATTRIBUTE_UNUSED ) 28 | 29 | #if defined( __GNUC__ ) && __GNUC__ >= 3 30 | #define HIBR_TEST_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 31 | 32 | #else 33 | #define HIBR_TEST_ATTRIBUTE_UNUSED 34 | 35 | #endif /* defined( __GNUC__ ) && __GNUC__ >= 3 */ 36 | 37 | #endif /* !defined( HIBR_TEST_ATTRIBUTE_UNUSED ) */ 38 | 39 | #if defined( _MSC_VER ) 40 | #define HIBR_TEST_UNREFERENCED_PARAMETER( parameter ) \ 41 | UNREFERENCED_PARAMETER( parameter ); 42 | 43 | #else 44 | #define HIBR_TEST_UNREFERENCED_PARAMETER( parameter ) \ 45 | /* parameter */ 46 | 47 | #endif /* defined( _MSC_VER ) */ 48 | 49 | #endif /* !defined( _HIBR_TEST_UNUSED_H ) */ 50 | 51 | -------------------------------------------------------------------------------- /tests/lsan.suppressions: -------------------------------------------------------------------------------- 1 | leak:/lib*/libpython* 2 | -------------------------------------------------------------------------------- /tests/pkgbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to build a MacOS pkg 3 | # 4 | # Version: 20201121 5 | 6 | set -e 7 | 8 | make install DESTDIR=${PWD}/osx-pkg 9 | mkdir -p ${PWD}/osx-pkg/usr/share/doc/libhibr 10 | cp AUTHORS COPYING COPYING.LESSER NEWS README ${PWD}/osx-pkg/usr/share/doc/libhibr 11 | 12 | VERSION=`sed '5!d; s/^ \[//;s/\],$//' configure.ac` 13 | pkgbuild --root osx-pkg --identifier com.github.libyal.libhibr --version ${VERSION} --ownership recommended ../libhibr-${VERSION}.pkg 14 | 15 | -------------------------------------------------------------------------------- /tests/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to run tests 3 | # 4 | # Version: 20201121 5 | 6 | if test -f ${PWD}/libhibr/.libs/libhibr.1.dylib && test -f ./pyhibr/.libs/pyhibr.so; 7 | then 8 | install_name_tool -change /usr/local/lib/libhibr.1.dylib ${PWD}/libhibr/.libs/libhibr.1.dylib ./pyhibr/.libs/pyhibr.so; 9 | fi 10 | 11 | make check CHECK_WITH_STDERR=1; 12 | RESULT=$?; 13 | 14 | if test ${RESULT} -ne 0 && test -f tests/test-suite.log; 15 | then 16 | cat tests/test-suite.log; 17 | fi 18 | exit ${RESULT}; 19 | 20 | -------------------------------------------------------------------------------- /tests/syncsharedlibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script that synchronizes the shared library dependencies 3 | # 4 | # Version: 20201121 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | 9 | GIT_URL_PREFIX="https://github.com/libyal"; 10 | SHARED_LIBS="libcerror libcdata libclocale libcnotify libcsplit libuna libcfile libcpath libbfio libfcache libfdata libfdatetime libfwnt"; 11 | 12 | USE_HEAD=""; 13 | 14 | if test "$1" = "--use-head"; 15 | then 16 | USE_HEAD="--use-head"; 17 | fi 18 | 19 | OLDIFS=$IFS; 20 | IFS=" "; 21 | 22 | for SHARED_LIB in ${SHARED_LIBS}; 23 | do 24 | GIT_URL="${GIT_URL_PREFIX}/${SHARED_LIB}.git"; 25 | 26 | git clone --quiet ${GIT_URL} ${SHARED_LIB}-$$; 27 | 28 | if ! test -d ${SHARED_LIB}-$$; 29 | then 30 | echo "Unable to git clone: ${GIT_URL}"; 31 | 32 | IFS=$OLDIFS; 33 | 34 | exit ${EXIT_FAILURE}; 35 | fi 36 | (cd ${SHARED_LIB}-$$ && git fetch --quiet --all --tags --prune) 37 | 38 | LATEST_TAG=`cd ${SHARED_LIB}-$$ && git describe --tags --abbrev=0`; 39 | 40 | if test -n ${LATEST_TAG} && test -z ${USE_HEAD}; 41 | then 42 | echo "Synchronizing: ${SHARED_LIB} from ${GIT_URL} tag ${LATEST_TAG}"; 43 | 44 | (cd ${SHARED_LIB}-$$ && git checkout --quiet tags/${LATEST_TAG}); 45 | else 46 | echo "Synchronizing: ${SHARED_LIB} from ${GIT_URL} HEAD"; 47 | fi 48 | 49 | (cd ${SHARED_LIB}-$$ && ./synclibs.sh ${USE_HEAD} && ./autogen.sh); 50 | 51 | CONFIGURE_OPTIONS=""; 52 | 53 | (cd ${SHARED_LIB}-$$ && ./configure --help | grep -- '--enable-wide-character-type' > /dev/null); 54 | 55 | if test $? -eq 0; 56 | then 57 | CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} --enable-wide-character-type"; 58 | fi 59 | 60 | (cd ${SHARED_LIB}-$$ && ./configure --prefix=/usr ${CONFIGURE_OPTIONS} && make && sudo make install); 61 | 62 | rm -rf ${SHARED_LIB}-$$; 63 | done 64 | 65 | IFS=$OLDIFS; 66 | 67 | exit ${EXIT_SUCCESS}; 68 | 69 | -------------------------------------------------------------------------------- /tests/test_hibrinfo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Info tool testing script 3 | # 4 | # Version: 20240413 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | EXIT_IGNORE=77; 9 | 10 | PROFILES=("hibrinfo"); 11 | OPTIONS_PER_PROFILE=(""); 12 | OPTION_SETS=(); 13 | 14 | INPUT_GLOB="*"; 15 | 16 | if test -n "${SKIP_TOOLS_TESTS}" || test -n "${SKIP_TOOLS_END_TO_END_TESTS}"; 17 | then 18 | exit ${EXIT_IGNORE}; 19 | fi 20 | 21 | TEST_EXECUTABLE="../hibrtools/hibrinfo"; 22 | 23 | if ! test -x "${TEST_EXECUTABLE}"; 24 | then 25 | TEST_EXECUTABLE="../hibrtools/hibrinfo.exe"; 26 | fi 27 | 28 | if ! test -x "${TEST_EXECUTABLE}"; 29 | then 30 | echo "Missing test executable: ${TEST_EXECUTABLE}"; 31 | 32 | exit ${EXIT_FAILURE}; 33 | fi 34 | 35 | TEST_DIRECTORY=`dirname $0`; 36 | 37 | TEST_RUNNER="${TEST_DIRECTORY}/test_runner.sh"; 38 | 39 | if ! test -f "${TEST_RUNNER}"; 40 | then 41 | echo "Missing test runner: ${TEST_RUNNER}"; 42 | 43 | exit ${EXIT_FAILURE}; 44 | fi 45 | 46 | source ${TEST_RUNNER}; 47 | 48 | if ! test -d "input"; 49 | then 50 | echo "Test input directory not found."; 51 | 52 | exit ${EXIT_IGNORE}; 53 | fi 54 | RESULT=`ls input/* | tr ' ' '\n' | wc -l`; 55 | 56 | if test ${RESULT} -eq ${EXIT_SUCCESS}; 57 | then 58 | echo "No files or directories found in the test input directory"; 59 | 60 | exit ${EXIT_IGNORE}; 61 | fi 62 | 63 | for PROFILE_INDEX in ${!PROFILES[*]}; 64 | do 65 | TEST_PROFILE=${PROFILES[${PROFILE_INDEX}]}; 66 | 67 | TEST_PROFILE_DIRECTORY=$(get_test_profile_directory "input" "${TEST_PROFILE}"); 68 | 69 | IGNORE_LIST=$(read_ignore_list "${TEST_PROFILE_DIRECTORY}"); 70 | 71 | IFS=" " read -a PROFILE_OPTIONS <<< ${OPTIONS_PER_PROFILE[${PROFILE_INDEX}]}; 72 | 73 | RESULT=${EXIT_SUCCESS}; 74 | 75 | for TEST_SET_INPUT_DIRECTORY in input/*; 76 | do 77 | if ! test -d "${TEST_SET_INPUT_DIRECTORY}"; 78 | then 79 | continue; 80 | fi 81 | TEST_SET=`basename ${TEST_SET_INPUT_DIRECTORY}`; 82 | 83 | if check_for_test_set_in_ignore_list "${TEST_SET}" "${IGNORE_LIST}"; 84 | then 85 | continue; 86 | fi 87 | TEST_SET_DIRECTORY=$(get_test_set_directory "${TEST_PROFILE_DIRECTORY}" "${TEST_SET_INPUT_DIRECTORY}"); 88 | 89 | RESULT=${EXIT_SUCCESS}; 90 | 91 | if test -f "${TEST_SET_DIRECTORY}/files"; 92 | then 93 | IFS="" read -a INPUT_FILES <<< $(cat ${TEST_SET_DIRECTORY}/files | sed "s?^?${TEST_SET_INPUT_DIRECTORY}/?"); 94 | else 95 | IFS="" read -a INPUT_FILES <<< $(ls -1d ${TEST_SET_INPUT_DIRECTORY}/${INPUT_GLOB}); 96 | fi 97 | for INPUT_FILE in "${INPUT_FILES[@]}"; 98 | do 99 | TESTED_WITH_OPTIONS=0; 100 | 101 | for OPTION_SET in ${OPTION_SETS[@]}; 102 | do 103 | TEST_DATA_OPTION_FILE=$(get_test_data_option_file "${TEST_SET_DIRECTORY}" "${INPUT_FILE}" "${OPTION_SET}"); 104 | 105 | if test -f ${TEST_DATA_OPTION_FILE}; 106 | then 107 | TESTED_WITH_OPTIONS=1; 108 | 109 | IFS=" " read -a OPTIONS <<< $(read_test_data_option_file "${TEST_SET_DIRECTORY}" "${INPUT_FILE}" "${OPTION_SET}"); 110 | 111 | run_test_on_input_file "${TEST_SET_DIRECTORY}" "hibrinfo" "with_stdout_reference" "${OPTION_SET}" "${TEST_EXECUTABLE}" "${INPUT_FILE}" "${PROFILE_OPTIONS[@]}" "${OPTIONS[@]}"; 112 | RESULT=$?; 113 | 114 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 115 | then 116 | break; 117 | fi 118 | fi 119 | done 120 | 121 | if test ${TESTED_WITH_OPTIONS} -eq 0; 122 | then 123 | run_test_on_input_file "${TEST_SET_DIRECTORY}" "hibrinfo" "with_stdout_reference" "" "${TEST_EXECUTABLE}" "${INPUT_FILE}" "${PROFILE_OPTIONS[@]}"; 124 | RESULT=$?; 125 | fi 126 | 127 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 128 | then 129 | break; 130 | fi 131 | done 132 | 133 | # Ignore failures due to corrupted data. 134 | if test "${TEST_SET}" = "corrupted"; 135 | then 136 | RESULT=${EXIT_SUCCESS}; 137 | fi 138 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 139 | then 140 | break; 141 | fi 142 | done 143 | done 144 | 145 | exit ${RESULT}; 146 | 147 | -------------------------------------------------------------------------------- /tests/test_manpage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tests man pages. 3 | # 4 | # Version: 20240413 5 | 6 | EXIT_SUCCESS=0; 7 | EXIT_FAILURE=1; 8 | EXIT_IGNORE=77; 9 | 10 | run_test() 11 | { 12 | local INPUT_FILE=$1; 13 | local RESULT=0 14 | 15 | TEST_NAME=`basename ${INPUT_FILE}`; 16 | echo -n "Testing man with input: ${TEST_NAME}"; 17 | 18 | LC_ALL=en_US.UTF-8 MANROFFSEQ='' MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z ${INPUT_FILE} > /dev/null 2> ${TMPDIR}/${TEST_NAME}.warnings; 19 | RESULT=$?; 20 | 21 | # For now line break warnings are ignored. 22 | if test -f ${TMPDIR}/${TEST_NAME}.warnings; 23 | then 24 | sed "/can't break line/ d" -i ${TMPDIR}/${TEST_NAME}.warnings; 25 | fi 26 | if test -s ${TMPDIR}/${TEST_NAME}.warnings; 27 | then 28 | RESULT=${EXIT_FAILURE}; 29 | fi 30 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 31 | then 32 | echo " (FAIL)"; 33 | else 34 | echo " (PASS)"; 35 | fi 36 | if test -s ${TMPDIR}/${TEST_NAME}.warnings; 37 | then 38 | cat ${TMPDIR}/${TEST_NAME}.warnings; 39 | fi 40 | return ${RESULT}; 41 | } 42 | 43 | if test "${OSTYPE}" = "msys"; 44 | then 45 | exit ${EXIT_IGNORE}; 46 | fi 47 | 48 | TEST_DIRECTORY=`dirname $0`; 49 | 50 | TEST_RUNNER="${TEST_DIRECTORY}/test_runner.sh"; 51 | 52 | if ! test -f "${TEST_RUNNER}"; 53 | then 54 | echo "Missing test runner: ${TEST_RUNNER}"; 55 | 56 | exit ${EXIT_FAILURE}; 57 | fi 58 | 59 | source ${TEST_RUNNER}; 60 | 61 | assert_availability_binary man; 62 | 63 | RESULT=${EXIT_IGNORE}; 64 | 65 | TMPDIR="tmp$$"; 66 | 67 | rm -rf ${TMPDIR}; 68 | mkdir ${TMPDIR}; 69 | 70 | MANUALS_PATH="../manuals"; 71 | 72 | if ! test -d ${MANUALS_PATH}; 73 | then 74 | MANUALS_PATH="manuals"; 75 | fi 76 | 77 | if ! test -d ${MANUALS_PATH}; 78 | then 79 | echo "Manuals directory not found."; 80 | 81 | exit ${EXIT_IGNORE}; 82 | fi 83 | 84 | for INPUT_FILE in ${MANUALS_PATH}/*.[13]; 85 | do 86 | run_test "${INPUT_FILE}"; 87 | RESULT=$?; 88 | 89 | if test ${RESULT} -ne ${EXIT_SUCCESS}; 90 | then 91 | break; 92 | fi 93 | done 94 | 95 | rm -rf ${TMPDIR}; 96 | 97 | exit ${RESULT}; 98 | 99 | --------------------------------------------------------------------------------