mirror of https://github.com/x64dbg/zydis
Renamed some string-functions to match the existing naming convention (`ZydisString*`)
This commit is contained in:
parent
ef22aef632
commit
6a8825ead2
|
@ -327,7 +327,7 @@ ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* strin
|
|||
|
||||
/**
|
||||
* @brief Formats the given unsigned ordinal @c value to its decimal text-representation and
|
||||
* appends it to @c s.
|
||||
* appends it to the @c string.
|
||||
*
|
||||
* @param string A pointer to the string.
|
||||
* @param value The value.
|
||||
|
@ -341,12 +341,12 @@ ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* strin
|
|||
* The string-buffer pointer is increased by the number of chars written, if the call was
|
||||
* successfull.
|
||||
*/
|
||||
ZYDIS_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value,
|
||||
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecU(ZydisString* string, ZydisU64 value,
|
||||
ZydisU8 paddingLength);
|
||||
|
||||
/**
|
||||
* @brief Formats the given signed ordinal @c value to its decimal text-representation and
|
||||
* appends it to @c s.
|
||||
* appends it to the @c string.
|
||||
*
|
||||
* @param string A pointer to the string.
|
||||
* @param value The value.
|
||||
|
@ -360,12 +360,12 @@ ZYDIS_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value,
|
|||
* The string-buffer pointer is increased by the number of chars written, if the call was
|
||||
* successfull.
|
||||
*/
|
||||
ZYDIS_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value,
|
||||
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecS(ZydisString* string, ZydisI64 value,
|
||||
ZydisU8 paddingLength);
|
||||
|
||||
/**
|
||||
* @brief Formats the given unsigned ordinal @c value to its hexadecimal text-representation and
|
||||
* appends it to the @c buffer.
|
||||
* appends it to the @c string.
|
||||
*
|
||||
* @param string A pointer to the string.
|
||||
* @param value The value.
|
||||
|
@ -383,13 +383,13 @@ ZYDIS_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value,
|
|||
* The string-buffer pointer is increased by the number of chars written, if the call was
|
||||
* successfull.
|
||||
*/
|
||||
ZYDIS_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value,
|
||||
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexU(ZydisString* string, ZydisU64 value,
|
||||
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
|
||||
const ZydisString* suffix);
|
||||
|
||||
/**
|
||||
* @brief Formats the given signed ordinal @c value to its hexadecimal text-representation and
|
||||
* appends it to the @c buffer.
|
||||
* appends it to the @c string.
|
||||
*
|
||||
* @param string A pointer to the string.
|
||||
* @param value The value.
|
||||
|
@ -407,7 +407,7 @@ ZYDIS_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value,
|
|||
* The string-buffer pointer is increased by the number of chars written, if the call was
|
||||
* successfull.
|
||||
*/
|
||||
ZYDIS_EXPORT ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value,
|
||||
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexS(ZydisString* string, ZydisI64 value,
|
||||
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
|
||||
const ZydisString* suffix);
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ static ZydisStatus ZydisFormatOperandMemIntel(const ZydisFormatter* formatter, Z
|
|||
if (operand->mem.scale)
|
||||
{
|
||||
ZYDIS_CHECK(ZydisStringAppendC(string, "*"));
|
||||
ZYDIS_CHECK(ZydisPrintDecU(string, operand->mem.scale, 0));
|
||||
ZYDIS_CHECK(ZydisStringAppendDecU(string, operand->mem.scale, 0));
|
||||
}
|
||||
}
|
||||
ZYDIS_CHECK(formatter->funcPrintDisp(formatter, string, instruction, operand, userData));
|
||||
|
@ -337,10 +337,10 @@ static ZydisStatus ZydisFormatOperandPtrIntel(const ZydisFormatter* formatter, Z
|
|||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ZYDIS_CHECK(ZydisPrintHexU(string, operand->ptr.segment, 4,
|
||||
ZYDIS_CHECK(ZydisStringAppendHexU(string, operand->ptr.segment, 4,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix));
|
||||
ZYDIS_CHECK(ZydisStringAppendC(string, ":"));
|
||||
return ZydisPrintHexU(string, operand->ptr.offset, 8,
|
||||
return ZydisStringAppendHexU(string, operand->ptr.offset, 8,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
}
|
||||
|
||||
|
@ -376,11 +376,11 @@ static ZydisStatus ZydisFormatOperandImmIntel(const ZydisFormatter* formatter, Z
|
|||
|
||||
if (printSignedHEX)
|
||||
{
|
||||
return ZydisPrintHexS(string, (ZydisI32)operand->imm.value.s,
|
||||
return ZydisStringAppendHexS(string, (ZydisI32)operand->imm.value.s,
|
||||
formatter->hexPaddingAddress, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
}
|
||||
return ZydisPrintHexU(string, operand->imm.value.u,
|
||||
return ZydisStringAppendHexU(string, operand->imm.value.u,
|
||||
formatter->hexPaddingAddress, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
}
|
||||
|
@ -452,13 +452,13 @@ static ZydisStatus ZydisPrintAddrIntel(const ZydisFormatter* formatter, ZydisStr
|
|||
switch (instruction->stackWidth)
|
||||
{
|
||||
case 16:
|
||||
return ZydisPrintHexU(string, (ZydisU16)address, 4,
|
||||
return ZydisStringAppendHexU(string, (ZydisU16)address, 4,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
case 32:
|
||||
return ZydisPrintHexU(string, (ZydisU32)address, 8,
|
||||
return ZydisStringAppendHexU(string, (ZydisU32)address, 8,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
case 64:
|
||||
return ZydisPrintHexU(string, address, 16,
|
||||
return ZydisStringAppendHexU(string, address, 16,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
default:
|
||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||
|
@ -485,7 +485,7 @@ static ZydisStatus ZydisPrintDispIntel(const ZydisFormatter* formatter, ZydisStr
|
|||
(operand->mem.base != ZYDIS_REGISTER_NONE) ||
|
||||
(operand->mem.index != ZYDIS_REGISTER_NONE)))
|
||||
{
|
||||
return ZydisPrintHexS(string, operand->mem.disp.value, formatter->hexPaddingDisp,
|
||||
return ZydisStringAppendHexS(string, operand->mem.disp.value, formatter->hexPaddingDisp,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
}
|
||||
if ((operand->mem.base != ZYDIS_REGISTER_NONE) ||
|
||||
|
@ -493,8 +493,9 @@ static ZydisStatus ZydisPrintDispIntel(const ZydisFormatter* formatter, ZydisStr
|
|||
{
|
||||
ZYDIS_CHECK(ZydisStringAppendC(string, "+"));
|
||||
}
|
||||
return ZydisPrintHexU(string, (ZydisU64)operand->mem.disp.value, formatter->hexPaddingDisp,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
return ZydisStringAppendHexU(string, (ZydisU64)operand->mem.disp.value,
|
||||
formatter->hexPaddingDisp, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
}
|
||||
return ZYDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -520,16 +521,19 @@ static ZydisStatus ZydisPrintImmIntel(const ZydisFormatter* formatter, ZydisStri
|
|||
switch (operand->size)
|
||||
{
|
||||
case 8:
|
||||
return ZydisPrintHexS(string, (ZydisI8)operand->imm.value.s, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
return ZydisStringAppendHexS(string, (ZydisI8)operand->imm.value.s,
|
||||
formatter->formatImm, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
case 16:
|
||||
return ZydisPrintHexS(string, (ZydisI16)operand->imm.value.s, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
return ZydisStringAppendHexS(string, (ZydisI16)operand->imm.value.s,
|
||||
formatter->formatImm, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
case 32:
|
||||
return ZydisPrintHexS(string, (ZydisI32)operand->imm.value.s, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
return ZydisStringAppendHexS(string, (ZydisI32)operand->imm.value.s,
|
||||
formatter->formatImm, formatter->hexUppercase, formatter->hexPrefix,
|
||||
formatter->hexSuffix);
|
||||
case 64:
|
||||
return ZydisPrintHexS(string, operand->imm.value.s, formatter->formatImm,
|
||||
return ZydisStringAppendHexS(string, operand->imm.value.s, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
default:
|
||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||
|
@ -538,16 +542,16 @@ static ZydisStatus ZydisPrintImmIntel(const ZydisFormatter* formatter, ZydisStri
|
|||
switch (instruction->operandWidth)
|
||||
{
|
||||
case 8:
|
||||
return ZydisPrintHexU(string, (ZydisU8)operand->imm.value.u, formatter->formatImm,
|
||||
return ZydisStringAppendHexU(string, (ZydisU8)operand->imm.value.u, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
case 16:
|
||||
return ZydisPrintHexU(string, (ZydisU16)operand->imm.value.u, formatter->formatImm,
|
||||
return ZydisStringAppendHexU(string, (ZydisU16)operand->imm.value.u, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
case 32:
|
||||
return ZydisPrintHexU(string, (ZydisU32)operand->imm.value.u, formatter->formatImm,
|
||||
return ZydisStringAppendHexU(string, (ZydisU32)operand->imm.value.u, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
case 64:
|
||||
return ZydisPrintHexU(string, operand->imm.value.u, formatter->formatImm,
|
||||
return ZydisStringAppendHexU(string, operand->imm.value.u, formatter->formatImm,
|
||||
formatter->hexUppercase, formatter->hexPrefix, formatter->hexSuffix);
|
||||
default:
|
||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||
|
|
37
src/String.c
37
src/String.c
|
@ -66,7 +66,7 @@ static const char* decimalLookup =
|
|||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(ZYDIS_X86) || defined(ZYDIS_ARM)
|
||||
ZydisStatus ZydisPrintDecU32(ZydisString* string, ZydisU32 value, ZydisU8 paddingLength)
|
||||
ZydisStatus ZydisStringAppendDecU32(ZydisString* string, ZydisU32 value, ZydisU8 paddingLength)
|
||||
{
|
||||
ZYDIS_ASSERT(string);
|
||||
ZYDIS_ASSERT(string->buffer);
|
||||
|
@ -103,7 +103,7 @@ ZydisStatus ZydisPrintDecU32(ZydisString* string, ZydisU32 value, ZydisU8 paddin
|
|||
return ZYDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
ZydisStatus ZydisPrintHexU32(ZydisString* string, ZydisU32 value, ZydisU8 paddingLength,
|
||||
ZydisStatus ZydisStringAppendHexU32(ZydisString* string, ZydisU32 value, ZydisU8 paddingLength,
|
||||
ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix)
|
||||
{
|
||||
ZYDIS_ASSERT(string);
|
||||
|
@ -176,7 +176,7 @@ ZydisStatus ZydisPrintHexU32(ZydisString* string, ZydisU32 value, ZydisU8 paddin
|
|||
}
|
||||
#endif
|
||||
|
||||
ZydisStatus ZydisPrintDecU64(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength)
|
||||
ZydisStatus ZydisStringAppendDecU64(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength)
|
||||
{
|
||||
ZYDIS_ASSERT(string);
|
||||
ZYDIS_ASSERT(string->buffer);
|
||||
|
@ -213,7 +213,7 @@ ZydisStatus ZydisPrintDecU64(ZydisString* string, ZydisU64 value, ZydisU8 paddin
|
|||
return ZYDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
ZydisStatus ZydisPrintHexU64(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength,
|
||||
ZydisStatus ZydisStringAppendHexU64(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength,
|
||||
ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix)
|
||||
{
|
||||
ZYDIS_ASSERT(string);
|
||||
|
@ -355,48 +355,49 @@ ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text,
|
|||
/* Formatting */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength)
|
||||
ZydisStatus ZydisStringAppendDecU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength)
|
||||
{
|
||||
#if defined(ZYDIS_X64) || defined(ZYDIS_AARCH64)
|
||||
return ZydisPrintDecU64(string, value, paddingLength);
|
||||
return ZydisStringAppendDecU64(string, value, paddingLength);
|
||||
#else
|
||||
if (value & 0xFFFFFFFF00000000)
|
||||
{
|
||||
return ZydisPrintDecU64(string, value, paddingLength);
|
||||
return ZydisStringAppendDecU64(string, value, paddingLength);
|
||||
} else
|
||||
{
|
||||
return ZydisPrintDecU32(string, (ZydisU32)value, paddingLength);
|
||||
return ZydisStringAppendDecU32(string, (ZydisU32)value, paddingLength);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength)
|
||||
ZydisStatus ZydisStringAppendDecS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
ZYDIS_CHECK(ZydisStringAppendC(string, "-"));
|
||||
return ZydisPrintDecU(string, -value, paddingLength);
|
||||
return ZydisStringAppendDecU(string, -value, paddingLength);
|
||||
}
|
||||
return ZydisPrintDecU(string, value, paddingLength);
|
||||
return ZydisStringAppendDecU(string, value, paddingLength);
|
||||
}
|
||||
|
||||
ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength,
|
||||
ZydisStatus ZydisStringAppendHexU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength,
|
||||
ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix)
|
||||
{
|
||||
#if defined(ZYDIS_X64) || defined(ZYDIS_AARCH64)
|
||||
return ZydisPrintHexU64(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
return ZydisStringAppendHexU64(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
#else
|
||||
if (value & 0xFFFFFFFF00000000)
|
||||
{
|
||||
return ZydisPrintHexU64(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
return ZydisStringAppendHexU64(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
} else
|
||||
{
|
||||
return ZydisPrintHexU32(string, (ZydisU32)value, paddingLength, uppercase, prefix, suffix);
|
||||
return ZydisStringAppendHexU32(
|
||||
string, (ZydisU32)value, paddingLength, uppercase, prefix, suffix);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength,
|
||||
ZydisStatus ZydisStringAppendHexS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength,
|
||||
ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix)
|
||||
{
|
||||
if (value < 0)
|
||||
|
@ -406,9 +407,9 @@ ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value, ZydisU8 paddingL
|
|||
{
|
||||
ZYDIS_CHECK(ZydisStringAppend(string, prefix));
|
||||
}
|
||||
return ZydisPrintHexU(string, -value, paddingLength, uppercase, ZYDIS_NULL, suffix);
|
||||
return ZydisStringAppendHexU(string, -value, paddingLength, uppercase, ZYDIS_NULL, suffix);
|
||||
}
|
||||
return ZydisPrintHexU(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
return ZydisStringAppendHexU(string, value, paddingLength, uppercase, prefix, suffix);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue