0

Hi I'm a beginner in learning UEFI and trying to find out the logic of using protocols.

I've read the source code of CoreOpenProtocol, CoreCloseProtocol and CoreLocateProtocol.

What I've found that while CoreOpenProtocol will create a OPEN_PROTOCOL_DATA structure and linked into PROTOCOL_INTERFACE->OpenList, CoreLocateProtocol does not create such structure.

CoreCloseProtocol will actually delete the OPEN_PROTOCOL_DATA from PROTOCOL_INTERFACE->OpenList and free the memory that it took.

So since CoreLocateProtocol do not create OPEN_PROTOCOL_DATA, the close procedure seems meaningless.

Is that true?

Thanks a lot!

Shore
  • 827
  • 9
  • 24
  • 1
    It's better to base such a conclusion on the UEFI spec, rather than from reading the code. It is my understanding that it is unnecessary to close handles returned by LocateProtocol, and I don't close them in my code. I thought this understanding was based on a statement in the UEFI spec that it isn't required, but I can't find any such statement. However, the description of CloseProtocol says that it closes a handle "that was previously opened with OpenProtocol", which implies that it shouldn't be used for a handle that was obtained otherwise. – prl Sep 02 '20 at 08:15
  • @prl Thanks a lot. I looked at the spec and found what you've stated. would you like to post this as answer and I'll accept it. Thanks again – Shore Sep 02 '20 at 08:30

0 Answers0