int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HANDLE ekr_mutex; int iresult = 0; char **env; char **argv; int argc; _startupinfo info = {0}; ekr_mutex = CreateMutex (NULL, FALSE, "EkigaIsRunning"); if (GetLastError () == ERROR_ALREADY_EXISTS) MessageBox (NULL, "Ekiga is running already !", "Ekiga - 2nd instance", MB_ICONEXCLAMATION | MB_OK); else { /* use msvcrt.dll to parse command line */ __getmainargs (&argc, &argv, &env, 0, &info); iresult = main (argc, argv, env); } CloseHandle (ekr_mutex); return iresult; }
void _start(void) { __TRY__ int argc; char **argv; char **env; _startupinfo start_info; // Sets the current application type __set_app_type(_CONSOLE_APP); // Set default FP precision to 53 bits (8-byte double) // _MCW_PC (Precision control) is not supported on // the ARM and x64 architectures #if defined(_X86_) && !defined(__x86_64) _controlfp(_PC_53, _MCW_PC); #endif start_info.newmode = 0; if ( __getmainargs( &argc, &argv, &env, 0, &start_info ) < 0 ) { ExitProcess(-1); } else { exit( main(argc, argv, env) ); } }
static void __cdecl pre_cpp_init(void) { #ifdef _RTC atexit(_RTC_Terminate); #endif /* _RTC */ /* * Get the arguments for the call to main. Note this must be * done explicitly, rather than as part of the dll's * initialization, to implement optional expansion of wild * card chars in filename args */ startinfo.newmode = _newmode; #ifdef WPRFLAG argret = __wgetmainargs(&argc, &argv, &envp, _dowildcard, &startinfo); #else /* WPRFLAG */ argret = __getmainargs(&argc, &argv, &envp, _dowildcard, &startinfo); #endif /* WPRFLAG */ #ifndef _SYSCRT if (argret < 0) { _amsg_exit(_RT_SPACEARG); } #endif /* _SYSCRT */ }
void __declspec(noinline) mainCRTStartup(void) { //*_IMP___FMODE = _fmode; //*_IMP___COMMODE = _commode; // TODO: Adapt to different versions of VC. This works for VC++ 10-15 at least. _PVFV *pfbegin = (_PVFV *)__xi_a, *pfend = (_PVFV *)__xi_z; for (; pfbegin < pfend; ++pfbegin) { if (*pfbegin != NULL) (**pfbegin)(); } #if TL_X86 && TL_MSVCPP unsigned short x; __asm { fnstcw x } x &= ~PC_64; x |= PC_53; __asm { fldcw x } #endif _startupinfo startinfo; int argc; _TSCHAR **argv; _TSCHAR **envp; __getmainargs(&argc, &argv, &envp, _dowildcard, &startinfo); tl_std_init(); int r = main(argc, argv, envp); ExitProcess((UINT)r); }
static void __cdecl pre_cpp_init (void) { startinfo.newmode = _newmode; #ifdef WPRFLAG argret = __wgetmainargs(&argc,&argv,&envp,_dowildcard,&startinfo); #else argret = __getmainargs(&argc,&argv,&envp,_dowildcard,&startinfo); #endif }
static void test__environ(void) { int argc; char **argv, **envp = NULL; int i, mode = 0; ok( p_environ != NULL, "Expected the pointer to _environ to be non-NULL\n" ); if (p_environ) ok( *p_environ != NULL, "Expected _environ to be initialized on startup\n" ); if (!p_environ || !*p_environ) { skip( "_environ pointers are not valid\n" ); return; } /* Examine the returned pointer from __p__environ(), if available. */ if (p__p__environ) { ok( *p__p__environ() == *p_environ, "Expected _environ pointers to be identical\n" ); } else win_skip( "__p__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); ok( envp != NULL, "Expected initial environment block pointer to be non-NULL\n" ); if (!envp) { skip( "Initial environment block pointer is not valid\n" ); return; } for (i = 0; ; i++) { if ((*p_environ)[i]) { ok( envp[i] != NULL, "Expected environment block pointer element to be non-NULL\n" ); ok( !strcmp((*p_environ)[i], envp[i]), "Expected _environ and environment block pointer strings (%s vs. %s) to match\n", (*p_environ)[i], envp[i] ); } else { ok( !envp[i], "Expected environment block pointer element to be NULL, got %p\n", envp[i] ); break; } } }
/* * Do the work that mainCRTStartup() would normally do */ void GetArgs(int *argc, char ***argv, char ***envp) { _startupinfo startinfo; /* * Set the app type to Console (check CRT/SRC/INTERNAL.H: * \#define _CONSOLE_APP 1) */ __set_app_type(1); /* Mark this module as an EXE file */ __onexitbegin = __onexitend = (_PVFV *)(-1); startinfo.newmode = _newmode; __getmainargs(argc, argv, envp, _dowildcard, &startinfo); __initenv = *envp; #ifdef _M_IX86 _adjust_fdiv = * _imp___adjust_fdiv; _setdefaultprecision(); #endif }
static void test__wenviron(void) { static const WCHAR cat_eq_dogW[] = {'c','a','t','=','d','o','g',0}; static const WCHAR cat_eqW[] = {'c','a','t','=',0}; int argc; char **argv, **envp = NULL; WCHAR **wargv, **wenvp = NULL; int i, mode = 0; ok( p_wenviron != NULL, "Expected the pointer to _wenviron to be non-NULL\n" ); if (p_wenviron) ok( *p_wenviron == NULL, "Expected _wenviron to be NULL, got %p\n", *p_wenviron ); else { win_skip( "Pointer to _wenviron is not valid\n" ); return; } /* Examine the returned pointer from __p__wenviron(), if available. */ if (p__p__wenviron) { ok( *p__p__wenviron() == NULL, "Expected _wenviron pointers to be NULL\n" ); } else win_skip( "__p__wenviron() is not available\n" ); /* __getmainargs doesn't initialize _wenviron. */ __getmainargs(&argc, &argv, &envp, 0, &mode); ok( *p_wenviron == NULL, "Expected _wenviron to be NULL, got %p\n", *p_wenviron); ok( envp != NULL, "Expected initial environment block pointer to be non-NULL\n" ); if (!envp) { skip( "Initial environment block pointer is not valid\n" ); return; } /* Neither does calling the non-Unicode environment manipulation functions. */ ok( _putenv("cat=dog") == 0, "failed setting cat=dog\n" ); ok( *p_wenviron == NULL, "Expected _wenviron to be NULL, got %p\n", *p_wenviron); ok( _putenv("cat=") == 0, "failed deleting cat\n" ); /* _wenviron isn't initialized until __wgetmainargs is called or * one of the Unicode environment manipulation functions is called. */ ok( _wputenv(cat_eq_dogW) == 0, "failed setting cat=dog\n" ); ok( *p_wenviron != NULL, "Expected _wenviron to be non-NULL\n" ); ok( _wputenv(cat_eqW) == 0, "failed deleting cat\n" ); __wgetmainargs(&argc, &wargv, &wenvp, 0, &mode); ok( *p_wenviron != NULL, "Expected _wenviron to be non-NULL\n" ); ok( wenvp != NULL, "Expected initial environment block pointer to be non-NULL\n" ); if (!wenvp) { skip( "Initial environment block pointer is not valid\n" ); return; } /* Examine the returned pointer from __p__wenviron(), * if available, after _wenviron is initialized. */ if (p__p__wenviron) { ok( *p__p__wenviron() == *p_wenviron, "Expected _wenviron pointers to be identical\n" ); } for (i = 0; ; i++) { if ((*p_wenviron)[i]) { ok( wenvp[i] != NULL, "Expected environment block pointer element to be non-NULL\n" ); ok( !winetest_strcmpW((*p_wenviron)[i], wenvp[i]), "Expected _wenviron and environment block pointer strings (%s vs. %s) to match\n", wine_dbgstr_w((*p_wenviron)[i]), wine_dbgstr_w(wenvp[i]) ); } else { ok( !wenvp[i], "Expected environment block pointer element to be NULL, got %p\n", wenvp[i] ); break; } } }
/********************************************************************* * __getmainargs (MSVCRT20.@) * * new_mode is not a pointer in msvcrt20. */ void CDECL MSVCRT20__getmainargs( int *argc, char** *argv, char** *envp, int expand_wildcards, int new_mode ) { __getmainargs( argc, argv, envp, expand_wildcards, &new_mode ); }
void fn004019E0(word32 ebp, Eq_3 * fs) { word32 * eax_14 = fs->ptr0000; fs->ptr0000 = fp - 0x00000014; __set_app_type(); globals->dw40312C = 0xFFFFFFFF; globals->dw403130 = 0xFFFFFFFF; __p__fmode(); *eax_14 = globals->dw403120; __p__commode(); *eax_14 = globals->dw40311C; Mem46[0x00403128:word32] = Mem43[_adjust_fdiv:word32]; fn00401BE0(); word32 esp_193 = fp + 0xFFFFFF6C; if (globals->dw403040 == 0x00000000) { __setusermatherr(); esp_193 = fp + 0xFFFFFF68; } fn00401BB0(); Eq_51 * esp_54 = esp_193 - 0x00000004; esp_54->dw0000 = 0x00403014; esp_54->dw0000 = 0x00403010; _initterm(); esp_54->dw0000 = fp - 0x00000070; esp_54->dw0000 = globals->dw403114; esp_54->dw0000 = fp - 0x00000068; Mem74[esp_54 - 0x00000010:word32] = fp - 0x00000074; esp_54->dw0000 = fp - 0x00000064; __getmainargs(); esp_54->dwFFFFFFF8 = 0x0040300C; esp_54->dwFFFFFFF4 = 0x00403000; _initterm(); __p__acmdln(); Eq_85 * esi_161 = dwLoc74; if (dwLoc74->b0000 == 0x22) { do { esi_161 = esi_161 + 1; bcu8 al_169 = esi_161->b0000; } while (al_169 == 0x00 || al_169 == 0x22); if (esi_161->b0000 == 0x22) { esi_161 = esi_161 + 1; goto l00401AEE; } } while (esi_161->b0000 >u 0x20) esi_161 = esi_161 + 1; l00401AEE: bcu8 al_99 = esi_161->b0000; while (al_99 != 0x00 && al_99 <=u 0x20) { esi_161 = esi_161 + 1; al_99 = esi_161->b0000; } Eq_80 eax_117; esp_54->tFFFFFFF0 = fp - 0x00000060; GetStartupInfoA(esp_54->tFFFFFFF0); if (0x00 != 0x00) eax_117 = dwLoc30 & 0x0000FFFF; else eax_117.u0 = 0x0000000A; esp_54->tFFFFFFF0 = eax_117; esp_54->ptrFFFFFFEC = esi_161; esp_54->dwFFFFFFE8 = 0x00000000; esp_54->tFFFFFFE4.u0 = 0x00000000; Eq_80 eax_127 = GetModuleHandleA(esp_54->tFFFFFFE4); esp_54->tFFFFFFE4 = eax_127; fn00401BFC(ebp, dwArg00, dwArg04, dwArg08); esp_54->tFFFFFFF0 = eax_127; exit(esp_54->tFFFFFFF0); fp->dwFFFFFFF8 = 0xFFFFFFFF; fs->ptr0000 = eax_14; return; }
void fn1310E4E5(Eq_281 * fs) { word32 * eax_14 = fs->ptr0000; fs->ptr0000 = fp - 0x00000014; __set_app_type(); __p__fmode(); *eax_14 = 0x00000000; __p__commode(); *eax_14 = 0x00000000; word32 eax_51 = Mem49[_adjust_fdiv:word32]; fn1310E63E(); word32 esp_193 = fp + 0xFFFFFF68; if (eax_51 == 0x00000000) { __setusermatherr(); esp_193 = fp + 0xFFFFFF64; } fn1310E629(); Eq_318 * esp_59 = esp_193 - 0x00000004; esp_59->dw0000 = fp - 0x00000080; esp_59->dw0000 = fp - 0x00000080; _initterm(); esp_59->tFFFFFFF4 = fp - 0x00000070; esp_59->dwFFFFFFF0 = eax_51; esp_59->dwFFFFFFEC = fp - 0x00000068; esp_59->dwFFFFFFE8 = fp - 0x00000074; esp_59->dwFFFFFFE4 = fp - 0x00000064; __getmainargs(); esp_59->dwFFFFFFDC = fp - 0x00000080; esp_59->dwFFFFFFD8 = fp - 0x00000080; _initterm(); word32 esi_161 = Mem85[_acmdln:word32]; if (esi_161->b0000 == 0x22) { l1310E597: do { esi_161 = esi_161 + 1; bcu8 al_171 = esi_161->b0000; } while (al_171 == 0x00 || al_171 == 0x22); if (esi_161->b0000 == 0x22) { l1310E5AA: esi_161 = esi_161 + 1; l1310E5AE: bcu8 al_98 = esi_161->b0000; if (al_98 != 0x00 && al_98 <=u 0x20) goto l1310E5AA; } else goto l1310E5AE; } else while (esi_161->b0000 >u 0x20) esi_161 = esi_161 + 1; Eq_57 eax_113; esp_59->tFFFFFFF4 = fp - 0x00000060; GetStartupInfoA(esp_59->tFFFFFFF4); word32 esp_109 = &esp_59->tFFFFFFF4; if (0x00 != 0x00) eax_113 = (word32) wLoc30; else { esp_59->tFFFFFFF4.u0 = 0x0000000A; eax_113 = esp_59->tFFFFFFF4; esp_109 = &esp_59->tFFFFFFF4; } Eq_439 * esp_115 = esp_109 - 0x00000004; esp_115->t0000 = eax_113; Mem118[esp_115 - 0x00000004:word32] = esi_161; esp_115->t0000.u0 = 0x00000000; esp_115->t0000.u0 = 0x00000000; Mem126[esp_115 - 0x0000000C:word32] = GetModuleHandleA(esp_115->t0000); esp_115->dw0016 = fn1310E09B(); exit(esp_115->dw0016); word32 ecx_137 = **dwLoc18; esp_115->ptr0012 = dwLoc18; esp_115->dw000E = ecx_137; _XcptFilter(); return; }