-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
512f97d
commit bf302f6
Showing
10 changed files
with
1,027 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Building AdvSpec plugin | ||
============================== | ||
|
||
Notice | ||
- | ||
AdvSpec is not yet available for Linux & OS X. | ||
|
||
Requirements | ||
- | ||
* **[Windows]** Visual Studio or Visual Express C++ | ||
* cmake 2.6+ | ||
* source-sdk-2013 - https://github.com/ValveSoftware/source-sdk-2013/ | ||
|
||
Building | ||
- | ||
**Windows** | ||
`cmake -DHL2SDK=c:\path\to\source-sdk-2013\mp\src -G "Visual Studio 10" ..` | ||
Then open in Visual Studio/C++ Express and build. Note the `\mp\src` in the SDK path! | ||
|
||
Open advspec properties, then in `Linker -> Input -> Ignore Specific Default Libraries`, change `libcmt`, to `libcmtd` | ||
Do this for Debug and Release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
cmake_minimum_required(VERSION 2.6) | ||
|
||
project(statusspec) | ||
|
||
set(PACKAGE "statusspec") | ||
set(PACKAGE_VERSION "v0.1") | ||
set(PACKAGE_BUGREPORT "https://github.com/fwdcp/StatusSpec/issues") | ||
set(PACKAGE_NAME "${PACKAGE}") | ||
set(PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}") | ||
set(PACKAGE_TARNAME "${PACKAGE}_${PACKAGE_VERSION}") | ||
set(PACKAGE_URL "https://github.com/fwdcp/StatusSpec") | ||
set(VERSION "${PACKAGE_VERSION}") | ||
|
||
include_directories(${PROJECT_BINARY_DIR}) | ||
# Put final product in 'bin' folder | ||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") | ||
|
||
# Include source and hl2sdk | ||
include_directories(${PROJECT_SOURCE_DIR}/src) | ||
include_directories(${HL2SDK}/common) | ||
include_directories(${HL2SDK}/public) | ||
include_directories(${HL2SDK}/public/tier0) | ||
include_directories(${HL2SDK}/public/tier1) | ||
include_directories(${HL2SDK}/game/client) | ||
include_directories(${HL2SDK}/game/shared) | ||
|
||
set(HDR_PUBLIC | ||
src/statusspec.h | ||
src/offsets.h | ||
src/stdafx.h | ||
src/vfuncs.h | ||
) | ||
|
||
set(SOURCES | ||
src/statusspec.cpp | ||
src/offsets.cpp | ||
src/vfuncs.cpp | ||
) | ||
|
||
source_group("Header Files" FILES ${HDR_PUBLIC}) | ||
source_group("Source FIles" FILES ${SOURCES}) | ||
|
||
# Setup defines, compiler options and linker options for each platform | ||
if(UNIX) # Common Unix settings | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
# Malloc fix | ||
include_directories(/usr/include/malloc) | ||
set(SymbolVisibility "hidden") | ||
set(GCC_ExtraCompilerFlags "") | ||
set(GCC_ExtraLinkerFlags "") | ||
set(WarnFlags "-Wall -Wextra -Wshadow -Wno-invalid-offsetof -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -fdiagnostics-show-option -Wformat -Wformat-security") | ||
|
||
#Set Optimizer Level | ||
if(CMAKE_BUILD_TYPE MATCHES DEBUG) | ||
set(OptimizerLevel "-gdwarf-2 -g -O0") | ||
add_definitions(-DDEBUG -D_DEBUG -DGNUC -DPOSIX -D_OSX -DOSX -D_DARWIN_UNLIMITED_SELECT -DFD_SETSIZE=10240 -DQUICKTIME_VIDEO -DFORCE_QUICKTIME -DGL_GLEXT_PROTOTYPES -DDX_TO_GL_ABSTRACTION -D_MBCS -D_DLL_EXT=.dylib -D_POSIX=1) | ||
else() | ||
set(OptimizerLevel "-gdwarf-2 -g -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer") | ||
add_definitions(-DNDEBUG -DGNUC -DPOSIX -D_OSX -DOSX -D_DARWIN_UNLIMITED_SELECT -DFD_SETSIZE=10240 -DQUICKTIME_VIDEO -DFORCE_QUICKTIME -DGL_GLEXT_PROTOTYPES -DDX_TO_GL_ABSTRACTION -D_MBCS -D_DLL_EXT=.dylib -D_POSIX=1) | ||
endif() | ||
|
||
set(CFLAGS "-arch i386 -m32 -march=prescott -momit-leaf-frame-pointer -mtune=core2 ${WarnFlags} -fvisibility=${SymbolVisibility} ${OptimizerLevel} -pipe ${GCC_ExtraCompilerFlags} -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE -mmacosx-version-min=10.5 -fasm-blocks") | ||
set(COMPILER_FLAGS ${CFLAGS}) | ||
add_definitions(-DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE) | ||
set(LINKER_FLAGS "${CFLAGS} ${GCC_ExtraLinkerFlags} ${OptimizerLevel} -dynamiclib -current_version 1.0 -compatibility_version 1.0 -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms") | ||
else() # Linux | ||
set(SymbolVisibility "hidden") | ||
set(GCC_ExtraCompilerFlags "-U_FORTIFY_SOURCE") | ||
set(GCC_ExtraLinkerFlags "") | ||
set(WarnFlags "-Wall -Wextra -Wshadow -Wno-invalid-offsetof -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -fdiagnostics-show-option -Wformat -Wformat-security") | ||
|
||
# Set Optimizer Level | ||
if(CMAKE_BUILD_TYPE MATCHES DEBUG) | ||
set(OptimizerLevel "-gdwarf-2 -g -O0") | ||
add_definitions(-DDEBUG -D_DEBUG -DPOSIX -DGNUC -DLINUX -D_LINUX -DRAD_TELEMETRY_DISABLED -DBINK_VIDEO -DGL_GLEXT_PROTOTYPES -DDX_TO_GL_ABSTRACTION -DUSE_SDL -D_MBCS -D_EXTERNAL_DLL_EXT=.so -D_DLL_EXT=.so -D_LINUX=1 -D_POSIX=1 -DLINUX=1 -DPOSIX=1) | ||
else() | ||
set(OptimizerLevel "-gdwarf-2 -g -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize -fpredictive-commoning -funswitch-loops") | ||
add_definitions(-DNDEBUG -DPOSIX -DGNUC -DLINUX -D_LINUX -DRAD_TELEMETRY_DISABLED -DBINK_VIDEO -DGL_GLEXT_PROTOTYPES -DDX_TO_GL_ABSTRACTION -DUSE_SDL -D_MBCS -D_EXTERNAL_DLL_EXT=.so -D_DLL_EXT=.so -D_LINUX=1 -D_POSIX=1 -DLINUX=1 -DPOSIX=1) | ||
endif() | ||
|
||
set(CFLAGS "-m32 -march=pentium4 -mtune=core2 -msse2 -mfpmath=sse ${WarnFlags} -fvisibility=${SymbolVisibility} ${OptimizerLevel} -pipe ${GCC_ExtraCompilerFlags} -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE") | ||
set(COMPILER_FLAGS ${CFLAGS}) | ||
add_definitions(-DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE) | ||
set(LINKER_FLAGS "${CFLAGS} ${GCC_ExtraLinkerFlags} ${OptimizerLevel} -Wl,--build-id -shared -Wl,--no-undefined -Wl,-Map,$(@:.so=).map -static-libgcc -Wl,--start-group -Wl,--end-group -lm -ldl -lpthread -l:ld-linux.so.2") | ||
endif() | ||
else() # Windows | ||
# Force use of static libs | ||
# Credit SteveL & brofield on StackOverflow | ||
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINOFO) | ||
string(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}") | ||
endforeach() | ||
|
||
add_definitions(/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE) | ||
set(COMPILER_FLAGS "/EHsc /DR- /W3 /nologo /Zi /TP") | ||
set(LINKER_FLAGS "/MACHINE:X86 /subsystem:windows /NODEFAULTLIB:libc /NODEFAULTLIB:libcd") | ||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt") | ||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmt") | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}") | ||
|
||
# Create the plugin | ||
add_library(statusspec SHARED | ||
${HDR_PUBLIC} | ||
${SOURCES}) | ||
|
||
# Remove 'lib' prefix | ||
set_target_properties(statusspec PROPERTIES PREFIX "") | ||
|
||
# Link sdk libraries | ||
if(WIN32) | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/tier0.lib) | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/tier1.lib) | ||
else() | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/osx32/libtier0.dylib) | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/osx32/tier1.a) | ||
else() | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/linux32/libtier0.so) | ||
target_link_libraries(statusspec ${HL2SDK}/lib/public/linux32/tier1.a) | ||
endif() | ||
|
||
target_link_libraries(statusspec dl) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
AdvSpec | ||
Copyright (c) 2013, Matthew McNamara | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
/* | ||
* offsets.cpp | ||
* WebSpec project | ||
* Modified for AdvSpec, used in StatusSpec | ||
* | ||
* Copyright (c) 2013 Matthew McNamara | ||
* BSD 2-Clause License | ||
* http://opensource.org/licenses/BSD-2-Clause | ||
* | ||
*/ | ||
|
||
#include "offsets.h" | ||
|
||
int WSOffsets::pCTFPlayer__m_iTeamNum = 0; | ||
int WSOffsets::pCTFPlayer__m_nPlayerCond = 0; | ||
int WSOffsets::pCTFPlayer___condition_bits = 0; | ||
int WSOffsets::pCTFPlayer__m_nPlayerCondEx = 0; | ||
int WSOffsets::pCTFPlayer__m_nPlayerCondEx2 = 0; | ||
|
||
//================================================================================= | ||
// Find the offsets for all stored NetVars | ||
// TODO: change to bool when an offset can't be found | ||
//================================================================================= | ||
void WSOffsets::PrepareOffsets() { | ||
WSOffsets::pCTFPlayer__m_iTeamNum = WSOffsets::FindOffsetOfClassProp("CTFPlayer", "m_iTeamNum"); | ||
WSOffsets::pCTFPlayer__m_nPlayerCond = WSOffsets::FindOffsetOfClassProp("CTFPlayer", "m_nPlayerCond"); | ||
WSOffsets::pCTFPlayer___condition_bits = WSOffsets::FindOffsetOfClassProp("CTFPlayer", "_condition_bits"); | ||
WSOffsets::pCTFPlayer__m_nPlayerCondEx = WSOffsets::FindOffsetOfClassProp("CTFPlayer", "_condition_bits"); | ||
WSOffsets::pCTFPlayer__m_nPlayerCondEx2 = WSOffsets::FindOffsetOfClassProp("CTFPlayer", "m_nPlayerCondEx2"); | ||
} | ||
|
||
//================================================================================= | ||
// Loop through all server classes until className is found, then crawl through the | ||
// class to find the property | ||
// TODO: return -1 when an offset is not found | ||
//================================================================================= | ||
int WSOffsets::FindOffsetOfClassProp(const char *className, const char *propName) { | ||
//ServerClass *sc = serverGameDLL->GetAllServerClasses(); | ||
ClientClass *sc = pClient->GetAllClasses(); | ||
while (sc) { | ||
if (Q_strcmp(sc->GetName(), className) == 0) { | ||
//SendTable *sTable = sc->m_pTable; | ||
RecvTable *sTable = sc->m_pRecvTable; | ||
if (sTable) { | ||
int offset = 0; | ||
bool found = WSOffsets::CrawlForPropOffset(sTable, propName, offset); | ||
if (!found) | ||
offset = 0; | ||
return offset; | ||
} | ||
} | ||
sc = sc->m_pNext; | ||
} | ||
return 0; | ||
} | ||
|
||
int WSOffsets::FindOffsetOfArrayEnt(const char *classname, const char *arrayName, int element) { | ||
ClientClass *cc = pClient->GetAllClasses(); | ||
while (cc) { | ||
if (Q_strcmp(cc->GetName(), classname) == 0) { | ||
RecvTable *rTable = cc->m_pRecvTable; | ||
if (rTable) { | ||
int offset = 0; | ||
bool found = WSOffsets::CrawlForArrayEnt(rTable, arrayName, element, offset); | ||
if (!found) | ||
offset = 0; | ||
return offset; | ||
} | ||
} | ||
cc = cc->m_pNext; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
//================================================================================= | ||
// Search through a class table, and any subtables, for a given property name | ||
//================================================================================= | ||
bool WSOffsets::CrawlForPropOffset(RecvTable *sTable, const char *propName, int &offset) { | ||
for (int i=0; i < sTable->GetNumProps(); i++) { | ||
//SendProp *sProp = sTable->GetProp(i); | ||
RecvProp *sProp = sTable->GetProp(i); | ||
if (strcmp(sProp->GetName(),"000") == 0) //End of an array | ||
continue; | ||
|
||
//SendTable *sChildTable = sProp->GetDataTable(); | ||
RecvTable *sChildTable = sProp->GetDataTable(); | ||
|
||
//Check if it is an array, don't care for these atm so skip them | ||
bool isArray = false; | ||
if (sChildTable && sChildTable->GetNumProps() > 0) { | ||
if ( !strcmp(sChildTable->GetProp(0)->GetName(), "000") | ||
|| !strcmp(sChildTable->GetProp(0)->GetName(), "lengthproxy")) | ||
isArray = true; | ||
} | ||
|
||
if (!isArray) { | ||
//If we have our property, add to the offset and start returning | ||
if (strcmp(sProp->GetName(), propName) == 0) { | ||
offset += sProp->GetOffset(); | ||
return true; | ||
} | ||
|
||
//If we find a subtable, search it for the property, | ||
//but keep current offset in case it isn't found here | ||
if (sProp->GetType() == DPT_DataTable) { | ||
int origOffset = offset; | ||
offset += sProp->GetOffset(); | ||
bool found = WSOffsets::CrawlForPropOffset(sChildTable, propName, offset); | ||
if (found) { | ||
return true; | ||
} else { | ||
offset = origOffset; | ||
} | ||
} | ||
} else { | ||
continue; | ||
} | ||
|
||
if (strcmp(sProp->GetName(), "000") == 0) //More array stuff from dumping function, may not be needed here | ||
break; | ||
} | ||
return false; | ||
} | ||
|
||
bool WSOffsets::CrawlForArrayEnt(RecvTable *sTable, const char *propName, int element, int &offset) { | ||
for (int i=0; i < sTable->GetNumProps(); i++) { | ||
RecvProp *sProp = sTable->GetProp(i); | ||
if (strcmp(sProp->GetName(),"000") == 0) //End of an array | ||
continue; | ||
|
||
//SendTable *sChildTable = sProp->GetDataTable(); | ||
RecvTable *sChildTable = sProp->GetDataTable(); | ||
|
||
//Check if it is an array, don't care for these atm so skip them | ||
bool isArray = false; | ||
if (sChildTable && sChildTable->GetNumProps() > 0) { | ||
if ( !strcmp(sChildTable->GetProp(0)->GetName(), "000") | ||
|| !strcmp(sChildTable->GetProp(0)->GetName(), "lengthproxy")) | ||
isArray = true; | ||
} | ||
|
||
if (!isArray) { | ||
//If we have our property, add to the offset and start returning | ||
if (strcmp(sProp->GetName(), propName) == 0) { | ||
offset += sProp->GetOffset(); | ||
return true; | ||
} | ||
|
||
//If we find a subtable, search it for the property, | ||
//but keep current offset in case it isn't found here | ||
if (sProp->GetType() == DPT_DataTable) { | ||
int origOffset = offset; | ||
offset += sProp->GetOffset(); | ||
bool found = WSOffsets::CrawlForArrayEnt(sChildTable, propName, element, offset); | ||
if (found) { | ||
return true; | ||
} else { | ||
offset = origOffset; | ||
} | ||
} | ||
} else { | ||
if (strcmp(sProp->GetName(), propName) != 0) | ||
continue; | ||
|
||
//We have our array | ||
offset += sProp->GetOffset(); | ||
|
||
int elements = sProp->GetDataTable()->GetNumProps(); | ||
if (element < 0 || element >= elements) | ||
return false; | ||
|
||
offset += sProp->GetDataTable()->GetProp(element)->GetOffset(); | ||
return true; | ||
} | ||
|
||
if (strcmp(sProp->GetName(), "000") == 0) //More array stuff from dumping function, may not be needed here | ||
break; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* offsets.h | ||
* WebSpec project | ||
* Modified for AdvSpec, used in StatusSpec | ||
* | ||
* Copyright (c) 2013 Matthew McNamara | ||
* BSD 2-Clause License | ||
* http://opensource.org/licenses/BSD-2-Clause | ||
* | ||
*/ | ||
|
||
#ifndef OFFSETS_H | ||
#define OFFSETS_H | ||
|
||
#include "cdll_client_int.h" | ||
#include "client_class.h" | ||
|
||
extern IBaseClientDLL *pClient; | ||
|
||
class WSOffsets { | ||
public: | ||
static int pCTFPlayer__m_iTeamNum; | ||
static int pCTFPlayer__m_nPlayerCond; | ||
static int pCTFPlayer___condition_bits; | ||
static int pCTFPlayer__m_nPlayerCondEx; | ||
static int pCTFPlayer__m_nPlayerCondEx2; | ||
|
||
static void PrepareOffsets(); | ||
static int FindOffsetOfClassProp(const char *className, const char *propName); | ||
static int FindOffsetOfArrayEnt(const char *classname, const char *arrayName, int element); | ||
|
||
private: | ||
static bool CrawlForPropOffset(RecvTable *sTable, const char *propName, int &offset); | ||
static bool CrawlForArrayEnt(RecvTable *sTable, const char *propName, int element, int &offset); | ||
}; | ||
|
||
#define MakePtr( cast, ptr, addValue ) (cast)( (unsigned long)(ptr) + (unsigned long)(addValue)) | ||
|
||
#endif |
Oops, something went wrong.