Initial commit

This commit is contained in:
mykola2312 2018-05-19 05:20:28 +03:00
commit ecb94ca91f
22 changed files with 432 additions and 0 deletions

BIN
Release/CL.read.1.tlog Normal file

Binary file not shown.

BIN
Release/CL.write.1.tlog Normal file

Binary file not shown.

BIN
Release/cl.command.1.tlog Normal file

Binary file not shown.

BIN
Release/link.command.1.tlog Normal file

Binary file not shown.

BIN
Release/link.read.1.tlog Normal file

Binary file not shown.

BIN
Release/link.write.1.tlog Normal file

Binary file not shown.

BIN
Release/main.obj Normal file

Binary file not shown.

BIN
Release/mt.command.1.tlog Normal file

Binary file not shown.

BIN
Release/mt.read.1.tlog Normal file

Binary file not shown.

BIN
Release/mt.write.1.tlog Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.pdb
D:\GMOD9_SERVER\GMOD9\LUA\BIN\SV_A2S_FIX.DLL
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMOD9_SERVER\GMOD9\LUA\BIN\SV_A2S_FIX.PDB
D:\lua502\lua\sv_a2s_fix\..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.dll
D:\lua502\lua\sv_a2s_fix\Release\cl.command.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\CL.read.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\CL.write.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\link.command.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\link.read.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\link.write.1.tlog
D:\LUA502\LUA\SV_A2S_FIX\RELEASE\MAIN.OBJ
D:\lua502\lua\sv_a2s_fix\Release\mt.command.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\mt.read.1.tlog
D:\lua502\lua\sv_a2s_fix\Release\mt.write.1.tlog
D:\LUA502\LUA\SV_A2S_FIX\RELEASE\SV_A2S_FIX.DLL.INTERMEDIATE.MANIFEST
D:\lua502\lua\sv_a2s_fix\Release\sv_a2s_fix.write.1.tlog
D:\LUA502\LUA\SV_A2S_FIX\RELEASE\VC100.PDB

View file

@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View file

@ -0,0 +1,2 @@
#v4.0:v100:false
Release|Win32|D:\lua502\lua\|

29
Release/sv_a2s_fix.log Normal file
View file

@ -0,0 +1,29 @@
Build started 19.05.2018 4:49:57.
1>Project "D:\lua502\lua\sv_a2s_fix\sv_a2s_fix.vcxproj" on node 2 (build target(s)).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(299,5): warning MSB8004: каталог Output заканчивается не косой чертой. Этот экземпляр построения добавит косую черту, поскольку она необходима для правильного определения каталога Output.
1>InitializeBuildStatus:
Creating "Release\sv_a2s_fix.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /ID:\source2006\public\dlls /ID:\source2006\dlls\hl2_dll /ID:\source2006\game_shared\hl2 /ID:\source2006\game_shared\hl2mp /ID:\source2006\game_shared /ID:\source2006\dlls /ID:\source2006\public\tier1 /ID:\source2006\public\tier0 /ID:\source2006\public /ID:\source2006\common /ID:\lua502\lua\lua502_sdk /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D _WINDLL /D _MBCS /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
main.cpp
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\winnt.h(1140): warning C4005: ARRAYSIZE: изменение макроопределения
d:\source2006\public\tier0\commonmacros.h(35): см. предыдущее определение "ARRAYSIZE"
1>main.cpp(156): warning C4800: int: принудительно задано логическое значение "true" или "false" (предупреждение о производительности)
1>main.cpp(197): warning C4800: int: принудительно задано логическое значение "true" или "false" (предупреждение о производительности)
1>main.cpp(198): warning C4800: int: принудительно задано логическое значение "true" или "false" (предупреждение о производительности)
Link:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.dll" /NOLOGO /LIBPATH:D:\source2006\lib\public /LIBPATH:D:\lua502\lua\Release lua502_sdk.lib vstdlib.lib tier0.lib tier1.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NODEFAULTLIB:LIBCMT.lib /MANIFEST /ManifestFile:"Release\sv_a2s_fix.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.pdb" /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib" /MACHINE:X86 /DLL Release\main.obj
Создается библиотека ..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib и объект ..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
Создание кода
Создание кода завершено
sv_a2s_fix.vcxproj -> D:\lua502\lua\sv_a2s_fix\..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.dll
Manifest:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe /nologo /verbose /outputresource:"..\..\..\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.dll;#2" /manifest Release\sv_a2s_fix.dll.intermediate.manifest
FinalizeBuildStatus:
Deleting file "Release\sv_a2s_fix.unsuccessfulbuild".
Touching "Release\sv_a2s_fix.lastbuildstate".
1>Done Building Project "D:\lua502\lua\sv_a2s_fix\sv_a2s_fix.vcxproj" (build target(s)).
Построение успешно завершено.
Time Elapsed 00:00:02.21

View file

@ -0,0 +1,15 @@
^D:\lua502\lua\sv_a2s_fix\sv_a2s_fix.vcxproj
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
^D:\lua502\lua\sv_a2s_fix\sv_a2s_fix.vcxproj
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
^D:\lua502\lua\sv_a2s_fix\sv_a2s_fix.vcxproj
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.lib
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp
D:\GMod9_Server\gmod9\lua\bin\sv_a2s_fix.exp

BIN
Release/vc100.pdb Normal file

Binary file not shown.

BIN
lua/bin/sv_a2s_fix.dll Normal file

Binary file not shown.

7
lua/init/a2s_info.lua Normal file
View file

@ -0,0 +1,7 @@
function onClientResponse(addr,req)
return true
end
function onServerQuery(info,addr)
return info
end

251
main.cpp Normal file
View file

@ -0,0 +1,251 @@
#define GAME_DLL
#include "cbase.h"
#include "bitbuf.h"
#include "plugin.h"
#include "glua.h"
#include "chook.h"
typedef struct {
uint16 family;
uint16 port;
uint32 addr;
} ws2_addr;
#define LUA_CALLBACK "onServerQuery"
#define LUA_CALLBACK2 "onClientResponse"
typedef int (__stdcall* SendTo_t)(int,const char*,int,int,void*,int);
DECLARE_PLUGIN(CA2SFix)
public:
virtual bool Load(CreateInterfaceFn,
CreateInterfaceFn);
virtual void Unload();
virtual bool LuaInit(lua_State*);
bool IsResponseAllowed(uint32 naddr,unsigned char req);
bool ProcessResponse(bf_read&,bf_write&,uint32);
bool ProcessLua(bf_read&,bf_write&,uint32);
bool m_bLua;
lua_State* L;
static CHook* s_pSendHook;
static SendTo_t s_SendTo;
END_PLUGIN(CA2SFix,"A2S Fix");
CHook* CA2SFix::s_pSendHook = NULL;
SendTo_t CA2SFix::s_SendTo = NULL;
static int __stdcall SendTo_Hook(int s,const char* buf,
int len,int flags,void* addr,int tolen)
{
static char s_szBuf[1024];
uint32 naddr = ((ws2_addr*)addr)->addr;
if(*(uint32*)buf == 0xFFFFFFFF)
{
if(!s_CA2SFix.IsResponseAllowed(naddr,(unsigned char)buf[4]))
return len;
}
if(*(uint32*)buf == 0xFFFFFFFF && buf[4] == 0x49)
{
memset(s_szBuf,'\0',1024);
bf_read br(buf,len);
bf_write bf(s_szBuf,1024);
if(!s_CA2SFix.ProcessResponse(br,bf,naddr))
return len;
return CA2SFix::s_SendTo(s,(const char*)bf.GetData(),
bf.GetNumBytesWritten(),flags,addr,tolen);
}
return CA2SFix::s_SendTo(s,buf,len,flags,addr,tolen);
}
bool CA2SFix::Load(CreateInterfaceFn engineFn,CreateInterfaceFn)
{
s_pSendHook = new CHook((DWORD)GetProcAddress(
GetModuleHandle("WS2_32.dll"),"sendto"),5);
s_SendTo = (SendTo_t)s_pSendHook
->HookFunction((DWORD)&SendTo_Hook);
m_bLua = (GetModuleHandle("lua502.dll") != NULL);
return true;
}
void CA2SFix::Unload()
{
delete s_pSendHook;
}
bool CA2SFix::LuaInit(lua_State* _L)
{
L = _L;
return true;
}
bool CA2SFix::ProcessResponse(bf_read& br,bf_write& bf,uint32 naddr)
{
bf.WriteLong(br.ReadLong());
bf.WriteByte(br.ReadByte());
br.ReadByte();
bf.WriteByte(7); //Protocol version
if(m_bLua)
{
if(!ProcessLua(br,bf,naddr))
return false;
}
else bf.WriteBitsFromBuffer(&br,br.GetNumBitsLeft());
return true;
}
#define lua_setstring(L,name,s) \
lua_pushstring(L,name); \
lua_pushstring(L,s); \
lua_settable(L,-3)
#define lua_setnumber(L,name,d) \
lua_pushstring(L,name); \
lua_pushnumber(L,(double)d); \
lua_settable(L,-3)
inline const char* lua_getstring(lua_State* L,
const char* name)
{
lua_pushstring(L,name);
lua_gettable(L,-2);
const char* pStr = lua_tostring(L,-1);
lua_pop(L,1);
return pStr;
}
inline int lua_getnumber(lua_State* L,
const char* name)
{
lua_pushstring(L,name);
lua_gettable(L,-2);
int pNum = lua_tonumber(L,-1);
lua_pop(L,1);
return pNum;
}
int _aterror(lua_State* L)
{
return g_pLua502->GetLuaCallbacks()->OnLuaError(L);
}
inline char* addr2str(uint32 naddr)
{
static char szBuf[32] = {0};
unsigned char* ip = (unsigned char*)&naddr;
sprintf(szBuf,"%d.%d.%d.%d",ip[0],
ip[1],ip[2],ip[3]);
return szBuf;
}
bool CA2SFix::IsResponseAllowed(uint32 naddr,unsigned char req)
{
lua_pushcfunction(L,_aterror);
int iHandler = lua_gettop(L);
lua_getglobal(L,LUA_CALLBACK2);
if(lua_isnil(L,-1))
{
lua_pop(L,2);
return true;
}
lua_pushstring(L,addr2str(naddr));
lua_pushnumber(L,req);
lua_pcall(L,2,1,iHandler);
bool bRet = lua_toboolean(L,-1);
lua_pop(L,2);
return bRet;
}
bool CA2SFix::ProcessLua(bf_read& br,bf_write& bf,uint32 naddr)
{
lua_pushcfunction(L,_aterror);
int iHandler = lua_gettop(L);
lua_getglobal(L,LUA_CALLBACK);
if(lua_isnil(L,-1))
{
lua_pop(L,2);
bf.WriteBitsFromBuffer(&br,br.GetNumBitsLeft());
return true;
}
static char szServer[256] = {0};
static char szMapName[128] = {0};
static char szFolder[128];
static char szGame[64] = {0};
static char szVersion[32] = {0};
int iAppId,iPlayers,iMaxPlayers,iBots;
char szSvType[2] = {0,0};
char szSvEnv[2] = {0,0};
bool bVisibility,bVac;
br.ReadString(szServer,256);
br.ReadString(szMapName,128);
br.ReadString(szFolder,128);
br.ReadString(szGame,64);
iAppId = br.ReadWord();
iPlayers = br.ReadByte();
iMaxPlayers = br.ReadByte();
iBots = br.ReadByte();
szSvType[0] = br.ReadByte();
szSvEnv[0] = br.ReadByte();
bVisibility = br.ReadByte();
bVac = br.ReadByte();
br.ReadString(szVersion,32);
lua_newtable(L);
lua_setstring(L,"name",szServer);
lua_setstring(L,"map",szMapName);
lua_setstring(L,"folder",szFolder);
lua_setstring(L,"game",szGame);
lua_setnumber(L,"appid",iAppId);
lua_setnumber(L,"players",iPlayers);
lua_setnumber(L,"maxplayers",iMaxPlayers);
lua_setnumber(L,"bots",iBots);
lua_setstring(L,"type",szSvType);
lua_setstring(L,"env",szSvEnv);
lua_setnumber(L,"visibility",bVisibility);
lua_setnumber(L,"vac",bVac);
lua_setstring(L,"version",szVersion);
lua_pushstring(L,addr2str(naddr));
lua_pcall(L,2,1,iHandler);
if(lua_isnil(L,-1))
{
lua_pop(L,2);
bf.WriteBitsFromBuffer(&br,br.GetNumBitsLeft());
return true;
}
bf.WriteString(lua_getstring(L,"name"));
bf.WriteString(lua_getstring(L,"map"));
bf.WriteString(lua_getstring(L,"folder"));
bf.WriteString(lua_getstring(L,"game"));
bf.WriteWord(lua_getnumber(L,"appid"));
bf.WriteByte(lua_getnumber(L,"players"));
bf.WriteByte(lua_getnumber(L,"maxplayers"));
bf.WriteByte(lua_getnumber(L,"bots"));
bf.WriteByte(lua_getstring(L,"type")[0]);
bf.WriteByte(lua_getstring(L,"env")[0]);
bf.WriteByte(lua_getnumber(L,"visibility"));
bf.WriteByte(lua_getnumber(L,"vac"));
bf.WriteString(lua_getstring(L,"version"));
bf.WriteBitsFromBuffer(&br,br.GetNumBitsLeft());
lua_pop(L,2);
return true;
}

74
sv_a2s_fix.vcxproj Normal file
View file

@ -0,0 +1,74 @@
<?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>{9063DF3A-3CCF-497C-916F-E44CC01DE942}</ProjectGuid>
<RootNamespace>sv_a2s_fix</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</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)'=='Release|Win32'">
<OutDir>..\..\..\GMod9_Server\gmod9\lua\bin</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>D:\source2006\public\dlls;D:\source2006\dlls\hl2_dll;D:\source2006\game_shared\hl2;D:\source2006\game_shared\hl2mp;D:\source2006\game_shared;D:\source2006\dlls;D:\source2006\public\tier1;D:\source2006\public\tier0;D:\source2006\public;D:\source2006\common;D:\lua502\lua\lua502_sdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>D:\source2006\lib\public;D:\lua502\lua\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>lua502_sdk.lib;vstdlib.lib;tier0.lib;tier1.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMT.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Файлы исходного кода">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Заголовочные файлы">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
</ItemGroup>
</Project>

3
sv_a2s_fix.vcxproj.user Normal file
View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>