Softice Detection

Short, C code:

bool
IsSoftIceLoaded() {
HANDLE fh;
fh = CreateFileA("\\\\.\\NTICE", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (fh != INVALID_HANDLE_VALUE) {
CloseHandle(fh);
return (TRUE);
}
return (FALSE);
}

If you want to detect a regular debugger, then you can use IsDebuggerPresent(), it’s part of the PSDK.