_cfg_path.printf(TEXT("%s\\ros-explorer-cfg.xml"), _cfg_dir.c_str());
if (!_cfg.read_file(_cfg_path)) {
- //if (_cfg._last_error != XML_ERROR_NO_ELEMENTS)
- MessageBox(_hwndDesktop, _cfg._errors.str(),
- TEXT("ROS Explorer - reading user settings"), MB_OK);
+ if (!_cfg._errors.empty())
+ MessageBox(_hwndDesktop, _cfg._errors.str(),
+ TEXT("ROS Explorer - reading user settings"), MB_OK);
_cfg.read_file(TEXT("explorer-cfg-template.xml"));
}
if (_tcsstr(ext_options,TEXT("-console"))) {
AllocConsole();
- _dup2(_open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_RDONLY), 0);
- _dup2(_open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), 0), 1);
- _dup2(_open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE), 0), 2);
+ _dup2(_open_osfhandle((intptr_t)GetStdHandle(STD_INPUT_HANDLE), _O_RDONLY), 0);
+ _dup2(_open_osfhandle((intptr_t)GetStdHandle(STD_OUTPUT_HANDLE), 0), 1);
+ _dup2(_open_osfhandle((intptr_t)GetStdHandle(STD_ERROR_HANDLE), 0), 2);
g_Globals._log = _fdopen(1, "w");
setvbuf(g_Globals._log, 0, _IONBF, 0);
if (use_gdb_stub) {
LOG(TEXT("waiting for debugger connection...\n"));
+#ifdef __i386__
initialize_gdb_stub();
+#endif
}
g_Globals.init(hInstance);
{
HDC hDC = GetDC(NULL);
#ifndef _NO_REBAR
- //static WCHAR Title1[] = TEXT("Toolbar");
- static WCHAR Title2[] = TEXT("Address :");
+ //static TCHAR Title1[] = TEXT("Toolbar");
+ static TCHAR Title2[] = TEXT("Address :");
#endif
if (hDC)
HINSTANCE hinst = ShellExecute(_hwnd, NULL/*operation*/, dlg.cmd/*file*/, NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow);
- if ((int)hinst <= 32)
+ if ((INT_PTR)hinst <= 32)
display_error(_hwnd, GetLastError());
}
break;}
HiddenWindow hide(_hsidebar);
WindowCanvas canvas(_hwnd);
- TreeView_DeleteAllItems(_hsidebar);
+ (void)TreeView_DeleteAllItems(_hsidebar);
g_Globals._icon_cache.get_icon(ICID_FAVORITES).add_to_imagelist(_himl, canvas);
g_Globals._icon_cache.get_icon(ICID_BOOKMARK).add_to_imagelist(_himl, canvas);
g_Globals._favorites.fill_tree(_hsidebar, hitem_bookmarks, _himl, canvas);
- TreeView_Expand(_hsidebar, hitem_bookmarks, TVE_EXPAND);
+ (void)TreeView_Expand(_hsidebar, hitem_bookmarks, TVE_EXPAND);
}
// Max number of entries = MaxPageNum >> 10
// FIXME: This is a number to describe ALL physical memory
// and windows doesn't expect ALL memory mapped...
- NumPageTables = (GetSystemMemorySize() >> MM_PAGE_SHIFT) >> 10;
+ NumPageTables = TotalPagesInLookupTable >> 10;
DPRINTM(DPRINT_WINDOWS, "NumPageTables = %d\n", NumPageTables);
// Allocate memory block for all these things:
// PDE, HAL mapping page table, physical mapping, kernel mapping
- TotalSize = (1+1+NumPageTables*2)*MM_PAGE_SIZE;
+ TotalSize = (1 + 1 + NumPageTables * 2) * MM_PAGE_SIZE;
// PDE+HAL+KernelPTEs == MemoryData
Buffer = MmAllocateMemoryWithType(TotalSize, LoaderMemoryData);
BOOLEAN
MempSetupPaging(IN ULONG StartPage,
- IN ULONG NumberOfPages)
+ IN ULONG NumberOfPages)
{
PHARDWARE_PTE PhysicalPT;
PHARDWARE_PTE KernelPT;
//
// Now actually set up the page tables for identity mapping
//
- for (Page=StartPage; Page < StartPage+NumberOfPages; Page++)
+ for (Page = StartPage; Page < StartPage + NumberOfPages; Page++)
{
Entry = Page >> 10;
KernelPT = (PHARDWARE_PTE)(PDE[Entry+(KSEG0_BASE >> 22)].PageFrameNumber << MM_PAGE_SHIFT);
}
- if (Page == 0)
- {
- PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
- PhysicalPT[Page & 0x3ff].Valid = 0;
- PhysicalPT[Page & 0x3ff].Write = 0;
-
- KernelPT[Page & 0x3ff].PageFrameNumber = Page;
- KernelPT[Page & 0x3ff].Valid = 0;
- KernelPT[Page & 0x3ff].Write = 0;
- }
- else
- {
- PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
- PhysicalPT[Page & 0x3ff].Valid = 1;
- PhysicalPT[Page & 0x3ff].Write = 1;
+ PhysicalPT[Page & 0x3ff].PageFrameNumber = Page;
+ PhysicalPT[Page & 0x3ff].Valid = (Page != 0);
+ PhysicalPT[Page & 0x3ff].Write = (Page != 0);
- KernelPT[Page & 0x3ff].PageFrameNumber = Page;
- KernelPT[Page & 0x3ff].Valid = 1;
- KernelPT[Page & 0x3ff].Write = 1;
- }
+ KernelPT[Page & 0x3ff].PageFrameNumber = Page;
+ KernelPT[Page & 0x3ff].Valid = (Page != 0);
+ KernelPT[Page & 0x3ff].Write = (Page != 0);
}
return TRUE;
*/
}
-#if DBG
VOID
MempDump()
{
DPRINTM(DPRINT_WINDOWS, "\n");
}
}
-#endif
FASTCALL
DeleteRegion( HRGN hRgn )
{
- #if 0
PRGN_ATTR Rgn_Attr;
if ((GdiGetHandleUserData((HGDIOBJ) hRgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr)) &&
}
}
}
- #endif
return NtGdiDeleteObjectApp((HGDIOBJ) hRgn);
}
HRGN hSrc2,
INT CombineMode)
{
- #if 0
PRGN_ATTR pRgn_Attr_Dest = NULL;
PRGN_ATTR pRgn_Attr_Src1 = NULL;
PRGN_ATTR pRgn_Attr_Src2 = NULL;
!pRgn_Attr_Dest ||
!pRgn_Attr_Src1 ||
pRgn_Attr_Src1->Flags > SIMPLEREGION )
- #endif
return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
- #if 0
+
/* Handle COPY and use only src1. */
if ( CombineMode == RGN_COPY )
{
DPRINT1("RGN_COPY was handled! CombineMode %d\n",CombineMode);
return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
}
+ /* Now handle DIFF. */
+ if ( pRgn_Attr_Src1->Flags == NULLREGION )
+ {
+ if (SetRectRgn( hDest, 0, 0, 0, 0))
+ return NULLREGION;
+ goto ERROR_Exit;
+ }
- if ( pRgn_Attr_Src1->Flags != NULLREGION &&
- pRgn_Attr_Src2->Flags != NULLREGION )
+ if ( pRgn_Attr_Src2->Flags != NULLREGION )
{
Complexity = ComplexityFromRects( &pRgn_Attr_Src1->Rect, &pRgn_Attr_Src2->Rect);
- /* If same or overlapping and norm just go K. */
- if (Complexity == SAME_RGN || Complexity == OVERLAPPING_RGN)
- return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
+
+ if ( Complexity != DIFF_RGN )
+ {
+ if ( Complexity != INVERTED_RGN)
+ /* If same or overlapping and norm just go K. */
+ return NtGdiCombineRgn(hDest, hSrc1, hSrc2, CombineMode);
+
+ if (SetRectRgn( hDest, 0, 0, 0, 0))
+ return NULLREGION;
+ goto ERROR_Exit;
+ }
}
- /* Just NULL rgn. */
- if (SetRectRgn( hDest, 0, 0, 0, 0))
- return NULLREGION;
- goto ERROR_Exit;
}
else /* Handle OR or XOR. */
{
/* Even on error the flag is set dirty and force server side to redraw. */
pRgn_Attr_Dest->AttrFlags |= ATTR_RGN_DIRTY;
return ERROR;
- #endif
}
/*
WINAPI
CreatePolygonRgn( const POINT * lppt, int cPoints, int fnPolyFillMode)
{
- return (HRGN) NtGdiPolyPolyDraw( (HDC) fnPolyFillMode, (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
+ return (HRGN) NtGdiPolyPolyDraw(ULongToHandle(fnPolyFillMode), (PPOINT) lppt, (PULONG) &cPoints, 1, GdiPolyPolyRgn);
}
/*
GetRgnBox(HRGN hrgn,
LPRECT prcOut)
{
- #if 0
PRGN_ATTR Rgn_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr))
- #endif
return NtGdiGetRgnBox(hrgn, prcOut);
- #if 0
+
if (Rgn_Attr->Flags == NULLREGION)
{
prcOut->left = 0;
RtlCopyMemory( prcOut, &Rgn_Attr->Rect, sizeof(RECT));
}
return Rgn_Attr->Flags;
- #endif
}
/*
int nXOffset,
int nYOffset)
{
- #if 0
PRGN_ATTR pRgn_Attr;
int nLeftRect, nTopRect, nRightRect, nBottomRect;
if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr))
- #endif
return NtGdiOffsetRgn(hrgn,nXOffset,nYOffset);
- #if 0
+
if ( pRgn_Attr->Flags == NULLREGION)
return pRgn_Attr->Flags;
}
}
return pRgn_Attr->Flags;
- #endif
}
/*
int x,
int y)
{
- #if 0
PRGN_ATTR pRgn_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr))
- #endif
return NtGdiPtInRegion(hrgn,x,y);
- #if 0
+
if ( pRgn_Attr->Flags == NULLREGION)
return FALSE;
return NtGdiPtInRegion(hrgn,x,y);
return INRECT( pRgn_Attr->Rect, x, y);
- #endif
}
/*
RectInRegion(HRGN hrgn,
LPCRECT prcl)
{
- #if 0
PRGN_ATTR pRgn_Attr;
RECTL rc;
if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr))
- #endif
return NtGdiRectInRegion(hrgn, (LPRECT) prcl);
- #if 0
+
if ( pRgn_Attr->Flags == NULLREGION)
return FALSE;
return TRUE;
return FALSE;
- #endif
}
/*
int nRightRect,
int nBottomRect)
{
- #if 0
PRGN_ATTR Rgn_Attr;
if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &Rgn_Attr))
- #endif
return NtGdiSetRectRgn(hrgn, nLeftRect, nTopRect, nRightRect, nBottomRect);
- #if 0
+
if ((nLeftRect == nRightRect) || (nTopRect == nBottomRect))
{
Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY;
Rgn_Attr->AttrFlags |= ATTR_RGN_DIRTY ;
Rgn_Attr->Flags = SIMPLEREGION;
return TRUE;
- #endif
}
/*
if(ProcThrdInfo != NULL)
{
NtFreeVirtualMemory(NtCurrentProcess(),
- ProcThrdInfo,
+ &ProcThrdInfo,
&ProcThrdInfoSize,
MEM_RELEASE);
}
HANDLE hSection;
PTH32SNAPSHOT Snapshot;
ULONG_PTR DataOffset;
- ULONG ViewSize, i;
- ULONG nProcesses = 0, nThreads = 0, nHeaps = 0, nModules = 0;
+ SIZE_T ViewSize;
+ ULONG i, nProcesses = 0, nThreads = 0, nHeaps = 0, nModules = 0;
ULONG RequiredSnapshotSize = sizeof(TH32SNAPSHOT);
PRTL_PROCESS_HEAPS hi = NULL;
PRTL_PROCESS_MODULES mi = NULL;
ProcessListEntry->dwSize = sizeof(PROCESSENTRY32W);
ProcessListEntry->cntUsage = 0; /* no longer used */
- ProcessListEntry->th32ProcessID = (ULONG)ProcessInfo->UniqueProcessId;
+ ProcessListEntry->th32ProcessID = (ULONG_PTR)ProcessInfo->UniqueProcessId;
ProcessListEntry->th32DefaultHeapID = 0; /* no longer used */
ProcessListEntry->th32ModuleID = 0; /* no longer used */
ProcessListEntry->cntThreads = ProcessInfo->NumberOfThreads;
- ProcessListEntry->th32ParentProcessID = (ULONG)ProcessInfo->InheritedFromUniqueProcessId;
+ ProcessListEntry->th32ParentProcessID = (ULONG_PTR)ProcessInfo->InheritedFromUniqueProcessId;
ProcessListEntry->pcPriClassBase = ProcessInfo->BasePriority;
ProcessListEntry->dwFlags = 0; /* no longer used */
if(ProcessInfo->ImageName.Buffer != NULL)
{
ThreadListEntry->dwSize = sizeof(THREADENTRY32);
ThreadListEntry->cntUsage = 0; /* no longer used */
- ThreadListEntry->th32ThreadID = (ULONG)ThreadInfo->ClientId.UniqueThread;
- ThreadListEntry->th32OwnerProcessID = (ULONG)ThreadInfo->ClientId.UniqueProcess;
+ ThreadListEntry->th32ThreadID = (ULONG_PTR)ThreadInfo->ClientId.UniqueThread;
+ ThreadListEntry->th32OwnerProcessID = (ULONG_PTR)ThreadInfo->ClientId.UniqueProcess;
ThreadListEntry->tpBasePri = ThreadInfo->BasePriority;
ThreadListEntry->tpDeltaPri = 0; /* no longer used */
ThreadListEntry->dwFlags = 0; /* no longer used */
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lphl, sizeof(HEAPLIST32));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lphl, sizeof(HEAPLIST32));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lpme, sizeof(MODULEENTRY32W));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lpme, sizeof(MODULEENTRY32W));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lppe, sizeof(PROCESSENTRY32W));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lppe, sizeof(PROCESSENTRY32W));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lpte, sizeof(THREADENTRY32));
{
PTH32SNAPSHOT Snapshot;
LARGE_INTEGER SOffset;
- ULONG ViewSize;
+ SIZE_T ViewSize;
NTSTATUS Status;
CHECK_PARAM_SIZE(lpte, sizeof(THREADENTRY32));
BOOL
WINAPI
Toolhelp32ReadProcessMemory(DWORD th32ProcessID, LPCVOID lpBaseAddress,
- LPVOID lpBuffer, DWORD cbRead, LPDWORD lpNumberOfBytesRead)
+ LPVOID lpBuffer, SIZE_T cbRead, SIZE_T* lpNumberOfBytesRead)
{
HANDLE hProcess = OpenProcess(PROCESS_VM_READ, FALSE, th32ProcessID);
if(hProcess != NULL)
/*
* @implemented
*/
- BOOL WINAPI
- GetProcessAffinityMask (HANDLE hProcess,
- PDWORD_PTR lpProcessAffinityMask,
- PDWORD_PTR lpSystemAffinityMask)
+ BOOL
+ WINAPI
+ GetProcessAffinityMask(HANDLE hProcess,
- LPDWORD lpProcessAffinityMask,
- LPDWORD lpSystemAffinityMask)
++ PDWORD_PTR lpProcessAffinityMask,
++ PDWORD_PTR lpSystemAffinityMask)
{
- PROCESS_BASIC_INFORMATION ProcessInfo;
- SYSTEM_BASIC_INFORMATION SystemInfo;
- NTSTATUS Status;
+ PROCESS_BASIC_INFORMATION ProcessInfo;
+ SYSTEM_BASIC_INFORMATION SystemInfo;
+ NTSTATUS Status;
- Status = NtQuerySystemInformation(SystemBasicInformation,
- &SystemInfo,
- sizeof(SystemInfo),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQuerySystemInformation(SystemBasicInformation,
+ &SystemInfo,
+ sizeof(SystemInfo),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus (Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- Status = NtQueryInformationProcess (hProcess,
- ProcessBasicInformation,
- (PVOID)&ProcessInfo,
- sizeof(PROCESS_BASIC_INFORMATION),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessBasicInformation,
+ (PVOID)&ProcessInfo,
+ sizeof(PROCESS_BASIC_INFORMATION),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus (Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- *lpProcessAffinityMask = (DWORD)ProcessInfo.AffinityMask;
- *lpSystemAffinityMask = (DWORD)SystemInfo.ActiveProcessorsAffinityMask;
+ *lpProcessAffinityMask = (DWORD)ProcessInfo.AffinityMask;
+ *lpSystemAffinityMask = (DWORD)SystemInfo.ActiveProcessorsAffinityMask;
- return TRUE;
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
- SetProcessAffinityMask (HANDLE hProcess,
- DWORD_PTR dwProcessAffinityMask)
+ BOOL
+ WINAPI
+ SetProcessAffinityMask(HANDLE hProcess,
- DWORD dwProcessAffinityMask)
++ DWORD_PTR dwProcessAffinityMask)
{
- NTSTATUS Status;
+ NTSTATUS Status;
- Status = NtSetInformationProcess (hProcess,
- ProcessAffinityMask,
- (PVOID)&dwProcessAffinityMask,
- sizeof(DWORD));
- if (!NT_SUCCESS(Status))
+ Status = NtSetInformationProcess(hProcess,
+ ProcessAffinityMask,
+ (PVOID)&dwProcessAffinityMask,
+ sizeof(DWORD));
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus (Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
- GetProcessShutdownParameters (LPDWORD lpdwLevel,
- LPDWORD lpdwFlags)
+ BOOL
+ WINAPI
+ GetProcessShutdownParameters(LPDWORD lpdwLevel,
+ LPDWORD lpdwFlags)
{
- CSR_API_MESSAGE CsrRequest;
- ULONG Request;
- NTSTATUS Status;
+ CSR_API_MESSAGE CsrRequest;
+ ULONG Request;
+ NTSTATUS Status;
- Request = GET_SHUTDOWN_PARAMETERS;
- Status = CsrClientCallServer(&CsrRequest,
- NULL,
- MAKE_CSR_API(Request, CSR_NATIVE),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
+ Request = GET_SHUTDOWN_PARAMETERS;
+ Status = CsrClientCallServer(&CsrRequest,
+ NULL,
+ MAKE_CSR_API(Request, CSR_NATIVE),
+ sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{
- SetLastErrorByStatus (Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- *lpdwLevel = CsrRequest.Data.GetShutdownParametersRequest.Level;
- *lpdwFlags = CsrRequest.Data.GetShutdownParametersRequest.Flags;
+ *lpdwLevel = CsrRequest.Data.GetShutdownParametersRequest.Level;
+ *lpdwFlags = CsrRequest.Data.GetShutdownParametersRequest.Flags;
- return(TRUE);
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
- SetProcessShutdownParameters (DWORD dwLevel,
- DWORD dwFlags)
+ BOOL
+ WINAPI
+ SetProcessShutdownParameters(DWORD dwLevel,
+ DWORD dwFlags)
{
- CSR_API_MESSAGE CsrRequest;
- ULONG Request;
- NTSTATUS Status;
+ CSR_API_MESSAGE CsrRequest;
+ ULONG Request;
+ NTSTATUS Status;
- CsrRequest.Data.SetShutdownParametersRequest.Level = dwLevel;
- CsrRequest.Data.SetShutdownParametersRequest.Flags = dwFlags;
+ CsrRequest.Data.SetShutdownParametersRequest.Level = dwLevel;
+ CsrRequest.Data.SetShutdownParametersRequest.Flags = dwFlags;
- Request = SET_SHUTDOWN_PARAMETERS;
- Status = CsrClientCallServer(&CsrRequest,
- NULL,
- MAKE_CSR_API(Request, CSR_NATIVE),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
+ Request = SET_SHUTDOWN_PARAMETERS;
+ Status = CsrClientCallServer(&CsrRequest,
+ NULL,
+ MAKE_CSR_API(Request, CSR_NATIVE),
+ sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{
- SetLastErrorByStatus (Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
- GetProcessWorkingSetSize (HANDLE hProcess,
- PSIZE_T lpMinimumWorkingSetSize,
- PSIZE_T lpMaximumWorkingSetSize)
+ BOOL
+ WINAPI
+ GetProcessWorkingSetSize(HANDLE hProcess,
+ PSIZE_T lpMinimumWorkingSetSize,
+ PSIZE_T lpMaximumWorkingSetSize)
{
- QUOTA_LIMITS QuotaLimits;
- NTSTATUS Status;
+ QUOTA_LIMITS QuotaLimits;
+ NTSTATUS Status;
- Status = NtQueryInformationProcess(hProcess,
- ProcessQuotaLimits,
- &QuotaLimits,
- sizeof(QUOTA_LIMITS),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessQuotaLimits,
+ &QuotaLimits,
+ sizeof(QUOTA_LIMITS),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- *lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
- *lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
+ *lpMinimumWorkingSetSize = QuotaLimits.MinimumWorkingSetSize;
+ *lpMaximumWorkingSetSize = QuotaLimits.MaximumWorkingSetSize;
- return(TRUE);
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
+ BOOL
+ WINAPI
SetProcessWorkingSetSize(HANDLE hProcess,
- SIZE_T dwMinimumWorkingSetSize,
- SIZE_T dwMaximumWorkingSetSize)
+ SIZE_T dwMinimumWorkingSetSize,
+ SIZE_T dwMaximumWorkingSetSize)
{
- QUOTA_LIMITS QuotaLimits;
- NTSTATUS Status;
+ QUOTA_LIMITS QuotaLimits;
+ NTSTATUS Status;
- QuotaLimits.MinimumWorkingSetSize = dwMinimumWorkingSetSize;
- QuotaLimits.MaximumWorkingSetSize = dwMaximumWorkingSetSize;
+ QuotaLimits.MinimumWorkingSetSize = dwMinimumWorkingSetSize;
+ QuotaLimits.MaximumWorkingSetSize = dwMaximumWorkingSetSize;
- Status = NtSetInformationProcess(hProcess,
- ProcessQuotaLimits,
- &QuotaLimits,
- sizeof(QUOTA_LIMITS));
- if (!NT_SUCCESS(Status))
+ Status = NtSetInformationProcess(hProcess,
+ ProcessQuotaLimits,
+ &QuotaLimits,
+ sizeof(QUOTA_LIMITS));
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
/*
* @implemented
*/
- BOOL WINAPI
+ BOOL
+ WINAPI
GetProcessTimes(HANDLE hProcess,
- LPFILETIME lpCreationTime,
- LPFILETIME lpExitTime,
- LPFILETIME lpKernelTime,
- LPFILETIME lpUserTime)
+ LPFILETIME lpCreationTime,
+ LPFILETIME lpExitTime,
+ LPFILETIME lpKernelTime,
+ LPFILETIME lpUserTime)
{
- KERNEL_USER_TIMES Kut;
- NTSTATUS Status;
+ KERNEL_USER_TIMES Kut;
+ NTSTATUS Status;
- Status = NtQueryInformationProcess(hProcess,
- ProcessTimes,
- &Kut,
- sizeof(Kut),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessTimes,
+ &Kut,
+ sizeof(Kut),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart;
- lpCreationTime->dwHighDateTime = Kut.CreateTime.u.HighPart;
+ lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart;
+ lpCreationTime->dwHighDateTime = Kut.CreateTime.u.HighPart;
- lpExitTime->dwLowDateTime = Kut.ExitTime.u.LowPart;
- lpExitTime->dwHighDateTime = Kut.ExitTime.u.HighPart;
+ lpExitTime->dwLowDateTime = Kut.ExitTime.u.LowPart;
+ lpExitTime->dwHighDateTime = Kut.ExitTime.u.HighPart;
- lpKernelTime->dwLowDateTime = Kut.KernelTime.u.LowPart;
- lpKernelTime->dwHighDateTime = Kut.KernelTime.u.HighPart;
+ lpKernelTime->dwLowDateTime = Kut.KernelTime.u.LowPart;
+ lpKernelTime->dwHighDateTime = Kut.KernelTime.u.HighPart;
- lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart;
- lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart;
+ lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart;
+ lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart;
- return(TRUE);
+ return TRUE;
}
/*
* @implemented
*/
- HANDLE WINAPI
+ HANDLE
+ WINAPI
GetCurrentProcess(VOID)
{
- return((HANDLE)NtCurrentProcess());
+ return (HANDLE)NtCurrentProcess();
}
/*
* @implemented
*/
- HANDLE WINAPI
+ HANDLE
+ WINAPI
GetCurrentThread(VOID)
{
- return((HANDLE)NtCurrentThread());
+ return (HANDLE)NtCurrentThread();
}
/*
* @implemented
*/
- DWORD WINAPI
+ DWORD
+ WINAPI
GetCurrentProcessId(VOID)
{
- return((DWORD)GetTeb()->ClientId.UniqueProcess);
+ return (DWORD)GetTeb()->ClientId.UniqueProcess;
}
/*
* @implemented
*/
- BOOL WINAPI
+ BOOL
+ WINAPI
GetExitCodeProcess(HANDLE hProcess,
- LPDWORD lpExitCode)
+ LPDWORD lpExitCode)
{
- PROCESS_BASIC_INFORMATION ProcessBasic;
- NTSTATUS Status;
+ PROCESS_BASIC_INFORMATION ProcessBasic;
+ NTSTATUS Status;
- Status = NtQueryInformationProcess(hProcess,
- ProcessBasicInformation,
- &ProcessBasic,
- sizeof(PROCESS_BASIC_INFORMATION),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessBasicInformation,
+ &ProcessBasic,
+ sizeof(PROCESS_BASIC_INFORMATION),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return(FALSE);
- }
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
- *lpExitCode = (DWORD)ProcessBasic.ExitStatus;
+ *lpExitCode = (DWORD)ProcessBasic.ExitStatus;
- return(TRUE);
+ return TRUE;
}
WINAPI
GetProcessId(HANDLE Process)
{
- PROCESS_BASIC_INFORMATION ProcessBasic;
- NTSTATUS Status;
+ PROCESS_BASIC_INFORMATION ProcessBasic;
+ NTSTATUS Status;
- Status = NtQueryInformationProcess(Process,
- ProcessBasicInformation,
- &ProcessBasic,
- sizeof(PROCESS_BASIC_INFORMATION),
- NULL);
- if (!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return 0;
- }
+ Status = NtQueryInformationProcess(Process,
+ ProcessBasicInformation,
+ &ProcessBasic,
+ sizeof(PROCESS_BASIC_INFORMATION),
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return 0;
+ }
- return (DWORD)ProcessBasic.UniqueProcessId;
+ return (DWORD)ProcessBasic.UniqueProcessId;
}
/*
* @implemented
*/
- HANDLE WINAPI
+ HANDLE
+ WINAPI
OpenProcess(DWORD dwDesiredAccess,
- BOOL bInheritHandle,
- DWORD dwProcessId)
+ BOOL bInheritHandle,
+ DWORD dwProcessId)
{
- NTSTATUS errCode;
- HANDLE ProcessHandle;
- OBJECT_ATTRIBUTES ObjectAttributes;
- CLIENT_ID ClientId;
-
- ClientId.UniqueProcess = (HANDLE)dwProcessId;
- ClientId.UniqueThread = 0;
-
- InitializeObjectAttributes(&ObjectAttributes,
- NULL,
- (bInheritHandle ? OBJ_INHERIT : 0),
- NULL,
- NULL);
-
- errCode = NtOpenProcess(&ProcessHandle,
- dwDesiredAccess,
- &ObjectAttributes,
- &ClientId);
- if (!NT_SUCCESS(errCode))
- {
- SetLastErrorByStatus (errCode);
- return NULL;
- }
- return ProcessHandle;
+ NTSTATUS errCode;
+ HANDLE ProcessHandle;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ CLIENT_ID ClientId;
+
+ ClientId.UniqueProcess = (HANDLE)dwProcessId;
+ ClientId.UniqueThread = 0;
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ NULL,
+ (bInheritHandle ? OBJ_INHERIT : 0),
+ NULL,
+ NULL);
+
+ errCode = NtOpenProcess(&ProcessHandle,
+ dwDesiredAccess,
+ &ObjectAttributes,
+ &ClientId);
+ if (!NT_SUCCESS(errCode))
+ {
+ SetLastErrorByStatus(errCode);
+ return NULL;
+ }
+
+ return ProcessHandle;
}
/*
* @implemented
*/
- UINT WINAPI
+ UINT
+ WINAPI
WinExec(LPCSTR lpCmdLine,
- UINT uCmdShow)
+ UINT uCmdShow)
{
- STARTUPINFOA StartupInfo;
- PROCESS_INFORMATION ProcessInformation;
- DWORD dosErr;
-
- RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
- StartupInfo.cb = sizeof(STARTUPINFOA);
- StartupInfo.wShowWindow = (WORD)uCmdShow;
- StartupInfo.dwFlags = 0;
-
- if (! CreateProcessA(NULL,
- (PVOID)lpCmdLine,
- NULL,
- NULL,
- FALSE,
- 0,
- NULL,
- NULL,
- &StartupInfo,
- &ProcessInformation))
- {
- dosErr = GetLastError();
- return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT;
- }
- if (NULL != lpfnGlobalRegisterWaitForInputIdle)
- {
- lpfnGlobalRegisterWaitForInputIdle (
- ProcessInformation.hProcess,
- 10000
- );
- }
- NtClose(ProcessInformation.hProcess);
- NtClose(ProcessInformation.hThread);
-
- return 33; /* Something bigger than 31 means success. */
+ STARTUPINFOA StartupInfo;
+ PROCESS_INFORMATION ProcessInformation;
+ DWORD dosErr;
+
+ RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFOA);
+ StartupInfo.wShowWindow = (WORD)uCmdShow;
+ StartupInfo.dwFlags = 0;
+
+ if (!CreateProcessA(NULL,
+ (PVOID)lpCmdLine,
+ NULL,
+ NULL,
+ FALSE,
+ 0,
+ NULL,
+ NULL,
+ &StartupInfo,
+ &ProcessInformation))
+ {
+ dosErr = GetLastError();
+ return dosErr < 32 ? dosErr : ERROR_BAD_FORMAT;
+ }
+
+ if (NULL != lpfnGlobalRegisterWaitForInputIdle)
+ {
+ lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,
+ 10000);
+ }
+
+ NtClose(ProcessInformation.hProcess);
+ NtClose(ProcessInformation.hThread);
+
+ return 33; /* Something bigger than 31 means success. */
}
/*
* @implemented
*/
- VOID WINAPI
- RegisterWaitForInputIdle (
- WaitForInputIdleType lpfnRegisterWaitForInputIdle
- )
+ VOID
+ WINAPI
+ RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle)
{
- lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
- return;
+ lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
+ return;
}
/*
* @implemented
*/
- VOID WINAPI
+ VOID
+ WINAPI
GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
{
- PRTL_USER_PROCESS_PARAMETERS Params;
+ PRTL_USER_PROCESS_PARAMETERS Params;
- if (lpStartupInfo == NULL)
+ if (lpStartupInfo == NULL)
{
- SetLastError(ERROR_INVALID_PARAMETER);
- return;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return;
}
- Params = NtCurrentPeb()->ProcessParameters;
-
- lpStartupInfo->cb = sizeof(STARTUPINFOW);
- lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
- lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
- lpStartupInfo->dwX = Params->StartingX;
- lpStartupInfo->dwY = Params->StartingY;
- lpStartupInfo->dwXSize = Params->CountX;
- lpStartupInfo->dwYSize = Params->CountY;
- lpStartupInfo->dwXCountChars = Params->CountCharsX;
- lpStartupInfo->dwYCountChars = Params->CountCharsY;
- lpStartupInfo->dwFillAttribute = Params->FillAttribute;
- lpStartupInfo->dwFlags = Params->WindowFlags;
- lpStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
- lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
- lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
-
- lpStartupInfo->hStdInput = Params->StandardInput;
- lpStartupInfo->hStdOutput = Params->StandardOutput;
- lpStartupInfo->hStdError = Params->StandardError;
+ Params = NtCurrentPeb()->ProcessParameters;
+
+ lpStartupInfo->cb = sizeof(STARTUPINFOW);
+ lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
+ lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
+ lpStartupInfo->dwX = Params->StartingX;
+ lpStartupInfo->dwY = Params->StartingY;
+ lpStartupInfo->dwXSize = Params->CountX;
+ lpStartupInfo->dwYSize = Params->CountY;
+ lpStartupInfo->dwXCountChars = Params->CountCharsX;
+ lpStartupInfo->dwYCountChars = Params->CountCharsY;
+ lpStartupInfo->dwFillAttribute = Params->FillAttribute;
+ lpStartupInfo->dwFlags = Params->WindowFlags;
+ lpStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
+ lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
+ lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
+
+ lpStartupInfo->hStdInput = Params->StandardInput;
+ lpStartupInfo->hStdOutput = Params->StandardOutput;
+ lpStartupInfo->hStdError = Params->StandardError;
}
/*
* @implemented
*/
- VOID WINAPI
+ VOID
+ WINAPI
GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
{
- PRTL_USER_PROCESS_PARAMETERS Params;
- ANSI_STRING AnsiString;
+ PRTL_USER_PROCESS_PARAMETERS Params;
+ ANSI_STRING AnsiString;
- if (lpStartupInfo == NULL)
+ if (lpStartupInfo == NULL)
{
- SetLastError(ERROR_INVALID_PARAMETER);
- return;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return;
}
- Params = NtCurrentPeb ()->ProcessParameters;
+ Params = NtCurrentPeb ()->ProcessParameters;
- RtlAcquirePebLock ();
+ RtlAcquirePebLock ();
- /* FIXME - not thread-safe */
- if (lpLocalStartupInfo == NULL)
+ /* FIXME - not thread-safe */
+ if (lpLocalStartupInfo == NULL)
{
- /* create new local startup info (ansi) */
- lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (),
- 0,
- sizeof(STARTUPINFOA));
+ /* create new local startup info (ansi) */
+ lpLocalStartupInfo = RtlAllocateHeap(RtlGetProcessHeap(),
+ 0,
+ sizeof(STARTUPINFOA));
if (lpLocalStartupInfo == NULL)
{
- RtlReleasePebLock ();
+ RtlReleasePebLock();
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return;
}
- lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);
-
- /* copy window title string */
- RtlUnicodeStringToAnsiString (&AnsiString,
- &Params->WindowTitle,
- TRUE);
- lpLocalStartupInfo->lpTitle = AnsiString.Buffer;
-
- /* copy desktop info string */
- RtlUnicodeStringToAnsiString (&AnsiString,
- &Params->DesktopInfo,
- TRUE);
- lpLocalStartupInfo->lpDesktop = AnsiString.Buffer;
-
- /* copy shell info string */
- RtlUnicodeStringToAnsiString (&AnsiString,
- &Params->ShellInfo,
- TRUE);
- lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
-
- lpLocalStartupInfo->dwX = Params->StartingX;
- lpLocalStartupInfo->dwY = Params->StartingY;
- lpLocalStartupInfo->dwXSize = Params->CountX;
- lpLocalStartupInfo->dwYSize = Params->CountY;
- lpLocalStartupInfo->dwXCountChars = Params->CountCharsX;
- lpLocalStartupInfo->dwYCountChars = Params->CountCharsY;
- lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute;
- lpLocalStartupInfo->dwFlags = Params->WindowFlags;
- lpLocalStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
- lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length;
- lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
-
- lpLocalStartupInfo->hStdInput = Params->StandardInput;
- lpLocalStartupInfo->hStdOutput = Params->StandardOutput;
- lpLocalStartupInfo->hStdError = Params->StandardError;
- }
-
- RtlReleasePebLock ();
-
- /* copy local startup info data to external startup info */
- memcpy (lpStartupInfo,
+ lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);
+
+ /* copy window title string */
+ RtlUnicodeStringToAnsiString(&AnsiString,
+ &Params->WindowTitle,
+ TRUE);
+ lpLocalStartupInfo->lpTitle = AnsiString.Buffer;
+
+ /* copy desktop info string */
+ RtlUnicodeStringToAnsiString(&AnsiString,
+ &Params->DesktopInfo,
+ TRUE);
+ lpLocalStartupInfo->lpDesktop = AnsiString.Buffer;
+
+ /* copy shell info string */
+ RtlUnicodeStringToAnsiString(&AnsiString,
+ &Params->ShellInfo,
+ TRUE);
+ lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
+
+ lpLocalStartupInfo->dwX = Params->StartingX;
+ lpLocalStartupInfo->dwY = Params->StartingY;
+ lpLocalStartupInfo->dwXSize = Params->CountX;
+ lpLocalStartupInfo->dwYSize = Params->CountY;
+ lpLocalStartupInfo->dwXCountChars = Params->CountCharsX;
+ lpLocalStartupInfo->dwYCountChars = Params->CountCharsY;
+ lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute;
+ lpLocalStartupInfo->dwFlags = Params->WindowFlags;
+ lpLocalStartupInfo->wShowWindow = (WORD)Params->ShowWindowFlags;
+ lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length;
+ lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
+
+ lpLocalStartupInfo->hStdInput = Params->StandardInput;
+ lpLocalStartupInfo->hStdOutput = Params->StandardOutput;
+ lpLocalStartupInfo->hStdError = Params->StandardError;
+ }
+
+ RtlReleasePebLock();
+
+ /* copy local startup info data to external startup info */
+ memcpy(lpStartupInfo,
lpLocalStartupInfo,
sizeof(STARTUPINFOA));
}
/*
* @implemented
*/
- BOOL WINAPI
- FlushInstructionCache (HANDLE hProcess,
- LPCVOID lpBaseAddress,
- DWORD dwSize)
+ BOOL
+ WINAPI
+ FlushInstructionCache(HANDLE hProcess,
+ LPCVOID lpBaseAddress,
+ DWORD dwSize)
{
- NTSTATUS Status;
+ NTSTATUS Status;
- Status = NtFlushInstructionCache(hProcess,
- (PVOID)lpBaseAddress,
- dwSize);
- if (!NT_SUCCESS(Status))
+ Status = NtFlushInstructionCache(hProcess,
+ (PVOID)lpBaseAddress,
+ dwSize);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return TRUE;
+
+ return TRUE;
}
/*
* @implemented
*/
- VOID WINAPI
+ VOID
+ WINAPI
ExitProcess(UINT uExitCode)
{
- CSR_API_MESSAGE CsrRequest;
- ULONG Request;
- NTSTATUS Status;
+ CSR_API_MESSAGE CsrRequest;
+ ULONG Request;
+ NTSTATUS Status;
- /* kill sibling threads ... we want to be alone at this point */
- NtTerminateProcess (NULL, 0);
+ /* kill sibling threads ... we want to be alone at this point */
+ NtTerminateProcess(NULL, 0);
- /* unload all dll's */
- LdrShutdownProcess ();
+ /* unload all dll's */
+ LdrShutdownProcess();
- /* notify csrss of process termination */
- Request = TERMINATE_PROCESS;
- Status = CsrClientCallServer(&CsrRequest,
- NULL,
- MAKE_CSR_API(Request, CSR_NATIVE),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
+ /* notify csrss of process termination */
+ Request = TERMINATE_PROCESS;
+ Status = CsrClientCallServer(&CsrRequest,
+ NULL,
+ MAKE_CSR_API(Request, CSR_NATIVE),
+ sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{
- DPRINT("Failed to tell csrss about terminating process\n");
+ DPRINT("Failed to tell csrss about terminating process\n");
}
+ NtTerminateProcess(NtCurrentProcess (),
+ uExitCode);
- NtTerminateProcess (NtCurrentProcess (),
- uExitCode);
-
- /* should never get here */
- ASSERT(0);
- while(1);
+ /* should never get here */
+ ASSERT(0);
+ while(1);
}
/*
* @implemented
*/
- BOOL WINAPI
- TerminateProcess (HANDLE hProcess,
- UINT uExitCode)
+ BOOL
+ WINAPI
+ TerminateProcess(HANDLE hProcess,
+ UINT uExitCode)
{
- NTSTATUS Status;
+ NTSTATUS Status;
- if (hProcess == NULL)
+ if (hProcess == NULL)
{
return FALSE;
}
- Status = NtTerminateProcess (hProcess, uExitCode);
- if (NT_SUCCESS(Status))
+ Status = NtTerminateProcess(hProcess, uExitCode);
+ if (NT_SUCCESS(Status))
{
- return TRUE;
+ return TRUE;
}
- SetLastErrorByStatus (Status);
- return FALSE;
+
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
/*
* @unimplemented
*/
- VOID WINAPI
+ VOID
+ WINAPI
FatalAppExitA(UINT uAction,
- LPCSTR lpMessageText)
+ LPCSTR lpMessageText)
{
- UNICODE_STRING MessageTextU;
- ANSI_STRING MessageText;
+ UNICODE_STRING MessageTextU;
+ ANSI_STRING MessageText;
- RtlInitAnsiString (&MessageText, (LPSTR) lpMessageText);
+ RtlInitAnsiString(&MessageText, (LPSTR)lpMessageText);
- RtlAnsiStringToUnicodeString (&MessageTextU,
- &MessageText,
- TRUE);
+ RtlAnsiStringToUnicodeString(&MessageTextU,
+ &MessageText,
+ TRUE);
- FatalAppExitW (uAction, MessageTextU.Buffer);
+ FatalAppExitW(uAction, MessageTextU.Buffer);
- RtlFreeUnicodeString (&MessageTextU);
+ RtlFreeUnicodeString(&MessageTextU);
}
/*
* @unimplemented
*/
- VOID WINAPI
+ VOID
+ WINAPI
FatalAppExitW(UINT uAction,
LPCWSTR lpMessageText)
{
DPRINT1("AppExit\n");
if (hModule)
- pMessageBoxW = (MessageBoxW_Proc) GetProcAddress(hModule, "MessageBoxW");
+ pMessageBoxW = (MessageBoxW_Proc)GetProcAddress(hModule, "MessageBoxW");
if (pMessageBoxW)
pMessageBoxW(0, lpMessageText, NULL, MB_SYSTEMMODAL | MB_OK);
/*
* @implemented
*/
- VOID WINAPI
- FatalExit (int ExitCode)
+ VOID
+ WINAPI
+ FatalExit(int ExitCode)
{
- ExitProcess(ExitCode);
+ ExitProcess(ExitCode);
}
/*
* @implemented
*/
- DWORD WINAPI
- GetPriorityClass (HANDLE hProcess)
+ DWORD
+ WINAPI
+ GetPriorityClass(HANDLE hProcess)
{
NTSTATUS Status;
PROCESS_PRIORITY_CLASS PriorityClass;
/*
* @implemented
*/
- BOOL WINAPI
- SetPriorityClass (HANDLE hProcess,
- DWORD dwPriorityClass)
+ BOOL
+ WINAPI
+ SetPriorityClass(HANDLE hProcess,
+ DWORD dwPriorityClass)
{
- NTSTATUS Status;
- PROCESS_PRIORITY_CLASS PriorityClass;
+ NTSTATUS Status;
+ PROCESS_PRIORITY_CLASS PriorityClass;
- switch(dwPriorityClass)
- {
- case IDLE_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
- break;
+ switch (dwPriorityClass)
+ {
+ case IDLE_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_IDLE;
+ break;
- case BELOW_NORMAL_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
- break;
+ case BELOW_NORMAL_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_BELOW_NORMAL;
+ break;
- case NORMAL_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
- break;
+ case NORMAL_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_NORMAL;
+ break;
- case ABOVE_NORMAL_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
- break;
+ case ABOVE_NORMAL_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_ABOVE_NORMAL;
+ break;
- case HIGH_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
- break;
+ case HIGH_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_HIGH;
+ break;
- case REALTIME_PRIORITY_CLASS:
- PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
- break;
+ case REALTIME_PRIORITY_CLASS:
+ PriorityClass.PriorityClass = PROCESS_PRIORITY_CLASS_REALTIME;
+ break;
- default:
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- PriorityClass.Foreground = FALSE;
+ default:
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
- Status = NtSetInformationProcess(hProcess,
- ProcessPriorityClass,
- &PriorityClass,
- sizeof(PROCESS_PRIORITY_CLASS));
+ PriorityClass.Foreground = FALSE;
- if(!NT_SUCCESS(Status))
- {
- SetLastErrorByStatus(Status);
- return FALSE;
- }
+ Status = NtSetInformationProcess(hProcess,
+ ProcessPriorityClass,
+ &PriorityClass,
+ sizeof(PROCESS_PRIORITY_CLASS));
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/*
* @implemented
*/
- DWORD WINAPI
+ DWORD
+ WINAPI
GetProcessVersion(DWORD ProcessId)
{
DWORD Version = 0;
_SEH2_TRY
{
- /* Caller's */
if (0 == ProcessId || GetCurrentProcessId() == ProcessId)
{
+ /* Caller's */
BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress;
NtHeader = RtlImageNtHeader(BaseAddress);
Version = (NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) |
(NtHeader->OptionalHeader.MinorOperatingSystemVersion);
}
- else /* other process */
+ else
{
+ /* Other process */
ProcessHandle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
FALSE,
ProcessId);
&ProcessBasicInfo,
sizeof(ProcessBasicInfo),
NULL);
+
if (!NT_SUCCESS(Status)) goto Error;
Status = NtReadVirtualMemory(ProcessHandle,
&Peb,
sizeof(Peb),
&Count);
+
if (!NT_SUCCESS(Status) || Count != sizeof(Peb)) goto Error;
memset(&DosHeader, 0, sizeof(DosHeader));
*/
BOOL
WINAPI
- GetProcessIoCounters(
- HANDLE hProcess,
- PIO_COUNTERS lpIoCounters)
+ GetProcessIoCounters(HANDLE hProcess,
+ PIO_COUNTERS lpIoCounters)
{
- NTSTATUS Status;
+ NTSTATUS Status;
- Status = NtQueryInformationProcess(hProcess,
- ProcessIoCounters,
- lpIoCounters,
- sizeof(IO_COUNTERS),
- NULL);
- if (!NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessIoCounters,
+ lpIoCounters,
+ sizeof(IO_COUNTERS),
+ NULL);
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return(FALSE);
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
GetProcessPriorityBoost(HANDLE hProcess,
PBOOL pDisablePriorityBoost)
{
- NTSTATUS Status;
- ULONG PriorityBoost;
+ NTSTATUS Status;
+ ULONG PriorityBoost;
- Status = NtQueryInformationProcess(hProcess,
- ProcessPriorityBoost,
- &PriorityBoost,
- sizeof(ULONG),
- NULL);
- if (NT_SUCCESS(Status))
+ Status = NtQueryInformationProcess(hProcess,
+ ProcessPriorityBoost,
+ &PriorityBoost,
+ sizeof(ULONG),
+ NULL);
+ if (NT_SUCCESS(Status))
{
- *pDisablePriorityBoost = PriorityBoost;
- return TRUE;
+ *pDisablePriorityBoost = PriorityBoost;
+ return TRUE;
}
- SetLastErrorByStatus(Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
SetProcessPriorityBoost(HANDLE hProcess,
BOOL bDisablePriorityBoost)
{
- NTSTATUS Status;
- ULONG PriorityBoost = (bDisablePriorityBoost ? TRUE : FALSE); /* prevent setting values other than 1 and 0 */
+ NTSTATUS Status;
+ ULONG PriorityBoost = (bDisablePriorityBoost ? TRUE : FALSE); /* prevent setting values other than 1 and 0 */
- Status = NtSetInformationProcess(hProcess,
- ProcessPriorityBoost,
- &PriorityBoost,
- sizeof(ULONG));
- if (!NT_SUCCESS(Status))
+ Status = NtSetInformationProcess(hProcess,
+ ProcessPriorityBoost,
+ &PriorityBoost,
+ sizeof(ULONG));
+ if (!NT_SUCCESS(Status))
{
- SetLastErrorByStatus(Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
*/
BOOL
WINAPI
- IsWow64Process(
- HANDLE hProcess,
- PBOOL Wow64Process
- )
+ IsWow64Process(HANDLE hProcess,
+ PBOOL Wow64Process)
{
ULONG pbi;
NTSTATUS Status;
&pbi,
sizeof(pbi),
NULL);
-
if (!NT_SUCCESS(Status))
{
SetLastError(RtlNtStatusToDosError(Status));
}
*Wow64Process = (pbi != 0);
+
return TRUE;
}
{
SetLastErrorByStatus(Status);
}
+
return !Status;
}
lpExeName,
*pdwSize,
NULL, NULL));
+
if (Result)
*pdwSize = strlen(lpExeName);
{
NTSTATUS Status;
HANDLE DuplicatedHandle;
- ULONG Dummy;
+ SIZE_T Dummy;
DPRINT("BasepDuplicateAndWriteHandle. hProcess: %lx, Handle: %lx,"
"Address: %p\n", ProcessHandle, StandardHandle, Address);
hSection,
hDebug,
NULL);
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
DPRINT1("Unable to create process, status 0x%x\n", Status);
SetLastErrorByStatus(Status);
/*
* @unimplemented
*/
- DWORD WINAPI
- DosPathToSessionPathW (DWORD SessionID, LPWSTR InPath, LPWSTR * OutPath)
+ DWORD
+ WINAPI
+ DosPathToSessionPathW(DWORD SessionID,
+ LPWSTR InPath,
+ LPWSTR *OutPath)
{
UNIMPLEMENTED;
- return 0;
+ return 0;
}
/*
*
* @unimplemented
*/
- DWORD WINAPI
- DosPathToSessionPathA (DWORD SessionId, LPSTR InPath, LPSTR * OutPath)
+ DWORD
+ WINAPI
+ DosPathToSessionPathA(DWORD SessionId,
+ LPSTR InPath,
+ LPSTR *OutPath)
{
- //DosPathToSessionPathW (SessionId,InPathW,OutPathW);
+ //DosPathToSessionPathW (SessionId,InPathW,OutPathW);
UNIMPLEMENTED;
- return 0;
+ return 0;
}
/*
* @implemented
*/
- BOOL WINAPI ProcessIdToSessionId (IN DWORD dwProcessId,
- OUT DWORD* pSessionId)
+ BOOL
+ WINAPI
+ ProcessIdToSessionId(IN DWORD dwProcessId,
+ OUT DWORD *pSessionId)
{
- PROCESS_SESSION_INFORMATION SessionInformation;
- OBJECT_ATTRIBUTES ObjectAttributes;
- CLIENT_ID ClientId;
- HANDLE ProcessHandle;
- NTSTATUS Status;
+ PROCESS_SESSION_INFORMATION SessionInformation;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ CLIENT_ID ClientId;
+ HANDLE ProcessHandle;
+ NTSTATUS Status;
- if(IsBadWritePtr(pSessionId, sizeof(DWORD)))
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- ClientId.UniqueProcess = (HANDLE)(ULONG_PTR)dwProcessId;
- ClientId.UniqueThread = 0;
+ if (IsBadWritePtr(pSessionId, sizeof(DWORD)))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
- InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
- ClientId.UniqueProcess = (HANDLE)dwProcessId;
++ ClientId.UniqueProcess = (HANDLE)(ULONG_PTR)dwProcessId;
+ ClientId.UniqueThread = 0;
- Status = NtOpenProcess(&ProcessHandle,
- PROCESS_QUERY_INFORMATION,
- &ObjectAttributes,
- &ClientId);
- if(NT_SUCCESS(Status))
- {
- Status = NtQueryInformationProcess(ProcessHandle,
- ProcessSessionInformation,
- &SessionInformation,
- sizeof(SessionInformation),
- NULL);
- NtClose(ProcessHandle);
+ InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
- if(NT_SUCCESS(Status))
+ Status = NtOpenProcess(&ProcessHandle,
+ PROCESS_QUERY_INFORMATION,
+ &ObjectAttributes,
+ &ClientId);
+ if (NT_SUCCESS(Status))
{
- *pSessionId = SessionInformation.SessionId;
- return TRUE;
+ Status = NtQueryInformationProcess(ProcessHandle,
+ ProcessSessionInformation,
+ &SessionInformation,
+ sizeof(SessionInformation),
+ NULL);
+ NtClose(ProcessHandle);
+
+ if (NT_SUCCESS(Status))
+ {
+ *pSessionId = SessionInformation.SessionId;
+ return TRUE;
+ }
}
- }
- SetLastErrorByStatus(Status);
- return FALSE;
+ SetLastErrorByStatus(Status);
+ return FALSE;
}
/*
* @implemented
*/
- DWORD WINAPI
- WTSGetActiveConsoleSessionId (VOID)
+ DWORD
+ WINAPI
+ WTSGetActiveConsoleSessionId(VOID)
{
- return ActiveConsoleSessionId;
+ return ActiveConsoleSessionId;
}
/* EOF */
DPRINT1("Converting Fiber to Thread\n");
/* the current thread isn't running a fiber: failure */
- if(!pTeb->HasFiberData)
+ if (!pTeb->HasFiberData)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
pTeb->HasFiberData = FALSE;
/* free the fiber */
- if(pTeb->NtTib.FiberData != NULL)
- if (pTeb->Tib.FiberData != NULL)
++ if (pTeb->NtTib.FiberData != NULL)
{
- RtlFreeHeap(GetProcessHeap(), 0, pTeb->Tib.FiberData);
+ RtlFreeHeap(GetProcessHeap(), 0, pTeb->NtTib.FiberData);
}
/* success */
DPRINT1("Converting Thread to Fiber\n");
/* the current thread is already a fiber */
- if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData;
+ if(pTeb->HasFiberData && pTeb->NtTib.FiberData) return pTeb->NtTib.FiberData;
/* allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(),
sizeof(FIBER));
/* failure */
- if(pfCurFiber == NULL)
+ if (pfCurFiber == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
/* copy some contextual data from the thread to the fiber */
pfCurFiber->Parameter = lpParameter;
- pfCurFiber->ExceptionList = pTeb->Tib.ExceptionList;
- pfCurFiber->StackBase = pTeb->Tib.StackBase;
- pfCurFiber->StackLimit = pTeb->Tib.StackLimit;
+ pfCurFiber->ExceptionList = pTeb->NtTib.ExceptionList;
+ pfCurFiber->StackBase = pTeb->NtTib.StackBase;
+ pfCurFiber->StackLimit = pTeb->NtTib.StackLimit;
pfCurFiber->DeallocationStack = pTeb->DeallocationStack;
pfCurFiber->FlsData = pTeb->FlsData;
pfCurFiber->GuaranteedStackBytes = pTeb->GuaranteedStackBytes;
pfCurFiber->ActivationContextStack = pTeb->ActivationContextStackPointer;
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
-
+
/* Save FPU State if requsted */
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
{
}
/* associate the fiber to the current thread */
- pTeb->Tib.FiberData = pfCurFiber;
+ pTeb->NtTib.FiberData = pfCurFiber;
pTeb->HasFiberData = TRUE;
/* success */
PVOID ActivationContextStack = NULL;
DPRINT1("Creating Fiber\n");
- #ifdef SXS_SUPPORT_ENABLED
+ #ifdef SXS_SUPPORT_ENABLED
/* Allocate the Activation Context Stack */
nErrCode = RtlAllocateActivationContextStack(&ActivationContextStack);
- #endif
-
+ #endif
+
/* Allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(),
0,
sizeof(FIBER));
/* Failure */
- if(pfCurFiber == NULL)
+ if (pfCurFiber == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
SetLastErrorByStatus(nErrCode);
return NULL;
}
-
+
/* Clear the context */
RtlZeroMemory(&pfCurFiber->Context, sizeof(CONTEXT));
-
+
/* copy the data into the fiber */
pfCurFiber->StackBase = usFiberInitialTeb.StackBase;
pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit;
pfCurFiber->FlsData = NULL;
pfCurFiber->ActivationContextStack = ActivationContextStack;
pfCurFiber->Context.ContextFlags = CONTEXT_FULL;
-
+
/* Save FPU State if requsted */
if (dwFlags & FIBER_FLAG_FLOAT_SWITCH)
{
pfCurFiber->Context.ContextFlags |= CONTEXT_FLOATING_POINT;
}
-
+
/* initialize the context for the fiber */
BasepInitializeContext(&ctxFiberContext,
lpParameter,
lpStartAddress,
usFiberInitialTeb.StackBase,
2);
-
+
/* Return the Fiber */
return pfCurFiber;
}
RtlFreeHeap(GetProcessHeap(), 0, lpFiber);
/* the fiber is deleting itself: let the system deallocate the stack */
- if(NtCurrentTeb()->Tib.FiberData == lpFiber) ExitThread(1);
+ if(NtCurrentTeb()->NtTib.FiberData == lpFiber) ExitThread(1);
/* deallocate the stack */
NtFreeVirtualMemory(NtCurrentProcess(),
DPRINT1("Starting Fiber\n");
BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Eax,
(LPVOID)Fiber->Context.Ebx);
+#elif defined(__x86_64__)
+ PFIBER Fiber = GetFiberData();
+
+ /* Call the Thread Startup Routine */
+ DPRINT1("Starting Fiber\n");
+ BaseThreadStartup((LPTHREAD_START_ROUTINE)Fiber->Context.Rax,
+ (LPVOID)Fiber->Context.Rbx);
#else
#warning Unknown architecture
UNIMPLEMENTED;
NtUserCallOneParam((DWORD_PTR)bShow, ONEPARAM_ROUTINE_SHOWCURSOR)
#define NtUserGetDesktopMapping(Ptr) \
- (PVOID)NtUserCallOneParam((DWORD)Ptr, ONEPARAM_ROUTINE_GETDESKTOPMAPPING)
+ (PVOID)NtUserCallOneParam((DWORD_PTR)Ptr, ONEPARAM_ROUTINE_GETDESKTOPMAPPING)
+ #define NtUserSetCursorPos(x, y) \
+ (BOOL)NtUserCallTwoParam((DWORD)x, (DWORD)y, TWOPARAM_ROUTINE_SETCURSORPOS)
+
#define ShowCaret(hwnd) \
NtUserShowCaret(hwnd)
{
0, 0, &WDML_CritSect,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": WDML_CritSect") }
+ 0, 0, { (DWORD_PTR)0/*(__FILE__ ": WDML_CritSect")*/ }
};
CRITICAL_SECTION WDML_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
TRACE("invoking CB[%p] (%x %x %p %p %p %p %lx %lx)\n",
pInstance->callback, uType, uFmt,
hConv, hsz1, hsz2, hdata, dwData1, dwData2);
- ret = pInstance->callback(uType, uFmt, hConv, hsz1, hsz2, hdata, dwData1, dwData2);
+ ret = pInstance->callback(uType, uFmt, hConv, hsz1, hsz2, hdata, dwData1, dwData2);
TRACE("done => %p\n", ret);
return ret;
}
BOOL WINAPI DdeFreeDataHandle(HDDEDATA hData)
{
TRACE("(%p)\n", hData);
+
+ /* 1 is the handle value returned by an asynchronous operation. */
+ if (hData == (HDDEDATA)1)
+ return TRUE;
+
return GlobalFree(hData) == 0;
}
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/misc/exit.c
* PURPOSE: Shutdown related functions
- * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
+ * PROGRAMMER: Eric Kohl
*/
#include <user32.h>
NTSTATUS Status;
CsrRequest = MAKE_CSR_API(REGISTER_SERVICES_PROCESS, CSR_GUI);
- Request.Data.RegisterServicesProcessRequest.ProcessId = (HANDLE)ServicesProcessId;
+ Request.Data.RegisterServicesProcessRequest.ProcessId = LongToHandle(ServicesProcessId);
Status = CsrClientCallServer(&Request,
NULL,
return TRUE;
else
return (NtUserQueryWindow(Wnd->head.h, QUERY_WINDOW_UNIQUE_PROCESS_ID) ==
- (DWORD)NtCurrentTeb()->ClientId.UniqueProcess );
+ (DWORD_PTR)NtCurrentTeb()->ClientId.UniqueProcess );
}
BOOL
INT Index;
USHORT generation;
- Index = (((UINT)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
+ Index = (((UINT_PTR)handle & 0xffff) - FIRST_USER_HANDLE) >> 1;
if (Index < 0 || Index >= gHandleTable->nb_handles)
return NULL;
if (!gHandleEntries[Index].type || !gHandleEntries[Index].ptr)
return NULL;
- generation = (UINT)handle >> 16;
+ generation = (UINT_PTR)handle >> 16;
if (generation == gHandleEntries[Index].generation || !generation || generation == 0xffff)
return &gHandleEntries[Index];
FASTCALL
GetThreadDesktopWnd(VOID)
{
- PWND Wnd = GetThreadDesktopInfo()->Wnd;
+ PWND Wnd = GetThreadDesktopInfo()->spwnd;
if (Wnd != NULL)
Wnd = DesktopPtrToUser(Wnd);
return Wnd;
* PROJECT: ReactOS Storage Stack
* FILE: drivers/storage/scsiport/scsiport.c
* PURPOSE: SCSI port driver
- * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
+ * PROGRAMMER: Eric Kohl
* Aleksey Bragin (aleksey reactos org)
*/
/* i/o space */
if (AddressSpace != 0)
- return((PVOID)TranslatedAddress.u.LowPart);
+ return((PVOID)(ULONG_PTR)TranslatedAddress.QuadPart);
MappedAddress = MmMapIoSpace(TranslatedAddress,
NumberOfBytes,
PortConfig->AccessRanges = (PVOID)(PortConfig+1);
/* Align to LONGLONG */
- PortConfig->AccessRanges = (PVOID)((ULONG)(PortConfig->AccessRanges) + 7);
- PortConfig->AccessRanges = (PVOID)((ULONG)(PortConfig->AccessRanges) & ~7);
+ PortConfig->AccessRanges = (PVOID)((ULONG_PTR)(PortConfig->AccessRanges) + 7);
+ PortConfig->AccessRanges = (PVOID)((ULONG_PTR)(PortConfig->AccessRanges) & ~7);
/* Copy the data */
RtlCopyMemory(PortConfig->AccessRanges,
* FILE: hal/halx86/generic/cmos.c
* PURPOSE: CMOS Access Routines (Real Time Clock and LastKnownGood)
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
- * Eric Kohl (ekohl@abo.rhein-zeitung.de)
+ * Eric Kohl
+ * Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
/* GLOBALS *******************************************************************/
-KSPIN_LOCK HalpSystemHardwareLock;
UCHAR HalpCmosCenturyOffset;
/* PRIVATE FUNCTIONS *********************************************************/
Cr4 = __readcr4();
//
- // Disable global pit
+ // Disable global bit
//
__writecr4(Cr4 & ~CR4_PGE);
__writeeflags(Flags);
}
+VOID
+NTAPI
+HalpSetInterruptGate(ULONG index, PVOID address)
+{
+ KIDTENTRY *idt;
+ KIDT_ACCESS Access;
+
+ /* Set the IDT Access Bits */
+ Access.Reserved = 0;
+ Access.Present = 1;
+ Access.Dpl = 0; /* Kernel-Mode */
+ Access.SystemSegmentFlag = 0;
+ Access.SegmentType = I386_INTERRUPT_GATE;
+
+ idt = (KIDTENTRY*)((ULONG)KeGetPcr()->IDT + index * sizeof(KIDTENTRY));
+ idt->Offset = (USHORT)((ULONG_PTR)address & 0xffff);
+ idt->Selector = KGDT_R0_CODE;
+ idt->Access = Access.Value;
+ idt->ExtendedOffset = (USHORT)((ULONG_PTR)address >> 16);
+}
+
/* FUNCTIONS *****************************************************************/
/*
NTAPI
HalHandleNMI(IN PVOID NmiInfo)
{
- UCHAR NmiStatus;
+ SYSTEM_CONTROL_PORT_B_REGISTER SystemControl;
//
// Don't recurse
if (HalpNMIInProgress++) while (TRUE);
//
- // Get the NMI Flag
+ // Read the system control register B
//
- NmiStatus = READ_PORT_UCHAR((PUCHAR)0x61);
+ SystemControl.Bits = __inbyte(SYSTEM_CONTROL_PORT_B);
//
// Switch to boot vieo
//
// Display NMI failure string
//
- HalDisplayString("\n*** Hardware Malfunction\n\n");
- HalDisplayString("Call your hardware vendor for support\n\n");
+ InbvDisplayString("\n*** Hardware Malfunction\n\n");
+ InbvDisplayString("Call your hardware vendor for support\n\n");
//
// Check for parity error
//
- if (NmiStatus & 0x80)
+ if (SystemControl.ParityCheck)
{
//
// Display message
//
- HalDisplayString("NMI: Parity Check / Memory Parity Error\n");
+ InbvDisplayString("NMI: Parity Check / Memory Parity Error\n");
}
//
// Check for I/O failure
//
- if (NmiStatus & 0x40)
+ if (SystemControl.ChannelCheck)
{
//
// Display message
//
- HalDisplayString("NMI: Channel Check / IOCHK\n");
+ InbvDisplayString("NMI: Channel Check / IOCHK\n");
}
//
//
// Halt the system
//
- HalDisplayString("\n*** The system has halted ***\n");
+ InbvDisplayString("\n*** The system has halted ***\n");
//
// Enter the debugger if possible
//
- //if (!KdDebuggerNotPresent && KdDebuggerEnabled) KeEnterKernelDebugger();
+ //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
//
// Freeze the system
//
return;
}
+
#define RTC_REG_A_UIP 0x80
#define RTC_REGISTER_CENTURY 0x32
- /* Timer Registers and Ports */
- #define TIMER_CONTROL_PORT 0x43
- #define TIMER_DATA_PORT0 0x40
- #define TIMER_SC0 0
- #define TIMER_BOTH 0x30
- #define TIMER_MD2 0x4
-
/* Usage flags */
#define IDT_REGISTERED 0x01
#define IDT_LATCHED 0x02
(((bcd & 0xF0) >> 4) * 10 + (bcd & 0x0F))
#define INT_BCD(int) \
(UCHAR)(((int / 10) << 4) + (int % 10))
-
+
+ //
+ // Commonly stated as being 1.19318MHz
+ //
+ // See ISA System Architecture 3rd Edition (Tom Shanley, Don Anderson, John Swindle)
+ // P. 471
+ //
+ // However, the true value is closer to 1.19318181[...]81MHz since this is 1/3rd
+ // of the NTSC color subcarrier frequency which runs at 3.57954545[...]45MHz.
+ //
+ // Note that Windows uses 1.193167MHz which seems to have no basis. However, if
+ // one takes the NTSC color subcarrier frequency as being 3.579545 (trimming the
+ // infinite series) and divides it by three, one obtains 1.19318167.
+ //
+ // It may be that the original NT HAL source code introduced a typo and turned
+ // 119318167 into 1193167 by ommitting the "18". This is very plausible as the
+ // number is quite long.
+ //
+ #define PIT_FREQUENCY 1193182
+
+ //
+ // These ports are controlled by the i8254 Programmable Interrupt Timer (PIT)
+ //
+ #define TIMER_CHANNEL0_DATA_PORT 0x40
+ #define TIMER_CHANNEL1_DATA_PORT 0x41
+ #define TIMER_CHANNEL2_DATA_PORT 0x42
+ #define TIMER_CONTROL_PORT 0x43
+
+ //
+ // Mode 0 - Interrupt On Terminal Count
+ // Mode 1 - Hardware Re-triggerable One-Shot
+ // Mode 2 - Rate Generator
+ // Mode 3 - Square Wave Generator
+ // Mode 4 - Software Triggered Strobe
+ // Mode 5 - Hardware Triggered Strobe
+ //
+ typedef enum _TIMER_OPERATING_MODES
+ {
+ PitOperatingMode0,
+ PitOperatingMode1,
+ PitOperatingMode2,
+ PitOperatingMode3,
+ PitOperatingMode4,
+ PitOperatingMode5,
+ PitOperatingMode2Reserved,
+ PitOperatingMode5Reserved
+ } TIMER_OPERATING_MODES;
+
+ typedef enum _TIMER_ACCESS_MODES
+ {
+ PitAccessModeCounterLatch,
+ PitAccessModeLow,
+ PitAccessModeHigh,
+ PitAccessModeLowHigh
+ } TIMER_ACCESS_MODES;
+
+ typedef enum _TIMER_CHANNELS
+ {
+ PitChannel0,
+ PitChannel1,
+ PitChannel2,
+ PitReadBack
+ } TIMER_CHANNELS;
+
+ typedef union _TIMER_CONTROL_PORT_REGISTER
+ {
+ struct
+ {
+ UCHAR BcdMode:1;
+ TIMER_OPERATING_MODES OperatingMode:3;
+ TIMER_ACCESS_MODES AccessMode:2;
+ TIMER_CHANNELS Channel:2;
+ };
+ UCHAR Bits;
+ } TIMER_CONTROL_PORT_REGISTER, *PTIMER_CONTROL_PORT_REGISTER;
+
+ //
+ // See ISA System Architecture 3rd Edition (Tom Shanley, Don Anderson, John Swindle)
+ // P. 400
+ //
+ // This port is controled by the i8255 Programmable Peripheral Interface (PPI)
+ //
+ #define SYSTEM_CONTROL_PORT_A 0x92
+ #define SYSTEM_CONTROL_PORT_B 0x61
+ typedef union _SYSTEM_CONTROL_PORT_B_REGISTER
+ {
+ struct
+ {
+ UCHAR Timer2GateToSpeaker:1;
+ UCHAR SpeakerDataEnable:1;
+ UCHAR ParityCheckEnable:1;
+ UCHAR ChannelCheckEnable:1;
+ UCHAR RefreshRequest:1;
+ UCHAR Timer2Output:1;
+ UCHAR ChannelCheck:1;
+ UCHAR ParityCheck:1;
+ };
+ UCHAR Bits;
+ } SYSTEM_CONTROL_PORT_B_REGISTER, *PSYSTEM_CONTROL_PORT_B_REGISTER;
+
//
// Mm PTE/PDE to Hal PTE/PDE
//
VOID
);
+VOID
+NTAPI
+HalpSetInterruptGate(ULONG Index, PVOID Address);
+
#ifdef _M_AMD64
#define KfLowerIrql KeLowerIrql
#ifndef CONFIG_SMP
#define EFLAG_SIGN 0x8000
#define EFLAG_ZERO 0x4000
+ //
+ // Legacy floating status word bit masks.
+ //
+ #define FSW_INVALID_OPERATION 0x1
+ #define FSW_DENORMAL 0x2
+ #define FSW_ZERO_DIVIDE 0x4
+ #define FSW_OVERFLOW 0x8
+ #define FSW_UNDERFLOW 0x10
+ #define FSW_PRECISION 0x20
+ #define FSW_STACK_FAULT 0x40
+
//
// IPI Types
//
#else
ULONG SpareFields0[1];
#endif
- CHAR VendorString[13];
+ UCHAR VendorString[13];
UCHAR InitialApicId;
UCHAR LogicalProcessorsPerPhysicalProcessor;
ULONG MHz;
{
PVOID pvDesktopBase;
PVOID pvDesktopLimit;
+ struct _WND *spwnd;
+ DWORD fsHooks;
+ struct tagHOOK * aphkStart[16];
- HANDLE hKernelHeap;
- ULONG_PTR HeapLimit;
HWND hTaskManWindow;
HWND hProgmanWindow;
HWND hShellWindow;
- struct _WND *Wnd;
union
{
PPROCESSINFO ppi;
} CLIENTINFO, *PCLIENTINFO;
-/* Make sure it fits exactly into the TEB */
-C_ASSERT(sizeof(CLIENTINFO) == FIELD_OFFSET(TEB, glDispatchTable) - FIELD_OFFSET(TEB, Win32ClientInfo));
+/* Make sure it fits into the TEB */
+C_ASSERT(sizeof(CLIENTINFO) <= sizeof(((PTEB)0)->Win32ClientInfo));
#define GetWin32ClientInfo() ((PCLIENTINFO)(NtCurrentTeb()->Win32ClientInfo))
NtUserResolveDesktopForWOW(
DWORD Unknown0);
- DWORD
+ BOOL
NTAPI
NtUserSBGetParms(
- DWORD Unknown0,
- DWORD Unknown1,
- DWORD Unknown2,
- DWORD Unknown3);
+ HWND hwnd,
+ int fnBar,
+ PSBDATA pSBData,
+ LPSCROLLINFO lpsi);
BOOL
NTAPI
OUT LPMONITORINFO pMonitorInfo);
/* Should be done in usermode */
- BOOL
- NTAPI
- NtUserGetScrollInfo(
- HWND hwnd,
- int fnBar,
- LPSCROLLINFO lpsi);
/* (other FocusedItem values give the position of the focused item) */
#define NO_SELECTED_ITEM 0xffff
* FILE: ntoskrnl/ex/init.c
* PURPOSE: Executive Initialization Code
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
- * Eric Kohl (ekohl@rz-online.de)
+ * Eric Kohl
*/
/* INCLUDES ******************************************************************/
PCHAR StringBuffer, EndBuffer, BeginBuffer, MpString = "";
PINIT_BUFFER InitBuffer;
ANSI_STRING TempString;
- ULONG LastTzBias, Size, YearHack = 0, Disposition, MessageCode = 0;
- SIZE_T Length;
+ ULONG LastTzBias, Length, YearHack = 0, Disposition, MessageCode = 0;
+ SIZE_T Size;
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
KEY_VALUE_PARTIAL_INFORMATION KeyPartialInfo;
UNICODE_STRING KeyName, DebugString;
StringBuffer = InitBuffer->VersionBuffer;
BeginBuffer = StringBuffer;
EndBuffer = StringBuffer;
- Length = 256;
+ Size = 256;
if (CmCSDVersionString.Length)
{
/* Print the version string */
Status = RtlStringCbPrintfExA(StringBuffer,
255,
&EndBuffer,
- &Length,
+ &Size,
0,
": %wZ",
&CmCSDVersionString);
else
{
/* No version */
- Length = 255;
+ Size = 255;
}
/* Null-terminate the string */
{
/* Create the banner message */
Status = RtlStringCbPrintfA(EndBuffer,
- Length,
+ Size,
MsgEntry->Text,
StringBuffer,
NtBuildNumber & 0xFFFF,
else
{
/* Use hard-coded banner message */
- Status = RtlStringCbCopyA(EndBuffer, Length, "REACTOS (R)\n");
+ Status = RtlStringCbCopyA(EndBuffer, Size, "REACTOS (R)\n");
if (!NT_SUCCESS(Status))
{
/* Bugcheck */
KeyValuePartialInformation,
&KeyPartialInfo,
sizeof(KeyPartialInfo),
- &Length);
+ &Size);
if (!NT_SUCCESS(Status)) AlternateShell = FALSE;
}
ZwClose(ProcessInfo->ProcessHandle);
/* Free the initial process environment */
- Size = 0;
+ Length = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
(PVOID*)&Environment,
- &Size,
+ &Length,
MEM_RELEASE);
/* Free the initial process parameters */
- Size = 0;
+ Length = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
(PVOID*)&ProcessParameters,
- &Size,
+ &Length,
MEM_RELEASE);
/* Increase init phase */
/* Call the generic handler with the system module list */
Status = ExpQueryModuleInformation(&PsLoadedModuleList,
&MmLoadedUserImageList,
- (PRTL_PROCESS_MODULES)Buffer,
- Size,
- ReqSize);
+ (PRTL_PROCESS_MODULES)Buffer,
+ Size,
+ ReqSize);
/* Release list lock and return status */
ExReleaseResourceLite(&PsLoadedModuleResource);
QSI_DEF(SystemInterruptInformation)
{
PKPRCB Prcb;
+ PKPCR Pcr;
LONG i;
ULONG ti;
PSYSTEM_INTERRUPT_INFORMATION sii = (PSYSTEM_INTERRUPT_INFORMATION)Buffer;
for (i = 0; i < KeNumberProcessors; i++)
{
Prcb = KiProcessorBlock[i];
- sii->ContextSwitches = KeGetContextSwitches(Prcb);
+#ifdef _M_AMD64
+ Pcr = CONTAINING_RECORD(Prcb, KPCR, CurrentPrcb);
+#else
+ Pcr = CONTAINING_RECORD(Prcb, KPCR, Prcb);
+#endif
+#ifdef _M_ARM // This code should probably be done differently
+ sii->ContextSwitches = Pcr->ContextSwitches;
+#else
+ sii->ContextSwitches = ((PKIPCR)Pcr)->ContextSwitches;
+#endif
sii->DpcCount = Prcb->DpcData[0].DpcCount;
sii->DpcRate = Prcb->DpcRequestRate;
sii->TimeIncrement = ti;
PVOID SectionPointer = Buffer;
/* Validate size */
- if (Size != sizeof(PVOID))
+ if(Size != sizeof(PVOID))
{
/* Incorrect length, fail */
return STATUS_INFO_LENGTH_MISMATCH;
- }
+ }
/* Only kernel mode can call this function */
if (ExGetPreviousMode() != KernelMode) return STATUS_PRIVILEGE_NOT_HELD;
/* Unload the image */
MmUnloadSystemImage(SectionPointer);
return STATUS_SUCCESS;
-}
+ }
/* Class 28 - Time Adjustment Information */
QSI_DEF(SystemTimeAdjustmentInformation)
/* Class 33 - Exception Information */
QSI_DEF(SystemExceptionInformation)
{
- /* FIXME */
- DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
- return STATUS_NOT_IMPLEMENTED;
+ PSYSTEM_EXCEPTION_INFORMATION ExceptionInformation =
+ (PSYSTEM_EXCEPTION_INFORMATION)Buffer;
+ PKPRCB Prcb;
+ ULONG i, AlignmentFixupCount = 0, ExceptionDispatchCount = 0;
+ ULONG FloatingEmulationCount = 0, ByteWordEmulationCount = 0;
+
+ /* Check size of a buffer, it must match our expectations */
+ if (sizeof(SYSTEM_EXCEPTION_INFORMATION) != Size)
+ return STATUS_INFO_LENGTH_MISMATCH;
+
+ /* Sum up exception count information from all processors */
+ for (i = 0; i < KeNumberProcessors; i++)
+ {
+ Prcb = KiProcessorBlock[i];
+ if (Prcb)
+ {
+ AlignmentFixupCount += Prcb->KeAlignmentFixupCount;
+ ExceptionDispatchCount += Prcb->KeExceptionDispatchCount;
+ FloatingEmulationCount += Prcb->KeFloatingEmulationCount;
+ }
+ }
+
+ /* Save information in user's buffer */
+ ExceptionInformation->AlignmentFixupCount = AlignmentFixupCount;
+ ExceptionInformation->ExceptionDispatchCount = ExceptionDispatchCount;
+ ExceptionInformation->FloatingEmulationCount = FloatingEmulationCount;
+ ExceptionInformation->ByteWordEmulationCount = ByteWordEmulationCount;
+
+ return STATUS_SUCCESS;
}
/* Class 34 - Crash Dump State Information */
/* Class 36 - Context Switch Information */
QSI_DEF(SystemContextSwitchInformation)
{
+ PSYSTEM_CONTEXT_SWITCH_INFORMATION ContextSwitchInformation =
+ (PSYSTEM_CONTEXT_SWITCH_INFORMATION)Buffer;
+ ULONG ContextSwitches, i;
+ PKPRCB Prcb;
+
+ /* Check size of a buffer, it must match our expectations */
+ if (sizeof(SYSTEM_CONTEXT_SWITCH_INFORMATION) != Size)
+ return STATUS_INFO_LENGTH_MISMATCH;
+
+ /* Calculate total value of context switches across all processors */
+ ContextSwitches = 0;
+ for (i = 0; i < KeNumberProcessors; i ++)
+ {
+ Prcb = KiProcessorBlock[i];
+ if (Prcb)
+ {
+ ContextSwitches += KeGetContextSwitches(Prcb);
+ }
+ }
+
+ ContextSwitchInformation->ContextSwitches = ContextSwitches;
+
/* FIXME */
- DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
- return STATUS_NOT_IMPLEMENTED;
+ ContextSwitchInformation->FindAny = 0;
+ ContextSwitchInformation->FindLast = 0;
+ ContextSwitchInformation->FindIdeal = 0;
+ ContextSwitchInformation->IdleAny = 0;
+ ContextSwitchInformation->IdleCurrent = 0;
+ ContextSwitchInformation->IdleLast = 0;
+ ContextSwitchInformation->IdleIdeal = 0;
+ ContextSwitchInformation->PreemptAny = 0;
+ ContextSwitchInformation->PreemptCurrent = 0;
+ ContextSwitchInformation->PreemptLast = 0;
+ ContextSwitchInformation->SwitchToIdle = 0;
+
+ return STATUS_SUCCESS;
}
/* Class 37 - Registry Quota Information */
#endif
+ #define KTS_SYSCALL_BIT (((KTRAP_STATE_BITS) { { .SystemCall = TRUE } }).Bits)
+ #define KTS_PM_BIT (((KTRAP_STATE_BITS) { { .PreviousMode = TRUE } }).Bits)
+ #define KTS_SEG_BIT (((KTRAP_STATE_BITS) { { .Segments = TRUE } }).Bits)
+ #define KTS_VOL_BIT (((KTRAP_STATE_BITS) { { .Volatiles = TRUE } }).Bits)
+ #define KTS_FULL_BIT (((KTRAP_STATE_BITS) { { .Full = TRUE } }).Bits)
+
/* INTERNAL KERNEL FUNCTIONS ************************************************/
VOID
PKTRAP_FRAME Tf
);
+ VOID
+ NTAPI
+ KiDispatchExceptionFromTrapFrame(
+ IN NTSTATUS Code,
+ IN ULONG_PTR Address,
+ IN ULONG ParameterCount,
+ IN ULONG_PTR Parameter1,
+ IN ULONG_PTR Parameter2,
+ IN ULONG_PTR Parameter3,
+ IN PKTRAP_FRAME TrapFrame
+ );
+
+ BOOLEAN
+ NTAPI
+ KiHandleNmi(VOID);
+
VOID
NTAPI
KeFlushCurrentTb(VOID);
VOID
NTAPI
KeRosDumpStackFrames(
- PULONG Frame,
+ PULONG_PTR Frame,
ULONG FrameCount
);
VOID
);
+ #ifndef HAL_INTERRUPT_SUPPORT_IN_C
VOID
NTAPI
KiInterruptDispatch(
KiChainedDispatch(
VOID
);
+ #else
+ VOID
+ FASTCALL
+ KiInterruptDispatch(
+ IN PKTRAP_FRAME TrapFrame,
+ IN PKINTERRUPT Interrupt
+ );
+
+ VOID
+ FASTCALL
+ KiChainedDispatch(
+ IN PKTRAP_FRAME TrapFrame,
+ IN PKINTERRUPT Interrupt
+ );
+ #endif
VOID
NTAPI
OUT PKPROCESSOR_STATE ProcessorState
);
+ VOID
+ NTAPI
+ KiSaveProcessorState(
+ IN PKTRAP_FRAME TrapFrame,
+ IN PKEXCEPTION_FRAME ExceptionFrame
+ );
+
VOID
FASTCALL
KiRetireDpcList(
VOID
);
+PVOID
+NTAPI
+KiPcToFileHeader(IN PVOID Eip,
+ OUT PLDR_DATA_TABLE_ENTRY *LdrEntry,
+ IN BOOLEAN DriversOnly,
+ OUT PBOOLEAN InKernel);
+
+PVOID
+NTAPI
+KiRosPcToUserFileHeader(IN PVOID Eip,
+ OUT PLDR_DATA_TABLE_ENTRY *LdrEntry);
+
#include "ke_x.h"
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */
* FILE: ntoskrnl/io/iomgr/arcname.c
* PURPOSE: ARC Path Initialization Functions
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
- * Eric Kohl (ekohl@rz-online.de)
+ * Eric Kohl
*/
/* INCLUDES ******************************************************************/
/* Now calculate the checksum */
for (i = 0; i < 2048 / sizeof(ULONG); i++) CheckSum += Buffer[i];
+#ifndef _M_AMD64
if (KeRosLoaderBlock) goto freeldrhack;
+#endif
/* Search if this device is the actual boot CD */
for (NextEntry = ArcDiskInfo->DiskSignatureListHead.Flink;
NTAPI
KiEspToTrapFrame(
IN PKTRAP_FRAME TrapFrame,
- IN ULONG Esp);
+ IN ULONG_PTR Esp);
/* ROS Internal. Please deprecate */
NTHALAPI
PKTRAP_FRAME TrapFrame,
PKDB_KTRAP_FRAME KdbTrapFrame)
{
- ULONG TrapCr0, TrapCr2, TrapCr3, TrapCr4;
+ ULONG_PTR TrapCr0, TrapCr2, TrapCr3, TrapCr4;
+#if defined(_M_IX86)
/* Copy the TrapFrame only up to Eflags and zero the rest*/
RtlCopyMemory(&KdbTrapFrame->Tf, TrapFrame, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
RtlZeroMemory((PVOID)((ULONG_PTR)&KdbTrapFrame->Tf + FIELD_OFFSET(KTRAP_FRAME, HardwareEsp)),
sizeof(KTRAP_FRAME) - FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
+#elif defined(_M_AMD64)
+ RtlCopyMemory(&KdbTrapFrame->Tf, TrapFrame, sizeof(KTRAP_FRAME));
+#endif
-#ifndef _MSC_VER
+#if defined(__GNUC__) && defined(_M_IX86)
asm volatile(
"movl %%cr0, %0" "\n\t"
"movl %%cr2, %1" "\n\t"
"movl %%cr4, %3" "\n\t"
: "=r"(TrapCr0), "=r"(TrapCr2),
"=r"(TrapCr3), "=r"(TrapCr4));
-#else
+#elif defined(_MSC_VER) && defined(_M_IX86)
__asm
{
mov eax, cr0;
//mov eax, cr4;
//mov TrapCr4, eax;
}
+#elif defined(__GNUC__) && defined(_M_AMD64)
+ asm volatile(
+ "movq %%cr0, %0" "\n\t"
+ "movq %%cr2, %1" "\n\t"
+ "movq %%cr3, %2" "\n\t"
+ "movq %%cr4, %3" "\n\t"
+ : "=r"(TrapCr0), "=r"(TrapCr2),
+ "=r"(TrapCr3), "=r"(TrapCr4));
+#else
+#error UNSUPPORTED ARCHITECTURE
#endif
KdbTrapFrame->Cr0 = TrapCr0;
KdbTrapFrame->Cr3 = TrapCr3;
KdbTrapFrame->Cr4 = TrapCr4;
+#ifdef _M_IX86
KdbTrapFrame->Tf.HardwareEsp = KiEspFromTrapFrame(TrapFrame);
KdbTrapFrame->Tf.HardwareSegSs = (USHORT)(KiSsFromTrapFrame(TrapFrame) & 0xFFFF);
-
+#elif defined(_M_AMD64)
+ //KdbTrapFrame->Tf.Rsp = KiEspFromTrapFrame(TrapFrame);
+ //KdbTrapFrame->Tf.SegGs = (USHORT)(KiSsFromTrapFrame(TrapFrame) & 0xFFFF);
+#endif
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
}
PKTRAP_FRAME TrapFrame)
{
/* Copy the TrapFrame only up to Eflags and zero the rest*/
+#ifdef _M_IX86
RtlCopyMemory(TrapFrame, &KdbTrapFrame->Tf, FIELD_OFFSET(KTRAP_FRAME, HardwareEsp));
/* FIXME: write cr0, cr2, cr3 and cr4 (not needed atm) */
KiEspToTrapFrame(TrapFrame, KdbTrapFrame->Tf.HardwareEsp);
/* FIXME: copy v86 registers if TrapFrame is a V86 trapframe */
+
+#elif defined(_M_AMD64)
+ RtlCopyMemory(TrapFrame, &KdbTrapFrame->Tf, sizeof(KTRAP_FRAME));
+ //KiSsToTrapFrame(TrapFrame, KdbTrapFrame->Tf.SegSs);
+ //KiEspToTrapFrame(TrapFrame, KdbTrapFrame->Tf.Rsp);
+
+#endif
}
static VOID
RtlZeroMemory(KdbTrapFrame, sizeof(KDB_KTRAP_FRAME));
StackPtr = (ULONG_PTR *) KernelStack;
-#if _M_X86_
+#ifdef _M_IX86
KdbTrapFrame->Tf.Ebp = StackPtr[3];
KdbTrapFrame->Tf.Edi = StackPtr[4];
KdbTrapFrame->Tf.Esi = StackPtr[5];
KdbTrapFrame->Tf.SegDs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegEs = KGDT_R0_DATA;
KdbTrapFrame->Tf.SegGs = KGDT_R0_DATA;
+#elif defined(_M_AMD64)
+ KdbTrapFrame->Tf.Rbp = StackPtr[3];
+ KdbTrapFrame->Tf.Rdi = StackPtr[4];
+ KdbTrapFrame->Tf.Rsi = StackPtr[5];
+ KdbTrapFrame->Tf.Rbx = StackPtr[6];
+ KdbTrapFrame->Tf.Rip = StackPtr[7];
+ KdbTrapFrame->Tf.Rsp = (ULONG_PTR) (StackPtr + 16);
+ KdbTrapFrame->Tf.SegSs = KGDT_64_R0_SS;
+ KdbTrapFrame->Tf.SegCs = KGDT_64_R0_CODE;
+ KdbTrapFrame->Tf.SegDs = KGDT_64_DATA;
+ KdbTrapFrame->Tf.SegEs = KGDT_64_DATA;
+ KdbTrapFrame->Tf.SegGs = KGDT_64_DATA;
#endif
/* FIXME: what about the other registers??? */
}
/* Get the interrupt descriptor */
- if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)((ULONG_PTR)Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
+ if (!NT_SUCCESS(KdbpSafeReadMemory(IntDesc, (PVOID)(ULONG_PTR)(Idtr.Base + (IntVect * 8)), sizeof (IntDesc))))
{
/*KdbpPrint("Couldn't access memory at 0x%p\n", (ULONG_PTR)Idtr.Base + (IntVect * 8));*/
return FALSE;
{
PETHREAD Thread;
PVOID SavedInitialStack, SavedStackBase, SavedKernelStack;
- ULONG SavedStackLimit;
+ ULONG_PTR SavedStackLimit;
KbdDisableMouse();
if (KdpDebugMode.Screen)
Thread->Tcb.StackLimit = (ULONG_PTR)KdbStack;
Thread->Tcb.KernelStack = (char*)KdbStack + KDB_STACK_SIZE;
- /*KdbpPrint("Switching to KDB stack 0x%08x-0x%08x (Current Stack is 0x%08x)\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase, Esp);*/
+ //KdbpPrint("Switching to KDB stack 0x%p-0x%p\n", Thread->Tcb.StackLimit, Thread->Tcb.StackBase);
KdbpStackSwitchAndCall(KdbStack + KDB_STACK_SIZE - sizeof(ULONG), KdbpCallMainLoop);
ULONGLONG ull;
BOOLEAN Resume = FALSE;
BOOLEAN EnterConditionMet = TRUE;
- ULONG OldEflags;
+ ULONG_PTR OldEflags;
KIRQL OldIrql;
NTSTATUS ExceptionCode;
if (BreakPoint->Type == KdbBreakPointSoftware)
{
- KdbpPrint("Entered debugger on breakpoint #%d: EXEC 0x%04x:0x%08x\n",
+ KdbpPrint("Entered debugger on breakpoint #%d: EXEC 0x%04x:0x%p\n",
KdbLastBreakPointNr, TrapFrame->SegCs & 0xffff, TrapFrame->Eip);
}
else if (BreakPoint->Type == KdbBreakPointHardware)
{
- KdbpPrint("Entered debugger on breakpoint #%d: %s 0x%08x\n",
+ KdbpPrint("Entered debugger on breakpoint #%d: %s 0x%p\n",
KdbLastBreakPointNr,
(BreakPoint->Data.Hw.AccessType == KdbAccessRead) ? "READ" :
((BreakPoint->Data.Hw.AccessType == KdbAccessWrite) ? "WRITE" :
return kdHandleException;
}
- KdbpPrint("Entered debugger on embedded INT3 at 0x%04x:0x%08x.\n",
+ KdbpPrint("Entered debugger on embedded INT3 at 0x%04x:0x%p.\n",
TrapFrame->SegCs & 0xffff, TrapFrame->Eip - 1);
}
else
ULONG Err;
TrapCr2 = __readcr2();
-
+#ifdef _M_IX86
Err = TrapFrame->ErrCode;
+#elif defined(_M_AMD64)
+ Err = TrapFrame->ErrorCode;
+#endif
+
KdbpPrint("Memory at 0x%p could not be %s: ", TrapCr2, (Err & (1 << 1)) ? "written" : "read");
if ((Err & (1 << 0)) == 0)
Result = FALSE;
return Result ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION;
-}
+}
* PURPOSE: Deferred Procedure Call (DPC) Support
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Philip Susi (phreak@iag.net)
- * Eric Kohl (ekohl@abo.rhein-zeitung.de)
+ * Eric Kohl
*/
/* INCLUDES ******************************************************************/
/* Decrease the queue depth */
DpcData->DpcQueueDepth--;
-
+#ifndef _M_AMD64
/* Clear DPC Time */
Prcb->DebugDpcTime = 0;
-
+#endif
/* Release the lock */
KeReleaseSpinLockFromDpcLevel(&DpcData->DpcLock);
Prcb->VendorString[sizeof(Prcb->VendorString) - sizeof(CHAR)] = ANSI_NULL;
/* Now check the CPU Type */
- if (!strcmp(Prcb->VendorString, CmpIntelID))
+ if (!strcmp((PCHAR)Prcb->VendorString, CmpIntelID))
{
return CPU_INTEL;
}
- else if (!strcmp(Prcb->VendorString, CmpAmdID))
+ else if (!strcmp((PCHAR)Prcb->VendorString, CmpAmdID))
{
return CPU_AMD;
}
- else if (!strcmp(Prcb->VendorString, CmpCyrixID))
+ else if (!strcmp((PCHAR)Prcb->VendorString, CmpCyrixID))
{
DPRINT1("Cyrix CPU support not fully tested!\n");
return CPU_CYRIX;
}
- else if (!strcmp(Prcb->VendorString, CmpTransmetaID))
+ else if (!strcmp((PCHAR)Prcb->VendorString, CmpTransmetaID))
{
DPRINT1("Transmeta CPU support not fully tested!\n");
return CPU_TRANSMETA;
}
- else if (!strcmp(Prcb->VendorString, CmpCentaurID))
+ else if (!strcmp((PCHAR)Prcb->VendorString, CmpCentaurID))
{
DPRINT1("Centaur CPU support not fully tested!\n");
return CPU_CENTAUR;
}
- else if (!strcmp(Prcb->VendorString, CmpRiseID))
+ else if (!strcmp((PCHAR)Prcb->VendorString, CmpRiseID))
{
DPRINT1("Rise CPU support not fully tested!\n");
return CPU_RISE;
Tss->CR3 = __readcr3();
Tss->Esp0 = PtrToUlong(KiDoubleFaultStack);
Tss->Esp = PtrToUlong(KiDoubleFaultStack);
- Tss->Eip = PtrToUlong(KiTrap8);
+ Tss->Eip = PtrToUlong(KiTrap08);
Tss->Cs = KGDT_R0_CODE;
Tss->Fs = KGDT_R0_PCR;
Tss->Ss = Ke386GetSs();
Tss->CR3 = __readcr3();
Tss->Esp0 = PtrToUlong(KiDoubleFaultStack);
Tss->Esp = PtrToUlong(KiDoubleFaultStack);
- Tss->Eip = PtrToUlong(KiTrap2);
+ Tss->Eip = PtrToUlong(KiTrap02);
Tss->Cs = KGDT_R0_CODE;
Tss->Fs = KGDT_R0_PCR;
Tss->Ss = Ke386GetSs();
{
PKIDTENTRY IdtEntry;
- /* Get the IDT Entry for Interrupt 19 */
- IdtEntry = &((PKIPCR)KeGetPcr())->IDT[19];
+ /* Get the IDT Entry for Interrupt 0x13 */
+ IdtEntry = &((PKIPCR)KeGetPcr())->IDT[0x13];
/* Set it up */
IdtEntry->Selector = KGDT_R0_CODE;
- IdtEntry->Offset = ((ULONG_PTR)KiTrap19 & 0xFFFF);
- IdtEntry->ExtendedOffset = ((ULONG_PTR)KiTrap19 >> 16) & 0xFFFF;
+ IdtEntry->Offset = ((ULONG_PTR)KiTrap13 & 0xFFFF);
+ IdtEntry->ExtendedOffset = ((ULONG_PTR)KiTrap13 >> 16) & 0xFFFF;
((PKIDT_ACCESS)&IdtEntry->Access)->Dpl = 0;
((PKIDT_ACCESS)&IdtEntry->Access)->Present = 1;
((PKIDT_ACCESS)&IdtEntry->Access)->SegmentType = I386_INTERRUPT_GATE;
/* PUBLIC FUNCTIONS **********************************************************/
+ /*
+ * @implemented
+ */
+ VOID
+ NTAPI
+ KiCoprocessorError(VOID)
+ {
+ PFX_SAVE_AREA NpxArea;
+
+ /* Get the FPU area */
+ NpxArea = KiGetThreadNpxArea(KeGetCurrentThread());
+
+ /* Set CR0_TS */
+ NpxArea->Cr0NpxState = CR0_TS;
+ __writecr0(__readcr0() | CR0_TS);
+ }
+
/*
* @implemented
*/
.endfunc
/*++
- * KiSwapContextInternal
+ * KiSwapContextInternal
*
+ * \brief
* The KiSwapContextInternal routine switches context to another thread.
*
+ * BOOLEAN USERCALL KiSwapContextInternal();
+ *
* Params:
* ESI - Pointer to the KTHREAD to which the caller wishes to
* switch to.
* EDI - Pointer to the KTHREAD to which the caller wishes to
* switch from.
*
- * Returns:
- * None.
+ * \returns
+ * APC state.
*
- * Remarks:
+ * \remarks
* Absolutely all registers except ESP can be trampled here for maximum code flexibility.
*
*--*/
#endif
.endfunc
-/*++
- * KiSwapContext
+/**
+ * KiSwapContext
*
+ * \brief
* The KiSwapContext routine switches context to another thread.
*
- * Params:
- * TargetThread - Pointer to the KTHREAD to which the caller wishes to
- * switch to.
+ * BOOLEAN FASTCALL
+ * KiSwapContext(PKTHREAD CurrentThread, PKTHREAD TargetThread);
*
- * Returns:
+ * \param CurrentThread
+ * Pointer to the KTHREAD of the current thread.
+ *
+ * \param TargetThread
+ * Pointer to the KTHREAD to which the caller wishes to switch to.
+ *
+ * \returns
* The WaitStatus of the Target Thread.
*
- * Remarks:
+ * \remarks
* This is a wrapper around KiSwapContextInternal which will save all the
* non-volatile registers so that the Internal function can use all of
* them. It will also save the old current thread and set the new one.
#endif
.endfunc
- .globl _Ki386AdjustEsp0@4
- .func Ki386AdjustEsp0@4
- _Ki386AdjustEsp0@4:
-
- /* Get the current thread */
- mov eax, [fs:KPCR_CURRENT_THREAD]
-
- /* Get trap frame and stack */
- mov edx, [esp+4]
- mov eax, [eax+KTHREAD_INITIAL_STACK]
-
- /* Check if V86 */
- test dword ptr [edx+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK
- jnz 1f
-
- /* Bias the stack */
- sub eax, KTRAP_FRAME_V86_GS - KTRAP_FRAME_SS
-
- 1:
- /* Skip FX Save Area */
- sub eax, SIZEOF_FX_SAVE_AREA
-
- /* Disable interrupts */
- pushf
- cli
-
- /* Adjust ESP0 */
- mov edx, [fs:KPCR_TSS]
- mov ss:[edx+KTSS_ESP0], eax
-
- /* Enable interrupts and return */
- popf
- ret 4
- .endfunc
-
.globl _KiSwapProcess@8
.func KiSwapProcess@8
_KiSwapProcess@8:
int 3
#endif
.endfunc
+
+ .globl _Ki386SetupAndExitToV86Mode@4
+ .func Ki386SetupAndExitToV86Mode@4
+ _Ki386SetupAndExitToV86Mode@4:
+
+ /* Enter V8086 mode */
+ pushad
+ sub esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)
+ mov ecx, esp
+ call @KiEnterV86Mode@4
+ jmp $
+ .endfunc
+
+ .globl @Ki386BiosCallReturnAddress@4
+ @Ki386BiosCallReturnAddress@4:
+
+ /* Exit V8086 mode */
+ call @KiExitV86Mode@4
+ mov esp, eax
+ add esp, (12 + KTRAP_FRAME_LENGTH + NPX_FRAME_LENGTH)
+ popad
+ ret 4
+
<library>bootvid</library>
<library>wdmguid</library>
<dependency>bugcodes</dependency>
- <!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38269
<directory name="include">
<pch>precomp.h</pch>
</directory>
- -->
<directory name="ke">
<if property="ARCH" value="i386">
<directory name="i386">
<file>systimer.S</file>
<file>thrdini.c</file>
<file>trap.s</file>
+ <file>traphdlr.c</file>
<file>usercall_asm.S</file>
<file>usercall.c</file>
<file>v86vdm.c</file>
- <file>v86m_sup.S</file>
</directory>
</if>
<if property="ARCH" value="arm">
<file>ctxhelp.S</file>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <file first="true">boot.S</file>
+ <file>context.c</file>
+ <file>cpu.c</file>
+ <file>ctxswitch.S</file>
+ <file>except.c</file>
+ <file>interrupt.c</file>
+ <file>irql.c</file>
+ <file>kiinit.c</file>
+ <file>spinlock.c</file>
+ <file>stubs.c</file>
+ <file>thrdini.c</file>
+ <file>trap.S</file>
+ </directory>
+ </if>
<file>apc.c</file>
<file>balmgr.c</file>
<file>bug.c</file>
<file>dpc.c</file>
<file>eventobj.c</file>
<file>except.c</file>
- <file>freeldr.c</file>
+ <if property="ARCH" value="i386">
+ <file>freeldr.c</file>
+ </if>
<file>freeze.c</file>
<file>gate.c</file>
<file>gmutex.c</file>
<file>cmhardwr.c</file>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="i386">
+ <file>cmhardwr.c</file>
+ </directory>
+ </if>
<if property="ARCH" value="arm">
<directory name="arm">
<file>cmhardwr.c</file>
<file>ioport.S</file>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <file>fastinterlck.c</file>
+ </directory>
+ </if>
<file>atom.c</file>
<file>callback.c</file>
<file>dbgctrl.c</file>
</if>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <if property="KDBG" value="1">
+ <group>
+ <file>i386-dis.c</file>
+ <file>kdb_help.S</file>
+ <file>kdb.c</file>
+ <file>setjmp.S</file>
+ </group>
+ </if>
+ </directory>
+ </if>
<if property="KDBG" value="1">
<file>kdb.c</file>
<file>kdb_cli.c</file>
</if>
<file>kdbg.c</file>
</directory>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <file>kd.c</file>
+ <file>kdmemsup.c</file>
+ </directory>
+ </if>
<file>kdinit.c</file>
<file>kdio.c</file>
<file>kdmain.c</file>
<file>page.c</file>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <file>init.c</file>
+ <file>page.c</file>
+ </directory>
+ </if>
<directory name="ARM3">
<if property="ARCH" value="i386">
<directory name="i386">
<file>psctx.c</file>
</directory>
</if>
+ <if property="ARCH" value="amd64">
+ <directory name="amd64">
+ <file>psctx.c</file>
+ </directory>
+ </if>
<file>debug.c</file>
<file>job.c</file>
<file>kill.c</file>
</directory>
<file>ntoskrnl.rc</file>
<linkerscript>ntoskrnl_$(ARCH).lnk</linkerscript>
-
- <!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38054#c7 -->
- <compilerflag compilerset="gcc">-fno-unit-at-a-time</compilerflag>
</group>