mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 06:45:05 +00:00
Implement version.dll properly
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
char buffer[128];
|
||||
@@ -21,5 +22,66 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
printf("VERSION size=%lu\n", (unsigned long)versionSize);
|
||||
|
||||
char modulePath[MAX_PATH];
|
||||
DWORD moduleLen = GetModuleFileNameA(NULL, modulePath, sizeof(modulePath));
|
||||
if (moduleLen == 0 || moduleLen >= sizeof(modulePath)) {
|
||||
printf("GetModuleFileNameA failed: %lu\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD handle = 0;
|
||||
DWORD infoSize = GetFileVersionInfoSizeA(modulePath, &handle);
|
||||
if (!infoSize) {
|
||||
printf("GetFileVersionInfoSizeA failed: %lu\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *infoBuffer = (char *)malloc(infoSize);
|
||||
if (!infoBuffer) {
|
||||
printf("malloc failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!GetFileVersionInfoA(modulePath, 0, infoSize, infoBuffer)) {
|
||||
printf("GetFileVersionInfoA failed: %lu\n", GetLastError());
|
||||
free(infoBuffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
VS_FIXEDFILEINFO *fixedInfo = NULL;
|
||||
unsigned int fixedSize = 0;
|
||||
if (!VerQueryValueA(infoBuffer, "\\", (void **)&fixedInfo, &fixedSize)) {
|
||||
printf("VerQueryValueA root failed\n");
|
||||
free(infoBuffer);
|
||||
return 1;
|
||||
}
|
||||
printf("FILEVERSION=%u.%u.%u.%u\n",
|
||||
fixedInfo->dwFileVersionMS >> 16,
|
||||
fixedInfo->dwFileVersionMS & 0xFFFF,
|
||||
fixedInfo->dwFileVersionLS >> 16,
|
||||
fixedInfo->dwFileVersionLS & 0xFFFF);
|
||||
|
||||
struct { WORD wLanguage; WORD wCodePage; } *translations = NULL;
|
||||
unsigned int transSize = 0;
|
||||
if (VerQueryValueA(infoBuffer, "\\VarFileInfo\\Translation", (void **)&translations, &transSize) &&
|
||||
translations && transSize >= sizeof(*translations)) {
|
||||
printf("Translation=%04X %04X\n", translations[0].wLanguage, translations[0].wCodePage);
|
||||
char subBlock[64];
|
||||
snprintf(subBlock, sizeof(subBlock), "\\StringFileInfo\\%04X%04X\\ProductVersion",
|
||||
translations[0].wLanguage, translations[0].wCodePage);
|
||||
char *productVersion = NULL;
|
||||
unsigned int pvSize = 0;
|
||||
printf("Querying %s\n", subBlock);
|
||||
if (VerQueryValueA(infoBuffer, subBlock, (void **)&productVersion, &pvSize) && productVersion) {
|
||||
printf("PRODUCTVERSION=%s\n", productVersion);
|
||||
} else {
|
||||
printf("ProductVersion lookup failed\n");
|
||||
}
|
||||
} else {
|
||||
printf("ProductVersion lookup failed\n");
|
||||
}
|
||||
|
||||
free(infoBuffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user