ImageVerifierCode 换一换
你正在下载:

AppLog.docx

[预览]
格式:DOCX , 页数:8 ,大小:17.05KB ,
资源ID:7923355      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7923355.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(AppLog.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

AppLog.docx

1、AppLogAppLog.c/*Module name: AppLog.cWritten by: Jonathan LockeNotices: Copyright (c) 1995 Jeffrey RichterPurpose: Shell hooks demonstration application*/#include Win95ADG.h /* See Appendix A for details */#include #include #pragma warning(disable: 4001) /* Single line comment */#include #include Sh

2、ellHk.h#include Resource.h/ Force a link with the import library for ShellHk.dll#pragma comment(lib, adgLIBBUILDTYPE adgLIBCPUTYPE ShellHk)/BOOL AppLog_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam) adgSETDLGICONS(hwnd, IDI_APPLOG, IDI_APPLOG); if (!ShellHook_Start(GetDlgItem(hwnd, IDC_APPL

3、OG) adgMB(_TEXT(Unable to start shell hook); EndDialog(hwnd, IDCANCEL); return(TRUE); / Accept default focus window. / void AppLog_OnSize (HWND hwnd, UINT state, int cx, int cy) / When the user resizes the main window, we must resize the listbox SetWindowPos(GetDlgItem(hwnd, IDC_APPLOG), NULL, 0, 0,

4、 cx, cy, SWP_NOZORDER); / void AppLog_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) switch (id) case IDCANCEL: / Allows dialog box to close / Unhook shell hook before exiting. if (!ShellHook_Stop() adgMB(_TEXT(Unable to stop shell hook); EndDialog(hwnd, id); break; / BOOL WINAPI AppLo

5、g_DlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (uMsg) / Standard Windows messages adgHANDLE_DLGMSG(hwnd, WM_INITDIALOG, AppLog_OnInitDialog); adgHANDLE_DLGMSG(hwnd, WM_COMMAND, AppLog_OnCommand); adgHANDLE_DLGMSG(hwnd, WM_SIZE, AppLog_OnSize); return(FALSE); / We didnt process

6、 the message./int WINAPI WinMain (HINSTANCE hinstExe, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int nCmdShow) adgWARNIFUNICODEUNDERWIN95(); adgVERIFY(-1 != DialogBox(hinstExe, MAKEINTRESOURCE(IDD_APPLOG), NULL, AppLog_DlgProc); return(0);ShellHk.c /*Module name: ShellHk.c Written by: Jonathan Locke No

7、tices: Copyright (c) 1995 Jeffrey Richter Purpose: Dll which sets a system shell hook. */ #include Win95ADG.h /* See Appendix A for details */ #include #include #pragma warning(disable: 4001) /* Single line comment */ #include #pragma warning(disable: 4001) /* Single line comment */ / We must define

8、 SHELLHKLIBAPI as dllexport before including ShellHk.h. / ShellHk.h will see that we have already defined SHELLHKLIBAPI and / will not (re)define it as dllimport. #define SHELLHKLIBAPI _declspec(dllexport) #include ShellHk.h / HINSTANCE g_hinstDll = NULL; / ShellHk.dlls instance handle / / Calling S

9、etWindowsHookEx with a thread id of zero will cause this DLL to be/ injected into other processes. Therefore, we must declare a shared data / section so that all mappings of our DLL (in all processes) share the same / set of global variables. /#pragma comment(lib, kernel32 ) #pragma data_seg(Shared)

10、 HHOOK g_hhook = NULL; / Hook handle for systemwide shell hook HWND g_hwndListBox = NULL; / Listbox in which to insert log strings #pragma data_seg() /#pragma comment(linker, -section:Shared,rws) / static LRESULT WINAPI ShellHook_HookProc (int nCode,WPARAM wParam, LPARAM lParam) TCHAR sz128, szPath1

11、28; DWORD dwProcessID; HWND hwnd = (HWND) wParam; DWORD dwThreadID = GetWindowThreadProcessId(hwnd, &dwProcessID); LRESULT lResult = CallNextHookEx(g_hhook, nCode, wParam, lParam); switch (nCode) case HSHELL_WINDOWCREATED: case HSHELL_WINDOWDESTROYED: / GetModuleFileName is being called in the conte

12、xt of the process in / which this Dll has been injected. if (!GetModuleFileName(NULL, szPath, adgARRAY_SIZE(szPath) _tcscpy(szPath, _TEXT(); wsprintf(sz, _TEXT(%c pid=0x%08x, tid=0x%08x, path=%s), (nCode = HSHELL_WINDOWCREATED ? _TEXT() : _TEXT(), dwProcessID, dwThreadID, szPath); ListBox_AddString(

13、g_hwndListBox, sz); break; return(lResult); / BOOL WINAPI ShellHook_Start (HWND hwndListBox) HHOOK hhook = NULL; / Return FALSE if hook has already been installed. if (g_hhook != NULL) return(FALSE); adgASSERT(IsWindow(hwndListBox); g_hwndListBox = hwndListBox; / Give up the remainder of our threads

14、 timeslice. / This gives us a better chance of getting all the way through the call / to SetWindowsHookEx and the variable assignment to g_hhook in one shot. / If we are preempted after the hook is set, but before the variable is / updated, it is possible for another thread to enter our hook filter

15、/ function before the hook handle is valid. Under Windows NT this is not / a problem. Under Windows 95, not having a valid hook handle will cause / CallNextHookEx to fail. If there is some reason that it is critical / that your application succeed in calling the next filter function in / the chain,

16、the only robust way to write this code is to use something / like the SWMRG (single-writer, multiple-reader guard) object developed / in Advanced Windows (Microsoft Press). Sleep(0); / Set our keyboard hook. hhook = SetWindowsHookEx(WH_SHELL, ShellHook_HookProc, g_hinstDll, 0); / Ensure that g_hhook

17、 is always valid (even if we are preempted whilst / in the middle of writing to it) by updating the variable atomically. InterlockedExchange(PLONG) &g_hhook, (LONG) hhook); return(g_hhook != NULL);/BOOL WINAPI ShellHook_Stop () BOOL fOK = TRUE; / Only uninstall the hook if it was successfully installed. if (g_hhook != NULL) fOK = UnhookWindowsHookEx(g_hhook); g_hhook = NULL; return(fOK);/BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) switch (fdwReason) case DLL_PROCESS_ATTACH: g_hinstDll = hinstDll; break; return(TRUE);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1