From 3fb6b5aa659e343cdd304b5a863aeb3f8cdf39dc Mon Sep 17 00:00:00 2001 From: Jason Hood Date: Thu, 26 Oct 2017 21:46:53 +1000 Subject: [PATCH] Fix unloading --- ANSI.c | 36 ++++++++++++++++++++++++++---------- ansicon.c | 2 +- version.h | 10 +++++----- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/ANSI.c b/ANSI.c index cba707d..cd5473d 100644 --- a/ANSI.c +++ b/ANSI.c @@ -151,6 +151,9 @@ join multibyte characters split across separate writes; remove wcstok, avoiding potential interference with the host; similarly, use a private heap instead of malloc. + + v1.80, 26 October, 2017: + fix unloading. */ #include "ansicon.h" @@ -1598,19 +1601,32 @@ BOOL HookAPIAllMod( PHookFn Hooks, BOOL restore, BOOL indent ) if (me.hModule == hDllInstance || me.hModule == hKernel) continue; - // Don't scan what we've already scanned. - if (*(PDWORD)((PBYTE)me.hModule + 36) == 'ISNA') // e_oemid, e_oeminfo + if (!restore) { - if (log_level & 16) - DEBUGSTR( 2, "%s%s %S", sp, zSkipping, me.szModule ); - continue; + // Don't scan what we've already scanned. + if (*(PDWORD)((PBYTE)me.hModule + 36) == 'ISNA') // e_oemid, e_oeminfo + { + if (log_level & 16) + DEBUGSTR( 2, "%s%s %S", sp, zSkipping, me.szModule ); + continue; + } + // It's possible for the PE header to be inside the DOS header. + if (*(PDWORD)((PBYTE)me.hModule + 0x3C) >= 0x40) + { + VirtualProtect( (PBYTE)me.hModule + 36, 4, PAGE_READWRITE, &pr ); + *(PDWORD)((PBYTE)me.hModule + 36) = 'ISNA'; + VirtualProtect( (PBYTE)me.hModule + 36, 4, pr, &pr ); + } } - // It's possible for the PE header to be inside the DOS header. - if (*(PDWORD)((PBYTE)me.hModule + 0x3C) >= 0x40) + else { - VirtualProtect( (PBYTE)me.hModule + 36, 4, PAGE_READWRITE, &pr ); - *(PDWORD)((PBYTE)me.hModule + 36) = 'ISNA'; - VirtualProtect( (PBYTE)me.hModule + 36, 4, pr, &pr ); + if (*(PDWORD)((PBYTE)me.hModule + 36) != 'ISNA' && + *(PDWORD)((PBYTE)me.hModule + 0x3C) >= 0x40) + { + if (log_level & 16) + DEBUGSTR( 2, "%s%s %S", sp, zSkipping, me.szModule ); + continue; + } } if (search_env( L"ANSICON_EXC", me.szModule )) { diff --git a/ansicon.c b/ansicon.c index 1cff464..5af2592 100644 --- a/ansicon.c +++ b/ansicon.c @@ -87,7 +87,7 @@ add error codes to some message. */ -#define PDATE L"24 December, 2015" +#define PDATE L"26 October, 2017" #include "ansicon.h" #include "version.h" diff --git a/version.h b/version.h index 4d8705c..82da648 100644 --- a/version.h +++ b/version.h @@ -2,11 +2,11 @@ version.h - Version defines. */ -#define PVERS L"1.72" // wide string -#define PVERSA "1.72" // ANSI string (windres 2.16.91 didn't like L) -#define PVERE L"172" // wide environment string -#define PVEREA "172" // ANSI environment string -#define PVERB 1,7,2,0 // binary (resource) +#define PVERS L"1.80" // wide string +#define PVERSA "1.80" // ANSI string (windres 2.16.91 didn't like L) +#define PVERE L"180" // wide environment string +#define PVEREA "180" // ANSI environment string +#define PVERB 1,8,0,0 // binary (resource) #ifdef _WIN64 # define BITS L"64"