开发者

Change interface guids of COM DLL (ressource patch)

I have to build OEM versions of a COM library (DLL). Does anyone开发者_如何学编程 know a tool (ressource hacker) which may replace some of my interface guids after build time?

I just want to build and test one DLL and generate the OEM versions afterwards.


No tool that I know of. You could use an automated build process to actually build dll#s with different GUID's.


Replacing interface ids in the compiled binary is not that easy. They are usually hardcoded and the compiler allocates them in static storage and they might even have static linkage so you will have problems finding them. Remember how QueryInterface() is usually implemented?

HRESULT CImpl::QueryInterface( IID& iid, void** result )
{
    if( iid == __uuidof( IInterfaceThisClassImplements1 ) ) {
       *result = static_cast<IInterfaceThisClassImplements1*>( this );
    } else {
       ///same stuff for other interfaces
    }
    //call AddRef() if succeeded
}

It's not limited to resource editing, you have to actually patch the static data of the binary image and likely no tool will be able to do this automatically for you.

Since you have the full source your best bet is to just rebuild the binary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜