Use an ADS client that is connected to the EtherCAT masters AmsNetId and Port number 65535.
Prepare a byte buffer[] that has a length that is equal to 2*ConfiguredSlaveCount. (2 is the size of ST_EcSlaveState).
If you don't know your configured slave count you can read it as an uint from the same ADS client at index group 0x6 subIndex 0x0.
Do a Client.Read operation supplying this buffer to index group 0x9 and subIndex 0x0. Your buffer will be filled with data that describes an ST_EcSlaveState for each of your configured slaves. A description of the struct can be found here: https://infosys.beckhoff.com/english.php?content=../content/1033/tcplclib_tc2_ethercat/57122443.html&id=