Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/fusioninventory/lib/FusionInventory/Agent/Tools/Win32/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/fusioninventory/lib/FusionInventory/Agent/Tools/Win32/LoadIndirectString.pm
package FusionInventory::Agent::Tools::Win32::LoadIndirectString;

use warnings;
use strict;

use parent 'Exporter';

use FusionInventory::Agent::Tools::Win32::API;
use FusionInventory::Agent::Tools::Win32::WideChar;

our @EXPORT = qw(
    SHLoadIndirectString
);

my $apiSHLoadIndirectString;

sub SHLoadIndirectString {
    my ($string) = @_;

    return unless $string;

    my $wstring = MultiByteToWideChar($string)
        or return;

    unless ($apiSHLoadIndirectString) {
        $apiSHLoadIndirectString = FusionInventory::Agent::Tools::Win32::API->new(
            win32api => [
                'shlwapi',
                'SHLoadIndirectString',
                [ 'P', 'P', 'I', 'I' ],
                'N'
            ]
        );
    }

    return unless $apiSHLoadIndirectString;

    # Buffer size should be sufficient for our purpose
    my $buffer = '\0' x 4096;
    my $ret = $apiSHLoadIndirectString->Call(
        $wstring,
        $buffer,
        4096,
        0
    );

    return if ($ret || !$buffer);

    $buffer = WideCharToMultiByte($buffer);

    # api returns the same string in buffer is no indirect string was found
    return unless ($buffer && $buffer ne $string);

    return $buffer ;
}

1;

Hry