I want to change the UUID of items that are decorated with __declspec(uuid())
at runtime.

I want to actually change the __uuidof references because there are macros
and templated classes (e.g. CComPtr) that expect to be able to use __uuidof.
So I either have to change all points where __uuidof is used to make it
retrieve the UUID at runtime without using __uuidof or I find a way to change
the actual memory address that __uuidof is using.

Is there a simple way to do this?

I've done some investigation and I have found that at least in non-optimized
builds __uuidof results in a reference to an extern "c" declaration similar
to the following:

extern "C" GUID _GUID_aa968851_31e5_406e_8673_32b01ea26ae3;

And I've found that I can change that value and in a non-optimized build it
changes all of the __uuidof references.

However, I suspect members of the compiler team will jump up and down when
they see this usage. Are you jumping yet? I'm just curious: Is it almost
guaranteed that optimizations will break attemps at doing this?
Theoretically speaking is there a way to prevent the optimizer from binding
the __uuidof value at compile time? Perhaps there's a simpler solution that
I'm missing?

Thanks!
- Don

Re: Changing a runtime UUID value that is declared with __declspec(uui by Igor

Igor
Wed Apr 12 16:39:22 CDT 2006

Don Schmitt <DonSchmitt@discussions.microsoft.com> wrote:
> I want to change the UUID of items that are decorated with
> __declspec(uuid()) at runtime.
> Perhaps there's a simpler solution that I'm missing?

A more interesting question is - why do you want to do this in the first
place? What is the real problem you are trying to solve? Perhaps there
is a simpler solution to that one.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925