[PATCH] wdscore: Implement CurrentIP.

Jinoh Kang jinoh.kang.kr at gmail.com
Thu Jan 20 22:32:01 CST 2022


On 1/19/22 09:59, Mohamad Al-Jaf wrote:

> I see, thanks for the examples. I took a look at them and put this in tests/main.c:
> 
> extern void *WINAPI CurrentIP(void);
> 
> Doing this, the 64-bit test compiles without a problem, but the 32-bit runs into this problem:
> 
> /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld: dlls/wdscore/tests/main.cross.o: in function `test_CurrentIP':
> src/wine-staging-32-build/../wine-staging/dlls/wdscore/tests/main.c:33: undefined reference to `CurrentIP at 0'
> /usr/lib/gcc/i686-w64-mingw32/11.2.0/../../../../i686-w64-mingw32/bin/ld:
> /src/wine-staging-32-build/../wine-staging/dlls/wdscore/tests/main.c:33: undefined reference to `CurrentIP at 0'
> collect2: error: ld returned 1 exit status
> winegcc: /usr/bin/i686-w64-mingw32-gcc failed
> make[1]: *** [Makefile:228478: dlls/wdscore/tests/wdscore_test.exe] Error 2

"CurrentIP at 0" is a mangled symbol. The "@0" suffix means "this function follows the
__stdcall calling convention, and it accepts 0 bytes of arguments."

However, export symbols are usually exported as unmangled names. Try:

  DECLSPEC_IMPORT extern void *WINAPI CurrentIP(void);

> 
> Removing WINAPI from the declaration allows it to compile:
> 
> extern void *CurrentIP(void);

Note that this workaround can only be applied if the function takes no arguments.
Otherwise, stack corruption would result since the callee (__stdcall) would pop
out the arguments from the stack while the caller doesn't expect that (since it
was declared with default calling convention, which is __cdecl).

> 
> I don't understand why this is happening. What am I missing? The same error happens if I add a header file and import it. The dll wlanapi also has a void* function (void *WINAPI WlanAllocateMemory) and I don't see anything that might be missing in wdscore. Is there a missing header? I tried adding windows.h and other headers from similar dlls but it still says undefined reference to CurrentIP. Why would it work on 64-bit but not 32-bit?

In any architectures other than IA-32, __stdcall and __cdecl are the same;
thus, the name mangling does not take place.

> 
> I had a similar problem in the past with UiaRaiseAutomationPropertyChangedEvent but that was due to an incorrect spec file parameter. As far as I know, the spec parameter should be empty for 0 arguments and this is indeed how it is with other dlls:
> 
> ./dlls/powrprof/powrprof.spec:2:@ stdcall CanUserWritePwrScheme ()
> ./dlls/user32/user32.spec:365:@ stdcall GetProgmanWindow ()
> ./dlls/ws2_32/ws2_32.spec:71:@ stdcall WSACreateEvent ()

The "@NNN" part specifies the argument size, so there's some chance it is probably related.

-- 
Sincerely,
Jinoh Kang



More information about the wine-devel mailing list