好久没有访问csdn,现在都变的不太认识.
【程序编程相关:学习DTS:数据库之间的导入和导出。】 【推荐阅读: 用java实现print screen】由于这几年从事驱动开发,就发一些自已的心得. 【扩展信息:C++ Advanced Trainin】 在驱动开发中,有时候我们需要取得当前进程的路径,在之前,大家都是在抄xfilt的代码(xfilt是抄osr). #define base_process_peb_offset 0x01b0 #define base_peb_process_parameter_offset 0x0010 #define base_process_parameter_full_image_name 0x003cpcwstr kfgetprocessfullname()
/*++ arguments:pfullimagename - pointer to get the process name, etc: "c:\winnt\notepad.exe".
--*/
{ dword dwaddress;if(kegetcurrentirql() != passive_level)
return null;dwaddress = (dword)psgetcurrentprocess();
if(dwaddress == 0 || dwaddress == 0xffffffff)
return null; dwaddress += base_process_peb_offset; if((dwaddress = *(dword*)dwaddress) == 0) return 0; dwaddress += base_peb_process_parameter_offset; if((dwaddress = *(dword*)dwaddress) == 0) return 0; dwaddress += base_process_parameter_full_image_name; if((dwaddress = *(dword*)dwaddress) == 0) return 0;return (pcwstr)dwaddress;
} 这段代码在2k/xp能正确工作,可在2003上,一执行就蓝屏,为什么呢??? 首先你要理想这段代码的工作原理(知道还看什么,快关ie.) 流程: 1.取得eprocess(psgetcurrentprocess();) 2. 通过偏移量取得peb, (address + base_process_peb_offset ) 3.通过peb指针的偏移量取得rtl_user_process_parameter( address + base_peb_process_parameter_offset) 最后是取得其imagepathname, 得到是unicode_string结构. 知道原理后,下面演示我是如何在2003上取得:调试心得记录:使用windbg 分析2003的全路径存在哪儿?
... 下一页