Skip to content

Commit

Permalink
Fix CComCreator::Hook_CoCreateInstance().
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcad committed Nov 3, 2011
1 parent 9385218 commit 454453f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
11 changes: 9 additions & 2 deletions code/pkg_Platform/Modules/ComHook/ComCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ComCreator.h"
#include "ComFileMap.h"
#include "../Public/ApiHook.h"
#include <UtilFunc/RelToAbs.h>

static const PROC s_oldfunc = (PROC)CoCreateInstance;
static CComFileMap s_filemap;
Expand Down Expand Up @@ -38,7 +39,9 @@ HRESULT WINAPI CComCreator::Hook_CoCreateInstance(
{
typedef HRESULT (WINAPI *FUNC_CREATE)(
REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID*);
hr = ((FUNC_CREATE)s_oldfunc)(rclsid, pUnkOuter, context, riid, ppv);
HRESULT hr2 = ((FUNC_CREATE)s_oldfunc)(rclsid, pUnkOuter, context, riid, ppv);
if (hr2 != REGDB_E_CLASSNOTREG)
hr = hr2;
}

return hr;
Expand Down Expand Up @@ -67,7 +70,11 @@ static inline std::wstring tostr(REFCLSID rclsid)
HRESULT CComCreator::LocalCreateInstance(
REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
HMODULE hmod = s_modules.GetModule(s_filemap.GetComFile(tostr(rclsid)));
std::wstring filename(s_filemap.GetComFile(tostr(rclsid)));
if (PathIsRelativeW(filename.c_str()))
filename = x3::FileNameRelToAbs(filename.c_str());

HMODULE hmod = s_modules.GetModule(filename);
HRESULT hr = hmod ? E_FAIL : REGDB_E_CLASSNOTREG;

if (hmod != NULL)
Expand Down
8 changes: 4 additions & 4 deletions projects/msvc/vcproj/HelloFrame_vc80.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -435,7 +435,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -444,7 +444,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -453,7 +453,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand Down
8 changes: 4 additions & 4 deletions projects/msvc/vcproj/HelloFrame_vc90.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -424,7 +424,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -433,7 +433,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -442,7 +442,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\config\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand Down
4 changes: 2 additions & 2 deletions projects/msvc/vcproj/TestPlatform.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions projects/msvc/vcproj/TestPlatform_vc80.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -409,7 +409,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -418,7 +418,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -427,7 +427,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -440,7 +440,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -449,7 +449,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -458,7 +458,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -467,7 +467,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand Down
16 changes: 8 additions & 8 deletions projects/msvc/vcproj/TestPlatform_vc90.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -398,7 +398,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -407,7 +407,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -416,7 +416,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\tests\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -429,7 +429,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -438,7 +438,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -447,7 +447,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand All @@ -456,7 +456,7 @@
>
<Tool
Name="VCCustomBuildTool"
CommandLine="xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
CommandLine="if exist $(InputPath) xcopy $(InputPath) &quot;$(TargetDir)\..\config\commap\&quot; /S/Q/Y/D&#x0D;&#x0A;"
Outputs="$(IntDir)\$(InputName)"
/>
</FileConfiguration>
Expand Down

0 comments on commit 454453f

Please sign in to comment.