<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rongchaua's blog</title>
	
	<link>http://rongchaua.net/blog</link>
	<description>Blog of rongchaua</description>
	<lastBuildDate>Wed, 17 Jun 2009 07:39:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<itunes:explicit>no</itunes:explicit><itunes:subtitle>Blog of rongchaua</itunes:subtitle><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/RongchauaBlog" type="application/rss+xml" /><feedburner:emailServiceId>RongchauaBlog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Sister Act – I will follow him</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/NIpw069csJE/</link>
		<comments>http://rongchaua.net/blog/sister-act-i-will-follow-him/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 07:00:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Entertainment]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=343</guid>
		<description><![CDATA[Today I read a post on facebook of my friend. She shares a small clip of film sister act. I like this song and would like to share it with you. You can download mp3 ...]]></description>
			<content:encoded><![CDATA[<p>Today I read a post on facebook of my friend. She shares a small clip of film sister act. I like this song and would like to share it with you. You can download mp3 version &#8220;<a title="I will follow him" href="http://uploading.com/files/D5M4231R/I Will Follow Him.mp3.html">I will follow him</a>&#8221; or take a look at video below.</p>
<p>Lyrics:</p>
<p>-I will follow Him<br />
Follow Him wherever He may go,<br />
And near Him, I always will be<br />
For nothing can keep me away,<br />
He is my destiny.</p>
<p>I will follow Him,<br />
Ever since He touched my heart I knew,<br />
There isn&#8217;t an ocean too deep,<br />
A mountain so high it can keep,<br />
Keep me away, away from His love.</p>
<p>I love Him, I love Him, I love Him,<br />
And where He goes,<br />
I&#8217;ll follow, I&#8217;ll follow, I&#8217;ll follow.<br />
he&#8217;ll always be my true love, my true love, my true love<br />
from now until forever, forever, forever</p>
<p>I will follow Him,<br />
Follow Him wherever He may go,<br />
There isn&#8217;t an ocean too deep,<br />
A mountain so high it can keep,<br />
Keep me away, away from His love&#8230;</p>
<p>We will follow Him,<br />
Follow Him wherever He may go,<br />
There isn&#8217;t an ocean too deep,<br />
A mountain so high it can keep,<br />
Keep us away, away from His love&#8230;</p>
<p>I love Him<br />
(Oh yes I love Him)<br />
I&#8217;ll follow<br />
(I&#8217;m gonna follow)<br />
True love<br />
(He&#8217;ll always be my true, true love)<br />
Forever<br />
(Now until forever)<br />
I love Him, I love Him, I love Him,<br />
And where He goes,<br />
I&#8217;ll follow, I&#8217;ll follow, I&#8217;ll follow,<br />
He&#8217;ll always be my true love,<br />
My true love, my true love,<br />
From now until forever,<br />
Forever, forever&#8230;</p>
<p>There isn&#8217;t an ocean too deep,<br />
A mountain so high it can keep,<br />
Keep me away, away from His love</p>
<p><object width="425" height="344" data="http://www.youtube.com/v/nqp89bkFe8k&amp;hl=de&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/nqp89bkFe8k&amp;hl=de&amp;fs=1" /><param name="allowfullscreen" value="true" /></object></p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=343&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/uNMuO-w6yWnCzujVt7_aa5ZKkmM/0/da"><img src="http://feedads.g.doubleclick.net/~a/uNMuO-w6yWnCzujVt7_aa5ZKkmM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/uNMuO-w6yWnCzujVt7_aa5ZKkmM/1/da"><img src="http://feedads.g.doubleclick.net/~a/uNMuO-w6yWnCzujVt7_aa5ZKkmM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=NIpw069csJE:lUwFJ8RiXZ0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/sister-act-i-will-follow-him/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<media:content url="http://feedproxy.google.com/~r/RongchauaBlog/~5/S7k04iENJeg/nqp89bkFe8k&amp;amp;hl=de&amp;amp;fs=1" fileSize="1034" type="application/x-shockwave-flash" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Today I read a post on facebook of my friend. She shares a small clip of film sister act. I like this song and would like to share it with you. You can download mp3 ...</itunes:subtitle><itunes:summary>Today I read a post on facebook of my friend. She shares a small clip of film sister act. I like this song and would like to share it with you. You can download mp3 ...</itunes:summary><itunes:keywords>Entertainment</itunes:keywords><feedburner:origLink>http://rongchaua.net/blog/sister-act-i-will-follow-him/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/RongchauaBlog/~5/S7k04iENJeg/nqp89bkFe8k&amp;amp;hl=de&amp;amp;fs=1" length="1034" type="application/x-shockwave-flash" /><feedburner:origEnclosureLink>http://www.youtube.com/v/nqp89bkFe8k&amp;amp;hl=de&amp;amp;fs=1</feedburner:origEnclosureLink></item>
		<item>
		<title>C# – How to read MP3 header?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/nWaGiE0xBvU/</link>
		<comments>http://rongchaua.net/blog/c-how-to-read-mp3-header/#comments</comments>
		<pubDate>Sat, 30 May 2009 07:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=335</guid>
		<description><![CDATA[Today i am trying to write a small application to merge some mp3 files into one. Owing to the fact that I am listening to some audio books. You know a book is always categorized ...]]></description>
			<content:encoded><![CDATA[<p>Today i am trying to write a small application to merge some mp3 files into one. Owing to the fact that I am listening to some audio books. You know a book is always categorized into many chapters and is very long. Therefore the audio version is splitted into many parts too. I don&#8217;t like that because i can easily lose one of them and when I hear them I must sort them into exact order. Because of the above points I would like to write a small tool to merge all files into one.</p>
<p>As I start my project I know it must be pretty complex because Mp3 format was invented long time ago and it has different versions since its first publishcation. So I made a search to <a title="MP3 file format specification" href="http://www.mpgedit.org/mpgedit/mpeg_format/MP3Format.html">MP3 file format specification</a> and I found that it is badly documented and the website is not professionally designed. I thought I went into wrong link but after more searching I think that is may be the best one (???).  I started to read the documentation and found this interesting paragraph</p>
<blockquote><p>An MPEG audio file is built up from smaller parts called frames.       Generally, frames are independent items. Each frame has its own       header and audio informations. As there is no file header, you       can cut any part of MPEG file and play it correctly</p></blockquote>
<p>Ah ha, I thought I can simply join two mp3 files and they will work like a charm.</p>
<pre class="brush: csharp;">

FileStream fs0001 = File.Open(&quot;D:\\Downloads\\0001.mp3&quot;, FileMode.Append);
FileStream fs0002 = File.Open(&quot;D:\\Downloads\\0002.mp3&quot;, FileMode.Open);
byte[] baOut = new byte[fs0002.Length];
fs0002.Read(baOut, 0, (int)baOut.Length);
fs0001.Write(baOut, 0, (int)baOut.Length);
fs0001.Close();
fs0002.Close();
</pre>
<p>After running the code above, the output file can be played with WMP11. I thought I was successfull. But you know, life is not easy as we hope. Although WMP11 can play the whole output file but the information of file was wrong. For example I merged a 3-minutes length mp3 files with a 2-minutes length one but the duration of output was only 3-minutes.  That means it takes the duration of first file for the new one and it is of course wrong. So I manage to rewrite the duration of output file .I make another search for a library working with <a title="ID3" href="http://www.id3.org/">ID3</a> Tag. Writing an own one must be a big work. There are a lot of kinds of this library, I chose to use <a title="TagLib Sharp" href="http://developer.novell.com/wiki/index.php/TagLib_Sharp">TagLib Sharp</a> because I think this library will be continuously developed in future. Below is a small code snippet for reading ID3 Tag from a mp3 file.</p>
<pre class="brush: csharp;">

TagLib.File fiMp3 = TagLib.File.Create(&quot;D:\\Downloads\\0001.mp3&quot;);
Console.WriteLine(fiMp3.Tag.Performers[0].ToString());
Console.WriteLine(fiMp3.Properties.Duration);
</pre>
<p>However until now I can still NOT to edit the duration of the output file. I am reading the mp3 documentation forward and hope that I can find a way.</p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=335&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/TJSskl68NsKM7MJS1lzgSgi9WqY/0/da"><img src="http://feedads.g.doubleclick.net/~a/TJSskl68NsKM7MJS1lzgSgi9WqY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/TJSskl68NsKM7MJS1lzgSgi9WqY/1/da"><img src="http://feedads.g.doubleclick.net/~a/TJSskl68NsKM7MJS1lzgSgi9WqY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=nWaGiE0xBvU:DA58DEeP9H8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/c-how-to-read-mp3-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/c-how-to-read-mp3-header/</feedburner:origLink></item>
		<item>
		<title>C# – How to enable SeDebugPrivilege?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/n-iOeQrJSeM/</link>
		<comments>http://rongchaua.net/blog/c-how-to-enable-sedebugprivilege/#comments</comments>
		<pubDate>Mon, 25 May 2009 07:00:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=328</guid>
		<description><![CDATA[I&#8217;m writing a small application to recognize which processes are using a define file. The reason to start this project is sometimes I can not delete some folder because it was accessed by any program. ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing a small application to recognize which processes are using a define file. The reason to start this project is sometimes I can not delete some folder because it was accessed by any program. I can not figure out which program are accessing that folder. It makes me really annoyed so it is good if I can find out which application are trying to access my folder and terminate it or close its access.To achieve this idea I must enable SeDebugPrivilege for my tool.</p>
<blockquote><p>By setting the SeDebugPrivilege privilege on the running process, you can obtain the process handle of any running application. When obtaining the handle to a process, you can then specify the PROCESS_ALL_ACCESS flag, which will allow the calling of various Win32 APIs upon that process handle, which you normally could not do.</p></blockquote>
<p>It is pretty easy to enable SeDebugPrivilege with help of Pinvoke.net. However I would like to share it for anyone who needs it.</p>
<pre class="brush: csharp;">

IntPtr hToken;
LUID luidSEDebugNameValue;
TOKEN_PRIVILEGES tkpPrivileges;

if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out hToken))
{
Console.WriteLine(&quot;OpenProcessToken() failed, error = {0} . SeDebugPrivilege is not available&quot;, Marshal.GetLastWin32Error());
return;
}
else
{
Console.WriteLine(&quot;OpenProcessToken() successfully&quot;);
}

if (!LookupPrivilegeValue(null, SE_DEBUG_NAME, out luidSEDebugNameValue))
{
Console.WriteLine(&quot;LookupPrivilegeValue() failed, error = {0} .SeDebugPrivilege is not available&quot;, Marshal.GetLastWin32Error());
CloseHandle(hToken);
return;
}
else
{
Console.WriteLine(&quot;LookupPrivilegeValue() successfully&quot;);
}

tkpPrivileges.PrivilegeCount = 1;
tkpPrivileges.Luid = luidSEDebugNameValue;
tkpPrivileges.Attributes = SE_PRIVILEGE_ENABLED;

if (!AdjustTokenPrivileges(hToken,false,ref tkpPrivileges, 0,IntPtr.Zero,IntPtr.Zero))
{
Console.WriteLine(&quot;LookupPrivilegeValue() failed, error = {0} .SeDebugPrivilege is not available&quot;, Marshal.GetLastWin32Error());
}
else
{
Console.WriteLine(&quot;SeDebugPrivilege is now available&quot;);
}
CloseHandle(hToken);
Console.ReadLine();
</pre>
<p>As you can see, there are 3 steps to enable SeDebugPrivilege. First we need to get the token of current process, then we use this token handle to query its debug name and at last we adjust it with the new one. For a complete working source code you cand find at this c# file <a title="How to enable SeDebugPrivilege" href="http://rongchaua.net/Web/Source/Program.cs">How to enable SeDebugPrivilege source code</a>.</p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=328&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/c50pf7M396YT8jMLRaGNDUc673A/0/da"><img src="http://feedads.g.doubleclick.net/~a/c50pf7M396YT8jMLRaGNDUc673A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/c50pf7M396YT8jMLRaGNDUc673A/1/da"><img src="http://feedads.g.doubleclick.net/~a/c50pf7M396YT8jMLRaGNDUc673A/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=n-iOeQrJSeM:qrvUSGM9WRI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/c-how-to-enable-sedebugprivilege/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/c-how-to-enable-sedebugprivilege/</feedburner:origLink></item>
		<item>
		<title>Windows Vista – Folder Winsxs?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/xq5BKRE7qY4/</link>
		<comments>http://rongchaua.net/blog/windows-vista-folder-winsxs/#comments</comments>
		<pubDate>Wed, 20 May 2009 07:00:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=324</guid>
		<description><![CDATA[When I started to use Vista I did know why my hard disk is always more than 50% full after some months. So I used TuneUp Disk Space Explorer to find out which folder occupies ...]]></description>
			<content:encoded><![CDATA[<p>When I started to use Vista I did know why my hard disk is always more than 50% full after some months. So I used TuneUp Disk Space Explorer to find out which folder occupies so much disk space and at last I found a strange folder which is very big. Its size is about 7 GB and gets bigger and bigger day by day. It is winsxs folder.</p>
<p><img src="http://img2.pict.com/2a/8e/c2/eab258cfa941e49d5ad3fdfdb1/5WZNl/1.png" alt="WinSxS" /></p>
<p>For more details about winsxs folder you can find at <a title="The secret of vista folder" href="http://www.winvistaclub.com/f16.html" target="_blank">The Secret of Vista Winsxs folder</a> . As I saw this result I thought it is a real folder. But today I found another article which states that.</p>
<blockquote><p>“Modularizing” the operating system was an engineering goal in Windows Vista. This was to solve a number of issues in legacy Windows related to installation, servicing and reliability. The Windows SxS directory represents the “installation and servicing state” of all system components. But in reality <strong>it doesn’t actually consume as much disk space as it appears</strong> when using the built-in tools (DIR and Explorer) to measure disk space used. The fact that we make it tricky for you to know how much space is actually consumed in a directory is definitely a fair point!</p>
<p>In practice, nearly every file in the WinSxS directory is a “hard link” to the physical files elsewhere on the system—meaning that the files are not actually in this directory. For instance in the WinSxS there might be a file called advapi32.dll that takes up &gt;700K however what’s being reported is a hard link to the actual file that lives in the Windows\System32, and it will be counted twice (or more) when simply looking at the individual directories from Windows Explorer.</p></blockquote>
<p>So the winsxs just contains links to real file. Anyway if you install more softwares on your computer, this folder will get bigger too because more files will be saved at your machine to let multiple applications run in Windows without any compatibility problem.</p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=324&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/IlN2gcXZhpyIO8AAVVLslqsfD4I/0/da"><img src="http://feedads.g.doubleclick.net/~a/IlN2gcXZhpyIO8AAVVLslqsfD4I/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/IlN2gcXZhpyIO8AAVVLslqsfD4I/1/da"><img src="http://feedads.g.doubleclick.net/~a/IlN2gcXZhpyIO8AAVVLslqsfD4I/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=xq5BKRE7qY4:McMs6M1tCI0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/windows-vista-folder-winsxs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/windows-vista-folder-winsxs/</feedburner:origLink></item>
		<item>
		<title>PHP – How to use curl to get content of a website?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/NVoGl1m_Dis/</link>
		<comments>http://rongchaua.net/blog/php-how-to-use-curl-to-get-content-of-a-website/#comments</comments>
		<pubDate>Tue, 19 May 2009 07:00:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=320</guid>
		<description><![CDATA[As I developed my own small applications with Silverlight, I have difficulties with Cross-Site-Domain access. Because of preventing potential networking threats to be mitigated include:

Denial of Service (DoS) attacks – A large number of remote ...]]></description>
			<content:encoded><![CDATA[<p>As I developed my own small applications with Silverlight, I have difficulties with Cross-Site-Domain access. Because of preventing potential networking threats to be mitigated include:</p>
<ul>
<li>Denial of Service (DoS) attacks – A large number of remote hosts are used to attack a target site sothat the target is unable to service valid requests.</li>
<li>DNS Rebinding attacks – Use DNS to force a remote host to rebind a trusted host name (site oforigin) to a victim’s IP address, thus allowing access to a host other than site of origin.</li>
<li>Reverse tunnel attack – Use a remote client’s outgoing connection as a back tunnel to the client’sprivate network</li>
</ul>
<p>Therefore Silverlight requires a Security Policy System based on a xml file which will be put at the cross domain site. If he found this file on cross domain site, he will check the security policy. If he is allowed to access, then he&#8217;ll create a connection to it and start to transfer the data. If not, he will give an error with access limitation back.  This policy is good for avoiding all discussed threats above but it limits the functionalities of tools too.</p>
<p>For example I would like to call a url from a website and get its content back. I can not do it easily with Silverlight. I need to ask the author of website to put a xml file which allows my program to access. It is so complicated and I am sure that no author will allow you without gaining any benefit.</p>
<p>So I must find a way to get the content of that website through my website and Silverlight will connect to my site, get the content because I have full permission to my website. I can allow which tool to access my site. My site will work as a webservice which can be implemented in ASP or PHP.</p>
<p>Now it is time to decide which language should be used. I have used a month to ask my friends to share me a windows host to test some of my webservices. However none of my friend can help me. They all use Linux host. Thus I have no choice any more, I must use PHP. And today I write a very small code to get direct link of a song from http://chacha.vn as my first lesson with PHP.</p>
<p>Chacha.vn is music website, you can find there a lot of songs (vietnames, international) in MP3 quality. However they turned off the download function so if you want to download songs you need some add-ons or tool to get direct link of song. I think it is good to write my first tool in PHP with getting direct link. It must be not so difficult and suitable for beginners. Here is my code in PHP and here is tool to <a title="Get direct link of chacha.vn" href="http://rongchaua.net/Web/Service/chacha.php" target="_blank">get direct link of chacha.vn</a>.</p>
<pre class="brush: php;">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt; Tool to get download link from http://chacha.vn&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form method=&quot;post&quot; action=&quot;chacha.php&quot;&gt;
&lt;p&gt;Tool to get download link of a song at site http://chacha.vn&lt;/p&gt;
Enter id of song
&lt;input type=&quot;text&quot; name=&quot;txtSongId&quot; value=&quot;&lt;?php echo $_POST['txtSongId']; ?&gt;&quot;&gt;
&lt;input type=&quot;submit&quot; name=&quot;btnSubmit&quot; value=&quot;Get link&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;bSubmitted&quot; value=1&gt;
&lt;/form&gt;

&lt;?php
if (isset($_POST['bSubmitted']))
{
$strSongId = (string) $_POST['txtSongId'];
$strLinkMp3 = &quot;http://chacha.vn/song/getUrl?id=&quot;.$strSongId.&quot;&amp;songTable=1&quot;;
$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$strLinkMp3);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$strContent = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($strContent))
{
print &quot;Sorry, the id you entered may be wrong or the site chacha.vn is now not accessible&quot;;
}
else
{
print $strContent;
}
}
?&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=320&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/MYm5V4O2bWrv-08Wq5WdDt93wgY/0/da"><img src="http://feedads.g.doubleclick.net/~a/MYm5V4O2bWrv-08Wq5WdDt93wgY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/MYm5V4O2bWrv-08Wq5WdDt93wgY/1/da"><img src="http://feedads.g.doubleclick.net/~a/MYm5V4O2bWrv-08Wq5WdDt93wgY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=NVoGl1m_Dis:_ix1CN370Rw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/php-how-to-use-curl-to-get-content-of-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/php-how-to-use-curl-to-get-content-of-a-website/</feedburner:origLink></item>
		<item>
		<title>C# – How to read data from .msi file?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/QkMdQ3JP0nQ/</link>
		<comments>http://rongchaua.net/blog/c-how-to-read-data-from-msi-file/#comments</comments>
		<pubDate>Sun, 17 May 2009 07:00:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=314</guid>
		<description><![CDATA[Today I start a new small project on extracting file from .msi file. The reason I start this project is that sometimes I just want to run a program only once but it needs to ...]]></description>
			<content:encoded><![CDATA[<p>Today I start a new small project on extracting file from .msi file. The reason I start this project is that sometimes I just want to run a program only once but it needs to install on my machine. I do not like that. For example, I would like to check if my computer is suitable for Windows 7 so I downloaded <a title="Windows 7 Upgrade Advisor" href="http://www.chip.de/downloads/Windows-7-Upgrade-Advisor_36415833.html" target="_blank">Windows 7 Upgrade Advisor</a> and run it to test. After finising with download, I realized that it is a .msi file. That means I must install if I would like to use. So I search around to find an unpacker for MSI file but after some searching I decide to write my own one. I guess it is not so difficult to write a program to extract all files in .msi file.</p>
<p>In my first step, I searched for MSI file format specification but after hard searching in 30 minutes, I could not find any documenation about msi file format. I really hate Microsoft in some cases. Microsoft did not publish any documentation of some important file formats and protocols which they use in Windows. Before I have problem with MMS protocol and now with MSI, always no specification for them. <img src='http://rongchaua.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . I thought I could not start my project because it is not easy to reverse a file format of a complex structure. Luckily Wikipedia leads me to a <a title="Wix" href="http://wix.sourceforge.net/" target="_blank">WIX</a>.</p>
<blockquote><p>The Windows Installer XML toolset, is a free software toolset that builds Windows Installer (MSI) packages from an XML document. It supports a command-line environment that developers may integrate into their build processes to build MSI and MSM setup packages. WiX was the first software released by Microsoft under an open-source license called Common Public License.</p></blockquote>
<p>For more details, you can find at homepage of Wix. I just post below a small code snippet to access info from msi file.</p>
<pre class="brush: csharp;">

string strFileMsi = &quot;D:\\w7ua.msi&quot;;
string strFileMsiNameOnly = Path.GetFileNameWithoutExtension(strFileMsi);
string strDirectory = Path.GetDirectoryName(strFileMsi);
Database dbMsiFile = new Database(strFileMsi, OpenDatabase.ReadOnly);
View viewTemp = dbMsiFile.OpenExecuteView(&quot;SELECT * FROM Media&quot;);
Record rcTemp = viewTemp.Fetch();
string strCabsName = rcTemp[CNST_MEDIA_CABINET];
Console.WriteLine(strCabsName);
strCabsName = strCabsName.Substring(1);
viewTemp = dbMsiFile.OpenExecuteView(&quot;SELECT * FROM `_Streams` WHERE `Name` = '&quot; + strCabsName + &quot;'&quot;);
rcTemp = viewTemp.Fetch();
</pre>
<p>To view all available tables from msi file you can use Orca tool which is shipped with <a title="Windows Installer 4.5 SDK" href="http://www.microsoft.com/downloadS/details.aspx?familyid=6A35AC14-2626-4846-BB51-DDCE49D6FFB6&amp;displaylang=en" target="_blank">Windows Installer 4.5 SDK</a> as figure below.</p>
<p><img src="http://img2.pict.com/e2/4c/90/990c2468f05b4dcada9c7bbe39/ZxyG0/1.png" alt="Orca" /></p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=314&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/moGBKB31clXKHy75rTMo0N6Y-Z8/0/da"><img src="http://feedads.g.doubleclick.net/~a/moGBKB31clXKHy75rTMo0N6Y-Z8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/moGBKB31clXKHy75rTMo0N6Y-Z8/1/da"><img src="http://feedads.g.doubleclick.net/~a/moGBKB31clXKHy75rTMo0N6Y-Z8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=QkMdQ3JP0nQ:hMHLTiaX4TQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/c-how-to-read-data-from-msi-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/c-how-to-read-data-from-msi-file/</feedburner:origLink></item>
		<item>
		<title>C# – How to edit resource of an assembly?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/aG9ra_gw0Es/</link>
		<comments>http://rongchaua.net/blog/c-how-to-edit-resource-of-an-assembly/#comments</comments>
		<pubDate>Fri, 15 May 2009 07:00:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=305</guid>
		<description><![CDATA[In my previous blogs about playing around with SWF, I did already some important steps. There is still only one step which plays the most important role in development. That is how we can edit ...]]></description>
			<content:encoded><![CDATA[<p>In my previous blogs about <a title="SWF Tutorial" href="http://rongchaua.net/blog/category/tutorial/" target="_blank">playing around with SWF</a>, I did already some important steps. There is still only one step which plays the most important role in development. That is how we can edit the resource of an assembly. For example, in the screenshot below, I would like to replace the &#8220;fmared&#8221; with my own.</p>
<p><img src="http://img2.pict.com/da/0b/98/5b9ff4f6de3f51f9b0e5699f4c/62fHC/1.png" alt="Resources" /></p>
<p>So I try to explore the assembly with CFF Explorer to locate where the resources lies in the assembly. Open file with CFF Explorer, on the Resource Editor branch, I find the byte array of resources.</p>
<p><img src="http://img2.pict.com/18/f4/d9/8594fa80c1606dae8224a951b5/gn6o4/1.png" alt="Resources" /></p>
<p>In CFF Explorer, on Hex Editor branch, I enter some first bytes of resource section to find where it is in assembly.<br />
<img src=" http://img2.pict.com/1c/65/bf/8743e99b7e0c007292ae9ad044/Sd5Ra/1.png" alt="Resources" /></p>
<p>As you can see that the resource section lies circa in the middle of assembly. It lies under the section source code and above the MetaData Section. To edit a resource we must edit the byte array and paste all bytes which are under the resource byte. The header of file should be adjusted especially the .net meta data. It must be a big work. So I decide not write my own a dll to do that and so I use an available <a title="Mono.Cecil" href="http://www.mono-project.com/Cecil" target="_blank">Mono.Cecil</a> instead.</p>
<p>However as far as I know, I can not edit resource in Application.Properties.Resources.resources with Mono.Cecil. I can only create my own resource and edit, replace it as the code below. In this code snippet I load assembly new.exe, find the &#8220;rca&#8221; resource and dump it to file. You can create another code to edit resource basing on my own.</p>
<pre class="brush: csharp;">

static void Main(string[] args)
{
Assembly asm = Assembly.LoadFile(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + &quot;new.exe&quot;);
foreach (string strTemp in asm.GetManifestResourceNames())
{
if (strTemp == &quot;rca&quot;)
{
Stream readStream = asm.GetManifestResourceStream(strTemp);
string saveTo = &quot;d:\\export.swf&quot;;
// create a write stream
FileStream writeStream = new FileStream(saveTo, FileMode.Create, FileAccess.Write);
// write to the stream
ReadWriteStream(readStream,writeStream);
}
}
Console.ReadLine();
}
</pre>
<p>For example, the code below will add a custom resource &#8220;rca&#8221; to assembly.</p>
<pre class="brush: csharp;">
AssemblyDefinition asdDefinition = AssemblyFactory.GetAssembly(&quot;new.exe&quot;);
EmbeddedResource erTemp = new EmbeddedResource(&quot;rca&quot;, ManifestResourceAttributes.Public);
erTemp.Data = new byte[] { 0x01, 0x02, 0x03, 0x04 };
asdDefinition.MainModule.Resources.Add(erTemp);
AssemblyFactory.SaveAssembly(asdDefinition, &quot;new.exe&quot;);
</pre>
<p>The project Mono.Cecil can be checked out at this SVN http://anonsvn.mono-project.com/source/trunk/mcs/class/Mono.Cecil . If you do not have any tool to check out, you can download <a title="Mono.Cecil" href="http://go-mono.com/archive/cecil/cecil-0.6-bin.zip">Cecil 0.6 Binary (zip)</a> (from homepage) or <a title="Mono.Cecil" href="http://uploading.com/files/URBFL3IQ/Mono.Cecil.dll.html">my built version (15.05.2009)</a>.</p>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=305&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/m0m8_7X4QFzniw2Pj9aGqV0NMSs/0/da"><img src="http://feedads.g.doubleclick.net/~a/m0m8_7X4QFzniw2Pj9aGqV0NMSs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/m0m8_7X4QFzniw2Pj9aGqV0NMSs/1/da"><img src="http://feedads.g.doubleclick.net/~a/m0m8_7X4QFzniw2Pj9aGqV0NMSs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=aG9ra_gw0Es:PZy2iemzcfY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/c-how-to-edit-resource-of-an-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<media:content url="http://feedproxy.google.com/~r/RongchauaBlog/~5/TCZVgEXR4to/cecil-0.6-bin.zip" fileSize="169135" type="application/zip" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>In my previous blogs about playing around with SWF, I did already some important steps. There is still only one step which plays the most important role in development. That is how we can edit ...</itunes:subtitle><itunes:summary>In my previous blogs about playing around with SWF, I did already some important steps. There is still only one step which plays the most important role in development. That is how we can edit ...</itunes:summary><itunes:keywords>Tutorial</itunes:keywords><feedburner:origLink>http://rongchaua.net/blog/c-how-to-edit-resource-of-an-assembly/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/RongchauaBlog/~5/TCZVgEXR4to/cecil-0.6-bin.zip" length="169135" type="application/zip" /><feedburner:origEnclosureLink>http://go-mono.com/archive/cecil/cecil-0.6-bin.zip</feedburner:origEnclosureLink></item>
		<item>
		<title>C# – How to merge assembly?</title>
		<link>http://feedproxy.google.com/~r/RongchauaBlog/~3/411pP9V9UMw/</link>
		<comments>http://rongchaua.net/blog/c-how-to-merge-assembly/#comments</comments>
		<pubDate>Thu, 14 May 2009 16:53:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://rongchaua.net/blog/?p=301</guid>
		<description><![CDATA[In my two previous blogs C# &#8211; How to read header of SWF file? and C# &#8211; How to play a .swf file? , I showed you how to work around to read the header ...]]></description>
			<content:encoded><![CDATA[<p>In my two previous blogs <a title="Permanent Link to C# - How to read header of SWF file?" rel="bookmark" href="../c-how-to-read-header-of-swf-file/">C# &#8211; How to read header of SWF file?</a> and <a title="Permanent Link to C# - How to play a .swf file?" rel="bookmark" href="../c-how-to-play-a-swf-file/">C# &#8211; How to play a .swf file?</a> , I showed you how to work around to read the header of a swf file so that we can load it exactly. In my blogs you can see that we need a reference to an ocx control so that we can play a swf file. When adding this ocx control, two referenced dll will be automatically added into project. They are AxInterop.ShockwaveFlashObjects.dll and Interop.ShockwaveFlashObjects.dll. Shipping these two dlls will make my tool broken because I would like to convert a swf file to an exe. I would not like to convert one file to 3 files. Therefore I think about method to merge all assemblies into only one. So I can use either <a title="ILMerge" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=22914587-b4ad-4eae-87cf-b14ae6a939b0&amp;displaylang=en" target="_blank">ILMerge</a> (from Microsoft) or <a title="AssMer" href="http://rongchaua.net/tools-mainmenu-36/122-assmer-tool-to-merge-assembly" target="_blank">AssMer</a> (from my site).</p>
<p><span style="text-decoration: underline;"><strong>ILMerge</strong></span></p>
<blockquote><p>ILMerge takes a set of <em>input assemblies</em> and merges them into one <em>target assembly</em>. The first assembly in the list of input assemblies is the <em>primary assembly</em>. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.</p></blockquote>
<p><span style="text-decoration: underline;"><strong>AssMer</strong></span></p>
<blockquote><p>And now I would like to introduce to you AssMer, a tool to merge your assemblies. As its name, you can merge only until now ONLY assemblies with each other. You can not merge an assembly with a native code file.This tool is based on source code of Mono.Merge.</p></blockquote>
<p>You can choose any tool which you like. ILMerge is a console application. You can find its GUI at <a title="ILMerge GUI" href="http://ilmergegui.codeplex.com/" target="_blank">ILMerge GUI</a>. The following code is a code snippet which I extract from my tool. You can see that after merging we must fix the reference too.</p>
<pre class="brush: csharp;">
static void Process(MergeContext context)
{
AssemblyDefinition primary = AssemblyFactory.GetAssembly(context.Assemblies[0]);

for (int i = 1; i &lt; context.Assemblies.Count; i++)
{
AssemblyDefinition asm = AssemblyFactory.GetAssembly(context.Assemblies[i]);
asm.Accept(new StructureMerger(context, primary, asm));
}

FixReflectionAfterMerge fix = new FixReflectionAfterMerge(context, primary, primary);
fix.Process();

AssemblyFactory.SaveAssembly(primary, context.OutputPath);
}
</pre>
<img src="http://rongchaua.net/blog/?ak_action=api_record_view&id=301&type=feed" alt="" />
<p><a href="http://feedads.g.doubleclick.net/~a/w00P5FT-GLMo7D5AOpCAOplWJqQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/w00P5FT-GLMo7D5AOpCAOplWJqQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/w00P5FT-GLMo7D5AOpCAOplWJqQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/w00P5FT-GLMo7D5AOpCAOplWJqQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RongchauaBlog?a=411pP9V9UMw:sdJAVMDXCD8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RongchauaBlog?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://rongchaua.net/blog/c-how-to-merge-assembly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://rongchaua.net/blog/c-how-to-merge-assembly/</feedburner:origLink></item>
	<media:rating>nonadult</media:rating></channel>
</rss>
