Skip to content

Commit

Permalink
PIL import graceful exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Abyss-W4tcher committed Dec 22, 2024
1 parent f6a54c5 commit 7caf8c5
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions volatility3/framework/plugins/linux/graphics/fbdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import logging
import io

# Image manipulation functions are kept in the plugin,
# to prevent a general exit on missing PIL (pillow) dependency.
from PIL import Image
from dataclasses import dataclass
from typing import Type, List, Dict, Tuple
from volatility3.framework import constants, exceptions, interfaces
Expand All @@ -16,6 +13,15 @@
from volatility3.framework.constants import architectures
from volatility3.framework.symbols import linux

# Image manipulation functions are kept in the plugin,
# to prevent a general exit on missing PIL (pillow) dependency.
try:
from PIL import Image

has_pil = True
except ImportError:
has_pil = False

vollog = logging.getLogger(__name__)


Expand Down Expand Up @@ -101,7 +107,7 @@ def convert_fb_raw_buffer_to_image(
context: interfaces.context.ContextInterface,
kernel_name: str,
fb: Framebuffer,
) -> Image.Image:
):
"""Convert raw framebuffer pixels to an image.
Args:
Expand Down Expand Up @@ -238,6 +244,13 @@ def parse_fb_info(
return fb

def _generator(self):

if not has_pil:
vollog.error(
"PIL (pillow) module is required to use this plugin. Please install it manually or through pyproject.toml."
)
return None

kernel_name = self.config["kernel"]
kernel = self.context.modules[kernel_name]

Expand Down

0 comments on commit 7caf8c5

Please sign in to comment.