Skip to content

Commit

Permalink
fix: windows xp support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeefo committed May 16, 2024
1 parent 9cac79a commit d35f784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 0 additions & 4 deletions crlib/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ class SimpleLogger final : public Singleton <SimpleLogger> {
auto msg = strings.format (fmt, cr::forward <Args> (args)...);

logToFile ("FATAL", msg);

if (printFun_) {
printFun_ (msg);
}
plat.abort (msg);
}

Expand Down
13 changes: 9 additions & 4 deletions crlib/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,22 @@ struct Platform : public Singleton <Platform> {
// helper platform-dependant functions
template <typename U> bool isValidPtr (U *ptr) {
#if defined(CR_WINDOWS)
#if defined(CR_HAS_WINXP_SUPPORT)
if (IsBadCodePtr (reinterpret_cast <FARPROC> (ptr))) {
return false;
}
#else
MEMORY_BASIC_INFORMATION mbi {};

if (VirtualQuery (reinterpret_cast <LPVOID> (ptr), &mbi, sizeof (mbi))) {
auto mask = PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY;
auto result = !(mbi.Protect & mask);
auto result = (mbi.Protect & PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);

if (mbi.Protect & (PAGE_GUARD | PAGE_NOACCESS)) {
return !result;
result = false;
}
return !result;
return result;
}
#endif
#else
(void) (ptr);
#endif
Expand Down

0 comments on commit d35f784

Please sign in to comment.