Friday, May 3, 2019

Disabling Skype's Spellchecker

Long story short, Skype hasn't had an option to disable their spellchecker for aeons and yesterday this really got on my nerve and looked around to find out what it's doing;

The quick solution : Just go to

/Applications/Skype.app/Contents/Resources/app.asar.unpacked/node_modules/@paulcbetts/spellchecker/build/Release/

and remove spellchecker.node . Make a backup of the file, why not.

The explanation : Snooping around in /Applications/Skype.app/ you can find various libs, apparently electron, nodejs, etc were used (interesting) and one of them is suspiciously called 'spellchecker'. Running lsof | grep -i spell will show you that Skype is indeed using the node file ('spellchecker.node'). This file is apparently a nodejs lib from here : https://github.com/anaisbetts/node-spellchecker . Reading the page of the lib it seems that to use it you'd run 'SpellChecker.isMisspelled(word)', to check if a word is misspelled... soo if this is in that lib maybe you could just return a 0x0 and disable the spell checker. The main.cc of the project sets isMisspelled to IsMisspelled :

Nan::SetPrototypeMethod(tpl, "isMisspelled", Spellchecker::IsMisspelled);

So just in case we do a case-insensitive search on the symbol...

nm -gU spellchecker.node | grep -i ismisspelled
0000000000003334 T __ZN12spellchecker15MacSpellchecker12IsMisspelledERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE

00000000000025c8 T __ZN12spellchecker20HunspellSpellchecker12IsMisspelledERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE

And sure enough, there it is. Twice. Since spellchecker.node claims to provide 'Native bindings to NSSpellChecker', I went with the 'Mac' call at 0x3334.

objdump -d ./spellchecker.node --start-address=0x3334 | less

...so next, you just need to overwrite the call so it sets rax to 0x0, then ret back the hell out of there. Once you're done the squiggly red lines disappear and you can merrily type away again.

Personally I used radare2, because it's a great tool and a lot easier to just write asm code than come up with opcodes, but something like this will also work, after you cp spellchecker.node spellchecker_disabled.node :

perl -e "print pack('ccc', 0x31, 0xc0, 0xc3 );" | dd of=./spellchecker_disabled.node bs=1 count=3 conv=notrunc seek=$(nm -gU spellchecker.node  | grep MacSpellchecker12IsMisspelled | cut -d ' ' -f1 | perl -ne "printf '%d', hex($_)")

The cmd above will write the 3 opcodes as bytes to stdout, then pass it on to dd, which in turn will write it at the correct location inside the node lib. And yes, this is just zeroing eax (not rax) out, but maybe you want to do part of the work, huh? Note: this is macos, so the numbers returned by nm are the file offsets. And yeah, perl. I like perltles.

Sunday, March 11, 2018

android sdk systrace probs

systrace :

- if it fails on an adb usb connection because it can't scp the trace output (eg.: ssh: connect to host port 22: Connection refused), try connecting to the box using an ssh tunnel

- if you get '/system/bin/sh: printf: not found' and have busybox, just create a symlink to it

Effective groupids on Android

to get the effective gids :

root@rootedbox:/system # grep com.example.bla /data/system/packages.list

com.example.bla 10064 0 /data/data/com.example.bla default 1028,1015,3003,3002,3001

for list of gids check here ( eg.: AID_SDCARD_RW is 1015 ):

https://android.googlesource.com/platform/system/core/+/master/libcutils/include/private/android_filesystem_config.h

open is implemented here :

https://android.googlesource.com/platform/bionic/+/master/libc/bionic/open.cpp

ls is implemented in toolbox, here : 

https://android.googlesource.com/platform/system/core.git/+/android-4.2.2_r1/toolbox/ls.c

ls maps uids to usernames using getpwuid(), defined here :

https://android.googlesource.com/platform/bionic/+/52d6233296ec84eb5b58fcbf7bc9da4b96a943aa/libc/bionic/stubs.c

'struct passwd' that is returned is defined here :

 https://android.googlesource.com/platform/bionic/+/882b8af/libc/include/pwd.h

Wednesday, September 6, 2017

sdl2 osx opengl transparent background

not sure how often this question comes up, but every now and then you'll have an sdl2 window with opengl rendering and want to make the background transparent (the alpha of glClear is ignored).

here's the osx solution (you need to make the sdl window transparent and also set surface opacity to 0) :
void setOSXWindowTransparent(void *window)
{
 NSWindow *win = (NSWindow *)window;
 [win setOpaque:NO];
 [win setHasShadow:NO];
 [win setBackgroundColor:[NSColor clearColor]];
}

void setSDLWindowTransparent(void * window)
{
 SDL_SysWMinfo info;
 if(SDL_GetWindowWMInfo(static_cast<SDL_Window *>(window),&info))
 {
  setOSXWindowTransparency(info.info.cocoa.window);
 }
}

void setOSXOGLSurfaceOpacity(void *context)
{
 GLint opacity = 0;
 NSOpenGLContext * nscontext = (NSOpenGLContext *)context;
 [nscontext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
}


Friday, January 22, 2016

VirtualBox osx host, ubuntu guest - "Waiting for network configuration"

wanted to cross-compile a project to raspi1 on an ubuntu guest in vbox. ubuntu had eth0 in /etc/network/interfaces, but eth0 didn't exist. attempting to conf eth1 with ifconfig worked, so changed references to eth0 in the /etc file to eth1, works like a charm. hooray for pokey!

Tuesday, October 20, 2015

XWalkWebView

so in case you run into this :

"Please have your activity extend XWalkActivity for shared mode"

while using the awesome xwalkwebview. it may be because you forgot to (or it's disabled by scm rules) commit the .so file in the library project; the android lib will be used, everything will compile, but the .so files will be missed and it will look like you chose 'shared mode' on purpose.

Thursday, September 3, 2015

libcec compilation for android (example)

1. get libplatform
https://github.com/Pulse-Eight/platform

1.1 run cmake in ./build

export ANDROID_NDK=~/dev/android/ndk && cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_toolchains/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/libplatform -DANDROID_ABI=armeabi-v7a -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 ..

1.2 make install

2. get libcec
https://github.com/Pulse-Eight/libcec

2.1 run cmake in ./build

export ANDROID_NDK=~/dev/android/ndk && cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_toolchains/android.toolchain.cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/libcec -DANDROID_ABI=armeabi-v7a -DANDROID_STL=gnustl_static -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DCMAKE_PREFIX_PATH=/tmp/libplatform/lib/platform/ ..

2.2 make install

UPDATE (29/03/16) : add these two lines to CMakeLists.txt for 5.0> :

SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE -pie")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -pie")