I'm not a lawyer, so don't take what I say as fact.
It probably doesn't matter, so long as you're not trying to make money off of it. I see a ton of guides/codes/faqs available on Gamefaqs.com, yet that site hasn't been shut down, even though people write a ton of guides for games there (computer or console. The forums there, on the other hand, can get quite childish at times, but that's another issue hehe).
Chances are you probably won't get sued for writing it, but also don't charge money for it (unless you're working for a legitimate game guide publishing company, like Bradygames or Prima) or you could face some legal action.
If you are trying to make money off of it though, yeah, you may want to contact the publisher of the game to try and get those rights (again though, if there is ever a guide made, it's probably already done via Bradygames or Prima, so you're best bet is to contact them and try to get a job there).
I have to say though, sometimes their info is horribly inaccurate (at least when it comes to massive multiplayer online games, or MMO's such as World of Warcraft or Everquest. For those, I'd stick to online sources, as they're more up to date), so make sure you know a lot about that game (although usually the company making the game will tell you stuff so you can put it into the book as well. After all, it's not a very useful guide if the book doesn't tell you how to solve that puzzle in the game lol).