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 


[C]Shutting Down Other Computer ?

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

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Sep 28, 2008 8:10 am    Post subject: [C]Shutting Down Other Computer ? Reply with quote

I'm using InitiateSystemShutdown to shutdown a computer that is connected to the same network as me, but it fails, why ?

my code is: //i did not code the EnablePriv() block


Code:
#include <windows.h>
#include <stdio.h>

BOOL asdf(LPWSTR lpMachineName, LPWSTR lpMessage)
{
   return InitiateSystemShutdown(lpMachineName, lpMessage, 5, TRUE, FALSE);
}

BOOL EnablePriv(LPCSTR lpszPriv) // by Napalm
{
    HANDLE hToken;
    LUID luid;
    TOKEN_PRIVILEGES tkprivs;

    RtlZeroMemory(&tkprivs, sizeof(tkprivs));
   
    if(!OpenProcessToken(GetCurrentProcess(), (TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY), &hToken))
        return FALSE;
   
    if(!LookupPrivilegeValueA(NULL, lpszPriv, &luid)){
        CloseHandle(hToken); return FALSE;
    }
   
    tkprivs.PrivilegeCount = 1;
    tkprivs.Privileges[0].Luid = luid;
    tkprivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
   
    BOOL bRet = AdjustTokenPrivileges(hToken, FALSE, &tkprivs, sizeof(tkprivs), NULL, NULL);
    CloseHandle(hToken);
    return bRet;
}

void main(void)
{
   switch(EnablePriv("SeShutdownPrivilege")) //AAA
   {
   case TRUE:printf("Sccuess\n");break;
   case FALSE:printf("Failed\n");break;
   }
   switch(asdf(L"192.168.123.156", L"Test")) //LAN
   {
   case TRUE:printf("Sccuess\n");break;
   case FALSE:printf("Failed\n");break;
   }
   return;
}


I get:

Success
Failed
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sun Sep 28, 2008 11:40 am    Post subject: Reply with quote

Because your asdf function is returning the InitiateSystemShutdown rather than a bool value. You're checking to see whether it returns true or false, and it doesn't return either.
_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Sep 28, 2008 12:07 pm    Post subject: Reply with quote

Overload wrote:
Because your asdf function is returning the InitiateSystemShutdown rather than a bool value. You're checking to see whether it returns true or false, and it doesn't return either.


Ahahaha... nice catch, now i'll fix it, but still, doesn't work :S.
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sun Sep 28, 2008 1:37 pm    Post subject: Reply with quote

The parameter for your function should be an LPCTSTR not LPCSTR
_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Sep 28, 2008 2:58 pm    Post subject: Reply with quote

Overload wrote:
The parameter for your function should be an LPCTSTR not LPCSTR


Which one ? EnablePriv ?
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sun Sep 28, 2008 4:05 pm    Post subject: Reply with quote

Rot1 wrote:
Overload wrote:
The parameter for your function should be an LPCTSTR not LPCSTR


Which one ? EnablePriv ?

Yes. Right now you have it as LPCSTR. Change it to LPCTSTR

_________________
Blog

Quote:
Rhys says:
you can be my maid
Rhys says:
ill buy you a french maid outfit
Tyler says:
Sounds good
Rhys says:
ill hold you to that
Back to top
View user's profile Send private message 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