|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThe Overlay Mgr, as seen above, is a managed wrapper around the raphook.dll by Ray Adam's (ATI Tray Tools), which supports overlays in D3D and OpenGL. The application simply makes it possible to use your own plugins and display your own numbers/strings in the overlay, which was not possible on Nvidia Cards before.
BackgroundSome of you might know my previous article about Overlay Tools. Those worked fine with my ATI card, but since I now got a Nvidia card it won't even create the overlay ( Therefore I looked quite some time for an alternative, but haven't found anything satisfying. So I decided to go with the overlay DLL provided in ATI Tray Tools/NVTray. Using the CodeThe program is divided into three parts. I. OverlayWrapperThe Overlay Wrapper library is a native wrapper around the raphook.dll (which seems to only support 32-bit Windows by the way) and provides the basic methods for showing/hiding the overlay, as well as editing the data shown. The data, which can be set in the As the library is based upon the [Flags]
public enum eItems {
GPUClock = 1,
MemClock = 2,
GPUTemp = 4,
EnvTemp = 8,
FanSpeed = 16,
FTM = 32,
RenderAPI = 64,
SMU = 128,
FVM = 256,
CustomString = 1024
}
II. OverlayMgrThe Overlay Manager, the main program, uses the wrapper to display the plugins selected. The plugins are loaded via reflection (all DLLs in the plugins folder are checked): /// <summary>
/// Load Plugins
/// </summary>
public static void LoadPlugins() {
if (!Directory.Exists("plugins"))
Directory.CreateDirectory("plugins");
Evidence ev = new Evidence();
ev.AddAssembly(typeof (MainForm).Assembly);
ev.AddAssembly(typeof (Overlay).Assembly);
foreach (string pl in Directory.GetFiles("plugins", "*.dll",
SearchOption.TopDirectoryOnly)) {
try {
Assembly a = Assembly.LoadFile(Path.GetFullPath(pl), ev);
foreach (Type t in a.GetExportedTypes()) {
if (typeof (IPlugin).IsAssignableFrom(t) && !t.IsAbstract) {
IPlugin plugin;
string data = Path.GetDirectoryName(pl) + "\\" +
Path.GetFileNameWithoutExtension(pl) + ".cfg";
if (t.IsSerializable && File.Exists(data)) {
using (FileStream fs = new FileStream
(data, FileMode.Open, FileAccess.Read)) {
BinaryFormatter bf = new BinaryFormatter();
bf.Binder = new FixedBinder();
plugin = (IPlugin) bf.Deserialize(fs);
}
}
else plugin = (IPlugin) Activator.CreateInstance(t);
m_Plugins.Add(plugin);
if (plugin.Active)
plugin.Load();
}
}
}
catch (Exception e) {
Console.WriteLine(e);
continue;
}
}
}
When writing that part of the code, I had to decide how I was going to save the settings of the individual plugins. I decided to go with standard serialization and therefore just serialize the whole III. PluginsThe plugin system is quite easy: You just have to implement the public interface IPlugin {
string Name { get; }
string Description { get; }
bool Active { get; set; }
bool Load();
bool Unload();
void ShowConfig();
void Tick();
}
The Advantages/DisadvantagesThe main advantage of this approach is that you don't really have to bother about hooking, drivers and different manufacturers when doing everything yourself/using But all in all, I would say that this overlay should be enough for most purposes, especially for those people who only want to display some small data while playing games. History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||