存档
set install_name for dylib g++ -install_name xxx.o -o xxx.dylib view install_name: method1: otool -L xxx.dylib see the first row. change install_name install_name_tool -change old.dylib new.dylib xxx.dylib pack libs lipo -create a_32.dylib a_64.dylib -output a.dylib
from mac 10.5 on, task_for_pid fails if the calling process has no root privilege. today I wrote a small app that needs this function, so I decided to make it run. Finding out the web , I found the result. There are something wrong or outdated on sites talk about it, so I wrote this [...]
vs有比较完善的unicode支持,从2005(或更早?)开始就支持源文件是utf-8,并且可以用中文做变量名函数名。(可以是可以,不推荐) 不过,也有一点很让人生气,就算源文件是utf-8编码的,编译时,他也会把utf-8转成主机的编码。所以,对于中文编码而言,如果源文件是 utf-8的并且有这样的内容,编译还是一样出问题: const char * test = “®”; tt.cpp(10) : warning C4566: character represented by universal-character-name ‘\u00AE’ cannot be represented in the current code page (936) c++0x草案中有 u8″string literal” 形式的字符串,如果可以用这个,则问题解决,可惜的是,vs2010并不支持 u8-prefix string literal。当然,u和U也不支持。不过由于windows本身所说的unicode是utf-16 le,所以vc里L”string”就是u”string”。 如果才能让vc以持u8呢?写一个宏和字符串转化的类,在运行期转化是一个可行但比较折中的办法,这个办法最大的问题是依然不能在代码里写”®”这样的字串,因为编译期转成中文编码失败成?号,运行期转成utf-8还是问号。 当然,可以写 L”®”,这样这个u8类可以这样写: string to_utf8(const wchar_t*); #define U8(string) to_utf8(string).c_str() 然后在用的地方写: U8(L”®”); 这样基本能用,但带来了一些运行期消耗。并且L的字符串也比较大。当然宏本身还可以改改,使得不需要写L,而是在预处理后加入L,但会带来额外的限制(想想U8(“hello” “world”))。 能不能hack编译器加入u8的支持呢?经过一番研究,发现了点眉目。 首先,vc编译器编译的主要功能代码在c1xx.dll中。这个dll的x86版本位于 C:\Program Files (x86)\Microsoft Visual Studio [...]
How to Disable Signature Enforcement during Development During the early stages of development, developers can disable enforcement in Windows so that driver signing is not necessary. The following options are available for developers to disable kernel mode code signing enforcement temporarily so that Windows Vista will load an unsigned driver. Attaching a kernel debugger. Attaching [...]
首先,我们要安装相应的程序: apt-get install gcc gobjc gcc g++ gnustep libgnustep-gui-dev 然后编写一个hello.m文件: 连hello.m都是抄来的,哈哈,程序如下: #import <Foundation/Foundation.h> @interface HelloWorld : NSObject – (void) hello; @end @implementation HelloWorld – (void) hello { NSLog(@”hello world!”); } @end int main(void) { HelloWorld *hw = [[HelloWorld alloc] init]; [hw hello]; [hw release]; } 然后就是编译了: 编译成.o文件: gcc -fconstant-string-class=NSConstantString -I /usr/include/GNUstep/ -c hello.m 链接: [...]
以便给自己的程序签名,呵呵。 当然,这样签 发的程序在别人那是不被信任的。除非把自己的根证书给别人安装。 用命令行,使用如下命令: makecert -pe -ss swigger -n “CN=swigger.net” -sv swigger_root.pvk -r swigger_root.cer 这里会弹出框要求密码,输入密码 root_pwd 或其它密码。共输入3次,前两次设置,后一次验证。 makecert -is swigger -n “CN=swigger file sign” -$ commercial -ic swigger_root.cer -sv fs.pvk fs.cer 这里继续弹出要密码,设置为 pwd2 或其它密码。共输入三次,两次设置,一次确认。还会弹出第四次要密码,要输入上一步设置的密码 root_pwd (或其它值)。 cert2spc fs.cer fs.spc 以下两条命令的pwd2是第二步设置的密码,如果不是pwd2,要换成其它值。 pvk2pfx -pvk fs.pvk -pi pwd2 -spc fs.spc -pfx fs.pfx -f signtool sign /t http://timestamp.verisign.com/scripts/timstamp.dll /v [...]
为android生成原生应用程序,不难啊。 初始条件:安装android的ndk,比如目前最新的 android-ndk-r3。(2010-03版) 我的目录结构: ~/android-ndk-r3 ~/android-ndk-r3/temp 这个是当前工作目录。 Step1: 写两个文件: hello.c: #include <stdio.h> int main() { printf("hello, world\n"); return 0; } start.c #include <stdlib.h> extern int main(int argc, char **argv); void _start(int argc, char **argv) { exit (main (argc, argv)); } Step2: compile [code] ../build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-gcc \ -I ../build/platforms/android-3/arch-arm/usr/include/ -c hello.c [...]
在安装的源盘根目录提供一个winnt.sif,写上: [SetupData] OsLoadOptions = “/noguiboot /fastdetect /debug /debugport=com1 /baudrate=115200 /break” 即可。 不过XP的setupldr.bin不支持这个,要win2k3的才行。(推荐sp1。sp2加载ramdisk有卡住bug)
结论非常简单,要先调用 NtInitializeRegistry. 参数见 wrk 中的 ntregapi.h 过程比较复杂,在smss.exe中用bootexecute启动的native程序里,调用 ntsavekey达不到想要的结果。 NtSaveKey会返回0,也就是没有错误。结果文件也会生成,生成的大小看起来也是对的。但是文件里面没有任何内容。所有字节都是0。 调试过程: 1. smss.exe启动的native程序是非常早的,可能是系统还有什么没准备好。试着替换其它程序而不是被smss.exe启动,来看看。 2. 替换winlogon.exe,发现能保存。 3. 替换 csrss.exe,发现也能保存。 4. 由于启动时候,smss创建csrss.exe ,后者再创建winlogon.exe。因此可以知道,在smss.exe调用native exe之后,启动csrss.exe之间,一定发生了什么事,使得ntsavekey在其前不能运行,其后可以运行。 5. 写一个简单的DLL,提供一个函数调用ntsavekey做测试,用lordpe把此DLL添加到smss.exe的依赖里。 6. WINDBG调试smss.exe启动native app后的路径,它每调几个函数就试下DLL中提供的函数看看ntsavekey是否正常。 7. 调试发现,在 NtInitializeRegistry之前,ntsavekey出现异常结果,之后,正常。 8. 结论: NtSaveKey需要用NtInitializeRegistry初始化注册表。
1:使用!process 0 0 获取用户空间的所有的进程的信息 !process 0 0 **** NT ACTIVE PROCESS DUMP **** PROCESS 80a02a60 Cid: 0002 Peb: 00000000 ParentCid: 0000 DirBase: 00006e05 ObjectTable: 80a03788 TableSize: 150. Image: System 。。。。。 2:使用.process /p + 你需要断的应用程序的EProcess地址切换到应用程序的地址空间 例如: .process /p 0x80a02a60 3:重新加载user PDB文件 .reload /f /user 4:使用非侵入式的切换进程空间 .process /i /p 0x80a02a60 5:下应用层断点 bp [...]