Solved Problems with ptrace in Linux - next try

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

GGR

Newbie
May 12, 2015
4
62
0
Hi Guys,

I'm trying to play around with ptrace and it won't work... There are only crappy tutorial or code-examples for reading and editing values in the memory of a process over the internet or i'm too stupid to find some good and working stuff.

I tried the source from here (https://guidedhacking.com/showthread.php?4483-ReadProcessMemory-for-Linux-equivalent) and it wont work. Debugger Error: error: incompatible type for argument 1 of 'waitpid' in LinuxMemory.c Line: 99
and i also tried a lot of tutorials about ptrace.

Now my project runs in 1 of 10 cases without an error and i got the correct value. In mostly times i got the error at PEEKDATA and sometimes at PEEKDETACH without any code changes...

my actual code in main.cpp:

C++:
pid_t pid = getProcIdByName("pcsx2");
		cout << "connecting to pid: " << pid << "\n" << endl;

    	int addr = 0x2031aa8a;

    	int Value;

        Value = myptrace_read(pid, addr);
        cout << "Value: " << Value << endl;
and myptrace.cpp:
C++:
int myptrace_read(pid_t pid, int address)
{
    int tmpValue = 0;
    int Value;
    errno = 0;

    tmpValue = ptrace(PTRACE_ATTACH, pid, NULL, NULL);
    if (tmpValue == -1 && errno)
    {
        perror("Fehler bei PTRACE_ATTACH - ptrace Error");
    }

    tmpValue = ptrace(PTRACE_PEEKDATA, pid, address, NULL);
    if (tmpValue == -1 && errno)
    {
        perror("Fehler bei PTRACE_PEEKDATA - ptrace Error");
    }

    Value = tmpValue;

    tmpValue = ptrace(PTRACE_DETACH, pid, NULL, NULL);
    if (tmpValue == -1 && errno)
    {
        perror("Fehler bei PTRACE_DETACH - ptrace Error");
    }

    return Value;
}
And now the Console Outputs:

Output Nr. 1 (this is really often...).

connecting to pid: 2744

Fehler bei PTRACE_PEEKDATA - ptrace Error: No such process
Value: -1


Programm wird mit [Enter] beendet...
Output Nr. 2 (this is just sometimes and in the process 2744 freezes everytime in this case)

connecting to pid: 2744

Fehler bei PTRACE_PEEKDATA - ptrace Error: No such process
Fehler bei PTRACE_DETACH - ptrace Error: No such process
Value: -1


Programm wird mit [Enter] beendet...
Outpu Nr. 3 (this is really rare, but i got the right value and everything seems to be ok..)

connecting to pid: 2744

Value: 2108444


Programm wird mit [Enter] beendet...
I know its crap, but i hope that anybody of you can give me a good guide about ptrace....

Thanks in advance.
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Hey ill take a look later, currently very busy.

EDIT: are you sure the address is right? and are you running as sudo?
 
Last edited:

GGR

Newbie
May 12, 2015
4
62
0
Thanks for your answer, NVTalk.

Yes, im running as sudo and the address is definetly correct and im sure that the address is always the same... :)

Greets
 

NTvalk

Hacker
Meme Tier VIP
Jul 6, 2013
499
3,108
8
Thanks for your answer, NVTalk.

Yes, im running as sudo and the address is definetly correct and im sure that the address is always the same... :)

Greets
Than probably the process id isnt right, maybe a mistake in my code im not sure
 

GGR

Newbie
May 12, 2015
4
62
0
Thanks for your answer again, but the process id is definitly correct...

Greetz
 
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.

Similar threads

Community Mods