Feeling

              三人行,必有我?guī)熝?/p>

             ::  :: 新隨筆 :: 聯(lián)系 ::  :: 管理 ::
            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,自不必說,用來監(jiān)聽鼠標(biāo)和鍵盤的。Journal的2個Hook則是所謂的日志鉤子,WH_JOURNALPLAYBACK Hook使應(yīng)用程序可以插入消息到系統(tǒng)消息隊(duì)列。可以使用這個Hook回放通過使用WH_JOURNALRECORD Hook記錄下來的連續(xù)的鼠標(biāo)和鍵盤事件。只要WH_JOURNALPLAYBACK Hook已經(jīng)安裝,正常的鼠標(biāo)和鍵盤事件就是無效的。WH_JOURNALPLAYBACK Hook是全局Hook,它不能象線程特定Hook一樣使用。WH_JOURNALPLAYBACK Hook返回超時值,這個值告訴系統(tǒng)在處理來自回放Hook當(dāng)前消息之前需要等待多長時間(毫秒)。這就使Hook可以控制實(shí)時事件的回放。

          基本上現(xiàn)在用SWT-Extension來實(shí)現(xiàn)這四個Hook還是很容易的,做了一下簡單的數(shù)據(jù)封裝和事件封裝,而且加入了結(jié)合體對象和JNI的handle互相轉(zhuǎn)換的函數(shù)。用來做C++的一些事情還是比較得心應(yīng)手的。最新版本的Example提供了一個簡單的系統(tǒng)Record/Playback例子,可以記錄和回放系統(tǒng)事件。

           

          最新的build已經(jīng)發(fā)布到 http://feeling.sourceforge.net 上了,有興趣的可以下載看看,并且可以作為Eclipse插件使用,支持 eclipse 3.2 以上版本。

          PS: Journal的2個Hook Vista已經(jīng)停止支持了,所以這個例子在Vista 下是看不到的:-(
          posted @ 2007-12-12 18:18 三人行,必有我?guī)熝?閱讀(1521) | 評論 (2)編輯 收藏

          SWT-Extension這個項(xiàng)目做了很久,但一直都沒有realease,只是個人做著玩玩,很重要的一個原因是對Windows System Hook的機(jī)制沒有能夠很好地實(shí)現(xiàn)出來。Hook本身不算是很難的技術(shù),在C++,C#里都能夠很容易的實(shí)現(xiàn),為什么運(yùn)用Java就那么困難呢?

          首先當(dāng)然主要還是我個人對C++并不在行了,其次就是Java和C++交互的問題了。要想通過C++把數(shù)據(jù)傳給Java,就要通過JNI標(biāo)準(zhǔn)的接口來實(shí)現(xiàn),也就是要通過 JNIENV 來實(shí)現(xiàn),但是HookProc 這個CallBack 是給系統(tǒng)進(jìn)程調(diào)用的,不是給你Java調(diào)用的,你說系統(tǒng)進(jìn)程調(diào)用了 HookProc 之后,沒法把這個事件傳遞給Java,那么還有一個方法,用Java不間斷的輪循Hook里的數(shù)據(jù),這倒是能實(shí)現(xiàn),網(wǎng)上也有一個老外的例子,但不好的地方就是當(dāng)我系統(tǒng)沒工作的時候,你Java還在那兒輪循我干嘛?這不是浪費(fèi)資源嗎?所以呢,這解鈴還需系鈴人,系統(tǒng)的事件還得讓系統(tǒng)來通知你才好。在Java里,有一個IO阻塞,比如當(dāng)調(diào)用System.in.read()的時候,系統(tǒng)就是等待你的輸入,如果你不輸入,系統(tǒng)就一直等著不工作。還有線程,有wait方法,非要等著其他的線程通過notify把你喚醒你才能工作。在C++里也有這么一套機(jī)制:CreateEvent 和WaitForSingleObject,也就是說我先創(chuàng)建一個事件,然后將這個事件置于未激活狀態(tài),讓它一直等待,將線程阻塞住,當(dāng)HookProc被系統(tǒng)進(jìn)程調(diào)用的時候,就將這個事件激活,通知Java程序你可以開始干活了,干完活以后再次被阻塞,直到這個Hook被uninstall掉。當(dāng)然這其中還有一些 C++ 代碼的細(xì)節(jié)性問題,比如怎么讓不同的進(jìn)程共享同一個事件,這里要說明的就是不同的進(jìn)程可以共享同一個事件,但是不能共享同一個事件句柄,同一個事件,在不同的進(jìn)程里有不同的句柄,句柄是不能跨進(jìn)程的。 

          我個人認(rèn)為Hook應(yīng)當(dāng)是SWT-Extension里一個很重要的組成部分,SWT本身只能實(shí)現(xiàn)線程鉤子,對于系統(tǒng)級的鉤子無能為力。因?yàn)橄到y(tǒng)機(jī)鉤子需要實(shí)現(xiàn)數(shù)據(jù)共享操作,還需要DLL入口句柄,這些我已都在SWT-Extension中實(shí)現(xiàn)了。唯一讓我遺憾的是沒有辦法實(shí)現(xiàn)日志鉤子,這是一個很有用的鉤子,可以用來記入當(dāng)前用戶行為的操作,然后重新演示,我想如果做自動化測試這個會很有用,或者給游戲軟件練功什么的,呵呵。之所以不能實(shí)現(xiàn)是因?yàn)檫@個鉤子很特別,它要的不是DLL的句柄,而是應(yīng)用程序的句柄,這沒有辦法從Java程序里獲得,我試過javaw.exe,但是也不行,會導(dǎo)致系統(tǒng)假死。以后有時間在研究吧。

          做完Hook,終于可以松一口氣,發(fā)一個小小的realease了,剩下的就是document工作要做了,一個枯燥無味的工作,就當(dāng)練習(xí)一下英語好了。

          這里發(fā)一個Hook的截圖:




          沒有了標(biāo)題欄的Eclipse
          最新的Build和代碼也可以在 http://feeling.sf.net 上下載了。
          posted @ 2007-12-07 15:08 三人行,必有我?guī)熝?閱讀(2469) | 評論 (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 三人行,必有我?guī)熝?閱讀(424) | 評論 (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 三人行,必有我?guī)熝?閱讀(256) | 評論 (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 三人行,必有我?guī)熝?閱讀(1029) | 評論 (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(走遍美國) 很好的英語口語學(xué)習(xí)教材
          Speed(生死時速) 練習(xí)聽力,語速很慢

          posted @ 2007-09-05 13:30 三人行,必有我?guī)熝?閱讀(288) | 評論 (0)編輯 收藏

          在你看來,下面圖像的運(yùn)動方向是順時針呢還是逆時針呢??
          每個人看來都是不一樣的 
           
          順時針的話,屬于是用右腦較多的類型
          逆時針屬于是用左腦較多的類型
          大部分人的眼里是逆時針方向轉(zhuǎn)動,但也有人看來是順時針方向轉(zhuǎn)動的。
          順時針的情況,女性比男性多 ~~
          試試吧!~ 

          我第一眼看上去是逆時針,第二眼又變成了順時針。

          怎么說呢,以不同的視角看,就會形成不同的旋轉(zhuǎn)路線,可能是逆時針也可能是順時針,我現(xiàn)在已經(jīng)是忽左忽右,快暴走了。

          自己找到了一個比較好的解決方法,腦袋貼近屏幕向右偏轉(zhuǎn)45度看,很容易形成逆時針,向左偏轉(zhuǎn)45度看,很容易形成順時針,主要是人和圖片的視角問題。這圖片設(shè)計(jì)的也太巧妙了。

          Team里的人大部分看都是順時針,只有一個左撇子看是逆時針。
          posted @ 2007-07-25 17:11 三人行,必有我?guī)熝?閱讀(1854) | 評論 (6)編輯 收藏

            中新網(wǎng)7月13日電 綜合報道,一名犯有重罪的羅馬尼亞犯人近日向上帝提出控訴,地方法院12日對此予以駁回。

            據(jù)悉,該名羅馬尼亞犯人是2005年7月因受賄罪被捕的。他被判處入獄20年,在獄中更是抱怨上帝對他不公,在2006年甚至向地方法院控告上帝。

            這名犯人說,早在他出生時在教堂受洗的時候就與上帝訂立了契約,讓他能夠快樂生活,但現(xiàn)在“上帝打破了這份契約,因此有必要控告他”。

            地方法院12日發(fā)布的判決書稱,“由于無法獲知上帝的家庭住址,因此無法向其傳達(dá)法院的意見,”并最終對囚犯的要求予以駁回。

          posted @ 2007-07-13 18:19 三人行,必有我?guī)熝?閱讀(316) | 評論 (0)編輯 收藏

          昨晚趕工為SF上的項(xiàng)目做了個首頁:http://feeling.sf.net 。各位兄弟有空可以看看,幫忙提點(diǎn)意見,不過現(xiàn)在鋪的好像就有點(diǎn)大了,這么多頁面,不知道何時才能做完,打算就先這么擱一個首頁,以后有時間再說吧。

          SWT Extension Example我今天打包了一下,已經(jīng)可以下載了,但是源代碼我暫時還沒打算開放下載,因?yàn)橛行┕δ苓€沒做好,需要一段時間,最重要的是我打算對現(xiàn)有代碼進(jìn)行重構(gòu),API可能有比較重大的調(diào)整,現(xiàn)在提供下載,對想要使用的兄弟來說是一種不負(fù)責(zé)任的態(tài)度。不過Code還是可以從CVS Checkout,地址可以在項(xiàng)目首頁上找到。

          SWT Extension Example下載地址:

          Java 版: http://feeling.sourceforge.net/downloads/example.zip
          Native版:http://feeling.sourceforge.net/downloads/example_native.zip (如果上網(wǎng)的機(jī)器上還沒有安裝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.

        1. Window Decorations: making windows always-on-top, transparent, flashing on the taskbar, etc.
        2. Custom Shape Window: creating non-rectangular windows using custom Regions.
        3. Access to Windows Registry.
        4. Shell Folders: getting paths and icons of the user folders (Favorites, My Pictures, etc)
        5. Shell Links: managing the system link files.
        6. System Info: gathering CPU and memory information.
        7. Specially, you can get a lot of functions via SWT, because SWT Extension extends SWT.
        8. posted @ 2007-06-28 17:10 三人行,必有我?guī)熝?閱讀(1337) | 評論 (7)編輯 收藏

          大概因?yàn)殚_發(fā)環(huán)境是英文的緣故吧,做了這么久時間的SWT-Extension,直到今天才發(fā)現(xiàn)存取中文都是亂碼。不過顯而易見的是Test Case做得太少了,畢竟是自己的開源項(xiàng)目,在上面投入的是興趣,而不是精力。雖然一直在弄,但動輒就幾個月沒有commit,而且到現(xiàn)在也沒有一個正式版發(fā)布。本來可以積累一點(diǎn)user的,現(xiàn)在估計(jì)也都跑光了。

          下面這段代碼用于JNI中jstring和Window char之間轉(zhuǎn)換:

          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 用起來實(shí)在太麻煩了,比我做Java開發(fā)效率實(shí)在低得太多,各種各樣的類型轉(zhuǎn)換,我頭都暈了…… 另外JNI好像是SUN中國研究院搞的,怎么就沒有提供一個好的中文解決方案?

          Eclipse SWT Extension snapshot:













          posted @ 2007-06-25 12:43 三人行,必有我?guī)熝?閱讀(952) | 評論 (2)編輯 收藏

          僅列出標(biāo)題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
          GitHub |  開源中國社區(qū) |  maven倉庫 |  文件格式轉(zhuǎn)換 
          主站蜘蛛池模板: 呼和浩特市| 离岛区| 安义县| 康定县| 宣武区| 宜章县| 金山区| 丘北县| 休宁县| 内黄县| 岫岩| 乌兰浩特市| 襄汾县| 万载县| 水城县| 临武县| 威信县| 革吉县| 汉源县| 修武县| 盱眙县| 富阳市| 鸡泽县| 清河县| 汉源县| 云霄县| 阜平县| 莱芜市| 平罗县| 汝城县| 静海县| 咸丰县| 灯塔市| 阳朔县| 铁岭县| 奈曼旗| 天门市| 襄樊市| 甘孜县| 永善县| 翁源县|