本文整理汇总了C++中SetLastNtError函数的典型用法代码示例。如果您正苦于以下问题:C++ SetLastNtError函数的具体用法?C++ SetLastNtError怎么用?C++ SetLastNtError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetLastNtError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IntGetAtomName
ULONG FASTCALL
IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
{
NTSTATUS Status = STATUS_SUCCESS;
PTHREADINFO pti;
ULONG Size = nSize;
pti = PsGetCurrentThreadWin32Thread();
if (pti->rpdesk == NULL)
{
SetLastNtError(Status);
return 0;
}
Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size);
if (Size < nSize)
*(lpBuffer + Size) = 0;
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return 0;
}
return Size;
}
示例2: NtUserSBGetParms
BOOL
APIENTRY
NtUserSBGetParms(
HWND hWnd,
int fnBar,
PSBDATA pSBData,
LPSCROLLINFO lpsi)
{
NTSTATUS Status;
PWND Window;
SCROLLINFO psi;
DWORD sz;
BOOL Ret;
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserGetScrollInfo\n");
UserEnterExclusive();
Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT));
if(!NT_SUCCESS(Status) ||
!((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos))))
{
SetLastNtError(Status);
RETURN(FALSE);
}
sz = psi.cbSize;
Status = MmCopyFromCaller(&psi, lpsi, sz);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
}
if(!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
}
UserRefObjectCo(Window, &Ref);
Ret = co_IntGetScrollInfo(Window, fnBar, &psi);
UserDerefObjectCo(Window);
Status = MmCopyToCaller(lpsi, &psi, sz);
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN( FALSE);
}
RETURN( Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollInfo, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
示例3: NtGdiGetAppClipBox
INT APIENTRY
NtGdiGetAppClipBox(HDC hDC, PRECTL rc)
{
INT Ret;
NTSTATUS Status = STATUS_SUCCESS;
RECTL Saferect;
Ret = GdiGetClipBox(hDC, &Saferect);
_SEH2_TRY
{
ProbeForWrite(rc,
sizeof(RECT),
1);
*rc = Saferect;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return ERROR;
}
return Ret;
}
示例4: NtUserOpenWindowStation
HWINSTA APIENTRY
NtUserOpenWindowStation(
POBJECT_ATTRIBUTES ObjectAttributes,
ACCESS_MASK dwDesiredAccess)
{
HWINSTA hwinsta;
NTSTATUS Status;
Status = ObOpenObjectByName(ObjectAttributes,
ExWindowStationObjectType,
UserMode,
NULL,
dwDesiredAccess,
NULL,
(PVOID*)&hwinsta);
if (!NT_SUCCESS(Status))
{
ERR("NtUserOpenWindowStation failed\n");
SetLastNtError(Status);
return 0;
}
TRACE("Opened window station %wZ with handle %p\n", ObjectAttributes->ObjectName, hwinsta);
return hwinsta;
}
示例5: NtGdiCreateColorSpace
HANDLE
APIENTRY
NtGdiCreateColorSpace(
IN PLOGCOLORSPACEEXW pLogColorSpace)
{
LOGCOLORSPACEEXW Safelcs;
NTSTATUS Status = STATUS_SUCCESS;
_SEH2_TRY
{
ProbeForRead( pLogColorSpace,
sizeof(LOGCOLORSPACEEXW),
1);
RtlCopyMemory(&Safelcs, pLogColorSpace, sizeof(LOGCOLORSPACEEXW));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return NULL;
}
return IntGdiCreateColorSpace(&Safelcs);
}
示例6: IntValidateWindowStationHandle
NTSTATUS FASTCALL
IntValidateWindowStationHandle(
HWINSTA WindowStation,
KPROCESSOR_MODE AccessMode,
ACCESS_MASK DesiredAccess,
PWINSTATION_OBJECT *Object,
POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
{
NTSTATUS Status;
if (WindowStation == NULL)
{
ERR("Invalid window station handle\n");
EngSetLastError(ERROR_INVALID_HANDLE);
return STATUS_INVALID_HANDLE;
}
Status = ObReferenceObjectByHandle(WindowStation,
DesiredAccess,
ExWindowStationObjectType,
AccessMode,
(PVOID*)Object,
pObjectHandleInfo);
if (!NT_SUCCESS(Status))
SetLastNtError(Status);
return Status;
}
示例7: NtUserLockWindowStation
BOOL APIENTRY
NtUserLockWindowStation(HWINSTA hWindowStation)
{
PWINSTATION_OBJECT Object;
NTSTATUS Status;
TRACE("About to set process window station with handle (%p)\n",
hWindowStation);
if (gpidLogon != PsGetCurrentProcessId())
{
ERR("Unauthorized process attempted to lock the window station!\n");
EngSetLastError(ERROR_ACCESS_DENIED);
return FALSE;
}
Status = IntValidateWindowStationHandle(hWindowStation,
UserMode,
0,
&Object,
0);
if (!NT_SUCCESS(Status))
{
TRACE("Validation of window station handle (%p) failed\n",
hWindowStation);
SetLastNtError(Status);
return FALSE;
}
Object->Flags |= WSS_LOCKED;
ObDereferenceObject(Object);
return TRUE;
}
示例8: NtUserSetClipboardData
HANDLE APIENTRY
NtUserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA pUnsafeScd)
{
SETCLIPBDATA scd;
HANDLE hRet;
TRACE("NtUserSetClipboardData(%x %p %p)\n", fmt, hData, pUnsafeScd);
_SEH2_TRY
{
ProbeForRead(pUnsafeScd, sizeof(*pUnsafeScd), 1);
RtlCopyMemory(&scd, pUnsafeScd, sizeof(scd));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(return NULL;)
}
_SEH2_END
UserEnterExclusive();
/* Call internal function */
hRet = UserSetClipboardData(fmt, hData, &scd);
UserLeave();
return hRet;
}
示例9: NtUserGetKeyboardLayoutName
/*
* NtUserGetKeyboardLayoutName
*
* Returns KLID of current thread keyboard layout
*/
BOOL
APIENTRY
NtUserGetKeyboardLayoutName(
LPWSTR pwszName)
{
BOOL bRet = FALSE;
PKL pKl;
PTHREADINFO pti;
UserEnterShared();
pti = PsGetCurrentThreadWin32Thread();
pKl = pti->KeyboardLayout;
if (!pKl)
goto cleanup;
_SEH2_TRY
{
ProbeForWrite(pwszName, KL_NAMELENGTH*sizeof(WCHAR), 1);
wcscpy(pwszName, pKl->spkf->awchKF);
bRet = TRUE;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
}
_SEH2_END;
cleanup:
UserLeave();
return bRet;
}
示例10: NtUserGetCaretPos
BOOL
APIENTRY
NtUserGetCaretPos(
LPPOINT lpPoint)
{
PTHREADINFO pti;
PUSER_MESSAGE_QUEUE ThreadQueue;
NTSTATUS Status;
DECLARE_RETURN(BOOL);
TRACE("Enter NtUserGetCaretPos\n");
UserEnterShared();
pti = PsGetCurrentThreadWin32Thread();
ThreadQueue = pti->MessageQueue;
Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
RETURN(FALSE);
}
RETURN(TRUE);
CLEANUP:
TRACE("Leave NtUserGetCaretPos, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
示例11: NtUserGetScrollBarInfo
BOOL
APIENTRY
NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi)
{
NTSTATUS Status;
SCROLLBARINFO sbi;
PWND Window;
BOOL Ret;
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
TRACE("Enter NtUserGetScrollBarInfo\n");
UserEnterExclusive();
Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO));
if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO)))
{
SetLastNtError(Status);
RETURN(FALSE);
}
if(!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
}
UserRefObjectCo(Window, &Ref);
Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi);
UserDerefObjectCo(Window);
Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO));
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
Ret = FALSE;
}
RETURN( Ret);
CLEANUP:
TRACE("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
示例12: NtUserCopyAcceleratorTable
ULONG
APIENTRY
NtUserCopyAcceleratorTable(
HACCEL hAccel,
LPACCEL Entries,
ULONG EntriesCount)
{
PACCELERATOR_TABLE Accel;
ULONG Ret;
DECLARE_RETURN(int);
TRACE("Enter NtUserCopyAcceleratorTable\n");
UserEnterShared();
Accel = UserGetAccelObject(hAccel);
if (!Accel)
{
RETURN(0);
}
/* If Entries is NULL return table size */
if (!Entries)
{
RETURN(Accel->Count);
}
/* Don't overrun */
if (Accel->Count < EntriesCount)
EntriesCount = Accel->Count;
Ret = 0;
_SEH2_TRY
{
ProbeForWrite(Entries, EntriesCount*sizeof(Entries[0]), 4);
for (Ret = 0; Ret < EntriesCount; Ret++)
{
Entries[Ret].fVirt = Accel->Table[Ret].fVirt;
Entries[Ret].key = Accel->Table[Ret].key;
Entries[Ret].cmd = Accel->Table[Ret].cmd;
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
Ret = 0;
}
_SEH2_END;
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserCopyAcceleratorTable, ret=%i\n", _ret_);
UserLeave();
END_CLEANUP;
}
示例13: NtGdiGetDeviceGammaRamp
BOOL
APIENTRY
NtGdiGetDeviceGammaRamp(HDC hDC,
LPVOID Ramp)
{
BOOL Ret;
PDC dc;
NTSTATUS Status = STATUS_SUCCESS;
PGAMMARAMP SafeRamp;
if (!Ramp) return FALSE;
dc = DC_LockDc(hDC);
if (!dc)
{
EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
SafeRamp = ExAllocatePoolWithTag(PagedPool, sizeof(GAMMARAMP), GDITAG_ICM);
if (!SafeRamp)
{
DC_UnlockDc(dc);
EngSetLastError(STATUS_NO_MEMORY);
return FALSE;
}
Ret = IntGetDeviceGammaRamp((HDEV)dc->ppdev, SafeRamp);
if (!Ret) return Ret;
_SEH2_TRY
{
ProbeForWrite( Ramp,
sizeof(PVOID),
1);
RtlCopyMemory( Ramp,
SafeRamp,
sizeof(GAMMARAMP));
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
DC_UnlockDc(dc);
ExFreePoolWithTag(SafeRamp, GDITAG_ICM);
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
}
return Ret;
}
示例14: NtUserGetKeyboardLayoutList
/*
* NtUserGetKeyboardLayoutList
*
* Returns list of loaded keyboard layouts in system
*/
UINT
APIENTRY
NtUserGetKeyboardLayoutList(
ULONG nBuff,
HKL *pHklBuff)
{
UINT uRet = 0;
PKL pKl;
if (!pHklBuff)
nBuff = 0;
UserEnterShared();
if (!gspklBaseLayout)
{
UserLeave();
return 0;
}
pKl = gspklBaseLayout;
if (nBuff == 0)
{
do
{
uRet++;
pKl = pKl->pklNext;
} while (pKl != gspklBaseLayout);
}
else
{
_SEH2_TRY
{
ProbeForWrite(pHklBuff, nBuff*sizeof(HKL), 4);
while (uRet < nBuff)
{
pHklBuff[uRet] = pKl->hkl;
uRet++;
pKl = pKl->pklNext;
if (pKl == gspklBaseLayout)
break;
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
uRet = 0;
}
_SEH2_END;
}
UserLeave();
return uRet;
}
示例15: NtGdiOpenDCW
HDC
APIENTRY
NtGdiOpenDCW(
PUNICODE_STRING pustrDevice,
DEVMODEW *pdmInit,
PUNICODE_STRING pustrLogAddr,
ULONG iType,
BOOL bDisplay,
HANDLE hspool,
VOID *pDriverInfo2,
VOID *pUMdhpdev)
{
UNICODE_STRING ustrDevice;
WCHAR awcDevice[CCHDEVICENAME];
DEVMODEW dmInit;
PVOID dhpdev;
HDC hdc;
/* Only if a devicename is given, we need any data */
if (pustrDevice)
{
/* Initialize destination string */
RtlInitEmptyUnicodeString(&ustrDevice, awcDevice, sizeof(awcDevice));
_SEH2_TRY
{
/* Probe the UNICODE_STRING and the buffer */
ProbeForRead(pustrDevice, sizeof(UNICODE_STRING), 1);
ProbeForRead(pustrDevice->Buffer, pustrDevice->Length, 1);
/* Copy the string */
RtlCopyUnicodeString(&ustrDevice, pustrDevice);
if (pdmInit)
{
/* FIXME: could be larger */
ProbeForRead(pdmInit, sizeof(DEVMODEW), 1);
RtlCopyMemory(&dmInit, pdmInit, sizeof(DEVMODEW));
}
if (pUMdhpdev)
{
ProbeForWrite(pUMdhpdev, sizeof(HANDLE), 1);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
SetLastNtError(_SEH2_GetExceptionCode());
_SEH2_YIELD(return NULL);
}
_SEH2_END
}
else
{