View previous topic :: View next topic |
Author |
Message |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Sat Nov 01, 2014 5:51 am Post subject: Function not working locating a base address |
|
|
Code: |
DWORD GetBaseAddr(DWORD pid,char* modName)
{
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,pid);
MODULEENTRY32 modEnt;
modEnt.dwSize = sizeof(MODULEENTRY32);
Module32First(snapshot,&modEnt);
do {
if(strcmp( modEnt.szModule,modName) == 0)
{
return (DWORD)modEnt.modBaseAddr;
}
} while(Module32Next(snapshot,&modEnt));
return 0;
}
|
Not working on 64 bit process, any help? works 100% on 32 bit
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Sat Nov 01, 2014 7:02 am Post subject: |
|
|
You need to strip the path from szModule and i recommend stricmp because the charcase could be different
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Sat Nov 01, 2014 5:32 pm Post subject: |
|
|
Alright after some investagating, I found out the process name was too long for me to read, I tried googling for the problem but came up with nothing. Any help would be appreciated!
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
|
Posted: Sat Nov 01, 2014 5:57 pm Post subject: |
|
|
Some notes about your function:
- The name you pass to the function can be const char* instead of just char*.
- You are opening a handle and never closing it.
- You should check the return of Module32First to ensure it didn't fail.
- strcmp is case-sensitive, check out strnicmp instead.
Also if you are looking for a specific module, there is no reason to use 'TH32CS_SNAPALL'. Instead, you should use TH32CS_SNAPMODULE or TH32CS_SNAPMODULE32 specifically.
_________________
- Retired. |
|
Back to top |
|
 |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Sat Nov 01, 2014 7:06 pm Post subject: |
|
|
Hey atom0s thanks for replying, I have edited my code and took your advice. I dont understand why I cant get the process module, I can get the processID just fine with my other function
Code: |
DWORD GetPID(char* procName)
{
HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
PROCESSENTRY32 procEnt;
procEnt.dwSize = sizeof( PROCESSENTRY32 );
Process32First(handle,&procEnt);
do {
if( strcmp(procEnt.szExeFile,procName) == 0 )
{
return procEnt.th32ProcessID;
}
}while( Process32Next(handle,&procEnt) );
CloseHandle(handle);
return 0;
}
|
But for some reason this game only, I cannot get the module. I never have run into this problem which is why I'm so confused. I mean it seems to me that the strcmp is not the problem because it can get the PID but I dont know
In cheat engine the pointer shows up just fine
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
|
Posted: Sat Nov 01, 2014 9:54 pm Post subject: |
|
|
Is the process you are targeting 64bit?
_________________
- Retired. |
|
Back to top |
|
 |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Sat Nov 01, 2014 10:37 pm Post subject: |
|
|
atom0s wrote: | Is the process you are targeting 64bit? |
yes
Code: |
DWORD base = GetBaseAddr(pid,"launcher64.exe");
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE,
pid);
|
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25785 Location: The netherlands
|
Posted: Sun Nov 02, 2014 12:18 am Post subject: |
|
|
is your code compiled as a 64-bit process as well? If not, it won't be able to target that process
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Sun Nov 02, 2014 9:33 am Post subject: |
|
|
Dark Byte wrote: | is your code compiled as a 64-bit process as well? If not, it won't be able to target that process |
Okay I finally got my application to 64 bit
|
|
Back to top |
|
 |
shakib187 Expert Cheater
Reputation: 0
Joined: 24 May 2007 Posts: 215
|
Posted: Mon Nov 03, 2014 2:09 am Post subject: |
|
|
I did it, thank you guys for your help, especially DB.
|
|
Back to top |
|
 |
|