Files
nuitka-mirror/tests/onefile/WindowsOverlayResourceModeTest.py
Kay Hayen 1da9b1d9b3 Onefile: Added "overlay" resource mode for large payloads
* A new "overlay" resource mode attaches the onefile payload to the end
  of the executable file rather than embedding it as a constant blob. It
  is used automatically on Windows when the embedded data would exceed
  the size limit of the PE file format, and can be requested with the
  hidden "--onefile-resource-mode=overlay" or "--resource-mode=overlay"
  options, or via the "NUITKA_ONEFILE_RESOURCE_MODE" and
  "NUITKA_RESOURCE_MODE" environment variables.

* The onefile bootstrap memory maps its own executable file and determines
  the end of the attached payload from the file size, adjusted for the
  certificate table that code signing places after it, and unpacks the
  payload from there.

* For now "overlay" works only on Windows, and only for the onefile mode
  where we need it.
2026-10-14 17:20:03 +02:00

38 lines
1.7 KiB
Python

# Copyright 2026, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
from __future__ import print_function
# nuitka-project: --mode=onefile
# nuitka-project: --onefile-resource-mode=overlay
# The payload is attached to the executable file rather than embedded as a
# constant blob, which is otherwise only done for payloads that are too large
# for the executable file format, and only supported on Windows.
# When signing is used, the certificate table is added after the attached
# payload, which the bootstrap has to cope with.
# nuitka-project-if: {Commercial} is not None:
# nuitka-project: --enable-plugin=signtool
# nuitka-project: --windows-certificate-filename={MAIN_DIRECTORY}/../../misc/test-cert.pfx
# nuitka-project: --windows-certificate-password=password
print("Hello Externally Attached Payload World!")
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.