#!/usr/bin/tclsh
#
# ps3mfw -- PS3 MFW creator
#
# Copyright (C) Anonymous Developers (Code Monkeys)
#
# This software is distributed under the terms of the GNU General Public
# License ("GPL") version 3, as published by the Free Software Foundation.
#
# Created By RazorX
# Priority: 700
# Description: Patch PSN Activator
# Option --allow-activating-psn: Patch to allow activating psn content offline
# Type --allow-activating-psn: boolean
namespace eval :

atch_vsh_psn {
array set :

atch_vsh_psn::options {
--allow-activating-psn true
}
proc main { } {
set self [file join dev_flash vsh module vsh.self]
::modify_devflash_file $self :

atch_vsh_psn:

atch_self
}
proc patch_self {self} {
if {!$:

atch_vsh_psn::options(--allow-activating-psn)} {
log "WARNING: Enabled task has no enabled option" 1
} else {
::modify_self_file $self :

atch_vsh_psn:

atch_elf
}
}
proc patch_elf {elf} {
if {$:

atch_vsh_psn::options(--allow-activating-psn)} {
log "Patching [file tail $elf] to allow activating psn content offline"
set offset "0x30b230"
set search "\x4b\xcf\x5b\x45"
set replace "\x38\x60\x00\x00"
catch_die {:

atch_elf $elf $search 0 $replace} "Unable to patch self [file tail $elf]"
set offset "0x30ac90"
set search "\x48\x31\xb4\x65"
set replace "\x38\x60\x00\x00"
catch_die {:

atch_elf $elf $search 20 $replace} "Unable to patch self [file tail $elf]"
log "WARNING: activating psn content offline requires reActPSN application" 1
}
}
}