capstone icon indicating copy to clipboard operation
capstone copied to clipboard

cs_open problem

Open 12UE opened this issue 2 years ago • 7 comments

cs_open not initial success every times .

12UE avatar Sep 24 '23 05:09 12UE

QQ截图20230924132241

12UE avatar Sep 24 '23 05:09 12UE

Could you please provide a minimal example to run. With the output you expect and what the actual behavior is.

Rot127 avatar Sep 25 '23 18:09 Rot127

error code 4,but i'm32gb dram .memory enough correct platform

12UE avatar Sep 26 '23 09:09 12UE

#include <stdio.h>
#include <inttypes.h>
#include<capstone.h>
#pragma comment(lib,"capstone.lib")

int main(int argc, char* argv[])
{
	auto buffer = "\x55\x8b\xec\x81\xec\x24\x03\x00\x00\x6a\x17\x90\x90\x90";

	csh handle;
	cs_insn* insn;
	size_t count;

	int size = 14;

	printf("By: LyShark \n\n");
	
	if (cs_open(CS_ARCH_X86, CS_MODE_32, &handle) != CS_ERR_OK)
	{
		return 0;
	}

	// https://www.cnblogs.com/lyshark
	count = cs_disasm(handle, (unsigned char*)buffer, size, 0x1000, 0, &insn);

	if (count > 0)
	{
		size_t index;
		for (index = 0; index < count; index++)
		{
			for (int x = 0; x < insn[index].size; x++)
			{
				printf("machine code: %d -> %02X \n", x, insn[index].bytes[x]);
			}

			printf("ADDR: 0x%llx| length: %d ASM: %s %s \n", insn[index].address, insn[index].size, insn[index].mnemonic, insn[index].op_str);
		}

		cs_free(insn, count);
	}
	else
	{
		printf("disasm failed! \n");
	}

	cs_close(&handle);

	getchar();
	return 0;
}

12UE avatar Sep 26 '23 12:09 12UE

图片

12UE avatar Sep 26 '23 12:09 12UE

@12UE Works fine on g++. Can you try this in MSVC to see if it works?

kabeor avatar Sep 27 '23 10:09 kabeor

msvc not working

12UE avatar Sep 27 '23 11:09 12UE