|
Encoding and Decoding UIB
This section sheds some light on the UIB data
encoding mechanism introduced in Windows Live Messenger
2009. For developers of Messenger Plus! skins, it is
purely informative and you won't miss anything by skipping it.
Other software developers however may be interested to learn more
about the mysterious "4010" resource type, what it's about and more
importantly, how to work with it.
UIB: What is that?
UIB is the acronym of... well, we honestly
don't know, and that alone sums-up the problem. The best guess we
could come up with is User Interface Blob but only a
developer of one of the Windows Live teams at Microsoft could give
you the real answer. This new data type appeared in Messenger in
one of the latest betas of 2008 and it now completely replaces the
old windows' definitions and styles types ("4004" and
"4005").
Many have speculated about the reasons
causing this change but speed-optimization was probably on top of
the list when Microsoft decided to do it. Previously, Messenger had
to parse 2 text files every time a different
window was open in Messenger. Parsing text was time consuming,
especially for some of the more complex windows as the program
needed to handle all sorts of syntax variations. A nice
side-effect, for add-on and patch developers, as well as skinners,
was that the plain text file was easy to modify to achieve all
sorts of visual results. Messenger Plus! itself relied on those
text files to add its buttons in various Messenger windows and to
let skin developers change the windows' structures.
In its latest releases, Messenger comes
bundled with an encoded version of the 2 text files previously
describing each window. These new files are kept in resource type
"4010" and are called UIB files by some people
because of the "UIB" tag that starts each and every file. Note that
it is important to make a difference between "encoded" and
"encrypted". The UIB files in Messenger are not encrypted and can
be understood with some research and patience, which is what was
done in Messenger Plus!.
How are UIB files handled by Messenger Plus!
?
Support for UIB files was added in Messenger
Plus! Live 4.80. Encoded files are automatically
decoded by the Resource Extractor when skinners need to
take a peek at what's inside Messenger. When the text files are
distributed in a skin, Messenger Plus! re-encodes them
automatically when a window is loaded. In order to make the
transition as smooth as possible for developers used to the old
system, Messenger Plus! produces decoded versions of the UIB files
that are almost identical to what used to be seen in Messenger 8.
The only noticeable difference is the <*PlusSkin */> line
that starts every file and gives Messenger Plus! some important
information regarding its origins. This will be mostly useful for
future versions of the UIB system and for that reason, that line
must be kept in place in all the files.
Like before, 2 text files are generated for
each window: a definition file and a style sheet file. Both are
required to re-create a UIB file, however, Messenger Plus! skins
are exempt of this restriction: when a skin is loaded, if either a
definition file or a style file is missing for one window,
Messenger Plus! decodes the internal UIB data to generate the
missing piece before re-encoding the whole thing. It slows things
down a little but this way, nothing needs to be changed in the way
you're used to write your skins. Also, because Messenger Plus! is
now in charge of all the parsing when encoding, the Skin Trace file now includes more detailed
information about errors encountered while loading a window. This
also allows Plus! to load the original version of the window in
case an error occurs, which is handy for end-users but means you
need to be extra-careful when doing changes in your skin. Always
check if a trace file has been generated after testing your skin
and you'll be fine.
This is all fine if you stay in the
environment provided by Plus! but what if you simply want to use
the encoding and decoding functionalities for your own
purposes?
Adding UIB encoding and decoding to your
software
The world of Messenger has always been full
of add-ons and patches of all kinds. Messenger Plus! was the first
one and there's no reason why it should be the last, at least not
so soon. Unfortunately, some of the changes brought by Windows Live
Messenger 2009 made us fear some programs wouldn't be able to
survive the upgrade. For that reason, we decided that UIB
encoding and decoding should be offered to everybody which
is what was finally done in Messenger Plus! Live 4.80.
A lot of work was necessary to create the two
fully-functional parsers that decode and re-encode the files. If
you're the developer of a program that changes Messenger's windows
files, you can let Messenger Plus! do the work without worrying
about it anymore. Two options are offered to you:
- If you need to make live changes to the
windows files, for example, when applying options selected by your
users at run time, your program will need to call
MPTools.exe on your users' computers to decode and
re-encode the file after it's been modified.
- If you only need to make static changes in
one particular version of Messenger and redistribute the result,
then you can use the same MPTools.exe program on your own computer
and distribute the re-encoded UIB file directly.
MPTools.exe is a program that's distributed
with Messenger Plus!. It makes all sorts of calls to the main
program for all kinds of reasons, it's a helper tool. Although it
was also distributed in previous versions of Messenger Plus!, it
was not meant to be used directly by end-users or other developers.
This is not the case anymore as MPTools.exe can now decode and
encode UIB files when the proper command line parameters are
used.
Here is an example of how to decode a UIB
file:
MPTools.exe /UIB=Decode /Src="C:\uibfile.uib" /Def="C:\deffile.txt" /Style="C:\stylefile.txt"
And here is another example of how to
re-create a UIB file:
MPTools.exe /UIB=Encode /Def="C:\deffile.txt" /Style="C:\stylefile.txt" /Dest="C:\uibfile.txt"
Pretty straightforward isn't it? When
decoding, the only input parameter that's needed is the UIB file
you'll have to extract from Messenger's own resources (resource
type "4010"). It can also be a UIB file that you previously
generated with this tool. The decoding process produces two text
files as specified in output parameters. If needed, only
/Def or /Style can be set to speed things up
(note however that you'll always need the two files to re-create a
UIB file).
When encoding, the two required input
parameters are the definition file and the style text file. These
files are subject to the same rules previously applied by Messenger
which means you should take great care when modifying them.
MPTools.exe, unlike skins loaded by Plus!, does not produce
detailed errors so don't hesitate to create a quick skin to make your life easier when
testing new ideas. The one single output parameter is, of course,
the name of the UIB file you want to be generated.
MPTools.exe is silent and will never prompt
anything to the user if the proper parameters are specified.
Fully-qualified paths should always be specified in the parameters
and existing files will be overwritten when needed. As far as
knowing the result of the operation, you have two ways to detect a
success:
- Check if the output file(s) were generated
(nothing is written on disk in case of failure).
- Verify the result code returned by the
program. A result between 0 and 9 (inclusive) means failure.
Results between 10 and 19 (inclusive) mean success.
Distribution
As mentioned above, you have the choice to
either distribute a pre-encoded version of the UIB file or make
live changes on your end-users computers. Rest assured that the UIB
files generated by Messenger Plus! Live are 100% compatible with
Messenger and do not require Messenger Plus! at all to be loaded.
The first option may look more appealing
to some as Messenger Plus! is not required on the end-user's
computer but keep in mind that this also means you'll need to
distribute updates of your program every time Microsoft changes the
way UIB files are encoded in Messenger.
Messenger Plus! Live is a widely distributed
add-on and its requirement shouldn't stop anybody from using your
program. If you chose to make live changes to the Messenger's
resources, check if Messenger Plus! is installed in your own setup.
You also need to check if the user is using a recent version of
Plus! that include UIB support. This can be done easily by checking
the SoftwareBuild value in HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\Messenger Plus!
Live. If the value is 4351 or
above, you're good to go!
MPTools.exe cannot and must not be
redistributed on its own. It depends on other files in the
Messenger Plus! directory to function properly. If Messenger Plus!
is not detected on the system (you can simply check if the registry
value mentioned contains a valid value), you may choose to do one
of the following:
- Invite the user to go to
msgpluslive.net to download the latest version of
Messenger Plus! Live.
- Download Messenger Plus!, launch the setup
and let the user complete the installation (recommended
way).
- Download Messenger Plus! and launch the
setup in silent mode to quickly and transparently install Plus! on
your users' computers. Make sure to display a notification while
doing so to keep things straight.
Note: when downloading Messenger Plus!,
always use http://download.msgpluslive.net/setup/MsgPlusLive-Setup.exe
to automatically get the latest public version of the software. It
is not recommended to bundle the setup directly but you're allowed
to do so if necessary.
Finally, when launching MPTools.exe, you have
to be careful of two things:
- Get the path where Messenger Plus! is
installed on the user's computer from the AppDir value in HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\Messenger Plus!
Live. Do not hardcode the path thinking it's always located
in Program Files. "MPTools.exe" will always be called by that name
though. As long as you load it from the proper directory, you'll
have no problem.
- Wait for the process to end before checking
the result. This may seem obvious but this is a common
mistake.
Summary
Skin developers working in Messenger Plus! do
not have to worry at all about what UIB is. For all the other
developers, we hope that the encoding and decoding functionalities
provided by our external tool will help keep your Messenger
projects alive and kicking. Don't hesitate to visit our forum if
you have any suggestion for improvements.
See Also
Specialized Subjects.
|