<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>WILD ARTIST &#187; DEVELOPMENT</title>
	<atom:link href="http://www.wildartist.org/archives/category/thinking-of-develop/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wildartist.org</link>
	<description>All about LIFE</description>
	<lastBuildDate>Tue, 07 Feb 2012 10:00:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Checking Out the Browser and the Version</title>
		<link>http://www.wildartist.org/archives/1683</link>
		<comments>http://www.wildartist.org/archives/1683#comments</comments>
		<pubDate>Sat, 05 Mar 2011 08:48:21 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Compatibility]]></category>
		<category><![CDATA[navigator.userAgent]]></category>
		<category><![CDATA[Web Browser]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=1683</guid>
		<description><![CDATA[In Javascript, browser information can be acquired from navigator.userAgent property. And it&#8217;d rather make them clear what the values are. The following table represents the list of navigator.userAgent value from each browser (and the version). Some of them might be &#8230; <a href="http://www.wildartist.org/archives/1683">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In Javascript, browser information can be acquired from <strong>navigator.userAgent</strong> property. And it&#8217;d rather make them clear what the values are. The following table represents the list of navigator.userAgent value from each browser (and the version).</p>
<p>Some of them might be differ from yours as they come from my laptop. For example, the value of IE8 involves .NET notations. That&#8217;s because I&#8217;ve installed .NET platform version 2.0, 3.0, 3.5 and 4.0. Thus, please don&#8217;t care about it.</p>
<div style="margin-bottom: 10px;">
<table style="width: 90%; border: 1px #ddd solid;">
<tbody>
<tr style="background: #eee; font-weight: bold; color:#000;">
<td style="width: 160px;">Browser</td>
<td>navigator.userAgent</td>
</tr>
<tr>
<td>Internet Explorer 8</td>
<td>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)</td>
</tr>
<tr>
<td>Internet Explorer 7</td>
<td>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)</td>
</tr>
<tr>
<td>Firefox 3.6</td>
<td>Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12</td>
</tr>
<tr>
<td>Chrome 9.0</td>
<td>Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13</td>
</tr>
<tr>
<td>Safari 5.0</td>
<td>Mozilla/5.0 (Windows; U; Windows NT 6.1; ko-KR) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4</td>
</tr>
<tr>
<td>Opera 11.0</td>
<td>Opera/9.80 (Windows NT 6.1; U; ko) Presto/2.7.62 Version/11.01</td>
</tr>
<tr>
<td>Android Browser<br />
(Motorola XT720)</td>
<td>Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; XT720 Build/STSKT_N_79.33.50R) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1</td>
</tr>
</tbody>
</table>
</div>
<p>Although there are more browsers, I think major browsers are already dealt.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/1683/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Listing Up HTTP Header Fields</title>
		<link>http://www.wildartist.org/archives/1651</link>
		<comments>http://www.wildartist.org/archives/1651#comments</comments>
		<pubDate>Mon, 07 Feb 2011 12:20:29 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[HTTP Header]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=1651</guid>
		<description><![CDATA[Whenever I write the code for HTTP request, I feel dumbed that I don&#8217;t memorize the header fields. So it would be nice to list up the fields with description in some place like blog. Some useful header fields are &#8230; <a href="http://www.wildartist.org/archives/1651">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Whenever I write the code for HTTP request, I feel dumbed that I don&#8217;t memorize the header fields. So it would be nice to list up the fields with description in some place like blog. Some useful header fields are here. (More headers are in <a href="http://en.wikipedia.org/wiki/List_of_HTTP_header_fields" target="_blank">Wikipedia</a>)</p>
<p><strong>Header Fields for HTTP Request</strong></p>
<table style="width: 100%; border: 1px #ddd solid;margin-bottom:10px;">
<tbody>
<tr style="background: #eee; font-weight: bold;color:#000;">
<td style="width: 120px;">Field Name</td>
<td>Field Description</td>
<td style="width: 180px;">Example</td>
</tr>
<tr>
<td>Accept</td>
<td>Content-Types that are acceptable.</td>
<td>text/plain</td>
</tr>
<tr>
<td>Accept-Charset</td>
<td>Character sets that are acceptable.</td>
<td>utf-8</td>
</tr>
<tr>
<td>Accept-Encoding</td>
<td>Acceptable encodings.</td>
<td>gzip</td>
</tr>
<tr>
<td>Accept-Language</td>
<td>Acceptable languages for response.</td>
<td>en-US</td>
</tr>
<tr>
<td>Cache-Control</td>
<td>Used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.</td>
<td>no-cache</td>
</tr>
<tr>
<td>Content-Type</td>
<td>The mime type of the body of the request.</td>
<td>application/x-www-form-urlencoded</td>
</tr>
<tr>
<td>User-Agent</td>
<td>The user agent string of the user agent.</td>
<td>Mozilla/5.0 (Linux; X11)</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/1651/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Introduction of RDMS Optimization</title>
		<link>http://www.wildartist.org/archives/1590</link>
		<comments>http://www.wildartist.org/archives/1590#comments</comments>
		<pubDate>Thu, 16 Dec 2010 08:24:06 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=1590</guid>
		<description><![CDATA[Almost all online services are using database. However, not-optimized database scheme causes disaster. The service would be slow down and sometimes get down with data requests overflown. Here I give a brief guideline on how to optimize database scheme. Most database &#8230; <a href="http://www.wildartist.org/archives/1590">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Almost all online services are using database. However, not-optimized database scheme causes disaster. The service would be slow down and sometimes get down with data requests overflown. Here I give a brief guideline on how to optimize database scheme.</p>
<p>Most database management system enacted on RDBMS(Relational Database Management System) base. The keyword is &#8220;Relational.&#8221; The way how to make relations mostly determines the whole performance.</p>
<p>There are 3 types of relation &#8211; 1:1, 1:n and n:m. Let&#8217;s take a look for each.</p>
<p><strong>One-to-One(1:1) relation</strong><br />
Although it is rarely used as all 1:1 relations can be expressed as one composite dataset, understanding the concept would help to see the connections more clear. A student and his student ID match is an example. One student has one ID and one ID is possessed by one student.</p>
<p><strong>One-to-Many(1:n) relation</strong><br />
It is the most common relation that most hierarchical structure can be represented with it. For example, suppose that 16 full-time employees are working in a company. Then the company has 16 employees, and each employee belong to one company.</p>
<p><strong>Many-to-Many(n:m) relation</strong><br />
This relation is the most complicated structure among relations so it requires the performance overhead. It traverses N*M times to search for data while One-to-Many relation does it N times. One of good examples is the relation between class and student. Students take many classes and each class has many students.</p>
<p>The key is that, avoid Many-to-Many relation to maximize performance. If it is inevitable, count the number of data records and control it with discussion. The performance is not to be ignored in web service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/1590/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Catch the User Input in Windows? Hooking!</title>
		<link>http://www.wildartist.org/archives/1430</link>
		<comments>http://www.wildartist.org/archives/1430#comments</comments>
		<pubDate>Mon, 11 Oct 2010 01:04:30 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Hooking]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=1430</guid>
		<description><![CDATA[Recently I got involved in a project as PM which deals with user input in Windows. The task was not easy so I hope to share some know-hows and tricks to implement the one. There are two categories of user &#8230; <a href="http://www.wildartist.org/archives/1430">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I got involved in a project as PM which deals with user input in Windows. The task was not easy so I hope to share some know-hows and tricks to implement the one.</p>
<p>There are two categories of user input: from character devices like keyboard and mouse, from inner process. An example of inner process is network packet-capturing. Anyway, I got to quote some code related to the first type of capture below. (Actually I don&#8217;t intend to post about the second type) Those implementations are actually in object-oriented structure. It is not that difficult so I just focused on the main issue rather than abstraction matter.</p>
<blockquote><p><span style="color: #0000ff;">int</span> idHook = NULL;<br />
HHOOK hHook = NULL;</p>
<p><span style="color: #0000ff;">bool</span> <strong>SetHook</strong>(HOOKPROC HookProc, HINSTANCE hInst) {</p>
<p style="padding-left: 30px;">ClearHook();<br />
hHook = SetWindowsHookEx(idHook, HookProc, hInst, 0);<br />
<span style="color: #0000ff;"> return</span> (hHook != 0);</p>
<p>}<br />
<span style="color: #0000ff;"> bool</span> <strong>SetHook</strong>(HOOKPROC HookProc, HINSTANCE hInst, DWORD dwThreadId) {</p>
<p style="padding-left: 30px;">ClearHook();<br />
hHook = SetWindowsHookEx(idHook, HookProc, hInst, dwThreadId);<br />
<span style="color: #0000ff;"> return</span> (hHook != 0);</p>
<p>}<br />
<span style="color: #0000ff;"> void</span> <strong>ClearHook</strong>() {</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">if</span> (hHook) {</p>
<p style="padding-left: 60px;">UnhookWindowsHookEx(hHook);<br />
hHook = NULL;</p>
<p style="padding-left: 30px;">}</p>
<p>}</p></blockquote>
<p>It&#8217;s very simple idea to register or clear hook process. To get inputs from character devices, we can use WH_JOURNALRECORD for idHook variable. It hooks all the messages from keyboard and mouse, returns the specific values in HookProc event handler. SetHook function gets 2~3 arguments which are hook procedure, Window instance handle and not necessarily, thread ID. I set the HookProc like this.</p>
<blockquote><p>LRESULT CALLBACK	<strong>JournalRecordProc</strong>(<span style="color: #0000ff;">int</span> code, WPARAM wParam, LPARAM lParam) {</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">if</span> (code &gt;= 0) UserInteractionProc(wParam, lParam);<br />
<span style="color: #0000ff;"> return</span> CallNextHookEx(hHook, code, wParam, lParam);</p>
<p>}</p></blockquote>
<p>JournalRecordProc seems to be simple and concise. UserInteractionProc represents an abstraction for disposal of the input message. That looks finished the implementation, however, there is a missing point. If user sends interrupt message, then the hook procedure would cease the operation. And the interruption easily occurs as Ctrl+ESC or Ctrl+Alt+Del key composition would make such an interruption. To retrieve the operation, you need to interleave a snippet of code lines.</p>
<blockquote><p><span style="color: #008000;">// Here is message loop in Windows application</span><br />
<span style="color: #0000ff;"> while</span> (GetMessage(&amp;msg, NULL, 0, 0)) {</p>
<p style="padding-left: 30px;"><span style="color: #008000;">// Retrieve the hook procedure here!</span><br />
<span style="color: #0000ff;"> if</span> (msg.message == WM_CANCELJOURNAL) SetHook(JournalRecordProc, hInst);</p>
<p style="padding-left: 30px;">TranslateMessage(&amp;msg);<br />
DispatchMessage(&amp;msg);</p>
<p>}</p></blockquote>
<p>I checked out that it works well in Windows XP. For Vista and 7, additional authorization process needed. For more information, see the MSDN documentation <a href="http://msdn.microsoft.com/en-us/library/bb625963.aspx" target="_blank">here</a>. It refers the User Interface Privilege Isolation (UIPI) and integrity in the lowest part of the document and you can get an answer for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/1430/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Event-driven Development Environment</title>
		<link>http://www.wildartist.org/archives/1093</link>
		<comments>http://www.wildartist.org/archives/1093#comments</comments>
		<pubDate>Tue, 27 Apr 2010 06:03:47 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Event-driven development]]></category>
		<category><![CDATA[SoA]]></category>
		<category><![CDATA[Software as a Service]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=1093</guid>
		<description><![CDATA[Human interacts with objects and these interactions are rooted in intention. Intention becomes a plan, and finally that would be a process. Looking familiar structure truely depends on how to do alike as we do. This paradigm invokes a great &#8230; <a href="http://www.wildartist.org/archives/1093">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Human interacts with objects and these interactions are rooted in intention. Intention becomes a plan, and finally that would be a process. Looking familiar structure truely depends on how to do alike as we do. This paradigm invokes a great development environment: Event-based development.</p>
<p><a href="http://www.wildartist.org/wp-content/uploads/2010/04/python.jpg"><img class="alignnone size-full wp-image-1092" title="python" src="http://www.wildartist.org/wp-content/uploads/2010/04/python.jpg" alt="" width="300" height="132" /></a></p>
<p>Traditional programming process has its entry point, like main() function in C and the structure adopts the one way, imperative design. But life is not that simple for many events occur in every second. It is the reality, and traditional model is not proper solution for complicated world nowadays. That is the point that event-driven programming can be a solution. In the context, each event makes its entry point and may call the handler procedures.</p>
<p>Event is a sort of interaction and process is the thing which does something intended and planned in advance. The role of programmer is just to plan the structure and to connect events to pertinent procedures. Limited input devices are prevailing that it is so lucky to developers that they don&#8217;t need to concern matters out of the range.</p>
<p>A good example of event-driven development environment is web. Server application listens to any request and do something for client who wants response expected. It is not a kind of new thinking but does a great role in even a cloud computing technology and other new coming edges. Believe it or not, I convince that this model would survive more than 20 years for it is the very simility to human nature. The change would be in how to weave the abstraction and how to capsulate the inner model and contents.</p>
<p>High expectation yields abundancy in the reality. And you know what? Expectation is a kind of <strong>event</strong> as well. Service and experience is a looming keyword in the 21st centuries industry going through the main stream now. It is the era of interaction and it accords with new trend like SaaS and PaaS. No one-way, broadcasting level communication anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/1093/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Focus on the Issue of Multi-Threading Tech.</title>
		<link>http://www.wildartist.org/archives/566</link>
		<comments>http://www.wildartist.org/archives/566#comments</comments>
		<pubDate>Mon, 07 Sep 2009 05:12:18 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Multithread]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=566</guid>
		<description><![CDATA[As prevailing of multi-core processors, the methodology of programming has changed recently. Severe contentions are on there, though, multi-threading paradigm is a well-known solution for parallel processing. I want to see this in the aspect of the performance and its &#8230; <a href="http://www.wildartist.org/archives/566">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As prevailing of multi-core processors, the methodology of programming has changed recently. Severe contentions are on there, though, multi-threading paradigm is a well-known solution for parallel processing. I want to see this in the aspect of the performance and its implementation.</p>
<p><img class="alignnone size-full wp-image-567" title="thread" src="http://www.wildartist.org/wp-content/uploads/2009/08/thread.jpg" alt="thread" width="300" height="128" /></p>
<p>The basic concept of multi-threading is this: <strong>divide and conquer</strong>. But you should not consider it of a speed-up engine which improves performance in proportional to the number of processors. There&#8217;s a way to determine the limit on the performance gaining from adding cores: Amdahl&#8217;s law. You can calculate total speed-up rate by using the formula below.</p>
<p>Speed-up-rate = 1 / (S + (1-S)/n)</p>
<p>Where S is the time spent executing the portion assigned to a thread or a processor and n is the number of processors. It shows that the speed-up rate would be decreased as the number of cores increases. Maximumly, if n goes to infinite, speed-up rate would converge to 1/S. For example, a task is divided into 10 parts and n is 2(dual-core), the speed-up rate for the task can be derived here: speedup = 1 / (0.1 + (1 &#8211; 0.1) / 2) = 1 / 0.55 ~= 1.8. (For quad-core, performance would increase more than 3 times according to the formula)</p>
<p>The actual importance is on its implementation. Even though the number of processor cores is numerous enough, the implementation may get down its performance. Parallelizing programming supports the hardware specification strongly and it&#8217;s ineluctable to increase performance. I&#8217;ve implemented a multi-thread processing library recently. And I want to reveal it in the part of running and waiting thread model which is implemented in C/C++ and Windows API.</p>
<p>First, I wrote the task class. It has 4 major member variables: a pointer for thread handler, that of parameter structure, thread handle, and its state. And the next, task manager class. It supports some methods to add/remove task objects, run, and wait. Now I open the code for Run and Wait functions.</p>
<blockquote><p><span style="color: #008000;">// Run: run all of the waiting tasks<br />
// _max_thread is determined by the number of processors</span><br />
<strong><span style="color: #0000ff;">void</span> wc_task_manager::Run()</strong> {</p>
<p style="padding-left: 30px;">size_t thread_count= _active_tasks.size();<br />
<span style="color: #008000;">// if thread pull is not full and any waiting task exists, assign a waiting task to the idle thread</span><br />
<span style="color: #0000ff;">while</span>(thread_count &lt; _max_thread &amp;&amp; _wait_tasks.size() &gt; 0) {</p>
<p style="padding-left: 60px;">wc_task* task = (wc_task*)(*_wait_tasks.begin());<br />
task-&gt;_complete = running;</p>
<p style="padding-left: 60px;">_wait_tasks.erase(_wait_tasks.begin());<br />
_active_tasks.push_back(task);<br />
thread_count++;<br />
<span style="color: #008000;">// CreateThread function is available only for windows.<br />
</span>task-&gt;_hThread = CreateThread(NULL, task-&gt;_stackSize, (LPTHREAD_START_ROUTINE)task-&gt;_handler, task-&gt;_param, 0, &amp;task-&gt;_hID);</p>
<p style="padding-left: 30px;">}</p>
<p>}</p></blockquote>
<blockquote><p><span style="color: #008000;">// Wait: wait for threads<br />
// it uses 3 container member variables: wait_tasks list, active_tasks list, and complete_tasks map</span><br />
<strong><span style="color: #0000ff;">void</span> wc_task_manager::Wait()</strong> {</p>
<p style="padding-left: 30px;"><span style="color: #008000;">// do while active task exists<br />
</span><span style="color: #0000ff;">while</span>(_active_tasks.size() &gt; 0) {</p>
<p style="padding-left: 60px;"><span style="color: #008000;">// count the waiting objects<br />
</span>size_t numberOfCurrentHandle = _active_tasks.size();<br />
<span style="color: #0000ff;">if</span>(numberOfCurrentHandle &gt; MAXIMUM_WAIT_OBJECTS)<br />
numberOfCurrentHandle = MAXIMUM_WAIT_OBJECTS;</p>
<p style="padding-left: 60px;"><span style="color: #008000;">// fill in the array of HANDLE</span><br />
HANDLE hList[MAXIMUM_WAIT_OBJECTS];<br />
<span style="color: #0000ff;">int</span> index = 0;<br />
<span style="color: #0000ff;">for</span>(list&lt;wc_task*&gt;::iterator pt = _active_tasks.begin(); pt != _active_tasks.end(); advance(pt, 1)) {</p>
<p style="padding-left: 90px;">wc_task* task = *pt;<br />
hList[index] = (HANDLE)(task-&gt;_hThread);<br />
index++;<br />
<span style="color: #0000ff;">if</span>(index == numberOfCurrentHandle) <span style="color: #0000ff;">break</span>;</p>
<p style="padding-left: 60px;">}</p>
<p style="padding-left: 60px;"><span style="color: #008000;">// waiting for signals<br />
<span style="color: #008000;">// _clockWait is set to 1 and that means it checks active threads each msec</span></span><br />
DWORD signal = WaitForMultipleObjects((DWORD)numberOfCurrentHandle, hList, FALSE, _clockWait);</p>
<p style="padding-left: 60px;"><span style="color: #008000;">// if some task has been completed</span><br />
<span style="color: #0000ff;">if</span>(signal != WAIT_TIMEOUT) {</p>
<p style="padding-left: 90px;">wc_task* task = NULL;</p>
<p style="padding-left: 90px;"><span style="color: #008000;">// if some task finishes in success, set the state to complete</span><br />
<span style="color: #0000ff;">if</span>(WAIT_OBJECT_0 &lt;= signal &amp;&amp; signal &lt; WAIT_OBJECT_0 + numberOfCurrentHandle) {</p>
<p style="padding-left: 90px;">HANDLE target_handle = hList[signal - WAIT_OBJECT_0];<br />
task = GetActiveTask(target_handle);<br />
<span style="color: #0000ff;">if</span>(task) task-&gt;_complete = complete;</p>
<p style="padding-left: 60px;">}<br />
<span style="color: #008000;">// if abandoned, set the state to abandoned</span><br />
<span style="color: #0000ff;">else if</span>(WAIT_ABANDONED_0 &lt;= signal &amp;&amp; signal &lt; WAIT_ABANDONED_0 + numberOfCurrentHandle) {</p>
<p style="padding-left: 90px;">HANDLE target_handle = hList[signal - WAIT_OBJECT_0];<br />
task = GetActiveTask(target_handle);<br />
<span style="color: #0000ff;">if</span>(task) task-&gt;_complete = abandoned;</span></span></p>
<p style="padding-left: 60px;">}</span></p>
<p style="padding-left: 60px;"><span style="color: #008000;">// if task exists</span><br />
<span style="color: #0000ff;">if</span>(task) {</p>
<p style="padding-left: 90px;"><span style="color: #008000;">// set the task to be complete and scheduling new task</span><br />
pair&lt;HANDLE, wc_task*&gt; p(task-&gt;_hThread, task);<br />
_complete_tasks.insert(p);<br />
_active_tasks.remove(task);<br />
Run();</p>
<p style="padding-left: 60px;">}</p>
<p style="padding-left: 30px;">}</p>
<p>}</p></blockquote>
<p>It&#8217;s not perfect but well-tested version. The reason why I don&#8217;t open the rest of the code is that there might be lots of troubles to overhaul so as to avoid exceptional errors. But the above 2 functions are the core factors of the library and it can be refered into the other applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/566/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Researching for public-key cryptography</title>
		<link>http://www.wildartist.org/archives/546</link>
		<comments>http://www.wildartist.org/archives/546#comments</comments>
		<pubDate>Tue, 07 Jul 2009 02:17:45 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Assymetric Key Algorithm]]></category>
		<category><![CDATA[Public Key Cryptography]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=546</guid>
		<description><![CDATA[Transferring data is like a broadcasting. In the other words, security plans don&#8217;t prevent sniffing clearly. You and I know that there&#8217;s no absolute solution for security. Actually it&#8217;s a big problem not to reveal the message to others but intended target. &#8230; <a href="http://www.wildartist.org/archives/546">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Transferring data is like a broadcasting. In the other words, security plans don&#8217;t prevent sniffing clearly. You and I know that there&#8217;s no absolute solution for security. Actually it&#8217;s a big problem not to reveal the message to others but intended target. Recently I&#8217;ve studied about public-key cryptography algorithm which encrypts data so that sniffers can&#8217;t understand the message or packets. Why does it works? The secret is, in equivalence of arithmetical formulas.</p>
<p><img class="alignnone size-full wp-image-547" title="checkmate" src="http://www.wildartist.org/wp-content/uploads/2009/07/checkmate.jpg" alt="checkmate" width="300" height="244" /></p>
<p>I couldn&#8217;t find any solution but a key structure. If you find some method that suffices the condition, you may get one of the most beautiful working solutions in the world. The simple is this: from randomly generated server-side private key Ks = { s1, s2, &#8230;, sk }, compose server-side public key Kf(s1, s2, &#8230;, sk). Client receives it and make a client-side private key Kc = { c1, c2, &#8230;, ck }. Lastly, client-side public key Kg(c1, c2, &#8230;, ck) should be bound to initial packet to server. The key solution is, a function list H = { H1, H2, &#8230;, Hk where Hi(Kg, si) = ci }. Now we can regulate it as below.</p>
<ul>
<li>Server generates server-side private key Ks and public key Kf.</li>
<li>Client receives Kf and compose client-side private key Kc and public key Kg.</li>
<li>Server gets client-side public key and takes Kc from Kg and Ks with function list H.</li>
</ul>
<p>Let x be an original data packet. Then we can encrypt it into a cipher E = Encrypt(Kc, x). (Function Encrypt should be reversible and its reversed function may be Decrypt) If server knows or gets Kc (as both server and client have Kf, and Kg and server is able to compose Kc from H), then server can decrypt the message by calculating x = Decrypt(Kc, E). Then the transfered message is safe from sniffing and eavesdropping.</p>
<p>Here&#8217;re some preconditions each key generation must keep in.</p>
<ul>
<li>Client-side public key Kg must not be decrypted to private key Kc by public keys.</li>
<li>Ks should not be predictable from public keys.</li>
<li>Encrypt function should not leave any clue to be decrypted.</li>
</ul>
<p>Famous algorithms like RSA, Diffie-Hallman exchange protocol also have this rule. I&#8217;ll keep researching for the algorithm and hope to find a great solution so that every web solution may have secure interactions between server and client. For more information about this issue, see <a href="http://en.wikipedia.org/wiki/Public-key_cryptography">http://en.wikipedia.org/wiki/Public-key_cryptography</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/546/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to avoid malicious content mitigation</title>
		<link>http://www.wildartist.org/archives/333</link>
		<comments>http://www.wildartist.org/archives/333#comments</comments>
		<pubDate>Tue, 23 Dec 2008 05:50:10 +0000</pubDate>
		<dc:creator>Chris Allo</dc:creator>
				<category><![CDATA[DEVELOPMENT]]></category>
		<category><![CDATA[Cyberattack]]></category>
		<category><![CDATA[Malicious Code]]></category>
		<category><![CDATA[SECURITY]]></category>

		<guid isPermaLink="false">http://www.wildartist.org/?p=333</guid>
		<description><![CDATA[This document is refered from CERT Adversory CA-2000-02. I introduce a security issue for web developers as I&#8217;m a web developer too. If you&#8217;ve researched about web security, you may have heard about XSS. What is XSS? XSS is acronym for cross-side &#8230; <a href="http://www.wildartist.org/archives/333">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This document is refered from <a href="http://www.cert.org/advisories/CA-2000-02.html" target="_blank">CERT Adversory CA-2000-02</a>.</p>
<p><img class="alignnone size-full wp-image-334" title="cert" src="http://www.wildartist.org/wp-content/uploads/2008/12/cert.jpg" alt="cert" width="300" height="155" /></p>
<p>I introduce a security issue for web developers as I&#8217;m a web developer too. If you&#8217;ve researched about web security, you may have heard about XSS. What is XSS? XSS is acronym for cross-side script. You may ask, &#8220;Why not CSS but XSS?&#8221; Yes. That&#8217;s because CSS means Cascading Style Sheets which is used to dispose HTML document and its components. To avoid confusion with duplicated terms, we often call cross-side script XSS. The document, CERT Adversory CA-2000-02, is talking about XSS. And I&#8217;ll abridge the report and explain how to avoid malicious script insertion.</p>
<p>In the beginning, let&#8217;s define a key term. What is script? Script includes javascript, VBScript, etc. It would be dangerous if someone seeds his script for malicious intention in your site. By the reference, its impact can be huge enough even to expose SSL-encrypted connections. Attackers are able to steal your cookies. They can modify the behavior of forms, including how results are submitted. Javascript rules domain based security policies but it would be broken with XSS attack.</p>
<p>Then how can we escape? Users can do nothing for this problem. Oh, there&#8217;s one. Disabling scripting languages would work. But, I think nobody want to do it. The real solution is in the hand of developers. They should recode dynamically generated pages to validate output. That means whenever user&#8217;s input text is revealed, replace original one by safe one. Now, I show you characters which can be a risky factor.</p>
<ul>
<li>In the content of the block-level elements, special characters like &#8220;&lt;&#8221;, &#8220;&gt;&#8221; and &#8220;&amp;&#8221; operates as a tag.</li>
<li>In attribute values, quotation marks should be checked.</li>
<li>In URLs, non-ASCII characters (especially &#8220;%&#8221;) should be filtered.</li>
</ul>
<p>These facts can be solved with the following solutions.<br />
<a href="http://www.cert.org/tech_tips/malicious_code_mitigation.html">http://www.cert.org/tech_tips/malicious_code_mitigation.html</a></p>
<p><strong>C++ Example</strong></p>
<blockquote><p>BYTE IsBadChar[] = {<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0xFF,0xFF,0&#215;00,0&#215;00,0xFF,0xFF,0xFF,0xFF,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0xFF,0xFF,0&#215;00,0xFF,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,0&#215;00,<br />
0&#215;00,0&#215;00,0&#215;00<br />
};</p>
<p>DWORD FilterBuffer(BYTE * pString,DWORD cChLen) {<br />
    BYTE * pBad = pString;<br />
    BYTE * pGood = pString;<br />
    DWORD i=0;<br />
    if (!pString) return 0;<br />
    for (i=0;pBad[i];i++) {<br />
        if (!IsBadChar[pBad[i]]) *pGood++ = pBad[i];<br />
    };<br />
    return pGood-pString;<br />
}</p></blockquote>
<p><strong>JavaScript Example</strong></p>
<blockquote><p>function RemoveBad(InStr) {<br />
    InStr = InStr.replace(/\&lt;/g,&#8221;").replace(/\&gt;/g,&#8221;");<br />
    InStr = InStr.replace(/\&#8221;/g,&#8221;")replace(/\&#8217;/g,&#8221;");<br />
    InStr = InStr.replace(/\%/g,&#8221;").replace(/\;/g,&#8221;");<br />
    InStr = InStr.replace(/\(/g,&#8221;").replace(/\)/g,&#8221;");<br />
    InStr = InStr.replace(/\&amp;/g,&#8221;").replace(/\+/g,&#8221;");<br />
    return InStr;<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.wildartist.org/archives/333/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

