ReactOS 0.4.15-dev-5672-gf73ac17
integrity.cpp File Reference
#include "rapps.h"
#include <sha1.h>
Include dependency graph for integrity.cpp:

Go to the source code of this file.

Functions

BOOL VerifyInteg (LPCWSTR lpSHA1Hash, LPCWSTR lpFileName)
 

Function Documentation

◆ VerifyInteg()

BOOL VerifyInteg ( LPCWSTR  lpSHA1Hash,
LPCWSTR  lpFileName 
)

Definition at line 13 of file integrity.cpp.

14{
15 BOOL ret = FALSE;
16
17 /* first off, does it exist at all? */
19
21 return FALSE;
22
23 /* let's grab the actual file size to organize the mmap'ing rounds */
26
27 /* retrieve a handle to map the file contents to memory */
29 if (map)
30 {
31 /* map that thing in address space */
32 const unsigned char *file_map = static_cast<const unsigned char *>(MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0));
33 if (file_map)
34 {
36 /* initialize the SHA-1 context */
37 A_SHAInit(&ctx);
38
39 /* feed the data to the cookie monster */
40 A_SHAUpdate(&ctx, file_map, size.LowPart);
41
42 /* cool, we don't need this anymore */
43 UnmapViewOfFile(file_map);
44
45 /* we're done, compute the final hash */
46 ULONG sha[5];
48
49 WCHAR buf[(sizeof(sha) * 2) + 1];
50 for (UINT i = 0; i < sizeof(sha); i++)
51 swprintf(buf + 2 * i, L"%02x", ((unsigned char *) sha)[i]);
52 /* does the resulting SHA1 match with the provided one? */
53 if (!_wcsicmp(buf, lpSHA1Hash))
54 ret = TRUE;
55 }
57 }
59 return ret;
60}
void WINAPI A_SHAInit(PSHA_CTX)
Definition: sha1.c:102
void WINAPI A_SHAUpdate(PSHA_CTX, const unsigned char *, UINT)
Definition: sha1.c:128
void WINAPI A_SHAFinal(PSHA_CTX, PULONG)
Definition: sha1.c:171
Definition: _map.h:48
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR sha[]
Definition: oid.c:1218
#define CloseHandle
Definition: compat.h:739
#define PAGE_READONLY
Definition: compat.h:138
#define UnmapViewOfFile
Definition: compat.h:746
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
#define GetFileSizeEx
Definition: compat.h:757
#define MapViewOfFile
Definition: compat.h:745
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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 int UINT
Definition: ndis.h:50
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Definition: addons.c:68
Definition: fci.c:127
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ LPCSTR lpFileName
Definition: winbase.h:3058
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CDownloadManager::ThreadFunc().