sysdetmg.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 849 行 · 第 1/2 页
H
849 行
/***MD sysdetmg.h - System Detection Manager definitions
*
* This module contains System Detection Manager definitions including
* Detection Module Services definitions and Module Function definitions.
*
* Copyright (c) 1992,1993 Microsoft Corporation
* Author: Michael Tsang (MikeTs)
* Created 12/10/92
*
* MODIFICATION HISTORY
*/
#ifndef _INC_SYSDETMG
#define _INC_SYSDETMG
/* do not complain about in-line comment and pragma use in windows.h */
#pragma warning(disable:4001 4103 4705)
#include <sdmerror.h>
#ifdef CALLCM //only do this hack if we need to call CM
#define WINVER 0x030a //system detection can be run under win31
#include <windows.h>
// Windows.h defines the following set of things for old reg users, whose
// WINVER is less than 0x0400. Normally this is not a problem, but SYSDETMG
// is a special DLL whose winver is 0x030a, but we really use Win4.0 reg
// error codes, so we need to pick up the defines in WINERROR.H, so this
// prevents macro redef warnings.
#ifdef ERROR_SUCCESS
#undef ERROR_SUCCESS
#endif
#ifdef ERROR_BADDB
#undef ERROR_BADDB
#endif
#ifdef ERROR_BADKEY
#undef ERROR_BADKEY
#endif
#ifdef ERROR_CANTOPEN
#undef ERROR_CANTOPEN
#endif
#ifdef ERROR_CANTREAD
#undef ERROR_CANTREAD
#endif
#ifdef ERROR_CANTWRITE
#undef ERROR_CANTWRITE
#endif
#ifdef ERROR_INSUFFICIENT_MEMORY
#undef ERROR_INSUFFICIENT_MEMORY
#endif
#ifdef ERROR_INVALID_PARAMETER
#undef ERROR_INVALID_PARAMETER
#endif
#ifdef ERROR_ACCESS_DENIED
#undef ERROR_ACCESS_DENIED
#endif
#ifdef HKEY_CLASSES_ROOT
#undef HKEY_CLASSES_ROOT
#endif
#ifndef REG_BINARY
#define REG_BINARY 0x0003
#endif
#ifndef HKEY_CURRENT_CONFIG
#define HKEY_CURRENT_CONFIG ((HKEY)0x80000005)
#endif
#ifndef HKEY_LOCAL_MACHINE
#define HKEY_LOCAL_MACHINE ((HKEY)0x80000002)
#endif
#else //ifdef SYSDETMG
#include <windows.h>
#endif
#include <winerror.h>
#define NOPRSHT //do not include prsht.h
#pragma warning(disable: 4201 4209)
#include <setupx.h>
#pragma warning(default: 4201 4209)
#include <string.h>
/*** String macros
*/
#define LSTRCAT _fstrcat
#define LSTRCATN _fstrncat
#define LSTRCHR _fstrchr
#define LSTRCHRR _fstrrchr
#define LSTRCMP _fstrcmp
#define LSTRCMPI _fstricmp
#define LSTRCMPN _fstrncmp
#define LSTRCMPNI _fstrnicmp
#define LSTRCPY _fstrcpy
#define LSTRCPYN _fstrncpy
#define LSTRLEN lstrlen //C run-time _fstrlen has bug
#define LSTRSTR _fstrstr
#define LSTRTOK _fstrtok
#define LSTRUPR _fstrupr
/*** Miscellaneou macros
*/
#define BYTEOF(d,i) (((BYTE *)&(d))[i])
#define WORDOF(d,i) (((WORD *)&(d))[i])
#define LOCAL PASCAL FAR
#define LOCALC CDECL FAR
#define DLLENTRY _loadds WINAPI
#define DEREF(x) ((x) = (x))
#define ALLOC(cb) MAKELP(GlobalAlloc(GHND, (cb)), 0)
#define FREE(lp) GlobalFree((HANDLE)SELECTOROF(lp))
#define CONSTSEG _based(_segname("_CODE"))
#define SZFORMAT lszFormat
#define CATMSG(s,p) { \
static char CONSTSEG SZFORMAT[] = s; \
CatMsg p; \
}
#define CATERR(rc,s,p) {if (rc) CATMSG(s, p);}
#define DMSERR(rc) ((((rc) & 0xffff) << 16) | MODERR_SDMERR)
#define REGERR(rc) ((((rc) & 0xffff) << 16) | MODERR_REGERR)
#ifdef DEBUG
#define ENTER(s,p) { \
static char CONSTSEG SZFORMAT[] = s; \
EnterProc p; \
}
#define EXIT(s,p) { \
static char CONSTSEG SZFORMAT[] = s; \
ExitProc p; \
}
#define PRINTTRACE(s,p) { \
static char CONSTSEG SZFORMAT[] = s; \
PrintTrace p; \
}
#else
#define ENTER(s,p)
#define EXIT(s,p)
#define PRINTTRACE(s,p)
#endif
/*** Implementation constants
*/
#define MAX_PATHNAME_LEN (MAX_PATH_LEN - 1) //max. path length
#define MAX_CLASSNAME_LEN 15 //max. length of device class name
#define MAX_FUNCNAME_LEN 31 //max. length of function name
#define MAX_DEVNAME_LEN 31 //max. length of device name
#define MAX_INSTNAME_LEN 15 //device instance name length
#define MAX_DOSDEVNAME_LEN 8 //dos device name length
#define MAX_PARAMLINE_LEN 63 //TSR parameter line length
#define MAX_DESC_LEN 63 //max. description length
#define MAX_LINE_LEN 127 //max. line length
#define MAX_BUFF_LEN 255 //max. buffer length
/*** Callback function error
*/
#define DCBERR_NONE 0x00000000 //no error
#define DCBERR_ABORT 0x80000001 //abort detection
/*** Other constants
*/
#define STR_INFNAME_MSDETINF "msdet.inf" //main detection INF name
//dwfDetOpen flags
#define DOF_OPENFLAG_MASK 0x0007ffffL
#define DOF_LOGLEVEL_MASK 0x00000003L
#define DOF_LOGLEVEL_NONE 0x00000000L
#define DOF_LOGLEVEL_MINIMUM 0x00000001L
#define DOF_LOGLEVEL_NORMAL 0x00000002L
#define DOF_LOGLEVEL_MAXIMUM 0x00000003L
#define DOF_PROGRESS_MASK 0x0000000cL
#define DOF_PROGRESS_NONE 0x00000000L
#define DOF_PROGRESS_MINIMUM 0x00000004L
#define DOF_PROGRESS_NORMAL 0x00000008L
#define DOF_PROGRESS_MAXIMUM 0x0000000cL
#define DEF_LOGLEVEL DOF_LOGLEVEL_MAXIMUM
#define DEF_PROGRESS DOF_PROGRESS_MINIMUM
#define DOF_SAFECLASSDET 0x00000010L //safe class detection
#define DOF_SAFE 0x00000020L //safe detection mode
#define DOF_CLEANREG 0x00000040L //clean hw from registry
#define DOF_NORECOVER 0x00000080L //disable crash recovery
#define DOF_PROMPTBEFORE 0x00000100L //prompt before detect
#define DOF_INSETUP 0x00000200L //called by Setup
#define DOF_LOGPERFORMANCE 0x00000400L //enable performance logging
#define DOF_QUIET 0x00000800L //enable quiet mode
#define DOF_VERIFYONLY 0x00001000L //do only device verification
#define DOF_DORECOVERY 0x00002000L //process detcrash.log
#define DOF_MINIWIN 0x00004000L //running under mini windows
#define DOF_IGNORE_PNPBIOS 0x00008000L //do not detect PnP BIOS
#define DOF_ENFORCE_PNPBIOS 0x00010000L //do detect PnP BIOS
#define DOF_NOSAFESTART_CHECK 0x00020000L //don't check safe start
#define DOF_VERIFYTOPBUS 0x00040000L //verify only top bus
//dwfDetect flags
#define DETF_SAFE 0x00010000L //safe detection
#define DETF_VERIFY 0x00020000L //verify mode
#define DETF_QUIET 0x00040000L //quiet mode
#define DETF_MINIWIN 0x00080000L //running under mini windows
#define DETF_INSETUP 0x00100000L //detection called by Setup
#define DETF_IGNORE_PNPBIOS 0x00200000L //do not detect PnP BIOS
#define DETF_EXCLENUMDEVS 0x00000001L //force exclude enumdev res.
#define DETF_VERIFYONLY 0x00000002L //do verification only
#define DETF_ENFORCE_PNPBIOS 0x00000004L //do detect PnP BIOS
//dwCallBackContext
#define CBC_DETECTTOTAL 1 //total number of detection funcs.
#define CBC_DETECTPROGRESS 2 //detection progress
#ifdef JAPAN
#define CBC_DETECTJKBD 9999
#endif // JAPAN
//dwfMem flags
#define MF_REALADDR 0x00000001 //real mode address
#define MF_PHYSICALMEM 0x00000002 //physical memory
#define MF_IGNORECASE 0x00000004 //case insensitive search
#define MF_PMADDR 0x00000008 // 32-bit protected mode address
//wfQuery flags
#define QF_PREFIXMATCH 0x00000001 //match key as prefix
//dwResType values
#define RESTYPE_IO 1 //I/O resource
#define RESTYPE_MEM 2 //memory resource
#define RESTYPE_IRQ 3 //irq resource
#define RESTYPE_DMA 4 //dma resource
#define RESTYPE_MAX 4 //max resource type
#define RESTYPE_TYPEMASK 0x00ff //resource type mask
#define RESTYPE_ADDITIONAL 0x8000 //additional resource
//Return values of DMSQueryIOMem or DMSQueryIRQDMA
#define RES_NOMATCH 0 //resources have no owner
#define RES_OVERLAP 1 //resources overlap with existing owner
#define RES_MATCH 2 //resources match with existing owner
#define RES_SHARED 3 //resources are shareable by the owner
#define RES_SUPERSET 4 //resources are superset of existing owner
#define RES_MATCHCRASH 5 //resources matched with crash resources
/*** Function type definitions
*/
#define HANDLE_NULL 0 //null handle
typedef DWORD HDET; //detection handle
typedef DWORD HDEV; //device handle
typedef LONG (DLLENTRY *LPFNDET)(HDET, DWORD, DWORD);
typedef LONG (FAR PASCAL _loadds *LPFNDCB)(DWORD, DWORD, DWORD);
typedef VOID (FAR PASCAL _loadds *LPFNICB)(WORD, DWORD);
typedef VOID (FAR PASCAL *LPFNGEN)();
typedef DWORD (FAR PASCAL _loadds *LPFNPROC)();
/*** Structure and related definitions
*/
typedef union _REGS FAR *LPREGS;
typedef struct _SREGS FAR *LPSREGS;
#define SYSENVF_EISASYSTEM 0x00000001
#define SYSENVF_MCASYSTEM 0x00000002
#define MACHINFO_MCABUS 0x02000000 //machine has MCA bus
#define MACHINFO_EXTBIOSAREA 0x04000000 //extended BIOS area allocated
#define MACHINFO_WAITEXTEVENT 0x08000000 //wait ext. event supported
#define MACHINFO_INT154FCALLOUT 0x10000000 //int15/4f callout at int09
#define MACHINFO_CMOSRTC 0x20000000 //CMOS/RTC installed
#define MACHINFO_PIC2 0x40000000 //2nd PIC
#define MACHINFO_HDDMA3 0x80000000 //hard disk BIOS using DMA3
typedef struct sysenv_s
{
DWORD dwSDMVersion; //byte 0,1=build number
//byte 2=version minor
//byte 3=version major
DWORD dwWinVer; //byte 0=winver minor
//byte 1=winver major
//byte 2=dosver minor
//byte 3=dosver major
DWORD dwWin95Build; //Windows 95 build number
DWORD dwWinFlags; //WinFlags from GetWinFlags
DWORD dwMachineInfo; //byte 0=model
//byte 1=sub-model
//byte 2=BIOS revision
//byte 3=features
DWORD dwfSysEnv; //system environment flags
DWORD dwfSysDet; //system detection flags (DOF)
char szInfPath[MAX_PATHNAME_LEN + 1]; //detection path string
} SYSENV;
typedef SYSENV *PSYSENV;
typedef SYSENV FAR *LPSYSENV;
typedef struct resinfo_s
{
int icIO; //number of I/O resource regions
int ioffsetIO; //offset of I/O resource array
int icMem; //number of memory resource regions
int ioffsetMem; //offset of memory resource array
int icIRQ; //number of IRQs
int ioffsetIRQ; //offset of IRQ resource array
int icDMA; //number of DMAs
int ioffsetDMA; //offset of DMA resource array
int icbResBuff; //resource buffer size that follows
// IOMEM and/or IRQDMA array follows here
} RESINFO;
typedef RESINFO *PRESINFO;
typedef RESINFO FAR *LPRESINFO;
typedef struct ownerinfo_s
{
char szClassName[MAX_CLASSNAME_LEN + 1]; //owner's class name
char szDevName[MAX_DEVNAME_LEN + 1]; //owner's device name
HDEV hdevOwner; //owner's device handle
LPRESINFO lpresinfo; //resource info.
} OWNERINFO;
typedef OWNERINFO *POWNERINFO;
typedef OWNERINFO FAR *LPOWNERINFO;
typedef struct iomem_s
{
DWORD dwStartAddr; //region starting address
DWORD dwEndAddr; //region ending address
DWORD dwDecodeMask; //decode mask (don't care aliases)
DWORD dwAliasMask; //alias mask (used aliases)
DWORD dwResAttr; //region attributes
} IOMEM;
typedef IOMEM *PIOMEM;
typedef IOMEM FAR *LPIOMEM;
typedef struct irqdma_s
{
DWORD dwResNum; //IRQ or DMA number
DWORD dwResAttr; //attributes for this IRQ or DMA
} IRQDMA;
typedef IRQDMA *PIRQDMA;
typedef IRQDMA FAR *LPIRQDMA;
//dwfDev flags
#define DEVF_CHARDEV 0x00000001 //lpstrDevName is a char dev name
//wfDev flags
#define DDF_INBOOTCONFIG 0x0001 //device is in boot config section
typedef struct dosdev_s
{
char szFileName[MAX_DOSDEVNAME_LEN + 1];//driver filename w/o .ext
char szDevName[MAX_DOSDEVNAME_LEN + 1];//device name
char szCfgSysLine[MAX_BUFF_LEN + 1];//<path><file><param>
char szCfgSysSect[MAX_LINE_LEN + 1];//boot config section name
LPSTR lpstrPath; //device path (in szCfgSysLine)
LPSTR lpstrFile; //device file (in szCfgSysLine)
LPSTR lpstrParam; //device param (in szCfgSysLine)
WORD wfDevAttr; //device attribute
WORD wcUnits; //number of block dev units
WORD wbitIRQs; //IRQ bit vector used by dev.
WORD wfDev; //device flags
DWORD dwDevHdrPtr; //pointer to device header
DWORD dwNextDevHdrPtr; //pointer to next in chain
} DOSDEV;
typedef DOSDEV *PDOSDEV;
typedef DOSDEV FAR *LPDOSDEV;
typedef struct dostsr_s
{
char szPathName[MAX_PATHNAME_LEN + 1];//TSR full path name
char szMCBOwner[9];
char chMCBType;
WORD segTSRPSP; //TSR's segment address
WORD wcparaTSRSize; //TSR's size in paragrahs
WORD segParentPSP;
WORD wbitIRQs; //IRQ bit vector used by TSR
char szParamLine[MAX_PARAMLINE_LEN + 1];//TSR's parameter line
DWORD dwMCBPtr; //MCB pointer
DWORD dwNextMCBPtr; //the seg addr of next MCB
} DOSTSR;
typedef DOSTSR *PDOSTSR;
typedef DOSTSR FAR *LPDOSTSR;
#define FUNC_CALLED 0x00000001 //function has been called
#define FUNC_DISABLED 0x00000002 //function is disabled
#define FUNC_DESELECT 0x00000004 //function is deselected
typedef DWORD HFUNC;
typedef struct funcstate_s
{
char szFuncName[MAX_FUNCNAME_LEN + 1];
char szFuncDesc[MAX_DESC_LEN + 1];
char szClassName[MAX_CLASSNAME_LEN + 1];
char szClassDesc[MAX_DESC_LEN + 1];
DWORD dwfFunc;
HFUNC hFunc;
} FUNCSTATE;
typedef FUNCSTATE FAR *LPFUNCSTATE;
#define CLASS_SKIPPED 0x00000001 //class has been skipped
typedef DWORD HCLASS;
typedef struct classstate_s
{
char szClassName[MAX_CLASSNAME_LEN + 1];
char szClassDesc[MAX_DESC_LEN + 1];
DWORD dwfClass;
HCLASS hClass;
} CLASSSTATE;
typedef CLASSSTATE FAR *LPCLASSSTATE;
#define MAX_MCA_SLOTS 8
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?