Difference between revisions of "Metamod:Source"

From AlliedModders Wiki
Jump to: navigation, search
m (Fixed link to Valve Software page... was linking to edit page before)
m
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
:{{owned_project}}
 
:{{owned_project}}
 
==Introduction==
 
==Introduction==
Metamod:Source is an API manager and interception handler that sits in between the [[Half-Life_2|Half-Life 2]] Engine (Source) and a subsequent Game Modification (MOD). It can dynamically load "SourceMM Plugins", written in C++, to intercept, override, and hook Engine and GameDLL API interfaces. It also allows for inter-plugin communication.  As a backend it contains [[SourceHook]], a powerful library for safely manipulating virtual table hooks.
+
Metamod:Source is an API manager and interception handler that sits in between the [[Half-Life_2|Half-Life 2]] Engine (Source) and a subsequent Game Modification (MOD). It can dynamically load "Metamod:Source Plugins", written in C++, to intercept, override, and hook Engine and GameDLL API interfaces. It also allows for inter-plugin communication.  As a backend it contains [[SourceHook]], a powerful library for safely manipulating virtual table hooks.
  
 
[[Category:Half-Life 2]]
 
[[Category:Half-Life 2]]
[[Category:SourceMM]]
+
[[Category:Metamod:Source Documentation]]
 +
 
 +
==Where to Download==
 +
Metamod:Source is hosted on [http://sourceforge.net/projects/sourcemm Source Forge] or can be accessed via the [http://www.sourcemm.net/ Metamod:Source Home Page].
  
 
==Naming Conventions==
 
==Naming Conventions==
Metamod:Source refers to the overall product and concept behind SourceMM.  SourceMM is the actual implementation and codebase.  For practical purposes the names are interchangeable, however, "Metamod:Source" is preferred for public relations/marketing purposes and SourceMM is preferred for programming purposes.
+
The name "SourceMM" is no longer used.
  
 
==History==
 
==History==
Line 18: Line 21:
  
 
====SourceHook Finalized====
 
====SourceHook Finalized====
After four major revisions, [[SourceHook]] was mature enough to be used in a production environment.  While [[User:PM|PM]] concentrated on fleshing out [[SourceHook]], [[User:BAILOPAN|BAILOPAN]] and [[User:Damaged Soul|DS]] created the GameDLL wrapper portion.
+
After four major revisions, [[SourceHook]] was mature enough to be used in a production environment.  While [[User:PM|PM]] concentrated on fleshing out [[SourceHook]], [[User:BAILOPAN|BAILOPAN]] and [[User:DS|DS]] created the GameDLL wrapper portion.
  
 
====Version 1.0====
 
====Version 1.0====
On May 6, 2005, Metamod:Source 1.0 was released with SourceHook v4.1 as a backend.  GameDLL wrapping was achieved by providing the engine with fake copies of the IServerGame* interfaces.  Once the true GameDLL location was known it would be loaded by SourceMM.  The fake interface then directly wrapped calls to the real GameDLL.
+
On May 6, 2005, Metamod:Source 1.0 was released with SourceHook v4.1 as a backend.  GameDLL wrapping was achieved by providing the engine with fake copies of the IServerGame* interfaces.  Once the true GameDLL location was known it would be loaded by Metamod:Source.  The fake interface then directly wrapped calls to the real GameDLL.
  
 
====Version 1.1====
 
====Version 1.1====
On October 21, 2005, the first major revision of SourceMM was released, featuring SourceHook v4.4, internal event listeners, dropped reliance on STL, and rewritten GameDLL hooking code.  The [[Day of Defeat|Day of Defeat:Source]] release by [[VALVe_Software|Valve Software]] revealed that the binary interface between the engine and mod wasn't necessarily public or current, and SourceMM's detection was improved for compatibility and speed.  Furthermore, SourceMM stopped wrapping the GameDLL interfaces and began using SourceHook to hook them.
+
On October 21, 2005, the first major revision of Metamod:Source was released, featuring SourceHook v4.4, internal event listeners, dropped reliance on STL, and rewritten GameDLL hooking code.  The [[Day of Defeat|Day of Defeat:Source]] release by [[VALVe_Software|Valve Software]] revealed that the binary interface between the engine and mod wasn't necessarily public or current, and MM:S's detection was improved for compatibility and speed.  Furthermore, Metamod:Source stopped wrapping the GameDLL interfaces and began using SourceHook to hook them.
  
 
====Version 1.2====
 
====Version 1.2====
On January 7th, 2006, SourceMM was updated for SourceHook v4.5, but received no major API changes.
+
On January 7th, 2006, Metamod:Source was updated for SourceHook v4.3, but received no major API changes.
 +
 
 +
====Version 1.3====
 +
On August 16th, 2006, Metamod:Source was updated for SourceHook v4.4, minor API changes, bug fixes, and a sync to the latest HL2SDK.
 +
 
 +
====Version 1.4====
 +
On April 5th, 2007, Metamod:Source was updated with API for [[Valve Server Plugin]] interface hooking and crash-safe user message enumeration. An experimental gameinfo.txt update tool was also added. No SourceHook changes were made in this release.
 +
 
 +
====Version 1.6====
 +
Currently in development, Metamod:Source received a near complete overhaul to abstract engine-specific code to support Orange Box.  Additionally, SourceHook received a massive overhaul and is now v5.0, adding global hooks and various major API simplifications.  It is the first backwards compatibility break since 1.1.
  
 
==Design Considerations==
 
==Design Considerations==
 
====Metamod====
 
====Metamod====
Originally, SourceMM was a plugin co-existing with SourceMod.  However, there are factories, pointers, and certain capabilities not possible from a [[Valve Server Plugin]].  Furthermore, the [[Half-Life 2]] engine does not properly unload VSPs, making debugging and resource unloading more difficult.  Eventually it was decided the added functionality and fine-tuned control outweighed the extra cost of having to configure an intercepting binary.
+
Originally, Metamod:Source was a plugin co-existing with SourceMod.  However, there are factories, pointers, and certain capabilities not possible from a [[Valve Server Plugin]].  Furthermore, the [[Half-Life 2]] engine does not properly unload VSPs, making debugging and resource unloading more difficult.  Eventually it was decided the added functionality and fine-tuned control outweighed the extra cost of having to configure an intercepting binary.
  
 
====Plugins====
 
====Plugins====
Plugins are specific to Metamod:Source.  This means that [[Valve Server Plugin]]s and [[SourceMM Plugins]] are entirely separate in the API characteristics.  While it is certainly possible to expose the necessary interfaces to VSPs, it creates an added layer of complexity for dealing with things that SourceMM might not directly control.  For example, when a SourceMM plugin is removed at runtime, all of the necessary hooks are also removed.  A VSP has no clear callback for detecting this event, therefore it would be more difficult to ensure proper unloading.  VSP and SMM plugins also have different ways of attaching and detaching server [[Cvars|cvars]] and [[Console commands|concmds]].
+
Plugins are specific to Metamod:Source.  This means that [[Valve Server Plugin]]s and [[Open_Source_Plugins_for_Metamod:Source|Metamod:Source Plugins]] are entirely separate in the API characteristics.  While it is certainly possible to expose the necessary interfaces to VSPs, it creates an added layer of complexity for dealing with things that Metamod:Source might not directly control.  For example, when a Metamod:Source plugin is removed at runtime, all of the necessary hooks are also removed.  A VSP has no clear callback for detecting this event, therefore it would be more difficult to ensure proper unloading.  VSP and MM:S plugins also have different ways of attaching and detaching server [[Cvars|cvars]] and [[Console commands|concmds]].
  
By keeping the plugin system isolated, SourceMM can also provide a unique set of console commands and API.  For example, plugins can listen for certain Metamod:Source-specific events and provide communication channels with other plugins.
+
By keeping the plugin system isolated, Metamod:Source can also provide a unique set of console commands and API.  For example, plugins can listen for certain Metamod:Source-specific events and provide communication channels with other plugins.
  
 
====Hooking====
 
====Hooking====
SourceMM is powered by [[SourceHook]], a versatile library for hooking virtual functions.  The original [[Half-Life 1]] engine used structs of function pointers which could easily be modified as they passed from one library to another.  However, HL2 is comprised almost entirely of pure virtual interfaces.  SourceHook was designed for declaring single hooks against a given virtual function and a this pointer, which is not only faster than a blanket hooking system like Metamod's, but more flexible and precise.
+
Metamod:Source is powered by [[SourceHook]], a versatile library for hooking virtual functions.  The original [[Half-Life 1]] engine used structs of function pointers which could easily be modified as they passed from one library to another.  However, HL2 is comprised almost entirely of pure virtual interfaces.  SourceHook was designed for declaring single hooks against a given virtual function and a this pointer, which is not only faster than a blanket hooking system like Metamod's, but more flexible and precise.
  
Hooking under SourceMM has a number of features that don't exist in a hooking system style like Metamod's, and it achieves something closer to [[Detours|detours]], rather than Metamod, which is hardcoded.  For example
+
Hooking under Metamod:Source has a number of features that don't exist in a hooking system style like Metamod's, and it achieves something closer to [[Detours|detours]], rather than Metamod, which is hardcoded.  For example
 
*You can change parent parameters during a hooked call
 
*You can change parent parameters during a hooked call
 
*You can hook member functions, both by a pre-existing declaration or given vtable offset
 
*You can hook member functions, both by a pre-existing declaration or given vtable offset
Line 47: Line 59:
  
 
==Documentation==
 
==Documentation==
For more information on installing, configuring, and coding for SourceMM, see [[:Category:Documentation (SourceMM)|Documentation]].
+
For more information on installing, configuring, and coding for Metamod:Source, see [[:Category:Documentation (SourceMM)|Documentation]].
  
 
==The Future==
 
==The Future==
While SourceMM is a stable/production product, more features are on the horizon.  There are distant plans for a [[Detours|detouring]] library and a library for efficiently automated [[Signature Scanning|signature scanning]].
+
While Metamod:Source is a stable/production product, more features are on the horizon.  There are distant plans for a [[Detours|detouring]] library and a library for efficiently automated [[Signature Scanning|signature scanning]].
  
 
==License==
 
==License==
SourceMM is licensed under the [[zLib/libpng License]].  It is free to use for both open-source and proprietary projects.
+
Metamod:Source is licensed under the [[zLib/libpng License]].  It is free to use for both open-source and proprietary projects.
  
 
==External Links==
 
==External Links==
Line 59: Line 71:
 
*[http://www.metamod.org/ Metamod Website]
 
*[http://www.metamod.org/ Metamod Website]
 
*[http://www.sourcemod.net/ SourceMod Website]
 
*[http://www.sourcemod.net/ SourceMod Website]
 +
*[http://resonus.net/doxygen_sourcemm/ Doxygen of Metamod:Source]

Latest revision as of 06:52, 5 October 2009

Comment
This project is owned by the Consortium that controls this wiki. Changes to this main page are allowed but patrolled.

Introduction

Metamod:Source is an API manager and interception handler that sits in between the Half-Life 2 Engine (Source) and a subsequent Game Modification (MOD). It can dynamically load "Metamod:Source Plugins", written in C++, to intercept, override, and hook Engine and GameDLL API interfaces. It also allows for inter-plugin communication. As a backend it contains SourceHook, a powerful library for safely manipulating virtual table hooks.

Where to Download

Metamod:Source is hosted on Source Forge or can be accessed via the Metamod:Source Home Page.

Naming Conventions

The name "SourceMM" is no longer used.

History

Metamod:Source is derived from the Metamod concept of intercepting calls between a game's engine and mod library. While not based on the same code, the API is designed to be similar and familiar to Half-Life 1 programmers.

SourceMod Core1

Initially, the SourceMod project was started as the next-generation continuation of the AMX Mod X project. It was designed to be a meta-interface layer for inter-communicating plugins. However, as development continued, it was soon realized that the Valve Server Plugin interface would not be sufficient to provide proper engine access.

Pavol Marko (core1 developer) decided to add "SourceHook" to SourceMod core1. It was embedded as a large library for hooking specific virtual table functions. After multiple revisions (see SourceHook history), it became apparent that 1)SourceHook needed to be game and interface generic, and 2)SourceMod and SourceHook needed to be split into two separate projects. The logic behind this was that SourceHook needed to be a layer above Valve Server Plugins, in order to properly manage hooks with the least possibility of conflicts. Furthermore, SourceMod should be a plugin to the SourceHook interface, rather than managing it. This decision can be likened to Admin-Mod's early decision to split into the first Metamod project.

SourceHook Finalized

After four major revisions, SourceHook was mature enough to be used in a production environment. While PM concentrated on fleshing out SourceHook, BAILOPAN and DS created the GameDLL wrapper portion.

Version 1.0

On May 6, 2005, Metamod:Source 1.0 was released with SourceHook v4.1 as a backend. GameDLL wrapping was achieved by providing the engine with fake copies of the IServerGame* interfaces. Once the true GameDLL location was known it would be loaded by Metamod:Source. The fake interface then directly wrapped calls to the real GameDLL.

Version 1.1

On October 21, 2005, the first major revision of Metamod:Source was released, featuring SourceHook v4.4, internal event listeners, dropped reliance on STL, and rewritten GameDLL hooking code. The Day of Defeat:Source release by Valve Software revealed that the binary interface between the engine and mod wasn't necessarily public or current, and MM:S's detection was improved for compatibility and speed. Furthermore, Metamod:Source stopped wrapping the GameDLL interfaces and began using SourceHook to hook them.

Version 1.2

On January 7th, 2006, Metamod:Source was updated for SourceHook v4.3, but received no major API changes.

Version 1.3

On August 16th, 2006, Metamod:Source was updated for SourceHook v4.4, minor API changes, bug fixes, and a sync to the latest HL2SDK.

Version 1.4

On April 5th, 2007, Metamod:Source was updated with API for Valve Server Plugin interface hooking and crash-safe user message enumeration. An experimental gameinfo.txt update tool was also added. No SourceHook changes were made in this release.

Version 1.6

Currently in development, Metamod:Source received a near complete overhaul to abstract engine-specific code to support Orange Box. Additionally, SourceHook received a massive overhaul and is now v5.0, adding global hooks and various major API simplifications. It is the first backwards compatibility break since 1.1.

Design Considerations

Metamod

Originally, Metamod:Source was a plugin co-existing with SourceMod. However, there are factories, pointers, and certain capabilities not possible from a Valve Server Plugin. Furthermore, the Half-Life 2 engine does not properly unload VSPs, making debugging and resource unloading more difficult. Eventually it was decided the added functionality and fine-tuned control outweighed the extra cost of having to configure an intercepting binary.

Plugins

Plugins are specific to Metamod:Source. This means that Valve Server Plugins and Metamod:Source Plugins are entirely separate in the API characteristics. While it is certainly possible to expose the necessary interfaces to VSPs, it creates an added layer of complexity for dealing with things that Metamod:Source might not directly control. For example, when a Metamod:Source plugin is removed at runtime, all of the necessary hooks are also removed. A VSP has no clear callback for detecting this event, therefore it would be more difficult to ensure proper unloading. VSP and MM:S plugins also have different ways of attaching and detaching server cvars and concmds.

By keeping the plugin system isolated, Metamod:Source can also provide a unique set of console commands and API. For example, plugins can listen for certain Metamod:Source-specific events and provide communication channels with other plugins.

Hooking

Metamod:Source is powered by SourceHook, a versatile library for hooking virtual functions. The original Half-Life 1 engine used structs of function pointers which could easily be modified as they passed from one library to another. However, HL2 is comprised almost entirely of pure virtual interfaces. SourceHook was designed for declaring single hooks against a given virtual function and a this pointer, which is not only faster than a blanket hooking system like Metamod's, but more flexible and precise.

Hooking under Metamod:Source has a number of features that don't exist in a hooking system style like Metamod's, and it achieves something closer to detours, rather than Metamod, which is hardcoded. For example

  • You can change parent parameters during a hooked call
  • You can hook member functions, both by a pre-existing declaration or given vtable offset
  • You can call the original function and still fire its associated hooks, or you can call it without firing hooks in order to prevent infinite recursion

Documentation

For more information on installing, configuring, and coding for Metamod:Source, see Documentation.

The Future

While Metamod:Source is a stable/production product, more features are on the horizon. There are distant plans for a detouring library and a library for efficiently automated signature scanning.

License

Metamod:Source is licensed under the zLib/libpng License. It is free to use for both open-source and proprietary projects.

External Links