Full access to the Direct3D device being used by 3ds Max can be retrieved using ID3D9GraphicsWindow::GetDevice(). For information on how to retrieve pointers to ID3D9GraphicsWindow, see the topic Determining DirectX Version.
It is the developer's responsibility to keep the state correct. You should use state blocks so that the Direct3D device can be returned to the state before the custom usage.