If the gun and powder flask were not exposed to flame, they would likely survive. Smoke, fumes, and steam (if there were an effort to fight the fire) would rust the gun but it would not be unsalvageable. If the powder were tightly capped it would not be affected.
From under a hearthstone or out of a root cellar would be a plausable way to recover gun and ammo after a fire.
I have done it!
My house burned, not to the ground but a total loss due to its old style construction and the intensity of the gas-fed fire.
My guns were about the only thing recovered. The ones out of the safe were very finish damaged but salvageable. The ones in the safe were fine.
Fixed ammunition was damaged, misfire rates run from 5 to 40% depending on caliber, brand, and location.
Cans of powder thrown out the window by a fireman are fine.
Primers in factory tray, box, and sleeve are fine.
I have on my new mantelpiece a discolored can of Goex FFFg and a blackened bottle of Jameson's Irish whisky. The contents of both are fine. The Irish was tested 100%.
They were in a cabinet where they were shielded from flame but not smoke and at least some heat. The cabinet door was scorched but not penetrated. It is obvious why wood boxes and cabinets are recommended for powder and ammo storage.
Maybe even a cedar chest would be protection enough for the gun and powder, if you can describe a fire that did not burn it up.