title: OpenThreadToken() error 1008, ERROR_NO_TOKEN
body: <p>and, first of all, I'm sorry if it's a noobie problem, I'm just a initiate on this kind of things.<br>
  I'm trying to read from the memory of the MineSweeper to learn that kind of stuff, but I have a little problem.<br>
  When I try to print the modules it says to me I have no rights to do that. I know that's because the memory of that process is protected from write-read, and to read from it, I need to have debug rights.<br>
  And right there, my problem is when I call the OpenThreadToken(..), it fails with code 1008, and that's ERROR_NO_TOKEN.<br><br>
  Here you are the code, and sorry for the long intro: <br></p>
  
  <pre><code>int privileges(){
  HANDLE token;
  TOKEN_PRIVILEGES tp;
  DWORD siz = sizeof(TOKEN_PRIVILEGES);
  
  if (OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
  FALSE, &amp;token) != 0){ //HERE IT FAILS
      LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &amp;tp.Privileges[0].Luid);
      tp.PrivilegeCount = 1;
      tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
      if (AdjustTokenPrivileges(token, 0, &amp;tp, siz, NULL ,NULL) != 0){
          cout &lt;&lt; "--Conseguido acceso debug.\n";
          return TRUE;
      }
      else {
          cout &lt;&lt; "fail adjust\n";
          return FALSE;
      }
  }
  else {
      cout &lt;&lt; "fail if: " &lt;&lt; GetLastError() &lt;&lt; endl;
      cin.get();
      return FALSE;
  }
  </code></pre>
  
  <p>I don't know why it fails. I've tried with the Microsoft example too, but same problem.<br>
  Does anybody know why it fails?<br></p>