Search results for '전역 후크'

노트북 도난방지 1004

2008. 10. 5. 18:57

최대한 내가 필요로 하는 것과 비슷한 전역 후킹 소스를 찾았다
http://www.codeproject.com/KB/cs/globalhook.aspx
내가 필요한건 따로 txt파일로 저장하는 기능인데
이건 따로 저장만 안한다 뿐이지, 키값들을 계속 텍스트상자에 보여주길래
얼씨구 싶어서 바로 다운로드!!!

VS 2008 로 열어서 csproj 파일을 sin으로 바꾸고 실행해보니,
음 괜찮다. 이걸 txt에 저장하도록 바꾸고, 폼을 안보이게 하고
잘 눈치 못채게 숨기면 될 것같다.

일단 소스를 옮긴 다음에 조금씩 바꿔볼려고
VS 2008 에서 새 프로젝트를 만들어서 소스를 그대로 옮겨왔는데,
왠걸...
SetWindowsHookEx(...)으로 값을 할당받은 Hmouse 변수의 값이 변화가 없다.
SetWindowsHookEx()...가 먹히지 않는다.
도대체 뭐가 문제인지.
소스를 그대로 옮겨왔는데도 불구하고...OTL

괜히 이것저것 고쳐보고 하다가 시간만 흘러가고ㅠ_ㅠ
오늘은 그냥 여기까지만 하고 체념할때즈음에
저 소스를 구했던 곳의 Q&A를 보니 누군가가
How to make debugging work in VS2008 (express) with these hook?
이렇게 질문해놓은 글을 보았다.
그리고 그에 대한 친절한 답변.

The answer is simple: 
0: Copy UserActivityHook.cs to your project, add an instance of the UserActivityHook object, set up the event handlers, enter Debug mode, and waste a couple of hours trying to fix the Win32Exceptions thrown on lines 538 and 562 before coming back to this site and seeing this solution.
1: Go to the project properties page (right-click the project name and select properties)
2: Go to the Debug tab and uncheck "Enable the Visual Studios hosting process"
3: Realize that the ctrl and alt keys map to Keys.LControlKey, Keys.RControlKey, Keys.LMenu, and Keys.RMenu, since you're now able to see the results of each of your key presses. (It really makes a lot more sense, now that I can see how Windows is managing each of the keys... Just wasn't obvious before.  )


으하하
이렇게 난 해결을 보고야 말았다.
좋구나, 조금씩 조금씩 완성에 다가가는 이 느낌♬

박상근 프로그래밍/Laptop Guard