Code:
BOOL IsDebuggerActive() {
typedef unsigned long(_fastcall *bNtQueryInformationProcess) (IN HANDLE, IN int32_t, OUT PVOID, IN ULONG, OUT PULONG);
bNtQueryInformationProcess NtQueryInfoProcess = nullptr;
HMODULE Nt = LoadLibrary(L"ntdll.dll");
NtQueryInfoProcess = (bNtQueryInformationProcess)GetProcAddress(Nt, "NtQueryInformationProcess");
PVOID ProcessInformation = NULL;
unsigned long Ret = NtQueryInfoProcess(GetCurrentProcess(), 0x7, &ProcessInformation, sizeof(ProcessInformation), nullptr);
if (Ret == 0x0 && ProcessInformation != 0) return TRUE;
else return FALSE;
}
Credits to McAfee (website) and Axion