View | Details | Raw Unified | Return to bug 325902
Collapse All | Expand All

(-)library/eclipse.c (+21 lines)
Lines 355-360 Link Here
355
355
356
#ifdef _WIN32
356
#ifdef _WIN32
357
static void     createConsole();
357
static void     createConsole();
358
static void		fixDLLSearchPath();
358
static int 		isConsoleLauncher();
359
static int 		isConsoleLauncher();
359
#endif
360
#endif
360
static int      consoleLauncher = 0;
361
static int      consoleLauncher = 0;
Lines 415-420 Link Here
415
#elif _WIN32
416
#elif _WIN32
416
    /* this must be before doing any console stuff, platforms other than win32 leave this set to 0 */
417
    /* this must be before doing any console stuff, platforms other than win32 leave this set to 0 */
417
    consoleLauncher = isConsoleLauncher();
418
    consoleLauncher = isConsoleLauncher();
419
    
420
    /*fix the DLL search path for security */
421
    fixDLLSearchPath();
418
#endif
422
#endif
419
    
423
    
420
    /* Find the directory where the Eclipse program is installed. */
424
    /* Find the directory where the Eclipse program is installed. */
Lines 1373-1378 Link Here
1373
	}
1377
	}
1374
	return 0;
1378
	return 0;
1375
}
1379
}
1380
1381
static void fixDLLSearchPath() {
1382
#ifdef UNICODE
1383
	_TCHAR* functionName = _T_ECLIPSE("SetDllDirectoryW");
1384
#else
1385
	_TCHAR* functionName = _T_ECLIPSE("SetDllDirectoryA");
1386
#endif
1387
1388
	BOOL (WINAPI *SetDLLDirectory)(LPCTSTR);
1389
	void * handle = loadLibrary(_T_ECLIPSE("Kernel32.dll"));
1390
	if (handle != NULL) {
1391
		if ( (SetDLLDirectory = findSymbol(handle, functionName)) != NULL) {
1392
			SetDLLDirectory(_T_ECLIPSE(""));
1393
		}
1394
	}
1395
}
1396
1376
#endif
1397
#endif
1377
1398
1378
/* Set the vm to use based on the given .ee file.
1399
/* Set the vm to use based on the given .ee file.
(-)library/win32/eclipseWin.c (-3 / +13 lines)
Lines 286-291 Link Here
286
286
287
void adjustSearchPath( _TCHAR* vmLib ){
287
void adjustSearchPath( _TCHAR* vmLib ){
288
	_TCHAR ** paths;
288
	_TCHAR ** paths;
289
	_TCHAR* cwd = NULL;
289
	_TCHAR * path = NULL, *newPath = NULL;
290
	_TCHAR * path = NULL, *newPath = NULL;
290
	_TCHAR * c;
291
	_TCHAR * c;
291
	int i, length;
292
	int i, length;
Lines 293-304 Link Here
293
	
294
	
294
	paths = getVMLibrarySearchPath(vmLib);
295
	paths = getVMLibrarySearchPath(vmLib);
295
	
296
	
297
	/* bug 325902 - add current working dir to the end of the search path */
298
	length = GetCurrentDirectory(0, NULL);
299
	cwd = malloc((length + 1)* sizeof(_TCHAR));
300
	GetCurrentDirectory(length, cwd);
301
	cwd[length - 1] = pathSeparator;
302
	cwd[length] = 0;
303
	
296
	/* first call to GetEnvironmentVariable tells us how big to make the buffer */
304
	/* first call to GetEnvironmentVariable tells us how big to make the buffer */
297
	length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0);
305
	length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0);
298
	if (length > 0) {
306
	if (length > 0) {
307
		_TCHAR* current [] = { cwd, NULL };
299
		path = malloc(length * sizeof(_TCHAR));
308
		path = malloc(length * sizeof(_TCHAR));
300
		GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length);
309
		GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length);
301
		needAdjust = !containsPaths(path, paths);
310
		needAdjust = !containsPaths(path, paths) || !containsPaths(path, current);
302
		freePath = 1;
311
		freePath = 1;
303
	} else {
312
	} else {
304
		path = _T_ECLIPSE("");
313
		path = _T_ECLIPSE("");
Lines 308-315 Link Here
308
	
317
	
309
	if (needAdjust) {
318
	if (needAdjust) {
310
		c = concatStrings(paths);
319
		c = concatStrings(paths);
311
		newPath = malloc((_tcslen(c) + length + 1) * sizeof(_TCHAR));
320
		newPath = malloc((_tcslen(c) + length + 1 + _tcslen(cwd) + 1) * sizeof(_TCHAR));
312
		_stprintf(newPath, _T_ECLIPSE("%s%s"), c, path);
321
		_stprintf(newPath, _T_ECLIPSE("%s%s%c%s"), c, path, pathSeparator, cwd);
313
		SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath);
322
		SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath);
314
		free(c);
323
		free(c);
315
		free(newPath);
324
		free(newPath);
Lines 318-323 Link Here
318
	for (i = 0; paths[i] != NULL; i++)
327
	for (i = 0; paths[i] != NULL; i++)
319
		free(paths[i]);
328
		free(paths[i]);
320
	free(paths);
329
	free(paths);
330
	free(cwd);
321
	if (freePath)
331
	if (freePath)
322
		free(path);
332
		free(path);
323
}
333
}

Return to bug 325902