Skip to content

Commit 8ac3269

Browse files
committed
Refactoring.
1 parent d3e377c commit 8ac3269

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/CLI.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: CLI handler (last modified: 2020.07.10).
11+
* This file: CLI handler (last modified: 2020.10.30).
1212
*/
1313

1414
namespace phpMussel\CLI;
@@ -39,6 +39,7 @@ class CLI
3939
* Construct the loader.
4040
*
4141
* @param \phpMussel\Core\Loader $Loader The instantiated loader object, passed by reference.
42+
* @param \phpMussel\Core\Scanner $Scanner The instantiated scanner object, passed by reference.
4243
*/
4344
public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Scanner &$Scanner)
4445
{
@@ -334,7 +335,7 @@ private function peMeta(string $File): string
334335
$Returnable .= $this->Loader->L10N->getString('cli_pe2') . "\n";
335336
for ($PECaret = 0; $PECaret < $NumberOfSections; $PECaret++) {
336337
$SectionHead = substr($Data, $Offset + 24 + $OptHdrSize + ($PECaret * 40), $NumberOfSections * 40);
337-
$SectionName = str_ireplace("\x00", '', substr($SectionHead, 0, 8));
338+
$SectionName = str_ireplace("\0", '', substr($SectionHead, 0, 8));
338339
$VirtualSize = $this->Loader->unpackSafe('S', substr($SectionHead, 8, 4));
339340
$VirtualSize = $VirtualSize[1];
340341
$VirtualAddress = $this->Loader->unpackSafe('S', substr($SectionHead, 12, 4));
@@ -348,21 +349,21 @@ private function peMeta(string $File): string
348349
$Returnable .= $SizeOfRawData . ':' . $SHA256 . ':' . $SectionName . "\n";
349350
}
350351
$Returnable .= "\n";
351-
if (strpos($Data, "V\x00a\x00r\x00F\x00i\x00l\x00e\x00I\x00n\x00f\x00o\x00\x00\x00\x00\x00\x24") !== false) {
352-
$PEParts = $this->Loader->substrAfterLast($Data, "V\x00a\x00r\x00F\x00i\x00l\x00e\x00I\x00n\x00f\x00o\x00\x00\x00\x00\x00\x24");
352+
if (strpos($Data, "V\0a\0r\0F\0i\0l\0e\0I\0n\0f\0o\0\0\0\0\0\x24") !== false) {
353+
$PEParts = $this->Loader->substrAfterLast($Data, "V\0a\0r\0F\0i\0l\0e\0I\0n\0f\0o\0\0\0\0\0\x24");
353354
foreach ([
354-
["F\x00i\x00l\x00e\x00D\x00e\x00s\x00c\x00r\x00i\x00p\x00t\x00i\x00o\x00n\x00\x00\x00", 'PEFileDescription'],
355-
["F\x00i\x00l\x00e\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00\x00\x00", 'PEFileVersion'],
356-
["P\x00r\x00o\x00d\x00u\x00c\x00t\x00N\x00a\x00m\x00e\x00\x00\x00", 'PEProductName'],
357-
["P\x00r\x00o\x00d\x00u\x00c\x00t\x00V\x00e\x00r\x00s\x00i\x00o\x00n\x00\x00\x00", 'PEProductVersion'],
358-
["L\x00e\x00g\x00a\x00l\x00C\x00o\x00p\x00y\x00r\x00i\x00g\x00h\x00t\x00\x00\x00", 'PECopyright'],
359-
["O\x00r\x00i\x00g\x00i\x00n\x00a\x00l\x00F\x00i\x00l\x00e\x00n\x00a\x00m\x00e\x00\x00\x00", 'PEOriginalFilename'],
360-
["C\x00o\x00m\x00p\x00a\x00n\x00y\x00N\x00a\x00m\x00e\x00\x00\x00", 'PECompanyName'],
355+
["F\0i\0l\0e\0D\0e\0s\0c\0r\0i\0p\0t\0i\0o\0n\0\0\0", 'PEFileDescription'],
356+
["F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0", 'PEFileVersion'],
357+
["P\0r\0o\0d\0u\0c\0t\0N\0a\0m\0e\0\0\0", 'PEProductName'],
358+
["P\0r\0o\0d\0u\0c\0t\0V\0e\0r\0s\0i\0o\0n\0\0\0", 'PEProductVersion'],
359+
["L\0e\0g\0a\0l\0C\0o\0p\0y\0r\0i\0g\0h\0t\0\0\0", 'PECopyright'],
360+
["O\0r\0i\0g\0i\0n\0a\0l\0F\0i\0l\0e\0n\0a\0m\0e\0\0\0", 'PEOriginalFilename'],
361+
["C\0o\0m\0p\0a\0n\0y\0N\0a\0m\0e\0\0\0", 'PECompanyName'],
361362
] as $PEVars) {
362363
if (strpos($PEParts, $PEVars[0]) !== false && (
363-
$ThisPEData = trim(str_ireplace("\x00", '', $this->Loader->substrBeforeFirst(
364+
$ThisPEData = trim(str_ireplace("\0", '', $this->Loader->substrBeforeFirst(
364365
$this->Loader->substrAfterLast($PEParts, $PEVars[0]),
365-
"\x00\x00\x00"
366+
"\0\0\0"
366367
)))
367368
)) {
368369
$Returnable .= sprintf(

0 commit comments

Comments
 (0)