News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

OleAut32 lib linking issues with UASM64

Started by 2B||!2B, March 06, 2025, 07:48:33 PM

Previous topic - Next topic

2B||!2B

There is an issue with linking to this library.

I can't call any function from this library.

error LNK2019: unresolved external symbol _imp__SysAllocString@4
I already included the library OleAut32.lib

oleauto.inc has the prototype like so

proto_SysAllocString typedef proto WINSTDCALLCONV  :ptr OLECHAR
externdef WINSTDCALLCONV _imp__SysAllocString@4: ptr proto_SysAllocString
SysAllocString equ <_imp__SysAllocString@4>

With UASM32 it works. Only 64bit has this issue.

Anyone has the same issue?

six_L

Hi, 2B||!2B
QuoteOnly 64bit has this issue.
try this: (oleauto.inc)
proto_SysAllocString typedef proto WINSTDCALLCONV  :ptr OLECHAR
externdef WINSTDCALLCONV _imp__SysAllocString@8: ptr proto_SysAllocString
SysAllocString equ <_imp__SysAllocString@8>

32bit: the address is dword(4 bytes)
64bit: the address is qword(8 bytes)

Regards.
Say you, Say me, Say the codes together for ever.

sinsi

I'm not a UASM64 user, but 64-bit libraries don't have the "@4" suffix (that's for STDCALL).
externdef __imp_SysAllocString:PTR
SysAllocString equ <__imp_SysAllocString>

2B||!2B

Quote from: six_L on March 06, 2025, 08:46:14 PMHi, 2B||!2B
QuoteOnly 64bit has this issue.
try this: (oleauto.inc)
proto_SysAllocString typedef proto WINSTDCALLCONV  :ptr OLECHAR
externdef WINSTDCALLCONV _imp__SysAllocString@8: ptr proto_SysAllocString
SysAllocString equ <_imp__SysAllocString@8>

32bit: the address is dword(4 bytes)
64bit: the address is qword(8 bytes)

Regards.

I tried your suggession and now it complains about this tooerror LNK2019: unresolved external symbol _imp__SysAllocString@8

Quote from: sinsi on March 06, 2025, 09:24:38 PMI'm not a UASM64 user, but 64-bit libraries don't have the "@4" suffix (that's for STDCALL).
externdef __imp_SysAllocString:PTR
SysAllocString equ <__imp_SysAllocString>

This seems to have fixed the unresolved external.
Does this mean that oleauto.inc has wrong prototypes? Or is it only for MASM32?

This has solved it:
SysAllocString PROTO :ptr OLECHAR
I attached the oleauto.inc file which is from UASM WinInc210 zip.

_japheth

Quote from: 2B||!2B on March 06, 2025, 09:36:05 PMDoes this mean that oleauto.inc has wrong prototypes? Or is it only for MASM32?

It's just 32-bit.
The history: those includes were generated by tool h2incx, translating Win32 C header files supplied in the Windows SDKs. Not all at once, first just the basic Win32 ones. Your oleauto.inc was generated by a rather old version of h2incx, and used a source of an even older version of the Win SDK (MS VC 6).
To generate assembly includes that were compatible with both Win32 and Win64, one has to
  • use MS SDK C headers from at least 2003
  • use a h2incx version that understands cmdline option -d3

Even then it's not unlikely that the translated include files need some manual adjustments.

Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

2B||!2B


six_L

Hi, 2B||!2B

sorry: This is my misunderstanding.
@4: means the api has a parameter
@8: means the api have two parameters

another way:
_SysAllocString typedef PROTO psz:QWORD
@SysAllocString typedef ptr _SysAllocString

_SysFreeString typedef PROTO psz:QWORD
@SysFreeString typedef ptr _SysFreeString

.data?
hOleAut32_dll dq ?
pSz dq ?
pSysAllocString @SysAllocString ?
pSysFreeString @SysFreeString ?
.code

GetAPIFunc proc

invoke LoadLibrary,CStr("OleAut32.dll")
.if rax
mov hOleAut32_dll,rax
invoke GetProcAddress,hOleAut32_dll,CStr("SysAllocString")
mov pSysAllocString,rax
.if rax == NULL
invoke MessageBox,0,CStr("SysAllocString"),CStr("Error!"),MB_OK
jmp @Err
.endif

invoke GetProcAddress,hOleAut32_dll,CStr("SysFreeString")
mov pSysFreeString,rax
.if rax == NULL
invoke MessageBox,0,CStr("SysFreeString"),CStr("Error!"),MB_OK
jmp @Err
.endif
.else
invoke MessageBox,0,CStr("OleAut32.dll"),CStr("Error!"),MB_OK
jmp @Err
.endif
        mov     rax, 0
ret
@Err:
        mov     rax, 1
ret
GetAPIFunc endp

...
invoke GetAPIFunc
...
        invoke  pSysAllocString,pSz
...
invoke  pSysFreeString, pSz     
...
invoke FreeLibrary,hOleAut32_dll
...
Say you, Say me, Say the codes together for ever.