Status codes returned, Examples – Intel Extensible Firmware Interface User Manual
Page 169

Services — Boot Services
Version 1.10
12/01/02
5-71
If
NoHandles
is
NULL
, then
EFI_INVALID_PARAMETER
is returned.
If
Buffer
is
NULL
, then
EFI_INVALID_PARAMETER
is returned.
If there are no handles in the handle database that match the search criteria, then
EFI_NOT_FOUND
is returned.
If there are not enough resources available to allocate
Buffer
, then
EFI_OUT_OF_RESOURCES
is returned.
Status Codes Returned
EFI_SUCCESS
The array of handles was returned in
Buffer
, and the number of
handles in
Buffer
was returned in
NoHandles
.
EFI_INVALID_PARAMETER
NoHandles
is
NULL
EFI_INVALID_PARAMETER
Buffer
is
NULL
EFI_NOT_FOUND
No handles match the search.
EFI_OUT_OF_RESOURCES
There is not enough pool memory to store the matching results.
Examples
//
// The following example traverses the entire handle database.
First all of
// the handles in the handle database are retrieved by using
// LocateHandleBuffer().
Then it uses ProtocolsPerHandle() to retrieve the
// list of protocol GUIDs attached to each handle.
Then it uses OpenProtocol()
// to get the protocol instance associated with each protocol GUID on the
// handle.
Finally, it uses OpenProtocolInformation() to retrieve the list of
// agents that have opened the protocol on the handle.
The caller of these
// functions must make sure that they free the return buffers with FreePool()
// when they are done.
//
EFI_STATUS
Status;
EFI_BOOT_SERVICES_TABLE
*gBS;
EFI_HANDLE
ImageHandle;
UINTN
HandleCount;
EFI_HANDLE
*HandleBuffer;
UINTN
HandleIndex;
EFI_GUID
**ProtocolGuidArray;
UINTN
ArrayCount;
UINTN
ProtocolIndex;
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
UINTN
OpenInfoCount;
UINTN
OpenInfoIndex;
//
// Retrieve the list of all handles from the handle database
//
Status = gBS->LocateHandleBuffer (
AllHandles,
NULL,
NULL,
&HandleCount,
&HandleBuffer
);
if (!EFI_ERROR (Status)) {
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {