修正了 TPC 的一些错误,包括 Test 维护后 TPV 无法重新编译或重编译后越界的部分问题
This commit is contained in:
33
heapvalidate_test.c
Normal file
33
heapvalidate_test.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main() {
|
||||
HANDLE h = GetProcessHeap();
|
||||
printf("process heap handle: %p\n", h);
|
||||
fflush(stdout);
|
||||
|
||||
/* validate before any alloc */
|
||||
BOOL v0 = HeapValidate(h, 0, NULL);
|
||||
printf("before alloc: HeapValidate=%d\n", v0);
|
||||
fflush(stdout);
|
||||
|
||||
void *p = malloc(1024);
|
||||
BOOL v1 = HeapValidate(h, 0, NULL);
|
||||
printf("after malloc(1024): HeapValidate=%d (p=%p)\n", v1, p);
|
||||
fflush(stdout);
|
||||
|
||||
/* intentionally overflow */
|
||||
memset((char*)p + 1024, 0xCC, 64);
|
||||
|
||||
BOOL v2 = HeapValidate(h, 0, NULL);
|
||||
printf("after overflow: HeapValidate=%d\n", v2);
|
||||
fflush(stdout);
|
||||
|
||||
/* try to trigger detection via free */
|
||||
free(p);
|
||||
BOOL v3 = HeapValidate(h, 0, NULL);
|
||||
printf("after free: HeapValidate=%d\n", v3);
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user