Debian Codegraph @

Source/BinInterop.h

raw
1 /*
2 * BinInterop.h
3 *
4 * This file is a part of NSIS.
5 *
6 * Copyright (C) 2017-2026 Anders Kjersem
7 *
8 * Licensed under the zlib/libpng license (the "License");
9 * you may not use this file except in compliance with the License.
10 *
11 * Licence details can be found in the file COPYING.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty.
15 *
16 */
17
18 #ifndef NSIS_BININTEROP_H
19 #define NSIS_BININTEROP_H
20
21 #include "Platform.h"
22 #include "tchar.h"
23 #include <stdio.h> // FILE*
24
25 signed char GetExeType(const void*pData, size_t Size);
26 signed char GetExeType(const TCHAR*filepath);
27
28 FILE* MSTLB_fopen(const TCHAR*filepath, size_t*pResId = 0);
29 bool GetTLBVersion(const TCHAR *filepath, DWORD &high, DWORD &low, bool NotUsed = false);
30
31 bool GetDLLVersion(const TCHAR *filepath, DWORD &high, DWORD &low, bool Product = false);
32
33 typedef struct GENERICIMAGEINFO {
34 UINT32 Width, Height;
35 INT32 RawHeight;
36 WORD BPP, Planes;
37 GENERICIMAGEINFO() : RawHeight(0) {}
38 bool IsTopDownBitmap() const { return Height != (UINT32) RawHeight && RawHeight; }
39 } GENERICIMAGEINFO;
40
41 DWORD GetDIBHeaderInfo(const void*pData, size_t DataSize, GENERICIMAGEINFO&Info);
42 DWORD IsBMPFile(const void*pData, size_t DataSize, GENERICIMAGEINFO*pInfo = 0);
43 #define GetBMPFileHeaderSize IsBMPFile
44
45 inline WORD IsICOCURFile(const void*pData)
46 {
47 WORD *p16 = (WORD*) pData, ico = 1, cur = 2, type, count;
48 if (p16[0] == FIX_ENDIAN_INT16(0x0000))
49 if ((type = FIX_ENDIAN_INT16(p16[1])) == ico || type == cur)
50 return count = FIX_ENDIAN_INT16(p16[2]);
51 return 0;
52 }
53 inline WORD IsICOCURFile(const void*pData, size_t DataSize)
54 {
55 return DataSize > 6 ? IsICOCURFile(pData) : 0;
56 }
57
58 bool LoadImageCanLoadFile(const void*pData, size_t DataSize);
59 bool LoadImageCanLoadFile(const TCHAR *filepath);
60 #define LoadImageCanLoadFileFromResource LoadImageCanLoadFile
61
62 #endif //~ NSIS_BININTEROP_H