ReactOS 0.4.16-dev-2298-gcac013a
dllmain.c File Reference
#include <sys/stat.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <mbstring.h>
#include <windef.h>
Include dependency graph for dllmain.c:

Go to the source code of this file.

Classes

struct  crtdll_stat
 

Typedefs

typedef short crtdll_dev_t
 

Functions

void __getmainargs (int *argc, char ***argv, char ***envp, int expand_wildcards, int *new_mode)
 
static void convert_struct_stat (struct crtdll_stat *dst, const struct _stat *src)
 
void __GetMainArgs (int *argc, char ***argv, char ***envp, int expand_wildcards)
 
int CRTDLL__fstat (int fd, struct crtdll_stat *buf)
 
int CRTDLL__stat (const char *path, struct crtdll_stat *buf)
 
char_strdec (const char *str1, const char *str2)
 
char_strinc (const char *str)
 
size_t _strncnt (const char *str, size_t maxlen)
 
unsigned int _strnextc (const char *str)
 
char_strninc (const char *str, size_t len)
 
char_strspnp (const char *str1, const char *str2)
 
unsigned charCRTDLL__mbsstr (const unsigned char *Str, const unsigned char *Substr)
 
int CRTDLL_sprintf (char *buffer, const char *format,...)
 
unsigned long CRTDLL_strtoul (const char *nptr, char **endptr, int base)
 
unsigned long CRTDLL_wcstoul (const wchar_t *nptr, wchar_t **endptr, int base)
 
int CRTDLL_system (const char *command)
 
unsigned charCRTDLL__mbsnbcat (unsigned char *dest, const unsigned char *src, size_t n)
 
unsigned charCRTDLL__mbsncat (unsigned char *dest, const unsigned char *src, size_t n)
 
int CRTDLL__vsnprintf (char *buffer, size_t count, const char *format, va_list argptr)
 
int CRTDLL__snprintf (char *buffer, size_t count, const char *format,...)
 
int CRTDLL__vsnwprintf (wchar_t *buffer, size_t count, const wchar_t *format, va_list argptr)
 
BOOLEAN WINAPI SystemFunction036 (PVOID pbBuffer, ULONG dwLen)
 

Variables

unsigned int CRTDLL__basemajor_dll = 0
 
unsigned int CRTDLL__baseminor_dll = 0
 
unsigned int CRTDLL__baseversion_dll = 0
 
unsigned int CRTDLL__cpumode_dll = 0
 
unsigned int CRTDLL__osmajor_dll = 0
 
unsigned int CRTDLL__osminor_dll = 0
 
unsigned int CRTDLL__osmode_dll = 0
 
unsigned int CRTDLL__osversion_dll = 0
 
int _fileinfo_dll
 
char ** _environ
 
char ** __initenv
 
wchar_t ** _wenviron
 
wchar_t ** __winitenv
 

Typedef Documentation

◆ crtdll_dev_t

Definition at line 48 of file dllmain.c.

Function Documentation

◆ __GetMainArgs()

void __GetMainArgs ( int argc,
char ***  argv,
char ***  envp,
int  expand_wildcards 
)

Definition at line 85 of file dllmain.c.

86{
87 int new_mode = 0;
88 __getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
89}
static int argc
Definition: ServiceArgs.c:12
void __getmainargs(int *argc, char ***argv, char ***envp, int expand_wildcards, int *new_mode)
Definition: data.c:579
#define argv
Definition: mplay32.c:18

◆ __getmainargs()

void __getmainargs ( int argc,
char ***  argv,
char ***  envp,
int  expand_wildcards,
int new_mode 
)

Definition at line 579 of file data.c.

581{
582 TRACE("(%p,%p,%p,%d,%p).\n", argc, argv, envp, expand_wildcards, new_mode);
583
584 if (expand_wildcards) {
588 if (wargv_expand) {
590
593 }else {
594 expand_wildcards = 0;
595 }
596 }
597 if (!expand_wildcards) {
598#ifdef __REACTOS__
599 if ((MSVCRT___argv == NULL) || (MSVCRT___argc == 0))
600 {
601 MSVCRT___argv = cmdline_to_argvA(MSVCRT__acmdln, &MSVCRT___argc);
602 }
603#else
606#endif
607 }
608
611 *envp = MSVCRT__environ;
612
613 if (new_mode)
614 _set_new_mode( *new_mode );
615 return 0;
616}
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static char ** build_argv(WCHAR **wargv)
Definition: data.c:63
static int initial_argc
Definition: data.c:30
static int build_expanded_wargv(int *argc, wchar_t **argv)
Definition: data.c:471
static int wargc_expand
Definition: data.c:32
char ** MSVCRT___argv
Definition: data.c:50
static WCHAR ** initial_wargv
Definition: data.c:29
int MSVCRT___argc
Definition: data.c:31
char ** MSVCRT__environ
Definition: data.c:55
char * MSVCRT__acmdln
Definition: data.c:53
static wchar_t ** wargv_expand
Definition: data.c:52
int CDECL _set_new_mode(int mode)
Definition: heap.c:227
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by __GetMainArgs(), mainCRTStartup(), test__environ(), and test__wenviron().

◆ _strdec()

char * _strdec ( const char str1,
const char str2 
)

Definition at line 123 of file dllmain.c.

124{
125 return (char *)(str2 - 1);
126}
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35

◆ _strinc()

char * _strinc ( const char str)

Definition at line 132 of file dllmain.c.

133{
134 return (char *)(str + 1);
135}
const WCHAR * str

◆ _strncnt()

size_t _strncnt ( const char str,
size_t  maxlen 
)

Definition at line 141 of file dllmain.c.

142{
143 size_t len = strlen(str);
144 return (len > maxlen) ? maxlen : len;
145}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
GLenum GLsizei len
Definition: glext.h:6722

◆ _strnextc()

unsigned int _strnextc ( const char str)

Definition at line 151 of file dllmain.c.

152{
153 return (unsigned int)str[0];
154}

◆ _strninc()

char * _strninc ( const char str,
size_t  len 
)

Definition at line 160 of file dllmain.c.

161{
162 return (char *)(str + len);
163}

◆ _strspnp()

char * _strspnp ( const char str1,
const char str2 
)

Definition at line 169 of file dllmain.c.

170{
171 str1 += strspn( str1, str2 );
172 return *str1 ? (char*)str1 : NULL;
173}
_ACRTIMP size_t __cdecl strspn(const char *, const char *)
Definition: string.c:3515
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35

◆ convert_struct_stat()

static void convert_struct_stat ( struct crtdll_stat dst,
const struct _stat src 
)
static

Definition at line 66 of file dllmain.c.

67{
68 dst->st_dev = src->st_dev;
69 dst->st_ino = src->st_ino;
70 dst->st_mode = src->st_mode;
71 dst->st_nlink = src->st_nlink;
72 dst->st_uid = src->st_uid;
73 dst->st_gid = src->st_gid;
74 dst->st_rdev = src->st_rdev;
75 dst->st_size = src->st_size;
76 dst->st_atime = src->st_atime;
77 dst->st_mtime = src->st_mtime;
78 dst->st_ctime = src->st_ctime;
79}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by CRTDLL__fstat(), and CRTDLL__stat().

◆ CRTDLL__fstat()

int CRTDLL__fstat ( int  fd,
struct crtdll_stat buf 
)

Definition at line 95 of file dllmain.c.

96{
97 extern int _fstat(int,struct _stat*);
98 struct _stat st;
99 int ret;
100
101 if (!(ret = _fstat( fd, &st ))) convert_struct_stat( buf, &st );
102 return ret;
103}
static void convert_struct_stat(struct crtdll_stat *dst, const struct _stat *src)
Definition: dllmain.c:66
return ret
Definition: mutex.c:146
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _fstat
Definition: stat.h:144
static int fd
Definition: io.c:51
Definition: stat.h:52

◆ CRTDLL__mbsnbcat()

unsigned char * CRTDLL__mbsnbcat ( unsigned char dest,
const unsigned char src,
size_t  n 
)

Definition at line 238 of file dllmain.c.

239{
240 if (n)
241 {
242 /* Access both buffers to emulate CRTDLL exception behavior */
243 (void)*(volatile char*)dest;
244 (void)*(volatile char*)src;
245 }
246
247 return _mbsnbcat(dest, src, n);
248}
#define _mbsnbcat
GLdouble n
Definition: glext.h:7729
static char * dest
Definition: rtl.c:135

◆ CRTDLL__mbsncat()

unsigned char * CRTDLL__mbsncat ( unsigned char dest,
const unsigned char src,
size_t  n 
)

Definition at line 253 of file dllmain.c.

254{
255 if (n)
256 {
257 /* Access both buffers to emulate CRTDLL exception behavior */
258 (void)*(volatile char*)dest;
259 (void)*(volatile char*)src;
260 }
261
262 return _mbsncat(dest, src, n);
263}
#define _mbsncat

◆ CRTDLL__mbsstr()

unsigned char * CRTDLL__mbsstr ( const unsigned char Str,
const unsigned char Substr 
)

Definition at line 178 of file dllmain.c.

179{
180 if (!*Str && !*Substr)
181 return NULL;
182 return (unsigned char*)strstr((const char*)Str, (const char*)Substr);
183}
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415

◆ CRTDLL__snprintf()

int CRTDLL__snprintf ( char buffer,
size_t  count,
const char format,
  ... 
)

Definition at line 285 of file dllmain.c.

286{
288 int ret;
291 va_end(args);
292 return ret;
293}
int CRTDLL__vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
Definition: dllmain.c:268
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
#define args
Definition: format.c:66
Definition: match.c:390
Definition: format.c:58

◆ CRTDLL__stat()

int CRTDLL__stat ( const char path,
struct crtdll_stat buf 
)

Definition at line 109 of file dllmain.c.

110{
111 extern int _stat(const char*,struct _stat*);
112 struct _stat st;
113 int ret;
114
115 if (!(ret = _stat( path, &st ))) convert_struct_stat( buf, &st );
116 return ret;
117}
#define _stat
Definition: stat.h:146

◆ CRTDLL__vsnprintf()

int CRTDLL__vsnprintf ( char buffer,
size_t  count,
const char format,
va_list  argptr 
)

Definition at line 268 of file dllmain.c.

269{
270 (void)*(volatile char*)format;
271 if (count)
272 {
273 (void)*(volatile char*)buffer;
274 }
275 int ret = _vsnprintf(buffer, count, format, argptr);
276 if (ret > (int)count)
277 ret = -1;
278 errno = 0;;
279 return ret;
280}
#define errno
Definition: errno.h:120
#define _vsnprintf
Definition: xmlstorage.h:202

Referenced by CRTDLL__snprintf().

◆ CRTDLL__vsnwprintf()

int CRTDLL__vsnwprintf ( wchar_t buffer,
size_t  count,
const wchar_t format,
va_list  argptr 
)

Definition at line 298 of file dllmain.c.

299{
300 (void)*(volatile wchar_t*)format;
301 int ret = _vsnwprintf(buffer, count, format, argptr);
302 if ((ret > (int)count) || !buffer)
303 ret = -1;
304 errno = 0;;
305 return ret;
306}
#define _vsnwprintf
Definition: _vsnwprintf.c:28

◆ CRTDLL_sprintf()

int CRTDLL_sprintf ( char buffer,
const char format,
  ... 
)

Definition at line 188 of file dllmain.c.

189{
191 int ret;
192
193 /* Access both buffers to emulate CRTDLL exception behavior */
194 (void)*(volatile char*)buffer;
195 (void)*(volatile char*)format;
196
199 va_end(args);
200 return ret;
201}
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl vsprintf(char *, const char *, va_list) __WINE_CRT_PRINTF_ATTR(2

◆ CRTDLL_strtoul()

unsigned long CRTDLL_strtoul ( const char nptr,
char **  endptr,
int  base 
)

Definition at line 206 of file dllmain.c.

207{
208 /* Access nptr to emulate CRTDLL exception behavior */
209 (void)*(volatile char*)nptr;
210 return strtoul(nptr, endptr, base);
211}
_ACRTIMP __msvcrt_ulong __cdecl strtoul(const char *, char **, int)
Definition: string.c:1859

◆ CRTDLL_system()

int CRTDLL_system ( const char command)

Definition at line 226 of file dllmain.c.

227{
228 if (command != NULL)
229 {
230 errno = 0;
231 }
232 return system(command);
233}
_ACRTIMP int __cdecl system(const char *)
Definition: process.c:1297

◆ CRTDLL_wcstoul()

unsigned long CRTDLL_wcstoul ( const wchar_t nptr,
wchar_t **  endptr,
int  base 
)

Definition at line 216 of file dllmain.c.

217{
218 /* Access nptr to emulate CRTDLL exception behavior */
219 (void)*(volatile wchar_t*)nptr;
220 return wcstoul(nptr, endptr, base);
221}
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2912

◆ SystemFunction036()

BOOLEAN WINAPI SystemFunction036 ( PVOID  pbBuffer,
ULONG  dwLen 
)

Definition at line 312 of file dllmain.c.

313{
314 assert(FALSE);
315 return 0;
316}
#define FALSE
Definition: types.h:117
#define assert(_expr)
Definition: assert.h:32

Referenced by gen_rand_impl().

Variable Documentation

◆ __initenv

char** __initenv
extern

Referenced by Test___initenv().

◆ __winitenv

wchar_t** __winitenv
extern

Referenced by Test___winitenv().

◆ _environ

char** _environ
extern

◆ _fileinfo_dll

int _fileinfo_dll

Definition at line 39 of file dllmain.c.

◆ _wenviron

wchar_t** _wenviron
extern

◆ CRTDLL__basemajor_dll

unsigned int CRTDLL__basemajor_dll = 0

Definition at line 31 of file dllmain.c.

Referenced by msvcrt_init_args().

◆ CRTDLL__baseminor_dll

unsigned int CRTDLL__baseminor_dll = 0

Definition at line 32 of file dllmain.c.

Referenced by msvcrt_init_args().

◆ CRTDLL__baseversion_dll

unsigned int CRTDLL__baseversion_dll = 0

Definition at line 33 of file dllmain.c.

Referenced by msvcrt_init_args().

◆ CRTDLL__cpumode_dll

unsigned int CRTDLL__cpumode_dll = 0

Definition at line 34 of file dllmain.c.

◆ CRTDLL__osmajor_dll

unsigned int CRTDLL__osmajor_dll = 0

Definition at line 35 of file dllmain.c.

◆ CRTDLL__osminor_dll

unsigned int CRTDLL__osminor_dll = 0

Definition at line 36 of file dllmain.c.

◆ CRTDLL__osmode_dll

unsigned int CRTDLL__osmode_dll = 0

Definition at line 37 of file dllmain.c.

◆ CRTDLL__osversion_dll

unsigned int CRTDLL__osversion_dll = 0

Definition at line 38 of file dllmain.c.