Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ASLRTest.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <Windows.h>
- DWORD heapAdr=0x12345678;
- int _tmain(int argc, _TCHAR* argv[])
- {
- FILE* fpLog;
- BOOL newFile=FALSE;
- char stackBuf[512];
- static char staticHeapBuf[512];
- char* crtHeap;
- char* virtualAllocHeap;
- char* heapAllocHeap;
- char* heapAllocSecondHeap;
- HANDLE hHeap;
- fpLog=fopen("aslr.log", "r");
- if(!fpLog)
- newFile=TRUE;
- else
- fclose(fpLog);
- fpLog=fopen("aslr.log", "a");
- if(!fpLog)
- {
- printf("Error opening aslr.log for appending.\n");
- return 1;
- }
- if(newFile)
- fprintf(fpLog, "Stack;Static Heap;C Runtime Heap(malloc);Heap (VirtualAlloc);Heap (HeapAlloc default heap);Heap (HeapAlloc additional Heap)\n");
- crtHeap=(char*) malloc(4096);
- virtualAllocHeap=(char*) VirtualAlloc(NULL, 4096, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
- heapAllocHeap=(char*) HeapAlloc(GetProcessHeap(), 0, 4096);
- hHeap=HeapCreate(0, 4096, 32768);
- heapAllocSecondHeap=(char*) HeapAlloc(hHeap, 0, 4096);
- // Write adresses to log
- fprintf(fpLog, "0x%x;0x%x;0x%x;0x%x;0x%x;0x%x\n", &stackBuf[0], &staticHeapBuf[0], crtHeap, virtualAllocHeap, heapAllocHeap, heapAllocSecondHeap);
- fclose(fpLog);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement