public static int Main(String inParam) { if (inParam == null) { return(0); } var ptr = (IntPtr)Int64.Parse(inParam, NumberStyles.HexNumber); var connection = HostConnectionData.LoadData(ptr); if (connection.State != HostConnectionData.ConnectionState.Valid) { return((int)connection.State); } // Adjust host PID in case of WOW64 bypass and service help... connection.UnmanagedInfo.m_HostPID = connection.RemoteInfo.HostPID; try { // Prepare parameter array. var paramArray = new object[1 + connection.RemoteInfo.UserParams.Length]; // The next type cast is not redundant because the object needs to be an explicit IContext // when passed as a parameter to the IEntryPoint constructor and Run() methods. paramArray[0] = (RemoteHooking.IContext)connection.UnmanagedInfo; for (var i = 0; i < connection.RemoteInfo.UserParams.Length; i++) { paramArray[i + 1] = connection.RemoteInfo.UserParams[i]; } // Note: at this point all but the first parameter are still binary encoded. // Load the user library and initialize the IEntryPoint. return(LoadUserLibrary(connection.RemoteInfo.UserLibraryName, connection.RemoteInfo.UserLibrary, paramArray, connection.HelperInterface)); } catch (Exception ExtInfo) { Config.PrintWarning(ExtInfo.ToString()); return(-1); } finally { if (_connectedChannels.Contains(connection.RemoteInfo.ChannelName)) { _connectedChannels.Remove(connection.RemoteInfo.ChannelName); } } }
public static int Main(string inParam) { if (inParam == null) { return(0); } var ptr = (IntPtr)Int64.Parse(inParam, System.Globalization.NumberStyles.HexNumber); var connection = HostConnectionData.LoadData(ptr); if (connection.State != HostConnectionData.ConnectionState.Valid) { return((int)connection.State); } // Adjust host PID in case of WOW64 bypass and service help... connection.UnmanagedInfo.m_HostPID = connection.RemoteInfo.HostPID; try { // Prepare parameter array. var paramArray = new object[1 + connection.RemoteInfo.UserParams.Length]; paramArray[0] = (RemoteHooking.IContext)connection.UnmanagedInfo; for (int i = 0; i < connection.RemoteInfo.UserParams.Length; i++) { paramArray[i + 1] = connection.RemoteInfo.UserParams[i]; } /// Load the user library and initialize the IEntryPoint. return(LoadUserLibrary(connection.RemoteInfo.UserLibrary, paramArray, connection.HelperInterface)); } catch (Exception ExtInfo) { Config.Log.Warning(ExtInfo.ToString()); return(-1); } finally { if (_connectedChannels.Contains(connection.RemoteInfo.ChannelName)) { _connectedChannels.Remove(connection.RemoteInfo.ChannelName); } } }