ReactOS 0.4.15-dev-5673-g06b25bc
gflags.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <winreg.h>
#include <stdio.h>
#include <stdlib.h>
#include <pstypes.h>
Include dependency graph for gflags.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define DEST_REGISTRY   1
 
#define DEST_KERNEL   2
 
#define DEST_IMAGE   4
 

Functions

BOOL PageHeap_ParseCmdline (INT i, int argc, LPWSTR argv[])
 
BOOL ImageFile_ParseCmdline (INT i, int argc, LPWSTR argv[])
 
INT PageHeap_Execute ()
 
INT ImageFile_Execute ()
 
DWORD ReadSZFlagsFromRegistry (HKEY SubKey, PWSTR Value)
 
BOOL OpenImageFileExecOptions (IN REGSAM SamDesired, IN OPTIONAL PCWSTR ImageName, OUT HKEY *Key)
 
void PrintFlags (IN DWORD GlobalFlags, IN OPTIONAL WORD Dest)
 

Variables

const WCHAR ImageExecOptionsString []
 

Macro Definition Documentation

◆ DEST_IMAGE

#define DEST_IMAGE   4

Definition at line 35 of file gflags.h.

◆ DEST_KERNEL

#define DEST_KERNEL   2

Definition at line 34 of file gflags.h.

◆ DEST_REGISTRY

#define DEST_REGISTRY   1

Definition at line 33 of file gflags.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 8 of file gflags.h.

Function Documentation

◆ ImageFile_Execute()

INT ImageFile_Execute ( )

Definition at line 251 of file imagefile.c.

252{
254 {
256 }
257 else
258 {
259 ModifyStatus();
260 }
261
262 return 0;
263}
static BOOL OptionsSet
Definition: imagefile.c:13
static VOID DisplayStatus(VOID)
Definition: imagefile.c:190
static DWORD OptionsAdd
Definition: imagefile.c:11
static DWORD OptionsRemove
Definition: imagefile.c:12
static VOID ModifyStatus(VOID)
Definition: imagefile.c:135

Referenced by wmain().

◆ ImageFile_ParseCmdline()

BOOL ImageFile_ParseCmdline ( INT  i,
int  argc,
LPWSTR  argv[] 
)

Definition at line 207 of file imagefile.c.

208{
209 for (; i < argc; i++)
210 {
211 if (ImageFile == NULL)
212 {
213 ImageFile = argv[i];
214 }
215 else if (argv[i][0] == '+')
216 {
217 if (OptionsSet)
218 {
219 wprintf(L"Unexpected argument - '%s'\n", argv[i]);
220 return FALSE;
221 }
223 }
224 else if (argv[i][0] == '-')
225 {
226 if (OptionsSet)
227 {
228 wprintf(L"Unexpected argument - '%s'\n", argv[i]);
229 return FALSE;
230 }
232 }
233 else
234 {
236 OptionsAdd = wcstoul(argv[i], NULL, 16);
237 if (OptionsAdd == ~0)
238 OptionsAdd = 0;
239 }
240 }
241
242 if (ImageFile == NULL)
243 {
244 wprintf(L"No Image specified\n");
245 return FALSE;
246 }
247
248 return TRUE;
249}
static int argc
Definition: ServiceArgs.c:12
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DEST_IMAGE
Definition: gflags.h:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static DWORD FindFlag(PCWSTR Name, WORD Dest)
Definition: imagefile.c:117
static PWSTR ImageFile
Definition: imagefile.c:10
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
#define wprintf(...)
Definition: whoami.c:18

Referenced by ParseCmdline().

◆ OpenImageFileExecOptions()

BOOL OpenImageFileExecOptions ( IN REGSAM  SamDesired,
IN OPTIONAL PCWSTR  ImageName,
OUT HKEY Key 
)

Definition at line 16 of file gflags.c.

17{
18 LONG Ret;
19 HKEY HandleKey, HandleSubKey;
20
21 Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ImageExecOptionsString, 0, SamDesired, &HandleKey);
22 if (Ret != ERROR_SUCCESS)
23 {
24 wprintf(L"OpenIFEO: RegOpenKeyEx failed (%d)\n", Ret);
25 return FALSE;
26 }
27
28 if (ImageName == NULL)
29 {
30 *Key = HandleKey;
31 return TRUE;
32 }
33
34 Ret = RegCreateKeyExW(HandleKey, ImageName, 0, NULL, REG_OPTION_NON_VOLATILE, SamDesired, NULL, &HandleSubKey, NULL);
35 CloseHandle(HandleKey);
36
37 if (Ret != ERROR_SUCCESS)
38 {
39 wprintf(L"OpenIFEO: RegCreateKeyEx failed (%d)\n", Ret);
40 return FALSE;
41 }
42 *Key = HandleSubKey;
43 return TRUE;
44}
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define CloseHandle
Definition: compat.h:739
const WCHAR ImageExecOptionsString[]
Definition: gflags.c:14
static const char * ImageName
Definition: image.c:34
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
long LONG
Definition: pedump.c:60
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DisplayStatus(), and ModifyStatus().

◆ PageHeap_Execute()

INT PageHeap_Execute ( )

Definition at line 295 of file pageheap.c.

296{
297 if (!Set && !Unset)
298 {
300 }
301 else
302 {
303 ModifyStatus();
304 }
305
306 return 0;
307}
static BOOL Set
Definition: pageheap.c:10
static BOOL Unset
Definition: pageheap.c:11
static VOID DisplayStatus(VOID)
Definition: pageheap.c:178
static VOID ModifyStatus(VOID)
Definition: pageheap.c:16

Referenced by wmain().

◆ PageHeap_ParseCmdline()

BOOL PageHeap_ParseCmdline ( INT  i,
int  argc,
LPWSTR  argv[] 
)

Definition at line 244 of file pageheap.c.

245{
246 for (; i < argc; i++)
247 {
248 if (argv[i][0] == L'/')
249 {
250 if (wcscmp(argv[i], L"/enable") == 0)
251 {
252 Set = TRUE;
253 }
254 else if (wcscmp(argv[i], L"/disable") == 0)
255 {
256 Unset = TRUE;
257 }
258 else if (wcscmp(argv[i], L"/full") == 0)
259 {
260 Full = TRUE;
261 }
262 }
263 else if (Image == NULL)
264 {
265 Image = argv[i];
266 }
267 else
268 {
269 wprintf(L"Invalid option: %s\n", argv[i]);
270 return FALSE;
271 }
272 }
273
274 if (Set && Unset)
275 {
276 wprintf(L"ENABLE and DISABLED cannot be set together\n");
277 return FALSE;
278 }
279
280 if (Image == NULL && (Set || Unset || Full))
281 {
282 wprintf(L"Can't ENABLE or DISABLE with no image\n");
283 return FALSE;
284 }
285
286 if (!Set && !Unset && Full)
287 {
288 wprintf(L"Cannot deal with full traces with no other indication\n");
289 return FALSE;
290 }
291
292 return TRUE;
293}
static BOOL Full
Definition: pageheap.c:12
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by ParseCmdline().

◆ PrintFlags()

void PrintFlags ( IN DWORD  GlobalFlags,
IN OPTIONAL WORD  Dest 
)

Definition at line 67 of file imagefile.c.

68{
69 DWORD n;
70
71 for (n = 0; n < ARRAYSIZE(g_Flags); ++n)
72 {
73 if (!Dest || (g_Flags[n].wDest & Dest))
74 {
75 if (g_Flags[n].dwFlag & GlobalFlags)
76 {
77 wprintf(L" %s - %s\n", g_Flags[n].szAbbr, g_Flags[n].szDesc);
78 }
79 }
80 }
81}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble n
Definition: glext.h:7729
UINT NTAPI GlobalFlags(HGLOBAL hMem)
Definition: heapmem.c:520
static const FlagInfo g_Flags[]
Definition: imagefile.c:30

Referenced by ShowStatus(), and wmain().

◆ ReadSZFlagsFromRegistry()

DWORD ReadSZFlagsFromRegistry ( HKEY  SubKey,
PWSTR  Value 
)

Definition at line 47 of file gflags.c.

48{
49 WCHAR Buffer[20] = { 0 };
51
52 Len = sizeof(Buffer) - sizeof(WCHAR);
53 Flags = 0;
54 if (RegQueryValueExW(SubKey, Value, NULL, &Type, (BYTE*)Buffer, &Len) == ERROR_SUCCESS && Type == REG_SZ)
55 {
56 Flags = wcstoul(Buffer, NULL, 16);
57 }
58
59 return Flags;
60}
Type
Definition: Type.h:7
Definition: bufpool.h:45
#define Len
Definition: deflate.h:82
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
#define REG_SZ
Definition: layer.c:22
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DisplayImageInfo(), DisplayStatus(), and ModifyStatus().

Variable Documentation

◆ ImageExecOptionsString

const WCHAR ImageExecOptionsString[]
extern