cscope-indexer -r -i ~/(path)/cscope.files -f ~/(path)/cscope.out /usr/include/
Wednesday, 30 October 2013
Friday, 6 September 2013
joy2key with anki
joy2key -X -thresh 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -buttons space 1 2
A = default (space), B = wrong answer, X = hard
A = default (space), B = wrong answer, X = hard
Thursday, 5 September 2013
PieceOfWonder has not been installed properly.
Faced this message after trying to run this old novel from an old hard drive without reinstalling. The original installer has been lost, what should I do?
First, let's locate the error message in the binary:
$ objdump -s PieceOfWonder.exe
...
5056c0 50696563 654f6657 6f6e6465 72206861 PieceOfWonder ha
5056d0 73206e6f 74206265 656e2069 6e737461 s not been insta
5056e0 6c6c6564 2070726f 7065726c 792e0000 lled properly...
...
Now let's see where the string is referred from:
$ objdump -d PieceOfWonder.exe |grep -C3 5056c0
406ac6: eb 09 jmp 0x406ad1
406ac8: 6a 00 push $0x0
406aca: 6a 00 push $0x0
406acc: 68 c0 56 50 00 push $0x5056c0
406ad1: e8 21 46 0d 00 call 0x4db0f7
406ad6: 8b 4c 24 08 mov 0x8(%esp),%ecx
406ada: 33 c0 xor %eax,%eax
Basic block that shows the error message starts from 406ac8, what calls it?
$ objdump -dF PieceOfWonder.exe | grep 4069f2
4069f2: 0f 84 d0 00 00 00 je 0x406ac8 (File Offset: 0x6ac8)
So the panic routine is launched by the conditional jump at 4069f2.
Let's try replacing it with NOPs (NOP is a 1-byte instruction that does nothing, thus replacing a jump with them will prevent the program from showing the error dialog box and quitting) and see what it does:
WHOA.
In conclusion, in order to fix the problem, grab any hex editor, open the exe file in it, and replace bytes 69f2 through 69f7 with hexadecimal 90.
Example of what you should see before the edit:
000069f0: e800 0f84 d000 0000 480f 84be 0000 0048
And after:
000069f0: e800 9090 9090 9090 480f 84be 0000 0048
PS
Piece of Wonder does not look like the bane of visual novels so far. A lot of the art looks sketchy and rough, but the characters are certainly cute and the whole game had enough charm to make me want to come back to it. Oh, and it also has a great OP song.
PPS
Really surprised I managed to figure out the problem. And Pin was not needed. Still, a short summary on how to obtain an instruction trace of a program in Wine for future reference:
$ cd pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples && make TARGET=ia32 # make itrace, must be the same arch as the instrumented program
$ winedbg PieceOfWonder.exe
$ .../pin-2.12-58423-gcc.4.4.7-linux/pin.sh -pid $(PoW_exe_pid) -t .../pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples/obj-ia32/itrace.so
Wine-dbg>c
PPPS
Scratch itrace, DebugTrace *is* the PIN tool you want to use! Proper instruction + memory trace with value resolution, mmmm. To run it, do smth like ".../pin/pin -t .../pin/source/tools/DebugTrace/obj-ia32/debugtrace.dylib -instruction -i -memory -unique_logfile -flush -- ./my_binary"
First, let's locate the error message in the binary:
$ objdump -s PieceOfWonder.exe
...
5056c0 50696563 654f6657 6f6e6465 72206861 PieceOfWonder ha
5056d0 73206e6f 74206265 656e2069 6e737461 s not been insta
5056e0 6c6c6564 2070726f 7065726c 792e0000 lled properly...
...
Now let's see where the string is referred from:
$ objdump -d PieceOfWonder.exe |grep -C3 5056c0
406ac6: eb 09 jmp 0x406ad1
406ac8: 6a 00 push $0x0
406aca: 6a 00 push $0x0
406acc: 68 c0 56 50 00 push $0x5056c0
406ad1: e8 21 46 0d 00 call 0x4db0f7
406ad6: 8b 4c 24 08 mov 0x8(%esp),%ecx
406ada: 33 c0 xor %eax,%eax
Basic block that shows the error message starts from 406ac8, what calls it?
$ objdump -dF PieceOfWonder.exe | grep 4069f2
4069f2: 0f 84 d0 00 00 00 je 0x406ac8 (File Offset: 0x6ac8)
So the panic routine is launched by the conditional jump at 4069f2.
Let's try replacing it with NOPs (NOP is a 1-byte instruction that does nothing, thus replacing a jump with them will prevent the program from showing the error dialog box and quitting) and see what it does:
WHOA.
In conclusion, in order to fix the problem, grab any hex editor, open the exe file in it, and replace bytes 69f2 through 69f7 with hexadecimal 90.
Example of what you should see before the edit:
000069f0: e800 0f84 d000 0000 480f 84be 0000 0048
And after:
000069f0: e800 9090 9090 9090 480f 84be 0000 0048
PS
Piece of Wonder does not look like the bane of visual novels so far. A lot of the art looks sketchy and rough, but the characters are certainly cute and the whole game had enough charm to make me want to come back to it. Oh, and it also has a great OP song.
PPS
Really surprised I managed to figure out the problem. And Pin was not needed. Still, a short summary on how to obtain an instruction trace of a program in Wine for future reference:
$ cd pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples && make TARGET=ia32 # make itrace, must be the same arch as the instrumented program
$ winedbg PieceOfWonder.exe
$ .../pin-2.12-58423-gcc.4.4.7-linux/pin.sh -pid $(PoW_exe_pid) -t .../pin-2.12-58423-gcc.4.4.7-linux/source/tools/ManualExamples/obj-ia32/itrace.so
Wine-dbg>c
PPPS
Scratch itrace, DebugTrace *is* the PIN tool you want to use! Proper instruction + memory trace with value resolution, mmmm. To run it, do smth like ".../pin/pin -t .../pin/source/tools/DebugTrace/obj-ia32/debugtrace.dylib -instruction -i -memory -unique_logfile -flush -- ./my_binary"
Tuesday, 30 July 2013
im-switch -s ibus
When in trouble with IME detecting shortcuts (even if it "sees" the window).
Friday, 19 July 2013
Mirroring a website using wget
Every time I have to restore from my memory and man the same line of making a local copy of a website (or a part of it). But enough of that! I'll just post the line here and will never forget as long as this blog is not taken down (which may happen at some point, but who knows when and why?)
wget -N -np -r -l0 -k -p <URL>
wget -N -r -l0 -k -p -D website.edu,img.website.edu http://website.edu/stuffdir/ -I stuffdir -H
Also, this fine man explains how to fix the tilde character converted to a hex value: http://www.kozubik.com/docs/wget_hack.txt (tldr: urlchr_table:url.c). Weird that the source Ubuntu version has it fixed while the binary package doesn't.
This post was brought to you by: a teacup of red wine.
wget -N -np -r -l0 -k -p <URL>
wget -N -r -l0 -k -p -D website.edu,img.website.edu http://website.edu/stuffdir/ -I stuffdir -H
Also, this fine man explains how to fix the tilde character converted to a hex value: http://www.kozubik.com/docs/wget_hack.txt (tldr: urlchr_table:url.c). Weird that the source Ubuntu version has it fixed while the binary package doesn't.
This post was brought to you by: a teacup of red wine.
Sunday, 14 July 2013
LoL
Finding a working version of LoL (the only sane keyboard navigation plugin for Firefox to my knowledge) is getting more and more difficult every time I have to install a new instance of Firefox, so here is the link:
http://elder-gods.org/lol/
http://elder-gods.org/lol/
Tuesday, 21 May 2013
Tuesday, 2 April 2013
Fixing the "stack overflow in regexp matcher" error in Emacs.
I'm using a relatively large ctags file (~20 Mb) built for a C project I'm working on and I ran into the problem recently that the complete-symbol command (Ctrl-Alt-i) that auto-completes function and variable names in C files fails with the "stack overflow in regexp matcher" error.
Long story short, you need to increase the re_max_failures variable located in regex.c to fix this. Is this the right way? I don't know, but it works for me and the comments were not very clear to elaborate. There is also some "smart" logic related to re_max_failures in emacs.c that apparently tries to tweak it to the best value possible, but it turns out to be not smart enough for my use case.
This post was brought to you by GDB Reverse Debugging: Occasionally useful results for those who've got some lifetime to spare!
Long story short, you need to increase the re_max_failures variable located in regex.c to fix this. Is this the right way? I don't know, but it works for me and the comments were not very clear to elaborate. There is also some "smart" logic related to re_max_failures in emacs.c that apparently tries to tweak it to the best value possible, but it turns out to be not smart enough for my use case.
This post was brought to you by GDB Reverse Debugging: Occasionally useful results for those who've got some lifetime to spare!
Labels:
ctags,
emacs,
pain in the arse,
regexp,
stack overflow,
tags
Thursday, 14 March 2013
Probabilities in the game of Quasar.
def getPrize(num):
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
if num == 15:
return 5
elif num == 16:
return 10
elif num == 17:
return 20
elif num == 18:
return 25
elif num == 19:
return 30
elif num == 20:
return 40
else:
return 0
def getRoll(before):
if before > 20:
return ((), 0)
best_roll = ()
best_avg = getPrize(before)
for roll in (range(1,9), range(4,8)):
avg = 0.
for i in roll:
avg += getRoll(before + i)[1]
avg /= float(len(roll))
if avg > best_avg:
best_avg = avg
best_roll = roll
return (best_roll, best_avg)
for before in range(20):
roll=getRoll(before)
print("%d: %s(%f)" % (before, str(roll[0]), roll[1]))
Which leaves us with the following table of the best bets:
current sum: best choice option (average money won)
0: 4..7(24.459561)
1: 4..7(24.461427)
2: 4..7(23.844185)
3: 1..8(23.573145)
4: 1..8(23.723004)
5: 1..8(24.281559)
6: 4..7(24.718933)
7: 4..7(25.114746)
8: 4..7(23.730469)
9: 1..8(21.812592)
10: 1..8(22.166748)
11: 1..8(23.037109)
12: 1..8(24.921875)
13: 4..7(28.750000)
14: 4..7(23.750000)
15: 4..7(17.500000)
16: 1..8(14.375000)
17+: stop
Too bad the wages are too low to make it a viable source of income.
Saturday, 12 January 2013
Wheezy GTK in KDE4 black on black
1) /etc/kde/kdm/kdmrc: TerminateServer=true
2) restart
via http://www.linuxquestions.org/questions/slackware-14/next-kde-4-8-2-regression-firefox-thunderbird-joined-the-all-blacks-942693/
2) restart
via http://www.linuxquestions.org/questions/slackware-14/next-kde-4-8-2-regression-firefox-thunderbird-joined-the-all-blacks-942693/
Subscribe to:
Posts (Atom)