Example #1
0
/**
  Register image to memory profile.

  @param DriverEntry    Image info.
  @param FileType       Image file type.

  @retval TRUE          Register success.
  @retval FALSE         Register fail.

**/
BOOLEAN
RegisterMemoryProfileImage (
  IN LOADED_IMAGE_PRIVATE_DATA  *DriverEntry,
  IN EFI_FV_FILETYPE            FileType
  )
{
  MEMORY_PROFILE_CONTEXT_DATA       *ContextData;
  MEMORY_PROFILE_DRIVER_INFO_DATA   *DriverInfoData;

  if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
    return FALSE;
  }

  ContextData = GetMemoryProfileContext ();
  if (ContextData == NULL) {
    return FALSE;
  }

  DriverInfoData = BuildDriverInfo (
                     ContextData,
                     GetFileNameFromFilePath (DriverEntry->Info.FilePath),
                     DriverEntry->ImageContext.ImageAddress,
                     DriverEntry->ImageContext.ImageSize,
                     DriverEntry->ImageContext.EntryPoint,
                     DriverEntry->ImageContext.ImageType,
                     FileType
                     );
  if (DriverInfoData == NULL) {
    return FALSE;
  }

  return TRUE;
}
Example #2
0
/**
  Unregister image from memory profile.

  @param DriverEntry    Image info.

  @retval TRUE          Unregister success.
  @retval FALSE         Unregister fail.

**/
BOOLEAN
UnregisterMemoryProfileImage (
  IN LOADED_IMAGE_PRIVATE_DATA      *DriverEntry
  )
{
  EFI_STATUS                        Status;
  MEMORY_PROFILE_CONTEXT_DATA       *ContextData;
  MEMORY_PROFILE_DRIVER_INFO_DATA   *DriverInfoData;
  EFI_GUID                          *FileName;
  PHYSICAL_ADDRESS                  ImageAddress;
  VOID                              *EntryPointInImage;

  if (!IS_UEFI_MEMORY_PROFILE_ENABLED) {
    return FALSE;
  }

  ContextData = GetMemoryProfileContext ();
  if (ContextData == NULL) {
    return FALSE;
  }

  DriverInfoData = NULL;
  FileName = GetFileNameFromFilePath (DriverEntry->Info.FilePath);
  ImageAddress = DriverEntry->ImageContext.ImageAddress;
  if ((DriverEntry->ImageContext.EntryPoint < ImageAddress) || (DriverEntry->ImageContext.EntryPoint >= (ImageAddress + DriverEntry->ImageContext.ImageSize))) {
    //
    // If the EntryPoint is not in the range of image buffer, it should come from emulation environment.
    // So patch ImageAddress here to align the EntryPoint.
    //
    Status = InternalPeCoffGetEntryPoint ((VOID *) (UINTN) ImageAddress, &EntryPointInImage);
    ASSERT_EFI_ERROR (Status);
    ImageAddress = ImageAddress + (UINTN) DriverEntry->ImageContext.EntryPoint - (UINTN) EntryPointInImage;
  }
  if (FileName != NULL) {
    DriverInfoData = GetMemoryProfileDriverInfoByFileNameAndAddress (ContextData, FileName, ImageAddress);
  }
  if (DriverInfoData == NULL) {
    DriverInfoData = GetMemoryProfileDriverInfoFromAddress (ContextData, ImageAddress);
  }
  if (DriverInfoData == NULL) {
    return FALSE;
  }

  ContextData->Context.TotalImageSize -= DriverInfoData->DriverInfo.ImageSize;

  DriverInfoData->DriverInfo.ImageBase = 0;
  DriverInfoData->DriverInfo.ImageSize = 0;

  if (DriverInfoData->DriverInfo.PeakUsage == 0) {
    ContextData->Context.ImageCount --;
    RemoveEntryList (&DriverInfoData->Link);
    //
    // Use CoreInternalFreePool() that will not update profile for this FreePool action.
    //
    CoreInternalFreePool (DriverInfoData);
  }

  return TRUE;
}
Example #3
0
	string FileSystem::GetFileNameNoExtensionFromFilePath(const string& filepath)
	{
		auto fileName		= GetFileNameFromFilePath(filepath);
		auto lastindex		= fileName.find_last_of('.');
		auto fileNameNoExt	= fileName.substr(0, lastindex);

		return fileNameNoExt;
	}
Example #4
0
// Download thread
void ViDownloadThread(THREAD *thread, void *param)
{
	VI_INSTALL_DLG *d;
	VI_SETTING_ARCH *a;
	HWND hWnd;
	UINT num_files = 2;
	VI_DOWNLOAD_FILE files[2];
	VI_DOWNLOAD_FILE *f;
	UINT i;
	// Validate arguments
	if (thread == NULL || param == NULL)
	{
		return;
	}

	d = (VI_INSTALL_DLG *)param;
	hWnd = d->hWnd;

	Zero(files, sizeof(files));

	a = ViGetSuitableArchForCpu();

	// File body
	f = &files[0];
	StrCpy(f->SrcPath, sizeof(f->SrcPath), a->Path);

	// Configuration file
	if (IsEmptyStr(setting.SettingPath) == false)
	{
		f = &files[1];
		StrCpy(f->SrcPath, sizeof(f->SrcPath), setting.SettingPath);
	}
	else
	{
		// No configuration file
		num_files = 1;
	}

	for (i = 0;i < num_files;i++)
	{
		bool b = true;

		if (i == 0 && setting.DownloadNotRequired)
		{
			b = false;
		}

		if (b)
		{
			wchar_t tmp[MAX_SIZE];
			IO *dest = NULL;
			VI_FILE *down;
			UINT ret;
			UINT totalsize;
			UINT currentsize;
			wchar_t filename_w[MAX_PATH];

			f = &files[i];
			GetFileNameFromFilePath(f->FileName, sizeof(f->FileName), f->SrcPath);
			MakeSafeFileName(f->FileName, sizeof(f->FileName), f->FileName);

			StrToUni(filename_w, sizeof(filename_w), f->FileName);
			ConbinePathW(f->DestPathW, sizeof(f->DestPathW), MsGetMyTempDirW(), filename_w);

			ViInstallDlgSetPos(hWnd, 0);
			UniFormat(tmp, sizeof(tmp), _U(IDS_DOWNLOADSTART+skip), f->FileName);
			ViInstallDlgSetText(d, hWnd, S_STATUS, tmp);

			down = ViOpenFile(f->SrcPath);
			if (down == NULL)
			{
				MsgBoxEx(hWnd, MB_ICONSTOP, _U(IDS_DOWNLOAD_ERROR+skip), f->FileName);

				ViInstallDlgCancel(hWnd);
				return;
			}

			dest = FileCreateW(f->DestPathW);
			if (dest == NULL)
			{
				MsgBoxEx(hWnd, MB_ICONSTOP, _U(IDS_TEMP_ERROR+skip), f->DestPathW);

				ViCloseFile(down);
				ViInstallDlgCancel(hWnd);
				return;
			}

			totalsize = ViGetFileSize(down);
			currentsize = 0;

			UniFormat(tmp, sizeof(tmp), _U(IDS_DOWNLOADING3+skip), f->FileName);
			ViInstallDlgSetText(d, hWnd, S_STATUS, tmp);

			while (true)
			{
				UINT pos = 0;

				if (d->Halt)
				{
					// User cancel
					FileClose(dest);
					ViCloseFile(down);
					return;
				}

				UniFormat(tmp, sizeof(tmp), _U(IDS_DOWNLOADING3+skip), f->FileName);

				ViInstallDlgSetText(d, hWnd, IDS_DOWNLOADING3+skip, tmp);
				ret = ViReadFile(down, d->Buf, d->BufSize);

				if (ret == INFINITE)
				{
					// Communication error
					MsgBoxEx(hWnd, MB_ICONSTOP, _U(IDS_DOWNLOAD_ERROR+skip), f->FileName);

					FileClose(dest);
					ViCloseFile(down);
					ViInstallDlgCancel(hWnd);

					return;
				}

				// Draw progress
				currentsize += ret;

				if (totalsize != 0)
				{
					UniFormat(tmp, sizeof(tmp), _U(IDS_DOWNLOADING+skip),
						((float)totalsize) / 1024.0f / 1024.0f,
						((float)currentsize) / 1024.0f / 1024.0f);

					pos = (UINT)(((float)currentsize) * 100.0f / ((float)totalsize));
				}
				else
				{
					UniFormat(tmp, sizeof(tmp), _U(IDS_DOWNLOADING2+skip),
						((float)currentsize) / 1024.0f / 1024.0f);
					pos = (UINT)(((float)currentsize) * 100.0f / (1024.0f * 1024.0f * 10.0f));
				}

				ViInstallDlgSetText(d, hWnd, S_SIZEINFO, tmp);
				ViInstallDlgSetPos(hWnd, pos);

				if (ret == 0)
				{
					// Download Complete
					break;
				}
				else
				{
					FileWrite(dest, d->Buf, ret);
				}
			}

			ViCloseFile(down);
			FileClose(dest);
		}
	}

	UniStrCpy(setting.DownloadedInstallerPathW, sizeof(setting.DownloadedInstallerPathW),
		files[0].DestPathW);

	if (num_files >= 2)
	{
		UniStrCpy(setting.DownloadedSettingPathW, sizeof(setting.DownloadedSettingPathW),
			files[1].DestPathW);
	}

	PostMessageA(hWnd, WM_VI_DOWNLOAD_FINISHED, 0, 0);
}
void Dialog::Draw(double xOffset, double yOffset)
{
#ifdef ENABLE_DEBUG_MODE
    if (gEnableDebugMode && filePath.length() > 0)
    {
        MLIFont *pFont = CommonCaseResources::GetInstance()->GetFontManager()->GetFontFromId("MouseOverFont");
        pFont->Draw(GetFileNameFromFilePath(ConvertSeparatorsInPath(filePath + ".ogg")), Vector2(xOffset, yOffset + gScreenHeight - Dialog::Height - TabHeight + 3 - pFont->GetLineHeight()));
    }
#endif

    if (isInterrogation)
    {
        if (!pEvidenceSelector->GetIsShowing() && !evidencePresented && !pState->WasInterjectionOngoing())
        {
            if (!isPassive)
            {
                pPressForInfoTab->Draw(xOffset, yOffset);
                pPresentEvidenceTab->Draw(xOffset, yOffset);

                if (Case::GetInstance()->GetPartnerManager()->GetCurrentPartnerId().length() > 0 && pCurrentPartner->GetConversationAbilityName().length() > 0)
                {
                    pUsePartnerTab->Draw(0, yOffset);
                }
            }

            if (!isConfrontation || Confrontation::GetEnabledConfrontationTopicCount() > 1)
            {
                pEndInterrogationTab->Draw(xOffset, yOffset);
            }
        }
    }
    else if (pEvidenceSelector->GetIsShowing())
    {
        pEvidenceSelector->Draw(yOffset);
    }

    if (GetIsStarted())
    {
        Vector2 lineScreenPosition = Vector2(textAreaRect.GetX() + desiredPadding, textAreaRect.GetY() + desiredPadding);
        int curTextPosition = 0;
        TextColor curTextColor = TextColorNormal;
        deque<string> lines = split(GetString(), '\n');

        list<Interval>::iterator textIntervalEnumerator = textIntervalList.begin();
        Interval *pCurrentTextInterval = NULL;

        if (textIntervalEnumerator != textIntervalList.end())
        {
            pCurrentTextInterval = &(*textIntervalEnumerator);
            curTextColor = pCurrentTextInterval->Color;
            ++textIntervalEnumerator;
        }

        for (unsigned int i = 0; i < lines.size(); i++)
        {
            string line = lines[i];
            int curLineTextPosition = 0;
            Vector2 curScreenPosition = Vector2(lineScreenPosition.GetX(), lineScreenPosition.GetY());
            string lineRemainder = line;

            while (pCurrentTextInterval != NULL && pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition <= (int)lineRemainder.length())
            {
                string linePortionToDraw = lineRemainder.substr(0, pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition);
                lineRemainder = lineRemainder.substr(pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition);
                pDialogFont->Draw(linePortionToDraw, Vector2(curScreenPosition.GetX() + xOffset, curScreenPosition.GetY() + yOffset), GetColorFromTextColor(curTextColor));
                curScreenPosition.SetX(curScreenPosition.GetX() + pDialogFont->GetWidth(linePortionToDraw));
                curLineTextPosition += linePortionToDraw.length();

                if (textIntervalEnumerator != textIntervalList.end())
                {
                    pCurrentTextInterval = &(*textIntervalEnumerator);
                    curTextColor = pCurrentTextInterval->Color;
                    ++textIntervalEnumerator;
                }
                else
                {
                    curTextColor = TextColorNormal;
                    pCurrentTextInterval = NULL;
                }
            }

            pDialogFont->Draw(lineRemainder, Vector2(curScreenPosition.GetX() + xOffset, curScreenPosition.GetY() + yOffset), GetColorFromTextColor(curTextColor));
            lineScreenPosition.SetY(lineScreenPosition.GetY() + pDialogFont->GetLineHeight());

            // Add one for the carriage return character.
            curTextPosition += line.length() + 1;
        }
    }

    if (GetIsReadyToProgress() && !evidencePresented)
    {
        if (isInterrogation)
        {
            if (!pEvidenceSelector->GetIsShowing())
            {
                pInterrogationUpArrow->Draw(xOffset, yOffset);
                pInterrogationDownArrow->Draw(xOffset, yOffset);
            }
        }
        else if (!pEvidenceSelector->GetIsShowing() && !GetIsAutomatic() && !isStatic)
        {
            pConversationDownArrow->Draw(xOffset, yOffset);
        }
    }
}
// Get VLAN tag pass-through availability of all devices
bool EnumEthVLanWin32(RPC_ENUM_ETH_VLAN *t)
{
	UINT i;
	LIST *o;
	// Validate arguments
	if (t == NULL)
	{
		return false;
	}

	Zero(t, sizeof(RPC_ENUM_ETH_VLAN));

	if (MsIsWin2000OrGreater() == false)
	{
		return false;
	}

	if (IsEthSupported() == false)
	{
		return false;
	}

	// Get device list
	Lock(eth_list_lock);

	InitEthAdaptersList();

	o = NewListFast(CmpRpcEnumEthVLan);

	for (i = 0;i < LIST_NUM(eth_list);i++)
	{
		WP_ADAPTER *a = LIST_DATA(eth_list, i);

		if (IsEmptyStr(a->Guid) == false)
		{
			char class_key[MAX_SIZE];
			char short_key[MAX_SIZE];

			if (GetClassRegKeyWin32(class_key, sizeof(class_key),
				short_key, sizeof(short_key), a->Guid))
			{
				char *device_instance_id = MsRegReadStr(REG_LOCAL_MACHINE, class_key, "DeviceInstanceID");

				if (IsEmptyStr(device_instance_id))
				{
					Free(device_instance_id);
					device_instance_id = SearchDeviceInstanceIdFromShortKey(short_key);
				}

				if (IsEmptyStr(device_instance_id) == false)
				{
					char device_key[MAX_SIZE];
					char *service_name;

					Format(device_key, sizeof(device_key), "SYSTEM\\CurrentControlSet\\Enum\\%s",
						device_instance_id);

					service_name = MsRegReadStr(REG_LOCAL_MACHINE, device_key, "Service");
					if (IsEmptyStr(service_name) == false)
					{
						char service_key[MAX_SIZE];
						char *sys;

						Format(service_key, sizeof(service_key),
							"SYSTEM\\CurrentControlSet\\services\\%s",
							service_name);

						sys = MsRegReadStr(REG_LOCAL_MACHINE, service_key, "ImagePath");

						if (IsEmptyStr(sys) == false)
						{
							char sysname[MAX_PATH];

							GetFileNameFromFilePath(sysname, sizeof(sysname), sys);

							Trim(sysname);

							if (EndWith(sysname, ".sys"))
							{
								// device found
								RPC_ENUM_ETH_VLAN_ITEM *e = ZeroMalloc(sizeof(RPC_ENUM_ETH_VLAN_ITEM));

								StrCpy(e->DeviceName, sizeof(e->DeviceName), a->Title);
								StrCpy(e->Guid, sizeof(e->Guid), a->Guid);
								StrCpy(e->DeviceInstanceId, sizeof(e->DeviceInstanceId), device_instance_id);
								StrCpy(e->DriverName, sizeof(e->DriverName), sysname);

								// Get VLAN tag pass-through availability of the device
								GetVLanSupportStatus(e);

								// Get current pass-through setting of the device
								GetVLanEnableStatus(e);

								Insert(o, e);
							}
						}

						Free(sys);
					}

					Free(service_name);
				}

				Free(device_instance_id);
			}
		}
	}

	t->NumItem = LIST_NUM(o);
	t->Items = ZeroMalloc(sizeof(RPC_ENUM_ETH_VLAN_ITEM) * i);

	for (i = 0;i < LIST_NUM(o);i++)
	{
		RPC_ENUM_ETH_VLAN_ITEM *e = LIST_DATA(o, i);

		Copy(&t->Items[i], e, sizeof(RPC_ENUM_ETH_VLAN_ITEM));

		Free(e);
	}

	ReleaseList(o);

	Unlock(eth_list_lock);

	return true;
}
void LanguageScreen::Init()
{
    MLIScreen::Init();

    fadeOpacity = 1;
    pFadeInEase->Begin();
    pFadeOutEase->Reset();

    while (!finishedLoadingAnimations)
    {
        SDL_Delay(1);
    }

    pBackgroundVideo->Begin();

    pSelector->Reset();

    vector<string> localizedResourcesFilePaths = GetLanguageResourcesFilePaths();
    vector<LanguageSelectorItem *> languageSelectorItems;
    unsigned int selectedIndex = 0;

    SelectorSection *pSection = new SelectorSection("LanguageScreen/SelectLanguageText");

    for (string filePath : localizedResourcesFilePaths)
    {
        string fileName = GetFileNameFromFilePath(filePath);
        string languageName;

        if (ResourceLoader::GetInstance()->LoadTemporaryCommonLocalizedResources(filePath))
        {
            XmlReader localizableContentReader("XML/LocalizableContent.xml");
            LocalizableContent temporaryLocalizableContent(&localizableContentReader);

            languageName = temporaryLocalizableContent.GetText("LanguageName");

            ResourceLoader::GetInstance()->UnloadTemporaryCommonLocalizedResources();
        }
        else
        {
            continue;
        }

        languageSelectorItems.push_back(new LanguageSelectorItem(fileName, languageName));
    }

    sort(languageSelectorItems.begin(), languageSelectorItems.end(), &LanguageSelectorItem::CompareByLanguageName);

    unsigned int index = 0;
    for (LanguageSelectorItem *pItem : languageSelectorItems)
    {
        if (pItem->GetLocalizedResourcesFileName() == gLocalizedResourcesFileName)
        {
            selectedIndex = index;
        }

        pSection->AddItem(pItem);
        index++;
    }

    pSelector->AddSection(pSection);

    if (selectedIndex < pSelector->GetSection(0)->GetCount())
    {
        pSelector->SelectItem(0, selectedIndex);
    }
}