Trees that have been dead for some time, attract a variety of decay organisms and insects that will live within the dead tree. I would suspect that the "worms" you found were the larvae stage (grub like in appearance) of a large beetle and not really a worm. The larvae eat decaying wood. They will pupate later in the summer and emerge next year. Insects like this along with the decay fungal organisms are taking advantage of a situation that already exists, and are not the cause of the tree's death.
Sincerely, Richard Hentschel