ReactOS 0.4.15-dev-8028-g8e799e2
CmdLineUtil.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API Tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for CRT command-line handling - Utility GUI program.
5 * PROGRAMMER: Hermès BÉLUSCA - MAÏTO <hermes.belusca@sfr.fr>
6 */
7
8#define WIN32_NO_STATUS
9#include <stdio.h>
10#include <windef.h>
11#include <winbase.h>
12#include <ndk/rtlfuncs.h>
13
14#include "CmdLineUtil.h"
15
17 HINSTANCE hPrevInstance,
18 LPWSTR lpCmdLine,
19 int nCmdShow)
20{
21 /*
22 * Get the unparsed command line as seen in Win32 mode,
23 * and the NT-native mode one.
24 */
26 UNICODE_STRING CmdLine_U = NtCurrentPeb()->ProcessParameters->CommandLine;
27
28 /* Write the results into a file. */
31 0, NULL,
34 NULL);
36 {
37 DWORD dwSize, dwStringSize;
38
39 /*
40 * Format of the data file :
41 *
42 * [size_of_string 4 bytes][null_terminated_C_string]
43 * [size_of_string 4 bytes][null_terminated_C_string]
44 * [UNICODE_STRING_structure][string_buffer_of_UNICODE_STRING]
45 */
46
47 /* 1- Write the WinMain's command line. */
48 dwStringSize = (lstrlenW(lpCmdLine) + 1) * sizeof(WCHAR);
49
51 &dwStringSize,
52 sizeof(dwStringSize),
53 &dwSize,
54 NULL);
55
57 lpCmdLine,
58 dwStringSize,
59 &dwSize,
60 NULL);
61
62 /* 2- Write the Win32 mode command line. */
63 dwStringSize = (lstrlenW(CmdLine) + 1) * sizeof(WCHAR);
64
66 &dwStringSize,
67 sizeof(dwStringSize),
68 &dwSize,
69 NULL);
70
72 CmdLine,
73 dwStringSize,
74 &dwSize,
75 NULL);
76
77 /* 3- Finally, write the UNICODE_STRING command line. */
79 &CmdLine_U,
80 sizeof(CmdLine_U),
81 &dwSize,
82 NULL);
83
85 CmdLine_U.Buffer,
86 CmdLine_U.Length,
87 &dwSize,
88 NULL);
89
90 /* Now close the file. */
92 }
93
94 return 0;
95}
96
97/* EOF */
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
Definition: CmdLineUtil.c:16
#define DATAFILE
Definition: CmdLineUtil.h:11
#define NtCurrentPeb()
Definition: FLS.c:22
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define APIENTRY
Definition: api.h:79
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
static const WCHAR CmdLine[]
Definition: install.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184