-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwinres.c
82 lines (69 loc) · 1.61 KB
/
winres.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <winreg.h>
#include "nocrt.h"
#include "winres.h"
#include "setuperr.h"
BOOL is_wrapper(const char *dll, BOOL need_exists)
{
DWORD cbRes = 0;
DWORD dwHandle = 0;
void *res;
char strbuf[255];
int cnt = 0;
BOOL rc = FALSE;
cbRes = GetFileVersionInfoSizeA(dll, &dwHandle);
if(cbRes > 0)
{
res = malloc(cbRes);
if(res != NULL)
{
if(GetFileVersionInfoA(dll, dwHandle, cbRes, res))
{
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
UINT cbTranslate;
UINT i;
VerQueryValueA(res, "\\VarFileInfo\\Translation", (LPVOID *)&lpTranslate, &cbTranslate);
for(i = 0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++)
{
void *desc;
UINT descLen;
sprintf(strbuf, "\\StringFileInfo\\%04x%04x\\ProductName", lpTranslate[i].wLanguage, lpTranslate[i].wCodePage);
if(VerQueryValue(res, strbuf, &desc, &descLen))
{
if(descLen < sizeof(strbuf))
{
memcpy(strbuf, desc, descLen);
strbuf[descLen] = '\0';
//printf("ProductName (%u): %s\n", descLen, strbuf);
if(strstr(strbuf, "WINE") != NULL)
{
rc = TRUE;
}
else if(strstr(strbuf, "wine") != NULL)
{
rc = TRUE;
}
}
cnt++;
}
}
}
free(res);
/* no info, this is probably wrapper... */
if(cnt == 0)
{
rc = TRUE;
}
}
}
else if(need_exists)
{
return TRUE;
}
return rc;
}