diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..71fabad --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required (VERSION 3.7.0) + +project(ripole) + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set(SOURCE ${PROJECT_SOURCE_DIR}/ole.c +${PROJECT_SOURCE_DIR}/olestream-unwrap.c +${PROJECT_SOURCE_DIR}/bytedecoders.c +${PROJECT_SOURCE_DIR}/logger.c +${PROJECT_SOURCE_DIR}/pldstr.c +${PROJECT_SOURCE_DIR}/bt-int.c +${PROJECT_SOURCE_DIR}/ripole.c) + +add_executable(ripole ${SOURCE}) + +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ripole) diff --git a/logger.c b/logger.c index d0cc5dc..adcbbe9 100644 --- a/logger.c +++ b/logger.c @@ -319,9 +319,11 @@ int LOGGER_log( char *format, ...) case _LOGGER_STDERR: fprintf(stderr,"%s%s",output, lineend ); break; +#ifndef WIN32 case _LOGGER_SYSLOG: syslog(_LOGGER_syslog_mode,"%s",output); break; +#endif case _LOGGER_STDOUT: fprintf(stdout,"%s%s",output, lineend); fflush(stdout); diff --git a/ole.c b/ole.c index fd359b5..bd8634c 100644 --- a/ole.c +++ b/ole.c @@ -6,6 +6,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "logger.h" #include "pldstr.h" #include "bt-int.h" @@ -1450,8 +1454,11 @@ int OLE_open_file( struct OLE_object *ole, char *fullpath ) int OLE_open_directory( struct OLE_object *ole, char *directory ) { int result=0; - - result = mkdir( directory, S_IRWXU ); +#ifndef WIN32 + result = mkdir(directory, S_IRWXU); +#else + result = _mkdir(directory); +#endif if ((result != 0)&&(errno != EEXIST)) { LOGGER_log("%s:%d:OLE_open_directory:ERROR: %s",FL,strerror(errno)); diff --git a/olestream-unwrap.c b/olestream-unwrap.c index 0b43663..bb7498d 100644 --- a/olestream-unwrap.c +++ b/olestream-unwrap.c @@ -395,11 +395,19 @@ int OLEUNWRAP_decode_attachment( struct OLEUNWRAP_object *oleuw, char *stream, s sp += 2; // Full attachment string +#ifndef WIN32 oh.attach_name = strdup( sp ); +#else + oh.attach_name = _strdup(sp); +#endif sp = sp + strlen(oh.attach_name) +1; // Attachment full path +#ifndef WIN32 oh.fname_1 = strdup( sp ); +#else + oh.fname_1 = _strdup(sp); +#endif sp += strlen(oh.fname_1) +1; // Unknown memory segment @@ -407,7 +415,11 @@ int OLEUNWRAP_decode_attachment( struct OLEUNWRAP_object *oleuw, char *stream, s sp = sp +8; // Attachment full path +#ifndef WIN32 oh.fname_2 = strdup( sp ); +#else + oh.fname_2 = _strdup(sp); +#endif sp += strlen(oh.fname_2) +1; oh.attach_size = (size_t)get_uint32( sp ); diff --git a/pldstr.c b/pldstr.c index fdacdd2..4ad898f 100644 --- a/pldstr.c +++ b/pldstr.c @@ -37,9 +37,17 @@ char *PLD_strstr(char *haystack, char *needle, int insensitive) if (insensitive > 0) { +#ifndef WIN32 hs = strdup(haystack); +#else + hs = _strdup(haystack); +#endif PLD_strlower(hs); +#ifndef WIN32 ne = strdup(needle); +#else + ne = _strdup(needle); +#endif PLD_strlower(ne); } else { hs = haystack; diff --git a/ripole.c b/ripole.c index 387d382..e562f83 100644 --- a/ripole.c +++ b/ripole.c @@ -84,12 +84,20 @@ int ROLE_parse_parameters( struct ripOLE_object *role, int argc, char **argv ) { case 'i': i++; +#ifndef WIN32 role->inputfile = strdup(argv[i]); +#else + role->inputfile = _strdup(argv[i]); +#endif break; case 'd': i++; +#ifndef WIN32 role->outputdir = strdup(argv[i]); +#else + role->outputdir = _strdup(argv[i]); +#endif break; case 'v':