Пример #1
0
DLLEXPORT int julia_trampoline(int argc, char **argv, int (*pmain)(int ac,char *av[]))
{
#if defined(_WIN32) //&& !defined(_WIN64)
    SetUnhandledExceptionFilter(exception_handler);
#endif
    unsigned char * p = (unsigned char *) &__stack_chk_guard;
    char a = p[sizeof(__stack_chk_guard)-1];
    char b = p[sizeof(__stack_chk_guard)-2];
    char c = p[0];
    /* If you have the ability to generate random numbers in your kernel then use them */
    p[sizeof(__stack_chk_guard)-1] = 255;
    p[sizeof(__stack_chk_guard)-2] = '\n';
    p[0] = 0;
#ifdef COPY_STACKS
    // initialize base context of root task
    jl_root_task->stackbase = (char*)&argc;
    if (jl_setjmp(jl_root_task->base_ctx, 0)) {
        jl_switch_stack(jl_current_task, jl_jmp_target);
    }
#endif
    int ret = pmain(argc, argv);
    p[sizeof(__stack_chk_guard)-1] = a;
    p[sizeof(__stack_chk_guard)-2] = b;
    p[0] = c;
    return ret;
}
Пример #2
0
DLLEXPORT
int julia_trampoline(int argc, char *argv[], int (*pmain)(int ac,char *av[]))
{
#ifdef COPY_STACKS
    // initialize base context of root task
    jl_root_task->stackbase = (char*)&argc;
    if (jl_setjmp(jl_root_task->base_ctx, 1)) {
        jl_switch_stack(jl_current_task, jl_jmp_target);
    }
#endif
    return pmain(argc, argv);
}
Пример #3
0
/*
 * DefaultWinMain - main windows entry point
 */
int PASCAL __export DefaultWinMain( HINSTANCE inst, HINSTANCE previnst,
        LPSTR cmd, int show, int (*pmain)( int, char ** ) )
{
    int rc;

    previnst = previnst;
    cmd = cmd;
    if( !firstInstance( inst ) ) return( FALSE );
    if( !windowsInit( inst, show ) ) return( FALSE );
    _InitFunctionPointers();

    rc = pmain( ___Argc, ___Argv );

    _WindowsExit();
    return( rc );

} /* DefaultWinMain */
Пример #4
0
int WINAPI
WinMain(
    HINSTANCE	hInstance,
    HINSTANCE	hPrevInst,
    LPSTR	lpszCmdLine,
    int		nCmdShow)
{
    int		argc;
    char	**argv;
    char	*tofree;
    char	prog[256];

    /*
     * Ron: added full path name so that the $VIM variable will get set to our
     * startup path (so the .vimrc file can be found w/o a VIM env. var.)
     * Remove the ".exe" extension, and find the 1st non-space.
     */
    GetModuleFileName(hInstance, prog, 255);
    if (*prog != NUL)
	exe_name = FullName_save((char_u *)prog, FALSE);

    /* Separate the command line into arguments. */
    argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
    if (argc == 0)
    {
	/* Error message? */
	return 0;
    }

    pSaveInst = SaveInst;
    pmain = VimMain;
    pSaveInst(hInstance);
    pmain(argc, argv);

    free(argv);
    if (tofree != NULL)
	free(tofree);

    return 0;
}
Пример #5
0
/*ARGSUSED*/
    int WINAPI
WinMain(
    HINSTANCE	hInstance,
    HINSTANCE	hPrevInst,
    LPSTR	lpszCmdLine,
    int		nCmdShow)
{
    int		argc = 0;
    char	**argv;
    char	*tofree;
    char	prog[256];
#ifdef VIMDLL
    char	*p;
    HANDLE	hLib;
#endif

    /* Ron: added full path name so that the $VIM variable will get set to our
     * startup path (so the .vimrc file can be found w/o a VIM env. var.) */
    GetModuleFileName(NULL, prog, 255);

    argc = get_cmd_args(prog, (char *)lpszCmdLine, &argv, &tofree);
    if (argc == 0)
    {
	MessageBox(0, "Could not allocate memory for command line.",
							      "VIM Error", 0);
	return 0;
    }

#ifdef DYNAMIC_GETTEXT
    /* Initialize gettext library */
    dyn_libintl_init(NULL);
#endif

#ifdef VIMDLL
    // LoadLibrary - get name of dll to load in here:
    p = strrchr(prog, '\\');
    if (p != NULL)
    {
# ifdef DEBUG
	strcpy(p+1, "vim32d.dll");
# else
	strcpy(p+1, "vim32.dll");
# endif
    }
    hLib = LoadLibrary(prog);
    if (hLib == NULL)
    {
	MessageBox(0, _("Could not load vim32.dll!"), _("VIM Error"), 0);
	goto errout;
    }
    // fix up the function pointers
# ifdef FEAT_GUI
    pSaveInst = GetProcAddress(hLib, (LPCSTR)2);
# endif
    pmain = GetProcAddress(hLib, (LPCSTR)1);
    if (pmain == NULL)
    {
	MessageBox(0, _("Could not fix up function pointers to the DLL!"),
							    _("VIM Error"),0);
	goto errout;
    }
#else
# ifdef FEAT_GUI
    pSaveInst = SaveInst;
# endif
    pmain =
# if defined(FEAT_GUI_W32)
    //&& defined(__MINGW32__)
	VimMain
# else
	main
# endif
	;
#endif
#ifdef FEAT_GUI
    pSaveInst(
#ifdef __MINGW32__
	    GetModuleHandle(NULL)
#else
	    hInstance
#endif
	    );
#endif
    pmain(argc, argv);

#ifdef VIMDLL
    FreeLibrary(hLib);
errout:
#endif
    free(argv);
    if (tofree != NULL)
	free(tofree);
#ifdef FEAT_MBYTE
    free_cmd_argsW();
#endif

    return 0;
}
Пример #6
0
static int SimCvsStartup(int argc, const char **argv)
{
	BOOL bIsCVSNT;
	TCHAR CVSNTInstallPath[1024];
	HKEY hKeyLocal,hKeyGlobal;
	TCHAR InstallPath[1024],SearchPath[2048],Env[10240];
	DWORD dwLen,dwType;

	if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"Software\\CVS\\PServer",0,KEY_QUERY_VALUE,&hKeyGlobal))
		hKeyGlobal = NULL;

	if(RegOpenKeyEx(HKEY_CURRENT_USER,L"Software\\Cvsnt\\PServer",0,KEY_QUERY_VALUE,&hKeyLocal))
		hKeyLocal = NULL;

	dwLen=sizeof(InstallPath);
	if(RegQueryValueEx(hKeyGlobal,L"InstallPath",NULL,&dwType,(LPBYTE)InstallPath,&dwLen) &&
		RegQueryValueEx(hKeyLocal,L"InstallPath",NULL,&dwType,(LPBYTE)InstallPath,&dwLen))
	{
		InstallPath[0]='\0';
	}

	dwLen=sizeof(SearchPath);
	if(RegQueryValueEx(hKeyGlobal,L"SearchPath",NULL,&dwType,(LPBYTE)SearchPath,&dwLen) &&
		RegQueryValueEx(hKeyLocal,L"SearchPath",NULL,&dwType,(LPBYTE)SearchPath,&dwLen))
	{
		SearchPath[0]='\0';
	}
	RegCloseKey(hKeyGlobal);
	RegCloseKey(hKeyLocal);
	
	_tcscpy(Env,InstallPath);
	_tcscat(Env,_T(";"));
	_tcscat(Env,SearchPath);
	_tcscat(Env,_T(";"));

	GetEnvironmentVariable(_T("Path"),Env+_tcslen(Env),sizeof(Env));
	SetEnvironmentVariable(_T("Path"),Env);

	//_tcscpy(InstallPath,_T("cvsnt.exe"));
	GetModuleFileName(NULL,InstallPath,sizeof(InstallPath));
	//printf("load %S\n",InstallPath);
	if(!_tcsicmp(InstallPath+_tcslen(InstallPath)-9,_T("cvsnt.exe")))
	{
		bIsCVSNT = TRUE;
		_tcscpy(CVSNTInstallPath,InstallPath);
		_tcscpy(CVSNTInstallPath+_tcslen(InstallPath)-4,_T(".dll"));
		_tcscpy(InstallPath+_tcslen(InstallPath)-9,_T("cvs.dll"));
	}
	else
	if(!_tcsicmp(InstallPath+_tcslen(InstallPath)-4,_T(".exe")))
		_tcscpy(InstallPath+_tcslen(InstallPath)-4,_T(".dll"));
	else
	if(_tcsicmp(InstallPath+_tcslen(InstallPath)-4,_T(".dll")))
		_tcscat(InstallPath,_T(".dll"));

	HMODULE hModule = LoadLibraryEx(InstallPath,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);

	if(!hModule)
	{
		if (bIsCVSNT)
		{
			hModule = LoadLibraryEx(CVSNTInstallPath,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
			if(!hModule)
			{
				printf("Unable to load %S\n",InstallPath);
				printf("Unable to load %S\n",CVSNTInstallPath);
				return -1;
			}
			_tcscpy(InstallPath,CVSNTInstallPath);
		}
		else
		{
		printf("Unable to load %S\n",InstallPath);
		return -1;
		}
	}
	simVerifyTrust(InstallPath,true);

	int (*pmain)(int argc, const char **argv);

	pmain = (int (*)(int, const char **))GetProcAddress(hModule,"main");

	if(!pmain)
	{
		printf("%S does not export main()\n",InstallPath);
		return -1;
	}

	return pmain(argc,argv);
}