(dump)
(dump)
Hi Lutz,
Is it possible to clear a complete function from newlisp
using dump/pack/cpymem.. If yes then what byte do i
exactly need to set/remove to make sure the function is:
a) disabled (or just make it 0x00 ?)
b) cleared from the newlisp stack? (if possible at all)
Thanks in advance... Norman.
Is it possible to clear a complete function from newlisp
using dump/pack/cpymem.. If yes then what byte do i
exactly need to set/remove to make sure the function is:
a) disabled (or just make it 0x00 ?)
b) cleared from the newlisp stack? (if possible at all)
Thanks in advance... Norman.
-- (define? (Cornflakes))
read "doc/hacking_newlisp.html" from the source distribution. Remove the protection bit, then use 'delete' to delete the symbol
I just realize it works not on built-ins
Lutz
I just realize it works not on built-ins
Lutz
Last edited by Lutz on Mon Oct 04, 2004 8:22 pm, edited 2 times in total.
But here is a way to make it work with (set 'print nil) inbetween:
Lutz
Code: Select all
symbol is protected in function set : print
> (cpymem (pack "c c" 0 32) (last (dump 'print)) 2)
2
> (set 'print nil)
nil
> (delete 'print)
true
every combination i make it keep dumping... on linux (slackware 9.1)
(newlisp 8.2.0) ->
bash-2.05b$ newlisp
newLISP v.8.2.0 Copyright (c) 2004 Lutz Mueller. All rights reserved.
> (cpymem (pack "c c" 0 32) (last (dump 'pipe )) 2)
2
> (set 'pipe nil)
nil
> (delete 'pipe)
Segmentation fault
bash-2.05b$ newlisp
newLISP v.8.2.0 Copyright (c) 2004 Lutz Mueller. All rights reserved.
> (cpymem (pack "c c" 0 32) (last (dump 'print )) 2)
2
> (set 'print nil)
nil
> (delete 'print)
Segmentation fault
bash-2.05b$
(newlisp 8.2.0) ->
bash-2.05b$ newlisp
newLISP v.8.2.0 Copyright (c) 2004 Lutz Mueller. All rights reserved.
> (cpymem (pack "c c" 0 32) (last (dump 'pipe )) 2)
2
> (set 'pipe nil)
nil
> (delete 'pipe)
Segmentation fault
bash-2.05b$ newlisp
newLISP v.8.2.0 Copyright (c) 2004 Lutz Mueller. All rights reserved.
> (cpymem (pack "c c" 0 32) (last (dump 'print )) 2)
2
> (set 'print nil)
nil
> (delete 'print)
Segmentation fault
bash-2.05b$
-- (define? (Cornflakes))
I guess it depends on how data-, static- and code segments are organized on different OS's and compilers. My tests where on Win32/MinGW and FreeBSD/GCC, where it seemed to work fine. It probably happens when newLISP is trying to free/access memory for the symbol name, when deleting the symbol of a built-in.
If it crashes your machine, then don't do it :-). This is why this example is in the 'hacking newLISP' section. It should be safe though on all other (non-buit-in) symbols.
What is this all about anyway? Tell us more about what you want to do. Perhaps there is a different approach to make it work.
Lutz
If it crashes your machine, then don't do it :-). This is why this example is in the 'hacking newLISP' section. It should be safe though on all other (non-buit-in) symbols.
What is this all about anyway? Tell us more about what you want to do. Perhaps there is a different approach to make it work.
Lutz
Hello Lutz,
Im trying to create from the current newlisp version a "shell" like replacement
for i.e. Bash/Ksh/csh.... Not all the file/net-io should be usable but must be
configurable per users...Thats why i want to emleminate some functions during
startup of newlisp... Its still expirimental but it would be nice if i could get
newlisp to replace bash on some shell parts...
Regards, Norman.
Im trying to create from the current newlisp version a "shell" like replacement
for i.e. Bash/Ksh/csh.... Not all the file/net-io should be usable but must be
configurable per users...Thats why i want to emleminate some functions during
startup of newlisp... Its still expirimental but it would be nice if i could get
newlisp to replace bash on some shell parts...
Regards, Norman.
-- (define? (Cornflakes))
You could just redefine the built-in to some default message:
The 'silent' avoids that you see the return value from the function, which again would be the message, but quoted.
Becuase you are using 'constant' to redefine the built-in you don't need the 'cpymem' trick at all, (constant 'pipe ...) alone will do it.
Lutz
Code: Select all
(define (default-message) (silent (println "Not a valid command!")))
(constant 'pipe default-message)
(pipe)
Not a valid command!
Becuase you are using 'constant' to redefine the built-in you don't need the 'cpymem' trick at all, (constant 'pipe ...) alone will do it.
Lutz