// 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; }
// Get the version information of Windows void Win32GetWinVer(RPC_WINVER *v) { // Validate arguments if (v == NULL) { return; } Zero(v, sizeof(RPC_WINVER)); v->IsWindows = true; if (OS_IS_WINDOWS_NT(GetOsType()) == false) { // Windows 9x OSVERSIONINFO os; Zero(&os, sizeof(os)); os.dwOSVersionInfoSize = sizeof(os); GetVersionEx(&os); v->Build = LOWORD(os.dwBuildNumber); v->VerMajor = os.dwMajorVersion; v->VerMinor = os.dwMinorVersion; Format(v->Title, sizeof(v->Title), "%s %s", GetOsInfo()->OsProductName, GetOsInfo()->OsVersion); Trim(v->Title); } else { // Windows NT 4.0 SP6 or later OSVERSIONINFOEX os; Zero(&os, sizeof(os)); os.dwOSVersionInfoSize = sizeof(os); Win32GetVersionExInternal((LPOSVERSIONINFOA)&os); v->IsNT = true; v->Build = os.dwBuildNumber; v->ServicePack = os.wServicePackMajor; if (os.wProductType != VER_NT_WORKSTATION) { v->IsServer = true; } v->VerMajor = os.dwMajorVersion; v->VerMinor = os.dwMinorVersion; if (GetOsInfo()->OsServicePack == 0) { StrCpy(v->Title, sizeof(v->Title), GetOsInfo()->OsProductName); } else { Format(v->Title, sizeof(v->Title), "%s Service Pack %u", GetOsInfo()->OsProductName, GetOsInfo()->OsServicePack); } Trim(v->Title); if (InStr(GetOsInfo()->OsVersion, "rc") || InStr(GetOsInfo()->OsVersion, "beta")) { v->IsBeta = true; } } }
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; }