1
0
Fork 0

Avoiding having space in MnemonicNop instruction

This commit is contained in:
foralost 2023-12-17 13:07:06 +01:00 committed by Marek Szwajka
parent 04c5050015
commit 9ed6033fb6
1 changed files with 18 additions and 8 deletions

View File

@ -351,21 +351,31 @@ bool ZydisTokenizer::TokenEquals(const SingleToken* a, const SingleToken* b, boo
return tokenTextPoolEquals(a->text, b->text); return tokenTextPoolEquals(a->text, b->text);
} }
static bool tokenIsSpace(ZydisTokenizer::TokenType type)
{
return type == ZydisTokenizer::TokenType::Space || type == ZydisTokenizer::TokenType::ArgumentSpace || type == ZydisTokenizer::TokenType::MemoryOperatorSpace;
}
void ZydisTokenizer::addToken(TokenType type, QString text, const TokenValue & value) void ZydisTokenizer::addToken(TokenType type, QString text, const TokenValue & value)
{ {
switch(type) bool isItSpaceType = tokenIsSpace(type);
if(!isItSpaceType)
{ {
case TokenType::Space:
case TokenType::ArgumentSpace:
case TokenType::MemoryOperatorSpace:
break;
default:
text = text.trimmed(); text = text.trimmed();
break;
} }
if(mUppercase && !value.size) if(mUppercase && !value.size)
text = text.toUpper(); text = text.toUpper();
mInst.tokens.push_back(SingleToken(mIsNop ? TokenType::MnemonicNop : type, text, value));
if(isItSpaceType)
{
mInst.tokens.push_back(SingleToken(type, text, value));
}
else
{
mInst.tokens.push_back(SingleToken(mIsNop ? TokenType::MnemonicNop : type, text, value));
}
} }
void ZydisTokenizer::addToken(TokenType type, const QString & text) void ZydisTokenizer::addToken(TokenType type, const QString & text)