コード例 #1
0
def main():
    if len(sys.argv) > 2:
        print('USAGE: %s <file>' % sys.argv[0])
        return

    #Allow user to provide filename during execution
    if len(sys.argv) == 2:
        outFile = sys.argv[1]
    else:
        outFile = input('Name of file to write: ')

    handhelds = Handheld.FindHandhelds()

    if len(handhelds) == 0:
        print('No handhelds are connected.')
        return

    #Get and dump the OTP for the first connected handheld
    handheld = handhelds[0]

    otp = handheld.ReadOTP()

    with open(outFile, 'wb') as f:
        f.write(otp)

    checksumLong = '%06X' % sum(otp)
    checksumShort = checksumLong[-4:]

    print('OTP checksum is %s (displayed as %s on 1.0 firmware)' %
          (checksumLong, checksumShort))
コード例 #2
0
def main():
    if len(sys.argv) > 2:
        print('USAGE: %s <creditz>' % sys.argv[0])
        return

    handhelds = Handheld.FindHandhelds()

    if len(handhelds) == 0:
        print('No handhelds are connected.')
        return

    #Allow user to provide creditz during execution
    if len(sys.argv) == 2:
        creditz = sys.argv[1]
    else:
        creditz = input('New creditz value: ')

    #Ensure that the creditz value is a number
    try:
        creditz = int(creditz)
    except:
        print('Number of creditz needs to be an integer.')
        return

    #Operate on the first connected handheld
    handheld = handhelds[0]

    data = handheld.ReadPage(1, 0xFF)

    creditzhcd = HexCodedDecimal(creditz)
    data = list(data)
    data[0x9AA:0x9AE] = list(creditzhcd)
    data = bytes(data)

    handheld.WritePage(data, 1, 0xFF)
コード例 #3
0
def main():
    if len(sys.argv) > 2:
        print('USAGE: %s <file>' % sys.argv[0])
        return

    #Allow user to provide filename during execution
    if len(sys.argv) == 2:
        inFile = sys.argv[1]
    else:
        inFile = input('Name of file to load from: ')

    if not os.path.isfile(inFile):
        print('"%s" does not exist, so it cannot be loaded.' % inFile)
        return

    handhelds = Handheld.FindHandhelds()

    if len(handhelds) == 0:
        print('No handhelds are connected.')
        return

    #Get and load to the first connected handheld
    handheld = handhelds[0]
    handheld.WriteFull(inFile)
    handheld.Eject()
コード例 #4
0
def main():
    handheld = Handheld.FindHandhelds()[0]

    buttons = [
        'Mute', 'Action', 'Screen Bottom Right', 'Screen Bottom Left',
        'Screen Top Right', 'Screen Top Left', 'Upside-Down', 'Upside-Up',
        'Menu', 'Power', 'Right', 'Left', 'Down', 'Up'
    ]
    while True:
        data = handheld.ReadRamLeak()[0x3FFF:0x4001]
        mask, = struct.unpack('<H', data)
        #print(bin(mask))

        print(', '.join([
            x for i, x in enumerate(buttons)
            if (not (1 << (len(buttons) - 1 - i)) & mask) and x
        ]))
コード例 #5
0
ファイル: FastLoad.py プロジェクト: NovaSquirrel/MiuchizGames
def main():
    if len(sys.argv) != 3:
        print('USAGE: %s <Flash clone file> <Flash load file>' % sys.argv[0])
        return
    handheld = Handheld.FindHandhelds()[0]
    clone, load = sys.argv[1:3]
    
    while True:
        try:
            with open(clone, 'rb') as f:
                cloneData = f.read()
            break
        except FileNotFoundError:
            handheld.DumpFull(clone)

    with open(load, 'rb') as f:
        loadData = f.read()

    BANK_LENGTH = 1048576
    PAGE_LENGTH = 0x1000

    if len(loadData) != BANK_LENGTH * 2 and len(cloneData) != BANK_LENGTH * 2:
            raise Exception('Full handheld data should be 2097152 bytes.')

    for bank in range(2):
        for page in range(256):
            bankstart = bank * BANK_LENGTH
            pagestart = bankstart + page * PAGE_LENGTH
            pageend = bankstart + (page+1) * PAGE_LENGTH

            thisLoadData = loadData[pagestart : pageend]
            thisCloneData = cloneData[pagestart : pageend]

            if thisLoadData == thisCloneData:
                continue

            print('Writing bank %d, page %d.' % (bank, page))
            
            handheld.WritePage(thisLoadData, bank, page)

    with open(clone, 'wb') as f:
        print('Updating clone file.')
        f.write(loadData)
    
    handheld.Eject()
コード例 #6
0
def main():
    if len(sys.argv) > 2:
        print('USAGE: %s <file>' % sys.argv[0])
        return

    #Allow user to provide filename during execution
    if len(sys.argv) == 2:
        outFile = sys.argv[1]
    else:
        outFile = input('Name of file to write: ')

    handhelds = Handheld.FindHandhelds()

    if len(handhelds) == 0:
        print('No handhelds are connected.')
        return

    #Get and dump the first connected handheld
    handheld = handhelds[0]
    handheld.DumpFull(outFile)
コード例 #7
0
def main():
    handheld = Handheld.FindHandhelds()[0]
    data = handheld.ReadPage(1, 0xFF)
    creditz = UndoHCD(data[0x9AA:0x9AE])
    print(creditz)
コード例 #8
0
def main():
    handheld = Handheld.FindHandhelds()[0]
    handheld.Eject()