Solved Can't access handler? Why?

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
Hi, i'm trying to make a bot for an online game... Not hacking, just like a macro to send key strokes to the game .. But, when i check for "hProc" it doesn't exist..
Here's the code:
C++:
HWND hWnd = NULL;
DWORD dwProcId = NULL;
	HANDLE hProc = NULL;	

	while (1 == 1)
	{
		hWnd = FindWindow(L"Eden Eternal                   ", L"Eden Eternal                   ");
		if (hWnd)
		{
			GetWindowThreadProcessId(hWnd, &dwProcId);
			if (dwProcId)
			{
				hProc = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcId);
				if (hProc)
				{
					cout << "FOUND IT" << endl;
					break;
				}
                                else
                                {
                                      cout << "hProc is null" << endl;
                                }
                       }
                } 
       }
It's telling me that hProc doesn't exist.. Maybe it has something to be with the window info? idk, having all those blank spaces.... (?)

As you may know by now, the game is Eden Eternal...

EDIT: The code is working perfectly cause i tested on other app, but idk why it can't access process handler in this game :S
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,371
78,998
2,414

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
Run with the same elevation as game, eg with admin rights.
 

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
Still nothing.... :S can't access hProc neither send key strokes using PostMessage method (that uses only hWnd)

C++:
bool SendKey(UINT uiKeyValue)
{
          return PostMessage(hWnd, WM_KEYDOWN, uiKeyValue, (MapVirtualKey(uiKeyValue, 0) << 16) + 1);
}
 

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
Yes, i'm sure.. My code it's bigger, i just copy here the more important, here's the full code:


C++:
bool SendKey(UINT uiKeyValue)
{
    return PostMessage( hWnd, WM_KEYDOWN, uiKeyValue, (MapVirtualKey(uiKeyValue, 0) << 16) + 1));
}



void main()
{	
	DWORD dwProcId = NULL;
	HANDLE hProc = NULL;	

	while (1 == 1)
	{
		hWnd = FindWindow(L"Eden Eternal                              ", L"Eden Eternal                              ");
		if (hWnd)
		{
			GetWindowThreadProcessId(hWnd, &dwProcId);
			if (dwProcId)
			{
				hProc = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcId);
				if (hProc)
				{
					cout << "EDEN encontrado" << endl;
					SendKey(0x20);
					SendKey(0x4B);
					break;
				}
				else
				{
					if (SendKey(0x20))
						cout << "Espacio mandado" << endl;
					else
						cout << "No pudo enviarse ESPACIO" << endl;
					if (SendKey(0x6C))
						cout << "Enter Mandado?? " << endl;
					else
						cout << "No pudo enviarse ENTER" << endl;
					[B][U]cout << "No existe hProc" << endl;[/U][/B]
					break;
				}
			}
			else
			{
				cout << "No se pudo asignar dwProcId" << endl;
				break;
			}
		}
		else
		{
			system("cls");
			cout << "EDEN NOT FOUND" << endl;
			break;
			//system("PAUSE");
		}
	}
	system("pause");
It's always going through that hProc else statement...

By the way, i can't search for "Eden Eternal" without spaces cause that returns nothing.. Thats not the name of the window neither the process class... also, i just realize it changes everytime i run the game.. i had "Eden Eternal " on my code, i re-open the game and it changed to "Eden Eternal " (more spaces, this shit is not showing spaces but they're changing everytime i run the game)
 
Last edited:

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
I was actually thinking about that, but the game only runs as administrator... So, if it's lacking of privileges even if run my code as administrator what can i do? :S i'll do that and post result.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
I was actually thinking about that, but the game only runs as administrator... So, if it's lacking of privileges even if run my code as administrator what can i do? :S i'll do that and post result.
Try enable debugging privileges for example, loads of reading about that topic on the web.
 

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
Okay, GetLastError() returns a 5... How exactly do i use FormatMessage() to see it as string?, i mean.. what parameters should i pass? lol

C++:
DWORD WINAPI FormatMessage(
  _In_      DWORD dwFlags,
  _In_opt_  LPCVOID lpSource,
  _In_      DWORD dwMessageId,
  _In_      DWORD dwLanguageId,
  _Out_     LPTSTR lpBuffer,
  _In_      DWORD nSize,
  _In_opt_  va_list *Arguments
);
o_O?
 

Portujua

Newbie
Full Member
Jan 3, 2013
8
192
0
Okay, about debugging privileges.. I found this code:

C++:
#pragma comment(lib, "advapi32.lib")

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;
}

And i'm calling it like this:

C++:
HANDLE currentProcessToken;
    OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &currentProcessToken);
    SetPrivilege(currentProcessToken,TEXT("SeDebugPrivilege") ,true);

But it's telling me "The token does not have the specified privileges." :confused:
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
5 (0x5) - Access is denied..
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods