From cc70274079a0de78497011e2c665838522b6e1f5 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Wed, 2 Oct 2024 12:13:25 +0200 Subject: src: check if the system is hibernated before /image/create Mount the system partition in readonly mode and check for the hiberfil.sys file if the target system is a Windows. Fail the image creation process if the target system is hibernated. --- src/utils/probe.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/utils/probe.py') diff --git a/src/utils/probe.py b/src/utils/probe.py index 2ed029b..e53f08f 100644 --- a/src/utils/probe.py +++ b/src/utils/probe.py @@ -178,3 +178,10 @@ def os_probe(mountpoint): return getwindowsversion(winreghives) else: return 'unknown' + +def is_hibernation_enabled(mountpoint): + if get_os_family(mountpoint) != OSFamily.WINDOWS: + return False + + hiberfile_path = f'{mountpoint}/hiberfil.sys' + return os.path.exists(hiberfile_path) -- cgit v1.2.3-18-g5258