summaryrefslogtreecommitdiffstats
path: root/ceee/testing/utils/gflag_utils_unittest.cc
blob: c48bfc7a99156d730c7ecf7e0520be0412681f68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Unittests for the gflags utilities.
#include "gtest/gtest.h"
#include "ceee/testing/utils/gflag_utils.h"
#include "ceee/testing/utils/nt_internals.h"

namespace testing {

TEST(GFlagUtilsTest, WriteProcessGFlags) {
  // Get our own global flags.
  ULONG old_gflags = nt_internals::RtlGetNtGlobalFlags();

  // Toggle one bit.
  ULONG new_gflags = old_gflags ^ FLG_SHOW_LDR_SNAPS;
  EXPECT_HRESULT_SUCCEEDED(WriteProcessGFlags(::GetCurrentProcess(),
                                              new_gflags));
  EXPECT_EQ(new_gflags, nt_internals::RtlGetNtGlobalFlags());

  // Restore old global flags.
  EXPECT_HRESULT_SUCCEEDED(WriteProcessGFlags(::GetCurrentProcess(),
                                              old_gflags));
  EXPECT_EQ(old_gflags, nt_internals::RtlGetNtGlobalFlags());
}

}  // namespace testing