X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/4197a3f6ff9420673cc2eeaeb3eeedeb4a9c0dc9..36b1cdd1b4064e1a506b5bab0d00e61b91cb10b2:/client/whereami.c diff --git a/client/whereami.c b/client/whereami.c index 289aeb1f..6e5e85f3 100644 --- a/client/whereami.c +++ b/client/whereami.c @@ -10,6 +10,11 @@ extern "C" { #endif +#if defined(__linux__) +// make realpath() available: +#define _DEFAULT_SOURCE +#endif + #if !defined(WAI_MALLOC) || !defined(WAI_FREE) || !defined(WAI_REALLOC) #include #endif @@ -51,7 +56,7 @@ extern "C" { #pragma warning(push, 3) #endif #include -#include +//#include // not required and doesn't exist in old mingw environments #if defined(_MSC_VER) #pragma warning(pop) #endif @@ -136,7 +141,9 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) return WAI_PREFIX(getModulePath_)(NULL, out, capacity, dirname_length); } -WAI_NOINLINE +// GetModuleHandleEx() is not available on old mingw environments. We don't need getModulePath() yet. +// Sacrifice it for the time being to improve backwards compatibility +/* WAI_NOINLINE WAI_FUNCSPEC int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) { @@ -157,13 +164,15 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) return length; } + */ #elif defined(__linux__) #include #include #include -#include +// #include // not all linux distributions define PATH_MAX in limits.h because it depends on the filesystem. Therefore use... +#include #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif @@ -252,7 +261,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) if (!fgets(buffer, sizeof(buffer), maps)) break; - if (sscanf(buffer, "%" PRIx64 "-%" PRIx64 " %s %" PRIx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8) + if (sscanf(buffer, "%" SCNx64 "-%" SCNx64 " %s %" SCNx64 " %x:%x %u %s\n", &low, &high, perms, &offset, &major, &minor, &inode, path) == 8) { uint64_t addr = (uint64_t)(uintptr_t)WAI_RETURN_ADDRESS(); if (low <= addr && addr <= high)