checking in all the old panacean stuff

This commit is contained in:
2016-07-25 15:42:39 -04:00
parent c996cdd81f
commit 8fd9e44ae5
1210 changed files with 220657 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,930 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2010. IntelliProtector.com
// Web site: http://intelliprotector.com
// Version: v2.5
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace netprotector.api
{
internal delegate void dVoid_NoParams();
internal delegate void dVoid_BoolParam(out bool b1);
internal delegate void dVoid_IntParam(out int i1);
internal delegate void dVoid_2IntParam(out int i1, int i2);
internal delegate void dVoid_5IntParams(out int i1, out int i2, out int i3, out int i4, out int i5);
internal delegate void dVoid_StringBuilderParam([MarshalAs(UnmanagedType.LPWStr)] StringBuilder s1, int iMaxLength);
internal delegate void dBool_StringParam(out bool res, [MarshalAs(UnmanagedType.LPWStr)]String s1, int iMaxLength);
internal delegate void dBool_StringOnlyParam(out bool res, [MarshalAs(UnmanagedType.LPWStr)]String s1);
internal delegate void dBool_StringStringParam(out bool res, [MarshalAs(UnmanagedType.LPWStr)]String s1, [MarshalAs(UnmanagedType.LPWStr)]String s2);
}
namespace IntelliProtectorService.attributes
{
internal class Encrypt : Attribute { }
internal class GetBuyNowLinkAttribute : Attribute { }
internal class IsSoftwareProtectedAttribute : Attribute { }
internal class IsSoftwareRegisteredAttribute : Attribute { }
internal class GetTrialDaysCountAttribute : Attribute { }
internal class GetTrialUnitsCountAttribute : Attribute { }
internal class GetTrialDaysLeftCountAttribute : Attribute { }
internal class GetTrialUnitsLeftCountAttribute : Attribute { }
internal class GetTrialLaunchesCountAttribute : Attribute { }
internal class GetTrialLaunchesLeftCountAttribute : Attribute { }
internal class ShowRegistrationWindowAttribute : Attribute { }
internal class IsTrialElapsedAttribute : Attribute { }
internal class GetRenewalPurchaseLinkAttribute : Attribute { }
internal class GetLicenseTypeAttribute : Attribute { }
internal class GetLicenseExpirationDaysCountAttribute : Attribute { }
internal class GetLicenseExpirationDaysLeftCountAttribute : Attribute { }
internal class GetSupportExpirationDaysCountAttribute : Attribute { }
internal class GetSupportExpirationDaysLeftCountAttribute : Attribute { }
internal class GetCurrentProductVersionAttribute : Attribute { }
internal class GetCustomerNameAttribute : Attribute { }
internal class GetCustomerEMailAttribute : Attribute { }
internal class GetLicenseCodeAttribute : Attribute { }
internal class RegisterSoftwareAttribute : Attribute { }
internal class RenewLicenseCodeAttribute : Attribute { }
internal class GetCurrentActivationDateAttribute : Attribute { }
internal class GetCurrentRegistrationDateAttribute : Attribute { }
internal class GetFirstRegistrationDateAttribute : Attribute { }
internal class GetOrderDateAttribute : Attribute { }
internal class GetLicenseExpirationDateAttribute : Attribute { }
internal class GetProtectionDateAttribute : Attribute { }
internal class GetSupportExpirationDateAttribute : Attribute { }
internal class GetSupportExpirationProductVersionAttribute : Attribute { }
internal class GetIntelliProtectorVersionAttribute : Attribute { }
internal class CreateRegistrationRequestCertificateAttribute : Attribute { }
internal class UseRegistrationResponseCertificateAttribute : Attribute { }
internal class SystemFunction1Attribute : Attribute { }
}
namespace IntelliProtectorService
{
internal class IntelliProtector
{
public static double Version_2_5()
{
return 2.5f;
}
#if DEBUG
public static bool IsInDebugMode()
{
return true;
}
#endif
public enum enUnitDimension
{
eudMinutes,
eudHours,
eudDays,
eudWeeks,
eudMonths
};
private class Init32
{
[DllImport("JitHookCore.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Init")]
public static extern void Init();
};
private class Init64
{
[DllImport("JitHookCoreX64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Init")]
public static extern void Init();
};
public static bool Init()
{
try
{
bool tryLoadX64 = false;
try
{
Init32.Init();
}
catch (BadImageFormatException)
{
tryLoadX64 = true;
}
if (tryLoadX64)
{
try
{
Init64.Init();
}
catch (BadImageFormatException)
{
return false;
}
}
return true;
}
catch (System.Exception)
{
return false;
}
}
#region GetBuyNowLink
[attributes.GetBuyNowLinkAttribute]
public static String GetBuyNowLink()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetBuyNowLinkTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetBuyNowLinkTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region IsSoftwareProtected
[attributes.IsSoftwareProtected]
public static bool IsSoftwareProtected()
{
UInt64 address = 0;
object[] obj = new object[] { false };
Type tp = typeof(netprotector.api.dVoid_BoolParam);
IsSoftwareProtectedTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void IsSoftwareProtectedTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(bool))
return;
obj[0] = false;
}
#endregion
#region IsSoftwareRegistered
[attributes.IsSoftwareRegistered]
public static bool IsSoftwareRegistered()
{
UInt64 address = 0;
object[] obj = new object[] { false };
Type tp = typeof(netprotector.api.dVoid_BoolParam);
IsSoftwareRegisteredTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void IsSoftwareRegisteredTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(bool))
return;
obj[0] = false;
}
#endregion
#region GetTrialDaysCount
[attributes.GetTrialDaysCount]
public static int GetTrialDaysCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetTrialDaysCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
protected static void GetTrialDaysCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetTrialUnitsCount
[attributes.GetTrialUnitsCount]
public static int GetTrialUnitsCount(int dimensions)
{
UInt64 address = 0;
object[] obj = new object[] { (int)0, dimensions };
Type tp = typeof(netprotector.api.dVoid_2IntParam);
GetTrialUnitsCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetTrialUnitsCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) && obj[1].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetTrialDaysLeftCount
[attributes.GetTrialDaysLeftCount]
public static int GetTrialDaysLeftCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetTrialDaysLeftCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetTrialDaysLeftCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetTrialUnitsLeftCount
[attributes.GetTrialUnitsLeftCount]
public static int GetTrialUnitsLeftCount(int dimension)
{
UInt64 address = 0;
object[] obj = new object[] { (int)0, dimension };
Type tp = typeof(netprotector.api.dVoid_2IntParam);
GetTrialUnitsLeftCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetTrialUnitsLeftCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) && obj[1].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetTrialLaunchesCount
[attributes.GetTrialLaunchesCount]
public static int GetTrialLaunchesCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetTrialLaunchesCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetTrialLaunchesCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetTrialLaunchesLeftCount
[attributes.GetTrialLaunchesLeftCount]
public static int GetTrialLaunchesLeftCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetTrialLaunchesLeftCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetTrialLaunchesLeftCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region ShowRegistrationWindow
[attributes.ShowRegistrationWindow]
public static void ShowRegistrationWindow()
{
UInt64 address = 0;
Type tp = typeof(netprotector.api.dVoid_NoParams);
ShowRegistrationWindowTest(address, null, tp);
}
[attributes.Encrypt]
public static void ShowRegistrationWindowTest(UInt64 address, object[] obj, Type delegateType)
{
}
#endregion
#region IsTrialElapsed
[attributes.IsTrialElapsed]
public static bool IsTrialElapsed()
{
UInt64 address = 0;
object[] obj = new object[] { false };
Type tp = typeof(netprotector.api.dVoid_BoolParam);
IsTrialElapsedTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void IsTrialElapsedTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(bool))
return;
obj[0] = false;
}
#endregion
#region GetRenewalPurchaseLink
[attributes.GetRenewalPurchaseLink]
public static String GetRenewalPurchaseLink()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetRenewalPurchaseLinkTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetRenewalPurchaseLinkTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region GetLicenseType
[attributes.GetLicenseType]
public static int GetLicenseType()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetLicenseTypeTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetLicenseTypeTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetLicenseExpirationDaysCount
[attributes.GetLicenseExpirationDaysCount]
public static int GetLicenseExpirationDaysCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetLicenseExpirationDaysCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetLicenseExpirationDaysCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetLicenseExpirationDaysLeftCount
[attributes.GetLicenseExpirationDaysLeftCount]
public static int GetLicenseExpirationDaysLeftCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetLicenseExpirationDaysLeftTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetLicenseExpirationDaysLeftTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetSupportExpirationDaysCount
[attributes.GetSupportExpirationDaysCount]
public static int GetSupportExpirationDaysCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetSupportExpirationDaysCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetSupportExpirationDaysCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetSupportExpirationDaysLeftCount
[attributes.GetSupportExpirationDaysLeftCount]
public static int GetSupportExpirationDaysLeftCount()
{
UInt64 address = 0;
object[] obj = new object[] { (int)0 };
Type tp = typeof(netprotector.api.dVoid_IntParam);
GetSupportExpirationDaysLeftCountTest(address, obj, tp);
return (int)obj[0];
}
[attributes.Encrypt]
public static void GetSupportExpirationDaysLeftCountTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int))
return;
obj[0] = -1;
}
#endregion
#region GetCurrentProductVersion
[attributes.GetCurrentProductVersion]
public static String GetCurrentProductVersion()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetCurrentProductVersionTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetCurrentProductVersionTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region GetCustomerName
[attributes.GetCustomerName]
public static String GetCustomerName()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetCustomerNameTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetCustomerNameTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region GetCustomerEMail
[attributes.GetCustomerEMail]
public static String GetCustomerEMail()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetCustomerEMailTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetCustomerEMailTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region GetLicenseCode
[attributes.GetLicenseCode]
public static String GetLicenseCode()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetLicenseCodeTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetLicenseCodeTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region RegisterSoftware
[attributes.RegisterSoftware]
public static bool RegisterSoftware(string licenseKey)
{
UInt64 address = 0;
bool res = false;
object[] obj = new object[] { res, licenseKey, licenseKey.Length };
Type tp = typeof(netprotector.api.dBool_StringParam);
RegisterSoftwareTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void RegisterSoftwareTest(UInt64 address, object[] obj, Type delegateType)
{
obj[0] = false;
}
#endregion
#region RenewLicenseCode
[attributes.RenewLicenseCode]
public static bool RenewLicenseCode(string renewalCode)
{
UInt64 address = 0;
object[] obj = new object[] { false, renewalCode, renewalCode.Length };
Type tp = typeof(netprotector.api.dBool_StringParam);
RenewLicenseCodeTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void RenewLicenseCodeTest(UInt64 address, object[] obj, Type delegateType)
{
obj[0] = false;
}
#endregion
#region GetCurrentActivationDate
[attributes.GetCurrentActivationDate]
public static DateTime GetCurrentActivationDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetCurrentActivationDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetCurrentActivationDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetCurrentRegistrationDate
[attributes.GetCurrentRegistrationDate]
public static DateTime GetCurrentRegistrationDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetCurrentRegistrationDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetCurrentRegistrationDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetFirstRegistrationDate
[attributes.GetFirstRegistrationDate]
public static DateTime GetFirstRegistrationDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetFirstRegistrationDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetFirstRegistrationDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetOrderDate
[attributes.GetOrderDate]
public static DateTime GetOrderDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetOrderDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetOrderDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetLicenseExpirationDate
[attributes.GetLicenseExpirationDate]
public static DateTime GetLicenseExpirationDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetLicenseExpirationDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetLicenseExpirationDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetProtectionDate
[attributes.GetProtectionDate]
public static DateTime GetProtectionDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetProtectionDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetProtectionDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetSupportExpirationDate
[attributes.GetSupportExpirationDate]
public static DateTime GetSupportExpirationDate()
{
UInt64 address = 0;
object[] obj = new object[] { 0, 0, 0, 0, 0 };
Type tp = typeof(netprotector.api.dVoid_5IntParams);
GetSupportExpirationDateTest(address, obj, tp);
if ((int)obj[0] < 0)
return DateTime.MinValue;
return new DateTime((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3], (int)obj[4], 0);
}
[attributes.Encrypt]
protected static void GetSupportExpirationDateTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(int) ||
obj[1].GetType() != typeof(int) ||
obj[2].GetType() != typeof(int) ||
obj[3].GetType() != typeof(int) ||
obj[4].GetType() != typeof(int))
{
return;
}
obj[0] = -1;
obj[1] = -1;
obj[2] = -1;
obj[3] = -1;
obj[4] = -1;
}
#endregion
#region GetSupportExpirationProductVersion
[attributes.GetSupportExpirationProductVersion]
public static String GetSupportExpirationProductVersion()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetSupportExpirationProductVersionTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetSupportExpirationProductVersionTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region GetIntelliProtectorVersion
[attributes.GetIntelliProtectorVersion]
public static String GetIntelliProtectorVersion()
{
UInt64 address = 0;
int ciMinLength = 0;
int ciMaxLength = 1024;
StringBuilder rValue = new StringBuilder(ciMaxLength);
object[] obj = new object[] { rValue, ciMaxLength - ciMinLength };
Type tp = typeof(netprotector.api.dVoid_StringBuilderParam);
GetIntelliProtectorVersionTest(address, obj, tp);
return rValue.ToString();
}
[attributes.Encrypt]
protected static void GetIntelliProtectorVersionTest(UInt64 address, object[] obj, Type delegateType)
{
if (obj[0].GetType() != typeof(StringBuilder))
return;
string strLink = "";
if ((int)obj[1] >= strLink.Length)
((StringBuilder)obj[0]).Append(strLink);
}
#endregion
#region CreateRegistrationRequestCertificate
[attributes.CreateRegistrationRequestCertificate]
public static bool CreateRegistrationRequestCertificate(string path, string licenseCode)
{
UInt64 address = 0;
bool res = false;
object[] obj = new object[] { res, path, licenseCode };
Type tp = typeof(netprotector.api.dBool_StringStringParam);
CreateRegistrationRequestCertificateTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void CreateRegistrationRequestCertificateTest(UInt64 address, object[] obj, Type delegateType)
{
obj[0] = true;
}
#endregion
#region UseRegistrationResponseCertificate
[attributes.UseRegistrationResponseCertificate]
public static bool UseRegistrationResponseCertificate(string path)
{
UInt64 address = 0;
bool res = false;
object[] obj = new object[] { res, path };
Type tp = typeof(netprotector.api.dBool_StringOnlyParam);
UseRegistrationResponseCertificateTest(address, obj, tp);
return (bool)obj[0];
}
[attributes.Encrypt]
protected static void UseRegistrationResponseCertificateTest(UInt64 address, object[] obj, Type delegateType)
{
obj[0] = true;
}
#endregion
#region SystemFunction1
[attributes.SystemFunction1]
protected static void SystemFunction1(UInt64 address, object[] parameters, Type delegateType)
{
Delegate delegateFunc = Marshal.GetDelegateForFunctionPointer((IntPtr)address, delegateType);
delegateFunc.DynamicInvoke(parameters);
}
#endregion
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SMFTP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Panacean Technologies, LLC")]
[assembly: AssemblyProduct("SMFTP")]
[assembly: AssemblyCopyright("Copyright © Panacean Technologies 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2ec998f7-55c3-4904-a9d1-e4d9d125af39")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,397 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Reflection;
using System.IO;
using IntelliProtectorService;
namespace SMFTP
{
/// <remarks>
/// Wrapper Managed Class around putty sftp.
/// <example>
/// <code>
/// SFTPClient client = new SFTPClient();
/// if(client.Connect("sftp.somedomain.com","user","password","22"))
/// bool bFetchedFile = client.CmdExec_Any("get somefile.txt");
/// </code>
/// </example>
/// </remarks>
public class SFTPClient : IDisposable
{
#region Private Statics
/// <summary>
/// Used in the all to LoadLibrary * Names here
/// * if you change it here * also change DllImports (below)
/// </summary>
private const string PSFTP_FILENAME = "psftp.dll";
/// <summary>
/// We only want to load the Psftp dll once per process
/// </summary>
private static bool s_PSFTPDLL_IsLoaded = false;
/// <summary>
/// Responsible for creating an active connection
/// </summary>
[DllImport("psftp.dll")]
private static extern int dllmain(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] String[] argv);
/// <summary>
/// Responsible for running a command on an active connection
/// </summary>
[DllImport("psftp.dll")]
private static extern int do_sftp2([MarshalAs(UnmanagedType.LPStr)] string cmdLine);
/// <summary>
/// Responsible for Putty Cleanup
/// </summary>
[DllImport("psftp.dll")]
private static extern void dllmain_cleanup();
/// <summary>
/// Loads the Putty Dll
/// </summary>
[DllImport("kernel32.dll")]
private static extern IntPtr LoadLibrary(String dllname);
#endregion
#region Construction / Destruction
/// <summary>
/// Create a SFTClient Object
/// </summary>
public SFTPClient()
{
bool bForceFileWrite = true;
#if !DEBUG
// Initialize IntelliProtect
if (!IntelliProtector.Init())
throw new Exception("Cannot load protector SFTPClient");
bForceFileWrite = false;
#endif
// Extract the Native Dll to the Temp Directory,
// if it is not already there...
if (bForceFileWrite || !File.Exists(_pstfpTempFileNameNPath))
{
using (BinaryReader br = new BinaryReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(("SMFTP.Components." + PSFTP_FILENAME))))
using (BinaryWriter bw = new BinaryWriter(new FileStream(_pstfpTempFileNameNPath, FileMode.Create)))
{
byte[] buffer = new byte[64 * 1024];
int numread = br.Read(buffer, 0, buffer.Length);
while (numread > 0)
{
bw.Write(buffer, 0, numread);
numread = br.Read(buffer, 0, buffer.Length);
}
bw.Flush();
}
}
// Load the dll, if it isn't already
if (!s_PSFTPDLL_IsLoaded)
{
IntPtr hDll = LoadLibrary(_pstfpTempFileNameNPath);
s_PSFTPDLL_IsLoaded = (hDll != IntPtr.Zero);
}
if (!s_PSFTPDLL_IsLoaded)
throw new Exception(("Failed to load " + _pstfpTempFileNameNPath + ". Something terrible is wrong"));
}
/// <summary>
/// Finalizer
/// </summary>
~SFTPClient()
{
Dispose(false);
}
#endregion
#region Private Members
private bool _IsConnected = false;
private bool _disposed = false;
private readonly string _pstfpTempFileNameNPath = Path.GetTempPath() + PSFTP_FILENAME;
#endregion
#region Main Putty Functions
/// <summary>
/// Start a Connection to the specified Host with the specified credentials
/// </summary>
/// <param name="hostname">url to sftp host</param>
/// <param name="username">user credential</param>
/// <param name="password">password credential</param>
/// <param name="port">port to connect to (default 22)</param>
/// <returns>true if connection occured successfully, false otherwise</returns>
public bool Connect(string hostname, string username, string password, string port = "22")
{
if (String.IsNullOrEmpty(hostname) || String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(port))
throw new ArgumentException("Empty String not valid for any of the arguments");
Disconnect();
int nResult = dllmain(10, new String[] { Assembly.GetExecutingAssembly().Location, "-l", username, "-pw", password, "-P", port, "-batch", "-y", hostname });
if (nResult != 0) // Error occured connecting to host with specified prms
return false;
_IsConnected = true;
return true;
}
/// <summary>
/// End the active Connection
/// </summary>
public bool Disconnect()
{
if (_IsConnected)
{
dllmain_cleanup();
_IsConnected = false;
}
return !_IsConnected;
}
/// <summary>
/// Performs the specified Command on the Active Connection
/// </summary>
/// <param name="Command">a Command including optional parameters like "dir *.*" that can be understood by psftp</param>
/// <returns>true, if command run successfully, falser otherwise</returns>
public bool CmdExec_Any(string Command)
{
// Perform the Action
if (_IsConnected)
{
bool bPerformedAction = (do_sftp2(Command) == 1);
return bPerformedAction;
}
return false;
}
#endregion
#region Command Helpers (Assumes Active Connection)
/// <summary>
/// Set the Working Directory Locally
/// </summary>
/// <param name="path">path to a local directory</param>
/// <param name="bCreateIfNotExists">true to create the local directory, if it doesn't exist, false otherwise</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExec_LocalDirSet(string path, bool bCreateIfNotExists = false)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if(String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
bool bSuccess = CmdExec_Any("lcd " + path);
if (!bSuccess && bCreateIfNotExists)
{
Directory.CreateDirectory(path);
if(Directory.Exists(path))
bSuccess = CmdExec_Any("lcd " + path);
}
return bSuccess;
}
/// <summary>
/// Set the Working Directory on the Remote sftp connection
/// </summary>
/// <param name="path">path to a remote directory</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExec_RemoteDirSet(string path)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
// Always make paths absolute * safer *
if (path[0] != '/' && path[0] != '\\')
path = '/' + path;
bool bSuccess = CmdExec_Any("cd " + path);
return bSuccess;
}
/// <summary>
/// Checks for existence of the Directory on the Server
/// </summary>
/// <param name="path">path to a remote directory</param>
/// <returns>true, if remote directory exists, false otherwise</returns>
public bool CmdExec_RemoteDirExists(string path)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
// Always make paths absolute * safer *
if (path[0] != '/' && path[0] != '\\')
path = '/' + path;
bool bSuccess = CmdExec_Any("cd /"); // make sure we are at the root dir
if (bSuccess)
bSuccess = CmdExec_Any("cd " + path);
if (bSuccess)
bSuccess = CmdExec_Any("cd /"); // back to root dir
return bSuccess;
}
/// <summary>
/// Download a Directory at once including all it's files. if bRecursive is set,
/// Download all child directories and files
/// </summary>
/// <param name="bRecursive">If bRecursive is true, recursively fetch files and directories</param>
/// <param name="path">path to a remote directory</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MGetDir(bool bRecursive, string path)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
// Always make paths absolute * safer *
if (path[0] != '/' && path[0] != '\\')
path = '/' + path;
string mgetCmd = bRecursive ? "mget -r " : "mget ";
bool bSuccess = CmdExec_Any(mgetCmd + path);
return bSuccess;
}
/// <summary>
/// Download multiple files at once
/// <example>
/// "*.c" "filename1.txt" "*.sln"
/// </example>
/// </summary>
/// <param name="filenames_or_wildcards">space seperated list of multiple filenames or wildcards</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MGetFiles(string filenames_or_wildcards)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(filenames_or_wildcards))
throw new ArgumentException("filenames_or_wildcards can not be empty");
bool bSuccess = CmdExec_Any("mget " + filenames_or_wildcards);
return bSuccess;
}
/// <summary>
/// Upload a Directory at once including all it's files. if bRecursive is set,
/// Upload all child directories and files
/// </summary>
/// <param name="bRecursive">If bRecursive is true, recursively put files and directories</param>
/// <param name="path">path to a local directory</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MPutDir(bool bRecursive, string path)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
string mgetCmd = bRecursive ? "mput -r " : "mget ";
bool bSuccess = CmdExec_Any(mgetCmd + path);
return bSuccess;
}
/// <summary>
/// Upload multiple files at once
/// <example>
/// "*.c" "filename1.txt" "*.sln"
/// </example>
/// </summary>
/// <param name="filenames_or_wildcards">space seperated list of multiple filenames or wildcards</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MPutFiles(string filenames_or_wildcards)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(filenames_or_wildcards))
throw new ArgumentException("filenames_or_wildcards can not be empty");
bool bSuccess = CmdExec_Any("mput " + filenames_or_wildcards);
return bSuccess;
}
/// <summary>
/// Delete multiple files at once from the server
/// <example>
/// "*.c" "filename1.txt" "*.sln"
/// </example>
/// </summary>
/// <param name="filenames_or_wildcards">space seperated list of multiple filenames or wildcards</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MDelFiles(string filenames_or_wildcards)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(filenames_or_wildcards))
throw new ArgumentException("filenames_or_wildcards can not be empty");
bool bSuccess = CmdExec_Any("del " + filenames_or_wildcards);
return bSuccess;
}
/// <summary>
/// Removes a Directory from the server. Directory must be empty in order
/// to be removed.
/// </summary>
/// <param name="path">path to a remote directory</param>
/// <returns>true, if successful, false otherwise</returns>
public bool CmdExe_MDelDir(string path)
{
if (!_IsConnected)
throw new Exception("Not Connected");
if (String.IsNullOrEmpty(path))
throw new ArgumentException("path can not be empty");
// Always make paths absolute * safer *
if (path[0] != '/' && path[0] != '\\')
path = '/' + path;
bool bSuccess = CmdExec_Any("" + path);
return bSuccess;
}
#endregion
#region IDisposable Members
public void Dispose()
{
Dispose(true);
// Use SupressFinalize in case a subclass
// of this type implements a finalizer
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free Managed Resources
}
// Free Unmanaged Resources
Disconnect();
_disposed = true;
}
}
#endregion
}
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6C463FB5-D25B-4CD4-A493-7B91615E8467}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SMFTP</RootNamespace>
<AssemblyName>SMFTP</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Target\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IntelliProtector.cs" />
<Compile Include="SFTPClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Components\psftp.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>copy "$(SolutionDir)psftp\WINDOWS\MSVC\PSFTP\$(ConfigurationName)\psftp.dll" "$(ProjectDir)Components" /y
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@@ -0,0 +1,5 @@
C:\_ROOT_\PanaceanTech\sFTPlugins\Target\Release\SMFTP.dll
C:\_ROOT_\PanaceanTech\sFTPlugins\Target\Release\SMFTP.pdb
C:\_ROOT_\PanaceanTech\sFTPlugins\SMFTP\obj\Release\ResolveAssemblyReference.cache
C:\_ROOT_\PanaceanTech\sFTPlugins\SMFTP\obj\Release\SMFTP.dll
C:\_ROOT_\PanaceanTech\sFTPlugins\SMFTP\obj\Release\SMFTP.pdb

Binary file not shown.

Binary file not shown.