ReactOS  0.4.14-dev-323-g6fe6a88
sdbfileattr.c File Reference
#include "windef.h"
#include "apphelp.h"
#include "strsafe.h"
#include "winver.h"
#include "rtlfuncs.h"
Include dependency graph for sdbfileattr.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NUM_ATTRIBUTES   28
 

Enumerations

enum  APPHELP_MODULETYPE { MODTYPE_UNKNOWN = 0, MODTYPE_DOS = 1, MODTYPE_NE = 2, MODTYPE_PE = 3 }
 

Functions

static void WINAPI SdbpSetDWORDAttr (PATTRINFO attr, TAG tag, DWORD value)
 
static void WINAPI SdbpSetQWORDAttr (PATTRINFO attr, TAG tag, QWORD value)
 
static void WINAPI SdbpSetStringAttr (PATTRINFO attr, TAG tag, WCHAR *string)
 
static void WINAPI SdbpSetAttrFail (PATTRINFO attr)
 
static WCHAR *WINAPI SdbpGetStringAttr (LPWSTR translation, LPCWSTR attr, PVOID file_info)
 
static void WINAPI SdbpSetStringAttrFromAnsiString (PATTRINFO attr, TAG tag, PBYTE string, size_t len)
 
static void WINAPI SdbpSetStringAttrFromPascalString (PATTRINFO attr, TAG tag, PBYTE string)
 
static void SdbpReadFileVersion (PATTRINFO attr_info, PVOID file_info)
 
static DWORD WINAPI SdbpCalculateFileChecksum (PMEMMAPPED mapping)
 
static DWORD WINAPI SdbpGetModuleType (PMEMMAPPED mapping, PIMAGE_NT_HEADERS *nt_headers)
 
BOOL WINAPI SdbFreeFileAttributes (PATTRINFO attr_info)
 
BOOL WINAPI SdbGetFileAttributes (LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
 

Macro Definition Documentation

◆ NUM_ATTRIBUTES

#define NUM_ATTRIBUTES   28

Definition at line 18 of file sdbfileattr.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file sdbfileattr.c.

Enumeration Type Documentation

◆ APPHELP_MODULETYPE

Enumerator
MODTYPE_UNKNOWN 
MODTYPE_DOS 
MODTYPE_NE 
MODTYPE_PE 

Definition at line 19 of file sdbfileattr.c.

20 {
21  MODTYPE_UNKNOWN = 0,
22  MODTYPE_DOS = 1,
23  MODTYPE_NE = 2,
24  MODTYPE_PE = 3,
25 };

Function Documentation

◆ SdbFreeFileAttributes()

BOOL WINAPI SdbFreeFileAttributes ( PATTRINFO  attr_info)

Frees attribute data allocated by SdbGetFileAttributes.

Note
Unlike Windows, this implementation will not crash if attr_info is NULL.
Parameters
[in]attr_infoPointer to array of ATTRINFO which will be freed.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 214 of file sdbfileattr.c.

215 {
216  WORD i;
217 
218  if (!attr_info)
219  return FALSE;
220 
221  for (i = 0; i < NUM_ATTRIBUTES; i++)
222  if ((attr_info[i].type & TAG_TYPE_MASK) == TAG_TYPE_STRINGREF)
223  SdbFree(attr_info[i].lpattr);
224  SdbFree(attr_info);
225  return TRUE;
226 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define NUM_ATTRIBUTES
Definition: sdbfileattr.c:18
#define TAG_TYPE_MASK
Definition: shimdbg.c:106
#define SdbFree(mem)
Definition: sdbpapi.h:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short WORD
Definition: ntddk_ex.h:93
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109

Referenced by InitApphelp(), SdbGetMatchingExe(), SdbpMatchExe(), and START_TEST().

◆ SdbGetFileAttributes()

BOOL WINAPI SdbGetFileAttributes ( LPCWSTR  path,
PATTRINFO attr_info_ret,
LPDWORD  attr_count 
)

Retrieves attribute data shim database requires to match a file with database entry

Note
You must free the attr_info allocated by this function by calling SdbFreeFileAttributes.
Parameters
[in]pathPath to the file.
[out]attr_info_retPointer to array of ATTRINFO. Contains attribute data.
[out]attr_countNumber of attributes in attr_info.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 239 of file sdbfileattr.c.

240 {
241  static const WCHAR str_tinfo[] = {'\\','V','a','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n',0};
242  static const WCHAR str_trans[] = {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o','\\','%','0','4','x','%','0','4','x','\\','%','%','s',0};
243  static const WCHAR str_CompanyName[] = {'C','o','m','p','a','n','y','N','a','m','e',0};
244  static const WCHAR str_FileDescription[] = {'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
245  static const WCHAR str_FileVersion[] = {'F','i','l','e','V','e','r','s','i','o','n',0};
246  static const WCHAR str_InternalName[] = {'I','n','t','e','r','n','a','l','N','a','m','e',0};
247  static const WCHAR str_LegalCopyright[] = {'L','e','g','a','l','C','o','p','y','r','i','g','h','t',0};
248  static const WCHAR str_OriginalFilename[] = {'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e',0};
249  static const WCHAR str_ProductName[] = {'P','r','o','d','u','c','t','N','a','m','e',0};
250  static const WCHAR str_ProductVersion[] = {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
251 
253  MEMMAPPED mapped;
254  PBYTE mapping_end;
255  PVOID file_info = 0;
257  WCHAR translation[128] = {0};
258  PATTRINFO attr_info;
259 
260  struct LANGANDCODEPAGE {
261  WORD language;
262  WORD code_page;
263  } *lang_page;
264 
265  if (!SdbpOpenMemMappedFile(path, &mapped))
266  {
267  SHIM_ERR("Error retrieving FILEINFO structure\n");
268  return FALSE;
269  }
270  mapping_end = mapped.view + mapped.size;
271 
272  attr_info = (PATTRINFO)SdbAlloc(NUM_ATTRIBUTES * sizeof(ATTRINFO));
273 
274  SdbpSetDWORDAttr(&attr_info[0], TAG_SIZE, mapped.size);
275  if (mapped.size)
276  SdbpSetDWORDAttr(&attr_info[1], TAG_CHECKSUM, SdbpCalculateFileChecksum(&mapped));
277  else
278  SdbpSetAttrFail(&attr_info[1]);
280 
282  SdbpSetDWORDAttr(&attr_info[16], TAG_MODULE_TYPE, module_type);
283  else
284  SdbpSetAttrFail(&attr_info[16]); /* TAG_MODULE_TYPE */
285 
286  if (headers && module_type == MODTYPE_PE && ((PBYTE)(headers+1) <= mapping_end))
287  {
288  DWORD info_size;
289  ULONG export_dir_size;
291 
292  info_size = GetFileVersionInfoSizeW(path, NULL);
293  if (info_size != 0)
294  {
295  UINT page_size = 0;
296  file_info = SdbAlloc(info_size);
297  GetFileVersionInfoW(path, 0, info_size, file_info);
298  VerQueryValueW(file_info, str_tinfo, (LPVOID)&lang_page, &page_size);
299  StringCchPrintfW(translation, ARRAYSIZE(translation), str_trans, lang_page->language, lang_page->code_page);
300  }
301 
302  /* Handles 2, 3, 12, 13, 14, 15, 21, 22 */
303  SdbpReadFileVersion(attr_info, file_info);
304 
305  SdbpSetStringAttr(&attr_info[4], TAG_PRODUCT_VERSION, SdbpGetStringAttr(translation, str_ProductVersion, file_info));
306  SdbpSetStringAttr(&attr_info[5], TAG_FILE_DESCRIPTION, SdbpGetStringAttr(translation, str_FileDescription, file_info));
307  SdbpSetStringAttr(&attr_info[6], TAG_COMPANY_NAME, SdbpGetStringAttr(translation, str_CompanyName, file_info));
308  SdbpSetStringAttr(&attr_info[7], TAG_PRODUCT_NAME, SdbpGetStringAttr(translation, str_ProductName, file_info));
309  SdbpSetStringAttr(&attr_info[8], TAG_FILE_VERSION, SdbpGetStringAttr(translation, str_FileVersion, file_info));
310  SdbpSetStringAttr(&attr_info[9], TAG_ORIGINAL_FILENAME, SdbpGetStringAttr(translation, str_OriginalFilename, file_info));
311  SdbpSetStringAttr(&attr_info[10], TAG_INTERNAL_NAME, SdbpGetStringAttr(translation, str_InternalName, file_info));
312  SdbpSetStringAttr(&attr_info[11], TAG_LEGAL_COPYRIGHT, SdbpGetStringAttr(translation, str_LegalCopyright, file_info));
313 
314  /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms680339(v=vs.85).aspx */
315 
316  SdbpSetDWORDAttr(&attr_info[17], TAG_PE_CHECKSUM, headers->OptionalHeader.CheckSum);
317 
318  SdbpSetDWORDAttr(&attr_info[18], TAG_LINKER_VERSION, /* mislabeled! */
319  ((DWORD)headers->OptionalHeader.MajorImageVersion) << 16 | headers->OptionalHeader.MinorImageVersion);
320  SdbpSetAttrFail(&attr_info[19]); /* TAG_16BIT_DESCRIPTION */
321  SdbpSetAttrFail(&attr_info[20]); /* TAG_16BIT_MODULE_NAME */
322 
323  SdbpSetDWORDAttr(&attr_info[23], TAG_LINK_DATE, headers->FileHeader.TimeDateStamp);
324  SdbpSetDWORDAttr(&attr_info[24], TAG_UPTO_LINK_DATE, headers->FileHeader.TimeDateStamp);
325 
327  if (export_dir && ((PBYTE)(export_dir+1) <= mapping_end))
328  {
330  PBYTE export_name = RtlImageRvaToVa(headers, mapped.view, export_dir->Name, &section);
331  if (export_name)
332  SdbpSetStringAttrFromAnsiString(&attr_info[25], TAG_EXPORT_NAME, export_name, strlen((char*)export_name));
333  else
334  SdbpSetAttrFail(&attr_info[25]); /* TAG_EXPORT_NAME */
335  }
336  else
337  {
338  SdbpSetAttrFail(&attr_info[25]); /* TAG_EXPORT_NAME */
339  }
340 
341  if (info_size)
342  SdbpSetDWORDAttr(&attr_info[26], TAG_VER_LANGUAGE, lang_page->language);
343 
344  SdbpSetDWORDAttr(&attr_info[27], TAG_EXE_WRAPPER, 0); /* boolean */
345  }
346  else
347  {
348  int n;
349  for (n = 2; n < NUM_ATTRIBUTES; ++n)
350  {
351  if (n != 16 && n != 26)
352  SdbpSetAttrFail(&attr_info[n]);
353  }
354  if (module_type == MODTYPE_NE)
355  {
356  PBYTE ptr;
358  if ((PBYTE)(os2 + 1) <= mapping_end)
359  {
360  ptr = mapped.view + os2->ne_nrestab;
361  if (ptr <= mapping_end && (ptr + 1 + *ptr) <= mapping_end)
363  ptr = (PBYTE)os2 + os2->ne_restab;
364  if (ptr <= mapping_end && (ptr + 1 + *ptr) <= mapping_end)
366  }
367  }
368  }
369 
370  *attr_info_ret = attr_info;
371  *attr_count = NUM_ATTRIBUTES; /* As far as I know, this one is always 28 */
372 
374  SdbpCloseMemMappedFile(&mapped);
375  return TRUE;
376 }
#define TAG_INTERNAL_NAME
Definition: apphelp.c:68
#define TAG_16BIT_DESCRIPTION
Definition: apphelp.c:70
#define TAG_FILE_VERSION
Definition: apphelp.c:66
#define TRUE
Definition: types.h:120
#define TAG_EXE_WRAPPER
Definition: apphelp.c:56
#define TAG_VER_LANGUAGE
Definition: apphelp.c:52
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static DWORD WINAPI SdbpGetModuleType(PMEMMAPPED mapping, PIMAGE_NT_HEADERS *nt_headers)
Definition: sdbfileattr.c:176
#define RtlImageRvaToVa
Definition: compat.h:458
GLdouble n
Definition: glext.h:7729
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
static void WINAPI SdbpSetStringAttrFromAnsiString(PATTRINFO attr, TAG tag, PBYTE string, size_t len)
Definition: sdbfileattr.c:76
vector< Header * > headers
Definition: sdkparse.cpp:39
#define TAG_PRODUCT_NAME
Definition: apphelp.c:63
PBYTE view
Definition: sdbpapi.h:45
#define NUM_ATTRIBUTES
Definition: sdbfileattr.c:18
Definition: parser.c:55
#define SdbFree(mem)
Definition: sdbpapi.h:37
#define TAG_SIZE
Definition: apphelp.c:44
#define SdbAlloc(size)
Definition: sdbpapi.h:35
#define TAG_PRODUCT_VERSION
Definition: apphelp.c:64
static WCHAR *WINAPI SdbpGetStringAttr(LPWSTR translation, LPCWSTR attr, PVOID file_info)
Definition: sdbfileattr.c:60
static PVOID ptr
Definition: dispmode.c:27
struct tagATTRINFO * PATTRINFO
smooth NULL
Definition: ftsmooth.c:416
#define TAG_PE_CHECKSUM
Definition: apphelp.c:51
#define TAG_FILE_DESCRIPTION
Definition: apphelp.c:65
static export_section_t export_dir
Definition: data.c:448
#define TAG_CHECKSUM
Definition: apphelp.c:45
static void WINAPI SdbpSetDWORDAttr(PATTRINFO attr, TAG tag, DWORD value)
Definition: sdbfileattr.c:28
static void WINAPI SdbpSetStringAttr(PATTRINFO attr, TAG tag, WCHAR *string)
Definition: sdbfileattr.c:42
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define TAG_LEGAL_COPYRIGHT
Definition: apphelp.c:69
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define TAG_COMPANY_NAME
Definition: apphelp.c:62
void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping)
Definition: sdbapi.c:244
static void SdbpReadFileVersion(PATTRINFO attr_info, PVOID file_info)
Definition: sdbfileattr.c:104
BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping)
Definition: sdbapi.c:170
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RtlImageDirectoryEntryToData
Definition: compat.h:460
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:616
#define TAG_ORIGINAL_FILENAME
Definition: apphelp.c:67
module_type
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:140
#define TAG_MODULE_TYPE
Definition: apphelp.c:46
#define TAG_16BIT_MODULE_NAME
Definition: apphelp.c:71
#define TAG_LINK_DATE
Definition: apphelp.c:54
struct _IMAGE_OS2_HEADER * PIMAGE_OS2_HEADER
static void WINAPI SdbpSetAttrFail(PATTRINFO attr)
Definition: sdbfileattr.c:55
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
Definition: services.c:325
unsigned int UINT
Definition: ndis.h:50
struct _IMAGE_EXPORT_DIRECTORY * PIMAGE_EXPORT_DIRECTORY
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:850
static DWORD WINAPI SdbpCalculateFileChecksum(PMEMMAPPED mapping)
Definition: sdbfileattr.c:142
unsigned int ULONG
Definition: retypes.h:1
#define TAG_UPTO_LINK_DATE
Definition: apphelp.c:55
#define TAG_EXPORT_NAME
Definition: apphelp.c:72
static void WINAPI SdbpSetStringAttrFromPascalString(PATTRINFO attr, TAG tag, PBYTE string)
Definition: sdbfileattr.c:93
#define TAG_LINKER_VERSION
Definition: apphelp.c:53
BYTE * PBYTE
Definition: pedump.c:66
SIZE_T size
Definition: sdbpapi.h:46
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

Referenced by InitApphelp(), SdbGetMatchingExe(), SdbpMatchExe(), and START_TEST().

◆ SdbpCalculateFileChecksum()

static DWORD WINAPI SdbpCalculateFileChecksum ( PMEMMAPPED  mapping)
static

Definition at line 142 of file sdbfileattr.c.

143 {
144  size_t n, size;
145  PDWORD data;
146  DWORD checks = 0, carry = 0;
147 
148  if (mapping->size < 4)
149  return 0;
150 
151  if (mapping->size >= 0x1000)
152  {
153  size = 0x1000;
154  if (mapping->size < 0x1200)
155  data = (PDWORD)(mapping->view + mapping->size - size);
156  else
157  data = (PDWORD)mapping->view + (0x200 / 4);
158  }
159  else
160  {
161  data = (PDWORD)mapping->view;
162  size = mapping->size;
163  }
164 
165  for (n = 0; n < size / 4; ++n)
166  {
167  checks += *data;
168  carry = (checks & 1) ? 0x80000000 : 0;
169  checks >>= 1;
170  checks |= carry;
171  ++data;
172  }
173  return checks;
174 }
GLdouble n
Definition: glext.h:7729
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
DWORD * PDWORD
Definition: pedump.c:68

Referenced by SdbGetFileAttributes().

◆ SdbpGetModuleType()

static DWORD WINAPI SdbpGetModuleType ( PMEMMAPPED  mapping,
PIMAGE_NT_HEADERS nt_headers 
)
static

Definition at line 176 of file sdbfileattr.c.

177 {
179  PIMAGE_OS2_HEADER os2;
180 
181  *nt_headers = NULL;
182 
183  if (mapping->size < 2 || dos->e_magic != IMAGE_DOS_SIGNATURE)
184  return MODTYPE_UNKNOWN;
185 
186  if (mapping->size < sizeof(IMAGE_DOS_HEADER) || mapping->size < (dos->e_lfanew+2))
187  return MODTYPE_DOS;
188 
189  os2 = (PIMAGE_OS2_HEADER)((PBYTE)dos + dos->e_lfanew);
190  if (os2->ne_magic == IMAGE_OS2_SIGNATURE || os2->ne_magic == IMAGE_OS2_SIGNATURE_LE)
191  {
192  *nt_headers = (PIMAGE_NT_HEADERS)os2;
193  return MODTYPE_NE;
194  }
195 
196  if (mapping->size >= (dos->e_lfanew + 4) && ((PIMAGE_NT_HEADERS)os2)->Signature == IMAGE_NT_SIGNATURE)
197  {
198  *nt_headers = (PIMAGE_NT_HEADERS)os2;
199  return MODTYPE_PE;
200  }
201 
202  return MODTYPE_DOS;
203 }
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
smooth NULL
Definition: ftsmooth.c:416
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
if(!(yy_init))
Definition: macro.lex.yy.c:714
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
IMAGE_DOS_HEADER dos
Definition: module.c:49
#define IMAGE_OS2_SIGNATURE
Definition: pedump.c:90
struct _IMAGE_OS2_HEADER * PIMAGE_OS2_HEADER
BYTE * PBYTE
Definition: pedump.c:66
#define IMAGE_OS2_SIGNATURE_LE
Definition: pedump.c:91
PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS
Definition: ntddk_ex.h:187

Referenced by SdbGetFileAttributes().

◆ SdbpGetStringAttr()

static WCHAR* WINAPI SdbpGetStringAttr ( LPWSTR  translation,
LPCWSTR  attr,
PVOID  file_info 
)
static

Definition at line 60 of file sdbfileattr.c.

61 {
62  UINT size = 0;
63  PVOID buffer;
64  WCHAR value[128] = {0};
65 
66  if (!file_info)
67  return NULL;
68 
69  StringCchPrintfW(value, ARRAYSIZE(value), translation, attr);
70  if (VerQueryValueW(file_info, value, &buffer, &size) && size != 0)
71  return (WCHAR*)buffer;
72 
73  return NULL;
74 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: cookie.c:170
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

Referenced by SdbGetFileAttributes().

◆ SdbpReadFileVersion()

static void SdbpReadFileVersion ( PATTRINFO  attr_info,
PVOID  file_info 
)
static

Definition at line 104 of file sdbfileattr.c.

105 {
106  static const WCHAR str_root[] = {'\\',0};
107 
108  VS_FIXEDFILEINFO* fixed_info;
109  UINT size;
110  if (file_info && VerQueryValueW(file_info, str_root, (LPVOID*)&fixed_info, &size) && size)
111  {
112  if (fixed_info->dwSignature == VS_FFI_SIGNATURE)
113  {
115  version.HighPart = fixed_info->dwFileVersionMS;
116  version.LowPart = fixed_info->dwFileVersionLS;
117  SdbpSetQWORDAttr(&attr_info[2], TAG_BIN_FILE_VERSION, version.QuadPart);
118  SdbpSetQWORDAttr(&attr_info[21], TAG_UPTO_BIN_FILE_VERSION, version.QuadPart);
119  version.HighPart = fixed_info->dwProductVersionMS;
120  version.LowPart = fixed_info->dwProductVersionLS;
121  SdbpSetQWORDAttr(&attr_info[3], TAG_BIN_PRODUCT_VERSION, version.QuadPart);
122  SdbpSetQWORDAttr(&attr_info[22], TAG_UPTO_BIN_PRODUCT_VERSION, version.QuadPart);
123 
124  SdbpSetDWORDAttr(&attr_info[12], TAG_VERDATEHI, fixed_info->dwFileDateMS);
125  SdbpSetDWORDAttr(&attr_info[13], TAG_VERDATELO, fixed_info->dwFileDateLS);
126  SdbpSetDWORDAttr(&attr_info[14], TAG_VERFILEOS, fixed_info->dwFileOS); /* 0x000, 0x4, 0x40004, 0x40000, 0x10004, 0x10001*/
127  SdbpSetDWORDAttr(&attr_info[15], TAG_VERFILETYPE, fixed_info->dwFileType); /* VFT_APP, VFT_DLL, .... */
128  return;
129  }
130  }
131 
132  SdbpSetAttrFail(&attr_info[2]);
133  SdbpSetAttrFail(&attr_info[3]);
134  SdbpSetAttrFail(&attr_info[12]);
135  SdbpSetAttrFail(&attr_info[13]);
136  SdbpSetAttrFail(&attr_info[14]);
137  SdbpSetAttrFail(&attr_info[15]);
138  SdbpSetAttrFail(&attr_info[21]);
139  SdbpSetAttrFail(&attr_info[22]);
140 }
#define TAG_BIN_PRODUCT_VERSION
Definition: apphelp.c:58
#define TAG_VERFILEOS
Definition: apphelp.c:49
#define VS_FFI_SIGNATURE
Definition: verrsrc.h:37
#define TAG_VERDATEHI
Definition: apphelp.c:47
#define TAG_BIN_FILE_VERSION
Definition: apphelp.c:57
static const WCHAR version[]
Definition: asmname.c:66
static void WINAPI SdbpSetDWORDAttr(PATTRINFO attr, TAG tag, DWORD value)
Definition: sdbfileattr.c:28
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void WINAPI SdbpSetQWORDAttr(PATTRINFO attr, TAG tag, QWORD value)
Definition: sdbfileattr.c:35
#define TAG_VERFILETYPE
Definition: apphelp.c:50
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: apphelp.c:59
static void WINAPI SdbpSetAttrFail(PATTRINFO attr)
Definition: sdbfileattr.c:55
unsigned int UINT
Definition: ndis.h:50
#define TAG_UPTO_BIN_FILE_VERSION
Definition: apphelp.c:60
#define TAG_VERDATELO
Definition: apphelp.c:48
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

Referenced by SdbGetFileAttributes().

◆ SdbpSetAttrFail()

static void WINAPI SdbpSetAttrFail ( PATTRINFO  attr)
static

Definition at line 55 of file sdbfileattr.c.

56 {
57  attr->flags = ATTRIBUTE_FAILED;
58 }
Definition: cookie.c:170
#define ATTRIBUTE_FAILED
Definition: apphelp.h:143

Referenced by SdbGetFileAttributes(), and SdbpReadFileVersion().

◆ SdbpSetDWORDAttr()

static void WINAPI SdbpSetDWORDAttr ( PATTRINFO  attr,
TAG  tag,
DWORD  value 
)
static

Definition at line 28 of file sdbfileattr.c.

29 {
30  attr->type = tag;
31  attr->flags = ATTRIBUTE_AVAILABLE;
32  attr->dwattr = value;
33 }
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:142
Definition: cookie.c:170
GLsizei const GLfloat * value
Definition: glext.h:6069
char * tag
Definition: main.c:59

Referenced by SdbGetFileAttributes(), and SdbpReadFileVersion().

◆ SdbpSetQWORDAttr()

static void WINAPI SdbpSetQWORDAttr ( PATTRINFO  attr,
TAG  tag,
QWORD  value 
)
static

Definition at line 35 of file sdbfileattr.c.

36 {
37  attr->type = tag;
38  attr->flags = ATTRIBUTE_AVAILABLE;
39  attr->qwattr = value;
40 }
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:142
Definition: cookie.c:170
GLsizei const GLfloat * value
Definition: glext.h:6069
char * tag
Definition: main.c:59

Referenced by SdbpReadFileVersion().

◆ SdbpSetStringAttr()

static void WINAPI SdbpSetStringAttr ( PATTRINFO  attr,
TAG  tag,
WCHAR string 
)
static

Definition at line 42 of file sdbfileattr.c.

43 {
44  if (!string)
45  {
46  attr->flags = ATTRIBUTE_FAILED;
47  return;
48  }
49 
50  attr->type = tag;
51  attr->flags = ATTRIBUTE_AVAILABLE;
52  attr->lpattr = SdbpStrDup(string);
53 }
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:142
Definition: cookie.c:170
PWSTR SdbpStrDup(LPCWSTR string)
Definition: sdbapi.c:162
#define ATTRIBUTE_FAILED
Definition: apphelp.h:143
char * tag
Definition: main.c:59

Referenced by SdbGetFileAttributes().

◆ SdbpSetStringAttrFromAnsiString()

static void WINAPI SdbpSetStringAttrFromAnsiString ( PATTRINFO  attr,
TAG  tag,
PBYTE  string,
size_t  len 
)
static

Definition at line 76 of file sdbfileattr.c.

77 {
78  WCHAR* dest;
79  if (!string)
80  {
81  attr->flags = ATTRIBUTE_FAILED;
82  return;
83  }
84 
85  attr->type = tag;
86  attr->flags = ATTRIBUTE_AVAILABLE;
87  dest = attr->lpattr = SdbAlloc((len+1) * sizeof(WCHAR));
88  while (len--)
89  *(dest++) = *(string++);
90  *dest = 0;
91 }
#define SdbAlloc(size)
Definition: sdbpapi.h:35
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:142
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: cookie.c:170
GLenum GLsizei len
Definition: glext.h:6722
static char * dest
Definition: rtl.c:135
#define ATTRIBUTE_FAILED
Definition: apphelp.h:143
char * tag
Definition: main.c:59

Referenced by SdbGetFileAttributes(), and SdbpSetStringAttrFromPascalString().

◆ SdbpSetStringAttrFromPascalString()

static void WINAPI SdbpSetStringAttrFromPascalString ( PATTRINFO  attr,
TAG  tag,
PBYTE  string 
)
static

Definition at line 93 of file sdbfileattr.c.

94 {
95  if (!string)
96  {
97  attr->flags = ATTRIBUTE_FAILED;
98  return;
99  }
100 
101  SdbpSetStringAttrFromAnsiString(attr, tag, string + 1, *string);
102 }
static void WINAPI SdbpSetStringAttrFromAnsiString(PATTRINFO attr, TAG tag, PBYTE string, size_t len)
Definition: sdbfileattr.c:76
Definition: ecma_167.h:138
Definition: cookie.c:170
#define ATTRIBUTE_FAILED
Definition: apphelp.h:143

Referenced by SdbGetFileAttributes().