A children's book (or perhaps Young Adult) by Terry Pratchett. It is written in the style of his Discworld books, or Good Omens, although it is science fiction, not fantasy.
Johnny Maxwell is your average kid, although he has some odd friends... One of these friends is Wobbler Johnson, an expert cracker (he would have you believe) whose main hobby is pirating computer games*. The latest on the list of Wobbler's informally distributed games is Only You Can Save Mankind -- a classic shoot-the-alien-spaceships game. Only this time the aliens try to surrender**. Johnny does allow the ScreeWee to surrender (more out of confusion than anything), and agrees to give them safe conduct to their home planet. He soon finds himself popping in and out of the game's universe, trying to protect the ScreeWee -- shooting down the other gamers (strangely, this is not a network game), or better yet, convince them to help***...
Some kid getting pulled into a computer game is a rather overdone concept, but Terry Pratchett adds in some new stuff. First off, it is extremely funny -- lots of cynical wit and general Pratchettian humour. Johnny is also faced with deep moral questions; this story takes place at the same time as the first Gulf war, and Johnny finds himself asking questions like "what is our moral relationship to our enemies?", "what rights do we owe them?", and "when is it 'okay' to kill and when is it important not to kill?". Fortunately, these questions don't get in the way of the story, or the humour.
A very good book, and any Pratchett fan should read it (along with the rest of the Johnny Maxwell Trilogy), no matter what their age.
Published by Doubleday in 1992 (Hardcover), and Corgi in 1993 (Paperback).
This is the first book of the Johnny Maxwell series; the next two are Johnny and the Dead and Johnny and the Bomb.
* "Basically, there were two sides to the world. There was the entire computer games software industry engaged in a tremendous effort to stamp out piracy, and there was Wobbler. Currently, Wobbler was in front".
... "One day, the world would hear from Wobbler Johnson -- probably via a phone-line it didn't know was connected to its computer".
** "Johnny fired the laser one more time. Swsssh. He didn't really know why. It was just because you had the joystick and there was the Fire button and that was what it was for.
After all, there wasn't a Don't Fire button".
*** On Earth, No-one Can Hear You Say "Um"
"How do I know you're not some sort of maniac?"
"Do I sound like some sort of maniac?"
"All right, but apart from that?"
"Can't see them ever selling a game called Get Shot to Pieces."
I am debating over whether or not including quotes, in this format, is a Good Thing or a Bad Thing. Let me know what you think, your feedback can influence future WUs.