mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-02 03:32:04 +00:00
Implement 'woe' command and honor NOSUDO and PREFIX in sys/*.sh
This commit is contained in:
parent
24ccb7aabb
commit
7517099976
@ -362,6 +362,7 @@ static int cmd_write(void *data, const char *input) {
|
||||
switch (input[1]) {
|
||||
case 'a':
|
||||
case 's':
|
||||
case 'e':
|
||||
case 'A':
|
||||
case 'x':
|
||||
case 'r':
|
||||
@ -371,7 +372,10 @@ static int cmd_write(void *data, const char *input) {
|
||||
case 'o':
|
||||
case 'w':
|
||||
if (input[2]!=' ') {
|
||||
r_cons_printf ("Usage: 'wo%c 00 11 22'\n", input[1]);
|
||||
if (input[1]=='e') r_cons_printf (
|
||||
"Usage: 'woe from-to step'\n");
|
||||
else r_cons_printf (
|
||||
"Usage: 'wo%c 00 11 22'\n", input[1]);
|
||||
return 0;
|
||||
}
|
||||
case '2':
|
||||
@ -393,6 +397,7 @@ static int cmd_write(void *data, const char *input) {
|
||||
" wox 90 ; xor cur block with 0x90\n"
|
||||
" wox 0x0203 ; xor cur block with 0203\n"
|
||||
" woa 02 03 ; add [0203][0203][...] to curblk\n"
|
||||
" woe 02 03 \n"
|
||||
"Supported operations:\n"
|
||||
" wow == write looped value (alias for 'wb')\n"
|
||||
" woa += addition\n"
|
||||
|
@ -44,12 +44,40 @@ R_API int r_core_write_op(RCore *core, const char *arg, char op) {
|
||||
if (buf == NULL || str == NULL)
|
||||
goto beach;
|
||||
memcpy (buf, core->block, core->blocksize);
|
||||
len = r_hex_str2bin (arg, (ut8 *)str);
|
||||
if (len==-1) {
|
||||
eprintf ("Invalid hexpair string\n");
|
||||
goto beach;
|
||||
}
|
||||
if (op!='e') {
|
||||
len = r_hex_str2bin (arg, (ut8 *)str);
|
||||
if (len==-1) {
|
||||
eprintf ("Invalid hexpair string\n");
|
||||
goto beach;
|
||||
}
|
||||
} else len = 0;
|
||||
|
||||
if (op=='e') {
|
||||
char *p, *s = strdup (arg);
|
||||
int n, from = 0, to = 0, dif = 0, step = 1;
|
||||
n = from = to;
|
||||
to = UT8_MAX;
|
||||
//
|
||||
p = strchr (s, ' ');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
step = atoi (p+1);
|
||||
}
|
||||
p = strchr (s, '-');
|
||||
if (p) {
|
||||
*p = 0;
|
||||
to = atoi (p+1);
|
||||
}
|
||||
if (to<1 || to>UT8_MAX) to = UT8_MAX;
|
||||
from = atoi (s);
|
||||
free (s);
|
||||
dif = (to<=from)? UT8_MAX: (to-from)+1;
|
||||
from %= (UT8_MAX+1);
|
||||
if (dif<1) dif = UT8_MAX+1;
|
||||
if (step<1) step = 1;
|
||||
for (i=n=0; i<core->blocksize; i++, n+= step)
|
||||
buf[i] = (ut8)(n%dif)+from;
|
||||
} else
|
||||
if (op=='2' || op=='4') {
|
||||
op -= '0';
|
||||
for (i=0; i<core->blocksize; i+=op) {
|
||||
|
15
sys/build.sh
15
sys/build.sh
@ -1,7 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
MAKE_JOBS=8
|
||||
PREFIX=/usr
|
||||
[ -z "${PREFIX}" ] && PREFIX=/usr
|
||||
|
||||
case "$1" in
|
||||
-h)
|
||||
echo "Usage: sys/build.sh [/usr]"
|
||||
exit 0
|
||||
;;
|
||||
'')
|
||||
:
|
||||
;;
|
||||
*)
|
||||
PREFIX="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ ! "${PREFIX}" = /usr ] && \
|
||||
CFGARG=--with-rpath
|
||||
|
@ -15,5 +15,6 @@ elif [ -d .git ]; then
|
||||
fi
|
||||
|
||||
[ "`id -u`" = 0 ] || SUDO=sudo
|
||||
[ -n "${NOSUDO}" ] && SUDO=
|
||||
|
||||
./sys/build.sh && ${SUDO} ${MAKE} symstall
|
||||
./sys/build.sh $@ && ${SUDO} ${MAKE} symstall
|
||||
|
@ -4,14 +4,18 @@
|
||||
cd `dirname $PWD/$0` ; cd ..
|
||||
|
||||
. ./sys/CONFIG
|
||||
echo =============
|
||||
cat sys/CONFIG
|
||||
echo =============
|
||||
|
||||
[ -z "${PREFIX}" ] && PREFIX=/usr
|
||||
ID=`id -u`
|
||||
if [ "$ID" = 0 ]; then
|
||||
SUDO=
|
||||
else
|
||||
SUDO=sudo
|
||||
fi
|
||||
[ -n "${NOSUDO}" ] && SUDO=
|
||||
|
||||
export PYTHON
|
||||
export PYTHON_VERSION
|
||||
@ -22,7 +26,7 @@ echo "Using PYTHON_CONFIG ${PYTHON_CONFIG}"
|
||||
echo
|
||||
|
||||
cd r2-bindings
|
||||
./configure --prefix=/usr --enable=python || exit 1
|
||||
./configure --prefix=${PREFIX} --enable=python || exit 1
|
||||
${SUDO} make install-vapi || exit 1
|
||||
cd python
|
||||
make clean
|
||||
|
Loading…
x
Reference in New Issue
Block a user