[ros-kernel] Kdb scripting

art yerkes ayerkes at speakeasy.net
Thu Jan 8 02:37:49 CET 2004


I've been talking and thinking about making kdb scriptable for a while,
so I finally broke down and did it.  Actually, it's not as hard as it
sounds.  

Those interested in the development of kdb may be interested in trying
out what's there so far.  It's acutally pretty useful, and will become
more so as more features are added.  To use it just build a KDB=1 
kernel, update your registry with the new registry entries in the patch,
and type 'js' at the kdb prompt.

Bug #139 contains a patch that gives kdb a 'js' command to invoke the
kernel javascript interpreter.  There are some builtin functions and
some other created by the initialization code stored in the registry.

An example of what you can do in it:

kjs:> write(ebp().toString(16));;
cee8bf84

But wait, there's more:

kjs:> function dump_sec(base) {
.....   base2 = peekw(base + 0x3c) + base;
.....   sec_off = 0xf8;
.....   for( i = 0; peekl(base2 + sec_off + (40 * i)); i++ ) {
.....     base_sec = base2 + sec_off + (40 * i);
.....     write("Section: " + System.mread(0,base_sec) + "\n");
.....     write("RVA:     " + peekl(base_sec + 12).toString(16) + "\n");
.....   }
..... }
..... ;;

kjs:> dump_sec(0xc0000000);;
Section: .text
RVA:     1000
Section: init
RVA:     e6000
Section: .data
RVA:     f4000
Section: .edata
RVA:     10d000
Section: .idata
RVA:     115000
Section: .rsrc
RVA:     116000
Section: .bss
RVA:     118000
Section: .reloc
RVA:     15a000

And:

kjs:> var key = "\\registry\\machine\\system\\currentcontrolset\\services\\ne200
01\\parameters\\tcpip";;

kjs:> write(regread(key,"defaultgateway"));;
10.0.0.1

-- 
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected
 without, I thought, proper consideration."
   - S. Kelly-Bootle


More information about the Ros-kernel mailing list