Пример #1
0
tstring Settings::Transport()
{
    tstring transport = GetSettingString(TRANSPORT_NAME, TRANSPORT_DEFAULT);
    if (transport != TRANSPORT_VPN)
    {
        transport = TRANSPORT_DEFAULT;
    }
    return transport;
}
Пример #2
0
wchar_t Config::GetSettingChar( const std::wstring &_section_name, const std::wstring &_var_name )
{
	return GetSettingString( _section_name, _var_name )[0];
}
Пример #3
0
int Config::GetSettingInt( const std::wstring &_section_name, const std::wstring &_var_name )
{
	return _wtoi( GetSettingString(_section_name, _var_name).c_str() );
}
Пример #4
0
// DLL Entry Point
extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved )
{
	if (dwReason==DLL_PROCESS_ATTACH)
	{
		wchar_t path[_MAX_PATH];
		GetModuleFileName(NULL,path,_countof(path));
		const wchar_t *exe=PathFindFileName(path);
		if (_wcsicmp(exe,L"explorer.exe")==0) return FALSE;
		bool bIE9=false;
		if (_wcsicmp(exe,L"iexplore.exe")==0)
		{
			DWORD version=GetVersionEx(GetModuleHandle(NULL));
			if (version<0x09000000) return FALSE;
			bIE9=true;
		}

		g_Instance=hInstance;
		InitSettings();
		if (bIE9 && !GetSettingBool(L"ShowCaption") && !GetSettingBool(L"ShowProgress") && !GetSettingBool(L"ShowZone")) return FALSE;

		CString language=GetSettingString(L"Language");
		ParseTranslations(NULL,language);

		GetModuleFileName(hInstance,path,_countof(path));
		*PathFindFileName(path)=0;
		HINSTANCE resInstance=NULL;
		if (!language.IsEmpty())
		{
			wchar_t fname[_MAX_PATH];
			Sprintf(fname,_countof(fname),L"%s" INI_PATH L"%s.dll",path,language);
			resInstance=LoadLibraryEx(fname,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
		}
		else
		{
			wchar_t languages[100]={0};
			ULONG size=4; // up to 4 languages
			ULONG len=_countof(languages);
			GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME,&size,languages,&len);

			for (const wchar_t *language=languages;*language;language+=Strlen(language)+1)
			{
				wchar_t fname[_MAX_PATH];
				Sprintf(fname,_countof(fname),L"%s" INI_PATH L"%s.dll",path,language);
				resInstance=LoadLibraryEx(fname,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
				if (resInstance)
					break;
			}
		}

		if (resInstance && GetVersionEx(resInstance)!=GetVersionEx(g_Instance))
		{
			FreeLibrary(resInstance);
			resInstance=NULL;
		}
		LoadTranslationResources(g_Instance,resInstance,g_LoadDialogs);

		if (resInstance)
			FreeLibrary(resInstance);
		InitClassicIE9(hInstance);
	}

	return _AtlModule.DllMain(dwReason, lpReserved); 
}
Пример #5
0
// DLL Entry Point
extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved )
{
	if (dwReason==DLL_PROCESS_ATTACH)
	{
		InitSettings();
		g_TlsIndex=TlsAlloc();
		if (g_TlsIndex==TLS_OUT_OF_INDEXES) 
			return FALSE; // TLS failure

		wchar_t path[_MAX_PATH];
		GetModuleFileName(NULL,path,_countof(path));
		const wchar_t *exe=PathFindFileName(path);
		g_bExplorerExe=(_wcsicmp(exe,L"explorer.exe")==0 || _wcsicmp(exe,L"verclsid.exe")==0);
		bool bReplaceUI=GetWinVersion()<WIN_VER_WIN8 && (GetSettingBool(L"ReplaceFileUI") || GetSettingBool(L"ReplaceFolderUI") || GetSettingBool(L"EnableMore"));
		if (_wcsicmp(exe,L"regsvr32.exe")!=0 && _wcsicmp(exe,L"msiexec.exe")!=0 && _wcsicmp(exe,L"ClassicExplorerSettings.exe")!=0 && !g_bExplorerExe)
		{
			// some arbitrary app
			if ((!GetSettingBool(L"ShareOverlay") || GetSettingBool(L"ShareExplorer")) && (!bReplaceUI || GetSettingBool(L"FileExplorer")))
				return FALSE;
			CString whiteList=GetSettingString(L"ProcessWhiteList");
			if (!whiteList.IsEmpty())
			{
				// check for whitelisted process names
				const wchar_t *str=whiteList;
				bool bFound=false;
				while (*str)
				{
					wchar_t token[_MAX_PATH];
					str=GetToken(str,token,_countof(token),L",;");
					wchar_t *start=token;
					while (*start==' ')
						start++;
					wchar_t *end=start+Strlen(start);
					while (end>start && end[-1]==' ')
						end--;
					*end=0;
					if (_wcsicmp(exe,start)==0)
					{
						bFound=true;
						break;
					}
				}
				if (!bFound)
					return FALSE;
			}
			else
			{
				// check for blacklisted process names
				CString blackList=GetSettingString(L"ProcessBlackList");
				const wchar_t *str=blackList;
				while (*str)
				{
					wchar_t token[_MAX_PATH];
					str=GetToken(str,token,_countof(token),L",;");
					wchar_t *start=token;
					while (*start==' ')
						start++;
					wchar_t *end=start+Strlen(start);
					while (end>start && end[-1]==' ')
						end--;
					*end=0;
					if (_wcsicmp(exe,start)==0)
						return FALSE;
				}
			}
		}

		g_Instance=hInstance;
		g_LoadedSettingsAtom=(LPCWSTR)GlobalAddAtom(L"ClassicExplorer.LoadedSettings");

		GetModuleFileName(hInstance,path,_countof(path));
		*PathFindFileName(path)=0;
		wchar_t fname[_MAX_PATH];
		Sprintf(fname,_countof(fname),L"%s" INI_PATH L"ExplorerL10N.ini",path);
		CString language=GetSettingString(L"Language");
		ParseTranslations(fname,language);

		HINSTANCE resInstance=NULL;
		if (!language.IsEmpty())
		{
			wchar_t fname[_MAX_PATH];
			Sprintf(fname,_countof(fname),L"%s" INI_PATH L"%s.dll",path,language);
			resInstance=LoadLibraryEx(fname,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
		}
		else
		{
			wchar_t languages[100]={0};
			ULONG size=4; // up to 4 languages
			ULONG len=_countof(languages);
			GetThreadPreferredUILanguages(MUI_LANGUAGE_NAME,&size,languages,&len);

			for (const wchar_t *language=languages;*language;language+=Strlen(language)+1)
			{
				wchar_t fname[_MAX_PATH];
				Sprintf(fname,_countof(fname),L"%s" INI_PATH L"%s.dll",path,language);
				resInstance=LoadLibraryEx(fname,NULL,LOAD_LIBRARY_AS_DATAFILE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
				if (resInstance)
					break;
			}
		}

		if (resInstance && GetVersionEx(resInstance)!=GetVersionEx(g_Instance))
		{
			FreeLibrary(resInstance);
			resInstance=NULL;
		}
		LoadTranslationResources(g_Instance,resInstance,g_LoadDialogs);

		if (resInstance)
			FreeLibrary(resInstance);

		g_bHookCopyThreads=(bReplaceUI && (g_bExplorerExe || !GetSettingBool(L"FileExplorer")));
		if (g_bHookCopyThreads)
		{
			InitClassicCopyProcess();
			InitClassicCopyThread();
		}

		if (GetSettingBool(L"ShareOverlay") && (g_bExplorerExe || !GetSettingBool(L"ShareExplorer")))
			CShareOverlay::InitOverlay(GetSettingString(L"ShareOverlayIcon"));
	}

	if (dwReason==DLL_THREAD_ATTACH)
	{
		if (g_bHookCopyThreads)
			InitClassicCopyThread();
	}

	if (dwReason==DLL_THREAD_DETACH)
	{
		void *pData=TlsGetValue(g_TlsIndex);
		if (pData)
			LocalFree((HLOCAL)pData);
		TlsSetValue(g_TlsIndex,NULL);
		if (g_bHookCopyThreads)
			FreeClassicCopyThread();
	}

	if (dwReason==DLL_PROCESS_DETACH)
	{
		void *pData=TlsGetValue(g_TlsIndex);
		if (pData)
			LocalFree((HLOCAL)pData);
		TlsSetValue(g_TlsIndex,NULL);
		TlsFree(g_TlsIndex);
		GlobalDeleteAtom((ATOM)g_LoadedSettingsAtom);
	}

	return _AtlModule.DllMain(dwReason, lpReserved);
}
Пример #6
0
string Settings::GetWindowPlacement()
{
    return GetSettingString(WINDOW_PLACEMENT_NAME, WINDOW_PLACEMENT_DEFAULT);
}
Пример #7
0
string Settings::GetCookies()
{
    return GetSettingString(COOKIES_NAME, COOKIES_DEFAULT);
}
Пример #8
0
string Settings::EgressRegion()
{
    return GetSettingString(EGRESS_REGION_NAME, EGRESS_REGION_DEFAULT);
}
Пример #9
0
string Settings::UpstreamProxyHostname()
{
    return GetSettingString(UPSTREAM_PROXY_HOSTNAME_NAME, UPSTREAM_PROXY_HOSTNAME_DEFAULT);
}
Пример #10
0
string Settings::UpstreamProxyType()
{
    // We only support one type, but we'll call this to create the registry entry
    (void)GetSettingString(UPSTREAM_PROXY_TYPE_NAME, UPSTREAM_PROXY_TYPE_DEFAULT);
    return UPSTREAM_PROXY_TYPE_DEFAULT;
}