Skip to content

Commit 48febfc

Browse files
author
Requiem
committed
style: format changes
1 parent 394b843 commit 48febfc

1 file changed

Lines changed: 19 additions & 35 deletions

File tree

src/vmaware.hpp

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8119,14 +8119,16 @@ struct VM {
81198119
// format: VB12345678-12345678 (19 chars)
81208120
if (len != 19) return false;
81218121

8122-
if ((str[0] & 0xDF) != 'V' || (str[1] & 0xDF) != 'B') return false;
8123-
8122+
if ((str[0] & 0xDF) != 'V' || (str[1] & 0xDF) != 'B') {
8123+
return false;
8124+
}
81248125
if (str[10] != '-') return false;
81258126

81268127
auto is_hex = [](char c) noexcept -> bool {
81278128
const char lower = c | 0x20;
8128-
return (c >= '0' && c <= '9') || (lower >= 'a' && lower <= 'f');
8129-
};
8129+
return (c >= '0' && c <= '9')
8130+
|| (lower >= 'a' && lower <= 'f');
8131+
};
81308132

81318133
for (size_t i = 2; i < 10; ++i) {
81328134
if (!is_hex(str[i])) return false;
@@ -10119,38 +10121,20 @@ struct VM {
1011910121
} while (false);
1012010122

1012110123
// cleanup
10122-
if (pk_buf) {
10123-
PVOID b = pk_buf;
10124-
SIZE_T z = 0;
10125-
nt_free_memory(current_process_handle, &b, &z, 0x8000);
10126-
pk_buf = nullptr;
10127-
}
10128-
if (kek_buf) {
10129-
PVOID b = kek_buf;
10130-
SIZE_T z = 0;
10131-
nt_free_memory(current_process_handle, &b, &z, 0x8000);
10132-
kek_buf = nullptr;
10133-
}
10134-
10135-
if (pk_default_buf) {
10136-
PVOID b = pk_default_buf;
10137-
SIZE_T z = 0;
10138-
nt_free_memory(current_process_handle, &b, &z, 0x8000);
10139-
pk_default_buf = nullptr;
10140-
}
10141-
10142-
if (kek_default_buf) {
10143-
PVOID b = kek_default_buf;
10144-
SIZE_T z = 0;
10145-
nt_free_memory(current_process_handle, &b, &z, 0x8000);
10146-
kek_default_buf = nullptr;
10147-
}
10124+
auto cleanup = [&](auto& ptr) {
10125+
if (ptr) {
10126+
PVOID base = ptr;
10127+
SIZE_T size = 0;
10128+
nt_free_memory(current_process_handle, &base, &size, 0x8000);
10129+
ptr = nullptr;
10130+
}
10131+
};
1014810132

10149-
if (enum_base_buffer) {
10150-
SIZE_T z = 0;
10151-
nt_free_memory(current_process_handle, &enum_base_buffer, &z, 0x8000);
10152-
enum_base_buffer = nullptr;
10153-
}
10133+
cleanup(pk_buf);
10134+
cleanup(kek_buf);
10135+
cleanup(pk_default_buf);
10136+
cleanup(kek_default_buf);
10137+
cleanup(enum_base_buffer);
1015410138

1015510139
if (privileges_enabled && token_handle) {
1015610140
TOKEN_PRIVILEGES tp_disable{};

0 commit comments

Comments
 (0)