I recently asked how Starfleet sensors detect life signs and previously someone asked how Starfleet sensors receive information faster than light.
In the answers to my question (in the first link), there are references to points like watching for respiration and echoes or sounds. In the second link, there are comments about how subspace is used.
But this still leaves something open: How do the sensors actually work? Today we can "scan" things by radar or sonar or even lidar. But all of these involve sending out a beam (or a sound) and studying what comes back. In short, we have to work with reflected information.
But in The Enterprise Incident Checkov is able to find Spock on a Romulan vessel, where they would certainly be blocking any incoming electromagnetic beam that would be used for active scanning. Also, the Commander's quarters (or any quarters) are not likely to be directly up against the hull, where vibrations could be easily detected.
And when they're scanning a planet, that would mean the sensor beams (light, radio, or anything else in the EM spectrum) would have to be reflected back to provide information. That would mean that to scan a city, the sensors and computer would have to send out beams that detect and are reflected back by the outside of the building, but are also reflected back by the life forms in the building, as well as everything else in the building.
This would be true of scanning a spaceship, too. The sensor beams would either be reflected back by the hull or they'd penetrate. If they're powerful enough to penetrate the hull, then they'd go through a lifeform inside and not be reflected back.
So what do Starfleet ships use to read information about what is inside other ships or behind objects (like in buildings) or what's on the parts of a planet that aren't directly in their line of sight?