Files
admin
base
com
developer
drivers
ds
enduser
inetcore
inetsrv
loc
mergedcomponents
multimedia
net
printscan
public
published
sdktools
shell
termsrv
tools
windows
advcore
appcompat
ahui
apphelp
appverifier
buildtools
checkacversion
compatui
db
doc
package
sdbapi
shimdbc
shimengines
shims
avrflib
external
general
inc
layer
lib
lua
sample
specific
whistler
win2k
3dfrogfrenzy.cpp
acrobat5.cpp
adobelivemotion.cpp
afterdark.cpp
aliensvspredator.cpp
aolfindbundledinstaller_aolcode.cpp
aolfindbundledinstaller_aolcode.h
aolfindbundledinstaller_shim.cpp
aolrassetentryproperties.cpp
aolsysteminfo.cpp
attune.cpp
autocad.cpp
autodeskworld2.cpp
baanerp5.cpp
baanerp5c.cpp
baaniv.cpp
backoffice45suite.cpp
baseball2000.cpp
battleship.cpp
battlezone.cpp
beyondatlantis.cpp
bigactionconstruction.cpp
biggamehunter3.cpp
bizplanbuilder.cpp
boeingfix.cpp
britannica2001.cpp
canvas6.cpp
canvascheckedbuttons.cpp
casper.cpp
chemoffice.cpp
chollian2000.cpp
chollian2000plus.cpp
cluefinders3rdgrade.cpp
coffeecuphtmleditor.cpp
commandos.cpp
comptonsbible.cpp
corelappsregistration.cpp
coreldraw9jpn.cpp
corelsitebuilder.cpp
cossacks.cpp
createresumesquickandeasy.cpp
creativeonscreendisplay.cpp
crystalwebpageserver.cpp
cuseeme4.cpp
descent2.cpp
dinosauractivitycenter.cpp
dirs
dirttrackracing.cpp
dominantspecies.cpp
dongfangkuaiche3000setup.cpp
dongfangyingdu.cpp
dreye.cpp
ea3dsetup.cpp
easycdcreator4.cpp
easycdcreator5.cpp
encartaencyclopediadeluxe2k.cpp
encompassmonitor.cpp
europeanairwar.cpp
exchangeserversetup.cpp
f18carrier.cpp
firefighters.cpp
force21.cpp
gangsters.cpp
gizmos.cpp
herosdvd.cpp
hotfaxmessagecenter4.cpp
hoylegames.cpp
hptourguide.cpp
htmleditor8587.cpp
iconfig.cpp
ie5domsetup.cpp
installshield6.cpp
intelvideophone.cpp
isa.cpp
ispeed.cpp
javavm.cpp
javavm2.cpp
jetfighter4.cpp
keisoku7.cpp
khunmin2album.cpp
kingsquestmask.cpp
koeisecuritycheck.cpp
lhvoicexpressplus.cpp
linksextreme.cpp
lotusorganizer5.cpp
mahjonggmadness.cpp
main.cpp
mastersoforion2.cpp
mathblaster9_12.cpp
maxpayne.cpp
meccommander.cpp
mechwarrior2.cpp
midtownmadness2.cpp
millionaire.cpp
mindspring4.cpp
modemwizard.cpp
money2001.cpp
money2002.cpp
msaccess2000ime.cpp
msdevdisabledbuttons.cpp
msworks6.cpp
myphotocenter2.cpp
nbalive.cpp
netmanageviewnow.cpp
netobjectsfusion5.cpp
netzip.cpp
newshendiaoxialv.cpp
nflblitz.cpp
nflfever2000.cpp
nhl2001.cpp
nikonview.cpp
omikron.cpp
omnipagepro.cpp
omnipagepro11uninstall.cpp
operationsmanager.cpp
outlook2000.cpp
outlook97.cpp
outlook98wizard.cpp
overlaypro.cpp
panzercommander.cpp
petz.cpp
pickyeater.cpp
pirch98.cpp
planecrazy.cpp
postit2.cpp
powerbuilder.cpp
ppo3svrscr.cpp
precomp.h
printmaster4.cpp
proatlas2000.cpp
quicken2000.cpp
quicken2001.cpp
quicktime5.cpp
rcenter.cpp
resumewriter3.cpp
returntokrondor.cpp
riskii.cpp
riven.cpp
rumbaoffice.cpp
safedisc.cpp
schoolhouserockmath.cpp
settlers3.cpp
sevenkingdoms.cpp
shockwavelocation.cpp
sierracartracing.cpp
simply3d.cpp
sirenjukebox2.cpp
solidworks99plus.cpp
sources.inc
specops2.cpp
speechviewer3.cpp
stoneage.cpp
suda2000.cpp
summoner.cpp
superbike.cpp
superchix76.cpp
sysadmiral.cpp
taskbarandstartmenuproperty.cpp
threedjungletrain.cpp
timeslips.cpp
tonkaconstruction.cpp
treasurecove.cpp
turkeyhunter.cpp
twinssensodyssey.cpp
ultima9.cpp
ultimatesoccermanager.cpp
ultrawincleaner2002.cpp
uninstallshield.cpp
urbanchaos.cpp
usnf97.cpp
ver.rc
viavoice8j.cpp
viperracing.cpp
vjedelta.cpp
vjedeltasetup.cpp
vsanalyzerserversetup.cpp
webpage6.cpp
winfaxpro9.cpp
winstone99.cpp
wordperfect8.cpp
wordperfect9_1.cpp
wordperfect9_2.cpp
wordperfect9_3.cpp
works99.cpp
workssuite2001.cpp
worms2.cpp
wps2000.cpp
zenworks.cpp
verifier
dirs
placefil.txt
shimhook.def
shimhook.mak
ver.rc
slayerui
sld
tools
windowsupdate
dirs
placefil.txt
core
ddk
dload
feime
netdde
oleacc
published
richedit
winstate
dirs
project.mk
dirs
makefil0
2025-04-27 07:49:33 -04:00

274 lines
7.6 KiB
C++

/*++
Copyright (c) 2000 Microsoft Corporation
Module Name:
SevenKingdoms.cpp
Abstract:
The problem is in the installer that ships with some versions: specifically
the double pack: i.e. Seven Kingdoms and another. This installer reads
win.ini and parses it for localization settings.
Notes:
This is an app specific shim.
History:
07/24/2000 linstev Created
--*/
#include "precomp.h"
#include <stdio.h>
// This module has been given an official blessing to use the str routines.
#include "LegalStr.h"
IMPLEMENT_SHIM_BEGIN(SevenKingdoms)
#include "ShimHookMacro.h"
APIHOOK_ENUM_BEGIN
APIHOOK_ENUM_ENTRY(CreateFileA)
APIHOOK_ENUM_ENTRY(ReadFile)
APIHOOK_ENUM_ENTRY(CloseHandle)
APIHOOK_ENUM_END
CHAR *g_pszINI;
DWORD g_dwINIPos = 0;
DWORD g_dwINISize = 0;
/*++
Spoof the international settings in win.ini.
--*/
HANDLE
APIHOOK(CreateFileA)(
LPSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
)
{
HANDLE hRet;
if (lpFileName && (stristr(lpFileName, "win.ini")))
{
g_dwINIPos = 0;
hRet = (HANDLE)0xBAADF00D;
}
else
{
hRet = ORIGINAL_API(CreateFileA)(
lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile
);
}
return hRet;
}
/*++
Spoof the international settings in win.ini.
--*/
BOOL
APIHOOK(ReadFile)(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
)
{
BOOL bRet;
if (hFile == (HANDLE)0xBAADF00D)
{
//
// We've detected the bogus file, so pretend we are reading it
//
if (g_dwINIPos + nNumberOfBytesToRead >= g_dwINISize)
{
// At the end of the buffer, so return the number of bytes until the end
nNumberOfBytesToRead = g_dwINISize - g_dwINIPos;
}
MoveMemory(lpBuffer, g_pszINI + g_dwINIPos, nNumberOfBytesToRead);
// Move the initial position - like a file pointer
g_dwINIPos += nNumberOfBytesToRead;
if (lpNumberOfBytesRead)
{
// Store the number of bytes read
*lpNumberOfBytesRead = nNumberOfBytesToRead;
}
bRet = nNumberOfBytesToRead > 0;
}
else
{
bRet = ORIGINAL_API(ReadFile)(
hFile,
lpBuffer,
nNumberOfBytesToRead,
lpNumberOfBytesRead,
lpOverlapped);
}
return bRet;
}
/*++
Handle the close of the dummy win.ini file
--*/
BOOL
APIHOOK(CloseHandle)(HANDLE hObject)
{
BOOL bRet;
if (hObject == (HANDLE)0xBAADF00D)
{
// Pretend we closed a real file handle
g_dwINIPos = 0;
bRet = TRUE;
}
else
{
bRet = ORIGINAL_API(CloseHandle)(hObject);
}
return bRet;
}
/*++
Register hooked functions
--*/
BOOL
NOTIFY_FUNCTION(
DWORD fdwReason
)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
CHAR szLocale[MAX_PATH];
g_pszINI = (CHAR *) malloc(1024);
if (g_pszINI)
{
//
// Add all the locale settings to a buffer which looks like the [intl]
// group in win.ini on Win9x
//
int j = sprintf(g_pszINI, "[intl]\r\n");
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ICOUNTRY, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iCountry=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ICURRDIGITS, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "ICurrDigits=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ICURRENCY, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iCurrency=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDATE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iDate=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iDigits=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ILZERO, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iLZero=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iMeasure=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_INEGCURR, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iNegCurr=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ITIME, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iTime=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ITLZERO, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "iTLZero=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_S1159, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "s1159=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_S2359, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "s2359=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SCOUNTRY, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sCountry=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sCurrency=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDATE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sDate=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sDecimal=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sLanguage=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLIST, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sList=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sLongDate=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sShortDate=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sThousand=%s\r\n", szLocale);
if (GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIME, szLocale, MAX_PATH))
j += sprintf(g_pszINI + j, "sTime=%s\r\n", szLocale);
g_dwINISize = j;
}
}
return TRUE;
}
HOOK_BEGIN
CALL_NOTIFY_FUNCTION
APIHOOK_ENTRY(KERNEL32.DLL, CreateFileA)
APIHOOK_ENTRY(KERNEL32.DLL, ReadFile)
APIHOOK_ENTRY(KERNEL32.DLL, CloseHandle)
HOOK_END
IMPLEMENT_SHIM_END