Combine sugar and cornstarch in a saucepan. Stir in the milk. Cook over medium heat until thick and bubbly, about 10 minutes, stirring occasionally. Cook 2 minutes more.
Gradually stir 1 cup of the milk mixture into the egg yolks. Add the egg mixture to the milk mixture. Bring to a gentle boil, reduce heat; cook and stir 2 minutes more. Remove from heat; stir in butter and vanilla. Pour pudding into a bowl and cover with plastic wrap pressed directly onto the surface. Place bowl in refrigerator and chill at least 1 hour.
Layer pudding, vanilla wafer cookies, sliced bananas, and whipped topping evenly in six 8-ounce glasses or cups, repeating layers once. Top with a vanilla wafer.