Thursday, October 29, 2009

Android NDK Makefile

(1) install NDK 1.6 in say
~/Android/android-ndk-1.6_r1

download http://developer.android.com/sdk/ndk/1.6_r1/index.html

(2) install SDK 1.6 in say
~/Android/android-sdk-linux_x86-1.6_r1

download http://developer.android.com/sdk/1.6_r1/index.html

(3) you can compile standalone C program like this hello.c using the Makefile below

#include <stdio.h>
int main() {
  printf("hello, NDK makefile world\n");
  return 0;
}


(4) Create Makefile
Makefile Select all

APP=hello

NDK_DIR := /cygdrive/c/Android/android-ndk-1.6_r1
#NDK_DIR := ~/Android/android-ndk-1.6_r1
NDK_HOST := windows
#NDK_HOST := linux-x86
#NDK_HOST := darwin-x86
SDKTOOL := /cygdrive/c/Android/android-sdk-windows-1.6_r1/tools
#SDKTOOL := ~/Android/android-sdk-linux_x86-1.6_r1/tools
#SDKTOOL := ~/Android/android-sdk-mac_x86-1.6_r1/tools

TOOLCHAIN_PREFIX := $(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/bin/arm-eabi-
CC := $(TOOLCHAIN_PREFIX)gcc
CPP := $(TOOLCHAIN_PREFIX)g++
LD := $(CC)

COMMON_FLAGS := -mandroid -ffunction-sections -fdata-sections -Os -g --sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm \
-fPIC \
-fvisibility=hidden \
-D__NEW__

CFLAGS := $(COMMON_FLAGS)

CFLAGS += -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG

CFLAGS += -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -ffunction-sections -funwind-tables -fstack-protector -fmessage-length=0 -Bdynamic


CPPFLAGS := $(COMMON_FLAGS) \
-fno-rtti -fno-exceptions \
-fvisibility-inlines-hidden

LDFLAGS += --sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm
LDFLAGS += -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/android
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/lib/gcc
LDFLAGS += -L$(NDK_DIR)/build/prebuilt/$(NDK_HOST)/arm-eabi-4.2.1/arm-eabi/lib
LDFLAGS += -nostdlib -lc -llog -lgcc \
--no-undefined -z $(NDK_DIR)/build/platforms/android-4/arch-arm/usr/lib/crtbegin_dynamic.o $(NDK_DIR)/build/platforms/android-4/arch-arm/usr/lib/crtend_android.o

OBJS += $(APP).o

all: $(APP)

$(APP): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^

%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

%.o: %.cpp
$(CPP) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

install: $(APP)
$(SDKTOOL)/adb push $(APP) /data/local/bin/$(APP)
$(SDKTOOL)/adb shell chmod 755 /data/local/bin/$(APP)

run:
$(SDKTOOL)/adb shell /data/local/bin/$(APP)

clean:
@rm -f $(APP).o $(APP)


(5) connect device and test using

make all
make install run


(6) compile C++ program example1.cpp (no STL)

make APP=example1 all install run


example1.cpp Select all

#include <stdio.h>

class counter {
public:
int some_data;
char some_other_data[100];
int i;

void increment_counter() {i++;}
void decrement_counter() {i--;}
int query_counter() {return i;}

void set_counter(int new_value);
};

void counter::set_counter(int new_value)
{
i = new_value;
}

main()
{
counter apples;
counter oranges;
counter *pointer_to_counter = NULL;
counter array_of_counters[10];
int x = 5;

apples.some_data = x;

apples.set_counter(10);
apples.increment_counter();
apples.increment_counter();

oranges.set_counter(5);
oranges.decrement_counter();

printf("%d apples and %d oranges\n",
apples.query_counter(),
oranges.query_counter());
}





Saturday, October 24, 2009

Android NDK add stlport and compile C++ program

(1) Assume you have Android ndk 1.6 and your ndk directory is in ~/Android/android-ndk-1.6_r1 and you are using mac
download ndk-wrapper from

cd ~/Android
git clone git://umbel.mooo.com/ndk-wrappers.git


reference
http://umbel.mooo.com/git?p=ndk-wrappers.git;a=summary

(2) Edit ~/Android/ndk-wrappers/setup.sh and add these

export HOST=darwin-x86
export NDK_DIR=~/Android/android-ndk-1.6_r1
export NDK_WRAPPERS_BASE=~/Android/ndk-wrappers


(3) Edit ~/Android/ndk-wrappers/scripts/build-stlport.sh ad add these

export NDK_WRAPPERS_BASE=~/Android/ndk-wrappers
export PATH=~/Android/ndk-wrappers/bin:$PATH


(4) Edit ~/Android/ndk-wrappers/scripts/env-utils.sh and change / add these

SYSROOT="${NDK_DIR}/build/platforms/android-4/arch-arm"
HOST=darwin-x86


For linux
HOST=linux-x86

For CYGWIN
HOST=windows

(5) Change ~/Android/ndk-wrappers/stlport/build/lib/android.mak
from

--sysroot=$(NDK_DIR)/build/platforms/android-1.5/arch-arm \


to

--sysroot=$(NDK_DIR)/build/platforms/android-4/arch-arm \


(6) Add link

cd ~/Android/ndk-wrappers/stlport/build/Makefiles/gmake
ln -s linux arm-linux


(7) For Mac only, upgrade sed using Mac port

sudo port install gsed
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed



(8) build stlport

cd ~/Android/ndk-wrappers
export NDK_DIR=~/Android/android-ndk-1.6_r1
./setup.sh


(9) Create hello.cpp to test

#include <iostream>
using namespace std;
int main() {
  cout << "hello, world\n";
  return 0;
}


(10) Compile

~/Android/ndk-wrappers/bin/arm-linux-g++ -o hello hello.cpp -L~/Android/ndk-wrappers/stlport/build/lib/obj/arm-linux-gcc/so


(11) Sent to device for testing

adb push hello /data/local/bin/hello
adb shell chmod 755 /data/local/bin/hello
adb shell /data/local/bin/hello


You can use Makefile
Makefile Select all

APP := hello
SDKTOOL := ~/Android/android-sdk-mac_x86-1.6_r1/tools
WRAPPER := ~/Android/ndk-wrappers
STLLIB := -L~/Android/ndk-wrappers/stlport/build/lib/obj/arm-linux-gcc/so
BIN := $(WRAPPER)/bin
CPP := $(BIN)/arm-linux-g++
CC := $(BIN)/arm-linux-gcc

all: $(APP)

OBJS += $(APP).o

$(APP): $(OBJS)
$(CPP) $(LDFLAGS) -o $@ $(STLLIB) $^

%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@

%.o: %.cpp
$(CPP) -c $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $< -o $@

install: $(APP)
$(SDKTOOL)/adb push $(APP) /data/local/bin/$(APP)
$(SDKTOOL)/adb shell chmod 755 /data/local/bin/$(APP)

shell:
$(SDKTOOL)/adb shell

run:
$(SDKTOOL)/adb shell /data/local/bin/$(APP)

clean:
@rm -f $(APP).o $(APP)






Tuesday, October 6, 2009

Sunday, September 13, 2009

default write

Disable iTunes Device backup

defaults write com.apple.iTunes DeviceBackupsDisabled -bool true

Sunday, July 19, 2009

Fix SSH timeout for jailbreak iPhone

Login iPhone and edit /etc/ssh/sshd_config and change the line

from

#ClientAliveInterval 0

to

ClientAliveInterval 60

According to man sshd_config, this line,

Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only.

Don’t forget to restart sshd on the iPhone after you save the file.

Thursday, July 16, 2009

WinRAR v3.80 Serial Number

WinRAR v3.80

choose either one of them
create a document called rarreg.key and put it in C:\Program Files\WinRAR
=================================================
WinRAR v3.80 Select all

RAR registration data
Federal Agency for Education
1000000 PC usage license
UID=b621cca9a84bc5deffbf 6412612250ffbf533df6db2dfe8ccc3aae5362c06d54762105357d 5e3b1489e751c76bf6e0640001014be50a52303fed29664b074145 7e567d04159ad8defc3fb6edf32831fd1966f72c21c0c53c02fbbb 2f91cfca671d9c482b11b8ac3281cb21378e85606494da349941fa e9ee328f12dc73e90b6356b921fbfb8522d6562a6a4b97e8ef6c9f fb866be1e3826b5aa126a4d2bfe9336ad63003fc0e71c307fc2c60 64416495d4c55a0cc82d402110498da970812063934815d81470829275







=================================================
WinRAR v3.80 Select all

RAR registration data
Database Administrators
5 PC usage license
UID=54d582e921e445f1bfe8 6412212250bfe8e73e20bdb947f60ef0da9624150bcf8668412c68 84affda559742bbb686d6071302587655a7ba28d516e17834b7616 47cd79a293eb4c0e4fbf5e9f967e6ed5b28a02418d0ab2549fc4da 19e4644f2345190bf26ff7bcd0c819f12560b57cf28adc164a00c6 3174fcbb69509912e7c7c4793779b941901c6c793b7319cc395ee0 8bddb923fa08fc20019b59d0b246e0ac325d2e5854d4f97a602fc0 a4357b8f857cfb717545410ecad088fb28a2a3cf0dff2102863273







=================================================
WinRAR v5.x (32 / 64 bits)Select all
RAR registration data
DigitalConduct
Unlimited Company License
UID=50ffc598a5a2f6862abb 64122122502abbc84c39c3419cc42c830c7918bd06eb387ba39db0 c2e20d6aee1b3d045ed860fce6cb5ffde62890079861be57638717 7131ced835ed65cc743d9777f2ea71a8e32c7e593cf66794343565 b41bcf56929486b8bcdac33d50ecf7739960a8bc2f89179193e346 00ba2270daa5b65a7909ecfb8130b60452eabf07f1a805749a4b6b 1571bc8a47789bc120ff2b6ae77e980ce8b5af8cd45d8be260f16e 3df7bf450991bde61f43b36a2096f010e0d232d4331c1958956325







=================================================
For Windows 10 and WinRAR 5.9/6.01
notepad C:\Users\%USERNAME%\AppData\Roaming\WinRAR\rarreg.key
WinRAR v5.9 (64 bits) Windows 10     Select all
RAR registration data SeVeN Unlimited Company License UID=000de082d4cb7aebb1d7 6412212250b1d762e38f07647568de8cced6309ae961b9eb1ed950 a0d588193eea605f7ed160fce6cb5ffde62890079861be57638717 7131ced835ed65cc743d9777f2ea71a8e32c7e593cf66794343565 b41bcf56929486b8bcdac33d50ecf77399603440fd770694ebb26e 46c22a9c4a7903ca551e2eaef3a0ce8b8f8d29fa89bf8fabeb717f 2846e0e0346d2d9c68b9f5e25e381ab74c3e10640614a5dc607ec5 3c67604588e161f9ce5f6cf3ea01a7466cfbb6147b223047701380






Monday, July 13, 2009

MCleaner 1.8 Activation Code

(1) Start gdb in iPhone SSH putty session

gdb


(2) Enter these in gdb

break *0x00003320
break *0x00003348
commands 1
silent
print $r4
set $pc=0x3328
continue
end
commands 2
silent
printf "\n\n\nSERIAL:%c%c%c%c%c%c%c%c! ENJOY!\n\n\n",$1,$2,$3,$4,$5,$6,$7,$8
end
attach -waitfor MCleaner


(3)Start MCleaner in iPhone

(4) In gdb type continue and press enter

(5) Enter Activation code in MCleaner with 8 zeros that is 00000000

(6) Then gdb will show the real activation code on gdb screen like
SERIAL:99999999!ENJOY!

(7) Remember that 8 digits number and reenter it again when activation in MCleaner