To add just a little to Mac's answer, treat 'who' and 'whom' in exactly the same way as you treat 'he' and 'him' or 'she' and 'her'. So, "He kicked the ball"...ie 'he' is the one doing the action of kicking...compared with "The dog bit him"...ie the person is the one having the action of biting done to him. Thus, "Who gave you this?" as compared with "By whom was this given to you?"
To take this a little further, one thing that gets up my nose is so many people - including professional journalists who, one may think, would know better - saying "I" instead of "me". Example - "Answers to this question have been provided by Quizmonster and I" instead of "me". As with who and whom. it's a case of mixing up subject and object.