ReactOS 0.4.16-dev-292-gbbdcc14
imagefile.c File Reference
#include "gflags.h"
Include dependency graph for imagefile.c:

Go to the source code of this file.

Classes

struct  FlagInfo
 

Macros

#define FLG_DISABLE_DBGPRINT   0x8000000
 
#define FLG_CRITSEC_EVENT_CREATION   0x10000000
 
#define FLG_STOP_ON_UNHANDLED_EXCEPTION   0x20000000
 
#define FLG_ENABLE_HANDLE_EXCEPTIONS   0x40000000
 
#define FLG_DISABLE_PROTDLLS   0x80000000
 

Typedefs

typedef struct FlagInfo FlagInfo
 

Functions

void PrintFlags (IN DWORD GlobalFlags, IN OPTIONAL WORD Dest)
 
static void ShowStatus (DWORD GlobalFlags, DWORD Ignored)
 
static DWORD ValidateFlags (DWORD GlobalFlags, WORD Dest)
 
static DWORD FindFlag (PCWSTR Name, WORD Dest)
 
static VOID ModifyStatus (VOID)
 
static VOID DisplayStatus (VOID)
 
BOOL ImageFile_ParseCmdline (INT i, int argc, LPWSTR argv[])
 
INT ImageFile_Execute ()
 

Variables

static PWSTR ImageFile = NULL
 
static DWORD OptionsAdd = 0
 
static DWORD OptionsRemove = 0
 
static BOOL OptionsSet = FALSE
 
static const FlagInfo g_Flags []
 

Macro Definition Documentation

◆ FLG_CRITSEC_EVENT_CREATION

#define FLG_CRITSEC_EVENT_CREATION   0x10000000

Definition at line 24 of file imagefile.c.

◆ FLG_DISABLE_DBGPRINT

#define FLG_DISABLE_DBGPRINT   0x8000000

Definition at line 23 of file imagefile.c.

◆ FLG_DISABLE_PROTDLLS

#define FLG_DISABLE_PROTDLLS   0x80000000

Definition at line 27 of file imagefile.c.

◆ FLG_ENABLE_HANDLE_EXCEPTIONS

#define FLG_ENABLE_HANDLE_EXCEPTIONS   0x40000000

Definition at line 26 of file imagefile.c.

◆ FLG_STOP_ON_UNHANDLED_EXCEPTION

#define FLG_STOP_ON_UNHANDLED_EXCEPTION   0x20000000

Definition at line 25 of file imagefile.c.

Typedef Documentation

◆ FlagInfo

Function Documentation

◆ DisplayStatus()

static VOID DisplayStatus ( VOID  )
static

Definition at line 190 of file imagefile.c.

191{
192 HKEY IFEOKey;
194
196 {
197 return;
198 }
199
200 GlobalFlags = ReadSZFlagsFromRegistry(IFEOKey, L"GlobalFlag");
202
203 CloseHandle(IFEOKey);
204}
#define CloseHandle
Definition: compat.h:739
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL OpenImageFileExecOptions(IN REGSAM SamDesired, IN OPTIONAL PCWSTR ImageName, OUT HKEY *Key)
Definition: gflags.c:16
DWORD ReadSZFlagsFromRegistry(HKEY SubKey, PWSTR Value)
Definition: gflags.c:47
UINT NTAPI GlobalFlags(HGLOBAL hMem)
Definition: heapmem.c:520
static void ShowStatus(DWORD GlobalFlags, DWORD Ignored)
Definition: imagefile.c:83
static PWSTR ImageFile
Definition: imagefile.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50

Referenced by ImageFile_Execute().

◆ FindFlag()

static DWORD FindFlag ( PCWSTR  Name,
WORD  Dest 
)
static

Definition at line 117 of file imagefile.c.

118{
119 DWORD n;
120
121 for (n = 0; n < ARRAYSIZE(g_Flags); ++n)
122 {
123 if (g_Flags[n].wDest & Dest)
124 {
125 if (!_wcsicmp(Name, g_Flags[n].szAbbr))
126 {
127 return g_Flags[n].dwFlag;
128 }
129 }
130 }
131
132 return 0;
133}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLdouble n
Definition: glext.h:7729
static const FlagInfo g_Flags[]
Definition: imagefile.c:30
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD dwFlag
Definition: imagefile.c:17

Referenced by ImageFile_ParseCmdline().

◆ 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
_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 wprintf(...)
Definition: whoami.c:18

Referenced by ParseCmdline().

◆ ModifyStatus()

static VOID ModifyStatus ( VOID  )
static

Definition at line 135 of file imagefile.c.

136{
137 LONG Ret;
138 DWORD GlobalFlags, Requested, Ignored;
139 HKEY IFEOKey;
140 WCHAR Buffer[11];
141
143 {
144 return;
145 }
146
147 if (OptionsSet)
148 {
149 Requested = OptionsAdd;
150 }
151 else
152 {
153 Requested = ReadSZFlagsFromRegistry(IFEOKey, L"GlobalFlag");
154 Requested &= ~OptionsRemove;
155 Requested |= OptionsAdd;
156 }
157
159 Ignored = GlobalFlags ^ Requested;
160
161 if (GlobalFlags)
162 {
163 wsprintf(Buffer, L"0x%08x", GlobalFlags);
164 Ret = RegSetValueExW(IFEOKey, L"GlobalFlag", 0, REG_SZ, (BYTE*)Buffer, (wcslen(Buffer) + 1) * sizeof(WCHAR));
165 if (Ret != ERROR_SUCCESS)
166 {
167 wprintf(L"MS: RegSetValueEx failed (%d)\n", Ret);
168 }
169 else
170 {
171 ShowStatus(GlobalFlags, Ignored);
172 }
173 }
174 else
175 {
176 Ret = RegDeleteValueW(IFEOKey, L"GlobalFlag");
177 if (Ret != ERROR_SUCCESS)
178 {
179 wprintf(L"MS: RegDeleteValue failed (%d)\n", Ret);
180 }
181 else
182 {
183 ShowStatus(GlobalFlags, Ignored);
184 }
185 }
186 CloseHandle(IFEOKey);
187}
Definition: bufpool.h:45
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
static DWORD ValidateFlags(DWORD GlobalFlags, WORD Dest)
Definition: imagefile.c:101
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define KEY_WRITE
Definition: nt_native.h:1031
long LONG
Definition: pedump.c:60
#define wsprintf
Definition: winuser.h:5877
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ImageFile_Execute().

◆ 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}

Referenced by ShowStatus(), and wmain().

◆ ShowStatus()

static void ShowStatus ( DWORD  GlobalFlags,
DWORD  Ignored 
)
static

Definition at line 83 of file imagefile.c.

84{
85 if (GlobalFlags)
86 {
87 wprintf(L"Current Registry Settings for %s executable are: %08x\n", ImageFile, GlobalFlags);
89 }
90 else
91 {
92 wprintf(L"No Registry Settings for %s executable\n", ImageFile);
93 }
94 if (Ignored)
95 {
96 wprintf(L"The following settings were ignored: %08x\n", Ignored);
97 PrintFlags(Ignored, 0);
98 }
99}
void PrintFlags(IN DWORD GlobalFlags, IN OPTIONAL WORD Dest)
Definition: imagefile.c:67

Referenced by DisplayStatus(), and ModifyStatus().

◆ ValidateFlags()

static DWORD ValidateFlags ( DWORD  GlobalFlags,
WORD  Dest 
)
static

Definition at line 101 of file imagefile.c.

102{
103 DWORD n;
104 DWORD Valid = 0;
105
106 for (n = 0; n < ARRAYSIZE(g_Flags); ++n)
107 {
108 if (g_Flags[n].wDest & Dest)
109 {
110 Valid |= g_Flags[n].dwFlag;
111 }
112 }
113
114 return GlobalFlags & Valid;
115}

Referenced by ModifyStatus().

Variable Documentation

◆ g_Flags

const FlagInfo g_Flags[]
static

Definition at line 30 of file imagefile.c.

Referenced by FindFlag(), PrintFlags(), and ValidateFlags().

◆ ImageFile

◆ OptionsAdd

DWORD OptionsAdd = 0
static

Definition at line 11 of file imagefile.c.

Referenced by ImageFile_Execute(), ImageFile_ParseCmdline(), and ModifyStatus().

◆ OptionsRemove

DWORD OptionsRemove = 0
static

Definition at line 12 of file imagefile.c.

Referenced by ImageFile_Execute(), and ImageFile_ParseCmdline().

◆ OptionsSet

BOOL OptionsSet = FALSE
static

Definition at line 13 of file imagefile.c.

Referenced by ImageFile_Execute(), ImageFile_ParseCmdline(), and ModifyStatus().