After you pull up the toliet, you normally need not disconnect the drain. But you will need to disconnect the flange that was under the toliet. It should have 2 or 4 screws removed then lifted off. You will naturally find what you call studs. (They are really referred to as floor joists,) as you remove the rotted floor. The thing is you must remove floor extending TO the joists so you will have support for your new floor. Regards.