JSLinux rewritten to be human readable, hand deobfuscated and annotated.
Go to file
Anselm Levskaya 541ce3c478 Added comments and clarification on the PIC and PIT emulation code. 2013-09-15 20:17:04 -07:00
refactoring_hacks autocommented the weird operation-size-counting function 2011-12-23 21:08:07 -08:00
CMOS.js Added comments and clarification on the PIC and PIT emulation code. 2013-09-15 20:17:04 -07:00
KBD.js Clarified licensing information subject to the received permission of Fabrice Bellard to post this derivative work online. 2013-03-28 19:43:44 -07:00
LICENSE Clarified licensing information subject to the received permission of Fabrice Bellard to post this derivative work online. 2013-03-28 19:43:44 -07:00
PCEmulator.js Added comments and clarification on the PIC and PIT emulation code. 2013-09-15 20:17:04 -07:00
PIC.js Added comments and clarification on the PIC and PIT emulation code. 2013-09-15 20:17:04 -07:00
PIT.js Added comments and clarification on the PIC and PIT emulation code. 2013-09-15 20:17:04 -07:00
Serial.js Clarified licensing information subject to the received permission of Fabrice Bellard to post this derivative work online. 2013-03-28 19:43:44 -07:00
clipboard.js Clarified licensing information subject to the received permission of Fabrice Bellard to post this derivative work online. 2013-03-28 19:43:44 -07:00
cpux86-ta.js Clarified licensing information subject to the received permission of Fabrice Bellard to post this derivative work online. 2013-03-28 19:43:44 -07:00
cpux86-ta.original.js added the actual original cpu code for reference 2011-12-21 01:08:54 -08:00
index.html Split massive emulator code into logical parts. 2011-12-20 21:34:38 -08:00
jslinux.js moved files 2011-12-16 21:38:46 -08:00
linuxstart-20110820.tar.gz more notes 2011-12-17 04:22:50 -08:00
linuxstart.bin moved files 2011-12-16 21:38:46 -08:00
readme.md Synchronous XHR loading policies changed in new browsers breaking the current emulator on them, noted in readme. 2013-09-15 20:16:18 -07:00
root.bin moved files 2011-12-16 21:38:46 -08:00
term.js finished naming functions insofar as I can without overspeculating on a few of the cryptic flow-control routines. 2011-12-25 06:32:25 -08:00
vmlinux-2.6.20.bin moved files 2011-12-16 21:38:46 -08:00

readme.md

De-obfuscated JSLinux

I wanted to understand how the amazing JsLinux worked.

However the original was passed through a minifier and was completely incomprehensible in that form. (Mr Bellard's standards for the code that he open sources is very high.) I couldn't wait for the proper release of the opus, so in a fit of mania I hand de-obfuscated the codebase (primarily the core cpu-emulation routines and a bit of the rest as well) while studying it over a few days' time.

In the off-chance someone else might be interested in this code as a basis for further weird in-browser x86 hacking I'm posting this redacted version of the code here, with permission of Mr. Bellard.

Note that there is a much more readable, ground-up project to build an open-source 386-style emulator in javascript called jslm32.

Status

The current codebase won't run on recent webkit browsers due to a breaking change in the way Synchronous XHR requests are handled. The binary loading routines need to be rewritten to be asynchronous, not terribly hard but annoying enough that I haven't just done it. (Fabrice's original online version has been patched and runs fine.)

jslinux-deobfuscated is still a dense code base, it's an emulator of a rather complicated architecture, after all. However this version is nowhere near so incomprehensible as the original. Nearly all of the global variables and function names have been named somewhat sensibly. Many comments have been added.

The core opcode execution loop has been autocommented to indicate what instruction operation the opcode refers to.

One mystery is, why does CPUID(1) return 8 << 8 in EBX? EBX[15:8] is now used to indicate CLFLUSH line size, but that field must have been used for something else in the past.

ETC

I highly recommend, by the way, the excellent JSShaper library for transforming large javascript code bases. The hacks I made from it are in this repo: a little symbol-name-transformer node.js script and an emacs function for doing this in live buffers.

License

This is a pedagogical/aesthetic derivative of the original JSLinux code Copyright (c) 2011-2013 Fabrice Bellard. It is posted here with permission of the original author subject to his original constraints : Redistribution or commercial use is prohibited without the (original) author's permission.

References

Some other helpful references for understanding what's going on:

x86

Bit Hacking

Other devices