SetDebugPrivileges() Problems. menu

User Tag List

Results 1 to 10 of 10
  1. #1
    Unkn0wn0x's Avatar Member
    Reputation
    6
    Join Date
    Aug 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SetDebugPrivileges() Problems.

    Hello community,

    ive got a huge problem and i hope to find help. If you can help me you get +Rep.

    First i want to excuse for my poor english, im from Germany.

    Since i'm in my education i started developing all my Bots and other Tools in use of Qt Framework and C++. Before i used Autoit and C#.

    I used a long time BlackMagic (Shynds Libary) to read from the Process and the other stuff.

    Now i develop on C++ and i've coded my own Libary which works fine. Ive got an Aion Bot which works. The last two days i started coding a WoW Bot again and everythink works great if I start my Bot under Debug Mode from Visual Studio (which is started as administrator).

    If i try to compile my bot on release mode it works but it crashes if it wants to Open Process.

    I use for Open Process this function:

    Code:
    hProc = OpenProcess(PROCESS_ALL_ACCESS/*PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION*/, FALSE, aProcessId);
    (Tried it with the PROCESS_ALL_ACCESS and the other one )

    Ok i get the error 5 from GetLastError() which tells me that "Access denied".

    So i searched the forums here and found that I have to use SetDebugPriviles() with that it works (only under Debug Mode) on Release Mode i cannot get my Bot to work.

    My OS: Windows 7 x86 Professional

    Ps: the set debug privilge:

    //-----------------------------------------------------------------------------
    void SetDebugPrivileges()
    {
    void* tokenHandle;
    OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle);
    TOKEN_PRIVILEGES privilegeToken;
    LookupPrivilegeValue(0, SE_DEBUG_NAME, &privilegeToken.Privileges[0].Luid);
    privilegeToken.PrivilegeCount = 1;
    privilegeToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(tokenHandle, 0, &privilegeToken, sizeof(TOKEN_PRIVILEGES), 0, 0);
    CloseHandle(tokenHandle);
    }


    Greatings,

    Unkn0wn0x

    SetDebugPrivileges() Problems.
  2. #2
    darrensmith0125's Avatar Member
    Reputation
    18
    Join Date
    Apr 2009
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try:

    Control Panel->System security->Change user account control settings. Set to Never notify.

  3. #3
    tanis2000's Avatar Active Member
    Reputation
    39
    Join Date
    Feb 2009
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a stupid question first of all: are you calling your void SetDebugPrivileges() in Release Mode?

  4. #4
    Unkn0wn0x's Avatar Member
    Reputation
    6
    Join Date
    Aug 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    Here's a stupid question first of all: are you calling your void SetDebugPrivileges() in Release Mode?
    Yes i do. First i didnt and it doesnt work. Now i do and it does not work, too.

  5. #5
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are sure you explicitly run your application with administrative rights?

    And did you ever check if a function inside your SetDebugPrivilege() function fails?

    Exceptions are a nice way to cover this. I do it like this in my lib:

    Code:
    	void Process::AddLocalDebugPrivileges_() const
    	{
    		HANDLE hToken;
    		SafeHandle ensureClosure(hToken);
    		if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
    			throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : OpenProcessToken() failed");
    
    		TOKEN_PRIVILEGES tp;
    		if(!LookupPrivilegeValueA(NULL, "SeDebugPrivilege", &tp.Privileges[0].Luid))
    			throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : LookupPrivilegeValueA() failed");
    
    		tp.PrivilegeCount = 1;
    		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    
    		if(!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
    			throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : AdjustTokenPrivileges() failed");
    	}
    Hey, it compiles! Ship it!

  6. #6
    Unkn0wn0x's Avatar Member
    Reputation
    6
    Join Date
    Aug 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by flo8464 View Post
    You are sure you explicitly run your application with administrative rights?

    And did you ever check if a function inside your SetDebugPrivilege() function fails?

    Exceptions are a nice way to cover this. I do it like this in my lib:

    Code:
        void Process::AddLocalDebugPrivileges_() const
        {
            HANDLE hToken;
            SafeHandle ensureClosure(hToken);
            if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
                throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : OpenProcessToken() failed");
    
            TOKEN_PRIVILEGES tp;
            if(!LookupPrivilegeValueA(NULL, "SeDebugPrivilege", &tp.Privileges[0].Luid))
                throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : LookupPrivilegeValueA() failed");
    
            tp.PrivilegeCount = 1;
            tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    
            if(!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
                throw std::runtime_error("Process::AddLocalDebugPrivileges_ Error : AdjustTokenPrivileges() failed");
        }
    Hello flo,

    sure I run my Bot on Administrator Mode and i used certain functions to add the privileges some with result, some without. I cannot get it to work.

    I also tried Cyphers method open the Process which is nearly the same. Same effect. On debug mode it works. On release mode it cannot opens the process.

    It seems that the SetDebugPrivilegs() doesnt work on release build for me.

  7. #7
    Unkn0wn0x's Avatar Member
    Reputation
    6
    Join Date
    Aug 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved with adding some Debug Options to the Release Build. Dunno if this was the right way to solve it.

  8. #8
    Flowerew's Avatar Master Sergeant
    Reputation
    72
    Join Date
    Oct 2009
    Posts
    134
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should take a look at Windows Privileges Issues !! VC Tips++ though I don't know if this is really what you're looking for...hope it helps.

  9. #9
    tanis2000's Avatar Active Member
    Reputation
    39
    Join Date
    Feb 2009
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Unkn0wn0x View Post
    Solved with adding some Debug Options to the Release Build. Dunno if this was the right way to solve it.
    Which options did you add?

  10. #10
    Unkn0wn0x's Avatar Member
    Reputation
    6
    Join Date
    Aug 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    Which options did you add?
    Multi Debug Thread DLL :P

Similar Threads

  1. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  2. realm list problem
    By robtuner in forum World of Warcraft General
    Replies: 2
    Last Post: 07-21-2006, 09:08 AM
  3. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
  4. wow emu problem
    By bezike in forum World of Warcraft General
    Replies: 0
    Last Post: 07-09-2006, 04:45 PM
  5. Site problems
    By Shanaar in forum Community Chat
    Replies: 10
    Last Post: 05-14-2006, 01:15 AM
All times are GMT -5. The time now is 03:51 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search