|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi
![]() I have this code in c++, and I want to gain full access over an application. Code:
HANDLE hToken; TOKEN_PRIVILEGES tkp; // Get a token for this process. if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE; // Get the LUID for the shutdown privilege. LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0); I want to convert this code to Pascal. All functions return true, but a call of GetLastError() just after AdjustTokenPrivileges() gives me an errorcode 1300 ( Not all privileges or groups referenced are assigned to the caller ). So what do I do wrong ? Here's my code ( in Pascal ) Code:
var hToken : handle; tp: TOKEN_PRIVILEGES; OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, @hToken); LookupPrivilegeValue( NULL, SE_DEBUG_NAME, @tp.Privileges[0].LUID ); tp.PrivilegeCount := 1; tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges( hToken, FALSE, @tp, sizeof(TOKEN_PRIVILEGES), 0, 0 ); GetLastError(); // <- Returns 1300 :/ I've compiled this code by using Dev-Pas v1.9.2.Last edited by Jophry; 01-03-2007 at 01:47 PM. |
| Sponsored Links |
|
|
|
|||||
|
Not seeing how AdjustTokenPrivileges or GetLastError are implemented, it's kind of tough to say.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code: Capture Code from USB Camera | MrNobody | VB Tutorials | 44 | 07-28-2008 07:29 PM |
| Basic Calculator | AfTriX | VB Tutorials | 3 | 02-29-2008 08:53 AM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 08:45 AM |
| Where to Put PHP Code | clookid | PHP Tutorials | 1 | 01-11-2007 08:44 PM |
| John | ........ | 203.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 63%