I found the solution to this. The 32-bit call is expected to use the __stdcall calling convention. But using this convention causes the CoCreateInstance to not find the GetTSAudioEndpointEnumeratorForSession. To fix that I used a pragma:
#pragma comment(linker, "/export:GetTSAudioEndpointEnumeratorForSession=_GetTSAudioEndpointEnumeratorForSession@8")
Now the 32-bit code works as well as the 64-bit code.
CComActivator::DOCreateInstance throws access violation in 32-bit code.
Hi All,
I am seeing an exception running 32-bit code using CComActivator::DOCreateInstance. This call causes an access violation when invoking CoCreateInstance to instantiate a device enumerator object in a 32-bit DLL. The same code compiled 64-bit invoking the same enumerator in a 64-bit DLL works perfectly.
IMMDeviceEnumerator* pDeviceEnumerator = NULL;
CoCreateInstance(__uuidof(MMDeviceEnunerator), NULL, CLCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID*)&pDeviceEnumerator);
push 0
push eax
push 1
push 0
push dword ptr [ebp+10h]
mov ecx, ebx
call combase!CComActivator::DOCreateInstance
(3bc.1cf4): Access violation - code c0000005 (first chance)
BTW. The calling convention used in the DLL for all the enumerator methods is STDMETHODCALLTYPE, which is the required calling convention through class inheritance. What am I missing here? Is it a calling convention problem? Any ideas?
Sincerely,
Norman
1 answer
Sort by: Most helpful
-
Norman Viljoen 1 Reputation point
2022-05-17T10:56:03.91+00:00