/********************************************************************* * __std_exception_copy (MSVCRT.@) */ void CDECL MSVCRT___std_exception_copy(const struct __std_exception_data *src, struct __std_exception_data *dst) { TRACE("(%p %p)\n", src, dst); if(src->dofree && src->what) { dst->what = MSVCRT__strdup(src->what); dst->dofree = 1; } else { dst->what = src->what; dst->dofree = 0; } }
/* INTERNAL: Since we can't rely on Winelib startup code calling w/getmainargs, * we initialise data values during DLL loading. When called by a native * program we simply return the data we've already initialised. This also means * you can call multiple times without leaking */ void msvcrt_init_args(void) { OSVERSIONINFOW osvi; MSVCRT__acmdln = MSVCRT__strdup( GetCommandLineA() ); MSVCRT__wcmdln = msvcrt_wstrdupa(MSVCRT__acmdln); MSVCRT___argc = __wine_main_argc; MSVCRT___argv = __wine_main_argv; MSVCRT___wargv = __wine_main_wargv; TRACE("got %s, wide = %s argc=%d\n", debugstr_a(MSVCRT__acmdln), debugstr_w(MSVCRT__wcmdln),MSVCRT___argc); 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; MSVCRT__osplatform = osvi.dwPlatformId; TRACE( "winver %08x winmajor %08x winminor %08x osver %08x\n", MSVCRT__winver, MSVCRT__winmajor, MSVCRT__winminor, MSVCRT__osver); MSVCRT__HUGE = HUGE_VAL; MSVCRT___setlc_active = 0; MSVCRT___unguarded_readlc_active = 0; MSVCRT__fmode = MSVCRT__O_TEXT; MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL); MSVCRT___initenv = msvcrt_SnapshotOfEnvironmentA(NULL); MSVCRT___winitenv = msvcrt_SnapshotOfEnvironmentW(NULL); MSVCRT__pgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH); if (MSVCRT__pgmptr) { if (!GetModuleFileNameA(0, MSVCRT__pgmptr, MAX_PATH)) MSVCRT__pgmptr[0] = '\0'; else MSVCRT__pgmptr[MAX_PATH - 1] = '\0'; } MSVCRT__wpgmptr = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); if (MSVCRT__wpgmptr) { if (!GetModuleFileNameW(0, MSVCRT__wpgmptr, MAX_PATH)) MSVCRT__wpgmptr[0] = '\0'; else MSVCRT__wpgmptr[MAX_PATH - 1] = '\0'; } }
/********************************************************************* * _getdcwd (MSVCRT.@) * * Get the current working directory on a given disk. * * PARAMS * drive [I] Drive letter to get the current working directory from. * buf [O] Destination for the current working directory. * size [I] Length of drive in characters. * * RETURNS * Success: If drive is NULL, returns an allocated string containing the path. * Otherwise populates drive with the path and returns it. * Failure: NULL. errno indicates the error. */ char* CDECL MSVCRT__getdcwd(int drive, char * buf, int size) { static char* dummy; TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size); if (!drive || drive == MSVCRT__getdrive()) return MSVCRT__getcwd(buf,size); /* current */ else { char dir[MAX_PATH]; char drivespec[] = {'A', ':', 0}; int dir_len; drivespec[0] += drive - 1; if (GetDriveTypeA(drivespec) < DRIVE_REMOVABLE) { *MSVCRT__errno() = MSVCRT_EACCES; return NULL; } dir_len = GetFullPathNameA(drivespec,MAX_PATH,dir,&dummy); if (dir_len >= size || dir_len < 1) { *MSVCRT__errno() = MSVCRT_ERANGE; return NULL; /* buf too small */ } TRACE(":returning '%s'\n", dir); if (!buf) return MSVCRT__strdup(dir); /* allocate */ strcpy(buf,dir); } return buf; }