This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

20
attic/sblclfx/sblclfx.sln Normal file
View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2012 for Windows Desktop
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sblclfx", "sblclfx\sblclfx.vcxproj", "{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}.Debug|Win32.ActiveCfg = Debug|Win32
{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}.Debug|Win32.Build.0 = Debug|Win32
{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}.Release|Win32.ActiveCfg = Release|Win32
{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,116 @@
#include <Winsock2.h>
#include <WinBase.h>
#include <Windows.h>
#include <stdio.h>
#include <intrin.h>
#pragma comment(lib, "ws2_32.lib")
typedef unsigned char byte;
#pragma intrinsic(_ReturnAddress)
WINBASEAPI
BOOL
WINAPI
GetModuleHandleExA(
__in DWORD dwFlags,
__in_opt LPCSTR lpModuleName,
__out HMODULE* phModule
);
void WriteMem(DWORD addr, byte* mem, DWORD len)
{
DWORD dwOldPr;
if(VirtualProtect((void*)addr, len, PAGE_EXECUTE_READWRITE, &dwOldPr))
{
memcpy((void*)addr, mem, len);
VirtualProtect((void*)addr, len, dwOldPr, &dwOldPr);
FlushInstructionCache(GetCurrentProcess(), (void*)addr, len);
}
}
void WriteJmp(DWORD from, DWORD to)
{
byte jmp[5] = { 0xE9, 0,0,0,0 };
*(DWORD*)(&jmp[1]) = to - (from + 5);
WriteMem(from, jmp, 5);
}
byte* GetCodeBytes(DWORD len)
{
return (byte*)VirtualAlloc(NULL, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
}
void FinalizeCodeBytes(byte* addr, DWORD len) {
DWORD dwOldPr;
VirtualProtect((void*)addr, len, PAGE_EXECUTE_READ, &dwOldPr);
FlushInstructionCache(GetCurrentProcess(), (void*)addr, len);
}
DWORD GetAddr(const char* mod, const char* func)
{
return (DWORD)GetProcAddress(GetModuleHandleA(mod), func);
}
HMODULE ghMod;
DWORD setlocale_addr;
typedef char*(__cdecl* t_setlocale)(int, const char*);
t_setlocale o_setlocale;
CRITICAL_SECTION setlocale_cs;
char* __cdecl hk_setlocale(int category, const char* locale)
{
EnterCriticalSection(&setlocale_cs);
char* r = o_setlocale(category, locale);
LeaveCriticalSection(&setlocale_cs);
if(r == NULL)
r = "C";
return r;
}
void PatchSetLocale() {
HMODULE hmsvcrt;
if ((hmsvcrt=LoadLibraryA("msvcrt")) == NULL)
return;
InitializeCriticalSection(&setlocale_cs);
setlocale_addr = GetAddr("msvcrt", "setlocale");
byte* origcode = GetCodeBytes(2+5+5);
memcpy(origcode, (void*)setlocale_addr, 7);
WriteJmp((DWORD)&origcode[7], setlocale_addr+7);
o_setlocale = (t_setlocale)origcode;
WriteJmp(setlocale_addr, (DWORD)&hk_setlocale);
FinalizeCodeBytes(origcode, 2+5+5);
}
void ApplyPatches(void)
{
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
BOOL bIsWindowsXPOrEarlier = (osvi.dwMajorVersion <= 5);
if (bIsWindowsXPOrEarlier)
PatchSetLocale();
}
BOOL WINAPI DllMain(HMODULE hMod, DWORD fdwReason, LPVOID lpReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hMod);
ghMod = hMod;
ApplyPatches();
break;
}
return TRUE;
}

View file

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{146F8733-FB61-49F5-9B7A-FDAA9AD644B6}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>sblclfx</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SBLCLFX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<DebugInformationFormat>None</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SBLCLFX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,16 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// TODO: reference additional headers your program requires here

View file

@ -0,0 +1,8 @@
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>