Solved snapshot same error always

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

darknessxk

Newbie
Dank Tier Donator
Jul 25, 2015
10
673
1
Hello guys.

I need some help with this specific error.

I already rewrite this part of code line by line two times. no compiling errors. GetLastError always return 0.

But still giving INVALID_HANDLE_VALUE when i check for errors

This is the part of function "ProcManage.h" file

C++:
#include <cstdio>
#include <Windows.h>
#include <tlhelp32.h>
#include <Psapi.h>

#pragma comment( lib, "psapi" )

using namespace std;

void printError( TCHAR* msg );

DWORD GetProcessByName(char* ProcName)
{
	PROCESSENTRY32 pe32;
	HANDLE hSnapshot;
	DWORD lastError = 0;

	pe32.dwSize = sizeof( PROCESSENTRY32 );
	hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

	if( hSnapshot != INVALID_HANDLE_VALUE )
	{
		printError("CreateToolhelp32Snapshot (of processes)");
		
		CloseHandle( hSnapshot );
		return 0;
	}

	if( Process32First( hSnapshot, &pe32 ) )
	{
		do{
			printf("%u | %d | File: %s\n", pe32.th32ProcessID, strcmp( pe32.szExeFile, ProcName ), pe32.szExeFile);
			if( strcmp( pe32.szExeFile, ProcName ) == 0 )
				break;
		}while( Process32Next( hSnapshot, &pe32 ) );
	}


	return pe32.th32ProcessID;
}
and on main

C++:
#include "HookManager.h"
#include "ProcManager.h"
#include "MemManager.h"

int main(){
	DWORD pid = GetProcessByName("calc.exe");

	SetHook();
	
	//printf("Base Address 0x%08X", GetEntryPoint(pid, "calc.exe"));

	MSG msg;
    while (GetMessage(&msg, NULL, 0, 0)){ }

	return 0;
}
 

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
Run as admin. Maybe set debug privilege before trying to open another process.
 

rN'

Jr.Hacker
Meme Tier VIP
Jan 19, 2014
340
5,268
41
Check GetLastError and google that error when your handle in invalid?
 

darknessxk

Newbie
Dank Tier Donator
Jul 25, 2015
10
673
1
Check GetLastError and google that error when your handle in invalid?
Always return 0. Googled similar erros but not get any result.. i'll try put the the errorcheck on other locations.

Invalid handle ocurr while i create the snapshot.
right there
C++:
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
Вroihon;35066 said:
Run as admin. Maybe set debug privilege before trying to open another process.
Thanks for the tip


Solution: run as admin.
 
Last edited:
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