Merge branch 'develop' of github.com:zyantific/zyan-disassembler-engine into develop

This commit is contained in:
flobernd 2017-10-14 17:55:29 +02:00
commit e4cc39d195
2 changed files with 38 additions and 13 deletions

View File

@ -2,7 +2,7 @@
Zyan Disassembler Library (Zydis) Zyan Disassembler Library (Zydis)
Original Author : Florian Bernd Original Author : Florian Bernd, Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -292,27 +292,43 @@ ZydisStatus ZydisPrintStr(char** buffer, size_t bufferLen, const char* text,
{ {
return ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE; return ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE;
} }
memcpy(*buffer, text, strLen + 1); memcpy(*buffer, text, strLen + 1);
ZydisChangeCase(*buffer, strLen, letterCase);
*buffer += strLen;
return ZYDIS_STATUS_SUCCESS;
}
void ZydisChangeCase(char* buffer, size_t bufferLen, ZydisLetterCase letterCase)
{
char rewriteRangeStart;
char rewriteRangeEnd;
signed char rebase;
switch (letterCase) switch (letterCase)
{ {
case ZYDIS_LETTER_CASE_LOWER: case ZYDIS_LETTER_CASE_LOWER:
for (size_t i = 0; i < strLen; ++i) rewriteRangeStart = 'A';
{ rewriteRangeEnd = 'Z';
(*buffer)[i] = (char)tolower((*buffer)[i]); rebase = 'a' - 'A';
}
break; break;
case ZYDIS_LETTER_CASE_UPPER: case ZYDIS_LETTER_CASE_UPPER:
for (size_t i = 0; i < strLen; ++i) rewriteRangeStart = 'a';
{ rewriteRangeEnd = 'z';
(*buffer)[i] = (char)toupper((*buffer)[i]); rebase = 'A' - 'a';
}
break; break;
default: default:
break; return;
} }
*buffer += strLen;
return ZYDIS_STATUS_SUCCESS; for (size_t i = 0; i < bufferLen; ++i)
{
char* c = buffer + i;
if (*c >= rewriteRangeStart && *c <= rewriteRangeEnd)
{
*c += rebase;
}
}
} }
ZydisStatus ZydisPrintDecU(char** buffer, size_t bufferLen, uint64_t value, uint8_t paddingLength) ZydisStatus ZydisPrintDecU(char** buffer, size_t bufferLen, uint64_t value, uint8_t paddingLength)

View File

@ -2,7 +2,7 @@
Zyan Disassembler Library (Zydis) Zyan Disassembler Library (Zydis)
Original Author : Florian Bernd Original Author : Florian Bernd, Joel Höner
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -94,6 +94,15 @@ enum ZydisLetterCases
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintStr(char** buffer, size_t bufferLen, const char* text, ZYDIS_NO_EXPORT ZydisStatus ZydisPrintStr(char** buffer, size_t bufferLen, const char* text,
ZydisLetterCase letterCase); ZydisLetterCase letterCase);
/**
* @brief Rewrites the letter case of a given string.
*
* @param buffer The string to rewrite.
* @param bufferLen The number of bytes in the buffer to case-rewrite.
* @param letterCase The desired letter case.
*/
ZYDIS_NO_EXPORT void ZydisChangeCase(char* buffer, size_t bufferLen, ZydisLetterCase letterCase);
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
/* Decimal values */ /* Decimal values */
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */