记录一下
#include<stdlib.h>
#include<Windows.h>
#include<assert.h>
#include<stdio.h>
#include<string.h>
DWORD WINAPI CheckMemory(LPVOID Argv) {
char* ProcessBase = (char*)GetModuleHandle(nullptr);
char* CodeBuffer = 0;
char* CodeBase=0;
LONG CodeLen;
IMAGE_DOS_HEADER* Dos_Header = (IMAGE_DOS_HEADER*)ProcessBase;
IMAGE_SECTION_HEADER* SECTION_HEADER = (IMAGE_SECTION_HEADER*)(Dos_Header->e_lfanew + ProcessBase+sizeof(IMAGE_NT_HEADERS));
while (SECTION_HEADER->Characteristics)
{
if (!strcmp((char*)SECTION_HEADER->Name, ".text")) {
CodeBuffer = new char[SECTION_HEADER->Misc.VirtualSize];
CodeBase = SECTION_HEADER->VirtualAddress + ProcessBase;
CodeLen = SECTION_HEADER->Misc.VirtualSize;
memcpy(CodeBuffer, CodeBase, SECTION_HEADER->Misc.VirtualSize);
}
SECTION_HEADER++;
}
if (!CodeBase)
return 0;
unsigned long Number = 0;
while (true)
{
if (memcmp(CodeBuffer, CodeBase, CodeLen)) {
printf("I'm Anti-Debugger , Num:%ul!\n",Number++);
}
}
}
int main() {
CreateThread(NULL, NULL, CheckMemory, NULL, NULL, NULL);
while (true)
{
int a = 1;
}
int a = 5;
}