ReactOS 0.4.17-dev-117-g313be0c
CConfiguration Class Reference

#include <CConfiguration.h>

Public Member Functions

 CConfiguration ()
 
void ParseParameters (int argc, wchar_t *argv[])
 
void GetSystemInformation ()
 
void GetConfigurationFromFile ()
 
bool DoCrashRecovery () const
 
bool DoPrint () const
 
bool DoShutdown () const
 
bool DoSubmit () const
 
bool IsInteractive () const
 
bool IsReactOS () const
 
unsigned long GetRepeatCount () const
 
bool ListModulesOnly () const
 
const stringGetComment () const
 
const wstringGetModule () const
 
const stringGetTest () const
 
const stringGetAuthenticationRequestString () const
 
const stringGetSystemInfoRequestString () const
 

Private Attributes

bool m_CrashRecovery
 
bool m_IsInteractive
 
bool m_IsReactOS
 
bool m_PrintToConsole
 
unsigned long m_RepeatCount
 
bool m_Shutdown
 
bool m_Submit
 
bool m_ListModules
 
string m_Comment
 
wstring m_Module
 
string m_Test
 
string m_AuthenticationRequestString
 
string m_SystemInfoRequestString
 

Detailed Description

Definition at line 8 of file CConfiguration.h.

Constructor & Destructor Documentation

◆ CConfiguration()

CConfiguration::CConfiguration ( )

Constructs an empty CConfiguration object

Definition at line 20 of file CConfiguration.cpp.

21 : m_CrashRecovery(false),
22 m_IsInteractive(false),
23 m_PrintToConsole(true),
25 m_Shutdown(false),
26 m_Submit(false),
27 m_ListModules(false)
28{
30
31 /* Check if we are running under ReactOS by calling our versionhelper function.
32 We cannot use the name of the SystemRoot folder, because bootcdregtest is using "c:\Windows".
33 Note: "IsReactOS()" without "::" would resolve to CConfiguration::IsReactOS(). */
35
36 if(GetEnvironmentVariableW(L"WINETEST_INTERACTIVE", Interactive, _countof(Interactive)))
38}
unsigned long m_RepeatCount
bool IsReactOS() const
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2773
#define L(x)
Definition: resources.c:13
short WCHAR
Definition: pedump.c:58
@ Interactive
Definition: ntsecapi.h:289
#define _countof(array)
Definition: sndvol32.h:70

Member Function Documentation

◆ DoCrashRecovery()

bool CConfiguration::DoCrashRecovery ( ) const
inline

Definition at line 32 of file CConfiguration.h.

32{ return m_CrashRecovery; }

◆ DoPrint()

bool CConfiguration::DoPrint ( ) const
inline

Definition at line 33 of file CConfiguration.h.

33{ return m_PrintToConsole; }

◆ DoShutdown()

bool CConfiguration::DoShutdown ( ) const
inline

Definition at line 34 of file CConfiguration.h.

34{ return m_Shutdown; }

◆ DoSubmit()

bool CConfiguration::DoSubmit ( ) const
inline

Definition at line 35 of file CConfiguration.h.

35{ return m_Submit; }

◆ GetAuthenticationRequestString()

const string & CConfiguration::GetAuthenticationRequestString ( ) const
inline

Definition at line 44 of file CConfiguration.h.

string m_AuthenticationRequestString

◆ GetComment()

const string & CConfiguration::GetComment ( ) const
inline

Definition at line 40 of file CConfiguration.h.

40{ return m_Comment; }

◆ GetConfigurationFromFile()

void CConfiguration::GetConfigurationFromFile ( )

Reads additional configuration options from the INI file.

ParseParameters should be called before this function to get the desired result.

Definition at line 211 of file CConfiguration.cpp.

212{
214 string Value;
215 WCHAR ConfigFile[MAX_PATH];
216
217 /* Most values are only needed if we're going to submit anything */
218 if(m_Submit)
219 {
220 /* Build the path to the configuration file from the application's path */
221 GetModuleFileNameW(NULL, ConfigFile, MAX_PATH);
222 Length = wcsrchr(ConfigFile, '\\') - ConfigFile + 1;
224
225 /* Check if it exists */
227 EXCEPTION("Missing \"" CONFIGURATION_FILENAME "\" configuration file!\n");
228
229 /* Get the user name */
230 m_AuthenticationRequestString = "&sourceid=";
231 Value = GetINIValue(L"Login", L"SourceID", ConfigFile);
232
233 if(Value.empty())
234 EXCEPTION("SourceID is missing in the configuration file\n");
235
237
238 /* Get the password */
239 m_AuthenticationRequestString += "&password=";
240 Value = GetINIValue(L"Login", L"Password", ConfigFile);
241
242 if(Value.empty())
243 EXCEPTION("Password is missing in the configuration file\n");
244
246
247 /* If we don't have any Comment string yet, try to find one in the INI file */
248 if(m_Comment.empty())
249 m_Comment = GetINIValue(L"Submission", L"Comment", ConfigFile);
250 }
251}
#define CONFIGURATION_FILENAME
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TEXT(s)
Definition: k32.h:28
string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName)
Definition: tools.cpp:187
#define EXCEPTION(Message)
Definition: precomp.h:58
string EscapeString(const char *Input)
Definition: tools.cpp:24
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
wcscpy
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ GetModule()

const wstring & CConfiguration::GetModule ( ) const
inline

Definition at line 41 of file CConfiguration.h.

41{ return m_Module; }

◆ GetRepeatCount()

unsigned long CConfiguration::GetRepeatCount ( ) const
inline

Definition at line 38 of file CConfiguration.h.

38{ return m_RepeatCount; }

◆ GetSystemInfoRequestString()

const string & CConfiguration::GetSystemInfoRequestString ( ) const
inline

Definition at line 45 of file CConfiguration.h.

string m_SystemInfoRequestString

◆ GetSystemInformation()

void CConfiguration::GetSystemInformation ( )

Gets information about the running system and sets the appropriate configuration settings.

Definition at line 141 of file CConfiguration.cpp.

142{
143 char ProductType;
146
147 /* Get the build from the define */
148 ss << "&revision=";
149 ss << KERNEL_VERSION_COMMIT_HASH;
150
151 ss << "&platform=";
152
153 if(m_IsReactOS)
154 {
155 ss << "reactos";
156 }
157 else
158 {
159 RTL_OSVERSIONINFOEXW rtlinfo = {0};
160 /* No, then use the info from GetVersionExW */
161 rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
162
163 if (!pRtlGetVersion)
164 {
165 HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
166 pRtlGetVersion = (decltype(pRtlGetVersion))GetProcAddress(hNtdll, "RtlGetVersion");
167 }
168
169 pRtlGetVersion(&rtlinfo);
170
171 if (rtlinfo.dwMajorVersion < 5)
172 EXCEPTION("Application requires at least Windows 2000!\n");
173
174 if (rtlinfo.wProductType == VER_NT_WORKSTATION)
175 ProductType = 'w';
176 else
177 ProductType = 's';
178
179 /* Print all necessary identification information into the Platform string */
180 ss << rtlinfo.dwMajorVersion << '.'
181 << rtlinfo.dwMinorVersion << '.'
182 << rtlinfo.dwBuildNumber << '.'
183 << rtlinfo.wServicePackMajor << '.'
184 << rtlinfo.wServicePackMinor << '.'
185 << ProductType << '.';
186 }
187
188 /* We also need to know about the processor architecture.
189 To retrieve this information accurately, check whether "GetNativeSystemInfo" is exported and use it then, otherwise fall back to "GetSystemInfo". */
190 if (!pGetSystemInfo)
191 {
192 HMODULE hKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
193 pGetSystemInfo = (decltype(pGetSystemInfo))GetProcAddress(hKernel32, "GetNativeSystemInfo");
194
195 if (!pGetSystemInfo)
196 pGetSystemInfo = GetSystemInfo;
197 }
198
199 pGetSystemInfo(&si);
201
203}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
#define ss
Definition: i386-dis.c:441
HANDLE hKernel32
Definition: locale.c:13
static HMODULE hNtdll
Definition: integrity.c:31
static SYSTEM_INFO si
Definition: virtual.c:39
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
USHORT wServicePackMinor
Definition: rtltypes.h:276
UCHAR wProductType
Definition: rtltypes.h:278
ULONG dwBuildNumber
Definition: rtltypes.h:272
USHORT wServicePackMajor
Definition: rtltypes.h:275
WORD wProcessorArchitecture
Definition: winbase.h:894
#define VER_NT_WORKSTATION

◆ GetTest()

const string & CConfiguration::GetTest ( ) const
inline

Definition at line 42 of file CConfiguration.h.

42{ return m_Test; }

◆ IsInteractive()

bool CConfiguration::IsInteractive ( ) const
inline

Definition at line 36 of file CConfiguration.h.

36{ return m_IsInteractive; }

◆ IsReactOS()

bool CConfiguration::IsReactOS ( ) const
inline

Definition at line 37 of file CConfiguration.h.

37{ return m_IsReactOS; }

Referenced by CConfiguration().

◆ ListModulesOnly()

bool CConfiguration::ListModulesOnly ( ) const
inline

Definition at line 39 of file CConfiguration.h.

39{ return m_ListModules; }

◆ ParseParameters()

void CConfiguration::ParseParameters ( int  argc,
wchar_t argv[] 
)

Parses the passed parameters and sets the appropriate configuration settings.

Parameters
argcThe number of parameters (argc parameter of the wmain function)
argvPointer to a wchar_t array containing the parameters (argv parameter of the wmain function)

Definition at line 50 of file CConfiguration.cpp.

51{
52 /* Parse the command line arguments */
53 for(int i = 1; i < argc; i++)
54 {
55 if(argv[i][0] == '-' || argv[i][0] == '/')
56 {
57 unsigned long tmp_RepeatCount;
58
59 switch(argv[i][1])
60 {
61 case 'c':
62 ++i;
63 if (i >= argc)
64 {
66 }
67
69 break;
70
71 case 'n':
72 m_PrintToConsole = false;
73 break;
74
75 case 'r':
76 m_CrashRecovery = true;
77 break;
78
79 case 's':
80 m_Shutdown = true;
81 break;
82
83 case 'w':
84 m_Submit = true;
85 break;
86
87 case 't':
88 ++i;
89 if (i >= argc)
90 {
92 }
93
94 tmp_RepeatCount = wcstoul(argv[i], NULL, 10);
95
96 if (tmp_RepeatCount == 0 || tmp_RepeatCount > 10000)
97 {
99 }
100
101 m_RepeatCount = tmp_RepeatCount;
102 break;
103
104 case 'l':
105 m_ListModules = true;
106 break;
107
108 default:
110 }
111 }
112 else
113 {
114 /* Which parameter is this? */
115 if(m_Module.empty())
116 {
117 /* Copy the parameter */
118 m_Module = argv[i];
119 }
120 else if(m_Test.empty())
121 {
122 /* Copy the parameter converted to ASCII */
124 }
125 else
126 {
128 }
129 }
130 }
131
132 /* The /r and /w options shouldn't be used in conjunction */
135}
MonoAssembly int argc
Definition: metahost.c:107
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2912
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
string UnicodeToAscii(PCWSTR UnicodeString)
Definition: tools.cpp:261
#define argv
Definition: mplay32.c:18

Member Data Documentation

◆ m_AuthenticationRequestString

string CConfiguration::m_AuthenticationRequestString
private

Definition at line 23 of file CConfiguration.h.

Referenced by GetAuthenticationRequestString(), and GetConfigurationFromFile().

◆ m_Comment

string CConfiguration::m_Comment
private

Definition at line 19 of file CConfiguration.h.

Referenced by GetComment(), GetConfigurationFromFile(), and ParseParameters().

◆ m_CrashRecovery

bool CConfiguration::m_CrashRecovery
private

Definition at line 11 of file CConfiguration.h.

Referenced by DoCrashRecovery(), and ParseParameters().

◆ m_IsInteractive

bool CConfiguration::m_IsInteractive
private

Definition at line 12 of file CConfiguration.h.

Referenced by CConfiguration(), and IsInteractive().

◆ m_IsReactOS

bool CConfiguration::m_IsReactOS
private

Definition at line 13 of file CConfiguration.h.

Referenced by CConfiguration(), GetSystemInformation(), and IsReactOS().

◆ m_ListModules

bool CConfiguration::m_ListModules
private

Definition at line 18 of file CConfiguration.h.

Referenced by ListModulesOnly(), and ParseParameters().

◆ m_Module

wstring CConfiguration::m_Module
private

Definition at line 20 of file CConfiguration.h.

Referenced by GetModule(), and ParseParameters().

◆ m_PrintToConsole

bool CConfiguration::m_PrintToConsole
private

Definition at line 14 of file CConfiguration.h.

Referenced by DoPrint(), and ParseParameters().

◆ m_RepeatCount

unsigned long CConfiguration::m_RepeatCount
private

Definition at line 15 of file CConfiguration.h.

Referenced by GetRepeatCount(), and ParseParameters().

◆ m_Shutdown

bool CConfiguration::m_Shutdown
private

Definition at line 16 of file CConfiguration.h.

Referenced by DoShutdown(), and ParseParameters().

◆ m_Submit

bool CConfiguration::m_Submit
private

Definition at line 17 of file CConfiguration.h.

Referenced by DoSubmit(), GetConfigurationFromFile(), and ParseParameters().

◆ m_SystemInfoRequestString

string CConfiguration::m_SystemInfoRequestString
private

Definition at line 24 of file CConfiguration.h.

Referenced by GetSystemInfoRequestString(), and GetSystemInformation().

◆ m_Test

string CConfiguration::m_Test
private

Definition at line 21 of file CConfiguration.h.

Referenced by GetTest(), and ParseParameters().


The documentation for this class was generated from the following files: