Signed-off-by: Martin Storsjo martin@martin.st --- dlls/msvcrt/environ.c | 16 ++++++++++++++++ dlls/msvcrt/msvcrt.spec | 4 ++-- dlls/msvcrt/tests/environ.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/environ.c b/dlls/msvcrt/environ.c index cce62bc6a5..cc180e819e 100644 --- a/dlls/msvcrt/environ.c +++ b/dlls/msvcrt/environ.c @@ -310,3 +310,19 @@ int CDECL _wgetenv_s(MSVCRT_size_t *pReturnValue, MSVCRT_wchar_t *buffer, MSVCRT strcpyW(buffer, e); return 0; } + +/********************************************************************* + * _get_environ (MSVCRT.@) + */ +void CDECL MSVCRT__get_environ(char ***ptr) +{ + *ptr = MSVCRT__environ; +} + +/********************************************************************* + * _get_wenviron (MSVCRT.@) + */ +void CDECL MSVCRT__get_wenviron(MSVCRT_wchar_t ***ptr) +{ + *ptr = MSVCRT__wenviron; +} diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 0c2881d87b..5be4b4c16a 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -501,7 +501,7 @@ @ cdecl _gcvt_s(ptr long double long) MSVCRT__gcvt_s @ cdecl _get_current_locale() MSVCRT__get_current_locale @ cdecl _get_doserrno(ptr) -# stub _get_environ(ptr) +@ cdecl _get_environ(ptr) MSVCRT__get_environ @ cdecl _get_errno(ptr) # stub _get_fileinfo(ptr) @ cdecl _get_fmode(ptr) MSVCRT__get_fmode @@ -512,7 +512,7 @@ @ cdecl _get_output_format() MSVCRT__get_output_format @ cdecl _get_pgmptr(ptr) @ cdecl _get_sbh_threshold() -# stub _get_wenviron(ptr) +@ cdecl _get_wenviron(ptr) MSVCRT__get_wenviron @ cdecl _get_winmajor(ptr) MSVCRT__get_winmajor @ cdecl _get_winminor(ptr) MSVCRT__get_winminor # stub _get_winver(ptr) diff --git a/dlls/msvcrt/tests/environ.c b/dlls/msvcrt/tests/environ.c index fdfe81f5ee..11b79f0d7c 100644 --- a/dlls/msvcrt/tests/environ.c +++ b/dlls/msvcrt/tests/environ.c @@ -47,6 +47,8 @@ void __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
static char ***(__cdecl *p__p__environ)(void); static WCHAR ***(__cdecl *p__p__wenviron)(void); +static void (*p_get_environ)(char ***); +static void (*p_get_wenviron)(WCHAR ***);
static char ***p_environ; static WCHAR ***p_wenviron; @@ -59,6 +61,8 @@ static void init(void) p__p__wenviron = (void *)GetProcAddress(hmod, "__p__wenviron"); p_environ = (void *)GetProcAddress(hmod, "_environ"); p_wenviron = (void *)GetProcAddress(hmod, "_wenviron"); + p_get_environ = (void *)GetProcAddress(hmod, "_get_environ"); + p_get_wenviron = (void *)GetProcAddress(hmod, "_get_wenviron"); }
static void test_system(void) @@ -95,6 +99,16 @@ static void test__environ(void) else win_skip( "__p__environ() is not available\n" );
+ if (p_get_environ) + { + char **retptr; + p_get_environ(&retptr); + ok( retptr == *p_environ, + "Expected _environ pointers to be identical\n" ); + } + else + win_skip( "_get_environ() is not available\n" ); + /* Note that msvcrt from Windows versions older than Vista * expects the mode pointer parameter to be valid.*/ __getmainargs(&argc, &argv, &envp, 0, &mode); @@ -151,6 +165,16 @@ static void test__wenviron(void) else win_skip( "__p__wenviron() is not available\n" );
+ if (p_get_wenviron) + { + WCHAR **retptr; + p_get_wenviron(&retptr); + ok( retptr == NULL, + "Expected _wenviron pointers to be NULL\n" ); + } + else + win_skip( "_get_wenviron() is not available\n" ); + /* __getmainargs doesn't initialize _wenviron. */ __getmainargs(&argc, &argv, &envp, 0, &mode);
@@ -191,6 +215,14 @@ static void test__wenviron(void) "Expected _wenviron pointers to be identical\n" ); }
+ if (p_get_wenviron) + { + WCHAR **retptr; + p_get_wenviron(&retptr); + ok( retptr == *p_wenviron, + "Expected _wenviron pointers to be identical\n" ); + } + for (i = 0; ; i++) { if ((*p_wenviron)[i])