Exported `ZydisString*` functions

This commit is contained in:
flobernd 2018-02-23 01:34:06 +01:00
parent 098b37d6e7
commit ef22aef632
No known key found for this signature in database
GPG Key ID: 9C3AE0ED4A969F10
4 changed files with 23 additions and 23 deletions

View File

@ -138,7 +138,7 @@ ZydisFormatterFunc defaultPrintMnemonic;
static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisFormatter* formatter, static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisFormatter* formatter,
ZydisString* string, const ZydisDecodedInstruction* instruction, ZydisCustomUserData* userData) ZydisString* string, const ZydisDecodedInstruction* instruction, ZydisCustomUserData* userData)
{ {
// We use the user-data to pass data to the @c ZydisFormatterFormatOperandImm function. // We use the user-data to pass data to the @c ZydisFormatterFormatOperandImm function
userData->ommitImmediate = ZYDIS_TRUE; userData->ommitImmediate = ZYDIS_TRUE;
// Rewrite the instruction-mnemonic for the given instructions // Rewrite the instruction-mnemonic for the given instructions

View File

@ -245,7 +245,7 @@ void generateTestData(FILE* file, uint8_t encoding)
{ {
data[i] = rand() % 256; data[i] = rand() % 256;
} }
uint8_t offset = rand() % (ZYDIS_MAX_INSTRUCTION_LENGTH - 2); const uint8_t offset = rand() % (ZYDIS_MAX_INSTRUCTION_LENGTH - 2);
switch (encoding) switch (encoding)
{ {
case 0: case 0:
@ -302,7 +302,7 @@ void generateTestData(FILE* file, uint8_t encoding)
fwrite(&instruction.data[0], 1, instruction.length, file); fwrite(&instruction.data[0], 1, instruction.length, file);
++count; ++count;
uint8_t p = (uint8_t)((double)count / 100000 * 100); const uint8_t p = (uint8_t)((double)count / 100000 * 100);
if (last < p) if (last < p)
{ {
last = p; last = p;
@ -367,7 +367,7 @@ int main(int argc, char** argv)
{ {
FILE* file; FILE* file;
size_t len = strlen(directory); const size_t len = strlen(directory);
char buf[1024]; char buf[1024];
strncpy(&buf[0], directory, sizeof(buf) - 1); strncpy(&buf[0], directory, sizeof(buf) - 1);
if (generate) if (generate)
@ -390,7 +390,7 @@ int main(int argc, char** argv)
} else } else
{ {
fseek(file, 0L, SEEK_END); fseek(file, 0L, SEEK_END);
long length = ftell(file); const long length = ftell(file);
void* buffer = malloc(length); void* buffer = malloc(length);
if (!buffer) if (!buffer)
{ {

View File

@ -553,7 +553,7 @@ typedef ZydisStatus (*ZydisFormatterAddressFunc)(const ZydisFormatter* formatter
* @param string A pointer to the string. * @param string A pointer to the string.
* @param instruction A pointer to the `ZydisDecodedInstruction` struct. * @param instruction A pointer to the `ZydisDecodedInstruction` struct.
* @param operand A pointer to the `ZydisDecodedOperand` struct. * @param operand A pointer to the `ZydisDecodedOperand` struct.
* @param type The decorator type. * @param decorator The decorator type.
* @param userData A pointer to user-defined data. * @param userData A pointer to user-defined data.
* *
* @return Returning a status code other than `ZYDIS_STATUS_SUCCESS` will immediately cause the * @return Returning a status code other than `ZYDIS_STATUS_SUCCESS` will immediately cause the
@ -564,7 +564,7 @@ typedef ZydisStatus (*ZydisFormatterAddressFunc)(const ZydisFormatter* formatter
*/ */
typedef ZydisStatus (*ZydisFormatterDecoratorFunc)(const ZydisFormatter* formatter, typedef ZydisStatus (*ZydisFormatterDecoratorFunc)(const ZydisFormatter* formatter,
ZydisString* string, const ZydisDecodedInstruction* instruction, ZydisString* string, const ZydisDecodedInstruction* instruction,
const ZydisDecodedOperand* operand, ZydisDecoratorType type, void* userData); const ZydisDecodedOperand* operand, ZydisDecoratorType decorator, void* userData);
/* ---------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------- */
/* Formatter struct */ /* Formatter struct */

View File

@ -156,19 +156,19 @@ enum ZydisLetterCases
* @brief Initializes a `ZydisString` struct with a C-string. * @brief Initializes a `ZydisString` struct with a C-string.
* *
* @param string The string to initialize. * @param string The string to initialize.
* @param value The C-string constant. * @param text The C-string constant.
* *
* @return A zydis status code. * @return A zydis status code.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, char* value) ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, char* text)
{ {
if (!string || !value) if (!string || !text)
{ {
return ZYDIS_STATUS_INVALID_PARAMETER; return ZYDIS_STATUS_INVALID_PARAMETER;
} }
const ZydisUSize length = ZydisStrLen(value); const ZydisUSize length = ZydisStrLen(text);
string->buffer = value; string->buffer = text;
string->length = length; string->length = length;
string->capacity = length; string->capacity = length;
@ -182,7 +182,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, ch
* *
* @return A zydis status code. * @return A zydis status code.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string) ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string)
{ {
if (!string) if (!string)
{ {
@ -211,7 +211,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text, ZYDIS_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text,
ZydisLetterCase letterCase); ZydisLetterCase letterCase);
/** /**
@ -226,7 +226,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const Zydis
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* string, ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* string,
const char* text, ZydisLetterCase letterCase) const char* text, ZydisLetterCase letterCase)
{ {
ZydisString other; ZydisString other;
@ -247,7 +247,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* strin
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* string, ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* string,
const ZydisStaticString* text, ZydisLetterCase letterCase) const ZydisStaticString* text, ZydisLetterCase letterCase)
{ {
if (!text || !text->buffer) if (!text || !text->buffer)
@ -272,7 +272,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString*
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string, ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string,
const ZydisString* text) const ZydisString* text)
{ {
return ZydisStringAppendEx(string, text, ZYDIS_LETTER_CASE_DEFAULT); return ZydisStringAppendEx(string, text, ZYDIS_LETTER_CASE_DEFAULT);
@ -288,7 +288,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string,
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, const char* text) ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, const char* text)
{ {
ZydisString other; ZydisString other;
ZYDIS_CHECK(ZydisStringInit(&other, (char*)text)); ZYDIS_CHECK(ZydisStringInit(&other, (char*)text));
@ -306,7 +306,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string,
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
* sufficient to append the given @c text. * sufficient to append the given @c text.
*/ */
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* string, ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* string,
const ZydisStaticString* text, ZydisLetterCase letterCase) const ZydisStaticString* text, ZydisLetterCase letterCase)
{ {
if (!text || !text->buffer) if (!text || !text->buffer)
@ -341,7 +341,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* st
* The string-buffer pointer is increased by the number of chars written, if the call was * The string-buffer pointer is increased by the number of chars written, if the call was
* successfull. * successfull.
*/ */
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value, ZYDIS_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value,
ZydisU8 paddingLength); ZydisU8 paddingLength);
/** /**
@ -360,7 +360,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value,
* The string-buffer pointer is increased by the number of chars written, if the call was * The string-buffer pointer is increased by the number of chars written, if the call was
* successfull. * successfull.
*/ */
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value, ZYDIS_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value,
ZydisU8 paddingLength); ZydisU8 paddingLength);
/** /**
@ -383,7 +383,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value,
* The string-buffer pointer is increased by the number of chars written, if the call was * The string-buffer pointer is increased by the number of chars written, if the call was
* successfull. * successfull.
*/ */
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value, ZYDIS_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value,
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
const ZydisString* suffix); const ZydisString* suffix);
@ -407,7 +407,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value,
* The string-buffer pointer is increased by the number of chars written, if the call was * The string-buffer pointer is increased by the number of chars written, if the call was
* successfull. * successfull.
*/ */
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value, ZYDIS_EXPORT ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value,
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
const ZydisString* suffix); const ZydisString* suffix);