<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: From the list of idiotic function signatures&#8230;</title>
	<atom:link href="http://therning.org/magnus/archives/157/feed" rel="self" type="application/rss+xml" />
	<link>http://therning.org/magnus/archives/157?&amp;owa_from=feed&amp;owa_sid=</link>
	<description>Incoherent mumblings</description>
	<pubDate>Mon, 08 Sep 2008 12:18:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Magnus</title>
		<link>http://therning.org/magnus/archives/157#comment-3682</link>
		<dc:creator>Magnus</dc:creator>
		<pubDate>Sun, 29 Oct 2006 16:24:36 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/archives/157#comment-3682</guid>
		<description>&lt;p&gt;Well, despite my being wrong initially I think you've just made my initial point anyway. Absolutely &lt;em&gt;brilliant&lt;/em&gt; API. :-)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Well, despite my being wrong initially I think you&#8217;ve just made my initial point anyway. Absolutely <em>brilliant</em> API. <img src='http://therning.org/magnus/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hulten</title>
		<link>http://therning.org/magnus/archives/157#comment-3638</link>
		<dc:creator>Hulten</dc:creator>
		<pubDate>Fri, 27 Oct 2006 16:48:57 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/archives/157#comment-3638</guid>
		<description>&lt;p&gt;Well, not exactly.&lt;/p&gt;

&lt;p&gt;Basically what the code does is passing a 4 byte PSAPI_WORKING_SET_INFORMATION structure to QueryWorkingSet(). The first 4 bytes of the structure is the NumberOfEntries member. If the buffer is 4 bytes or more but still too small he will still fill out the NumberOfEntries member. 
Once you have NumberOfEntries you can easily calculate the full size of the structure. (NumberOfEntries+1)*4 and you have the number of bytes the structure needs. 
This behaviour is not inconsistent with msdnâ€™s documentation. But youâ€™re right, they donâ€™t document it at all. Itâ€™s a well know hack thatâ€™s been around at least since NT4. As with most hacks, the main drawback with it is that you donâ€™t get to whine if they change this behaviour in future versions..&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Well, not exactly.</p>
<p>Basically what the code does is passing a 4 byte PSAPI_WORKING_SET_INFORMATION structure to QueryWorkingSet(). The first 4 bytes of the structure is the NumberOfEntries member. If the buffer is 4 bytes or more but still too small he will still fill out the NumberOfEntries member.<br />
Once you have NumberOfEntries you can easily calculate the full size of the structure. (NumberOfEntries+1)*4 and you have the number of bytes the structure needs.<br />
This behaviour is not inconsistent with msdnâ€™s documentation. But youâ€™re right, they donâ€™t document it at all. Itâ€™s a well know hack thatâ€™s been around at least since NT4. As with most hacks, the main drawback with it is that you donâ€™t get to whine if they change this behaviour in future versions..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magnus</title>
		<link>http://therning.org/magnus/archives/157#comment-3635</link>
		<dc:creator>Magnus</dc:creator>
		<pubDate>Fri, 27 Oct 2006 09:02:17 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/archives/157#comment-3635</guid>
		<description>&lt;p&gt;What you are suggesting is that QueryWorkingSet() returns the size (well, actually a multiplier) in the "buffer" if the buffer size is too small.&lt;/p&gt;

&lt;p&gt;That is &lt;em&gt;not&lt;/em&gt; consistent with the documentation of the function in &lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms684946.aspx" rel="nofollow"&gt;MSDN&lt;/a&gt;. I'll give it a shot and report on the results.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>What you are suggesting is that QueryWorkingSet() returns the size (well, actually a multiplier) in the &#8220;buffer&#8221; if the buffer size is too small.</p>
<p>That is <em>not</em> consistent with the documentation of the function in <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms684946.aspx" rel="nofollow">MSDN</a>. I&#8217;ll give it a shot and report on the results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hulten</title>
		<link>http://therning.org/magnus/archives/157#comment-3625</link>
		<dc:creator>Hulten</dc:creator>
		<pubDate>Thu, 26 Oct 2006 18:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/archives/157#comment-3625</guid>
		<description>&lt;p&gt;To get the needed size for QueryWorkingSet() try something like:&lt;/p&gt;

&lt;p&gt;DWORD dw, dwNeededSize;
QueryWorkingSet(hProc, &#38;dw, sizeof(DWORD));
dwNeededSize = (dw+1) * sizeof(DWORD_PTR);
...
QueryWorkingSet(hProc, some allocated buff, dwNeededSize);&lt;/p&gt;

&lt;p&gt;you will want to check for correct error codes etc (like ERROR_BAD_LENGTH) after the first call..&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>To get the needed size for QueryWorkingSet() try something like:</p>
<p>DWORD dw, dwNeededSize;<br />
QueryWorkingSet(hProc, &amp;dw, sizeof(DWORD));<br />
dwNeededSize = (dw+1) * sizeof(DWORD_PTR);<br />
&#8230;<br />
QueryWorkingSet(hProc, some allocated buff, dwNeededSize);</p>
<p>you will want to check for correct error codes etc (like ERROR_BAD_LENGTH) after the first call..</p>
]]></content:encoded>
	</item>
</channel>
</rss>
