Share my knowledge, feel my life. Eric Shan' Blog myBloggie 2.1.6 © 2005   
Mar 2025 April 2025 May 2025
S M T W T F S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30    
Categories
About[5]
Blackberry[1]
dotNet and C Charp[1]
IPhone[10]
Life[4]
Unix&Linux[19]
WEB programming[16]
Windows API[5]
Windows Mobile[1]
Windows Multimedia[4]
Recent
CentOS mount CDrom and USB
CentOS GHOST(幽灵)漏洞修复方法
centos 改变语言并立即生效
centos vpn 接通后无法连接internet
让vlc播放中文字幕不出乱码
centos 取消屏保
php中ob_flush和flush的用法
CentOS检查,添加,删除自启动服务
CentOS中开机自动启动某个服务
Top命令中的翻页
Archives
February 2010[4]
September 2009[1]
August 2009[1]
January 2009[7]
October 2008[10]
June 2008[2]
December 2007[14]
November 2007[5]
May 2007[9]
April 2007[3]
March 2007[10]
User List
Eric Shan[66]
Search
Syndication
20 Oct 2008   09:42:21 am
Get print result from SQL statement
Some of my colleague is lazy, and create the report in SQL and refuse to create an interface for user to execute the SQL. The SQL looks like below. The 'print' make the result in the SQL server management message window. So I'm thinking to make an interface but I do not want to change the SQL, so that is mean I need to get the result from the 'print'. The google told me it is possible to create it through register an call back fuction is CS, but I want an C++ interface. So I finally find ODBC can do it.

Code :
Set @DueFromPBOC =(Select isnull(sum(isnull(ac.AccountBalance,0)),0) From View_Account_Log ac
Print 'Result = '+ Convert(varchar(50), @DueFromPBOC)


The process is just like below,

SQLAllocEnv
SQLAllocConnect
SQLConnect
SQLPrepare
SQLExecute

after that, using SQLGetDiagRec to find out the result from the SQL 'print'

Code :

i=1;
while ((rc2 = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, SqlState, &NativeError,
Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
{
//DisplayError(SqlState,NativeError,Msg,MsgLen);
//printf("%s, %srn",SqlState, Msg);

printf("%srn",Msg);
i++;
// }
}


There are two points here,

1. The SQL sentence must have an zero (0x0) end, to let SQL server know the end of the sentense
2. Must use SQLExecute instead of SQLExecDirect, SQLExecDirect can not reture the entired message, and only reture first part if you have several select statement in one batch.
Category : Windows API | By : Eric Shan | Comments [0] | Trackbacks [0]
19 Jun 2008   08:04:12 am
Readdir
http://www-128.ibm.com/developerworks/aix/library/au-unix-readdir.html

The dirent.h functions, opendir(), readdir(), and closedir(), are just what you need. Using them is very similar to the open/read/close idiom you're probably used to using with files, with one exception: the readdir() function returns a pointer to a special structure (of type struct dirent) for each directory entry

dir = opendir( "some/path/name" )
entry = readdir( dir )
while entry is not NULL:
do_something_with( entry )
entry = readdir( dir )
closedir( dir )


int readdir_r(DIR *, struct dirent *, struct dirent **);

struct dirent {
ino_t d_ino; /* file number of entry */
__uint16_t d_reclen; /* length of this record */
__uint8_t d_type; /* file type, see below */
__uint8_t d_namlen; /* length of string in d_name */
char d_name[__DARWIN_MAXNAMLEN + 1]; /* name must be no longer than this */
};


file type is list below,

DT_UNKNOWN
The file type is unknown.
DT_REG
This is a regular file.
DT_DIR
This is a directory.
DT_FIFO
This is a named pipe, or FIFO.
DT_SOCK
This is a Unix domain socket.
DT_CHR
This is a character device.
DT_BLK
This is a block device.
Category : About | By : Eric Shan | Comments [0] | Trackbacks [0]
03 Jun 2008   02:47:04 am
Winchain installation
用WinChain来装Iphone toolchain也是挺省力的事情,下载pretoolchain完后,解压,运行WinChain.1.1,觉得它就是把pretoolchain rename成Cygwin, 然后下载安装一下cgywin,装default的pack.

同样的过程在公司安装就是无法编译,最后发现\usr\local\arm-apple-darwin\include\stdint.h这个link不对了,用\usr\local\arm-apple-darwin\include\gcc\darwin\4.0替换掉.
Category : IPhone | By : Eric Shan | Comments [0] | Trackbacks [0]
29 May 2008   06:55:26 am
Makefile detail
Makefile基本结构
Makefile是Make读入的惟一配置文件,因此本节的内容实际就是讲述Makefile的编写规则。在一个Makefile中通常包含如下内容:

· 需要由make工具创建的目标体(target),通常是目标文件或可执行文件;

· 要创建的目标体所依赖的文件(dependency_file);

· 创建每个目标体时需要运行的命令(command)。

它的格式为:

target: dependency_files

command


Makefile中常见自动变量

命令格式 含 义

$* 不包含扩展名的目标文件名称

$+ 所有的依赖文件,以空格分开,并以出现的先后为序,可能包含重复的依赖文件

$< 第一个依赖文件的名称

$? 所有时间戳比目标文件晚的依赖文件,并以空格分开

$@ 目标文件的完整名称

$^ 所有不重复的依赖文件,以空格分开

$% 如果目标是归档成员,则该变量表示目标的归档成员名称

模式规则是用来定义相同处理规则的多个文件的。它不同于隐式规则,隐式规则仅仅能够用make默认的变量来进行操作,
而模式规则还能引入用户自定义变量,为多个文件建立相同的规则,从而简化Makefile的编写

相关文件前必须用“%”标明

%.o : %.c

$(CC) $(CFLAGS) -c $< -o $@

所有.o文件依赖所有相应c文件,用同样规则
Category : Unix&Linux | By : Eric Shan | Comments [0] | Trackbacks [0]
28 May 2008   12:57:57 am
Iphone firmwares
http://tungchingkai.blogspot.com/2008/01/decrypt-iphone-filesystem-firmware.html

(1) For Firmware 1.0.1
(i) get the vfdecrypt101.exe from Rapid share(http://rapidshare.com/files/63681184/vfdecrypt101.exe.html)
(ii) get the Apple's iPhone firmware 1.0.1 and rename it with extension .zip and unzip it
(run) vfdecrypt101 main_dmg_of_101.dmg decrypted101.dmg

(2) For Firmware 1.0.2
(i) get the vfdecrypt102.exe from Rapid share(http://rapidshare.com/files/58198544/vfdecrypt102.exe.html)
(ii) get the Apple's iPhone firmware 1.0.2 and rename it with extension .zip and unzip it
(run) vfdecrypt102.exe 694-5298-5.dmg decrypted102.dmg

(3) For Firmware 1.1.1
(i) get the vfdecrypt111.exe from Rapid share(http://rapidshare.com/files/63677864/vfdecrypt111.exe.html)
(ii) get the Apple's iPhone firmware 1.1.1 and rename it with extension .zip and unzip it
(run) vfdecrypt111.exe 022-3602-17.dmg decrypted111.dmg

(4) For Firmware 1.1.2
(i) get the vfdecrypt112.exe from Rapid share(http://rapidshare.com/files/68797940/vfdecrypt112.exe.html)
(ii) get the Apple's iPhone firmware 1.1.2 and rename it with extension .zip and unzip it
(run) vfdecrypt112.exe 022-3725-1.dmg decrypted112.dmg

(5) For Firmware 1.1.3(http://rapidshare.com/files/41004473/vfdecrypt.exe.html)
(i) get the vfdecrypt.exe from Rapid Share
(ii) get the Apple's iPhone firmware 1.1.3 and rename it with extension .zip and unzip it
(run) vfdecrypt -i 022-3743-100.dmg -o decrypted113.dmg -k 11070c11d93b9be5069b643204451ed95aad37df7b332d10e48fd3d23c62fca517055816

(6) For Firmware 1.1.4
(i) get the vfdecrypt.exe from Rapid Share
(ii) get the Apple's iPhone firmware 1.1.4 and rename it with extension .zip and unzip it
(run) vfdecrypt -i 022-3894-4.dmg -o decrypted114.dmg -k d0a0c0977bd4b6350b256d6650ec9eca419b6f961f593e74b7e5b93e010b698ca6cca1fe

(7) For Firmware 2.0 beta (Build 5A225c) (MD5 8254ccf38735bc74b38fb432ce982081) expired 8 April 2008
(i) Google Search iPhone1,1_2.0_5A225c_Restore.ipsw
(ii) Rename it with extension .zip and unzip it
(run) vfdecrypt -i 018-3473-4.dmg -o decrypted20b2.dmg -k ea14f3ec624c7fdbd52e108aa92d13b16f6b0b940c841f7bbc7792099dae45da928d13e7

(8 ) For Firmware 2.0 beta (Build 5A240d) (MD5 429142d57db7cf94d4c29ee4da7f21cc) (to be expired 15 May 2008 )
(i) Google Search iPhone1_1_2.0_5A240d_Restore.ipsw
(ii) Rename it with extension .zip and unzip it
(run) vfdecrypt -i 018-3553-6.dmg -o decrypted20b3.dmg -k e24bfab40a2e5d3dc25e089291846e5615b640897ae8b424946c587bcf53b201a1041d36


(9) For Firmware 2.0 beta (Build 5A258f) (MD5 f7a2937c32615545ba339c330356d9ad) (to be expired 4 June 2008 )
(i) Google Search iPhone 2.0 Beta 4 (5a258f)
(ii) Rename it with extension .zip and unzip it (unzip -o iPhone1,1_2.0_5A258f_Restore.ipsw 018-3585-6.dmg)
(run) vfdecrypt -i 018-3585-6.dmg -o decrypted20b4.dmg -k 198d6602ba2ad2d427adf7058045fff5f20d05846622c186cca3d423ad03b5bc3f43c61c

For vfdecrypt.exe,
libeay32.dll
http://pecl4win.php.net/download.php/dll/061dae89b309a98382dedc04942bd8a2/libeay32.dll

To extract the contents in the dmg image in PC you need hfsexplorer(plus java runtime) or dmg2img.exe
http://hem.bredband.net/catacombae/hfsx.html
http://devices.natetrue.com/iphone/ibrickr-jb113.zip
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jre-6u4-windows-i586-p-iftw.exe?BundledLineItemUUID=H25IBe.l.7oAAAEX_wIJ2rG5&OrderID=wqFIBe.lQkEAAAEX9AIJ2rG5&ProductID=lr9IBe.nFxoAAAEWAhINQrEN&FileName=/jre-6u4-windows-i586-p-iftw.exe

You can also use PowerISO 4.0 in Windows to examine and extract contents of Mac OS X *.dmg file
http://www.poweriso.com/

You can mount the decrypted image directly in Mac OS or Linux. To mount DMG
dd if=694-5259-38.dmg of=ramdisk.dmg bs=512 skip=4 conv=sync
mount -o loop decrpyted112.img /mnt/decrypted112


Keys

The key for the 1.01 revision is : 28c909fc6d322fa18940f03279d70880e59a4507998347c70d5b8ca7ef090ecccc15e82d

The key for the 1.02 revision is : 7d5962d0b582ec2557c2cade50de90f4353a1c1de07b74212513fef9cc71fb890574bfe5

The key for the 1.1.1 revision is : f45de7637a62b200950e550f4144696d7ff3dc5f0b19c8efdf194c88f3bc2fa808fea3b3

The key for the 1.1.2 revision is :
70e11d7209602ada5b15fbecc1709ad4910d0ad010bb9a9125b78f9f50e25f3e05c595e2

The key for the 1.1.3 revision is :
11070c11d93b9be5069b643204451ed95aad37df7b332d10e48fd3d23c62fca517055816

The key for the 1.1.4 revision is : d0a0c0977bd4b6350b256d6650ec9eca419b6f961f593e74b7e5b93e010b698ca6cca1fe

The key for the 1.2.0 beta (Build 5A147p) (md5 iPhone1,1_1.2_5A147p_Restore.ipsw = 3539f0b912812fd56ac1019d8fce4fc2 ) is: 86bec353ddfbe3fb750e9d7905801f79791e69acf65d16930d288e697644c76f16c4f16d

The key for the 2.0 beta (Build 5A225c) (md5 iPhone1,1_2.0_5A225c_Restore.ipsw = 8254ccf38735bc74b38fb432ce982081 ) is: ea14f3ec624c7fdbd52e108aa92d13b16f6b0b940c841f7bbc7792099dae45da928d13e7

The key for the 2.0 beta (Build 5A240d) (md5 iPhone1_1_2.0_5A240d_Restore.ipsw = 429142d57db7cf94d4c29ee4da7f21cc) is: e24bfab40a2e5d3dc25e089291846e5615b640897ae8b424946c587bcf53b201a1041d36

The key for the 2.0 beta (Build 5A258f) (md5 iPhone1,1_2.0_5A258f_Restore.ipsw = f7a2937c32615545ba339c330356d9ad) is: 198d6602ba2ad2d427adf7058045fff5f20d05846622c186cca3d423ad03b5bc3f43c61c

The key for the 2.0 beta (Build 5A274d) (md5 iPhone1,1_2.0_5A274d_Restore.ipsw = 1e671faa31d876602161d9bb463e15da) is: 589df25eaa4ff0a5e29e1425fb99bf50957888ff098ba2fcb72cf130f40e15e00bcf2fc7

Regarding how to find the key:

Read this on how to find the key for firmware 1.1.1 or above

For example, firmware 1.1.4, you can find the decrypt key by running this in Mac OS X Terminal

#!/bin/bash# first extract the ramdisk image file from the ipsw fileunzip -o iPhone1,1_1.1.4_4A102_Restore.ipsw 022-3896-4.dmg -d .# strip off the first 0x800 bytes and the trailing certificatedd if=022-3896-4.dmg of=022-3896-4.stripped.dmg bs=512 skip=4 count=36640 conv=sync# use the method of GEORGE HOTZ and ignore the erroropenssl enc -d -in 022-3896-4.stripped.dmg -out ramdisk-022-3896-4.dmg -aes-128-cbc -K 188458A6D15034DFE386F23B61D43774 -iv 0# print out the ramdisk key from the imagestrings ramdisk-022-3896-4.dmg | egrep "^[0-9a-fA-F]{72}$"

If you have the 8900decryptor binary, you can get the same decrypted image file and key from

#!/bin/bash./8900decryptor 022-3896-4.dmg 022-3896-4.8900decrypted.dmgstrings 022-3896-4.8900decrypted.dmg | egrep "^[0-9a-fA-F]{72}$"
Category : IPhone | By : Eric Shan | Comments [0] | Trackbacks [0]
27 May 2008   07:24:19 am
在Apple官方的Xcode上编译1.1.4的app
http://www.hackint0sh.org/forum/showthread.php?t=37998

Lets use all power of graphic IDE from Apple SDK for 1.1.4 development:
0. Close XCode and make sure its not running
1. Download installation:
-For SDK v1 http://r_apidshare.com/files/102531763/sdk_mod.tgz.html (remove _ )
-For SDK v2 http://r_apidshare.com/files/1030589...2_mod.tgz.html (remove _ )
-For SDK v3 http://r_apidshare.com/files/1081397...3_mod.tgz.html (remove _ )
2. Untgz it somwere for example to homedir. Apears folder: ~/make.sdk
3. Make sure Apple SDK installed to default foilded /Developer
4. Make sure original 1.1.4 filesystem is here: /usr/local/share/iphone-filesystem Otherwise u can change script manually
5. Open terminal on your Mac:

Code:
$ cd ~/make.sdk/
$ ls
Apple Mach-O Linker.xcspec include
GCC 4.0.xcspec keys.sh
Info.plist lib
ProjTempl sdk.sh
SDKSettings.plist sshd_config

Lets start:

$ ./sdk.sh
(#) 1.1.4 platform SDK creation script for XCode 3.0 -- by Darkmen
Copying Aspen1.2...
Configuring XCode GCC plugin...
Configuring SDK prefs...
Removing old templates...
Copying new templates...
Making SDK filesystem:
-Erasing 1.2 System
-Erasing 1.2 lib
Make sure original 1.1.4 filesystem is here: /usr/local/share/iphone-filesystem/
-Copying 1.1.4 iPhone fileystem...
-Copying dev team 1.1.4 headers...
-Copying dev team libs...
Done!

You will need paswordless SSH login to your iPhone to be able to use Run On Device script
You can do it now:

$ export IPHONE_IP=192.168.1.6 (please replace with your iPhone's IP address)
$ ./keys.sh
(#) Passwordless SSH login script -- dy Darkmen
WARNING: Dont forget to change iPhone's IP. Default is 192.168.1.6!
Generating RSA keys for SSH paswordless login on iPhone. Please leave default filenames and empty passphrase!

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/darkmen/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/darkmen/.ssh/id_rsa.
Your public key has been saved in /Users/darkmen/.ssh/id_rsa.pub.
The key fingerprint is:
xxxxxxxxxxxxxxxxx darkmen@darkmac.local
Copying public key to iPhone. First login can take 30 seconds. Password: alpine
root@192.168.1.6's password:
id_rsa.pub 100% 403 0.4KB/s 00:00
Copying SSHD config to iPhone. Password: alpine
sshd_config 100% 3248 3.2KB/s 00:00
Restarting SSHD on iPone...
Connection to 192.168.1.6 closed by remote host.
Done!

We DONE!
Category : IPhone | By : Eric Shan | Comments [0] | Trackbacks [0]
24 May 2008   01:43:05 am
Extract .pkg files in MAC
Here how to extract the files:

1. Download XAR-1.5.1 (I compiled it with 10.4.9 and the newest XCode)
hxxp://enzomusic.en.funpic.de/XAR.zip

2. Extract it and open Terminal (go to the directory you extracted it)

3. To extract an pkg, start xar with: ./xar -x -f /directory/file.pkg
(I always copy the pkg first to my hdd then copy the xar into the same, due to errors that could occur)

You will see some files now. The important one is the "Payload"-File.

4. Right-click on payload, open with "BOM-...."

http://forum.insanelymac.com/index.php?s=97724401abae75eec7d59b68b57f2e22&showtopic=55301&st=0&p=395559&#entry395559
Category : Unix&Linux | By : Eric Shan | Comments [0] | Trackbacks [0]
22 May 2008   02:12:30 pm
Cross compile for 2.0 and 1.14 possibility
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib

crosscompilation without xcode
http://www.hackint0sh.org/forum/showthread.php?t=33867

Replace lib with 1.14 versions and link

export CFLAGS="-I/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include -I/Developer/Platforms/iPhoneOS.platform/Developer/usr/include/ -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include"

export CPP="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.0"

export CPPFLAGS=$CFLAGS

export LDFLAGS="-L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/"

export PATH="$PATH:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/"
Category : IPhone | By : Eric Shan | Comments [0] | Trackbacks [0]
18 May 2008   03:12:36 am
Start Telnet SSH service in Apple Darwin
Service --list

sudo service telnet start


http://www.macgeekery.com/tips/all_about_launchd_items_and_how_to_make_one_yourself
Category : Unix&Linux | By : Eric Shan | Comments [0] | Trackbacks [0]
15 May 2008   09:27:58 am
error LNK2001: unresolved external symbol "int __cdecl getop
I'm in compileing iphuc under VC6, the getopt got error of

error LNK2001: unresolved external symbol "int __cdecl getopt(int,char * *,char *)" (?getopt@@YAHHPAPADPAD@Z)

This is mean the getopt need to be compile as C function, so in the getopt.h declaie the function as

extern "C" {
int _cdecl getopt(int argc, char **argv, char *opstring);
}

Then the problem was solved.
Category : IPhone | By : Eric Shan | Comments [0] | Trackbacks [0]
 
Prev 1 2 3 ...5 6 7 Next
Template theme : aura
Powered by myBloggie Copyright © 2004 2006
-- myWebland --

Sponsed by TNTSoft Store