Skip to content

Commit

Permalink
Adding win32 resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
PerryWerneck committed Nov 11, 2024
1 parent 077e2f7 commit b8a1d95
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 32 deletions.
24 changes: 22 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ app_conf.set('PACKAGE_VERSION_MAJOR', pkg_major_version)
app_conf.set('PACKAGE_VERSION_MINOR', pkg_minor_version)
app_conf.set('PACKAGE_VERSION_MICRO', pkg_micro_version)

app_conf.set('PRODUCT_NAME', meson.project_name())
app_conf.set('PRODUCT_VERSION', meson.project_version())

if cxx.compiles('#include <unistd.h>', name : 'unistd.h')
app_conf.set('HAVE_UNISTD_H', 1)
endif
Expand Down Expand Up @@ -147,8 +150,25 @@ lib_src = [
'src/libvmdetect/common.cc'
]

app_src = [
'src/vmdetect/vmdetect.cc'
]

if host_machine.system() == 'windows'

# https://mesonbuild.com/Windows-module.html
windows = import('windows')
resources = windows.compile_resources(
configure_file(
input : 'src/libvmdetect/os/windows/resources.rc.in',
output : 'resources.rc',
configuration : app_conf
)
)

lib_src += resources
app_src += resources

lib_src += [
'src/libvmdetect/os/windows/virtualmachine.cc'
]
Expand Down Expand Up @@ -197,7 +217,7 @@ if cxx.get_id() == 'msvc'

executable(
'vmdetect',
config_src + [ 'src/vmdetect/vmdetect.cc' ],
config_src + app_src,
install: true,
link_with : static,
include_directories: includes_dir,
Expand All @@ -219,7 +239,7 @@ else

executable(
'vmdetect',
config_src + [ 'src/vmdetect/vmdetect.cc' ],
config_src + app_src,
install: true,
link_with : dynamic,
include_directories: includes_dir,
Expand Down
104 changes: 74 additions & 30 deletions src/libvmdetect/os/windows/resources.rc.in
Original file line number Diff line number Diff line change
@@ -1,43 +1,87 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */

/*
* Copyright (C) 2021 Perry Werneck <perry.werneck@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/*
Recursos para o @PACKAGE_NAME@ windows
*
* Referências:
*
* <https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx>
* <https://stackoverflow.com/questions/1022449/how-to-change-an-executables-properties-windows>
* <https://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable>
*
*/

$URL: http://suportelinux.df.bb.com.br/svn/suporte/aplicativos/BBtools/v2/src/os/windows/resources.rc.in $
$Author: c1103788 $ $Date: 2022-01-13 16:23:55 -0300 (qui, 13 jan 2022) $ $Rev: 45749 $
#include <windows.h>

Referências:
#pragma code_page(65001) // UTF-8

<https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx>
<https://stackoverflow.com/questions/1022449/how-to-change-an-executables-properties-windows>
<https://stackoverflow.com/questions/708238/how-do-i-add-an-icon-to-a-mingw-gcc-compiled-executable>
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

VS_VERSION_INFO VERSIONINFO
FILEVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@
PRODUCTVERSION @PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@

*/
BEGIN

#include <windows.h>
// https://learn.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
// https://stackoverflow.com/questions/14221918/win32-resource-file-multiple-translations
BLOCK "StringFileInfo"
BEGIN

// English
BLOCK "080904B0"
BEGIN
VALUE "FileDescription", "Hypervisor detection\0"
VALUE "FileVersion", "@PACKAGE_VERSION_MAJOR@.@PACKAGE_VERSION_MINOR@.@PACKAGE_VERSION_MICRO@\0"
VALUE "LegalCopyright", "GNU GPLv3\0"
VALUE "ProductName", "@PRODUCT_NAME@\0"
VALUE "ProductVersion", "@PRODUCT_VERSION@\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@
PRODUCTVERSION @PACKAGE_MAJOR_VERSION@,@PACKAGE_MINOR_VERSION@,@PACKAGE_MAJOR_RELEASE@,@PACKAGE_MINOR_RELEASE@
END

// Brazilian Portuguese (UTF-8)
BLOCK "041604B0"
BEGIN
VALUE "FileDescription", "Detecção de máquina virtual\0"
VALUE "FileVersion", "@PACKAGE_VERSION_MAJOR@.@PACKAGE_VERSION_MINOR@.@PACKAGE_VERSION_MICRO@\0"
VALUE "LegalCopyright", "GNU GPLv3\0"
VALUE "ProductName", "@PRODUCT_NAME@\0"
VALUE "ProductVersion", "@PRODUCT_VERSION@\0"
END

/* CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "app-manifest.xml" */
// Brazilian Portuguese (Multilingual)
BLOCK "041604E4"
BEGIN
VALUE "FileDescription", "Detecção de máquina virtual\0"
VALUE "FileVersion", "@PACKAGE_VERSION_MAJOR@.@PACKAGE_VERSION_MINOR@.@PACKAGE_VERSION_MICRO@\0"
VALUE "LegalCopyright", "GNU GPLv3\0"
VALUE "ProductName", "@PRODUCT_NAME@\0"
VALUE "ProductVersion", "@PRODUCT_VERSION@\0"
END

BEGIN
END

BLOCK "StringFileInfo"
BEGIN
BLOCK "041604B0"
BEGIN
VALUE "FileDescription", "Hypervisor detection\0"
VALUE "FileVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0"
VALUE "OriginalFilename", "@PACKAGE_NAME@.dll\0"
VALUE "ProductName", "@PACKAGE_NAME@\0"
VALUE "ProductVersion", "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@\0"
END
END

BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0416, 0x04B0
END
// https://learn.microsoft.com/en-us/windows/win32/menurc/varfileinfo-block
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0809, 0x04B0, 0x0416, 0x04B0, 0x0416, 0x04E4
END

END

0 comments on commit b8a1d95

Please sign in to comment.