//--------------------------------------------------------------------------- #include #include #include #include #pragma hdrstop //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma comment(lib, "psapi.lib") bool IsDebugger() { asm { mov eax, fs:[0x18] mov eax, dword ptr [eax + 0x30] mov al, byte ptr [eax + 0x02] and eax, 0xFF } return _EAX; } static std::string getFileName(const std::string &s) { char sep = '\\'; size_t i = s.rfind(sep, s.length( )); if (i != std::string::npos) { return(s.substr(i+1, s.length( ) - i)); } return(""); } typedef NTSTATUS (NTAPI *PFUNC)(HANDLE, INT, PVOID, ULONG, PULONG); bool IsIDE() { DWORD dwLength = 0x18; LPVOID pbuf = NULL; bool retValue = false; PFUNC pFunc; pFunc = (PFUNC)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryInformationProcess"); assert(pFunc); pbuf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength); assert(pbuf); NTSTATUS status = pFunc(GetCurrentProcess(), 0, pbuf, dwLength, &dwLength); assert(!status); HANDLE hProcess; DWORD Access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; hProcess = OpenProcess(Access, FALSE, *PDWORD((PBYTE)pbuf + 0x14)) ; char str[MAX_PATH]; GetProcessImageFileNameA(hProcess, str, sizeof(str)); if( strcmpi("bds.exe", getFileName(std::string(str)).c_str()) == 0) retValue = true; CloseHandle(hProcess); HeapFree(GetProcessHeap(), 0, pbuf); return retValue; }