She had learned about this incarnation of the Room of Requirement while trying to investigate the attacks last year. Everyone was sure that what was going on was Dark Magic, and Hermione did not want to be caught in the Restricted Section reading Dark Arts material—it was her plan to become Head Girl—so she went to the seventh floor and asked the Room for the books. It had produced them. The Room apparently held enough banned books to stock a separate Dark Arts library, a secret second library in the castle.