Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions WoeUSB/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@


def init(from_cli=True, install_mode=None, source_media=None, target_media=None, workaround_bios_boot_flag=False,
target_filesystem_type="FAT", filesystem_label=DEFAULT_NEW_FS_LABEL):
target_filesystem_type="FAT", filesystem_label=DEFAULT_NEW_FS_LABEL,
bypass_workaround=False, bypass_ms_account=False, disable_bitlocker=False):
"""
:param from_cli:
:type from_cli: bool
Expand All @@ -50,6 +51,9 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None,
:param workaround_bios_boot_flag:
:param target_filesystem_type:
:param filesystem_label:
:param bypass_workaround: Bypass TPM/SecureBoot/RAM
:param bypass_ms_account: Bypass Microsoft Account Requirement
:param disable_bitlocker: Disable BitLocker Device Encryption
Comment thread
Nguyen12345tt marked this conversation as resolved.
Outdated
:return: List
"""
source_fs_mountpoint = "/media/woeusb_source_" + str(
Expand All @@ -66,6 +70,11 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None,
debug = False

parser = None

# Initialize default flags
bypass_workaround_flag = bypass_workaround
bypass_ms_account_flag = bypass_ms_account
Comment thread
Nguyen12345tt marked this conversation as resolved.
disable_bitlocker_flag = disable_bitlocker
Comment thread
Nguyen12345tt marked this conversation as resolved.

Comment thread
Nguyen12345tt marked this conversation as resolved.
if from_cli:
parser = setup_arguments()
Expand Down Expand Up @@ -95,6 +104,11 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None,
target_filesystem_type = args.target_filesystem

filesystem_label = args.label

# Capture CLI arguments for Windows 11 tweaks
bypass_workaround_flag = args.bypass_workaround
Comment thread
Nguyen12345tt marked this conversation as resolved.
Outdated
bypass_ms_account_flag = args.bypass_ms_account
disable_bitlocker_flag = args.disable_bitlocker

verbose = args.verbose

Expand All @@ -107,14 +121,17 @@ def init(from_cli=True, install_mode=None, source_media=None, target_media=None,
utils.gui = gui

if from_cli:
# Added new flags to the return list
return [source_fs_mountpoint, target_fs_mountpoint, temp_directory, install_mode, source_media, target_media,
workaround_bios_boot_flag, skip_legacy_bootloader, target_filesystem_type, filesystem_label, verbose, debug, parser]
workaround_bios_boot_flag, skip_legacy_bootloader, target_filesystem_type, filesystem_label, verbose, debug, parser,
bypass_workaround_flag, bypass_ms_account_flag, disable_bitlocker_flag]
else:
return [source_fs_mountpoint, target_fs_mountpoint, temp_directory, target_media]


def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory,
target_filesystem_type, workaround_bios_boot_flag, parser=None, skip_legacy_bootloader=False):
target_filesystem_type, workaround_bios_boot_flag, parser=None, skip_legacy_bootloader=False,
bypass_workaround_flag=False, bypass_ms_account_flag=False, disable_bitlocker_flag=False):
"""
:param parser:
:param source_fs_mountpoint:
Expand All @@ -125,6 +142,9 @@ def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media,
:param temp_directory:
:param target_filesystem_type:
:param workaround_bios_boot_flag:
:param bypass_workaround_flag: Hardware bypass
:param bypass_ms_account_flag: MS Account bypass
:param disable_bitlocker_flag: BitLocker disable
:return: 0 - succes; 1 - failure
"""
global debug
Expand Down Expand Up @@ -193,6 +213,20 @@ def main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media,

copy_filesystem_files(source_fs_mountpoint, target_fs_mountpoint)

# --- START WINDOWS 11 TWEAKS LOGIC ---
if bypass_workaround_flag or bypass_ms_account_flag or disable_bitlocker_flag:
utils.print_with_color(_("Applying Windows 11 customizations..."), "green")
if hasattr(utils, 'write_win11_bypass'):
utils.write_win11_bypass(
target_fs_mountpoint,
bypass_hardware=bypass_workaround_flag,
bypass_ms_account=bypass_ms_account_flag,
disable_bitlocker=disable_bitlocker_flag
)
else:
utils.print_with_color(_("Error: write_win11_bypass function not found in utils!"), "red")
Comment thread
Nguyen12345tt marked this conversation as resolved.
# --- END WINDOWS 11 TWEAKS LOGIC ---

workaround.support_windows_7_uefi_boot(source_fs_mountpoint, target_fs_mountpoint)
if not skip_legacy_bootloader:
install_legacy_pc_bootloader_grub(target_fs_mountpoint, target_device, command_grubinstall)
Expand Down Expand Up @@ -648,6 +682,16 @@ def setup_arguments():
help="This will skip the legacy grub bootloader creation step.")
parser.add_argument("--target-filesystem", "--tgt-fs", choices=["FAT", "NTFS"], default="FAT", type=str.upper,
help="Specify the filesystem to use as the target partition's filesystem.")

# --- NEW ARGUMENTS ---
parser.add_argument("--bypass-workaround", action="store_true",
help="Bypass Windows 11 TPM 2.0 / Secure Boot requirements.")
parser.add_argument("--bypass-ms-account", action="store_true",
help="Bypass Microsoft Account Requirement (allows offline account creation).")
parser.add_argument("--disable-bitlocker", action="store_true",
help="Disable automatic BitLocker device encryption.")
# --------------------

parser.add_argument('--for-gui', action="store_true", help=argparse.SUPPRESS)

return parser
Expand Down Expand Up @@ -709,14 +753,18 @@ def run():
if isinstance(result, list) is False:
return

# Updated unpacking to include new flags
source_fs_mountpoint, target_fs_mountpoint, temp_directory, \
install_mode, source_media, target_media, \
workaround_bios_boot_flag, skip_legacy_bootloader, target_filesystem_type, \
new_file_system_label, verbose, debug, parser = result
new_file_system_label, verbose, debug, parser, \
bypass_workaround_flag, bypass_ms_account_flag, disable_bitlocker_flag = result

try:
# Updated main call to include new flags
main(source_fs_mountpoint, target_fs_mountpoint, source_media, target_media, install_mode, temp_directory,
target_filesystem_type, workaround_bios_boot_flag, parser, skip_legacy_bootloader)
target_filesystem_type, workaround_bios_boot_flag, parser, skip_legacy_bootloader,
bypass_workaround_flag, bypass_ms_account_flag, disable_bitlocker_flag)
except KeyboardInterrupt:
pass
except Exception as error:
Expand All @@ -728,4 +776,4 @@ def run():


if __name__ == "__main__":
run()
run()
117 changes: 94 additions & 23 deletions WoeUSB/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,62 @@
_ = miscellaneous.i18n


# --- NEW CLASS: Cửa sổ chọn tùy chọn Windows 11 ---
class Win11TweaksDialog(wx.Dialog):
def __init__(self, parent):
super().__init__(parent, title=_("Windows Installation Tweaks"), size=(400, 250))

panel = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)

lbl = wx.StaticText(panel, label=_("Select customization options:"))
lbl.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
vbox.Add(lbl, flag=wx.LEFT|wx.TOP, border=10)

vbox.AddSpacer(10)

self.cb_hardware = wx.CheckBox(panel, label=_("Bypass Windows 11 Hardware Check\n(TPM 2.0, Secure Boot, RAM)"))
self.cb_ms_account = wx.CheckBox(panel, label=_("Bypass Microsoft Account Requirement\n(Allows creating local account offline)"))
self.cb_bitlocker = wx.CheckBox(panel, label=_("Disable BitLocker Device Encryption"))

# Mặc định có thể để check hoặc uncheck tùy ý
self.cb_hardware.SetValue(True)
self.cb_ms_account.SetValue(True)
self.cb_bitlocker.SetValue(True)

vbox.Add(self.cb_hardware, flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=15)
vbox.AddSpacer(10)
vbox.Add(self.cb_ms_account, flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=15)
vbox.AddSpacer(10)
vbox.Add(self.cb_bitlocker, flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=15)

vbox.AddSpacer(20)

hbox_btn = wx.BoxSizer(wx.HORIZONTAL)
btn_ok = wx.Button(panel, wx.ID_OK, label=_("OK"))
btn_cancel = wx.Button(panel, wx.ID_CANCEL, label=_("Cancel"))

hbox_btn.Add(btn_ok, flag=wx.RIGHT, border=10)
hbox_btn.Add(btn_cancel)

vbox.Add(hbox_btn, flag=wx.ALIGN_RIGHT|wx.ALL, border=10)

panel.SetSizer(vbox)
self.CenterOnParent()

def get_values(self):
return (self.cb_hardware.GetValue(),
self.cb_ms_account.GetValue(),
self.cb_bitlocker.GetValue())
# ----------------------------------------------------


class MainFrame(wx.Frame):
__MainPanel = None
__MenuBar = None

__menuItemShowAll = None
# Đã xóa các biến option menu cũ

def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE):
super(MainFrame, self).__init__(None, -1, title, pos, size, style)
Expand Down Expand Up @@ -52,6 +103,9 @@ def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE):
self.options_skip_grub = wx.MenuItem(options_menu, wx.ID_ANY, _("Skip legacy grub bootloader"),
_("No legacy grub bootloader will be created. NOTE: It will only boot on system with UEFI support."),
wx.ITEM_CHECK)

# Đã xóa các menu item Bypass ở đây để chuyển sang popup

options_menu.Append(self.options_boot)
options_menu.Append(self.options_filesystem)
options_menu.Append(self.options_skip_grub)
Expand All @@ -70,9 +124,7 @@ def __init__(self, title, pos, size, style=wx.DEFAULT_FRAME_STYLE):

self.SetSizer(main_sizer)

# self.Connect(self.__menuItemShowAll.GetId(), wx.EVT_MENU, MainPanel.on_show_all_drive, None, self.__MainPanel)
self.Bind(wx.EVT_MENU, self.__MainPanel.on_show_all_drive)

self.Bind(wx.EVT_MENU, self.on_quit, exit_item)
self.Bind(wx.EVT_MENU, self.on_about, help_item)

Expand All @@ -89,20 +141,14 @@ def is_show_all_checked(self):

class MainPanel(wx.Panel):
__parent = None

__dvdDriveList = None
__usbStickList = wx.ListBox

__dvdDriveDevList = []
__usbStickDevList = []

__isoFile = wx.FilePickerCtrl

__parentFrame = None

__btInstall = None
__btRefresh = None

__isoChoice = None
__dvdChoice = None

Expand Down Expand Up @@ -180,22 +226,16 @@ def refresh_list_content(self):
# USB
self.__usbStickDevList = []
self.__usbStickList.Clear()

show_all_checked = self.__parent.is_show_all_checked()

device_list = list_devices.usb_drive(show_all_checked)

for device in device_list:
self.__usbStickDevList.append(device[0])
self.__usbStickList.Append(device[1])

# ISO

self.__dvdDriveDevList = []
self.__dvdDriveList.Clear()

drive_list = list_devices.dvd_drive()

for drive in drive_list:
self.__dvdDriveDevList.append(drive[0])
self.__dvdDriveList.Append(drive[1])
Expand All @@ -204,10 +244,8 @@ def refresh_list_content(self):

def on_source_option_changed(self, __):
is_iso = self.__isoChoice.GetValue()

self.__isoFile.Enable(is_iso)
self.__dvdDriveList.Enable(not is_iso)

self.__btInstall.Enable(self.is_install_ok())

def is_install_ok(self):
Expand All @@ -218,23 +256,41 @@ def is_install_ok(self):
def on_list_or_file_modified(self, event):
if event.GetEventType() == wx.EVT_LISTBOX and not event.IsSelection():
return

self.__btInstall.Enable(self.is_install_ok())

def on_refresh(self, __):
self.refresh_list_content()

def on_install(self, __):
global woe

# 1. Cảnh báo xóa dữ liệu
if wx.MessageBox(
_("Are you sure? This will delete all your files and wipe out the selected partition."),
_("Cancel"),
wx.YES_NO | wx.ICON_QUESTION | wx.NO_DEFAULT,
self) != wx.YES:
return

if self.is_install_ok():
is_iso = self.__isoChoice.GetValue()

# 2. HIỆN POPUP CHỌN TÙY CHỌN WIN 11 ---
bypass_hw = False
bypass_ms = False
no_bitlocker = False

# Bạn có thể thêm logic kiểm tra nếu là file ISO Windows 11 mới hiện,
# nhưng hiện tại ta cứ hiện luôn cho tiện.
tweak_dlg = Win11TweaksDialog(self)
if tweak_dlg.ShowModal() == wx.ID_OK:
bypass_hw, bypass_ms, no_bitlocker = tweak_dlg.get_values()
tweak_dlg.Destroy()
else:
tweak_dlg.Destroy()
return # Người dùng bấm Cancel ở popup thì hủy cài đặt
# ---------------------------------------

is_iso = self.__isoChoice.GetValue()
device = self.__usbStickDevList[self.__usbStickList.GetSelection()]

if is_iso:
Expand All @@ -246,8 +302,18 @@ def on_install(self, __):
filesystem = "NTFS"
else:
filesystem = "FAT"

woe = WoeUSB_handler(iso, device, boot_flag=self.__parent.options_boot.IsChecked(), filesystem=filesystem, skip_grub=self.__parent.options_skip_grub.IsChecked())

Comment thread
Nguyen12345tt marked this conversation as resolved.
woe = WoeUSB_handler(
iso,
device,
boot_flag=self.__parent.options_boot.IsChecked(),
filesystem=filesystem,
skip_grub=self.__parent.options_skip_grub.IsChecked(),
# Truyền các giá trị từ Popup xuống Handler
bypass_workaround=bypass_hw,
bypass_ms_account=bypass_ms,
disable_bitlocker=no_bitlocker
Comment thread
Nguyen12345tt marked this conversation as resolved.
Outdated
)
woe.start()

dialog = wx.ProgressDialog(_("Installing"), _("Please wait..."), 101, self.GetParent(),
Expand Down Expand Up @@ -387,7 +453,8 @@ class WoeUSB_handler(threading.Thread):
error = ""
kill = False

def __init__(self, source, target, boot_flag, filesystem, skip_grub=False):
def __init__(self, source, target, boot_flag, filesystem, skip_grub=False,
bypass_workaround=False, bypass_ms_account=False, disable_bitlocker=False):
threading.Thread.__init__(self)

core.gui = self
Expand All @@ -396,6 +463,9 @@ def __init__(self, source, target, boot_flag, filesystem, skip_grub=False):
self.boot_flag = boot_flag
self.filesystem = filesystem
self.skip_grub = skip_grub
self.bypass_workaround = bypass_workaround
self.bypass_ms_account = bypass_ms_account
self.disable_bitlocker = disable_bitlocker

def run(self):
source_fs_mountpoint, target_fs_mountpoint, temp_directory, target_media = core.init(
Expand All @@ -406,7 +476,8 @@ def run(self):
)
try:
core.main(source_fs_mountpoint, target_fs_mountpoint, self.source, self.target, "device", temp_directory,
self.filesystem, self.boot_flag , None, self.skip_grub)
self.filesystem, self.boot_flag , None, self.skip_grub,
self.bypass_workaround, self.bypass_ms_account, self.disable_bitlocker)
except SystemExit:
pass

Expand All @@ -424,4 +495,4 @@ def run():


if __name__ == "__main__":
run()
run()
2 changes: 1 addition & 1 deletion WoeUSB/miscellaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import locale
import os

__version__ = "0.2.12"
__version__ = "0.2.13-alpha"

translation = gettext.translation("woeusb", os.path.dirname(__file__) + "/locale", [locale.getlocale()[0]], fallback=True)
translation.install()
Expand Down
Loading