ReactOS 0.4.16-dev-112-g52265ae
gflags.c File Reference
#include "gflags.h"
Include dependency graph for gflags.c:

Go to the source code of this file.

Functions

BOOL OpenImageFileExecOptions (IN REGSAM SamDesired, IN OPTIONAL PCWSTR ImageName, OUT HKEY *Key)
 
DWORD ReadSZFlagsFromRegistry (HKEY SubKey, PWSTR Value)
 
static BOOL ParseCmdline (int argc, LPWSTR argv[])
 
int wmain (int argc, LPWSTR argv[])
 

Variables

static BOOL UsePageHeap = FALSE
 
static BOOL UseImageFile = FALSE
 
const WCHAR ImageExecOptionsString [] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options"
 

Function Documentation

◆ 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
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#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
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define wprintf(...)
Definition: whoami.c:18
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DisplayStatus(), and ModifyStatus().

◆ ParseCmdline()

static BOOL ParseCmdline ( int  argc,
LPWSTR  argv[] 
)
static

Definition at line 62 of file gflags.c.

63{
64 INT i;
65
66 if (argc < 2)
67 {
68 wprintf(L"Not enough args!\n");
69 return FALSE;
70 }
71
72 for (i = 1; i < argc; i++)
73 {
74 if (argv[i][0] == L'/')
75 {
76 if (argv[i][1] == L'p' && argv[i][2] == UNICODE_NULL)
77 {
79 return PageHeap_ParseCmdline(i + 1, argc, argv);
80 }
81 if (argv[i][1] == L'i' && argv[i][2] == UNICODE_NULL)
82 {
84 return ImageFile_ParseCmdline(i + 1, argc, argv);
85 }
86 }
87 else
88 {
89 wprintf(L"Invalid option: %s\n", argv[i]);
90 return FALSE;
91 }
92 }
93
95 {
96 wprintf(L"Only page heap / image file flags are supported\n");
97 return FALSE;
98 }
99
100 return TRUE;
101}
static int argc
Definition: ServiceArgs.c:12
static BOOL UseImageFile
Definition: gflags.c:12
static BOOL UsePageHeap
Definition: gflags.c:11
BOOL ImageFile_ParseCmdline(INT i, int argc, LPWSTR argv[])
Definition: imagefile.c:207
BOOL PageHeap_ParseCmdline(INT i, int argc, LPWSTR argv[])
Definition: pageheap.c:244
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
#define argv
Definition: mplay32.c:18
#define UNICODE_NULL
int32_t INT
Definition: typedefs.h:58

Referenced by 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:4103
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#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().

◆ wmain()

int wmain ( int  argc,
LPWSTR  argv[] 
)

Definition at line 104 of file gflags.c.

105{
106 if (!ParseCmdline(argc, argv))
107 {
108 wprintf(L"Usage: gflags [/p [image.exe] [/enable|/disable [/full]]]\n"
109 L" [/i <image.exe> [<Flags>]]\n"
110 L" image.exe: Image you want to deal with\n"
111 L" /enable: enable page heap for the image\n"
112 L" /disable: disable page heap for the image\n"
113 L" /full: activate full debug page heap\n"
114 L" <Flags>: A 32 bit hex number (0x00000001) that specifies\n"
115 L" one or more global flags to set.\n"
116 L" Without any flags, the current settings are shown.\n"
117 L" Specify FFFFFFFF to delete the GlobalFlags entry.\n"
118 L" Additionally, instead of a single hex number,\n"
119 L" specify a list of abbreviations prefixed with\n"
120 L" a '+' to add, and '-' to remove a bit.\n"
121 L" Valid abbreviations:\n");
123 return 1;
124 }
125
126 if (UsePageHeap)
127 {
128 return PageHeap_Execute();
129 }
130 else if (UseImageFile)
131 {
132 return ImageFile_Execute();
133 }
134 return 2;
135}
static BOOL ParseCmdline(int argc, LPWSTR argv[])
Definition: gflags.c:62
INT ImageFile_Execute()
Definition: imagefile.c:251
INT PageHeap_Execute()
Definition: pageheap.c:295
void PrintFlags(IN DWORD GlobalFlags, IN OPTIONAL WORD Dest)
Definition: imagefile.c:67
#define DEST_IMAGE
Definition: gflags.h:35

Variable Documentation

◆ ImageExecOptionsString

const WCHAR ImageExecOptionsString[] = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options"

Definition at line 14 of file gflags.c.

Referenced by OpenImageFileExecOptions().

◆ UseImageFile

BOOL UseImageFile = FALSE
static

Definition at line 12 of file gflags.c.

Referenced by ParseCmdline(), and wmain().

◆ UsePageHeap

BOOL UsePageHeap = FALSE
static

Definition at line 11 of file gflags.c.

Referenced by ParseCmdline(), and wmain().