flat assembler
Message board for the users of flat assembler.
Index
> Windows > Fail VerQueryValue |
Author |
|
revolution 18 May 2017, 11:14
You are setting the value at hfile to the fixed constant VS_FIXEDFILEINFO.dwFileVersionLS. So MessageBox has nothing to display other than a pointer to an invalid buffer.
|
|||
18 May 2017, 11:14 |
|
Picnic 18 May 2017, 13:22
Hi fasmlover, it is somewhat more complex.
Here is a working sample (written hurriedly), see if you can make something of it. Notice that you have to include the version.inc file. Code: format PE gui 4.0 entry start include "..\include\win32ax.inc" section ".data" data readable writeable lptstrFilename db "C:\Windows\System32\ntoskrnl.exe",0 lpData dd 0 BufLen dd 0 dwLen dd 0 dwHandle dd 0 pFileInfo dd 0 lpBuffer rb 256 section ".code" code readable executable start: invoke GetFileVersionInfoSize, lptstrFilename, dwHandle .if eax = 0 ; handle error jmp .exit .endif mov [dwLen], eax invoke LocalAlloc, LPTR, eax ; use HeapAlloc instead .if eax = 0 ; handle error jmp .exit .endif mov [lpData], eax invoke GetFileVersionInfo, lptstrFilename, [dwHandle], [dwLen], [lpData] .if eax = 0 invoke GetLastError ; handle error ; free lpData jmp .exit .endif invoke VerQueryValue, [lpData], "\\", pFileInfo, BufLen .if eax = 0 ; handle error ; free lpData jmp .exit .endif mov esi, [pFileInfo] ; VS_FIXEDFILEINFO ptr (FAR* FAR*) mov eax, [esi+2*4] ; dwFileVersionMS mov ebx, eax and ebx, 0xFFFF ; Minor Version shr eax, 16 and eax, 0xFFFF ; Major Version mov ecx, [esi+3*4] ; dwFileVersionLS mov edx, ecx and edx, 0xFFFF ; Revision Number shr ecx, 16 and ecx, 0xFFFF ; Build Number ; Output: major.minor.build.revision cinvoke wsprintf, lpBuffer, <"File Version: %d.%d.%d.%d">, eax, ebx, ecx, edx invoke MessageBox, 0, lpBuffer, lptstrFilename, MB_OK invoke LocalFree, [lpData] .exit: invoke ExitProcess, 0 section ".idata" import data readable writeable library kernel32,"kernel32.dll", user32,"user32.dll", version,"version.dll" include "..\include\api\kernel32.inc" include "..\include\api\user32.inc" include "..\include\api\version.inc" XP 32-Bit Output: major.minor.build.revision Windows 7 64 Bit
|
|||||||||||
18 May 2017, 13:22 |
|
fasmlover 21 May 2017, 08:57
Many thanks, guys. Especially appreciated a detailed response from Picnic and included "version.inc". It is extremely helpful; I did not know at that time what my roadblock was. Thanks again! It works perfectly, Picnic.
|
|||
21 May 2017, 08:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.