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
14 Sep 2009   07:50:01 am
Hook原来是这样工作的
先用自己的exe装载含有自己hook代码的dll(可以用loadlibrary,或者静态直接启动装入这个dll)再在自己的exe调用一个SetWindowsHookEx,SetWindowsHookEx可以设定为对所有的mouse hook,而proc参数就是上面dll中的proc.

这样SetWindowsHookEx会在系统所有用到mouse的新启动的进程里都会loadlibrary装入自己的hook dll。

在自己hook dll的Dllmain里可以判断目前的进程是哪个exe,或dll,如果发现是自己想要hook的那个进程.就可以进一步修改这个进程的内存,可以修改它的import table使其在调用系统api时先调用我们的。也可以检索它的内存,找到特定的内部函数,在调用这些函数前先调用我们自己的函数.

这里比较让人吃惊的是,实际上SetWindowsHookEx后,对每个进程实际上系统回自动loadlibrary你自己
的hook dll,导致你的Dllmain每次都会被调用.
Category : Windows API | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
12 Apr 2009   02:10:47 am
Win32 picture process function
http://www.codeproject.com/KB/winsdk/win32image.aspx
Category : Windows API | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
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 | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
28 Nov 2007   07:27:59 am
VC VS2005 Link出的EXE居然要额外的Dll支持,都是winsxs惹的祸
vc vs2005, LINK 了一个简单的dos console的exe, 在本机上运行没有问题,但在没有装VS2005的机器上报错: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem

结果解决的办法是把VS2005下的两个文件考到和主程序同一目录下:

C:\Program FilesMicrosoft Visual Studio 8VCredistDebug_NonRedistx86Microsoft.VC80.DebugCRT

msvcr80d.dll
Microsoft.VC80.DebugCRT.manifest

至于winsxs, 可以参考:

http://davidlenihan.com/2007/07/winsxs.html
http://msdn2.microsoft.com/en-us/library/aa376307.aspx
http://msdn2.microsoft.com/EN-US/library/aa369532.aspx


English Version:

I linked a simple DOS(Console)exe, running in my PC is fine, but when copy to others PC, it reports error of:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem

The solution is copy two files from VS2005 to the same path of your exe:

C:\Program FilesMicrosoft Visual Studio 8VCredistDebug_NonRedistx86Microsoft.VC80.DebugCRT

msvcr80d.dll
Microsoft.VC80.DebugCRT.manifest

The winsxs is the reason of it, for detail see:

http://davidlenihan.com/2007/07/winsxs.html
http://msdn2.microsoft.com/en-us/library/aa376307.aspx
http://msdn2.microsoft.com/EN-US/library/aa369532.aspx
Category : Windows API | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
05 May 2007   02:10:10 pm
ListView排序新特性
在codeproject(http://www.codeproject.com/cpp/ListCtrlSort.asp)上看到这样一篇文章,大致是说在XP下,ListView的排序是:

sort1
sort2
sort10
sort20

而不再是

sort1
sort10
sort2
sort20

这很好啊,但是作者说不清楚如何可以在自己的app中达到这个效果.于是作者用LVM_SORTITEMSEX加上自己的sort function来达到这个效果. 这个sort function当然有点复杂.所以在评论中MVP建议使用StrCmpLogicalW来做sort的工作.这个StrCmpLogicalW是只在XP以上版本,而且只有Unicode.
Category : Windows API | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
 
1
Template theme : aura
Powered by myBloggie Copyright © 2004 2006
-- myWebland --

Sponsed by TNTSoft Store