// Is the PCD driver supported in current OS
bool IsPcdSupported()
{
	UINT type;
	OS_INFO *info = GetOsInfo();

	if (MsIsWindows10())
	{
		// Windows 10 or later never supports PCD driver.
		return false;
	}

	type = info->OsType;

	if (OS_IS_WINDOWS_NT(type) == false)
	{
		// Only on Windows NT series
		return false;
	}

	if (GET_KETA(type, 100) >= 2)
	{
		// Good for Windows 2000 or later
		return true;
	}

	// Not good for Windows NT 4.0 or Longhorn
	return false;
}
示例#2
0
// Load the string from the table
char *GetTableStr(char *name)
{
	TABLE *t;
	// Validate arguments
	if (name == NULL)
	{
		return "";
	}

#ifdef	OS_WIN32
	if (StrCmpi(name, "DEFAULT_FONT") == 0)
	{
		if (_II("LANG") == 2)
		{
			UINT os_type = GetOsType();
			if (OS_IS_WINDOWS_9X(os_type) ||
				GET_KETA(os_type, 100) <= 4)
			{
				// Use the SimSun font in Windows 9x, Windows NT 4.0, Windows 2000, Windows XP, and Windows Server 2003
				return "SimSun";
			}
		}
	}
#endif	// OS_WIN32

	// Search
	t = FindTable(name);
	if (t == NULL)
	{
		//Debug("%s: ANSI STRING NOT FOUND\n", name);
		return "";
	}

	return t->str;
}
示例#3
0
// Main process
void ViMain()
{
	char tmp[MAX_PATH];
	UINT ostype = GetOsInfo()->OsType;
	VI_SETTING_ARCH *suitable;
	TOKEN_LIST *t;
	UINT i;

	if (OS_IS_WINDOWS_NT(ostype) == false ||
		GET_KETA(ostype, 100) <= 1)
	{
		// The OS is too old
		MsgBox(NULL, MB_ICONEXCLAMATION, _U(IDS_BAD_OS+skip));
		return;
	}

	Zero(&setting, sizeof(setting));

	// Read the inf file
	Format(tmp, sizeof(tmp), "%s\\%s", MsGetExeDirName(), VI_INF_FILENAME);
	if (ViLoadInf(&setting, tmp) == false)
	{
		// Failure
		MsgBoxEx(NULL, MB_ICONSTOP, _U(IDS_INF_LOAD_FAILED+skip), VI_INF_FILENAME);
		return;
	}

	ViSetSkip();

	// Parse the command line options
	t = GetCommandLineToken();

	for (i = 0;i < t->NumTokens;i++)
	{
		char *s = t->Token[i];

		if (IsEmptyStr(s) == false)
		{
			if (StartWith(s, "/") || StartWith(s, "-"))
			{
				if (StrCmpi(&s[1], "web") == 0)
				{
					setting.WebMode = true;
				}
			}
			else
			{
				StrCpy(setting.SettingPath, sizeof(setting.SettingPath), s);
			}
		}
	}

	FreeToken(t);

	suitable = ViGetSuitableArchForCpu();

	// Security check
	if (setting.WebMode)
	{
		bool ok = true;

		if (ViIsInternetFile(suitable->Path) == false)
		{
			ok = false;
		}

		if (IsEmptyStr(setting.SettingPath) == false)
		{
			if (ViIsInternetFile(setting.SettingPath) == false)
			{
				ok = false;
			}
		}

		if (ok == false)
		{
			// Security breach
			MsgBox(NULL, MB_ICONEXCLAMATION, _U(IDS_SECURITY_ERROR+skip));
			return;
		}
	}

	// Get the current installation state
	ViLoadCurrentInstalledStates();

	if (suitable->Supported == false)
	{
		// This CPU isn't supported
		MsgBox(NULL, MB_ICONEXCLAMATION, _U(IDS_CPU_NOT_SUPPORTED+skip));
		return;
	}

	if (suitable->CurrentInstalled && suitable->Build <= suitable->CurrentInstalledBuild)
	{
		// Do not download client software since it has already been installed
		setting.DownloadNotRequired = true;
	}

	// Show the dialog
	ViInstallDlg();
}
ETH *OpenEthInternal(char *name, bool local, bool tapmode, char *tapaddr)
{
	WP_ADAPTER *t;
	ETH *e;
	ADAPTER *a = NULL;
	HANDLE h;
	CANCEL *c;
	MS_ADAPTER *ms;
	char name_with_id[MAX_SIZE];
	SU *su = NULL;
	SU_ADAPTER *su_adapter = NULL;
	// Validate arguments
	if (name == NULL || IsEthSupported() == false)
	{
		return NULL;
	}

	if (tapmode)
	{
		// Tap is not supported in Windows
		return NULL;
	}

	Lock(eth_list_lock);

	InitEthAdaptersList();

	t = Win32EthSearch(name);

	if (t == NULL)
	{
		Unlock(eth_list_lock);
		return NULL;
	}

	Debug("OpenEthInternal: %s\n", t->Name);

	if (StartWith(t->Name, SL_ADAPTER_ID_PREFIX))
	{
		// Open with SU
		su = SuInit();
		if (su == NULL)
		{
			// Fail to initialize SU
			Unlock(eth_list_lock);
			return NULL;
		}

		su_adapter = SuOpenAdapter(su, t->Name);

		if (su_adapter == NULL)
		{
			// Fail to get adapter
			SuFree(su);
			Unlock(eth_list_lock);
			return NULL;
		}

		is_using_selow = true;
	}
	else
	{
		// Open with SEE
		a = wp->PacketOpenAdapter(t->Name);
		if (a == NULL)
		{
			Unlock(eth_list_lock);
			return NULL;
		}

		if (IsWin32BridgeWithSee() == false)
		{
			MsSetThreadSingleCpu();
		}

		is_using_selow = false;
	}

	e = ZeroMalloc(sizeof(ETH));
	e->Name = CopyStr(t->Name);

	Win32EthMakeCombinedName(name_with_id, sizeof(name_with_id), t->Title, t->Guid);
	e->Title = CopyStr(name_with_id);

	if (su_adapter != NULL)
	{
		// SU
		e->SuAdapter = su_adapter;
		e->Su = su;

		// Get event object
		h = e->SuAdapter->hEvent;

		c = NewCancelSpecial(h);
		e->Cancel = c;
	}
	else
	{
		// SEE
		e->Adapter = a;

		wp->PacketSetBuff(e->Adapter, BRIDGE_WIN32_ETH_BUFFER);
		wp->PacketSetHwFilter(e->Adapter, local ? 0x0080 : 0x0020);
		wp->PacketSetMode(e->Adapter, PACKET_MODE_CAPT);
		wp->PacketSetReadTimeout(e->Adapter, -1);
		wp->PacketSetNumWrites(e->Adapter, 1);

		if (wp->PacketSetLoopbackBehavior != NULL)
		{
			// Filter loopback packet in kernel
			if (GET_KETA(GetOsType(), 100) >= 3)
			{
				if (MsIsWindows8() == false)
				{
					// Enable for Windows XP, Server 2003 or later
					// But disable for Windows 8 or later
					bool ret = wp->PacketSetLoopbackBehavior(e->Adapter, 1);
					Debug("*** PacketSetLoopbackBehavior: %u\n", ret);

					e->LoopbackBlock = ret;
				}
			}
		}

		// Get event object
		h = wp->PacketGetReadEvent(e->Adapter);

		c = NewCancelSpecial(h);
		e->Cancel = c;

		e->Packet = wp->PacketAllocatePacket();

		e->PutPacket = wp->PacketAllocatePacket();
	}

	e->Buffer = Malloc(BRIDGE_WIN32_ETH_BUFFER);
	e->BufferSize = BRIDGE_WIN32_ETH_BUFFER;

	e->PacketQueue = NewQueue();

	// Get MAC address by GUID
	ms = MsGetAdapterByGuid(t->Guid);
	if (ms != NULL)
	{
		if (ms->AddressSize == 6)
		{
			Copy(e->MacAddress, ms->Address, 6);
		}

		MsFreeAdapter(ms);
	}

	Unlock(eth_list_lock);

	return e;
}