[Forensics-changes] [yara] 189/368: Cumulative fixes for building on Windows gitignore updated for Visual Studio
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:30:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.5.0
in repository yara.
commit 8f705fb8613d772e8659271331ee768787cb3988
Author: Kyle Reed <kallanreed at outlook.com>
Date: Sat Feb 27 12:35:20 2016 -0800
Cumulative fixes for building on Windows
gitignore updated for Visual Studio
Signed-off-by: Kyle Reed <kallanreed at outlook.com>
---
.gitignore | 13 +++++++++++++
libyara/include/yara/strutils.h | 2 ++
libyara/libyara.c | 39 ++++++++++++++++++++++++++++++++++++++-
libyara/modules/pe.c | 6 +++---
libyara/parser.c | 2 +-
5 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
index e7c0f03..25c5fd2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,3 +49,16 @@ stamp-h1
# Linux and Mac files
*.swp
.DS_Store
+
+# Visual Studio files
+Release/
+Debug/
+x64/
+*.obj
+*.suo
+*.sdf
+*.opendb
+*.opensdf
+
+# NuGet
+windows/*/packages/
\ No newline at end of file
diff --git a/libyara/include/yara/strutils.h b/libyara/include/yara/strutils.h
index ef2c81e..2efcae1 100644
--- a/libyara/include/yara/strutils.h
+++ b/libyara/include/yara/strutils.h
@@ -25,7 +25,9 @@ limitations under the License.
// Cygwin already has these functions.
#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
+#endif
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
diff --git a/libyara/libyara.c b/libyara/libyara.c
index 0321367..df472c8 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -47,6 +47,43 @@ static int init_count = 0;
char lowercase[256];
char altercase[256];
+#ifndef HAVE_PTHREAD
+#ifdef _WIN32
+
+typedef HANDLE pthread_mutex_t;
+
+unsigned long pthread_self()
+{
+ return GetCurrentThreadId();
+}
+
+int pthread_mutex_init(pthread_mutex_t *mutex, void* attr)
+{
+ *mutex = CreateSemaphore(NULL, 1, 1, NULL);
+ return *mutex == NULL;
+}
+
+int pthread_mutex_destroy(pthread_mutex_t *mutex)
+{
+ BOOL result;
+
+ result = CloseHandle(*mutex);
+ *mutex = NULL;
+ return result == TRUE ? 0 : -1;
+}
+
+int pthread_mutex_lock(pthread_mutex_t mutex)
+{
+ return WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
+}
+
+int pthread_mutex_unlock(pthread_mutex_t mutex)
+{
+ return ReleaseSemaphore(mutex, 1, NULL) == TRUE ? 0 : -1;
+}
+#endif
+#endif
+
#ifdef HAVE_LIBCRYPTO
pthread_mutex_t *locks;
@@ -104,7 +141,7 @@ YR_API int yr_initialize(void)
#endif
#ifdef HAVE_LIBCRYPTO
- locks = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
+ locks = (pthread_mutex_t*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
for (i = 0; i < CRYPTO_num_locks(); i++)
pthread_mutex_init(&locks[i], NULL);
diff --git a/libyara/modules/pe.c b/libyara/modules/pe.c
index 6f612ae..4d8b56e 100644
--- a/libyara/modules/pe.c
+++ b/libyara/modules/pe.c
@@ -1838,7 +1838,7 @@ define_function(locale)
define_function(language)
{
YR_OBJECT* module = module();
- PE* pe = module->data;
+ PE* pe = (PE*)module->data;
uint64_t language = integer_argument(1);
int64_t n, i;
@@ -1881,7 +1881,7 @@ define_function(is_dll)
define_function(is_32bit)
{
YR_OBJECT* module = module();
- PE* pe = module->data;
+ PE* pe = (PE*)module->data;
if (pe == NULL)
return_integer(UNDEFINED);
@@ -1893,7 +1893,7 @@ define_function(is_32bit)
define_function(is_64bit)
{
YR_OBJECT* module = module();
- PE* pe = module->data;
+ PE* pe = (PE*)module->data;
if (pe == NULL)
return_integer(UNDEFINED);
diff --git a/libyara/parser.c b/libyara/parser.c
index 82b0994..5bddbf4 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -468,7 +468,7 @@ YR_STRING* yr_parser_reduce_string_declaration(
// Determine if a string with the same identifier was already defined
// by searching for the identifier in string_table.
- string = yr_hash_table_lookup(
+ string = (YR_STRING*)yr_hash_table_lookup(
compiler->strings_table,
identifier,
NULL);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list