Solved Create process handle

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Lettuce

Newbie
Silenced
May 4, 2017
2
763
0
I'm trying to create a handle for the assault cube with the following function.

C++:
HANDLE GetProcessHandle(const char *procName)
{
    HANDLE hProc = NULL;
    PROCESSENTRY32 pe32;
    pe32.dwSize = sizeof(PROCESSENTRY32);
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (Process32First(hSnapshot, &pe32)) {
        do {
            if (!strcmp(pe32.szExeFile, procName)) {
                hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
		break;
            }
        } while (Process32Next(hSnapshot, &pe32));
    }
    CloseHandle(hSnapshot);
    return hProc;
}
But when I compile give this error "invalid conversion from 'int' to 'const char*".
I do something wrong? I am using codeblocks and gcc as compiler
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,073
78,998
2,371
Tested your code with multi-byte character set as suggested and it works!

Do this tutorial
 
Last edited:

wolf22j

Coder
Full Member
Nobleman
Mar 19, 2014
133
1,778
20
I'm trying to create a handle for the assault cube with the following function.

C++:
HANDLE GetProcessHandle(const char *procName)
{
    HANDLE hProc = NULL;
    PROCESSENTRY32 pe32;
    pe32.dwSize = sizeof(PROCESSENTRY32);
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (Process32First(hSnapshot, &pe32)) {
        do {
            if (!strcmp(pe32.szExeFile, procName)) {
                hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
		break;
            }
        } while (Process32Next(hSnapshot, &pe32));
    }
    CloseHandle(hSnapshot);
    return hProc;
}
But when I compile give this error "invalid conversion from 'int' to 'const char*".
I do something wrong? I am using codeblocks and gcc as compiler
If you want to use char instead of wchar, you need to enable multi-byte character support. If your IDE doesn't have that option, (not sure if codeblocks does), then you can just undefine Microsoft's macros like this:

C++:
#ifdef UNICODE
#undef Process32First
#undef Process32Next
#undef PROCESSENTRY32
#undef PPROCESSENTRY32
#undef LPPROCESSENTRY32
#endif
And then you will be able to use char.
 
Last edited:

Broihon

edgy 12 y/o
Escobar Tier VIP
Fleep Tier Donator
Dec 22, 2013
1,745
40,528
316
If you want to use char instead of wchar, you need to enable multi-byte character support. If your IDE doesn't have that option, (not sure if codeblocks does), then you can just undefine Microsoft's macros like this:

C++:
#ifdef UNICODE
#undef Process32First
#undef Process32Next
#undef PROCESSENTRY32
#undef PPROCESSENTRY32
#undef LPPROCESSENTRY32
#endif
And then you will be able to use char.
It's completely retarded that Bill didn't define/typedef structures for ASCII when unicode is enabled. The other way around it works just fine ((LP)/(P)PROCESSENTRY32W).
Same shit for the module32 functions.
 

wolf22j

Coder
Full Member
Nobleman
Mar 19, 2014
133
1,778
20
It's completely retarded that Bill didn't define/typedef structures for ASCII when unicode is enabled. The other way around it works just fine ((LP)/(P)PROCESSENTRY32W).
Same shit for the module32 functions.
Yeah, I have no idea why they did that
 
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