#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
typedef enum _PROCESS_INFORMATION_CLASS {
ProcessBasicInformation = 0,
ProcessQuotaLimits,
ProcessIoCounters,
ProcessVmCounters,
ProcessTimes,
ProcessBasePriority,
ProcessRaisePriority,
ProcessDebugPort,
ProcessExceptionPort,
ProcessAccessToken,
ProcessLdtInformation,
ProcessLdtSize,
ProcessDefaultHardErrorMode,
ProcessIoPortHandlers,
ProcessPooledUsageAndLimits,
ProcessWorkingSetWatch,
ProcessUserModeIOPL,
ProcessEnableAlignmentFaultFixup,
ProcessPriorityClass,
ProcessWx86Information,
ProcessHandleCount,
ProcessAffinityMask,
ProcessPriorityBoost,
MaxProcessInfoClass,
ProcessBreakOnTermination = 0x1D
} PROCESS_INFORMATION_CLASS, *PPROCESS_INFORMATION_CLASS;
typedef NTSTATUS (WINAPI *t_NtSetInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
BOOL setProcessCritical(HANDLE hProcess, ULONG newValue)
{
t_NtSetInformationProcess _NtSetInformationProcess = 0;
_NtSetInformationProcess = (t_NtSetInformationProcess)GetProcAddress(GetModul eHandleA("ntdll.dll"), "NtSetInformationProcess");
if (_NtSetInformationProcess)
{
if (NT_SUCCESS(_NtSetInformationProcess(hProcess, ProcessBreakOnTermination, &newValue, sizeof(ULONG))))
{
return TRUE;
}
}
return FALSE;
}
BOOL setCurrentProcessCritical(ULONG newValue)
{
return setProcessCritical(GetCurrentProcess(), newValue);
}[/CODE]
setCurrentProcessCritical(TRUE);
Man braucht Debug-Rechte: SE_DEBUG_NAME
Nicht vergessen:
[CODE]LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_QUERYENDSESSION:
{
MessageBoxA(0,"WM_QUERYENDSESSION","",0);
return 0;
}
case WM_ENDSESSION:
{
MessageBoxA(0,"WM_ENDSESSION","",0);
return 0;
}
}
return DefWindowProcW(hWnd, message, wParam, lParam);
}