cmake: properly export public APIs in capstone.DLL. thanks to Daniel Pistelli for helping to fix this issue
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eeed767..dfde981 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -152,6 +152,7 @@
 if (BUILD_STATIC)
     add_library(capstone STATIC ${SOURCES})
 else ()
+    add_definitions(-DCAPSTONE_SHARED)
     add_library(capstone SHARED ${SOURCES})
 endif ()
 
diff --git a/cs.c b/cs.c
index 21ca39d..08cf8e3 100644
--- a/cs.c
+++ b/cs.c
@@ -87,6 +87,7 @@
 cs_vsnprintf_t cs_vsnprintf = NULL;
 #endif
 
+CAPSTONE_EXPORT
 unsigned int cs_version(int *major, int *minor)
 {
 	archs_enable();
@@ -99,6 +100,7 @@
 	return (CS_API_MAJOR << 8) + CS_API_MINOR;
 }
 
+CAPSTONE_EXPORT
 bool cs_support(int query)
 {
 	archs_enable();
@@ -132,6 +134,7 @@
 	return false;
 }
 
+CAPSTONE_EXPORT
 cs_err cs_errno(csh handle)
 {
 	struct cs_struct *ud;
@@ -143,6 +146,7 @@
 	return ud->errnum;
 }
 
+CAPSTONE_EXPORT
 const char *cs_strerror(cs_err code)
 {
 	switch(code) {
@@ -175,6 +179,7 @@
 	}
 }
 
+CAPSTONE_EXPORT
 cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle)
 {
 	cs_err err;
@@ -219,6 +224,7 @@
 	}
 }
 
+CAPSTONE_EXPORT
 cs_err cs_close(csh *handle)
 {
 	struct cs_struct *ud;
@@ -345,6 +351,7 @@
 	}
 }
 
+CAPSTONE_EXPORT
 cs_err cs_option(csh ud, cs_opt_type type, size_t value)
 {
 	struct cs_struct *handle;
@@ -415,6 +422,7 @@
 
 // dynamicly allocate memory to contain disasm insn
 // NOTE: caller must free() the allocated memory itself to avoid memory leaking
+CAPSTONE_EXPORT
 size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset, size_t count, cs_insn **insn)
 {
 	struct cs_struct *handle = (struct cs_struct *)(uintptr_t)ud;
@@ -569,6 +577,7 @@
 	return c;
 }
 
+CAPSTONE_EXPORT
 void cs_free(cs_insn *insn, size_t count)
 {
 	size_t i;
@@ -582,6 +591,7 @@
 }
 
 // return friendly name of regiser in a string
+CAPSTONE_EXPORT
 const char *cs_reg_name(csh ud, unsigned int reg)
 {
 	struct cs_struct *handle = (struct cs_struct *)(uintptr_t)ud;
@@ -593,6 +603,7 @@
 	return handle->reg_name(ud, reg);
 }
 
+CAPSTONE_EXPORT
 const char *cs_insn_name(csh ud, unsigned int insn)
 {
 	struct cs_struct *handle = (struct cs_struct *)(uintptr_t)ud;
@@ -616,6 +627,7 @@
 	return false;
 }
 
+CAPSTONE_EXPORT
 bool cs_insn_group(csh ud, cs_insn *insn, unsigned int group_id)
 {
 	struct cs_struct *handle;
@@ -642,6 +654,7 @@
 	return arr_exist(insn->detail->groups, insn->detail->groups_count, group_id);
 }
 
+CAPSTONE_EXPORT
 bool cs_reg_read(csh ud, cs_insn *insn, unsigned int reg_id)
 {
 	struct cs_struct *handle;
@@ -668,6 +681,7 @@
 	return arr_exist(insn->detail->regs_read, insn->detail->regs_read_count, reg_id);
 }
 
+CAPSTONE_EXPORT
 bool cs_reg_write(csh ud, cs_insn *insn, unsigned int reg_id)
 {
 	struct cs_struct *handle;
@@ -694,6 +708,7 @@
 	return arr_exist(insn->detail->regs_write, insn->detail->regs_write_count, reg_id);
 }
 
+CAPSTONE_EXPORT
 int cs_op_count(csh ud, cs_insn *insn, unsigned int op_type)
 {
 	struct cs_struct *handle;
@@ -769,6 +784,7 @@
 	return count;
 }
 
+CAPSTONE_EXPORT
 int cs_op_index(csh ud, cs_insn *insn, unsigned int op_type,
 		unsigned int post)
 {
diff --git a/include/capstone.h b/include/capstone.h
index 9ec8bce..de33b2f 100644
--- a/include/capstone.h
+++ b/include/capstone.h
@@ -18,6 +18,13 @@
 #ifdef _MSC_VER
 #pragma warning(disable:4201)
 #pragma warning(disable:4100)
+#ifdef CAPSTONE_SHARED	// compiling DLL file
+#define CAPSTONE_EXPORT __declspec(dllexport)
+#else
+#define CAPSTONE_EXPORT __declspec(dllimport)
+#endif
+#else	// not MSVC
+#define CAPSTONE_EXPORT
 #endif
 
 // Capstone API version
@@ -254,6 +261,7 @@
  NOTE: if you only care about returned value, but not major and minor values,
  set both @major & @minor arguments to NULL.
 */
+CAPSTONE_EXPORT
 unsigned int cs_version(int *major, int *minor);
 
 
@@ -270,6 +278,7 @@
 
  @return True if this library supports the given arch, or in 'diet' mode.
 */
+CAPSTONE_EXPORT
 bool cs_support(int query);
 
 /*
@@ -282,6 +291,7 @@
  @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum
  for detailed error).
 */
+CAPSTONE_EXPORT
 cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle);
 
 /*
@@ -298,6 +308,7 @@
  @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum
  for detailed error).
 */
+CAPSTONE_EXPORT
 cs_err cs_close(csh *handle);
 
 /*
@@ -314,6 +325,7 @@
  so that cs_option(handle, CS_OPT_MEM, value) can (i.e must) be called
  even before cs_open()
 */
+CAPSTONE_EXPORT
 cs_err cs_option(csh handle, cs_opt_type type, size_t value);
 
 /*
@@ -324,6 +336,7 @@
 
  @return: error code of cs_err enum type (CS_ERR_*, see above)
 */
+CAPSTONE_EXPORT
 cs_err cs_errno(csh handle);
 
 
@@ -335,6 +348,7 @@
  @return: returns a pointer to a string that describes the error code
     passed in the argument @code
 */
+CAPSTONE_EXPORT
 const char *cs_strerror(cs_err code);
 
 /*
@@ -358,6 +372,7 @@
 
  On failure, call cs_errno() for error code.
 */
+CAPSTONE_EXPORT
 size_t cs_disasm_ex(csh handle,
 		const uint8_t *code, size_t code_size,
 		uint64_t address,
@@ -370,6 +385,7 @@
  @insn: pointer returned by @insn argument in cs_disasm_ex()
  @count: number of cs_insn structures returned by cs_disasm_ex()
 */
+CAPSTONE_EXPORT
 void cs_free(cs_insn *insn, size_t count);
 
 /*
@@ -384,6 +400,7 @@
  @reg: register id
  @return: string name of the register, or NULL if @reg_id is invalid.
 */
+CAPSTONE_EXPORT
 const char *cs_reg_name(csh handle, unsigned int reg_id);
 
 /*
@@ -398,6 +415,7 @@
 
  @return: string name of the instruction, or NULL if @insn_id is invalid.
 */
+CAPSTONE_EXPORT
 const char *cs_insn_name(csh handle, unsigned int insn_id);
 
 /*
@@ -416,6 +434,7 @@
 
  @return: true if this instruction indeed belongs to aboved group, or false otherwise.
 */
+CAPSTONE_EXPORT
 bool cs_insn_group(csh handle, cs_insn *insn, unsigned int group_id);
 
 /*
@@ -433,6 +452,7 @@
 
  @return: true if this instruction indeed implicitly used aboved register, or false otherwise.
 */
+CAPSTONE_EXPORT
 bool cs_reg_read(csh handle, cs_insn *insn, unsigned int reg_id);
 
 /*
@@ -450,6 +470,7 @@
 
  @return: true if this instruction indeed implicitly modified aboved register, or false otherwise.
 */
+CAPSTONE_EXPORT
 bool cs_reg_write(csh handle, cs_insn *insn, unsigned int reg_id);
 
 /*
@@ -465,6 +486,7 @@
  @return: number of operands of given type @op_type in instruction @insn,
  or -1 on failure.
 */
+CAPSTONE_EXPORT
 int cs_op_count(csh handle, cs_insn *insn, unsigned int op_type);
 
 /*
@@ -483,6 +505,7 @@
  @return: index of operand of given type @op_type in arch.op_info[] array
  in instruction @insn, or -1 on failure.
 */
+CAPSTONE_EXPORT
 int cs_op_index(csh handle, cs_insn *insn, unsigned int op_type,
 		unsigned int position);