mirror of
https://github.com/capstone-engine/capstone
synced 2026-08-11 16:26:07 -04:00
* fixed and added a test for a thumb-2 invalid sequence that was incorrectly allowed before these changes (pop.w with sp argument included) * fixed and added a test for a blx from thumb to ARM that had its immediate argument incorrect (misaligned) * eliminated some warnings by explicitly casting so I could turn on treat warnings as errors locally General notes: * probably worth turning on treat all warnings as errors in the msvc project files, had a subtle bug that resulted from a missing declaration causing differences in dll and static compilation modes ( code was working incorrectly in dll form because of missing declaration in arch/ARM/ARMMapping.h for new function ARM_blx_to_arm_mode. Something about the linking was confusing ld when making the dll, and the resulting offsets were wonky (e.g. the added ble test would show up as #0x1fc instead of #0x1fe like it should have ) * the invalid pop was being treated as a soft fail which then gets coerced to a success because it is != MCDisassembler_Fail in Thumb_getInstruction what are the semantics of a soft fail? Maybe we should be able to set up whether or not we want a soft fail to be a real fail in the csh struct?
62 lines
1.1 KiB
C
62 lines
1.1 KiB
C
/* Capstone Disassembly Engine */
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
|
|
|
|
#include <stdint.h>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "SStream.h"
|
|
#include "cs_priv.h"
|
|
|
|
#ifdef _MSC_VER
|
|
#pragma warning(disable: 4996) // disable MSVC's warning on strcpy()
|
|
#endif
|
|
|
|
void SStream_Init(SStream *ss)
|
|
{
|
|
ss->index = 0;
|
|
ss->buffer[0] = '\0';
|
|
}
|
|
|
|
void SStream_concat0(SStream *ss, char *s)
|
|
{
|
|
#ifndef CAPSTONE_DIET
|
|
strcpy(ss->buffer + ss->index, s);
|
|
ss->index += (int) strlen(s);
|
|
#endif
|
|
}
|
|
|
|
void SStream_concat(SStream *ss, const char *fmt, ...)
|
|
{
|
|
#ifndef CAPSTONE_DIET
|
|
va_list ap;
|
|
int ret;
|
|
|
|
va_start(ap, fmt);
|
|
ret = cs_vsnprintf(ss->buffer + ss->index, sizeof(ss->buffer) - (ss->index + 1), fmt, ap);
|
|
va_end(ap);
|
|
ss->index += ret;
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
int main()
|
|
{
|
|
SStream ss;
|
|
int64_t i;
|
|
|
|
SStream_Init(&ss);
|
|
|
|
SStream_concat(&ss, "hello ");
|
|
SStream_concat(&ss, "%d - 0x%x", 200, 16);
|
|
|
|
i = 123;
|
|
SStream_concat(&ss, " + %ld", i);
|
|
SStream_concat(&ss, "%s", "haaaaa");
|
|
|
|
printf("%s\n", ss.buffer);
|
|
|
|
return 0;
|
|
}
|
|
*/
|