Table of Contents
HookshotDll can read from an optional configuration file that lists the hook modules and injected DLLs it should load. The configuration file, Hookshot.ini, follows standard INI format: name-value pairs scoped into different sections.
HookshotDll first checks for a configuration file located in the same directory as the target application executable. If a configuration file is not found in that location, it then checks for a configuration file located in the same directory as itself. If HookshotDll cannot find a configuration file, it applies the following default settings and behaviors.
- Logging is disabled.
- All hook modules located in the same directory of the target application are loaded.
- No injected DLLs are loaded.
If HookshotDll finds a malformed configuration file, it will output an error message indicating the problem and output the details to a log file, but otherwise not apply any non-default settings.
Examples of Configuration Files
Suppose three applications, App1.exe, App2.exe, and App3.exe, all located in C:\Directory\, are to be configured for use with Hookshot. The contents of C:\Directory\Hookshot.ini are shown below.
LogLevel = 0
HookModule = SomeRandomHooks
Inject = C:\AnyLibrary.dll
; Comments are also supported,
; as long as they are on lines of their own.
[App1.exe]
HookModule = HooksA
HookModule = HooksA2
; Hook module names can contain spaces.
HookModule = Hooks A 3
[App2.exe]
HookModule = HooksB
Inject = C:\LibB.dll
Inject = C:\LibB2.dll
This configuration file would result in the following behavior.
- Hook module
SomeRandomHookswould be loaded for all ofApp1.exe,App2.exe, andApp3.exe, and likewise the DLL fileC:\AnyLibrary.dllwould be injected into all three. - Hook modules
HooksA,HooksA2, andHooks A 3would additionally be loaded forApp1.exeonly. - Hook module
HooksBwould additionally be loaded forApp2.exeonly, and likewise the DLL filesC:\LibB.dllandC:\LibB2.dllwould only be injected intoApp2.exe.
A second example is shown below, demonstrating how to supply a configuration file but still preserve Hookshot's default behavior of loading all the hook modules it finds in the same directory as the target application's executable file. This is what Hookshot does in the absence of a configuration file, but Hookshot still offers that behavior if it is specifically requested in a configuration file.
LogLevel = 2
UseConfiguredHookModules = no
Inject = C:\AnyLibrary.dll
; Because UseConfiguredHookModules is set to "no" Hookshot ignores all HookModule lines.
HookModule = SomeRandomHooks
[App2.exe]
Inject = C:\LibB.dll
Inject = C:\LibB2.dll
; This is also ignored because of the value of UseConfiguredHookModules.
HookModule = HooksB
In the example above, logging is enabled at verbosity level 2, and Hookshot will load all hook modules it finds, irrespective of the application's executable file name. Injected DLLs can still be specified as in the previous example and are still effective the same way.
Available Scopes and Settings
There are no settings that are required to be specified in a configuration file for said configuration file to be valid. All settings are optional. A completely empty configuration file is perfectly valid but would result in logging being disabled, no hook modules being loaded, and no DLLs being injected into the target application.
At global scope (i.e. at the top of the file, before any sections are listed), the following settings are supported. Settings in this scope are applied to all executables in the same directory as the configuration file.
- LogLevel, an integer value used to configure logging. This is generally only useful when troubleshooting. When logging is enabled, messages produced by Hookshot are written to a file on the current user's desktop that is named to identify Hookshot, the executable name, and the process ID number. A value for this setting should only be specified once.
- 0 means logging is disabled. This is the default.
- 1 means to include error messages only.
- 2 means to include errors and warnings.
- 3 means to include errors, warnings, and informational messages.
- 4 means to include errors, warnings, informational messages, and internal debugging messages.
- HookModule, which names a hook module to load. Multiple hook modules may be specified.
- Hook modules have file names of the form
[Name].HookModule.(32|64).dll. Only the[Name]part should be specified in the configuration file. - For example, a hook module distributed as
SomeRandomHooks.HookModule.32.dllandSomeRandomHooks.HookModule.64.dllwould be identified asSomeRandomHooksin the configuration file.
- Hook modules have file names of the form
- Inject, which identifies the file name of an injected DLL.
- Hookshot passes the value of this setting directly to the system without modification.
- The system's directory search order for locating DLLs determines how the path is interpreted.
- UseConfiguredHookModules, a Boolean value that is used to tell Hookshot if it should load the hook modules specified in the configuration file or use its default behavior of loading all hook modules in the same directory as the target application's executable file.
- Default value is
yesif a configuration file is present, valid, and non-empty andnootherwise. - This is useful for turning on logging or specifying injected DLLs without affecting how Hookshot looks for hook modules.
- Default value is
- LoadHookModulesFromHookshotDirectory, a Boolean value that is used to tell HookshotDll whether or not it should look in the same directory as itself for hook modules instead of the target executable's directory.
- Default value is
no, which means that HookshotDll will look in the target executable's directory for hook modules.
- Default value is
Hookshot additionally supports per-executable scopes in the configuration file. The settings contained within each are applied only to the executable whose file name matches the configuration file section name. Each per-executable scope can contain values for HookModule and Inject.
Other than the fact that the global scope must be at the top of the file, the ordering of sections with respect to one another does not matter. Furthermore, the ordering of HookModule and Inject settings within a section also generally does not matter. Hookshot first loads all applicable hook modules in the order they appear in the configuration file and, once this is complete, loads applicable injected DLLs in the order they appear in the configuration file.