C# Class EasyHook.Config

Currently only provides a mechanism to register assemblies in the GAC.
Datei anzeigen Open project: gerich-home/lua-inject

Public Methods

Method Description
Register ( String InDescription ) : void

REQUIRES ADMIN PRIVILEGES. Installs EasyHook and all given user NET assemblies into the GAC and ensures that all references are cleaned up if the installing application is shutdown. Cleanup does not depend on the calling application...

ATTENTION: There are some problems when debugging processes whose libraries are added to the GAC. Visual Studio won't start the debug session! There is only one chance for you to workaround this issue if you want to install libraries AND debug them simultanously. This is simply to debug only one process which is the default setting of Visual Studio. Because the libraries are added to the GAC AFTER Visual Studio has initialized the debug session, there won't be any conflicts; at least so far...

In debug versions of EasyHook, you may also check the "Application" event log, which holds additional information about the GAC registration, after calling this method. In general this method works transactionally. This means if something goes wrong, the GAC state of all related libraries won't be violated!

The problem with NET assemblies is that the CLR only searches the GAC and directories starting with the application base directory for assemblies. To get injected assemblies working either all of them have to be located under the target base directory (which is not suitable in most cases) or reside in the GAC.

EasyHook provides a way to automatically register all of its own assemblies and custom ones temporarily in the GAC. It also ensures that all of these assemblies are removed if the installing process exists. So you don't need to care about and may write applications according to the XCOPY standard. If your application ships with an installer, you may statically install all of your assemblies and the ones of EasyHook into the GAC. In this case just don't call Register.

Of course EasyHook does also take care of multiple processes using the same injection libraries. So if two processes are sharing some of those DLLs, a stable reference counter ensures that the libraries are kept in the GAC if one process is terminated while the other continues running and so continues holding a proper GAC reference.

Please note that in order to add your library to the GAC, it has to be a valid NET assembly and expose a so called "Strong Name". Assemblies without a strong name will be rejected by this method!

Private Methods

Method Description
DebugPrint ( EventLogEntryType InType, String InMessage ) : void
PrintComment ( String InMessage ) : void
PrintError ( String InMessage ) : void
PrintWarning ( String InMessage ) : void
RunCommand ( String InFriendlyName, System.Boolean InWaitForExit, System.Boolean InShellExecute, String InPath, String InArguments ) : void

Method Details

Register() public static method

REQUIRES ADMIN PRIVILEGES. Installs EasyHook and all given user NET assemblies into the GAC and ensures that all references are cleaned up if the installing application is shutdown. Cleanup does not depend on the calling application...

ATTENTION: There are some problems when debugging processes whose libraries are added to the GAC. Visual Studio won't start the debug session! There is only one chance for you to workaround this issue if you want to install libraries AND debug them simultanously. This is simply to debug only one process which is the default setting of Visual Studio. Because the libraries are added to the GAC AFTER Visual Studio has initialized the debug session, there won't be any conflicts; at least so far...

In debug versions of EasyHook, you may also check the "Application" event log, which holds additional information about the GAC registration, after calling this method. In general this method works transactionally. This means if something goes wrong, the GAC state of all related libraries won't be violated!

The problem with NET assemblies is that the CLR only searches the GAC and directories starting with the application base directory for assemblies. To get injected assemblies working either all of them have to be located under the target base directory (which is not suitable in most cases) or reside in the GAC.

EasyHook provides a way to automatically register all of its own assemblies and custom ones temporarily in the GAC. It also ensures that all of these assemblies are removed if the installing process exists. So you don't need to care about and may write applications according to the XCOPY standard. If your application ships with an installer, you may statically install all of your assemblies and the ones of EasyHook into the GAC. In this case just don't call Register.

Of course EasyHook does also take care of multiple processes using the same injection libraries. So if two processes are sharing some of those DLLs, a stable reference counter ensures that the libraries are kept in the GAC if one process is terminated while the other continues running and so continues holding a proper GAC reference.

Please note that in order to add your library to the GAC, it has to be a valid NET assembly and expose a so called "Strong Name". Assemblies without a strong name will be rejected by this method!

/// At least one of the files specified could not be found! /// /// Unable to load at least one of the given files for reflection. /// /// At least one of the given files does not have a strong name. ///
public static Register ( String InDescription ) : void
InDescription String /// A description under which the installed files should be referenced. ///
return void