Using AcDbDatabase::readDwgFile(), you read several drawings into memory. With ads_entget() you try to get a resbuf of some DXF-values. But for most databases it returns NULL, while returning the correct value for some random databases. If ads-functions can be used on in-memory drawings, how do you direct the function to the correct drawing?
The short answer is, you cannot.
Some ADS functions might work with objects in other databases in some circumstances, but that is not by design. Therefore, you should not rely on of ADS style functions in such a case.
If you want to work on objects in databases that are not loaded into the AutoCAD editor, then you cannot safely use the ADS functions; you'll need to usenon-ads functions such as the methods in the various AcDb classes.