International Institute of Cricket Umpiring & Scoring
Dead ball alive?"I was batting when a delivery hit my bat and then landed in the top of my pad, where it came to rest. I believe that under those circumstances the ball becomes dead. So I fished it out and threw it back to the wicket-keeper. But, I wondered afterwards, if he had appealed, could I have been given out Handled the ball?"
No - and you've already answered your own question because, as you rightly say, the ball became dead the instant it lodged in your pad. But if the ball was still in play and you wilfully handled it, on appeal you would be given out in this way, And if you were to pick up and return the ball in play to a fielder without the fielding side's permission to do so, on appeal you would be given out Handled the ball
Note that prior to the amendment to the Laws in October 2010 you would have been out Obstructing the field.
Read more about Law 23.1 (Dead ball) at the MCC website