Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


token privileges

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 1:33 pm    Post subject: token privileges Reply with quote

I'm trying to make a function to change the token privileges of a process so that you can use PROCESS_ALL_ACCESS, but I have a problem. In the OpenProcessToken API it asks for a handle to the process, but the only way I can think of being able to get that is to call OpenProcess with any access (but PROCESS_ALL_ACCESS) and then pass the handle, then after the function close the handle and open it up again, but this time with PROCESS_ALL_ACCESS. But that doesn't seem, right, is there any other way to do it? Here's my code:

Code:

BOOL SetPrivilege(LPCSTR lpPrivilege) {
   HANDLE hToken;
   TOKEN_PRIVILEGES tp;
   LUID luid;
   if(OpenProcessToken(, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { //I left the first param blank because that's the one I'm having trouble with
      if(LookupPrivilegeValue(NULL, lpPrivilege, &luid)) {
         tp.PrivilegeCount = 1;
         tp.Privileges[0].Luid = luid;
         tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
         if(AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) {
            return TRUE;
         }
         return FALSE;
      }
      return FALSE;
   }
   return FALSE;
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Jul 04, 2008 2:20 pm    Post subject: Reply with quote

The first parameter is the process to set the privileges, call it with the first parameter being -1. (current process)
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 2:24 pm    Post subject: Reply with quote

That requires me to inject a DLL into a process and call this function and pass GetCurrentProcess(). I want to be able to do this just from a normal application.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Jul 04, 2008 2:49 pm    Post subject: Reply with quote

You want to change the current process privileges, so you can call OpenProcess with PROCESS_ALL_ACCESS from the current process, if you want to change another process's privileges, get the handle by calling OpenProcess, but if you get access denied then you still have to set the current process's privileges... Surprised
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Jul 04, 2008 3:51 pm    Post subject: Reply with quote

Oh, right. I just realized that you have to change the current process's privileges so that it can do whatever.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites