[Gambas-user] external function freezes

Jussi Lahtinen jussi.lahtinen at gmail.com
Sat Jun 9 01:10:58 CEST 2018


I'm not sure you need waitpid call at all, but if it is needed for some
side effects, then try to pass it as:
waitpid(Me.pid, Null, 1) ''IE WNOHANG


Jussi

On Sat, Jun 9, 2018 at 1:57 AM, Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> With exec or shell command, but I'm not sure that is what you want to do.
> I think you want to attach to existing process.
>
> From the documentation:
> *"The waitpid() system call suspends execution of the calling process
> until a child specified by pid argument has changed state."*
>
> So this is what you observe as freezing.
>
> *"By default, waitpid() waits only for terminated children, but this
> behavior is modifiable via the options argument, as described below."*
>
> Not sure what this means... maybe they meant to write "... waitpid waits
> only for termination of the children ...".
> Are they required to be child processes or do attaching to process count
> as child process? I don't know. If so, I don't think the options argument
> can be zero in your case.
>
>
> Jussi
>
>
> On Sat, Jun 9, 2018 at 1:22 AM, Demosthenes Koptsis <
> demosthenesk at gmail.com> wrote:
>
>> On 06/09/2018 12:11 AM, Tobias Boege wrote:
>>
>>> On Fri, 08 Jun 2018, Demosthenes Koptsis wrote:
>>>
>>>> Hello, i implemented a ptrace and waitpid external functions in order to
>>>> read/write a memory address of a process.
>>>>
>>>> i want to make a trainer for a game in gambas and i created a small
>>>> program
>>>> that reads and writes to a memory process.
>>>>
>>>> The problem is that when i try to write to memory it freezes at waitpid
>>>> line.
>>>>
>>>> i attach the test program you have to 1) open it as root 2) run a
>>>> process
>>>> you want to hack and get the pid 3) scan memory with scanmem and locate
>>>> an
>>>> address you want to write. 4) run my test program and see it freezes.
>>>>
>>>> Any help?
>>>>
>>>> Does the same code work in a C program? It seems like waitpid() is just
>>> what
>>> you need to do after PTRACE_ATTACH, but anyway I'd say it's a good idea
>>> to
>>> develop the low-level bits in C first, so that we're sure it's the
>>> translation
>>> to Gambas which is faulty, and not the algorithm.
>>>
>>> Three other remarks:
>>>
>>>    * I'm certainly not running a random somebody's buggy program as root.
>>>      Can't you spawn a child process yourself and then use PTRACE_TRACEME
>>>      for debugging purposes? That shouldn't require root privileges.
>>>
>>>    * You should also check return values of system calls.
>>>
>>>    * THIS MAILING LIST IS DEPRECATED. USE THE NEW ONE:
>>> https://lists.gambas-basic.org/listinfo/user
>>>
>>> Regards,
>>> Tobi
>>>
>>> i also test it with c++ with codeblocks and it also freezes at waitpid
>> of WriteMemory function
>>
>> how i spawn a child process?
>>
>>
>> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180609/17e3a2d6/attachment.html>


More information about the User mailing list