#!/bin/bash
# Import HKCU keys for IDA 6.6 — license + suppress nag dialogs
# These key names contain special chars that are tricky to escape in Dockerfile RUN

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "License Zhou Tao, Jiangsu Australia Sinuo Network Technology Co., Ltd." \
  /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "AutoCheckUpdates" /t REG_DWORD /d 0 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "AutoRequestUpdates" /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "DisplayWelcome" /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "InformedAboutUpdates2" /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "InputDirectory" /t REG_SZ /d "C:/Program Files/IDA 6.6" /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "QuickFilterFlags" /t REG_DWORD /d 0 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "SplashWindow" /t REG_DWORD /d 0 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA" \
  /v "48-3057-7374-2C6.6" /t REG_DWORD /d 0 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA\\Hidden Messages" \
  /v "Congratulations  the TIL validator is active " /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA\\Hidden Messages" \
  /v "GOOD NEWS  THE BTREE VALIDATOR v66 IS ACTIVE  The btree validator plugin will now verify the input d" \
  /t REG_DWORD /d 1 /f

wine reg add "HKEY_CURRENT_USER\\Software\\Hex-Rays\\IDA\\Hidden Messages" \
  /v "The technical support period of the Hex Rays decompiler has expired  You have 3 month grace period t" \
  /t REG_DWORD /d 1 /f

echo "HKCU keys imported"

# Add Python27 to system PATH so python.plw finds python27.dll
echo "Updating system PATH..."
CUR=$(wine reg query "HKLM\\System\\CurrentControlSet\\Control\\Session Manager\\Environment" /v PATH 2>/dev/null | tr -d '\r' | awk '/PATH/{$1=$2=""; sub(/^[ \t]+/, ""); print}')
wine reg add "HKLM\\System\\CurrentControlSet\\Control\\Session Manager\\Environment" /v PATH /t REG_EXPAND_SZ /d "C:\\Python27;${CUR}" /f
echo "PATH: C:\\Python27;${CUR}"
