Skip to content

Commit 7e4040a

Browse files
authored
Fix Windows unicode env API
1 parent 99e1cfa commit 7e4040a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

qefi.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ QByteArray qefi_get_variable(QUuid uuid, QString name)
622622
LPCTSTR c_uuid = std_uuid.c_str();
623623

624624
// Create a buffer
625+
size_t skip = sizeof(TCHAR) / sizeof(quint8);
625626
TCHAR buffer[EFIVAR_BUFFER_SIZE];
626627

627628
size_t length = read_efivar_win(c_name, c_uuid, (PVOID)buffer, EFIVAR_BUFFER_SIZE);
@@ -633,8 +634,11 @@ QByteArray qefi_get_variable(QUuid uuid, QString name)
633634
}
634635
else
635636
{
636-
for (const auto &byte : buffer) {
637-
value.append(byte);
637+
for (size_t i = 0; i < length / skip; i++) {
638+
for (size_t j = 0; j < skip; j++) {
639+
const quint8 byte = (quint8)((buffer[i] & (0xFF << (8 * j))) >> (8 * j));
640+
value.append(byte);
641+
}
638642
}
639643
}
640644

0 commit comments

Comments
 (0)