rapid7/meterpreter — pull request #72 by OJ (2014-01-24 13:23:14+00:00)
Title: Update uses of CreateRemoteThread to use new create_remote_thread

As a result of work done in https://github.com/rapid7/meterpreter/pull/71 I thought it'd make sense to look at other areas of the code to see where the problem might be hurting us. Migration was the primary area of focus, but it turns out other areas benefit as well.

Migration attempts to use `CreateRemoteThread` before falling back to the APC migration approach. However, in Vista and later, the first approach always fails and APC is what makes it work.

This PR contains code which reuses the `create_remote_thread` function (with a couple of tweaks) in a few areas, including the migration code, resulting in the APC side of migration actually not being used at all (from what I can see in my testing).

There's also a few other changes in here around formatting.

### Verification

- [ ] Migration on all platforms, on x86, x64, and between the two.
- [ ] Creation of threads directly from meterpreter.
- [ ] Injection of code via meterpreter.

I'm tired, must sleep. Big day. Such Meterpreter. Much threads. So commits. Wow.