2012-10-09 20:56:11 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS API Tests
|
|
|
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for CRT command-line handling - Utility GUI program.
|
2012-10-09 22:08:32 +00:00
|
|
|
* PROGRAMMER: Hermès BÉLUSCA - MAÏTO <hermes.belusca@sfr.fr>
|
2012-10-09 20:56:11 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include <stdio.h>
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <ndk/rtlfuncs.h>
|
2012-10-09 20:56:11 +00:00
|
|
|
|
2012-10-09 22:03:50 +00:00
|
|
|
#include "CmdLineUtil.h"
|
|
|
|
|
2012-10-09 20:56:11 +00:00
|
|
|
int APIENTRY wWinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPWSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Get the unparsed command line as seen in Win32 mode,
|
|
|
|
* and the NT-native mode one.
|
|
|
|
*/
|
|
|
|
LPWSTR CmdLine = GetCommandLineW();
|
|
|
|
UNICODE_STRING CmdLine_U = NtCurrentPeb()->ProcessParameters->CommandLine;
|
|
|
|
|
|
|
|
/* Write the results into a file. */
|
2012-10-09 22:03:50 +00:00
|
|
|
HANDLE hFile = CreateFileW(DATAFILE,
|
2012-10-09 20:56:11 +00:00
|
|
|
GENERIC_WRITE,
|
|
|
|
0, NULL,
|
|
|
|
CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
NULL);
|
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
DWORD dwSize, dwStringSize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Format of the data file :
|
|
|
|
*
|
|
|
|
* [size_of_string 4 bytes][null_terminated_C_string]
|
|
|
|
* [size_of_string 4 bytes][null_terminated_C_string]
|
|
|
|
* [UNICODE_STRING_structure][string_buffer_of_UNICODE_STRING]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 1- Write the WinMain's command line. */
|
|
|
|
dwStringSize = (wcslen(lpCmdLine) + 1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
WriteFile(hFile,
|
|
|
|
&dwStringSize,
|
|
|
|
sizeof(dwStringSize),
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
WriteFile(hFile,
|
|
|
|
lpCmdLine,
|
|
|
|
dwStringSize,
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* 2- Write the Win32 mode command line. */
|
|
|
|
dwStringSize = (wcslen(CmdLine) + 1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
WriteFile(hFile,
|
|
|
|
&dwStringSize,
|
|
|
|
sizeof(dwStringSize),
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
WriteFile(hFile,
|
|
|
|
CmdLine,
|
|
|
|
dwStringSize,
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* 3- Finally, write the UNICODE_STRING command line. */
|
|
|
|
WriteFile(hFile,
|
|
|
|
&CmdLine_U,
|
|
|
|
sizeof(CmdLine_U),
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
WriteFile(hFile,
|
|
|
|
CmdLine_U.Buffer,
|
|
|
|
CmdLine_U.Length,
|
|
|
|
&dwSize,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Now close the file. */
|
|
|
|
CloseHandle(hFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|