Feeling

    三人行,必有我师焉

   ::  :: 新随笔 :: 联系 ::  :: 管理 ::
  185 随笔 :: 0 文章 :: 392 评论 :: 0 Trackbacks

#

新增了4个Low Level Hook:Mouse_LL,Keyboard_LL, JournalRecord,JournalPlayback。由于是Low Level Hook,因此Hook是不依赖于dll,所以可以直接将HookProc在Java程序中编写。这四个钩子都是全局的,而且都很有用处。Mouse_LL,Keyboard_LL,自不必说,用来监听鼠标和键盘的。Journal的2个Hook则是所谓的日志钩子,WH_JOURNALPLAYBACK Hook使应用程序可以插入消息到系统消息队列。可以使用这个Hook回放通过使用WH_JOURNALRECORD Hook记录下来的连续的鼠标和键盘事件。只要WH_JOURNALPLAYBACK Hook已经安装,正常的鼠标和键盘事件就是无效的。WH_JOURNALPLAYBACK Hook是全局Hook,它不能象线程特定Hook一样使用。WH_JOURNALPLAYBACK Hook返回超时值,这个值告诉系统在处理来自回放Hook当前消息之前需要等待多长时间(毫秒)。这就使Hook可以控制实时事件的回放。

基本上现在用SWT-Extension来实现这四个Hook还是很容易的,做了一下简单的数据封装和事件封装,而且加入了结合体对象和JNI的handle互相转换的函数。用来做C++的一些事情还是比较得心应手的。最新版本的Example提供了一个简单的系统Record/Playback例子,可以记录和回放系统事件。

 

最新的build已经发布到 http://feeling.sourceforge.net 上了,有兴趣的可以下载看看,并且可以作为Eclipse插件使用,支持 eclipse 3.2 以上版本。

PS: Journal的2个Hook Vista已经停止支持了,所以这个例子在Vista 下是看不到的:-(
posted @ 2007-12-12 18:18 三人行,必有我师焉 阅读(1510) | 评论 (2)编辑 收藏

SWT-Extension这个项目做了很久,但一直都没有realease,只是个人做着玩玩,很重要的一个原因是对Windows System Hook的机制没有能够很好地实现出来。Hook本身不算是很难的技术,在C++,C#里都能够很容易的实现,为什么运用Java就那么困难呢?

首先当然主要还是我个人对C++并不在行了,其次就是Java和C++交互的问题了。要想通过C++把数据传给Java,就要通过JNI标准的接口来实现,也就是要通过 JNIENV 来实现,但是HookProc 这个CallBack 是给系统进程调用的,不是给你Java调用的,你说系统进程调用了 HookProc 之后,没法把这个事件传递给Java,那么还有一个方法,用Java不间断的轮循Hook里的数据,这倒是能实现,网上也有一个老外的例子,但不好的地方就是当我系统没工作的时候,你Java还在那儿轮循我干嘛?这不是浪费资源吗?所以呢,这解铃还需系铃人,系统的事件还得让系统来通知你才好。在Java里,有一个IO阻塞,比如当调用System.in.read()的时候,系统就是等待你的输入,如果你不输入,系统就一直等着不工作。还有线程,有wait方法,非要等着其他的线程通过notify把你唤醒你才能工作。在C++里也有这么一套机制:CreateEvent 和WaitForSingleObject,也就是说我先创建一个事件,然后将这个事件置于未激活状态,让它一直等待,将线程阻塞住,当HookProc被系统进程调用的时候,就将这个事件激活,通知Java程序你可以开始干活了,干完活以后再次被阻塞,直到这个Hook被uninstall掉。当然这其中还有一些 C++ 代码的细节性问题,比如怎么让不同的进程共享同一个事件,这里要说明的就是不同的进程可以共享同一个事件,但是不能共享同一个事件句柄,同一个事件,在不同的进程里有不同的句柄,句柄是不能跨进程的。 

我个人认为Hook应当是SWT-Extension里一个很重要的组成部分,SWT本身只能实现线程钩子,对于系统级的钩子无能为力。因为系统机钩子需要实现数据共享操作,还需要DLL入口句柄,这些我已都在SWT-Extension中实现了。唯一让我遗憾的是没有办法实现日志钩子,这是一个很有用的钩子,可以用来记入当前用户行为的操作,然后重新演示,我想如果做自动化测试这个会很有用,或者给游戏软件练功什么的,呵呵。之所以不能实现是因为这个钩子很特别,它要的不是DLL的句柄,而是应用程序的句柄,这没有办法从Java程序里获得,我试过javaw.exe,但是也不行,会导致系统假死。以后有时间在研究吧。

做完Hook,终于可以松一口气,发一个小小的realease了,剩下的就是document工作要做了,一个枯燥无味的工作,就当练习一下英语好了。

这里发一个Hook的截图:




没有了标题栏的Eclipse
最新的Build和代码也可以在 http://feeling.sf.net 上下载了。
posted @ 2007-12-07 15:08 三人行,必有我师焉 阅读(2437) | 评论 (17)编辑 收藏

1. Change priorities when it became apparent that items with major market impact didn't take much effort, or when it became apparent that items with minor market impact wuld take much more effort than they worth.
2. Prioritize the task list based on their presentation of the feature's importance.
3. Maintain a list of what is needed in the product.
4. Iterative, incremental development. Each iteration is called a Sprint, and the results of the iteration is called a Product Increment.
5. Whoever writes code owns it forever.
6. produce an updated produce technical illustration with each Sprint(and release)that could be used to understand the product design and code.
7. Institute a quick, daily meeting where the team would report what it is doing.
8. Product Backlog: A list, list all of the things that the system should include and address, including functionality, features, and technology.
9. The Product Backlog is a prioritized list of all product requirements. and it 's never finalized. Product backlog content can come from anywhere: users, customers, sales, marketing, customer service, and engineering can all submit items to the backlog. However, only the Product Owner can prioritize the backlog.
10. Scrum relies on team initiative and integrity.
11. The Scrum Team meets daily for a short status meeting, called the Daily Scrum.
12. At the end of the Sprint, the team gets together with management at a Spring Review Meeting to inspect the product increment the team has built.
posted @ 2007-09-24 13:44 三人行,必有我师焉 阅读(412) | 评论 (1)编辑 收藏

Since 19th century, human has been changing the earth continuously. They began to use various energies to server themselves. The most important application is electricity. If the electric power is cutted, wo even couldn't do anything. Air conditioner, fridge, wash matchine, computer and oven all need electric power. We use coal,water power,wind,biology and nuclear power to generate electric power. Generally, when we convert a power to another power, the efficiency is not perfect, we will lose some energy. Most of the lost energy is changed as hot energy. So when we touch the machine used electric power, we can feel it's hot.

Except electric power, we also use another kind of power, that is chemical power. We can get it by burning coal and oil. This power is used broadly. For example, the car, the plane and some other traffic tools. But when we generate the chemical power, there will cause lots of waste gas. Some kind gases in the waste gas can let earth become a greenhouse. Then we generate a mass of hot energy but these greenhouse gases prevent it to run away to the universe. The hot energy stays at our planet, and the temperature becomes high little by little.

Now the global warming is obvious, the ice of the south earth pole is melting little by little, the drought and the hurricane appears more and more. Each person can feel the earth is warming now.

Now the big energy countries start to decrease the greenhouse gas releasing and increase the efficiency of power conversion.For example, we use water power, wind, nuclear power to generate electric power as much as possible, but not use coal and oil. Each people has the responsibility to protect our home.

posted @ 2007-09-19 12:28 三人行,必有我师焉 阅读(245) | 评论 (0)编辑 收藏

Everyone knows that smoking is harmful for health, but why do so many people still smoke? It’s a complex society problem. There are several reasons that caused it.

 

Firstly, cigar contains some matters which can let people depend on them. Nicotine is one of the most harmful matters in the cigar. The nicotine contained in one cigar can kill one mouse by poison. And some other matters of cigar can let people get cancer. Smoking also can damage liver and lung. In short, smoking is very dangerous.


 

Secondly, lots of people smoking is caused by the social fashion. Generally, most of people started to smoke when they were teenager. They have a strong emulous mind, and they like to imitate the movie stars’ smoking behavior. The environment that the teenagers lives is bad for their growth.

 

Lastly, it’s caused by economy. The tax of cigar is very huge, each government couldn’t ignore it. It will generate a big benefit, so most of countries don’t forbid selling cigar. Fortunately, some of them begin to forbid selling cigar to the underage people.

 

Lots of parents don’t allow children to smoke, but it’s not very effective. Because they don’t let children smoke, but they still smoke. Children’s growth needs a clear and fresh environment, but not an environment full of smoking. The government must carry out more measures about forbidding smoking, and adult would better to give up smoking also.

posted @ 2007-09-18 12:36 三人行,必有我师焉 阅读(1014) | 评论 (0)编辑 收藏

Grammar Website: http://www.windsn.com/main/grammar/
Dictionary Online: http://www.godict.com
Google Translator: http://www.google.com/language_tools?hl=zh-CN
English Studying Fourm:http://www.maplesky.net/bbs/index.php (Can download a lot of resource from here)
English Movie:
Family Album U.S.A(走遍美国) 很好的英语口语学习教材
Speed(生死时速) 练习听力,语速很慢

posted @ 2007-09-05 13:30 三人行,必有我师焉 阅读(275) | 评论 (0)编辑 收藏

在你看来,下面图像的运动方向是顺时针呢还是逆时针呢??
每个人看来都是不一样的 
 
顺时针的话,属于是用右脑较多的类型
逆时针属于是用左脑较多的类型
大部分人的眼里是逆时针方向转动,但也有人看来是顺时针方向转动的。
顺时针的情况,女性比男性多 ~~
试试吧!~ 

我第一眼看上去是逆时针,第二眼又变成了顺时针。

怎么说呢,以不同的视角看,就会形成不同的旋转路线,可能是逆时针也可能是顺时针,我现在已经是忽左忽右,快暴走了。

自己找到了一个比较好的解决方法,脑袋贴近屏幕向右偏转45度看,很容易形成逆时针,向左偏转45度看,很容易形成顺时针,主要是人和图片的视角问题。这图片设计的也太巧妙了。

Team里的人大部分看都是顺时针,只有一个左撇子看是逆时针。
posted @ 2007-07-25 17:11 三人行,必有我师焉 阅读(1838) | 评论 (6)编辑 收藏

  中新网7月13日电 综合报道,一名犯有重罪的罗马尼亚犯人近日向上帝提出控诉,地方法院12日对此予以驳回。

  据悉,该名罗马尼亚犯人是2005年7月因受贿罪被捕的。他被判处入狱20年,在狱中更是抱怨上帝对他不公,在2006年甚至向地方法院控告上帝。

  这名犯人说,早在他出生时在教堂受洗的时候就与上帝订立了契约,让他能够快乐生活,但现在“上帝打破了这份契约,因此有必要控告他”。

  地方法院12日发布的判决书称,“由于无法获知上帝的家庭住址,因此无法向其传达法院的意见,”并最终对囚犯的要求予以驳回。

posted @ 2007-07-13 18:19 三人行,必有我师焉 阅读(291) | 评论 (0)编辑 收藏

昨晚赶工为SF上的项目做了个首页:http://feeling.sf.net 。各位兄弟有空可以看看,帮忙提点意见,不过现在铺的好像就有点大了,这么多页面,不知道何时才能做完,打算就先这么搁一个首页,以后有时间再说吧。

SWT Extension Example我今天打包了一下,已经可以下载了,但是源代码我暂时还没打算开放下载,因为有些功能还没做好,需要一段时间,最重要的是我打算对现有代码进行重构,API可能有比较重大的调整,现在提供下载,对想要使用的兄弟来说是一种不负责任的态度。不过Code还是可以从CVS Checkout,地址可以在项目首页上找到。

SWT Extension Example下载地址:

Java 版: http://feeling.sourceforge.net/downloads/example.zip
Native版:http://feeling.sourceforge.net/downloads/example_native.zip (如果上网的机器上还没有安装JRE的兄弟请选择这个)




SWT Extension extends the Eclipse library SWT.

It is a software development kit enabling you to work with native code from Java programs without using JNI. With SWT Extension, you don't need to create native libraries to call a function of the operating system API or a function from any dynamic library. You write code in the Java language only, and SWT Extension does the rest. SWT Extension provides quite a number of integration features to make your Java application look and behave like a Win32 citizen.

  • Window Decorations: making windows always-on-top, transparent, flashing on the taskbar, etc.
  • Custom Shape Window: creating non-rectangular windows using custom Regions.
  • Access to Windows Registry.
  • Shell Folders: getting paths and icons of the user folders (Favorites, My Pictures, etc)
  • Shell Links: managing the system link files.
  • System Info: gathering CPU and memory information.
  • Specially, you can get a lot of functions via SWT, because SWT Extension extends SWT.
  • posted @ 2007-06-28 17:10 三人行,必有我师焉 阅读(1326) | 评论 (7)编辑 收藏

    大概因为开发环境是英文的缘故吧,做了这么久时间的SWT-Extension,直到今天才发现存取中文都是乱码。不过显而易见的是Test Case做得太少了,毕竟是自己的开源项目,在上面投入的是兴趣,而不是精力。虽然一直在弄,但动辄就几个月没有commit,而且到现在也没有一个正式版发布。本来可以积累一点user的,现在估计也都跑光了。

    下面这段代码用于JNI中jstring和Window char之间转换:

    char* jstringToNative( JNIEnv  *env, jstring jstr )
    {
      
    int length = env->GetStringLength(jstr );
      
    const jchar* jcstr = env->GetStringChars(jstr, 0 );
      
    char* rtn = (char*)malloc( length*2+1 );
      
    int size = 0;
      size 
    = WideCharToMultiByte( CP_ACP, 0, (LPCWSTR)jcstr, length, rtn,(length*2+1), NULL, NULL );
      
    if( size <= 0 )return NULL;
      env
    ->ReleaseStringChars(jstr, jcstr );
      rtn[size] 
    = 0;
      
    return rtn;
    }

    jstring nativeTojstring( JNIEnv
    * env, char* str )
    {
      jstring rtn 
    = 0;
      
    int slen = strlen(str);
      unsigned 
    short * buffer = 0;
      
    if( slen == 0 )
        rtn 
    = env->NewStringUTF( str ); 
      
    else
      {
        
    int length = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)str, slen, NULL, 0 );
        buffer 
    = (unsigned short *)malloc( length*2 + 1 );
        
    if( MultiByteToWideChar( CP_ACP, 0, (LPCSTR)str, slen, (LPWSTR)buffer, length ) >0 )
          rtn 
    = env->NewString(  (jchar*)buffer, length );
      }
      
    if( buffer )
      free( buffer );
      
    return rtn;
    }



    JNI 用起来实在太麻烦了,比我做Java开发效率实在低得太多,各种各样的类型转换,我头都晕了…… 另外JNI好像是SUN中国研究院搞的,怎么就没有提供一个好的中文解决方案?

    Eclipse SWT Extension snapshot:













    posted @ 2007-06-25 12:43 三人行,必有我师焉 阅读(938) | 评论 (2)编辑 收藏

    仅列出标题
    共9页: 上一页 1 2 3 4 5 6 7 8 9 下一页 
    GitHub |  开源中国社区 |  maven仓库 |  文件格式转换