This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from io import BytesIO | |
from pathlib import Path | |
from struct import Struct | |
from typing import TYPE_CHECKING | |
from PIL import Image | |
from PIL.PngImagePlugin import PngImageFile | |
if TYPE_CHECKING: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original: | |
# https://github.com/SteamDatabase/ValveResourceFormat/blob/8ff0321c9ec6f5c0d487515fc87346cd02fac949/ValveResourceFormat/ClosedCaptions/ClosedCaptions.cs | |
import struct | |
FILE_PATH = r"D:\subtitles_english.dat" | |
with open(FILE_PATH, "rb") as f: | |
magic, version = struct.unpack("<4sI", f.read(8)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pefile | |
def get_product_version(data: bytes) -> str: | |
pe = pefile.PE(data=data, fast_load=True) | |
pe.parse_data_directories( | |
directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]] | |
) | |
for file_info in pe.FileInfo: | |
for entry in file_info: |