[Forensics-changes] [yara] 256/368: Cumulative fixes for building on Windows gitignore updated for Visual Studio

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:45 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 d5d83aec63c589e8de6493602da0faa6f8d818cd
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                      | 18 ++++++++++++++++++
 libyara/include/yara/strutils.h |  2 ++
 libyara/libyara.c               | 40 +++++++++++++++++++++++++++++++++++++++-
 libyara/modules/pe.c            |  1 +
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 1e4309e..884e451 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,6 +49,8 @@ stamp-h1
 # Linux and Mac files
 *.swp
 .DS_Store
+
+# Files generated by tests
 test-alignment
 test-alignment.log
 test-alignment.trs
@@ -56,3 +58,19 @@ test-rules
 test-rules.log
 test-rules.trs
 test-suite.log
+test-pe
+test-pe.log
+test-pe.trs
+
+# Visual Studio files
+Release/
+Debug/
+x64/
+*.obj
+*.suo
+*.sdf
+*.opendb
+*.opensdf
+
+# NuGet
+windows/*/packages/
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 8da0423..f9ee24a 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -61,6 +61,44 @@ 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;
 
@@ -119,7 +157,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 bbad762..f8b6614 100644
--- a/libyara/modules/pe.c
+++ b/libyara/modules/pe.c
@@ -1875,6 +1875,7 @@ define_function(language)
   YR_OBJECT* module = module();
   PE* pe = (PE*) module->data;
 
+
   uint64_t language = integer_argument(1);
   int64_t n, i;
 

-- 
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