加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何理解windows ddk中的“NTSTATUS”,“NT_SUCCESS”typedef?

发布时间:2020-12-13 22:28:47 所属栏目:Windows 来源:网络整理
导读:两个问题: 1. 在“ntdef.h”中,NTSTATUS定义如下: typedef __success(return = 0) LONG NTSTATUS; 到底是什么“__ success(return = 0)”? 2. 在“ntstatus.h”中,STATUS_SUCCESS定义为0. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
两个问题:

1.

在“ntdef.h”中,NTSTATUS定义如下:

typedef __success(return >= 0) LONG NTSTATUS;

到底是什么“__ success(return> = 0)”?

2.

在“ntstatus.h”中,STATUS_SUCCESS定义为0.

#define STATUS_SUCCESS   ((NTSTATUS)0x00000000L) // ntsubauth

但是“ntdef.h”中的NT_SUCCESS宏是:

#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)

不应该是“状态== 0”吗?

解决方法

__ccess是SpecStrings_strict.h中定义的“高级注释”,它定义如下.

*  __success(expr) T f() :  indicates whether function f succeeded or
*  not. If  is true at exit,all the function's guarantees (as given
*  by other annotations) must hold. If  is false at exit,the caller
*  should not expect any of the function's guarantees to hold. If not used,*  the function must always satisfy its guarantees. Added automatically to
*  functions that indicate success in standard ways,such as by returning an
*  HRESULT.

NT_SUCCESS不对STATUS_SUCCESS(0)进行严格测试的原因可能是其他代码(如STATUS_PENDING)实际上并未发生故障.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读