Skip to content

Commit

Permalink
trust NRVO
Browse files Browse the repository at this point in the history
This discrepancy was discovered by unaimed1337's comment.
  • Loading branch information
illegal-instruction-co committed Mar 12, 2023
1 parent 8660440 commit 54afa0d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/Toolkit/StringToolkit.hpp
Expand Up @@ -3,31 +3,36 @@
#include "Toolkit.hpp"

#include <Windows.h>
#include <iostream>

namespace ii {
class StringToolkit final : public Toolkit {
public:
static StringToolkit IsReadable(char* str) {
if (str == nullptr)
SetAs<bool>(false);

MEMORY_BASIC_INFORMATION mbi;

VirtualQuery(str, &mbi, sizeof(mbi));

SetAs<bool>(mbi.Protect & PAGE_READONLY || mbi.Protect & PAGE_READWRITE);
return std::move(StringToolkit());

return StringToolkit();
}

static StringToolkit IsAlphaNumeric(char* str) {
if (str == nullptr)
SetAs<bool>(false);

int len = sizeof(str);

for (int i = 0; i < len; i++)
if (!(isalpha(str[i]) || isdigit(str[i]) && (str[i] >= 'A' && str[i] <= 'Z' || str[i] >= 'a' && str[i] <= 'z')) || str[i] < 0 || str[i] > 127)
SetAs<bool>(false);

SetAs<bool>(true);

return std::move(StringToolkit());
return StringToolkit();
}
};
}

0 comments on commit 54afa0d

Please sign in to comment.