To get the full picture, play Kingdom Hearts 358/2 Days on the Nintendo DS. That game fills in this part of the story and also patches up several plot gaps between Chain of Memories and Kingdom Hearts II. Giving a more direct answer here would spoil the DS title, so experiencing it yourself is the better route.