ReactOS  0.4.12-dev-102-g4b7f1e0
integrity.cpp File Reference
#include "rapps.h"
#include <sha1.h>
Include dependency graph for integrity.cpp:

Go to the source code of this file.


BOOL VerifyInteg (LPCWSTR lpSHA1Hash, LPCWSTR lpFileName)

Function Documentation

◆ VerifyInteg()

BOOL VerifyInteg ( LPCWSTR  lpSHA1Hash,
LPCWSTR  lpFileName 

Definition at line 14 of file integrity.cpp.

Referenced by CDownloadManager::ThreadFunc().

15 {
16  BOOL ret = FALSE;
18  /* first off, does it exist at all? */
21  if (file == INVALID_HANDLE_VALUE)
22  return FALSE;
24  /* let's grab the actual file size to organize the mmap'ing rounds */
26  GetFileSizeEx(file, &size);
28  /* retrieve a handle to map the file contents to memory */
30  if (map)
31  {
32  /* map that thing in address space */
33  const unsigned char *file_map = static_cast<const unsigned char *>(MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0));
34  if (file_map)
35  {
36  SHA_CTX ctx;
37  /* initialize the SHA-1 context */
38  A_SHAInit(&ctx);
40  /* feed the data to the cookie monster */
41  A_SHAUpdate(&ctx, file_map, size.LowPart);
43  /* cool, we don't need this anymore */
44  UnmapViewOfFile(file_map);
46  /* we're done, compute the final hash */
47  ULONG sha[5];
48  A_SHAFinal(&ctx, sha);
50  WCHAR buf[(sizeof(sha) * 2) + 1];
51  for (UINT i = 0; i < sizeof(sha); i++)
52  swprintf(buf + 2 * i, L"%02x", ((unsigned char *) sha)[i]);
53  /* does the resulting SHA1 match with the provided one? */
54  if (!_wcsicmp(buf, lpSHA1Hash))
55  ret = TRUE;
56  }
57  CloseHandle(map);
58  }
59  CloseHandle(file);
60  return ret;
61 }
static const WCHAR sha[]
Definition: oid.c:1055
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
void WINAPI A_SHAUpdate(PSHA_CTX, const unsigned char *, UINT)
Definition: sha1.c:128
#define MapViewOfFile
Definition: compat.h:402
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum map
Definition: glfuncs.h:124
Definition: compat.h:391
GLenum GLclampf GLint i
Definition: glfuncs.h:14
Definition: addons.c:68
smooth NULL
Definition: ftsmooth.c:416
Definition: compat.h:427
Definition: compat.h:426
Definition: sha1.c:102
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned int UINT
Definition: ndis.h:50
Definition: nt_native.h:702
#define GetFileSizeEx
Definition: compat.h:414
int ret
static const WCHAR L[]
Definition: oid.c:1087
Definition: typedefs.h:104
Definition: compat.h:124
Definition: sha1.c:171
Definition: compat.h:127
#define CreateFileW
Definition: compat.h:400
unsigned int ULONG
Definition: retypes.h:1
#define UnmapViewOfFile
Definition: compat.h:403
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ LPCSTR lpFileName
Definition: winbase.h:3011
Definition: fci.c:126