xref: /aosp_15_r20/external/cronet/base/win/nt_status.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/win/nt_status.h"
6 
7 #include <windows.h>
8 
9 extern "C" NTSTATUS WINAPI RtlGetLastNtStatus();
10 
11 namespace base {
12 namespace win {
13 
GetLastNtStatus()14 NTSTATUS GetLastNtStatus() {
15   // This is equivalent to calling NtCurrentTeb() and extracting
16   // LastStatusValue from the returned _TEB structure, except that the public
17   // _TEB struct definition does not actually specify the location of the
18   // LastStatusValue field. We avoid depending on such a definition by
19   // internally using RtlGetLastNtStatus() from ntdll.dll instead.
20   return ::RtlGetLastNtStatus();
21 }
22 
23 }  // namespace win
24 }  // namespace base
25