My online notes – Section 0008

Note 1: Remove diacritics (special characters) from string

private static string RemoveDiacritics(string text)
{
	string textNormalized = text.Normalize(NormalizationForm.FormD);
	StringBuilder stringBuilder = new StringBuilder();

	for (int index = 0; index < textNormalized.Length; index++)
	{
		UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(textNormalized[index]);
		if (uc != UnicodeCategory.NonSpacingMark)
		{
			stringBuilder.Append(textNormalized[index]);
		}
	}

	return (stringBuilder.ToString().Normalize(NormalizationForm.FormC));
}

Continue reading My online notes – Section 0008

C# – Useful code listings

1. List all properties and their values

static void Main(string[] args)
{
	string fileName = Path.Combine(Directory.GetCurrentDirectory(), "All Polished.mp4");
	ShellObject shellObject= ShellObject.FromParsingName(fileName);
	PropertyInfo[] propertyInfos = shellObject.Properties.System.GetType().GetProperties();
	foreach (var propertyInfo in propertyInfos)
	{
		object value = propertyInfo.GetValue(shellObject.Properties.System, null);

		if (value is ShellProperty<int?>)
		{
			var nullableIntValue = (value as ShellProperty<int?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableIntValue}");
		}
		else if (value is ShellProperty<ulong?>)
		{
			var nullableLongValue =
				(value as ShellProperty<ulong?>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {nullableLongValue}");
		}
		else if (value is ShellProperty<string>)
		{
			var stringValue =
				(value as ShellProperty<string>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {stringValue}");
		}
		else if (value is ShellProperty<object>)
		{
			var objectValue =
				(value as ShellProperty<object>).Value;
			Console.WriteLine($"{propertyInfo.Name} - {objectValue}");
		}
		else
		{
			Console.WriteLine($"{propertyInfo.Name} - Dummy value");
		}
	}
	Console.ReadLine();
}

FluentValidation

https://github.com/JeremySkinner/FluentValidation

NodaTime

http://nodatime.org/

Quartz.net

http://www.quartz-scheduler.net/

DeXe – Deobfuscator for Xenocode

INTRODUCTION
Strings in assembly protected by XenoCode was encrypted. This tool will help you to decrypt string into readable form. Flow control is defeated too, but this tool can not recover to 100% original code. After version 1.0.1.3, the code name of this tool will be changed to DeXe because it is a part of a series of Deobfuscator which I make for .net. After decryption, a patched assembly with decrypted string will be saved at the same folder of the application. Use Reflector to see result. This tool will be updated soonly with more functions.

  • Requirements : .NET Framework 2.0
  • Version: 1.0.1.6
  • Supported version of Xenocode Postbuild
  • To XenoCode Postbuild 2007 build 6675
  • Want more functions. Post your comment directly after this post.

NOTE

If this tool doesn’t work with your packed assembly, send it to me. DO NOT blame me if this one doesn’t work. I’m just a newbie. Tongue out

LINK DOWN

When you want to post this tool to somewhere. Please post url to my site, that keeps update for this tool when you do that.

Download: http://hintdesk.com/Web/Tool/XeCoString.zip

HISTORY

  • [1.0.1.4 – 1.0.1.6] : Fix mirror bugs
  • [1.0.1.3] : Anti-obfuscate flow control is now better
  • [1.0.0.10] : Anti-obfuscate flow control
  • [1.0.0.9] : Fix Bug bei convert string to in at ID

SCREENSHOT
DeXe Screenshot

Hướng dẫn thương nhân bang Thanh Vân Thành Thảo Nguyên TLBB

Thương nhân trong game Thiên Long Bát Bộ muốn max phiếu (tức là đạt mức lợi tối đa) thì 2 thành thông thương với nhau phải cách nhau ít nhất 6 map. Bang Thanh Vân, server Phi Long Tại Thiên, nằm ở Thảo Nguyên thông thương với thành Quân Tử nằm ở Nhĩ Hải cách nhau 7 map nên khi chạy sẽ bị lệch giờ và dẫn tới tình trạng chờ giá lên. Do đó để không bị tình trạng chờ này thì tốt nhất là trả ở Lạc Dương và cách chạy là như sau.

1. Vào BANG, đến chữ KIM để nhận phiếu.

Continue reading Hướng dẫn thương nhân bang Thanh Vân Thành Thảo Nguyên TLBB

My online notes – Section 0006

Note 1: Sony Ericsson PC Suite for Z610i
http://www.megaupload.com/?d=V7II5C41

Note 2: Set autostart for program

private Boolean SchreibeinAutostart( String dateipfad )
{
    try
    {
        String samAccountName;
        {
            var currentWindowsIdentity = WindowsIdentity.GetCurrent( );
            if ( currentWindowsIdentity == null )
            {
                return false;
            }

            samAccountName = currentWindowsIdentity.Name;
        }

        var registrySecurity = new RegistrySecurity( );
        {
            registrySecurity.AddAccessRule( new RegistryAccessRule( samAccountName,
                    RegistryRights.WriteKey | RegistryRights.ChangePermissions, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow ) );
        }

        var targetRegistryKey = Registry.CurrentUser.CreateSubKey( "Software\\Microsoft\\Windows\\CurrentVersion\\Run\\" );

        if ( targetRegistryKey == null )
        {
            return false;
        }

        targetRegistryKey.SetValue( dateipfad.Remove( 0, dateipfad.LastIndexOf( @"\" ) + 1 ), dateipfad );

    }
    catch ( Exception )
    {
        return false;
    }

    return true;
}

Continue reading My online notes – Section 0006

My online notes – Section 0005

Note 1: Impersonation for accessing network path

private void ApplyUserCredentials(string Share, string Domain, string Username, string Password)
{
	USE_INFO_2 useInfo = new USE_INFO_2();
	useInfo.ui2_local = string.Empty;
	useInfo.ui2_remote = Share;
	useInfo.ui2_password = Password;
	useInfo.ui2_asg_type = 0;    //disk drive
	useInfo.ui2_usecount = 1;
	useInfo.ui2_username = Username;
	useInfo.ui2_domainname = Domain;
	uint paramErrorIndex;

	uint returnCode = NetUseAdd(null, 2, ref useInfo, out paramErrorIndex);
	if (returnCode != 0)
	{
		throw new Win32Exception((int)returnCode);
	}
}

[DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern UInt32 NetUseAdd(string UncServerName,UInt32 Level, ref USE_INFO_2 Buf,  out UInt32 ParmError);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct USE_INFO_2
{
	internal string ui2_local;
	internal string ui2_remote;
	internal string ui2_password;
	internal UInt32 ui2_status;
	internal UInt32 ui2_asg_type;
	internal UInt32 ui2_refcount;
	internal UInt32 ui2_usecount;
	internal string ui2_username;
	internal string ui2_domainname;
}

Continue reading My online notes – Section 0005

My online notes – Section 0004

Note 1: Proxy of HttpWebRequest for uploading

HttpWebRequest HttpRequest = (HttpWebRequest)WebRequest.Create(this.fullUrl);
<system.net>
    <defaultProxy enabled ="false">
		<proxy autoDetect ="True"/>
    </defaultProxy>
</system.net>

Note 2: Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control for page loading
http://msdn.microsoft.com/en-us/library/15a31akc.aspx

Continue reading My online notes – Section 0004