ReactOS  0.4.14-dev-604-gcfdd483
integrity.c File Reference
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "winnt.h"
#include "imagehlp.h"
#include "psapi.h"
Include dependency graph for integrity.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static BOOL (WINAPI *pImageAddCertificate)(HANDLE
 
static PIMAGE_NT_HEADERS (WINAPI *pCheckSumMappedFile)(PVOID
 
static BOOL copy_dll_file (void)
 
static DWORD get_file_size (void)
 
static DWORD test_add_certificate (const char *cert_data, int len)
 
static void test_get_certificate (const char *cert_data, int index)
 
static void test_remove_certificate (int index)
 
static void test_pe_checksum (void)
 
 START_TEST (integrity)
 

Variables

static HMODULE hImageHlp
 
static HMODULE hPsapi
 
static HMODULE hNtdll
 
static char test_dll_path [MAX_PATH]
 
static LPWIN_CERTIFICATE
 
static PDWORD
 
static WORD
 
static DWORD
 
static HMODULE
 
static LPMODULEINFO
 
static const char test_cert_data []
 
static const char test_cert_data_2 [] = {0xDE,0xAD,0xBE,0xEF,0x01,0x02,0x03}
 
static char test_pe_executable []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file integrity.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pImageAddCertificate)
static

◆ copy_dll_file()

static BOOL copy_dll_file ( void  )
static

Definition at line 120 of file integrity.c.

121 {
122  char sys_dir[MAX_PATH+15];
123  char temp_path[MAX_PATH];
124 
125  if (GetSystemDirectoryA(sys_dir, MAX_PATH) == 0)
126  {
127  skip("Failed to get system directory. Skipping certificate/PE image tests.\n");
128  return FALSE;
129  }
130 
131  if (sys_dir[lstrlenA(sys_dir) - 1] != '\\')
132  lstrcatA(sys_dir, "\\");
133 
134  lstrcatA(sys_dir, "imagehlp.dll");
135 
136  /* Copy DLL to a temp file */
139 
140  if (CopyFileA(sys_dir, test_dll_path, FALSE) == 0)
141  {
142  skip("Unable to create copy of imagehlp.dll for tests.\n");
143  return FALSE;
144  }
145 
146  return TRUE;
147 }
#define TRUE
Definition: types.h:120
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define MAX_PATH
Definition: compat.h:26
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define skip(...)
Definition: atltest.h:64
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
char temp_path[MAX_PATH]
Definition: mspatcha.c:123

Referenced by START_TEST().

◆ get_file_size()

static DWORD get_file_size ( void  )
static

Definition at line 149 of file integrity.c.

150 {
151  HANDLE file;
152  DWORD filesize = 0;
153 
156  if (file == INVALID_HANDLE_VALUE)
157  return 0;
158 
159  filesize = GetFileSize(file, NULL);
160  CloseHandle(file);
161 
162  return filesize;
163 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FILE_SHARE_READ
Definition: compat.h:125
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
Definition: fci.c:126

Referenced by START_TEST().

◆ PIMAGE_NT_HEADERS()

static PIMAGE_NT_HEADERS ( WINAPI pCheckSumMappedFile)
static

◆ START_TEST()

START_TEST ( integrity  )

Definition at line 391 of file integrity.c.

392 {
393  DWORD file_size, file_size_orig, first, second;
394 
395  hImageHlp = LoadLibraryA("imagehlp.dll");
396 
397  if (!hImageHlp)
398  {
399  win_skip("ImageHlp unavailable\n");
400  return;
401  }
402 
403  if (!copy_dll_file())
404  {
406  return;
407  }
408 
409  file_size_orig = get_file_size();
410 
411  pImageAddCertificate = (void *) GetProcAddress(hImageHlp, "ImageAddCertificate");
412  pImageEnumerateCertificates = (void *) GetProcAddress(hImageHlp, "ImageEnumerateCertificates");
413  pImageGetCertificateData = (void *) GetProcAddress(hImageHlp, "ImageGetCertificateData");
414  pImageGetCertificateHeader = (void *) GetProcAddress(hImageHlp, "ImageGetCertificateHeader");
415  pImageRemoveCertificate = (void *) GetProcAddress(hImageHlp, "ImageRemoveCertificate");
416  pCheckSumMappedFile = (void *) GetProcAddress(hImageHlp, "CheckSumMappedFile");
417 
418  hPsapi = LoadLibraryA("psapi.dll");
419  if (hPsapi)
420  pGetModuleInformation = (void *) GetProcAddress(hPsapi, "GetModuleInformation");
421 
422  hNtdll = LoadLibraryA("ntdll.dll");
423  if (hNtdll)
424  pRtlImageNtHeader = (void *) GetProcAddress(hNtdll, "RtlImageNtHeader");
425 
429 
431  ok(file_size == file_size_orig, "File size different after add and remove (old: %d; new: %d)\n", file_size_orig, file_size);
432 
433  /* Try adding multiple certificates */
436  ok(second == first + 1, "got %d %d\n", first, second);
437 
440 
441  /* Remove the first one and verify the second certificate is intact */
443  second--;
445 
446  test_remove_certificate(second);
447 
449  ok(file_size == file_size_orig, "File size different after add and remove (old: %d; new: %d)\n", file_size_orig, file_size);
450 
452 
453  if (hPsapi) FreeLibrary(hPsapi);
454  if (hNtdll) FreeLibrary(hNtdll);
457 }
static HMODULE hNtdll
Definition: integrity.c:31
const GLint * first
Definition: glext.h:5794
static HMODULE hImageHlp
Definition: integrity.c:31
static DWORD get_file_size(void)
Definition: integrity.c:149
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
static BOOL copy_dll_file(void)
Definition: integrity.c:120
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static DWORD test_add_certificate(const char *cert_data, int len)
Definition: integrity.c:165
#define FreeLibrary(x)
Definition: compat.h:413
static HMODULE hPsapi
Definition: integrity.c:31
unsigned long DWORD
Definition: ntddk_ex.h:95
static void test_remove_certificate(int index)
Definition: integrity.c:243
static void test_get_certificate(const char *cert_data, int index)
Definition: integrity.c:205
static const char test_cert_data[]
Definition: integrity.c:45
static void test_pe_checksum(void)
Definition: integrity.c:269
#define ok(value,...)
Definition: atltest.h:57
#define GetProcAddress(x, y)
Definition: compat.h:418
static const char test_cert_data_2[]
Definition: integrity.c:97
#define win_skip
Definition: test.h:150
#define file_size(inode)
Definition: reiserfs_fs.h:1869

◆ test_add_certificate()

static DWORD test_add_certificate ( const char cert_data,
int  len 
)
static

Definition at line 165 of file integrity.c.

166 {
167  HANDLE hFile;
169  DWORD cert_len;
170  DWORD index;
171  BOOL ret;
172 
174 
176  {
177  skip("Unable to open %s, skipping test\n", test_dll_path);
178  return ~0;
179  }
180 
181  cert_len = sizeof(WIN_CERTIFICATE) + len;
183 
184  if (!cert)
185  {
186  skip("Unable to allocate memory, skipping test\n");
188  return ~0;
189  }
190 
191  cert->dwLength = cert_len;
192  cert->wRevision = WIN_CERT_REVISION_1_0;
193  cert->wCertificateType = WIN_CERT_TYPE_PKCS_SIGNED_DATA;
194  CopyMemory(cert->bCertificate, cert_data, len);
195 
196  ret = pImageAddCertificate(hFile, cert, &index);
197  ok(ret, "Unable to add certificate to image, error %x\n", GetLastError());
198  trace("added cert index %d\n", index);
199 
202  return index;
203 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
struct _WIN_CERTIFICATE WIN_CERTIFICATE
#define WIN_CERT_REVISION_1_0
Definition: wintrust.h:623
#define FILE_SHARE_READ
Definition: compat.h:125
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
GLuint index
Definition: glext.h:6031
#define OPEN_EXISTING
Definition: compat.h:434
#define GetProcessHeap()
Definition: compat.h:403
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CopyMemory
Definition: winbase.h:1640
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define skip(...)
Definition: atltest.h:64
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by START_TEST().

◆ test_get_certificate()

static void test_get_certificate ( const char cert_data,
int  index 
)
static

Definition at line 205 of file integrity.c.

206 {
207  HANDLE hFile;
209  DWORD cert_len = 0;
210  DWORD err;
211  BOOL ret;
212 
214 
216  {
217  skip("Unable to open %s, skipping test\n", test_dll_path);
218  return;
219  }
220 
221  ret = pImageGetCertificateData(hFile, index, NULL, &cert_len);
222  err = GetLastError();
223 
224  ok ((ret == FALSE) && (err == ERROR_INSUFFICIENT_BUFFER), "ImageGetCertificateData gave unexpected result; ret=%d / err=%x\n", ret, err);
225 
227 
228  if (!cert)
229  {
230  skip("Unable to allocate memory, skipping test\n");
232  return;
233  }
234 
235  ret = pImageGetCertificateData(hFile, index, cert, &cert_len);
236  ok(ret, "Unable to retrieve certificate; err=%x\n", GetLastError());
237  ok(memcmp(cert->bCertificate, cert_data, cert_len - sizeof(WIN_CERTIFICATE)) == 0, "Certificate retrieved did not match original\n");
238 
241 }
#define CloseHandle
Definition: compat.h:406
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_READ
Definition: compat.h:125
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static BYTE cert[]
Definition: msg.c:1437
GLuint index
Definition: glext.h:6031
#define OPEN_EXISTING
Definition: compat.h:434
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define err(...)
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define skip(...)
Definition: atltest.h:64
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_pe_checksum()

static void test_pe_checksum ( void  )
static

Definition at line 269 of file integrity.c.

270 {
271  DWORD checksum_orig, checksum_new, checksum_correct;
275  char buffer[20];
276  BOOL ret_bool;
277 
278  if (!pCheckSumMappedFile)
279  {
280  win_skip("CheckSumMappedFile not supported, skipping tests\n");
281  return;
282  }
283 
284  SetLastError(0xdeadbeef);
285  ret = pCheckSumMappedFile(NULL, 0, &checksum_orig, &checksum_new);
286  ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
287  ok(((GetLastError() == ERROR_INVALID_PARAMETER)||(GetLastError() == 0xdeadbeef)),
288  "Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %x\n", GetLastError());
289 
290  SetLastError(0xdeadbeef);
291  ret = pCheckSumMappedFile((void *)0xdeadbeef, 0, &checksum_orig, &checksum_new);
292  ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
293  ok(((GetLastError() == ERROR_INVALID_PARAMETER)||(GetLastError() == 0xdeadbeef)),
294  "Expected 0xdeadbeef (XP) or ERROR_INVALID_PARAMETER (Vista+), got %x\n", GetLastError());
295 
296  /* basic checksum tests */
297  memset(buffer, 0x11, sizeof(buffer));
298  checksum_orig = checksum_new = 0xdeadbeef;
299  ret = pCheckSumMappedFile(buffer, sizeof(buffer), &checksum_orig, &checksum_new);
300  ok(ret == NULL, "Expected NULL, got %p\n", ret);
301  todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
302  todo_wine ok(checksum_new == 0xaabe, "Expected 0xaabe, got %x\n", checksum_new);
303 
304  memset(buffer, 0x22, sizeof(buffer));
305  checksum_orig = checksum_new = 0xdeadbeef;
306  ret = pCheckSumMappedFile(buffer, sizeof(buffer), &checksum_orig, &checksum_new);
307  ok(ret == NULL, "Expected NULL, got %p\n", ret);
308  todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
309  todo_wine ok(checksum_new == 0x5569, "Expected 0x5569, got %x\n", checksum_new);
310 
311  memset(buffer, 0x22, sizeof(buffer));
312  checksum_orig = checksum_new = 0xdeadbeef;
313  ret = pCheckSumMappedFile(buffer, 10, &checksum_orig, &checksum_new);
314  ok(ret == NULL, "Expected NULL, got %p\n", ret);
315  todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
316  todo_wine ok(checksum_new == 0xaab4, "Expected 0xaab4, got %x\n", checksum_new);
317 
318  memset(buffer, 0x22, sizeof(buffer));
319  checksum_orig = checksum_new = 0xdeadbeef;
320  ret = pCheckSumMappedFile(buffer, 11, &checksum_orig, &checksum_new);
321  ok(ret == NULL, "Expected NULL, got %p\n", ret);
322  todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
323  todo_wine ok(checksum_new == 0xaad7, "Expected 0xaad7, got %x\n", checksum_new);
324 
325  /* test checksum of PE module */
326  checksum_orig = checksum_new = 0xdeadbeef;
327  ret = pCheckSumMappedFile(test_pe_executable, sizeof(test_pe_executable),
328  &checksum_orig, &checksum_new);
329  ok((char *)ret == test_pe_executable + 0x80, "Expected %p, got %p\n", test_pe_executable + 0x80, ret);
330  ok(checksum_orig == 0xabcdef11, "Expected 0xabcdef11, got %x\n", checksum_orig);
331  ok(checksum_new == 0xaa4, "Expected 0xaa4, got %x\n", checksum_new);
332 
333  if (!pGetModuleInformation)
334  {
335  win_skip("GetModuleInformation not supported, skipping tests\n");
336  return;
337  }
338 
339  ret_bool = pGetModuleInformation(GetCurrentProcess(), GetModuleHandleA(NULL),
340  &modinfo, sizeof(modinfo));
341  ok(ret_bool, "GetModuleInformation failed, error: %x\n", GetLastError());
342 
343  SetLastError(0xdeadbeef);
344  checksum_orig = checksum_new = 0xdeadbeef;
345  ret = pCheckSumMappedFile(modinfo.lpBaseOfDll, modinfo.SizeOfImage, &checksum_orig, &checksum_new);
346  ok(ret != NULL, "Expected CheckSumMappedFile to succeed\n");
347  ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %x\n", GetLastError());
348  ok(checksum_orig != 0xdeadbeef, "Expected orig checksum != 0xdeadbeef\n");
349  ok(checksum_new != 0xdeadbeef, "Expected new checksum != 0xdeadbeef\n");
350 
351  SetLastError(0xdeadbeef);
352  checksum_orig = checksum_new = 0xdeadbeef;
353  ret = pCheckSumMappedFile((char *)modinfo.lpBaseOfDll + 100, modinfo.SizeOfImage - 100,
354  &checksum_orig, &checksum_new);
355  ok(!ret, "Expected CheckSumMappedFile to fail, got %p\n", ret);
356  ok(GetLastError() == 0xdeadbeef, "Expected err=0xdeadbeef, got %x\n", GetLastError());
357  todo_wine ok(checksum_orig == 0, "Expected 0, got %x\n", checksum_orig);
358  todo_wine ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
359 
360  nt_header = pRtlImageNtHeader( modinfo.lpBaseOfDll );
361  checksum_correct = nt_header->OptionalHeader.CheckSum;
362 
363  checksum_orig = checksum_new = 0xdeadbeef;
364  ret = pCheckSumMappedFile(modinfo.lpBaseOfDll, (char *)nt_header - (char *)modinfo.lpBaseOfDll,
365  &checksum_orig, &checksum_new);
366  ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
367  ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
368  ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
369 
370  checksum_orig = checksum_new = 0xdeadbeef;
371  ret = pCheckSumMappedFile(modinfo.lpBaseOfDll, sizeof(IMAGE_DOS_HEADER),
372  &checksum_orig, &checksum_new);
373  ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
374  ok((checksum_orig == 0) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
375  ok(checksum_new != 0 && checksum_new != 0xdeadbeef, "Got unexpected value %x\n", checksum_new);
376 
377  checksum_orig = checksum_new = 0xdeadbeef;
378  ret = pCheckSumMappedFile(modinfo.lpBaseOfDll, 0, &checksum_orig, &checksum_new);
379  ok(!ret || (ret == nt_header), "Expected CheckSumMappedFile to fail, got %p\n", ret);
380  ok((checksum_orig == 0xdeadbeef) || (checksum_orig == checksum_correct), "Expected %x, got %x\n", checksum_correct, checksum_orig);
381  ok((checksum_new == 0xdeadbeef) || (checksum_new != 0 && checksum_new != 0xdeadbeef), "Got unexpected value %x\n", checksum_new);
382 
383  checksum_orig = checksum_new = 0xdeadbeef;
384  ret = pCheckSumMappedFile((char *)modinfo.lpBaseOfDll + 1, 0,
385  &checksum_orig, &checksum_new);
386  ok(ret == NULL, "Expected NULL, got %p\n", ret);
387  ok((checksum_orig == 0) || (checksum_orig == 0xdeadbeef), "Expected 0, got %x\n", checksum_orig);
388  ok((checksum_new == 0) || (checksum_new == 0xdeadbeef), "Expected 0, got %x\n", checksum_new);
389 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static char test_pe_executable[]
Definition: integrity.c:99
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
PIMAGE_NT_HEADERS nt_header
Definition: pefixup.c:166
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
static HMODULE MODULEINFO * modinfo
Definition: module.c:32
int ret
#define todo_wine
Definition: test.h:163
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:150

Referenced by START_TEST().

◆ test_remove_certificate()

static void test_remove_certificate ( int  index)
static

Definition at line 243 of file integrity.c.

244 {
245  DWORD orig_count = 0, count = 0;
246  HANDLE hFile;
247  BOOL ret;
248 
250 
252  {
253  skip("Unable to open %s, skipping test\n", test_dll_path);
254  return;
255  }
256 
257  ret = pImageEnumerateCertificates(hFile, CERT_SECTION_TYPE_ANY, &orig_count, NULL, 0);
258  ok (ret, "Unable to enumerate certificates in file; err=%x\n", GetLastError());
259  ret = pImageRemoveCertificate(hFile, index);
260  ok (ret, "Unable to remove certificate from file; err=%x\n", GetLastError());
261 
262  /* Test to see if the certificate has actually been removed */
263  pImageEnumerateCertificates(hFile, CERT_SECTION_TYPE_ANY, &count, NULL, 0);
264  ok (count == orig_count - 1, "Certificate count mismatch; orig=%d new=%d\n", orig_count, count);
265 
267 }
#define CloseHandle
Definition: compat.h:406
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define CERT_SECTION_TYPE_ANY
Definition: imagehlp.h:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_READ
Definition: compat.h:125
static char test_dll_path[MAX_PATH]
Definition: integrity.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define OPEN_EXISTING
Definition: compat.h:434
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 35 of file integrity.c.

◆ hImageHlp

HMODULE hImageHlp
static

Definition at line 31 of file integrity.c.

Referenced by START_TEST().

◆ HMODULE

Definition at line 41 of file integrity.c.

◆ hNtdll

HMODULE hNtdll
static

Definition at line 31 of file integrity.c.

Referenced by START_TEST().

◆ hPsapi

HMODULE hPsapi
static

Definition at line 31 of file integrity.c.

Referenced by init_pointers(), and START_TEST().

◆ LPMODULEINFO

Definition at line 41 of file integrity.c.

◆ LPWIN_CERTIFICATE

Definition at line 34 of file integrity.c.

◆ PDWORD

Definition at line 34 of file integrity.c.

◆ test_cert_data

const char test_cert_data[]
static

Definition at line 45 of file integrity.c.

Referenced by START_TEST().

◆ test_cert_data_2

const char test_cert_data_2[] = {0xDE,0xAD,0xBE,0xEF,0x01,0x02,0x03}
static

Definition at line 97 of file integrity.c.

Referenced by START_TEST().

◆ test_dll_path

◆ test_pe_executable

char test_pe_executable[]
static
Initial value:
=
{
0x4d,0x5a,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0x00,
0x00,0xb8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x00,0x00,0x00,0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd,0x21,0xb8,0x01,
0x4c,0xcd,0x21,0x54,0x68,0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d,
0x20,0x63,0x61,0x6e,0x6e,0x6f,0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,0x20,
0x69,0x6e,0x20,0x44,0x4f,0x53,0x20,0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,
0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x45,0x00,0x00,0x4c,0x01,0x0f,
0x00,0xfd,0x38,0xc9,0x55,0x00,0x24,0x01,0x00,0xea,0x04,0x00,0x00,0xe0,0x00,
0x07,0x01,0x0b,0x01,0x02,0x18,0x00,0x1a,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,
0x06,0x00,0x00,0xe0,0x14,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x30,0x00,0x00,
0x00,0x00,0x40,0x00,0x00,0x10,0x00,0x00,0x00,0x02,0x00,0x00,0x04,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
0x01,0x00,0x00,0x04,0x00,0x00, 0x11,0xEF,0xCD,0xAB,0x03,0x00,
0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x00,0x00,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00
}

Definition at line 99 of file integrity.c.

Referenced by test_pe_checksum().

◆ WORD

Definition at line 35 of file integrity.c.