#!/usr/bin/perl use strict; use FileHandle; my $fn = 'td.elf'; my $fh = FileHandle->new($fn, '+< :raw') or die "$fn: $!"; $fh->binmode(':raw'); my $o1 = 0x21fc73c; my $inb; $fh->seek($o1, 0); $fh->read($inb, 2); if ($inb eq "\x7e\x0d") { print("Chunk#1: patched\n"); $fh->seek($o1, 0); $fh->write("\x90\x90", 2); } elsif ($inb eq "\x90\x90") { print("Chunk#1: already patched\n"); } else { printf("Chunk#1: unknown sequence: %02x.%02x\n", unpack("C2", $inb)); } my $o2 = 0x21fc744; $fh->seek($o2, 0); $fh->read($inb, 2); if ($inb eq "\x75\xb4") { print("Chunk#2: patched\n"); $fh->seek($o2, 0); $fh->write("\xEB", 1); } elsif ($inb eq "\xEB\xb4") { print("Chunk#2: already patched\n"); } else { printf("Chunk#2: unknown sequence: %02x.%02x\n", unpack("C2", $inb)); } $fh->close(); __END__ .text:00000000021FC736 loc_21FC736: ; CODE XREF: ValidateLicense(std::string const&,char *)+B88j .text:00000000021FC736 mov edx, [rcx+10h] .text:00000000021FC739 cmp r12d, edx .text:00000000021FC73C jle short l_21FC74B_lic_expired .text:00000000021FC73E add edx, 1 .text:00000000021FC741 cmp r12d, edx .text:00000000021FC744 jnz short lc_21FC6FA_lic_ok .text:00000000021FC746 cmp esi, [rcx+0Ch] .text:00000000021FC749 jge short lc_21FC6FA_lic_ok