Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Too FEW Arguments in BOOL?

Too FEW Arguments in BOOL?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rbwest86
    wrote on last edited by
    #1

    Ok, heres what should happen. The program should return the value's of the access token of the current user. What is wrong with this picture? I believe I need to relate SetPrivilege to a string. So later on I can use cout SetPrivilege() I am setting up a GUEST account on my laptop, then running my program to retrieve the access token, so we can view the relate ACE's within the DACL. The point is to retrieve the limited access and display it on the screen. So I can then change it; getting familiar with ACE's, DACL's, and SACL's. The error I get when compiling this source is that BOOL has to Few arguments. So BOOL does not have enough supplied telling it what to do, correct? Thank you all in advance! V/R Rob & Big #include <iostream> #include <string> #include <windows.h> #include <stdio.h> using namespace std; BOOL SetPrivilege( HANDLE hToken, // access token handle LPCTSTR lpszPrivilege, // name of privilege to enable/disable BOOL bEnablePrivilege // to enable or disable privilege ) { TOKEN_PRIVILEGES tp; LUID luid; if ( !LookupPrivilegeValue( NULL, // lookup privilege on local system lpszPrivilege, // privilege to lookup &luid ) ) // receives LUID of privilege { printf("LookupPrivilegeValue error: %u\n", GetLastError() ); return FALSE; } tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; if (bEnablePrivilege) tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; else tp.Privileges[0].Attributes = 0; // Enable the privilege or disable all privileges. if ( !AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL) ) { printf("AdjustTokenPrivileges error: %u\n", GetLastError() ); return FALSE; } if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) { printf("The token does not have the specified privilege. \n"); return FALSE; } return TRUE; } // Retrieve Local Computer Name string GetLocalComputerName() { TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; string strRetVal; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { strRetVal = chrComputerName; } else { strRetVal = ""; } return(strRetVal); } int main() { system("CLS"); string password; cout << "password: "; cin &g

    D R 2 Replies Last reply
    0
    • R rbwest86

      Ok, heres what should happen. The program should return the value's of the access token of the current user. What is wrong with this picture? I believe I need to relate SetPrivilege to a string. So later on I can use cout SetPrivilege() I am setting up a GUEST account on my laptop, then running my program to retrieve the access token, so we can view the relate ACE's within the DACL. The point is to retrieve the limited access and display it on the screen. So I can then change it; getting familiar with ACE's, DACL's, and SACL's. The error I get when compiling this source is that BOOL has to Few arguments. So BOOL does not have enough supplied telling it what to do, correct? Thank you all in advance! V/R Rob & Big #include <iostream> #include <string> #include <windows.h> #include <stdio.h> using namespace std; BOOL SetPrivilege( HANDLE hToken, // access token handle LPCTSTR lpszPrivilege, // name of privilege to enable/disable BOOL bEnablePrivilege // to enable or disable privilege ) { TOKEN_PRIVILEGES tp; LUID luid; if ( !LookupPrivilegeValue( NULL, // lookup privilege on local system lpszPrivilege, // privilege to lookup &luid ) ) // receives LUID of privilege { printf("LookupPrivilegeValue error: %u\n", GetLastError() ); return FALSE; } tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; if (bEnablePrivilege) tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; else tp.Privileges[0].Attributes = 0; // Enable the privilege or disable all privileges. if ( !AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL) ) { printf("AdjustTokenPrivileges error: %u\n", GetLastError() ); return FALSE; } if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) { printf("The token does not have the specified privilege. \n"); return FALSE; } return TRUE; } // Retrieve Local Computer Name string GetLocalComputerName() { TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; string strRetVal; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { strRetVal = chrComputerName; } else { strRetVal = ""; } return(strRetVal); } int main() { system("CLS"); string password; cout << "password: "; cin &g

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      rbwest86 wrote:

      The error I get when compiling this source is that BOOL has to Few arguments. So BOOL does not have enough supplied telling it what to do, correct?

      For starters, remove all of the code except that which is in error. Folks are not going to bother to wade through all of that when most of it is irrelevant. What was the exact error message?

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      1 Reply Last reply
      0
      • R rbwest86

        Ok, heres what should happen. The program should return the value's of the access token of the current user. What is wrong with this picture? I believe I need to relate SetPrivilege to a string. So later on I can use cout SetPrivilege() I am setting up a GUEST account on my laptop, then running my program to retrieve the access token, so we can view the relate ACE's within the DACL. The point is to retrieve the limited access and display it on the screen. So I can then change it; getting familiar with ACE's, DACL's, and SACL's. The error I get when compiling this source is that BOOL has to Few arguments. So BOOL does not have enough supplied telling it what to do, correct? Thank you all in advance! V/R Rob & Big #include <iostream> #include <string> #include <windows.h> #include <stdio.h> using namespace std; BOOL SetPrivilege( HANDLE hToken, // access token handle LPCTSTR lpszPrivilege, // name of privilege to enable/disable BOOL bEnablePrivilege // to enable or disable privilege ) { TOKEN_PRIVILEGES tp; LUID luid; if ( !LookupPrivilegeValue( NULL, // lookup privilege on local system lpszPrivilege, // privilege to lookup &luid ) ) // receives LUID of privilege { printf("LookupPrivilegeValue error: %u\n", GetLastError() ); return FALSE; } tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; if (bEnablePrivilege) tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; else tp.Privileges[0].Attributes = 0; // Enable the privilege or disable all privileges. if ( !AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL) ) { printf("AdjustTokenPrivileges error: %u\n", GetLastError() ); return FALSE; } if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) { printf("The token does not have the specified privilege. \n"); return FALSE; } return TRUE; } // Retrieve Local Computer Name string GetLocalComputerName() { TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1]; string strRetVal; DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1; if(GetComputerName(chrComputerName,&dwBufferSize)) { strRetVal = chrComputerName; } else { strRetVal = ""; } return(strRetVal); } int main() { system("CLS"); string password; cout << "password: "; cin &g

        R Offline
        R Offline
        rbwest86
        wrote on last edited by
        #3

        I am sorry for the confusion. Here is the code which needs clarification. I am trying to figure out how to relay the BOOL Function to a string, so I can then cout << string << endl; Here is the code: <code>BOOL SetPrivilege( HANDLE hToken, // access token handle LPCTSTR lpszPrivilege, // name of privilege to enable/disable BOOL bEnablePrivilege // to enable or disable privilege ) { TOKEN_PRIVILEGES tp; LUID luid; if ( !LookupPrivilegeValue( NULL, // lookup privilege on local system lpszPrivilege, // privilege to lookup &luid ) ) // receives LUID of privilege { printf("LookupPrivilegeValue error: %u\n", GetLastError() ); return FALSE; } tp.PrivilegeCount = 1; tp.Privileges[0].Luid = luid; if (bEnablePrivilege) tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; else tp.Privileges[0].Attributes = 0; // Enable the privilege or disable all privileges. if ( !AdjustTokenPrivileges( hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), (PTOKEN_PRIVILEGES) NULL, (PDWORD) NULL) ) { printf("AdjustTokenPrivileges error: %u\n", GetLastError() ); return FALSE; } if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) { printf("The token does not have the specified privilege. \n"); return FALSE; } return TRUE; } Thank you once again for helping me with this.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups