private TpmHandle[] GetLoadedEntities(Tpm2 tpm, Ht rangeToQuery)
{
const uint maxHandles = UInt32.MaxValue;
ICapabilitiesUnion h;
byte moreData = tpm.GetCapability(Cap.Handles, ((uint)rangeToQuery) << 24, maxHandles, out h);
if (moreData != 0)
{
throw new NotImplementedException("Too much data returned");
}
if (h.GetType() != typeof (HandleArray))
{
throw new Exception("Incorrect type");
}
var handles = (HandleArray)h;
return handles.handle;
}