Yes, after Security but before Passport Control. I would allow an extra 30 minutes. For the sake of 200 baht, I would let them do the form and photo for you.
Make sure you use the entrance on the left, which clearly signposts Re-entry permits. The one on the right doesn't. You go through Security first, then get the permit before Passport Control. If you pay the 200 service charge, you only need your passport. They will do the form and photo for you.
Then you have no choice. But 4 pages is enough for a new visa or Extension. Then get the new passport and transfer the Extension. As Ron says, you can't transfer the visa, but it remains valid in your old passport.
Do you have to go back to the UK? It might be easier to sort out your nonB/Extension here, then get a new passport here. It's then straightforward to get the Extension transferred to your new passport.