ReactOS  0.4.15-dev-1068-g467feb9
common.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS API tests
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: LOAD_CONFIG validation / registration
5  * COPYRIGHT: Copyright 2020 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "loadconfig.h"
9 
10 
11 // Tell the linker we want a LOAD_CONFIG
13 {
15  0, // TimeDateStamp
16  0, // MajorVersion
17  0, // MinorVersion
18  0, // GlobalFlagsClear
19  FLG_USER_STACK_TRACE_DB, // GlobalFlagsSet
20  0, // CriticalSectionDefaultTimeout
21  0, // DeCommitFreeBlockThreshold
22  0, // DeCommitTotalFreeThreshold
23  0, // LockPrefixTable
24  0, // MaximumAllocationSize
25  0, // VirtualMemoryThreshold
26  0, // ProcessHeapFlags
27  0, // ProcessAffinityMask
28  0, // CSDVersion
29  0, // Reserved1
30  0, // EditList
31  0, // SecurityCookie
32 };
33 
34 
36 {
37  BOOL Result;
38  PPEB Peb = NtCurrentPeb();
39  ULONG ConfigSize = 0;
40  ULONG MinimalSize;
42 
43  // Validate the required flag for the 'stacktrace' test
44  ok(Peb->NtGlobalFlag & FLG_USER_STACK_TRACE_DB, "NtGlobalFlag: 0x%lx\n", Peb->NtGlobalFlag);
46 
47  // Now validate our LOAD_CONFIG entry
49  TRUE,
51  &ConfigSize);
52 
53  MinimalSize = FIELD_OFFSET(IMAGE_LOAD_CONFIG_DIRECTORY, SecurityCookie) + sizeof(LoadConfig->SecurityCookie);
54  if (!LoadConfig || ConfigSize < MinimalSize)
55  {
56  ok(0, "Invalid IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG: %p, %lu (%lu)\n",
57  LoadConfig, ConfigSize, MinimalSize);
58  }
59  else
60  {
61  ok(LoadConfig->GlobalFlagsSet & FLG_USER_STACK_TRACE_DB,
62  "Invalid GlobalFlagsSet: %lx\n", LoadConfig->GlobalFlagsSet);
63  ok(!(LoadConfig->GlobalFlagsClear & FLG_USER_STACK_TRACE_DB),
64  "Invalid GlobalFlagsClear: %lx\n", LoadConfig->GlobalFlagsClear);
65  ok(LoadConfig->Size == sizeof(IMAGE_LOAD_CONFIG_DIRECTORY),
66  "Unexpected size difference: %lu vs %u\n", LoadConfig->Size, sizeof(IMAGE_LOAD_CONFIG_DIRECTORY));
67  }
68 
69  return Result;
70 }
PPEB Peb
Definition: dllmain.c:27
#define TRUE
Definition: types.h:120
const IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used
Definition: common.c:12
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
PIMAGE_LOAD_CONFIG_DIRECTORY32 PIMAGE_LOAD_CONFIG_DIRECTORY
Definition: ntimage.h:156
ULONG NtGlobalFlag
Definition: ntddk_ex.h:270
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG
Definition: compat.h:153
unsigned int BOOL
Definition: ntddk_ex.h:94
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static VOID LoadConfig(HWND hwndDlg, PPOWER_SCHEMES_PAGE_DATA pPageData, PPOWER_SCHEME pScheme)
Definition: powershemes.c:237
IMAGE_LOAD_CONFIG_DIRECTORY32 IMAGE_LOAD_CONFIG_DIRECTORY
Definition: ntimage.h:155
#define RtlImageDirectoryEntryToData
Definition: compat.h:557
#define NtCurrentPeb()
Definition: FLS.c:20
#define ok(value,...)
Definition: atltest.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
BOOL check_loadconfig()
Definition: common.c:35
unsigned int ULONG
Definition: retypes.h:1
#define FLG_USER_STACK_TRACE_DB
Definition: pstypes.h:67