UEFI Add Boot Option programmatically - uefi

How can i write code which add boot option from UEFI driver programmatically?
1) I try to add "Boot0001" variable:
ZeroMem(Data, 2048);
StrCpy(Data, L"Boot0001");
DataSize = StrLen(Data) * 2;
Status = gRT->SetVariable(L"Boot0001", &dGuid, Attr, DataSize, &Data);
2) I need add entry to "BootOrder" variable. But i can't understand how.
Ideally, i want to add boot option boot from sample efi application.

To add something to UEFI boot list:
Create BootXXXX variable, it's format looks like this.
Change BootOrder variable, adding newly created option somewhere in the list.
You can find a working code snippet in UEFI shell sources.

How this works is described in the UEFI specification - available without payment from the UEFI Forum. The current version is 2.4B.
The BootOrder variable mechanism (among other things) is described in section 3.2 - Globally Defined Variables, but I'll give a brief summary.
It is an array of UINT16 elements in the order of the preferred boot order. The UINT16 value is the number portion of your Boot#### variable name. So to rank options Boot0001, Boot0002 and Boot0003 in reverse order of preference, your BootOrder variable should contain (hex, ignoring endianness) 000300020001.
It also needs to have Non-Volatile, Boot-services and Runtime-services attributes set (as described in table 11 in that chapter).

Related

Where to find "Log Dyld API Usage" and "Log Library Loads" on XCode 11?

I want to disable the printing of Logging Dynamic loader events (dyld) in the XCode console. I found a solution here.
But I couldn't find Log Dyld API Usage and Log Library Loads options in product scheme diagnostics of XCode 11. Please help me find them.
PS: If there is a new process in Xcode11 for disabling logs, please let me know.
Answer: This step by step solution is suggested below in the answers. I am just attaching this picture for a better understanding.
Dynamic loader
Events environment variables
One would say that you can set environment variables like DYLD_PRINT_APIS=0, DYLD_PRINT_APIS=false, DYLD_PRINT_APIS=no, ... but it doesn't work in this way. Check the source code:
else if ( strcmp(key, "DYLD_PRINT_APIS") == 0 ) {
gLogAPIs = true;
}
In other words gLogAPIs is true when the variable exists. You can set it to whatever value, keep it empty, it will be always enabled if the variable exists.
Xcode scheme
UI for this setting is gone in the Xcode 11, but it can still be in the scheme file. Let's say that you have a simple project Foo. The scheme is located at Foo/Foo.xcodeproj/xcshareddata/xcschemes/Foo.xcscheme1). It's a XML file. Quit Xcode and open this file in any editor and search for the LaunchAction element.
There will be:
LaunchAction element attribute like enableAddressSanitizer = "YES"2) or
DYLD_... environment variable set.
Just remove this attribute/environment variable and you should be fine.
1) The exact path can vary, because it the scheme can be included in the workspace, project, ...
2) I don't have a previous version (10) of Xcode installed, can't check for the exact name, but it should be there and it will be obvious which one it is. This one, I used, is for the Address Sanitizer checkbox. If you find the exact name, let me know and I will update this answer or answer it yourself and I'll delete this one.
Update
Instructions above helped OP to find exact XML element names. One has to remove:
LaunchAction/AdditionalOptions/AdditionalOption elements
where the key is either DYLD_PRINT_LIBRARIES and/or DYLD_PRINT_APIS

Is it possible to get shell properties for an item not in the shell namespace?

Short Version
How does the shell get the properties of a file?
Long Version
The Windows Shell exposes a rich system of properties about items (e.g. files and folders) in the shell namespace.
For example:
System.Title: A Quick Guide for SQL Server Native Client OLE DB to ODBC Conversion
System.Author: George Yan (KW)
System.Document.LastAuthor: rohanl
System.Comment: To learn more about this speaker, find other TEDTalks, and subscribe to this Podcast series, visit www.TED.com Feedback: tedtalks#ted.com
System.ItemParticipants: George Yan (KW)
System.Company: Contoso
System.Language: English (United States)
System.Document.DateCreated: 6/‎10/‎2014 ‏‎5∶16∶30 ᴘᴍ
System.Image.HorizontalSize: 1845 pixels
System.Image.VerticalSize: 4695 pixels
System.Image.HorizontalResolution: 71 dpi
System.Image.VerticalResolution: 71 dpi
In order for the shell to read these properties, it obviously has to use a lot of sources:
Windows Media Foundation IMFMetadata works great for images and movies
Windows Imaging Component (WIC) probably has a lot of APIs for reading metadata
I'm not sure if IFilter can retrieve Title, Author, Subject, Comments etc from Office documents
Either way, it has to read the file contents stream and do something with the contents of the file in order to get all these fancy shell properties. In other words:
IStream \
+ |--> [magic] --> IPropertyStore
.ext /
Can use it with my own stream?
I have items that are not in the shell namespace; they are in a data store. I do expose them to the shell through IDataObject as CF_FILEDESCRIPTOR with an IStream when its time to perform copy-paste or drag-drop. But outside of that they are just streamable blobs in a data store.
I'd like to be able to leverage all the existing work done by the very talented and hard-working1 shell team to read metadata from a "file", which in the end only exists as an IStream.
Is there perhaps a binding context option that lets me get a property store based on an IDataObject rather than a IShellItem2?
So rather than:
IPropertyStore ps = shellItem2.GetPropertyStore();
is there a:
IPropertyStore ps = GetShellPropertiesFromFileStream(stream);
?
How does the shell get all the properties of a file?
Bonus Chatter - IPropertyStoreFactory
This interface is typically obtained through IShellFolder::BindToObject or IShellItem::BindToHandler. It is useful for data source implementers who want to avoid the additional overhead of creating a property store through IShellItem2::GetPropertyStore. However, IShellItem2::GetPropertyStore is the recommended method to obtain a property store unless you are implementing a data source through a Shell folder extension.
Tried
IPropertyStore ps = CoCreateInstance(CLSID_PropertyStore);
IInitializeWithStream iws = ps.QueryInterface(IID_IInitializeWithStream);
But CLSID_PropertyStore does not support IInitializeWithStream.
Bonus Reading
MSDN: Initializing Property Handlers
Property handlers are a crucial part of the property system. They are invoked in-process by the indexer to read and index property values, and are also invoked by Windows Explorer in-process to read and write property values directly in the files.
MSDN: Registering and Distributing Property Handlers (spellunking the registry for fun and reading contracts from the other side)
(Have some experience in Property Store handlers) How I see a solution:
Get PropertyStore handler CLSID for your file extension. You should use 2 regkeys key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers\.yourext
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\SystemPropertyHandlers
Create two objects with CoCreateInstance
If you have 2 object you can combine them into single object with PSCreateMultiplexPropertyStore
Query for IInitializeWithStream (also you can try to query IPersistStream).
If the PropertyStore object supports IInitializeWithStream/IPersistStream: you are lucky - just init your object and query the properties you need. If does not - you still have (dirty) variant to create temporary file and then use IPersistFile.

How do I programmatically set the length of Most Recent Used files in Eclipse

In Eclipse, I'm aware of the Preference setting for the number of recently opened files to offer:
For users of my RCP application I'd like to change the default length from 4 to 10.
I'm aware of the PreferenceManager, and can navigate to the correct node using this:
IPreferenceNode editorPrefs = preferenceManager.find
("/org.eclipse.ui.preferencePages.Workbench/org.eclipse.ui.preferencePages.Editors");
But, once I've found the node, I can't see how to access the specific property, in order to modify a value.
Anyone one done this before? Any tips?
Alternatively, I'm happy to do it via extension-point, but I couldn't get even this far via that mechanism.
This preference is set in the preferences for the org.eclipse.ui.workbench plugin. You can access this using ScopedPreferenceStore
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.workbench");
The key for recent files is RECENT_FILES so:
store.setValue("RECENT_FILES", value);
You may need to call the save() method to store the changes.
Note: it should also be possible [1] to update the preference from the .ini file. But it didn't work for me.
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=128411#c2

IUIAutomationValuePattern SetValue has no effect

I am using MS UIAutomation in C++ to control a third party WPF application. I can read the value of an edit control (IUIAutomationElement objects). When I try to set the value with SetValue (IUIAutomationValuePattern objects) it does not return an error, but does not set the value of the edit control.
The manifest contains , the application is signed and is run from C:\Program Files.
I experienced that some UI Elements do not implement the UI Automation Provider correctly, as a result some patterns do simply not work as expected or even fail (although they are shown available).
To verify that the object is corrupt and not your code you could use the ValuePattern via Inspect.exe. Open Inspect -> select the control -> Action (Toolbar) -> ValuePattern.setValue
As a workaround I would suggest you to use SendKeys. If you need to focus the element first, yourAutomationElement.setFocus() is your friend. If setFocus does not work get the ClickablePoint/BoundingRectangle of the AutomationElement and use user32.dll in order to click the object.

Query with toLocalizedTime in Plone

I'm using toLocalizedTime to output a date, as below
<span tal:content="python:here.toLocalisedTime(date.get('start_date'))"/>
This outputs eg. 2007/08/02, I'm just curious as to how one would alter the output so that it reads 02/08/2007
I'm not having much luck finding much info on toLocalizedTime, would someone point me in the right direction?
This depends on whether you have English selected as the site language (Site Setup >> Language). If so, then the default settings are used. You can change the defaults by dropping down into the ZMI, then into 'portal_properties', then 'site_properties'. The fields to change are either 'localTimeFormat' or 'localLongTimeFormat' depending on whether you pass in 'long_format=1' to the toLocalisedTime function.
If on the other hand, you have translations set up, the format may instead be pulled from the translation file for the locale selected. I'm not sure what is the easy way to change the format in this case (other than switching the site back to English). I guess you can register your own translation file but I've never needed to do that so you're going to have to look up the details.
Date string formatting follows the Python rules (http://docs.python.org/library/time.html#time.strftime).
Perhaps even more detail than you need:
here.toLocalizedTime()
is defined in the plone browser view at...
CMFPlone/browser/ploneview.py
which looks up the 'translation_service' utility, to call its 'ulocalized_time' function, defined at...
CMFPlone/TranslationServiceTool.py
which itself calls the 'ulocalized_time' function defined at...
CMFPlone/i18nl10n.py
As always, you can learn interesting things by grepping the source code ;-)
For an up to date answer for Plone 4.3 (after going through the source code)
These fields are now in the registry found at:
http://localhost:8080/yoursite/portal_registry
Then filter on "i18nl10n", which should give you the 4 fields you need to change.