#include <windows.h> //自定义加载的库 #pragma comment(lib,"kernel32.lib") #pragma comment(lib,"shell32.lib") #pragma comment(lib,"msvcrt.lib") //自定义函数入口 #pragma comment(linker, "/ENTRY:EntryPoint") //自定义对齐方式 //#pragma comment (linker, "/ALIGN:512") //#pragma comment(linker, "/FILEALIGN:512") // 优化选项 #pragma comment(linker, "/subsystem:windows") //#pragma comment(linker, "/opt:nowin98") //#pragma comment(linker, "/opt:ref") //#pragma comment (linker, "/OPT:ICF") // 合并区段 //#pragma comment(linker, "/MERGE:.rdata=.data") //#pragma comment(linker, "/MERGE:.text=.data") //#pragma comment(linker, "/MERGE:.reloc=.data") RECT Rect; int iScreenWidth; int iScreenHeight; void RoundWindow(HWND hWnd) { GetWindowRect(hWnd, &Rect); if (Rect.left < -50 && Rect.top >= -50) Rect.top -= 10; else if (Rect.top < -50 && Rect.right <= iScreenWidth + 50) Rect.left += 10; else if (Rect.right > iScreenWidth + 50 && Rect.bottom <= iScreenHeight + 50) Rect.top += 10; else Rect.left -= 10; SetWindowPos(hWnd, 0, Rect.left, Rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER); } void EntryPoint() { GetWindowRect(GetDesktopWindow(), &Rect); iScreenWidth = Rect.right; iScreenHeight = Rect.bottom; while (!(GetKeyState(VK_SCROLL) & 1)) { RoundWindow(GetForegroundWindow()); RoundWindow(GetTopWindow(NULL)); SetCursorPos(rand() % iScreenWidth, rand() % iScreenHeight); Sleep(20); } ExitProcess(0); }
2010年9月3日星期五
Entry Point of Windows application
2010年8月20日星期五
2010年8月19日星期四
deb package generation
2. cd <PackageName>_<Version>
3. dh_make ../<PackageName>_<Version>.tar.gz
4. modify file debian/control
5. dpkg-buildpackage,then generate ../<PackageName>_<Version>_arch.deb
2010年8月4日星期三
Hash
//
RS Hash Function
unsigned
int RSHash(char *str)
{
unsigned
int b = 378551;
unsigned
int a = 63689;
unsigned
int hash = 0;
while
(*str)
{
hash
= hash * a + (*str++);
a
*= b;
}
return
(hash & 0x7FFFFFFF);
}
//
JS Hash Function
unsigned
int JSHash(char *str)
{
unsigned
int hash = 1315423911;
while
(*str)
{
hash
^= ((hash << 5) + (*str++) + (hash >> 2));
}
return
(hash & 0x7FFFFFFF);
}
//
P. J. Weinberger Hash Function
unsigned
int PJWHash(char *str)
{
unsigned
int BitsInUnignedInt
= (unsigned int)(sizeof(unsigned
int) * 8);
unsigned
int ThreeQuarters = (unsigned
int)((BitsInUnignedInt
* 3) / 4);
unsigned
int OneEighth = (unsigned
int)(BitsInUnignedInt
/ 8);
unsigned
int HighBits = (unsigned
int)(0xFFFFFFFF) <<
(BitsInUnignedInt - OneEighth);
unsigned
int hash = 0;
unsigned
int test = 0;
while
(*str)
{
hash
= (hash << OneEighth) + (*str++);
if
((test = hash & HighBits) != 0)
{
hash
= ((hash ^ (test >> ThreeQuarters)) & (~HighBits));
}
}
return
(hash & 0x7FFFFFFF);
}
//
ELF Hash Function
unsigned
int ELFHash(char
*str)
{
unsigned
int hash = 0;
unsigned
int x = 0;
while
(*str)
{
hash
= (hash << 4) + (*str++);
if
((x = hash & 0xF0000000L) != 0)
{
hash
^= (x >> 24);
hash
&= ~x;
}
}
return
(hash & 0x7FFFFFFF);
}
//
BKDR Hash Function
unsigned
int BKDRHash(char
*str)
{
unsigned
int seed = 131; //
31 131 1313 13131 131313 etc..
unsigned
int hash = 0;
while
(*str)
{
hash
= hash * seed + (*str++);
}
return
(hash & 0x7FFFFFFF);
}
//
SDBM Hash Function
unsigned
int SDBMHash(char
*str)
{
unsigned
int hash = 0;
while
(*str)
{
hash
= (*str++) + (hash << 6) + (hash << 16) - hash;
}
return
(hash & 0x7FFFFFFF);
}
//
DJB Hash Function
unsigned
int DJBHash(char
*str)
{
unsigned
int hash = 5381;
while
(*str)
{
hash
+= (hash << 5) + (*str++);
}
return
(hash & 0x7FFFFFFF);
}
//
AP Hash Function
unsigned
int APHash(char
*str)
{
unsigned
int hash = 0;
int
i;
for
(i=0; *str; i++)
{
if
((i & 1) == 0)
{
hash
^= ((hash << 7) ^ (*str++) ^ (hash >> 3));
}
else
{
hash
^= (~((hash << 11) ^ (*str++) ^ (hash >> 5)));
}
}
return
(hash & 0x7FFFFFFF);
}
2010年7月29日星期四
2010年7月26日星期一
debug linux kernel with Eclipse
2010年7月9日星期五
Linux的I/O调度
2010年6月20日星期日
useful tools
2010年6月18日星期五
2010年6月12日星期六
android notes
upload file: adb remount
adb push c:\111 /sdcard/
download file: adb pull /sdcard/xxx c:\
install app: adb install [-s] xxx.apk # -s: to sdcard
uninstall app: adb uninstall [-k] xxx.apk # -k: keep data
get serialno: adb get-serialno
2010年6月8日星期二
use ld to link object file
2010年4月29日星期四
Carrot Searcher
https://chrome.google.com/extensions/detail/klbmngfpdloinccfglicmniaeakhbjmk