Obscure CreateRemoteThread Problem

Yesterday I spent several hours trying to finally figure out why my wsTaskborg application failed to work when run run in a second session on the same PC. That is, when you first log on – using whichever account you have – it works fine. If you then use “fast user switching” and log on as a different user, it wsTaskborg will start, but won’t be able to perform taskbar customization.

Long story short, I found that the core of the problem was CreateRemoteThread() failing with the error “Not enough storage is available to process this command”. The error message itself is bogus and has nothing to do with the actual problem. The actual cause of this behaviour is that CreateRemoteThread doesn’t work accross terminal sessions (this is by design). The only workaround I found mentioned on the Web is creating a new process in the corresponding session (using CreateProcessWithTokenW) and making that process call CreateRemoteThread. This seems tricky – I’d need to figure out how to get the correct token and there may be additional privilege problems (I’m not familiar with the security API). So unfortunately I’m not going to fix this issue anytime soon…

If anyone has implemented a workaround and/or has some source code I could look at, please let me know.

By the way, if you’re not trying to create a thread in a process in a different session and you still get this error message, it might indicate your process doesn’t have enough privileges. You may need to obtain the SeDebug privilege to be able to CreateRemoteThread() in a process.

Related posts :

One Response to “Obscure CreateRemoteThread Problem”

  1. [...] Wish I could do that. Actually, maybe I can… (if I can find a topic that’s not extremely obscure and manage avoid being needlessly eloquent while lacking essential syntax [...]

Leave a Reply