Grade: B-

Everything that can go wrong with a trashy thriller was demonstrated all too well by the recent “Perfect Stranger,” but happily we’re now treated to a slick, silly but clever serial-killer picture that redresses the balance—in part, at least. “Mr. Brooks” is pretty much pulpy junk, but for more than half the time it’s fun trash. As for the rest, well, as in life you have to take the bad with the good, and in this case it’s worth doing so.

The savory center of the movie is the story of the titular character, played by Kevin Costner. Earl Brooks is a successful Portland businessman who’s just been feted as the city’s man of the year. He also has a lovely wife, Emma (Marg Helgenberger, of “CSI”). But he also has a secret. He’s the notorious “Thumbprint Killer” who, up until two years ago, had been responsible for shooting couples and leaving behind their bloody prints as a signature. He’s been able to stifle his murderous urge through attendance at AA meetings, but now, egged on by his evil alter-ego Marshall (William Hurt), he decides to indulge himself one last time. Unfortunately, he’s a bit out of practice, and allows a peeping tom neighbor who calls himself Smith (Dane Cook) not only to spy him doing the deed but to photograph him in the act. Rather than turning him in or asking for cash to keep quiet, though, the thrill-seeking young guy demands something else—for Brooks to take him along on his next kill.

This part of Bruce A. Evans’s picture is a good, creepy B-movie fodder, with Costner putting his own hesitant, not-quite-natural persona to surprisingly good use as the almost obsessively organized guy who’s barely able to keep his murderous impulses at bay. He also builds good camaraderie with Cook, a stand-up comedian who’s bombed in comedies like “Employee of the Month” before now but whose callowness fits this character perfectly. The real key to the winning hand played by this part of the picture, though, is the routine that Costner and Hurt fashion together—a give-and-take in which the former can loosen up and the latter once again play to the rafters in the vein of his turn in “A History of Violence.” Hurt has finally shed the serious-actor attitude he’d long been saddled with and given free rein to his histrionic, Grand Guignol impulses, and as a result he’s far more fun to watch than he used to be—and Costner actually matches him note for note. As a result the contrived “internal conversation” gambit employed by Evans and his co-writer Raynold Gideon, which shouldn’t work at all, not only does, but becomes the chief reason why “Mr. Brooks” is so engaging: it’s a big advance on their previous collaboration, the awful Christian Slater bomb “Kuffs” (1992).

It’s a pity that the other half of the movie—the one on the right side of the law—isn’t nearly as strong. Demi Moore, of all people, plays the tough-as-nails detective on Mr. Brooks’s trail. But her character, Tracy Atwood, is saddled with tons of backstory that’s supposed to be fun but frankly isn’t. One aspect of it has to do with the fact that she’s independently wealthy—hell, a multi-millionaire, no less. (Why she’s a cop, despite all the cash, is revealed at the close, in a bit of sappy psychobabble.) Another has to do with the fact that her hunky trophy husband Jesse Vialo (not, unfortunately, played by Ashton Kutcher—it’s one Jason Lewis) is suing for divorce and, along with his slinky, skanky lawyer (Reiko Aylesworth), demanding a huge settlement. And a third has to do with a vicious killer she put in prison who’s escaped and is now looking for revenge. (She also has to deal with a comic-relief partner named Hawkins, played by Ruben Santiago-Hudson.)

To be sure, all these elements are necessary for the twist-upon-twist climaxes that Evans and Gideon have contrived for the last act, but to be honest they’re pretty boring to watch, as well as leading to sequences that are so rote that one can only hope they’re intended as parody (e.g., a divorce-settlement discussion and a scene in which the cop’s boss, played with a straight face by Lindsay Crouse (which must have been difficult), actually gives her three days to wrap up the case before bringing in the FBI!). It’s worth sitting through them just to get back to Costner, Hurt and Cook, but one can only imagine how much better “Mr. Brooks” would have been had the shamus been as interesting as the villain—or even as nearly so as the lawyer played by Richard Gere was in comparison to his client, played by Edward Norton, in “Primal Fear,” the kind of great trash this movie obviously aspires to emulate.

The picture even blunders in the Brooks section by adding a subplot about the Earl’s daughter Jane (Danielle Panabaker, from “Shark”), who returns home pregnant having quit college. One can understand the rationale behind this plot thread—remember “The Bad Seed”?—especially because it allows for yet another big moment in the script’s series of climaxes (though an especially cheesy one, to be honest). But that doesn’t stop it from seeming like padding.

Still, though it’s not as smooth as it might have been and by the close has gotten too clever by half, this trashy thriller delivers the goods more often than not. It boasts a solid production, with evocative cinematography by John Lindley and uniformly fine behind-the-camera work. And the score by Ramin Djawadi is adequate, if hardly extraordinary for this sort of fare—no Herrmann or Desplat he, but a decent craftsman.

But it’s the dance between Costner and Hurt that raises “Mr. Brooks” into the delectably decadent category. They’re no Astaire and Rogers, but their pas de deux is still a treat.