Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Lib/Elf/Structure/Elf64/Elf64ProgramHeaderEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class Elf64ProgramHeaderEntry
public const PT_NOTE = 4;
public const PT_SHLIB = 5;
public const PT_PHDR = 6;
public const PT_TLS = 7;
public const PT_LOPROC = 0x70000000;
public const PT_HIPROC = 0x7fffffff;

Expand Down Expand Up @@ -73,4 +74,9 @@ public function isNote(): bool
{
return $this->p_type === self::PT_NOTE;
}

public function isTls(): bool
{
return $this->p_type === self::PT_TLS;
}
}
18 changes: 18 additions & 0 deletions src/Lib/Elf/Structure/Elf64/Elf64ProgramHeaderTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,22 @@ public function findDynamic(): array
}
return $result;
}

/** @return Elf64ProgramHeaderEntry[] */
public function findTls(): array
{
$result = [];
foreach ($this->entries as $entry) {
if ($entry->isTls()) {
$result[] = $entry;
}
}
return $result;
}

/** @return Elf64ProgramHeaderEntry[] */
public function getAllEntries(): array
{
return $this->entries;
}
}
34 changes: 34 additions & 0 deletions src/Lib/PhpInternals/Types/Zend/ZendExecutorGlobals.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

final class ZendExecutorGlobals implements Dereferencable
{
/** @psalm-suppress PropertyNotSetInConstructor */
public Zval $uninitialized_zval;

/** @psalm-suppress PropertyNotSetInConstructor */
public Zval $error_zval;

/** @var Pointer<ZendExecuteData>|null */
public ?Pointer $current_execute_data;

Expand Down Expand Up @@ -61,6 +67,8 @@ public function __construct(
private CastedCData $casted_cdata,
private Pointer $pointer,
) {
unset($this->uninitialized_zval);
unset($this->error_zval);
unset($this->current_execute_data);
unset($this->function_table);
unset($this->class_table);
Expand All @@ -75,6 +83,32 @@ public function __construct(
public function __get(string $field_name): mixed
{
return match ($field_name) {
'uninitialized_zval' => $this->uninitialized_zval = new Zval(
new CastedCData(
$this->casted_cdata->casted->uninitialized_zval,
$this->casted_cdata->casted->uninitialized_zval
),
new Pointer(
Zval::class,
$this->pointer->address
+
\FFI::typeof($this->casted_cdata->casted)->getStructFieldOffset('uninitialized_zval'),
\FFI::sizeof($this->casted_cdata->casted->uninitialized_zval),
),
),
'error_zval' => $this->error_zval = new Zval(
new CastedCData(
$this->casted_cdata->casted->error_zval,
$this->casted_cdata->casted->error_zval
),
new Pointer(
Zval::class,
$this->pointer->address
+
\FFI::typeof($this->casted_cdata->casted)->getStructFieldOffset('error_zval'),
\FFI::sizeof($this->casted_cdata->casted->error_zval),
),
),
'current_execute_data' => $this->casted_cdata->casted->current_execute_data !== null
? Pointer::fromCData(
ZendExecuteData::class,
Expand Down
5 changes: 5 additions & 0 deletions src/Lib/PhpInternals/Types/Zend/Zval.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public function isNull(): bool
return $this->getType() === 'IS_NULL';
}

public function isError(): bool
{
return $this->u1->isError();
}

public function isScalar(): bool
{
return $this->isLong() || $this->isDouble() || $this->isBool() || $this->isNull();
Expand Down
5 changes: 5 additions & 0 deletions src/Lib/PhpInternals/Types/Zend/ZvalU1.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ public function getType(): string
default => 'UNKNOWN',
};
}

public function isError(): bool
{
return $this->type === 15;
}
}
5 changes: 3 additions & 2 deletions src/Lib/PhpProcessReader/PhpGlobalsFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class PhpGlobalsFinder
public function __construct(
private PhpSymbolReaderCreator $php_symbol_reader_creator,
private IntegerByteSequenceReader $integer_reader,
private MemoryReaderInterface $memory_reader
private MemoryReaderInterface $memory_reader,
private PhpTsrmLsCacheFinder $tsrm_ls_cache_finder,
) {
}

Expand All @@ -58,7 +59,7 @@ public function findTsrmLsCache(
}
return $tsrm_ls_cache_address;
}
return null;
return $this->tsrm_ls_cache_finder->findByBruteForcing($process_specifier, $target_php_settings);
}

/**
Expand Down
Loading