<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Loading a DLL from memory</title>
	<atom:link href="http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joachim-bauch.de</link>
	<description>random::entropy</description>
	<lastBuildDate>Sun, 05 Feb 2012 10:11:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gelbaerchen</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-30219</link>
		<dc:creator>Gelbaerchen</dc:creator>
		<pubDate>Sun, 05 Feb 2012 10:11:24 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-30219</guid>
		<description>Hi,

meanwhile I succeeded in loading a ocx from memory, but I had to solve some issues, which also partly affected MemoryModule. 

First I ran into a problem as the OCX DLL invokes GetModuleFileName() using the instance handle passed in DllEntry(), which cannot work, as this is not a valid instance handle for the OS. 

Second I always ended in a runtime error R6002 inside the memory loaded DLL, which means, there&#039;s no FPU support loaded. I finally found that the DLL calls _IsNonwritableInCurrentImage() before the FPU initialisation and this didn&#039;t work correct. I ended up inside MemoryModule.c CopySections() where the section structs union member PhysicalAddress is set. On the DLL side this union is interpreted as VirtualSize, which is not correct any more. After removing the lines which set PhysicalAddress the FPU support was loaded correctly. So my question is, whether you know if it&#039;s necessary to set PhysicalAddress or if it&#039;s OK to keep it as VirtualSize? 

Perhaps this is also some kind of help for other developers,
Gelbaerchen</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>meanwhile I succeeded in loading a ocx from memory, but I had to solve some issues, which also partly affected MemoryModule. </p>
<p>First I ran into a problem as the OCX DLL invokes GetModuleFileName() using the instance handle passed in DllEntry(), which cannot work, as this is not a valid instance handle for the OS. </p>
<p>Second I always ended in a runtime error R6002 inside the memory loaded DLL, which means, there&#8217;s no FPU support loaded. I finally found that the DLL calls _IsNonwritableInCurrentImage() before the FPU initialisation and this didn&#8217;t work correct. I ended up inside MemoryModule.c CopySections() where the section structs union member PhysicalAddress is set. On the DLL side this union is interpreted as VirtualSize, which is not correct any more. After removing the lines which set PhysicalAddress the FPU support was loaded correctly. So my question is, whether you know if it&#8217;s necessary to set PhysicalAddress or if it&#8217;s OK to keep it as VirtualSize? </p>
<p>Perhaps this is also some kind of help for other developers,<br />
Gelbaerchen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gelbaerchen</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-28902</link>
		<dc:creator>Gelbaerchen</dc:creator>
		<pubDate>Tue, 17 Jan 2012 21:27:19 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-28902</guid>
		<description>Hi Joachim,

I&#039;d like to load a dll from memory that&#039;s needed later on by another library (which is a ocx control). But this ocx control always loads the original dll and not the one which has been already preloaded from memory. So probably I need a way to define a &quot;filename&quot; for the dll loaded from memory, that is used by the win32 LoadLibrary() to check, whether this dll is already loaded. Is there any chance to do this?

Thanks and best regards,
Gelbaerchen</description>
		<content:encoded><![CDATA[<p>Hi Joachim,</p>
<p>I&#8217;d like to load a dll from memory that&#8217;s needed later on by another library (which is a ocx control). But this ocx control always loads the original dll and not the one which has been already preloaded from memory. So probably I need a way to define a &#8220;filename&#8221; for the dll loaded from memory, that is used by the win32 LoadLibrary() to check, whether this dll is already loaded. Is there any chance to do this?</p>
<p>Thanks and best regards,<br />
Gelbaerchen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gelbaerchen</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-28901</link>
		<dc:creator>Gelbaerchen</dc:creator>
		<pubDate>Tue, 17 Jan 2012 21:18:25 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-28901</guid>
		<description>Hi Roger,

first I extracted the manifest from the dll I want to load with some kind of resource extractor and save this to a temporary file. Then ..

ACTCTX actctx = {sizeof(actctx)};
ZeroMemory(&amp;actctx, sizeof(actctx));
actctx.cbSize = sizeof(actctx);
actctx.lpSource = static_cast(TempFilename);
HANDLE hActCtx = CreateActCtx( &amp;actctx );
ULONG_PTR cookie = 0;
if ( ActivateActCtx( hActCtx, &amp;cookie ) )
{
   hMemModule = MemoryLoadLibrary( pBuffer );
   DeactivateActCtx( 0, cookie );
   ReleaseActCtx( hActCtx );
}

HTH ;-)
Gelbaerchen
						}</description>
		<content:encoded><![CDATA[<p>Hi Roger,</p>
<p>first I extracted the manifest from the dll I want to load with some kind of resource extractor and save this to a temporary file. Then ..</p>
<p>ACTCTX actctx = {sizeof(actctx)};<br />
ZeroMemory(&amp;actctx, sizeof(actctx));<br />
actctx.cbSize = sizeof(actctx);<br />
actctx.lpSource = static_cast(TempFilename);<br />
HANDLE hActCtx = CreateActCtx( &amp;actctx );<br />
ULONG_PTR cookie = 0;<br />
if ( ActivateActCtx( hActCtx, &amp;cookie ) )<br />
{<br />
   hMemModule = MemoryLoadLibrary( pBuffer );<br />
   DeactivateActCtx( 0, cookie );<br />
   ReleaseActCtx( hActCtx );<br />
}</p>
<p>HTH <img src='http://www.joachim-bauch.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Gelbaerchen<br />
						}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Looking for a PE format expert.</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-27762</link>
		<dc:creator>Looking for a PE format expert.</dc:creator>
		<pubDate>Wed, 04 Jan 2012 21:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-27762</guid>
		<description>[...] (LPCSTR)&amp;thunkData-&gt;Name); if (*funcRef == 0) { handleImportError(); return; } } Taken From: http://www.joachim-bauch.de/tutorial...l-from-memory/ You might also want to look at: http://win32assembly.online.fr/pe-tut6.html                   Reply [...]</description>
		<content:encoded><![CDATA[<p>[...] (LPCSTR)&amp;thunkData-&gt;Name); if (*funcRef == 0) { handleImportError(); return; } } Taken From: <a href="http://www.joachim-bauch.de/tutorial...l-from-memory/" rel="nofollow">http://www.joachim-bauch.de/tutorial&#8230;l-from-memory/</a> You might also want to look at: <a href="http://win32assembly.online.fr/pe-tut6.html" rel="nofollow">http://win32assembly.online.fr/pe-tut6.html</a>                   Reply [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Der müde Joe</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-27652</link>
		<dc:creator>Der müde Joe</dc:creator>
		<pubDate>Tue, 03 Jan 2012 18:22:29 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-27652</guid>
		<description>#define DLL_FILE &quot;..\\SampleDLL\\SampleDLL.dll&quot;

müsste bei der derzeitigen Konfiguration:

#define DLL_FILE &quot;..\\..\\SampleDLL\\Debug\\SampleDLL.dll&quot;

heißen!</description>
		<content:encoded><![CDATA[<p>#define DLL_FILE &#8220;..\\SampleDLL\\SampleDLL.dll&#8221;</p>
<p>müsste bei der derzeitigen Konfiguration:</p>
<p>#define DLL_FILE &#8220;..\\..\\SampleDLL\\Debug\\SampleDLL.dll&#8221;</p>
<p>heißen!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Der müde Joe</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-27651</link>
		<dc:creator>Der müde Joe</dc:creator>
		<pubDate>Tue, 03 Jan 2012 18:16:59 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-27651</guid>
		<description>Hallo Joachim,

INVALID_HANDLE_VALUE wird nur bei z.B. CreateFile() zurückgegeben.
LoadLibrary() gibt NULL zurück! (in LoadFromFile).

Gruß</description>
		<content:encoded><![CDATA[<p>Hallo Joachim,</p>
<p>INVALID_HANDLE_VALUE wird nur bei z.B. CreateFile() zurückgegeben.<br />
LoadLibrary() gibt NULL zurück! (in LoadFromFile).</p>
<p>Gruß</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-26585</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Tue, 20 Dec 2011 17:30:43 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-26585</guid>
		<description>Is anyone having issues running a DLL function via MemoryModule that uses SEH (structured exception handling)? For me I get a windows uncaught exception error.</description>
		<content:encoded><![CDATA[<p>Is anyone having issues running a DLL function via MemoryModule that uses SEH (structured exception handling)? For me I get a windows uncaught exception error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-24498</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Wed, 23 Nov 2011 20:33:41 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-24498</guid>
		<description>I get this error...

Unhandled exception at 0x75f4d36f in DllLoader.exe: Microsoft C++ exception: Debug::Error at memory location 0x001dde5c..

I&#039;m loading a DLL that seems to depend on QT. This is what gets put to the console before the above runtime error is displayed:

QFileInfo::absolutePath: Constructed with empty filename</description>
		<content:encoded><![CDATA[<p>I get this error&#8230;</p>
<p>Unhandled exception at 0&#215;75f4d36f in DllLoader.exe: Microsoft C++ exception: Debug::Error at memory location 0&#215;001dde5c..</p>
<p>I&#8217;m loading a DLL that seems to depend on QT. This is what gets put to the console before the above runtime error is displayed:</p>
<p>QFileInfo::absolutePath: Constructed with empty filename</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-24499</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Wed, 23 Nov 2011 20:33:41 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-24499</guid>
		<description>I get this error...

Unhandled exception at 0x75f4d36f in DllLoader.exe: Microsoft C++ exception: Debug::Error at memory location 0x001dde5c..

I&#039;m loading a DLL that seems to depend on QT. This is what gets put to the console before the above runtime error is displayed:

QFileInfo::absolutePath: Constructed with empty filename</description>
		<content:encoded><![CDATA[<p>I get this error&#8230;</p>
<p>Unhandled exception at 0&#215;75f4d36f in DllLoader.exe: Microsoft C++ exception: Debug::Error at memory location 0&#215;001dde5c..</p>
<p>I&#8217;m loading a DLL that seems to depend on QT. This is what gets put to the console before the above runtime error is displayed:</p>
<p>QFileInfo::absolutePath: Constructed with empty filename</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.joachim-bauch.de/tutorials/loading-a-dll-from-memory/comment-page-1/#comment-24340</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Tue, 22 Nov 2011 03:34:23 +0000</pubDate>
		<guid isPermaLink="false">http://localhost/~magog/wordpress/?page_id=32#comment-24340</guid>
		<description>Hi Gelbaerchen,

How did you solve that problem exactly? The DLL I&#039;m trying to MemoryLoadLibrary() depends on msvcr90.dll and msvcp90.dll. LoadLibrary fails to load these because (i&#039;m assuming) of this manifest issue.</description>
		<content:encoded><![CDATA[<p>Hi Gelbaerchen,</p>
<p>How did you solve that problem exactly? The DLL I&#8217;m trying to MemoryLoadLibrary() depends on msvcr90.dll and msvcp90.dll. LoadLibrary fails to load these because (i&#8217;m assuming) of this manifest issue.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

