2001-01-11 00:59:25 +01:00
|
|
|
/*
|
|
|
|
* msvcrt.dll dll data items
|
|
|
|
*
|
|
|
|
* Copyright 2000 Jon Griffiths
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-01-11 00:59:25 +01:00
|
|
|
*/
|
2002-04-26 21:05:15 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include "msvcrt.h"
|
2020-07-21 12:21:59 +02:00
|
|
|
#include <winnls.h>
|
2002-01-22 01:57:16 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2020-04-08 15:09:26 +02:00
|
|
|
static WCHAR **initial_wargv;
|
|
|
|
static int initial_argc;
|
2008-07-21 14:47:55 +02:00
|
|
|
int MSVCRT___argc = 0;
|
2012-12-14 10:33:49 +01:00
|
|
|
static int wargc_expand;
|
2008-07-21 14:47:55 +02:00
|
|
|
unsigned int MSVCRT__commode = 0;
|
2018-12-14 17:39:06 +01:00
|
|
|
int MSVCRT__fmode = 0;
|
2008-07-21 14:47:55 +02:00
|
|
|
unsigned int MSVCRT__osver = 0;
|
2010-05-05 13:36:58 +02:00
|
|
|
unsigned int MSVCRT__osplatform = 0;
|
2008-07-21 14:47:55 +02:00
|
|
|
unsigned int MSVCRT__winmajor = 0;
|
|
|
|
unsigned int MSVCRT__winminor = 0;
|
|
|
|
unsigned int MSVCRT__winver = 0;
|
2019-03-29 14:06:05 +01:00
|
|
|
#ifdef _CRTDLL
|
|
|
|
unsigned int CRTDLL__basemajor_dll = 0;
|
|
|
|
unsigned int CRTDLL__baseminor_dll = 0;
|
|
|
|
unsigned int CRTDLL__baseversion_dll = 0;
|
|
|
|
unsigned int CRTDLL__cpumode_dll = 1;
|
|
|
|
unsigned int CRTDLL__osmode_dll = 1;
|
|
|
|
#endif
|
2008-07-21 14:47:55 +02:00
|
|
|
unsigned int MSVCRT___setlc_active = 0;
|
|
|
|
unsigned int MSVCRT___unguarded_readlc_active = 0;
|
|
|
|
double MSVCRT__HUGE = 0;
|
|
|
|
char **MSVCRT___argv = NULL;
|
|
|
|
MSVCRT_wchar_t **MSVCRT___wargv = NULL;
|
2012-12-14 10:33:49 +01:00
|
|
|
static MSVCRT_wchar_t **wargv_expand;
|
2008-07-21 14:47:55 +02:00
|
|
|
char *MSVCRT__acmdln = NULL;
|
|
|
|
MSVCRT_wchar_t *MSVCRT__wcmdln = NULL;
|
|
|
|
char **MSVCRT__environ = NULL;
|
2009-10-05 14:55:09 +02:00
|
|
|
MSVCRT_wchar_t **MSVCRT__wenviron = NULL;
|
2008-07-21 14:47:55 +02:00
|
|
|
char **MSVCRT___initenv = NULL;
|
|
|
|
MSVCRT_wchar_t **MSVCRT___winitenv = NULL;
|
|
|
|
int MSVCRT_app_type = 0;
|
|
|
|
char* MSVCRT__pgmptr = NULL;
|
|
|
|
WCHAR* MSVCRT__wpgmptr = NULL;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2002-07-23 22:59:12 +02:00
|
|
|
/* Get a snapshot of the current environment
|
|
|
|
* and construct the __p__environ array
|
|
|
|
*
|
|
|
|
* The pointer returned from GetEnvironmentStrings may get invalid when
|
|
|
|
* some other module cause a reallocation of the env-variable block
|
|
|
|
*
|
|
|
|
* blk is an array of pointers to environment strings, ending with a NULL
|
|
|
|
* and after that the actual copy of the environment strings, ending in a \0
|
|
|
|
*/
|
|
|
|
char ** msvcrt_SnapshotOfEnvironmentA(char **blk)
|
|
|
|
{
|
|
|
|
char* environ_strings = GetEnvironmentStringsA();
|
|
|
|
int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
|
|
|
|
char *ptr;
|
|
|
|
|
|
|
|
for (ptr = environ_strings; *ptr; ptr += strlen(ptr) + 1)
|
|
|
|
{
|
2018-09-25 09:39:59 +02:00
|
|
|
/* Don't count environment variables starting with '=' which are command shell specific */
|
|
|
|
if (*ptr != '=') count++;
|
2002-07-23 22:59:12 +02:00
|
|
|
len += strlen(ptr) + 1;
|
|
|
|
}
|
|
|
|
if (blk)
|
|
|
|
blk = HeapReAlloc( GetProcessHeap(), 0, blk, count* sizeof(char*) + len );
|
|
|
|
else
|
|
|
|
blk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(char*) + len );
|
|
|
|
|
|
|
|
if (blk)
|
|
|
|
{
|
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
memcpy(&blk[count],environ_strings,len);
|
|
|
|
for (ptr = (char*) &blk[count]; *ptr; ptr += strlen(ptr) + 1)
|
|
|
|
{
|
2018-09-25 09:39:59 +02:00
|
|
|
/* Skip special environment strings set by the command shell */
|
|
|
|
if (*ptr != '=') blk[i++] = ptr;
|
2002-07-23 22:59:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
blk[i] = NULL;
|
|
|
|
}
|
|
|
|
FreeEnvironmentStringsA(environ_strings);
|
|
|
|
return blk;
|
|
|
|
}
|
|
|
|
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk)
|
2002-07-23 22:59:12 +02:00
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t* wenviron_strings = GetEnvironmentStringsW();
|
2002-07-23 22:59:12 +02:00
|
|
|
int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t *wptr;
|
2002-07-23 22:59:12 +02:00
|
|
|
|
2020-07-21 12:21:59 +02:00
|
|
|
for (wptr = wenviron_strings; *wptr; wptr += MSVCRT_wcslen(wptr) + 1)
|
2002-07-23 22:59:12 +02:00
|
|
|
{
|
2018-09-25 09:39:59 +02:00
|
|
|
/* Don't count environment variables starting with '=' which are command shell specific */
|
|
|
|
if (*wptr != '=') count++;
|
2020-07-21 12:21:59 +02:00
|
|
|
len += MSVCRT_wcslen(wptr) + 1;
|
2002-07-23 22:59:12 +02:00
|
|
|
}
|
|
|
|
if (wblk)
|
2002-12-19 05:21:30 +01:00
|
|
|
wblk = HeapReAlloc( GetProcessHeap(), 0, wblk, count* sizeof(MSVCRT_wchar_t*) + len * sizeof(MSVCRT_wchar_t));
|
2002-07-23 22:59:12 +02:00
|
|
|
else
|
2002-12-19 05:21:30 +01:00
|
|
|
wblk = HeapAlloc(GetProcessHeap(), 0, count* sizeof(MSVCRT_wchar_t*) + len * sizeof(MSVCRT_wchar_t));
|
2002-07-23 22:59:12 +02:00
|
|
|
if (wblk)
|
|
|
|
{
|
|
|
|
if (count)
|
|
|
|
{
|
2002-12-19 05:21:30 +01:00
|
|
|
memcpy(&wblk[count],wenviron_strings,len * sizeof(MSVCRT_wchar_t));
|
2020-07-21 12:21:59 +02:00
|
|
|
for (wptr = (MSVCRT_wchar_t*)&wblk[count]; *wptr; wptr += MSVCRT_wcslen(wptr) + 1)
|
2002-07-23 22:59:12 +02:00
|
|
|
{
|
2018-09-25 09:39:59 +02:00
|
|
|
/* Skip special environment strings set by the command shell */
|
|
|
|
if (*wptr != '=') wblk[i++] = wptr;
|
2002-07-23 22:59:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
wblk[i] = NULL;
|
|
|
|
}
|
|
|
|
FreeEnvironmentStringsW(wenviron_strings);
|
|
|
|
return wblk;
|
|
|
|
}
|
2001-05-31 23:33:19 +02:00
|
|
|
|
2019-12-07 14:45:43 +01:00
|
|
|
static char **build_argv( WCHAR **wargv )
|
|
|
|
{
|
|
|
|
int argc;
|
|
|
|
char *p, **argv;
|
|
|
|
DWORD total = 0;
|
|
|
|
|
|
|
|
for (argc = 0; wargv[argc]; argc++)
|
|
|
|
total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL );
|
|
|
|
|
|
|
|
argv = HeapAlloc( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) );
|
|
|
|
p = (char *)(argv + argc + 1);
|
|
|
|
for (argc = 0; wargv[argc]; argc++)
|
|
|
|
{
|
|
|
|
DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL );
|
|
|
|
argv[argc] = p;
|
|
|
|
p += reslen;
|
|
|
|
total -= reslen;
|
|
|
|
}
|
|
|
|
argv[argc] = NULL;
|
|
|
|
return argv;
|
|
|
|
}
|
|
|
|
|
2020-04-08 15:09:26 +02:00
|
|
|
static WCHAR **cmdline_to_argv( const WCHAR *src, int *ret_argc )
|
|
|
|
{
|
|
|
|
WCHAR **argv, *arg, *dst;
|
2020-07-21 12:21:59 +02:00
|
|
|
int argc, in_quotes = 0, bcount = 0, len = MSVCRT_wcslen(src) + 1;
|
2020-04-08 15:09:26 +02:00
|
|
|
|
|
|
|
argc = 2 + len / 2;
|
|
|
|
argv = HeapAlloc( GetProcessHeap(), 0, argc * sizeof(*argv) + len * sizeof(WCHAR) );
|
|
|
|
arg = dst = (WCHAR *)(argv + argc);
|
|
|
|
argc = 0;
|
|
|
|
while (*src)
|
|
|
|
{
|
|
|
|
if ((*src == ' ' || *src == '\t') && !in_quotes)
|
|
|
|
{
|
|
|
|
/* skip the remaining spaces */
|
|
|
|
while (*src == ' ' || *src == '\t') src++;
|
|
|
|
if (!*src) break;
|
|
|
|
/* close the argument and copy it */
|
|
|
|
*dst++ = 0;
|
|
|
|
argv[argc++] = arg;
|
|
|
|
/* start with a new argument */
|
|
|
|
arg = dst;
|
|
|
|
bcount = 0;
|
|
|
|
}
|
|
|
|
else if (*src == '\\')
|
|
|
|
{
|
|
|
|
*dst++ = *src++;
|
|
|
|
bcount++;
|
|
|
|
}
|
|
|
|
else if (*src == '"')
|
|
|
|
{
|
|
|
|
if ((bcount & 1) == 0)
|
|
|
|
{
|
|
|
|
/* Preceded by an even number of '\', this is half that
|
|
|
|
* number of '\', plus a '"' which we discard.
|
|
|
|
*/
|
|
|
|
dst -= bcount / 2;
|
|
|
|
src++;
|
|
|
|
if (in_quotes && *src == '"') *dst++ = *src++;
|
|
|
|
else in_quotes = !in_quotes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Preceded by an odd number of '\', this is half that
|
|
|
|
* number of '\' followed by a '"'
|
|
|
|
*/
|
|
|
|
dst -= bcount / 2 + 1;
|
|
|
|
*dst++ = *src++;
|
|
|
|
}
|
|
|
|
bcount = 0;
|
|
|
|
}
|
|
|
|
else /* a regular character */
|
|
|
|
{
|
|
|
|
*dst++ = *src++;
|
|
|
|
bcount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*dst = 0;
|
|
|
|
argv[argc++] = arg;
|
|
|
|
argv[argc] = NULL;
|
|
|
|
*ret_argc = argc;
|
|
|
|
return argv;
|
|
|
|
}
|
|
|
|
|
2008-07-03 09:08:22 +02:00
|
|
|
typedef void (CDECL *_INITTERMFUN)(void);
|
2010-11-17 23:42:29 +01:00
|
|
|
typedef int (CDECL *_INITTERM_E_FN)(void);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2001-02-12 04:45:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* __p___argc (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int* CDECL MSVCRT___p___argc(void) { return &MSVCRT___argc; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __p__commode (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int* CDECL __p__commode(void) { return &MSVCRT__commode; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
2003-03-15 20:38:39 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __p__pgmptr (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
char** CDECL MSVCRT___p__pgmptr(void) { return &MSVCRT__pgmptr; }
|
2003-03-15 20:38:39 +01:00
|
|
|
|
2003-07-19 00:54:47 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* __p__wpgmptr (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
WCHAR** CDECL MSVCRT___p__wpgmptr(void) { return &MSVCRT__wpgmptr; }
|
2003-07-19 00:54:47 +02:00
|
|
|
|
2011-07-02 06:42:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* _get_pgmptr (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _get_pgmptr(char** p)
|
|
|
|
{
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
|
2011-07-02 06:42:06 +02:00
|
|
|
|
|
|
|
*p = MSVCRT__pgmptr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _get_wpgmptr (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL _get_wpgmptr(WCHAR** p)
|
|
|
|
{
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(p)) return MSVCRT_EINVAL;
|
2011-07-02 06:42:06 +02:00
|
|
|
*p = MSVCRT__wpgmptr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-02-12 04:45:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* __p__fmode (MSVCRT.@)
|
|
|
|
*/
|
2018-12-14 17:47:08 +01:00
|
|
|
int* CDECL MSVCRT___p__fmode(void) { return &MSVCRT__fmode; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
2012-12-21 13:37:47 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* _set_fmode (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int CDECL MSVCRT__set_fmode(int mode)
|
2012-12-21 13:37:47 +01:00
|
|
|
{
|
|
|
|
/* TODO: support _O_WTEXT */
|
|
|
|
if(!MSVCRT_CHECK_PMT(mode==MSVCRT__O_TEXT || mode==MSVCRT__O_BINARY))
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
|
|
|
|
MSVCRT__fmode = mode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* _get_fmode (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
int CDECL MSVCRT__get_fmode(int *mode)
|
2012-12-21 13:37:47 +01:00
|
|
|
{
|
|
|
|
if(!MSVCRT_CHECK_PMT(mode))
|
|
|
|
return MSVCRT_EINVAL;
|
|
|
|
|
|
|
|
*mode = MSVCRT__fmode;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-02-12 04:45:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* __p__osver (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int* CDECL __p__osver(void) { return &MSVCRT__osver; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __p__winmajor (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int* CDECL __p__winmajor(void) { return &MSVCRT__winmajor; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __p__winminor (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int* CDECL __p__winminor(void) { return &MSVCRT__winminor; }
|
2001-02-12 04:45:09 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* __p__winver (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
unsigned int* CDECL __p__winver(void) { return &MSVCRT__winver; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p__acmdln (MSVCRT.@)
|
|
|
|
*/
|
2018-12-14 17:47:08 +01:00
|
|
|
char** CDECL MSVCRT___p__acmdln(void) { return &MSVCRT__acmdln; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p__wcmdln (MSVCRT.@)
|
|
|
|
*/
|
2018-12-14 17:47:08 +01:00
|
|
|
MSVCRT_wchar_t** CDECL MSVCRT___p__wcmdln(void) { return &MSVCRT__wcmdln; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p___argv (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
char*** CDECL MSVCRT___p___argv(void) { return &MSVCRT___argv; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p___wargv (MSVCRT.@)
|
|
|
|
*/
|
2014-04-16 16:15:07 +02:00
|
|
|
MSVCRT_wchar_t*** CDECL MSVCRT___p___wargv(void) { return &MSVCRT___wargv; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p__environ (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
char*** CDECL MSVCRT___p__environ(void)
|
2002-07-23 22:59:12 +02:00
|
|
|
{
|
2008-01-08 05:20:30 +01:00
|
|
|
return &MSVCRT__environ;
|
2002-07-23 22:59:12 +02:00
|
|
|
}
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p__wenviron (MSVCRT.@)
|
|
|
|
*/
|
2011-06-03 15:28:32 +02:00
|
|
|
MSVCRT_wchar_t*** CDECL MSVCRT___p__wenviron(void)
|
2002-07-23 22:59:12 +02:00
|
|
|
{
|
2009-10-05 14:55:09 +02:00
|
|
|
return &MSVCRT__wenviron;
|
2002-07-23 22:59:12 +02:00
|
|
|
}
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p___initenv (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
char*** CDECL __p___initenv(void) { return &MSVCRT___initenv; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* __p___winitenv (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
MSVCRT_wchar_t*** CDECL __p___winitenv(void) { return &MSVCRT___winitenv; }
|
2001-01-22 03:21:54 +01:00
|
|
|
|
2010-05-05 13:36:58 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_osplatform (MSVCRT.@)
|
|
|
|
*/
|
2010-10-29 15:38:51 +02:00
|
|
|
int CDECL MSVCRT__get_osplatform(int *pValue)
|
2010-05-05 13:36:58 +02:00
|
|
|
{
|
2012-07-26 11:05:32 +02:00
|
|
|
if (!MSVCRT_CHECK_PMT(pValue != NULL)) return MSVCRT_EINVAL;
|
2010-10-29 15:38:51 +02:00
|
|
|
*pValue = MSVCRT__osplatform;
|
2010-05-05 13:36:58 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/* INTERNAL: Create a wide string from an ascii string */
|
2008-01-07 14:22:23 +01:00
|
|
|
MSVCRT_wchar_t *msvcrt_wstrdupa(const char *str)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2009-05-27 11:39:05 +02:00
|
|
|
const unsigned int len = strlen(str) + 1 ;
|
2002-12-19 05:21:30 +01:00
|
|
|
MSVCRT_wchar_t *wstr = MSVCRT_malloc(len* sizeof (MSVCRT_wchar_t));
|
2001-01-11 00:59:25 +01:00
|
|
|
if (!wstr)
|
|
|
|
return NULL;
|
2002-12-19 05:21:30 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,str,len,wstr,len);
|
2001-01-11 00:59:25 +01:00
|
|
|
return wstr;
|
|
|
|
}
|
|
|
|
|
2008-07-06 19:48:54 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* ___unguarded_readlc_active_add_func (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
unsigned int * CDECL MSVCRT____unguarded_readlc_active_add_func(void)
|
|
|
|
{
|
|
|
|
return &MSVCRT___unguarded_readlc_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* ___setlc_active_func (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
unsigned int CDECL MSVCRT____setlc_active_func(void)
|
|
|
|
{
|
|
|
|
return MSVCRT___setlc_active;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/* INTERNAL: Since we can't rely on Winelib startup code calling w/getmainargs,
|
2001-05-31 23:33:19 +02:00
|
|
|
* we initialise data values during DLL loading. When called by a native
|
2001-01-11 00:59:25 +01:00
|
|
|
* program we simply return the data we've already initialised. This also means
|
|
|
|
* you can call multiple times without leaking
|
|
|
|
*/
|
2001-04-10 23:16:07 +02:00
|
|
|
void msvcrt_init_args(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2009-04-16 09:10:28 +02:00
|
|
|
OSVERSIONINFOW osvi;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2011-06-03 15:28:32 +02:00
|
|
|
MSVCRT__acmdln = MSVCRT__strdup( GetCommandLineA() );
|
2019-12-07 14:45:43 +01:00
|
|
|
MSVCRT__wcmdln = MSVCRT__wcsdup( GetCommandLineW() );
|
2020-04-08 15:09:26 +02:00
|
|
|
initial_wargv = cmdline_to_argv( GetCommandLineW(), &initial_argc );
|
|
|
|
MSVCRT___argc = initial_argc;
|
|
|
|
MSVCRT___wargv = initial_wargv;
|
|
|
|
MSVCRT___argv = build_argv( initial_wargv );
|
2001-02-20 01:51:49 +01:00
|
|
|
|
2004-12-14 16:13:05 +01:00
|
|
|
TRACE("got %s, wide = %s argc=%d\n", debugstr_a(MSVCRT__acmdln),
|
2001-09-07 21:47:30 +02:00
|
|
|
debugstr_w(MSVCRT__wcmdln),MSVCRT___argc);
|
2001-01-11 00:59:25 +01:00
|
|
|
|
2009-04-16 09:10:28 +02:00
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
|
|
|
GetVersionExW( &osvi );
|
|
|
|
MSVCRT__winver = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
|
|
|
|
MSVCRT__winmajor = osvi.dwMajorVersion;
|
|
|
|
MSVCRT__winminor = osvi.dwMinorVersion;
|
|
|
|
MSVCRT__osver = osvi.dwBuildNumber;
|
2010-05-05 13:36:58 +02:00
|
|
|
MSVCRT__osplatform = osvi.dwPlatformId;
|
2017-12-28 11:11:20 +01:00
|
|
|
TRACE( "winver %08x winmajor %08x winminor %08x osver %08x\n",
|
|
|
|
MSVCRT__winver, MSVCRT__winmajor, MSVCRT__winminor, MSVCRT__osver);
|
2019-03-29 14:06:05 +01:00
|
|
|
#ifdef _CRTDLL
|
|
|
|
CRTDLL__baseversion_dll = (GetVersion() >> 16);
|
|
|
|
CRTDLL__basemajor_dll = CRTDLL__baseversion_dll >> 8;
|
|
|
|
CRTDLL__baseminor_dll = CRTDLL__baseversion_dll & 0xff;
|
|
|
|
#endif
|
2009-04-16 09:10:28 +02:00
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
MSVCRT__HUGE = HUGE_VAL;
|
|
|
|
MSVCRT___setlc_active = 0;
|
|
|
|
MSVCRT___unguarded_readlc_active = 0;
|
2004-06-25 03:19:15 +02:00
|
|
|
MSVCRT__fmode = MSVCRT__O_TEXT;
|
2010-09-30 08:24:13 +02:00
|
|
|
|
|
|
|
MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL);
|
|
|
|
MSVCRT___initenv = msvcrt_SnapshotOfEnvironmentA(NULL);
|
|
|
|
MSVCRT___winitenv = msvcrt_SnapshotOfEnvironmentW(NULL);
|
2001-05-22 21:17:26 +02:00
|
|
|
|
2003-07-19 00:54:47 +02:00
|
|
|
MSVCRT__pgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
|
|
|
|
if (MSVCRT__pgmptr)
|
2004-05-19 05:22:55 +02:00
|
|
|
{
|
|
|
|
if (!GetModuleFileNameA(0, MSVCRT__pgmptr, MAX_PATH))
|
|
|
|
MSVCRT__pgmptr[0] = '\0';
|
|
|
|
else
|
|
|
|
MSVCRT__pgmptr[MAX_PATH - 1] = '\0';
|
|
|
|
}
|
2003-07-19 00:54:47 +02:00
|
|
|
|
|
|
|
MSVCRT__wpgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
|
|
|
|
if (MSVCRT__wpgmptr)
|
2004-05-19 05:22:55 +02:00
|
|
|
{
|
|
|
|
if (!GetModuleFileNameW(0, MSVCRT__wpgmptr, MAX_PATH))
|
|
|
|
MSVCRT__wpgmptr[0] = '\0';
|
|
|
|
else
|
|
|
|
MSVCRT__wpgmptr[MAX_PATH - 1] = '\0';
|
|
|
|
}
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* INTERNAL: free memory used by args */
|
2001-04-10 23:16:07 +02:00
|
|
|
void msvcrt_free_args(void)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-05-31 23:33:19 +02:00
|
|
|
/* FIXME: more things to free */
|
2019-12-07 14:45:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT___argv);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT___initenv);
|
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT___winitenv);
|
2008-01-08 05:20:30 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT__environ);
|
2009-10-05 14:55:09 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT__wenviron);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT__pgmptr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, MSVCRT__wpgmptr);
|
2012-12-14 10:33:49 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, wargv_expand);
|
2012-12-13 13:45:24 +01:00
|
|
|
}
|
|
|
|
|
2012-12-14 10:33:49 +01:00
|
|
|
static int build_expanded_wargv(int *argc, MSVCRT_wchar_t **argv)
|
|
|
|
{
|
|
|
|
int i, size=0, args_no=0, path_len;
|
|
|
|
BOOL is_expandable;
|
|
|
|
HANDLE h;
|
|
|
|
|
|
|
|
args_no = 0;
|
2020-04-08 15:09:26 +02:00
|
|
|
for(i=0; i < initial_argc; i++) {
|
2012-12-14 10:33:49 +01:00
|
|
|
WIN32_FIND_DATAW data;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
is_expandable = FALSE;
|
2020-07-21 12:21:59 +02:00
|
|
|
for(path_len = MSVCRT_wcslen(initial_wargv[i])-1; path_len>=0; path_len--) {
|
2020-04-08 15:09:26 +02:00
|
|
|
if(initial_wargv[i][path_len]=='*' || initial_wargv[i][path_len]=='?')
|
2012-12-14 10:33:49 +01:00
|
|
|
is_expandable = TRUE;
|
2020-04-08 15:09:26 +02:00
|
|
|
else if(initial_wargv[i][path_len]=='\\' || initial_wargv[i][path_len]=='/')
|
2012-12-14 10:33:49 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
path_len++;
|
|
|
|
|
|
|
|
if(is_expandable)
|
2020-04-08 15:09:26 +02:00
|
|
|
h = FindFirstFileW(initial_wargv[i], &data);
|
2012-12-14 10:33:49 +01:00
|
|
|
else
|
|
|
|
h = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
if(h != INVALID_HANDLE_VALUE) {
|
|
|
|
do {
|
|
|
|
if(data.cFileName[0]=='.' && (data.cFileName[1]=='\0' ||
|
|
|
|
(data.cFileName[1]=='.' && data.cFileName[2]=='\0')))
|
|
|
|
continue;
|
|
|
|
|
2020-07-21 12:21:59 +02:00
|
|
|
len = MSVCRT_wcslen(data.cFileName)+1;
|
2012-12-14 10:33:49 +01:00
|
|
|
if(argv) {
|
2012-12-26 13:28:14 +01:00
|
|
|
argv[args_no] = (MSVCRT_wchar_t*)(argv+*argc+1)+size;
|
2020-04-08 15:09:26 +02:00
|
|
|
memcpy(argv[args_no], initial_wargv[i], path_len*sizeof(MSVCRT_wchar_t));
|
2012-12-14 10:33:49 +01:00
|
|
|
memcpy(argv[args_no]+path_len, data.cFileName, len*sizeof(MSVCRT_wchar_t));
|
|
|
|
}
|
|
|
|
args_no++;
|
|
|
|
size += len+path_len;
|
|
|
|
}while(FindNextFileW(h, &data));
|
2013-03-01 14:31:41 +01:00
|
|
|
FindClose(h);
|
2012-12-14 10:33:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!len) {
|
2020-07-21 12:21:59 +02:00
|
|
|
len = MSVCRT_wcslen(initial_wargv[i])+1;
|
2012-12-14 10:33:49 +01:00
|
|
|
if(argv) {
|
2012-12-26 13:28:14 +01:00
|
|
|
argv[args_no] = (MSVCRT_wchar_t*)(argv+*argc+1)+size;
|
2020-04-08 15:09:26 +02:00
|
|
|
memcpy(argv[args_no], initial_wargv[i], len*sizeof(MSVCRT_wchar_t));
|
2012-12-14 10:33:49 +01:00
|
|
|
}
|
|
|
|
args_no++;
|
|
|
|
size += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-26 13:28:14 +01:00
|
|
|
if(argv)
|
|
|
|
argv[args_no] = NULL;
|
2012-12-14 10:33:49 +01:00
|
|
|
size *= sizeof(MSVCRT_wchar_t);
|
2012-12-26 13:28:14 +01:00
|
|
|
size += (args_no+1)*sizeof(MSVCRT_wchar_t*);
|
2012-12-14 10:33:49 +01:00
|
|
|
*argc = args_no;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __wgetmainargs (MSVCRT.@)
|
|
|
|
*/
|
2019-02-15 12:25:14 +01:00
|
|
|
int CDECL __wgetmainargs(int *argc, MSVCRT_wchar_t** *wargv, MSVCRT_wchar_t** *wenvp,
|
2006-06-13 11:21:19 +02:00
|
|
|
int expand_wildcards, int *new_mode)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2012-12-14 10:33:49 +01:00
|
|
|
TRACE("(%p,%p,%p,%d,%p).\n", argc, wargv, wenvp, expand_wildcards, new_mode);
|
|
|
|
|
|
|
|
if (expand_wildcards) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, wargv_expand);
|
|
|
|
wargv_expand = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
build_expanded_wargv(&wargc_expand, NULL));
|
|
|
|
if (wargv_expand) {
|
|
|
|
build_expanded_wargv(&wargc_expand, wargv_expand);
|
|
|
|
|
|
|
|
MSVCRT___argc = wargc_expand;
|
|
|
|
MSVCRT___wargv = wargv_expand;
|
|
|
|
}else {
|
|
|
|
expand_wildcards = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!expand_wildcards) {
|
2020-04-08 15:09:26 +02:00
|
|
|
MSVCRT___argc = initial_argc;
|
|
|
|
MSVCRT___wargv = initial_wargv;
|
2012-12-14 10:33:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the _wenviron array if it's not already created. */
|
|
|
|
if (!MSVCRT__wenviron)
|
|
|
|
MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(NULL);
|
|
|
|
*argc = MSVCRT___argc;
|
|
|
|
*wargv = MSVCRT___wargv;
|
|
|
|
*wenvp = MSVCRT___winitenv;
|
|
|
|
if (new_mode)
|
|
|
|
MSVCRT__set_new_mode( *new_mode );
|
2019-02-15 12:25:14 +01:00
|
|
|
return 0;
|
2001-01-11 00:59:25 +01:00
|
|
|
}
|
|
|
|
|
2019-12-07 14:45:43 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __getmainargs (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL __getmainargs(int *argc, char** *argv, char** *envp,
|
|
|
|
int expand_wildcards, int *new_mode)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, envp, expand_wildcards, new_mode);
|
|
|
|
|
|
|
|
if (expand_wildcards) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, wargv_expand);
|
|
|
|
wargv_expand = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
build_expanded_wargv(&wargc_expand, NULL));
|
|
|
|
if (wargv_expand) {
|
|
|
|
build_expanded_wargv(&wargc_expand, wargv_expand);
|
|
|
|
|
|
|
|
MSVCRT___argc = wargc_expand;
|
|
|
|
MSVCRT___argv = build_argv( wargv_expand );
|
|
|
|
}else {
|
|
|
|
expand_wildcards = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!expand_wildcards) {
|
2020-04-08 15:09:26 +02:00
|
|
|
MSVCRT___argc = initial_argc;
|
|
|
|
MSVCRT___argv = build_argv( initial_wargv );
|
2019-12-07 14:45:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*argc = MSVCRT___argc;
|
|
|
|
*argv = MSVCRT___argv;
|
|
|
|
*envp = MSVCRT___initenv;
|
|
|
|
|
|
|
|
if (new_mode)
|
|
|
|
MSVCRT__set_new_mode( *new_mode );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _CRTDLL
|
|
|
|
/*********************************************************************
|
|
|
|
* __GetMainArgs (CRTDLL.@)
|
|
|
|
*/
|
|
|
|
void CDECL __GetMainArgs( int *argc, char ***argv, char ***envp, int expand_wildcards )
|
|
|
|
{
|
|
|
|
int new_mode = 0;
|
|
|
|
__getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _initterm (MSVCRT.@)
|
|
|
|
*/
|
2007-03-14 12:26:43 +01:00
|
|
|
void CDECL _initterm(_INITTERMFUN *start,_INITTERMFUN *end)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
2001-04-10 23:16:07 +02:00
|
|
|
_INITTERMFUN* current = start;
|
2001-01-11 00:59:25 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n",start,end);
|
|
|
|
while (current<end)
|
|
|
|
{
|
|
|
|
if (*current)
|
|
|
|
{
|
|
|
|
TRACE("Call init function %p\n",*current);
|
|
|
|
(**current)();
|
|
|
|
TRACE("returned\n");
|
|
|
|
}
|
|
|
|
current++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-17 23:42:29 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _initterm_e (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* call an array of application initialization functions and report the return value
|
|
|
|
*/
|
|
|
|
int CDECL _initterm_e(_INITTERM_E_FN *table, _INITTERM_E_FN *end)
|
|
|
|
{
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", table, end);
|
|
|
|
|
|
|
|
while (!res && table < end) {
|
|
|
|
if (*table) {
|
|
|
|
TRACE("calling %p\n", **table);
|
|
|
|
res = (**table)();
|
|
|
|
if (res)
|
|
|
|
TRACE("function %p failed: 0x%x\n", *table, res);
|
|
|
|
|
|
|
|
}
|
|
|
|
table++;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2001-01-11 00:59:25 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* __set_app_type (MSVCRT.@)
|
|
|
|
*/
|
2006-06-13 11:21:19 +02:00
|
|
|
void CDECL MSVCRT___set_app_type(int app_type)
|
2001-01-11 00:59:25 +01:00
|
|
|
{
|
|
|
|
TRACE("(%d) %s application\n", app_type, app_type == 2 ? "Gui" : "Console");
|
|
|
|
MSVCRT_app_type = app_type;
|
|
|
|
}
|
2015-08-27 22:27:24 +02:00
|
|
|
|
2018-01-03 09:11:44 +01:00
|
|
|
#if _MSVCR_VER>=140
|
|
|
|
|
2015-08-27 22:27:24 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_initial_narrow_environment (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
char** CDECL _get_initial_narrow_environment(void)
|
|
|
|
{
|
2016-04-05 05:24:21 +02:00
|
|
|
return MSVCRT___initenv;
|
2015-08-27 22:27:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _configure_narrow_argv (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
int CDECL _configure_narrow_argv(int mode)
|
|
|
|
{
|
|
|
|
TRACE("(%d)\n", mode);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _initialize_narrow_environment (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
int CDECL _initialize_narrow_environment(void)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-31 23:27:27 +02:00
|
|
|
|
2016-04-04 23:55:43 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_initial_wide_environment (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_wchar_t** CDECL _get_initial_wide_environment(void)
|
|
|
|
{
|
|
|
|
return MSVCRT___winitenv;
|
|
|
|
}
|
|
|
|
|
2016-03-31 23:27:27 +02:00
|
|
|
/*********************************************************************
|
|
|
|
* _configure_wide_argv (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
int CDECL _configure_wide_argv(int mode)
|
|
|
|
{
|
2020-02-28 14:39:57 +01:00
|
|
|
WARN("(%d) stub\n", mode);
|
2016-03-31 23:27:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _initialize_wide_environment (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
int CDECL _initialize_wide_environment(void)
|
|
|
|
{
|
2020-02-28 14:39:57 +01:00
|
|
|
WARN("stub\n");
|
2016-03-31 23:27:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2016-07-28 12:24:24 +02:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _get_narrow_winmain_command_line (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
char* CDECL _get_narrow_winmain_command_line(void)
|
|
|
|
{
|
|
|
|
static char *narrow_command_line;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
if (narrow_command_line)
|
|
|
|
return narrow_command_line;
|
|
|
|
|
|
|
|
s = GetCommandLineA();
|
|
|
|
while (*s && *s != ' ' && *s != '\t')
|
|
|
|
{
|
|
|
|
if (*s++ == '"')
|
|
|
|
{
|
|
|
|
while (*s && *s++ != '"')
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*s == ' ' || *s == '\t')
|
|
|
|
s++;
|
|
|
|
|
|
|
|
return narrow_command_line = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _get_wide_winmain_command_line (UCRTBASE.@)
|
|
|
|
*/
|
|
|
|
MSVCRT_wchar_t* CDECL _get_wide_winmain_command_line(void)
|
|
|
|
{
|
|
|
|
static MSVCRT_wchar_t *wide_command_line;
|
|
|
|
MSVCRT_wchar_t *s;
|
|
|
|
|
|
|
|
if (wide_command_line)
|
|
|
|
return wide_command_line;
|
|
|
|
|
|
|
|
s = GetCommandLineW();
|
|
|
|
while (*s && *s != ' ' && *s != '\t')
|
|
|
|
{
|
|
|
|
if (*s++ == '"')
|
|
|
|
{
|
|
|
|
while (*s && *s++ != '"')
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*s == ' ' || *s == '\t')
|
|
|
|
s++;
|
|
|
|
|
|
|
|
return wide_command_line = s;
|
|
|
|
}
|
2017-12-27 00:52:27 +01:00
|
|
|
|
2018-01-03 09:11:44 +01:00
|
|
|
#endif /* _MSVCR_VER>=140 */
|
|
|
|
|
2017-12-27 00:52:27 +01:00
|
|
|
/*********************************************************************
|
|
|
|
* _get_winmajor (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__get_winmajor(int* value)
|
|
|
|
{
|
|
|
|
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
|
|
|
|
*value = MSVCRT__winmajor;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _get_winminor (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__get_winminor(int* value)
|
|
|
|
{
|
|
|
|
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
|
|
|
|
*value = MSVCRT__winminor;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
* _get_osver (MSVCRT.@)
|
|
|
|
*/
|
|
|
|
int CDECL MSVCRT__get_osver(int* value)
|
|
|
|
{
|
|
|
|
if (!MSVCRT_CHECK_PMT(value != NULL)) return MSVCRT_EINVAL;
|
|
|
|
*value = MSVCRT__osver;
|
|
|
|
return 0;
|
|
|
|
}
|