ok, i want to get the version info out of my dll. i made a proc in asm that does just that, but could be buggy, i dont know,it returns all 0's. it uses VS_FIXEDFILEINFO,wich is the problem, i think........
i dont know if my problem is in the asm code, or the vb code.
i modled the asm off some vb code, if u want that too ask....

Public Declare Sub GetDllPathQuser32 Lib "QUSER32.dll" (ByVal pstr As String)'yes this works and returns a valid path name
Public Declare Sub GetDllVersionInfo Lib "QUSER32.dll" (ByVal pstr As String, ByRef bdshdh As VS_FIXEDFILEINFO)

dwSignature As Long
dwStrucVersion As Long
dwFileVersionMSl As Integer
dwFileVersionMSh As Integer
dwFileVersionLSl As Integer
dwFileVersionLSh As Integer
dwProductVersionMSl As Integer
dwProductVersionMSh As Integer
dwProductVersionLSl As Integer
dwProductVersionLSh As Integer
dwFileFlagsMask As Long
dwFileFlags As Long
dwFileOS As Long
dwFileType As Long
dwFileSubtype As Long
dwFileDateMS As Long
dwFileDateLS As Long
End Type

Dim c As String
c = Space(255)
GetDllPathQuser32 c
GetDllVersionInfo c, udtVerBuffer
MsgBox udtVerBuffer.dwFileVersionLSl & udtVerBuffer.dwFileVersionMSh & udtVerBuffer.dwFileVersionMSl & udtVerBuffer.dwFileVersionLSh

heres the asm

long Equ <:DWORD>
slashx db "\",0
GetDllVersionInfo Proc,FILEPTR long, REFvers long;:VS_FIXEDFILEINFO
Local lBufferLen long
Local ldummy long
Local hMemory long
Local pMemory long
Local lVerPointer long

Invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,5000
mov hMemory,eax
Invoke GlobalLock,hMemory
mov pMemory,eax

Invoke GetFileVersionInfoSize,FILEPTR,ldummy
mov lBufferLen,eax
cmp eax,0
je @GetDllVersionInfoEND

Invoke GetFileVersionInfo,FILEPTR,0,lBufferLen,pMemory
cmp eax,0
jnz @F
jmp @GetDllVersionInfoEND
Invoke VerQueryValue,pMemory,Addr slashx,lVerPointer,lBufferLen
cmp eax,0
jnz @F
jmp @GetDllVersionInfoEND
mov eax,REFvers
Invoke CopyMemory,eax,lVerPointer,lBufferLen

Invoke GlobalUnlock,pMemory
Invoke GlobalFree,hMemory
GetDllVersionInfo EndP
Posted on 2002-05-20 18:32:33 by Qages
try passing it ByVal instead of ByRef :)
Posted on 2002-05-20 19:09:03 by Hiroshimator
nope cant,
Posted on 2002-05-20 19:13:03 by Qages
ah yes

<snip> never mind, it's late, I'm tired and I didn't see the ;
Posted on 2002-05-20 19:19:03 by Hiroshimator
GetDllVersionInfo Proc,FILEPTR long, REFvers long
i am passing a dword, i made long equ :dword
.. if this is what ur talking about
Posted on 2002-05-20 19:21:58 by Qages
Posted on 2002-05-20 19:47:12 by sluggy
ive just spend 2 hours debugging it line by line and the asm just doesnt work, it isnt finding the dll oor somting i dont know it just doesnt work!!!! does any one have a thing that will return file info already made?
Posted on 2002-05-20 21:03:43 by Qages
Come on, you will have to be a bit more specific than that :rolleyes: What doesn't work? How do you know the dll isn't being found? Have you tried putting some debug messages inside the GetDllVersionInfo function to check program flow? And why do you not check your return values from API calls?

Also, there is another problem with your asm code. You should create your own private heap in your DllProcessAttach code, and use that within the dll. Like i mentioned previously, the VB runtime is always messing with the heap space that is allocated to the process, and you cannot always rely on your allocated memory being there and being safe to use.
Posted on 2002-05-20 22:51:32 by sluggy
Invoke GetFileVersionInfoSize,FILEPTR,ldummy
returns 0 wich means it didnt succeed
Posted on 2002-05-21 00:03:28 by Qages
Invoke GetFileVersionInfoSize,FILEPTR,ldummy
mov lBufferLen,eax
cmp eax,0
je @GetDllVersionInfoEND

Did you think to call GetLastError when this function fails? Windoze will tell you what went wrong, but only if you ask :)

One fault i can see with the code above: you are passing the variable 'ldummy', when you should actually be passing a *pointer* to it, i am surprised you are not getting a GPF.

Two other suggestions:
- are you checking that the VB variable 'c' contains a valid path before you pass it to the function GetDllVersionInfo? No path, no version.....
- is there version information stored in the dll file that you are trying to get information on? My understanding is that dll version info is stored in the dll as a resource, which means it could well be missing.

Also, just to be proper, you should change this line:
c = Space(255)

to this:
c = String(255, Chr$(0))
Posted on 2002-05-21 08:01:08 by sluggy
c contains the right path, and i added version info to the dll, i dont know why its not working. :(
Posted on 2002-05-21 15:31:16 by Qages
this vb code works 100%
returns 1002 my dll vers
oh how do i get the address of a var on the stack, lea eax...right?

edit: GetFileVersionInfoSize doesnt work in the asm, but works in the vb, ive debuged the code in vc++, the addresse to the string is right, its there and is termanated with null, and i made new code, and had addr to the ldummy.

GetDllPathQuser32 c
MsgBox QK_GetVersionInfo(c)
'GetDllVersionInfo c, udtVerBuffer
'MsgBox udtVerBuffer.dwFileVersionLSl & udtVerBuffer.dwFileVersionMSh & udtVerBuffer.dwFileVersionMSl & udtVerBuffer.dwFileVersionLSh
End Sub

Public Function QK_GetVersionInfo(ByVal sFile As String) As Long
Dim lDummy As Long
Dim sBuffer() As Byte
Dim lBufferLen As Long, lVerPointer As Long
Dim lVerBufferLen As Long
QK_GetVersionInfo = 0
lBufferLen = GetFileVersionInfoSize(sFile, _
If lBufferLen > 0 Then
ReDim sBuffer(lBufferLen)
If GetFileVersionInfo(sFile, 0&, _
lBufferLen, sBuffer(0)) <> 0 Then
If VerQueryValue(sBuffer(0), _
"\", lVerPointer, lVerBufferLen) _
<> 0 Then
CopyMemory udtVerBuffer, ByVal _
lVerPointer, Len(udtVerBuffer)
With udtVerBuffer
QK_GetVersionInfo = _
.dwFileVersionMSh & _
.dwFileVersionMSl & _
.dwFileVersionLSh & _
End With
End If
End If
End If
End Function

Posted on 2002-05-21 16:07:17 by Qages
Insert into your asm code a call to GetLastError if eax == 0 after the call to GetFileVersionInfoSize(). It will be a lot easier to diagnose your problem if we have an error code to work with.
Posted on 2002-05-21 23:51:35 by sluggy
Error code 1812 The specified image file did not contain a resource section. ERROR_RESOURCE_DATA_NOT_FOUND

but it works in vb! im passing the same string ptr to the asm and vb one
Posted on 2002-05-22 15:18:13 by Qages
im copying from vb heap, to my own heap and passin its pointer.
Posted on 2002-05-22 15:38:48 by Qages
In that picture you just posted, you had a file properties box. What shows up if you select the version tab? Is your dll's version there?

If you like, you can post your VB source and asm source to me, and i will see if i can fix it for you in the coming weekend (your source would have changed since you originally attached it). PM me first, i will give you my email address.
Posted on 2002-05-22 18:29:13 by sluggy
heres the version info. and i pmed you
Posted on 2002-05-22 21:27:18 by Qages