10#define WIN32_NO_STATUS
16#define COUNT_OF(x) (sizeof((x))/sizeof((x)[0]))
23#define DQUOTECHAR L'"'
25LPWSTR ExtractCmdLine(IN LPWSTR lpszCommandLine)
27 BOOL inDoubleQuote = FALSE;
30 * Skip the program's name (the first token in the command line).
31 * Handle quoted program's name.
35 while ( (*lpszCommandLine > SPACECHAR) ||
36 (*lpszCommandLine && inDoubleQuote) )
38 if (*lpszCommandLine == DQUOTECHAR)
39 inDoubleQuote = !inDoubleQuote;
44 /* Skip all white spaces preceeding the second token. */
45 while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
49 return lpszCommandLine;
52VOID ExtractCmdLine_U(IN OUT PUNICODE_STRING pCommandLine_U)
54 BOOL inDoubleQuote = FALSE;
55 PWSTR lpszCommandLine;
58 * Skip the program's name (the first token in the command line).
59 * Handle quoted program's name.
61 if (pCommandLine_U && pCommandLine_U->Buffer && (pCommandLine_U->Length != 0))
63 lpszCommandLine = pCommandLine_U->Buffer;
65 while ( (pCommandLine_U->Length > 0) &&
66 ( (*lpszCommandLine > SPACECHAR) ||
67 (*lpszCommandLine && inDoubleQuote) ) )
69 if (*lpszCommandLine == DQUOTECHAR)
70 inDoubleQuote = !inDoubleQuote;
73 pCommandLine_U->Length -= sizeof(WCHAR);
76 /* Skip all white spaces preceeding the second token. */
77 while ((pCommandLine_U->Length > 0) && *lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
80 pCommandLine_U->Length -= sizeof(WCHAR);
83 pCommandLine_U->Buffer = lpszCommandLine;
89/******************************************************************************/
91/* The path to the utility program run by this test. */
92static WCHAR UtilityProgramDirectory[MAX_PATH];
94/* The list of tests. */
95typedef struct _TEST_CASE
98 BOOL bEncloseProgramNameInQuotes;
99} TEST_CASE, *PTEST_CASE;
101static TEST_CASE TestCases[] =
105 {L"\"foo bar\"", FALSE},
106 {
L"foo \"bar John\" Doe",
FALSE},
110 {
L"\"foo bar\"",
TRUE},
111 {
L"foo \"bar John\" Doe",
TRUE},
130 if (
TestCase->bEncloseProgramNameInQuotes && bWasntInQuotes)
135 if (
TestCase->bEncloseProgramNameInQuotes && bWasntInQuotes)
182 WCHAR BuffNT[0xffff ];
200 sizeof(dwStringSize),
204 dwStringSize =
min(dwStringSize,
sizeof(BuffWinMain));
217 sizeof(dwStringSize),
221 dwStringSize =
min(dwStringSize,
sizeof(BuffWin32));
236 NTCmdLine.
Buffer = BuffNT;
268 ok(
wcslen(WinMainCmdLine) ==
wcslen(Win32CmdLine),
"Test %lu - WinMain and Win32 command lines do not have the same length !\n", TestNumber);
269 ok(
wcsncmp(WinMainCmdLine, Win32CmdLine, dwStringSize) == 0,
"Test %lu - WinMain and Win32 command lines are different !\n", TestNumber);
272 ok(
wcsncmp(WinMainCmdLine, NTCmdLine.
Buffer, dwStringSize) == 0,
"Test %lu - WinMain and NT command lines are different !\n", TestNumber);
275 ok(
wcsncmp(Win32CmdLine, NTCmdLine.
Buffer, dwStringSize) == 0,
"Test %lu - Win32 and NT command lines are different !\n", TestNumber);
297 ok(dwRet != 0,
"ERROR: Cannot retrieve the path to the current running process, last error %lu\n",
GetLastError());
298 if (dwRet == 0)
return;
VOID ExtractCmdLine_U(IN OUT PUNICODE_STRING pCommandLine_U)
static TEST_CASE TestCases[]
static void Test_CommandLine(IN ULONG TestNumber, IN PTEST_CASE TestCase)
static WCHAR UtilityProgramDirectory[MAX_PATH]
LPWSTR ExtractCmdLine(IN LPWSTR lpszCommandLine)
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
static const WCHAR CmdLine[]
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
DWORD WINAPI GetLastError(void)
#define CREATE_UNICODE_ENVIRONMENT