;       SCCSID = @(#)procstat.asm	6.1 90/12/10
;      SCCSID = @(#)procstat.asm	1.9 89/12/02
;
;	  IBM/Microsoft Confidential
;
;	  Copyright (c) IBM Corporation 1987, 1989
;	  Copyright (c) Microsoft Corporation 1987, 1989
;
;	  All Rights Reserved

TITLE	Stub: transforms obsolete DOSQPROCSTATUS call to Dos32QuerySysInfo call
NAME	PROCSTAT

;
;*  Title:
;*	ProcStat - Process Status
;*
;*  Author:
;*	Indira Subramanian
;*	(c) Microsoft Corporation
;*	1987
;*
;*  Description:
;*	Fill user buffer with process, thread, library, shared memory, and
;*	system semaphore information.
;*
;*  History:
;*	 1-May-1987 is	Initial version
;*	 8-May-1987 bws Bug fixes
;*	22-May-1987 is	Added shared mem and semaphores; optimizations.
;*	26-May-1987 bws Bug fixes
;*	09-Jul-1987 bws Change name of syssem equate
;*	05-Aug-1987 bws Validate user buffer, move to HIGH2CODE segment
;*	08-Jul-1988 jsf Bug fixes. 1.2 PTMs 920, 925
;*	30-Jun-1988 jsf Bug fixes. 1.2 PTM 1239
;*	30-Nov-1989 mea Gutted - now stub to call Dos32QuerySysState
; BUG CHECK INCLUDES
.xlist
include dosseg.inc
.xcref
include basemaca.inc
include osmaca.inc
include osconst.inc
include kmode.inc
.cref
.list

;MkFlat eax,ptr 		convert to 32-bit convention BUG FIX THIS

MkFlat	macro	reg,hi,lo
	?r substr <reg>,2
	ifb <lo>
	  mov	reg,hi			;;swap high/low words of eax
	  ror	reg,16			;;swap high/low words of eax
	  shr	?r,3			;;discard LDT and RPL bits
	  rol	reg,16			;;unswap high/low words of eax
	else
	  % ifidni <lo>,<?r>
	  rol	reg,16
	  endif
	  % ifdifi <hi>,<?r>
	  mov	?r,hi
	  endif
	  shr	?r,3			;;discard LDT and RPL bits
	  rol	reg,16			;;unswap high/low words of eax
	  % ifdifi <lo>,<?r>
	  mov	?r,lo
	  endif
	endif
endm

	CpuMode 386

	ReferFlat	_qsPSList,DWORD ;entity list to simulate DOSQPROCSTAT

	EXTRN32 	_QSQuerySysState

	FARCODE HIGH3
HIGH3CODE SEGMENT

;***LP	w_DosQProcStatus - return information about system resources
;
;	Transform DOsQProcStatus call to QuerySysState call
;
;	ENTRY	(AX)	Size of buffer in bytes
;		(DI)	Offset of Buffer
;		(ES)	Selector of buffer
;
;	EXIT	(AX)	Return code
;			0 = buffer is full of requested information
;
Procedure w_DosQProcStatus,faronly
    assume ds:nothing, es:nothing, ss:nothing, fs:nothing, gs:nothing

	EnterProc

	SaveReg<dx,ds,es>

	MkFlat	edx,es,di	; convert buffer pointer to flat
	movzx	eax,ax		; convert size parameter to long

	;_QSQuerySysState(elist, elevel, pid, tid, Buffer, cbBuffer)
	FlatContext <es,ds>
	CCALL32 _QSQuerySysState < [_qsPSList], 0, 0, 0, edx, eax >

	cmp	eax,1		; set carry on error return
	cmc

	RestoreReg<es,ds,dx>
	LeaveProc

	ret
EndProc w_DosQProcStatus

HIGH3CODE ends
	end
