Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * This file is part of the reliforp/reli-prof package. * * (c) sji <sji@sj-i..

Decoded Output download

<?php

/**
 * This file is part of the reliforp/reli-prof package.
 *
 * (c) sji <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Reli\Lib\Process\ProcessStopper;

use FFI\CInteger;
use Reli\Lib\Libc\Errno\Errno;
use Reli\Lib\Libc\Sys\Ptrace\PtraceRequest;
use Reli\Lib\Libc\Sys\Ptrace\PtraceX64;

final class ProcessStopper
{
    public function __construct(
        private PtraceX64 $ptrace,
        private Errno $errno,
    ) {
    }

    public function stop(int $pid): bool
    {
        /** @var \FFI\Libc\ptrace_ffi $this->ffi */
        $attach = $this->ptrace->ptrace(
            PtraceRequest::PTRACE_ATTACH,
            $pid,
            null,
            null
        );

        if ($attach === -1) {
            $errno = $this->errno->get();
            if ($errno) {
                return false;
            }
        }
        pcntl_waitpid($pid, $status, WUNTRACED);
        return true;
    }

    public function resume(int $pid): void
    {
        /** @var \FFI\Libc\ptrace_ffi $this->ffi */
        $detach = $this->ptrace->ptrace(
            PtraceRequest::PTRACE_DETACH,
            $pid,
            null,
            null
        );

        if ($detach === -1) {
            $errno = $this->errno->get();
            if ($errno) {
                return;
            }
        }
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

/**
 * This file is part of the reliforp/reli-prof package.
 *
 * (c) sji <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Reli\Lib\Process\ProcessStopper;

use FFI\CInteger;
use Reli\Lib\Libc\Errno\Errno;
use Reli\Lib\Libc\Sys\Ptrace\PtraceRequest;
use Reli\Lib\Libc\Sys\Ptrace\PtraceX64;

final class ProcessStopper
{
    public function __construct(
        private PtraceX64 $ptrace,
        private Errno $errno,
    ) {
    }

    public function stop(int $pid): bool
    {
        /** @var \FFI\Libc\ptrace_ffi $this->ffi */
        $attach = $this->ptrace->ptrace(
            PtraceRequest::PTRACE_ATTACH,
            $pid,
            null,
            null
        );

        if ($attach === -1) {
            $errno = $this->errno->get();
            if ($errno) {
                return false;
            }
        }
        pcntl_waitpid($pid, $status, WUNTRACED);
        return true;
    }

    public function resume(int $pid): void
    {
        /** @var \FFI\Libc\ptrace_ffi $this->ffi */
        $detach = $this->ptrace->ptrace(
            PtraceRequest::PTRACE_DETACH,
            $pid,
            null,
            null
        );

        if ($detach === -1) {
            $errno = $this->errno->get();
            if ($errno) {
                return;
            }
        }
    }
}

Function Calls

None

Variables

None

Stats

MD5 352da45bc709773e43686f9a05983985
Eval Count 0
Decode Time 103 ms