If the windows_package resource you are using is from the Windows cookbook then the current version comes from an installed_packages collection which is built here
It looks in the Windows registry, the registry locations are documented on the Windows cookbook GitHub page
The source code for the Windows cookbook is public you can trace through what it is doing by tracking down the windows_package LWRP, I’d start by looking at the load_current_resource method which was the old LWRP method for obtaining the current state of a resource.
The windows_package that is built in to Chef operates differently.
The inbuilt windows_packages uses the excellent FFI library to make calls into the MSI package, the code is
Where get_product_property is calling
UINT MsiGetProductProperty( In MSIHANDLE hProduct, In LPCTSTR szProperty, Out LPTSTR lpValueBuf, Inout DWORD *pcchValueBuf
To sum up what has been said here with some slight correction:
If you are using chef client version 12.6 or higher. The installed version for MSIs uses the win32 function MsiGetProductInfo and uses the VersionString property. For non MSIs (EXEs), the installed version comes from the DisplayVersion value in the registry key: Software\Microsoft\Windows\CurrentVersion\Uninstall in HKLM or HKCU.
Older clients that use the windows cookbook windows_package resource use almost the same logic except that MSIs also use the above mentioned registry value and not MsiGetProductInfo.