本文介绍了如何理解“ NTSTATUS”,“ NT_SUCCESS”?在Windows ddk中的typedef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

两个问题:

1。

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

In "ntdef.h" the NTSTATUS is defined as follow:

typedef __success(return >= 0) LONG NTSTATUS;

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

what the hell is the "__success(return >= 0)"?

2。

在 ntstatus.h中, STATUS_SUCCESS 定义为0。

In "ntstatus.h", STATUS_SUCCESS is defined to 0.

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

但是 ntdef.h中的 NT_SUCCESS 宏是:

But the NT_SUCCESS macro in "ntdef.h" is:

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

应该不是状态== 0吗?

Shouldn't it be "Status == 0" ?

推荐答案

__成功是在SpecStrings_strict中定义的高级注释 .h,其定义如下。

__success is an "Advanced Annotation" defined in SpecStrings_strict.h, which defines it as follows.


*  __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 不能对<$ c进行严格测试的原因$ c> STATUS_SUCCESS(0)可能是其他代码,例如 STATUS_PENDING 实际上并不是失败。

The reason that NT_SUCCESS doesn't do a strict test against STATUS_SUCCESS (0) is probably that other codes like STATUS_PENDING aren't actually failures.

这篇关于如何理解“ NTSTATUS”,“ NT_SUCCESS”?在Windows ddk中的typedef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 15:10