512B (Selfer)
Posted: Sat Mar 16, 2013 10:00 am
Hi,
Inspired by this thread, and especially DavidCooper's BwtSecOS, I took out some time to write Selfer. Selfer has got similar goals to BwtSecOS, and even though I cheated a bit by writing it in assembly, I think it does the job pretty well...
So, what all does it do?
First of all, Selfer assumes 0x7C00 to represent LBA 0, 0x7E00 to represent LBA 1, and so on. It then displays a byte stream from 0x7C00 to 0x7E00, makes the first byte "green" in color, displays the address of the first byte down below, and enters into an input loop, which, for the following characters, behaves as mentioned:
Thanks to Antti, for the idea; DavidCooper, for BwtSecOS; nortti for attempting to figure out what it's about from the hexdump.
Bugs
I've tried to fit a lot in there, so there are some bugs which I'm trying to fix without cutting down on functionality. These are (and the list would be extended as/when bugs are found):
Shikhin
EDIT: Things have changed for Selfer. You'd need to scroll down a bit, to see what all's different, now.
Inspired by this thread, and especially DavidCooper's BwtSecOS, I took out some time to write Selfer. Selfer has got similar goals to BwtSecOS, and even though I cheated a bit by writing it in assembly, I think it does the job pretty well...
So, what all does it do?
First of all, Selfer assumes 0x7C00 to represent LBA 0, 0x7E00 to represent LBA 1, and so on. It then displays a byte stream from 0x7C00 to 0x7E00, makes the first byte "green" in color, displays the address of the first byte down below, and enters into an input loop, which, for the following characters, behaves as mentioned:
- Left, or right arrow key. You can move between offsets into the sector, like this. Left key for previous byte; right key for next byte. I display a nice green color to indicate which is the "current" byte, but don't really change the cursor position. It also wraps around, and displays the address of the current byte down below.
- Down, or up arrow key. You can move between sectors, like this. Up key for previous sector, and down key for next sector. Moving between sectors automatically writes the current one to disk. Also, note that the lower bound is 0x7C00; the upper bound is 0x80000. If you look at the hexdump, it's pretty easy to change these values yourself.
- 'j'. This jumps to whatever the current address 0xYXXXX is, like 0xY000:0xXXXX. It also pushes a return address, so you can do a 'ret', and get back into the loop.
- 'r' & 'p'. 'r' copies the current value of the byte we're at, while 'p' pastes the value you copied last. It's supposed to paste 0x00, if you copied nothing.
- 'w'. That writes the current sector. Just in case you don't want to go the next/previous sector for writing.
- '>' & '<'. '>' increments the current byte (greater than), while '<' decrements it (smaller than).
- Input. Other than that, you can directly input hexadecimal values (both upper and lowercase accepted). It takes in the input, and moves to the next byte. It's not exactly safe, so try only to enter hexadecimal values.
Thanks to Antti, for the idea; DavidCooper, for BwtSecOS; nortti for attempting to figure out what it's about from the hexdump.
Bugs
I've tried to fit a lot in there, so there are some bugs which I'm trying to fix without cutting down on functionality. These are (and the list would be extended as/when bugs are found):
- In 'j' handling, while I do jump between segments, I don't push the segment for Selfer, which means that if the code jumped to returns without resetting CS, plausible bugs can ensue! But then, again, I don't reset 'ebp' either. I don't fix a lot of stuff. Returning from code you jumped to, isn't... advisable. EDIT: FIXED. You now need a far ret to properly return back to the event loop. It then resets ebp, and everything should work fine (as long as you don't touch the first 6 bytes of 0x500, and the stack ain't messed up).
Shikhin
EDIT: Things have changed for Selfer. You'd need to scroll down a bit, to see what all's different, now.