Re: [Factor-talk] Executable version information

2019-06-18 Thread Alexander Ilin
Well, I surely didn't mean to dig THAT deep! : )) Here's the code that works for me. Please have a look and see if I missed something. I'm out of my comfort zone dealing with the aliens, always afraid of leaking memory, etc.Also, is there an elegant way to replace the tail of multiple `] [ f ] if`? USING:   alien alien.data alien.libraries alien.syntax   destructors formatting io.binary kernel libc locals math sequences   windows.types;IN: winver<< "version" "version.dll" stdcall add-library >>LIBRARY: versionFUNCTION: DWORD GetFileVersionInfoSizeA (   LPCSTR  lptstrFilename,   LPDWORD lpdwHandle )FUNCTION: DWORD GetFileVersionInfoSizeW (   LPCWSTR lptstrFilename,   LPDWORD lpdwHandle )ALIAS: GetFileVersionInfoSize GetFileVersionInfoSizeWFUNCTION: BOOL GetFileVersionInfoA (   LPCSTR lptstrFilename,   DWORD  dwHandle,   DWORD  dwLen,   LPVOID lpData )FUNCTION: BOOL GetFileVersionInfoW (   LPCWSTR lptstrFilename,   DWORD  dwHandle,   DWORD  dwLen,   LPVOID lpData )ALIAS: GetFileVersionInfo GetFileVersionInfoWFUNCTION: BOOL VerQueryValueA (   LPCVOID pBlock,   LPCSTR  lpSubBlock,   LPVOID  *lplpBuffer,   PUINT   puLen )FUNCTION: BOOL VerQueryValueW (   LPCVOID pBlock,   LPCSTR  lpSubBlock,   LPVOID  *lplpBuffer,   PUINT   puLen )ALIAS: VerQueryValue VerQueryValueW: translation-prefix ( alien -- string )   LPDWORD deref 4 memory>byte-array 2 cut [ le> ] bi@   "\\StringFileInfo\\%04x%04x\\" sprintf ;: version-query ( alien -- string )   translation-prefix "FileVersion" append ;:: (file-version) ( path data-size -- string/f )   [       data-size malloc &free :> data       path 0 data-size data GetFileVersionInfo [           f LPVOID  :> translation           data "\\VarFileInfo\\Translation" translation f VerQueryValue [               f LPCSTR  :> result               data translation version-query result f VerQueryValue               [ result LPCSTR deref ] [ f ] if           ] [ f ] if       ] [ f ] if   ] with-destructors ;: file-version ( path -- string/f )   dup f GetFileVersionInfoSize dup 0 > [ (file-version) ] [ 2drop f ] if ;  18.06.2019, 21:09, "John Benediktsson" :I don't think so, but that'd be a cool thing to add! https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format On Tue, Jun 18, 2019 at 10:37 AM Alexander Ilin  wrote:Hello!  Is there a vocab in Factor to extract the Version Information resource from an executable file on Windows?  I'm writing an app that needs to know the "FileVersion" string from the "StringFileInfo" block.---=--- Александр  ---=---Александр ___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Executable version information

2019-06-18 Thread John Benediktsson
I don't think so, but that'd be a cool thing to add!

https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format

On Tue, Jun 18, 2019 at 10:37 AM Alexander Ilin  wrote:

> Hello!
>
>   Is there a vocab in Factor to extract the Version Information resource
> from an executable file on Windows?
>   I'm writing an app that needs to know the "FileVersion" string from the
> "StringFileInfo" block.
>
> ---=---
>  Александр
>
>
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Executable version information

2019-06-18 Thread Alexander Ilin
Hello!

  Is there a vocab in Factor to extract the Version Information resource from 
an executable file on Windows?
  I'm writing an app that needs to know the "FileVersion" string from the 
"StringFileInfo" block.

---=--- 
 Александр



___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk