__try异常处理
2015-06-22 22:12
295 查看
#ifdef __cplusplus extern "C" { #endif #include <ntddk.h> #ifdef __cplusplus } #endif void helloxpUnload(IN PDRIVER_OBJECT DriverObject); void Test(void); #ifdef __cplusplus extern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath); #endif NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { DbgPrint("Hello from hello2003!\n"); DriverObject->DriverUnload = helloxpUnload; PEPROCESS pEprocess=PsGetCurrentProcess(); PTSTR ProcessName=(PTSTR)((ULONG)pEprocess+0x174); DbgPrint(TEXT("%s"),ProcessName); int* P=NULL; __try { //判断指针是否可读 ProbeForRead(P,100,4); *P=1234; } __except(EXCEPTION_EXECUTE_HANDLER) { DbgPrint(TEXT("异常产生\n")); } Test(); return STATUS_SUCCESS; } void helloxpUnload(IN PDRIVER_OBJECT DriverObject) { DbgPrint("Goodbye from hello2003!\n"); } void Test(void) { __try { //做一些事哈 DbgPrint(TEXT("我是你的大皇冠\n")); return; } __finally { //程序退出前必须执行到这里,比如释放资源等等 DbgPrint(TEXT("打我PG我不乖\n")); } return; }
相关文章推荐
- swift switch Double
- Java IDE-常见Java开发工具的特点比较
- iOS开发之使用CALayer封装下载进度条
- 将一个二维数组行和列的元素互换,存到另一个二位数组中
- cglib代理
- 2015062202 - CSDN手机app
- 无惧杀入红海市场 ZUK手机底气在哪?
- iOS开发之使用UIimage+ImageEffects实现图片模糊效果
- 软件需求规格说明书
- Bash shell和变量详解
- 构造函数和析构函数
- Android中Activity四种启动模式和taskAffinity属性详解
- swift 编译预定义 --不知道怎么定义,但是可以#if
- 我的第一个开源项目(Auditory)
- 软件详细设计说明书
- 数据结构基础(5)--队列和循环队列详解--静态方式
- 推荐一个在线查看函数图象的网站 —— Desmos
- MySQL
- pycurl库使用详解
- iOS开发之那些不容错过的技术博客