Fix unloading

This commit is contained in:
Jason Hood 2017-10-26 21:46:53 +10:00
parent bff5e90eda
commit 3fb6b5aa65
3 changed files with 32 additions and 16 deletions

36
ANSI.c
View File

@ -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 ))
{

View File

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

View File

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