How to find the data direction register given a port address?
If you look at the register map for the ATmega328 the DDR address is always one less than the port address so that is trivial to calculate.

It may not be the same for other Arduino processors. You may need to have a table that is accessed by the processor type - that should be available at compile time.