ReactOS 0.4.16-dev-1946-g52006dd
CConfiguration.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Class for managing all the configuration parameters
5 * COPYRIGHT: Copyright 2009-2011 Colin Finck (colin@reactos.org)
6 */
7
8#include "precomp.h"
9#include <versionhelpers.h>
10
11#define CONFIGURATION_FILENAME "rosautotest.ini"
12
13static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
14static void(NTAPI *pRtlGetVersion)(RTL_OSVERSIONINFOEXW *);
15
16
21 : m_CrashRecovery(false),
22 m_IsInteractive(false),
23 m_PrintToConsole(true),
24 m_RepeatCount(1),
25 m_Shutdown(false),
26 m_Submit(false),
27 m_ListModules(false)
28{
29 WCHAR WindowsDirectory[MAX_PATH];
31
32 /* Check if we are running under ReactOS from the SystemRoot directory */
33 if(!GetWindowsDirectoryW(WindowsDirectory, MAX_PATH))
34 FATAL("GetWindowsDirectoryW failed\n");
35
36 m_IsReactOS = !_wcsnicmp(&WindowsDirectory[3], L"reactos", 7);
38
39 if(GetEnvironmentVariableW(L"WINETEST_INTERACTIVE", Interactive, _countof(Interactive)))
41}
42
52void
54{
55 /* Parse the command line arguments */
56 for(int i = 1; i < argc; i++)
57 {
58 if(argv[i][0] == '-' || argv[i][0] == '/')
59 {
60 unsigned long tmp_RepeatCount;
61
62 switch(argv[i][1])
63 {
64 case 'c':
65 ++i;
66 if (i >= argc)
67 {
69 }
70
72 break;
73
74 case 'n':
75 m_PrintToConsole = false;
76 break;
77
78 case 'r':
79 m_CrashRecovery = true;
80 break;
81
82 case 's':
83 m_Shutdown = true;
84 break;
85
86 case 'w':
87 m_Submit = true;
88 break;
89
90 case 't':
91 ++i;
92 if (i >= argc)
93 {
95 }
96
97 tmp_RepeatCount = wcstoul(argv[i], NULL, 10);
98
99 if (tmp_RepeatCount == 0 || tmp_RepeatCount > 10000)
100 {
102 }
103
104 m_RepeatCount = tmp_RepeatCount;
105 break;
106
107 case 'l':
108 m_ListModules = true;
109 break;
110
111 default:
113 }
114 }
115 else
116 {
117 /* Which parameter is this? */
118 if(m_Module.empty())
119 {
120 /* Copy the parameter */
121 m_Module = argv[i];
122 }
123 else if(m_Test.empty())
124 {
125 /* Copy the parameter converted to ASCII */
127 }
128 else
129 {
131 }
132 }
133 }
134
135 /* The /r and /w options shouldn't be used in conjunction */
138}
139
143void
145{
146 char ProductType;
148 SYSTEM_INFO si;
149
150 /* Get the build from the define */
151 ss << "&revision=";
152 ss << KERNEL_VERSION_COMMIT_HASH;
153
154 ss << "&platform=";
155
156 if(m_IsReactOS)
157 {
158 ss << "reactos";
159 }
160 else
161 {
162 RTL_OSVERSIONINFOEXW rtlinfo = {0};
163 /* No, then use the info from GetVersionExW */
164 rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
165
166 if (!pRtlGetVersion)
167 {
168 HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
169 pRtlGetVersion = (decltype(pRtlGetVersion))GetProcAddress(hNtdll, "RtlGetVersion");
170 }
171
172 pRtlGetVersion(&rtlinfo);
173
174 if (rtlinfo.dwMajorVersion < 5)
175 EXCEPTION("Application requires at least Windows 2000!\n");
176
177 if (rtlinfo.wProductType == VER_NT_WORKSTATION)
178 ProductType = 'w';
179 else
180 ProductType = 's';
181
182 /* Print all necessary identification information into the Platform string */
183 ss << rtlinfo.dwMajorVersion << '.'
184 << rtlinfo.dwMinorVersion << '.'
185 << rtlinfo.dwBuildNumber << '.'
186 << rtlinfo.wServicePackMajor << '.'
187 << rtlinfo.wServicePackMinor << '.'
188 << ProductType << '.';
189 }
190
191 /* We also need to know about the processor architecture.
192 To retrieve this information accurately, check whether "GetNativeSystemInfo" is exported and use it then, otherwise fall back to "GetSystemInfo". */
193 if (!pGetSystemInfo)
194 {
195 HMODULE hKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
196 pGetSystemInfo = (decltype(pGetSystemInfo))GetProcAddress(hKernel32, "GetNativeSystemInfo");
197
198 if (!pGetSystemInfo)
199 pGetSystemInfo = GetSystemInfo;
200 }
201
202 pGetSystemInfo(&si);
204
206}
207
213void
215{
217 string Value;
218 WCHAR ConfigFile[MAX_PATH];
219
220 /* Most values are only needed if we're going to submit anything */
221 if(m_Submit)
222 {
223 /* Build the path to the configuration file from the application's path */
224 GetModuleFileNameW(NULL, ConfigFile, MAX_PATH);
225 Length = wcsrchr(ConfigFile, '\\') - ConfigFile + 1;
227
228 /* Check if it exists */
230 EXCEPTION("Missing \"" CONFIGURATION_FILENAME "\" configuration file!\n");
231
232 /* Get the user name */
233 m_AuthenticationRequestString = "&sourceid=";
234 Value = GetINIValue(L"Login", L"SourceID", ConfigFile);
235
236 if(Value.empty())
237 EXCEPTION("SourceID is missing in the configuration file\n");
238
240
241 /* Get the password */
242 m_AuthenticationRequestString += "&password=";
243 Value = GetINIValue(L"Login", L"Password", ConfigFile);
244
245 if(Value.empty())
246 EXCEPTION("Password is missing in the configuration file\n");
247
249
250 /* If we don't have any Comment string yet, try to find one in the INI file */
251 if(m_Comment.empty())
252 m_Comment = GetINIValue(L"Submission", L"Comment", ConfigFile);
253 }
254}
#define CONFIGURATION_FILENAME
static int argc
Definition: ServiceArgs.c:12
unsigned long m_RepeatCount
void GetSystemInformation()
void GetConfigurationFromFile()
bool IsReactOS() const
string m_SystemInfoRequestString
void ParseParameters(int argc, wchar_t *argv[])
string m_AuthenticationRequestString
wcscpy
#define NULL
Definition: types.h:112
#define wcsrchr
Definition: compat.h:16
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:755
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
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 ss
Definition: i386-dis.c:441
#define TEXT(s)
Definition: k32.h:28
HANDLE hKernel32
Definition: locale.c:13
string GetINIValue(PCWCH AppName, PCWCH KeyName, PCWCH FileName)
Definition: tools.cpp:187
#define EXCEPTION(Message)
Definition: precomp.h:58
string UnicodeToAscii(PCWSTR UnicodeString)
Definition: tools.cpp:261
string EscapeString(const char *Input)
Definition: tools.cpp:24
#define FATAL(Message)
Definition: precomp.h:59
static HMODULE hNtdll
Definition: integrity.c:31
#define argv
Definition: mplay32.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ Interactive
Definition: ntsecapi.h:289
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define _countof(array)
Definition: sndvol32.h:70
#define true
Definition: stdbool.h:36
#define false
Definition: stdbool.h:37
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 NTAPI
Definition: typedefs.h:36
#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
struct _SYSTEM_INFO * LPSYSTEM_INFO
#define WINAPI
Definition: msvc.h:6
#define VER_NT_WORKSTATION
__wchar_t WCHAR
Definition: xmlstorage.h:180