Monday, October 10, 2011

HOW TO PATCH A BYTE OF A BINARY FILE USING QBASIC / FREEBASIC / VISUAL BASIC - A BINARY FILE PATCHER














Byte Number in Hex Editor Usually in Hexadecimal

..0..1..2..3..4..5..6..7 Hex Editor Offset Byte Number
B4 02 B2 01 CD 21 CD 20
^
|
Starting Offset Byte is 0 with Hex Editor, but for Qbasic / FreeBasic / Visual Basic Starting Offset Byte Starts with 1,

Source Code :-

CLS
PRINT "ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»"
PRINT ""
PRINT " BYTE PATCHER "
PRINT ""
PRINT " JALI Software 2011 "
PRINT ""
PRINT "ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ"

ON ERROR GOTO ErrHand:
OPEN "SMILE.COM" FOR INPUT AS #2
CLOSE #2

OPEN "SMILE.COM" FOR BINARY AS #1
a$ = CHR$(&H2) ' Byte value that we want to change
PUT #1, &H3 + 1, a$
' Offset Byte Must + 1 since Qbasic / FreeBasic / Visual Basic starting byte starts with 1
CLOSE #1

LOCATE 15, 30: PRINT "** DONE **"

LOCATE 23, 25: PRINT "--- Press Any Key ---"
WHILE INKEY$ = "": WEND
END

ErrHand:

LOCATE 10, 4: PRINT " ERROR - FILE NOT FOUND "
LOCATE 23, 25: PRINT "--- Press Any Key ---"
WHILE INKEY$ = "": WEND
END

Run the Patch and see how the program change :)

No comments: