2/03/2009

"CTS" is not supported by USBSer.sys?

The usbser.sys assumes that the device has always signaled CTS.
The RTS/CTS hardware handshaking is not implemented in usbser.sys.

1/05/2009

Layered Driver Architecture

http://msdn.microsoft.com/en-us/library/ms791644.aspx

Layered Driver Architecture

Windows operating systems support a layered driver architecture. Every device is serviced by a chain of drivers, typically called a driver stack. Each driver in the stack isolates some hardware-dependent features from the drivers above it.
The following figure shows the types of drivers that could potentially be in a driver stack for a hypothetical device. In reality, few (if any) driver stacks contain all these types of drivers.
Layered Driver Architecture
As the preceding figure shows:
Above the driver stack is an application. The application handles requests from users and other applications, and calls either the Win32 API or a routine that is exposed by the user-mode client driver.
A user-mode client driver handles requests from applications or from the Win32 API. For requests that require kernel-mode services, the user-mode client driver calls the Win32 API, which calls the appropriate kernel-mode client or support routine to carry out the request. User-mode client drivers are usually implemented as dynamic-link libraries (DLL). Printers support many operations that can be performed in user mode, and so typically have user-mode clients; disks and other storage devices, networks, and input devices do not.
A kernel-mode client driver handles requests similar to those handled by the user-mode client, except that these requests are carried out in kernel mode, rather than in user mode.
A device class and miniclass driver pair provides the bulk of the device-specific support. The class driver supplies system-required but hardware-independent support for a particular class of device. Class drivers are typically supplied by Microsoft.
A miniclass driver handles operations for a specific type of device of a particular class. For example, the battery class driver supports common operations for any battery, while a miniclass driver for a vendor's UPS device handles details unique to that particular device. Miniclass drivers are typically supplied by hardware vendors.
A corresponding port driver (for some devices, this is a host controller or host adapter driver) supports required I/O operations on an underlying port, hub, or other physical device through which the device attaches. Whether any such drivers are present depends on the type of device and the bus to which it eventually connects.
All driver stacks for storage devices have a port driver. For example, the SCSI port driver provides support for I/O over the SCSI bus.
For USB devices, a hub and host controller driver pair perform the duties of the port driver. These drivers handle I/O between the devices on the USB bus and the bus itself.
A corresponding miniport driver handles device-specific operations for the port driver. For most types of devices, the port driver is supplied with the operating system, and the miniport driver is supplied by the device vendor.
At the bottom of the figure is the hardware bus driver. Microsoft supplies bus drivers for all the major buses as part of the operating system. You should not attempt to replace these drivers.
Network drivers have their own unique terminology, defined in Windows 2000 and Later Network Architecture and the OSI Model. Nevertheless, network drivers are similarly layered, and each layer isolates device-specific or protocol-specific functionality from the layer above it.
Exactly which drivers are present, and what they are called, depends on the type of device and the bus to which it connects.
Graphics cards, for example, require a display driver, a video port driver, and a video miniport driver. The display driver is analogous to the kernel-mode client driver in the previous figure. It provides general drawing capabilities and can often work with more than one graphics card. The video port driver supports device-independent graphics operations. It works in tandem with the video miniport driver, which provides functionality that is specific to one graphics card (or a family of graphics cards). The paired video port/miniport drivers are analogous to the port/miniport drivers in the figure, and no class/miniclass drivers are present. For more information, see Display Architecture.
For simplicity, filter drivers are not shown in the previous figure. However, a filter driver can fit in at any layer of the driver stack above the hardware bus driver. A filter driver adds value to an existing driver by "filtering" — intercepting and manipulating device I/O. As a general rule, filter drivers do not operate the hardware directly, but work only on data and I/O requests passed to them from the next-higher or next-lower driver.
DirectShow, the Microsoft software for video capture, includes system-supplied filter drivers that run in user mode. These filters act as clients of the kernel-mode stream class driver to expose the underlying video capture technology.

12/29/2008

Unclassified Signature Program for WHQL signature

12.3.2.1 WHQL DTM Test Notes
As indicated in the WHQL documentation, before submitting the driver for testing you need to download Microsoft's Driver Test Manager (DTM) (http://www.microsoft.com/whdc/DevTools/WDK/DTM.mspx) and run the relevant tests for your hardware/software. After you have verified that you can successfully pass the DTM tests, create the required logs package and proceed according to Microsoft's documentation.
When running the DTM tests, note the following:
The DTM test class for WinDriver-based drivers should be Unclassified - Universal Device.
The Driver Verifier test is applied to all unsigned drivers found on the test machine. It is therefore important to try and minimize the number of unsigned drivers installed on the test PC (apart from the test driver - windrvr6.sys).
The USB Selective Suspend test requires that the depth of the under-test USB device in the USB devices tree is at least one external hub and no more than two external hubs deep.
The ACPI Stress test requires that the ACPI settings in the BIOS support the S3 power state.
Verify that the /PAE switch is added to the boot flags in the PC's boot.ini file.
The tests submission requires you to provide a *.pdb debug symbol file and an ouput of the PREfast utility (defects.xml). You can find copies of these files for the windrvr6.sys driver in the WinDriverredist directory. When selecting to rename and rebuild the windrvr6.sys driver module, as explained in section 12.2, a new debug symbols file is created for the driver. (The original defects.xml file is also applicable to the rebuilt driver).
Before submitting the file for certification you need to create a new catalog file, which lists your driver and specific INF file(s), and refer to this catalog file from your INF file(s), as explained above [12.3.2].

https://www.jungo.com/st/support/documentation/windriver/910/wdusb_man_mhtml/node71.html

FAQ for Windows Logo Program V. 3.0
https://www.microsoft.com/whdc/winlogo/VistaLogofaq.mspx


Unclassified Signature Program
https://www.microsoft.com/whdc/winlogo/drvsign/dqs.mspx

12/10/2008

DTM Audio Fidelity Test

Audio Fidelity Test:
http://msdn.microsoft.com/en-us/library/bb961150.aspx
http://www.microsoft.com/whdc/whql/audiofidelity.mspx

The training video on Fidelity Test:
http://download.microsoft.com/download/f/0/5/f05a42ce-575b-4c60-82d6-208d3754b2d6/DTM-AudioFidelityTestingLocal_Training.exe
http://download.microsoft.com/download/f/0/5/f05a42ce-575b-4c60-82d6-208d3754b2d6/DTM-AudioFidelityLogs_Training.exe

The equipment:
Windows Vista Logo Testing
http://ap.com/products/2700/vista_testing
The SYS-2722A-M
Microsoft Corporation has selected the Audio Precision SYS-2722A audio analyzer exclusively for its Windows Vista Logo Program Audio Fidelity tests.
To simplify ordering, Audio Precision has created a special product configuration of the SYS-2722A that includes all the filters and cables required by the Microsoft Driver Test Manager.

The details of test (Chinese):
http://ic.newmaker.com/art_28773.html

12/04/2008

Misc Information

1. Using Driver Verifier to identify issues with Windows drivers for advanced users
http://support.microsoft.com/kb/244617
To enable Driver Verifier by editing the registry, follow these steps: Start Registry Editor (Regedt32). Locate the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\VerifyDriversEdit the REG_SZ key.Set the REG_SZ key to the case-insensitive names of the drivers that you want to test.

2. Why CreateProcess failed in Unicode project with an access violation.
e.g:
CreateProcess( NULL, _T("test.exe"), NULL, ....) will fail with an unhandled exception in a UNICODE project.

MSDN:
The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.

3. Sometimes you may experience CreateFile failed with error code 5(Access is Denied) .
Security descriptors contain the security information associated with securable objects. For most securable objects, you can specify an object's security descriptor in the function call that creates the object.
Specifying a Security Descriptor From an INF File
http://msdn.microsoft.com/en-us/library/aa377450.aspx

For example, the following INF file snippet would create a registry key to which only administrators and the system have access. Note that this example requires administrative privileges.

 [DDInstall]
AddReg=mydevice.reg
 
[mydevice.reg]
include Registry information here
 
[mydevice.reg.Security]
"D:P(A;CI;GA;;;BA)(A;CI;GA;;;SY)"

SDDL for Device Objects
http://msdn.microsoft.com/en-us/library/ms794693.aspx

11/28/2008

How To Get PCMCIA Socket Information

The sample code performs the following steps:
Uses the IoGetDeviceObjectPointer function to obtain the device object and corresponding file object.
Initializes the PCMCIA_SOCKET_INFORMATION structure for the socket for which the information is sought.
Uses the IoBuildDeviceIoControlRequest function to allocate and set up an I/O request packet (IRP) for a device control request (the IOCTL_SOCKET_INFORMATION structure). This request should be sent at PASSIVE_LEVEL to the PCMCIA bus driver.
Passes the IRP down and waits for the result.

http://support.microsoft.com/kb/256161/en-us/

=============
This method is obsolete in Vista. Under Vista, PCMCIA device is no longer a named device object, (it's Securing Device Object now).


Maybe we can refer to “ntddpcm.h” under \winddk\version\inc\ddk, to turn on PCMCIA interface.

// Note: The IOCTL interface to pcmcia host controllers is turned off by
// default. These IOCTLs are provided for testing purposes only. To
// turn on this interface, add the following registry value:
// HKLM\SYSTEM\CurrentControlSet\Services\Pcmcia\Parameters\IoctlInterface : REG_DWORD : 1
//

#define IOCTL_PCMCIA_BASE FILE_DEVICE_CONTROLLER

#define DD_PCMCIA_DEVICE_NAME \\\\.\\Pcmcia

//
// IoControlCode values for this device.
//

#define IOCTL_GET_TUPLE_DATA CTL_CODE(IOCTL_PCMCIA_BASE, 3000, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_SOCKET_INFORMATION CTL_CODE(IOCTL_PCMCIA_BASE, 3004, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_PCMCIA_HIDE_DEVICE CTL_CODE(IOCTL_PCMCIA_BASE, 3010, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_PCMCIA_REVEAL_DEVICE CTL_CODE(IOCTL_PCMCIA_BASE, 3011, METHOD_BUFFERED, FILE_WRITE_ACCESS)

http://msdn.microsoft.com/en-us/library/ms789729.aspx
The PCMCIA IOCTL interface is enabled only if HKLM\SYSTEM\CurrentControlSet\Services\Pcmcia\Parameters\IoctlInterface (REG_DWORD) is set to 1. The IOCTL interface is turned off by default. This is valid for Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008.

11/06/2008

Banned API in Windows

http://download.microsoft.com/download/2/e/b/2ebac853-63b7-49b4-b66f-9fd85f37c0f5/banned.h
/***
* banned.h - list of Microsoft Security Development Lifecycle banned APIs
*
* Purpose:
* This include file contains a list of banned API which should not be used in new code and
* removed from legacy code over time
* History
* 01-Jan-2006 - mikehow - Initial Version
* 22-Apr-2008 - mikehow - Updated to SDL 4.1, commented out recommendations and added memcpy
*
***/
#ifndef _INC_BANNED
# define _INC_BANNED
#endif
#ifdef _MSC_VER
// Some of these functions are Windows specific
# pragma once
# pragma deprecated (strcpy, strcpyA, strcpyW, wcscpy, _tcscpy, _mbscpy, StrCpy, StrCpyA, StrCpyW, lstrcpy, lstrcpyA, lstrcpyW, _tccpy, _mbccpy)
# pragma deprecated (strcat, strcatA, strcatW, wcscat, _tcscat, _mbscat, StrCat, StrCatA, StrCatW, lstrcat, lstrcatA, lstrcatW, StrCatBuff, StrCatBuffA, StrCatBuffW, StrCatChainW, _tccat, _mbccat)
# pragma deprecated (wnsprintf, wnsprintfA, wnsprintfW, sprintfW, sprintfA, wsprintf, wsprintfW, wsprintfA, sprintf, swprintf, _stprintf, _snwprintf, _snprintf, _sntprintf)
# pragma deprecated (wvsprintf, wvsprintfA, wvsprintfW, vsprintf, _vstprintf, vswprintf)
# pragma deprecated (_vsnprintf, _vsnwprintf, _vsntprintf, wvnsprintf, wvnsprintfA, wvnsprintfW)
# pragma deprecated (strncpy, wcsncpy, _tcsncpy, _mbsncpy, _mbsnbcpy, StrCpyN, StrCpyNA, StrCpyNW, StrNCpy, strcpynA, StrNCpyA, StrNCpyW, lstrcpyn, lstrcpynA, lstrcpynW)
# pragma deprecated (strncat, wcsncat, _tcsncat, _mbsncat, _mbsnbcat, StrCatN, StrCatNA, StrCatNW, StrNCat, StrNCatA, StrNCatW, lstrncat, lstrcatnA, lstrcatnW, lstrcatn)
# pragma deprecated (strtok, _tcstok, wcstok, _mbstok)
# pragma deprecated (makepath, _tmakepath, _makepath, _wmakepath)
# pragma deprecated (_splitpath, _tsplitpath, _wsplitpath)
# pragma deprecated (scanf, wscanf, _tscanf, sscanf, swscanf, _stscanf, snscanf, snwscanf, _sntscanf)
//# pragma deprecated (_itoa, _itow, _i64toa, _i64tow, _ui64toa, _ui64tot, _ui64tow, _ultoa, _ultot, _ultow)
# pragma deprecated (gets, _getts, _gettws)
# pragma deprecated (IsBadWritePtr, IsBadHugeWritePtr, IsBadReadPtr, IsBadHugeReadPtr, IsBadCodePtr, IsBadStringPtr)
# pragma deprecated (CharToOem, CharToOemA, CharToOemW, OemToChar, OemToCharA, OemToCharW, CharToOemBuffA, CharToOemBuffW)
//# pragma deprecated (alloca, _alloca)
# pragma deprecated (strlen, wcslen, _mbslen, _mbstrlen, StrLen, lstrlen)
# pragma deprecated (memcpy, RtlCopyMemory, CopyMemory)
#else
#ifdef __GNUC__
// Some of these functions are Windows specific, so you may want to add *nix specific banned function calls
# pragma GCC poison strcpy strcpyA strcpyW wcscpy _tcscpy _mbscpy StrCpy StrCpyA StrCpyW lstrcpy lstrcpyA lstrcpyW _tccpy _mbccpy
# pragma GCC poison strcat strcatA strcatW wcscat _tcscat _mbscat StrCat StrCatA StrCatW lstrcat lstrcatA lstrcatW StrCatBuff StrCatBuffA StrCatBuffW StrCatChainW _tccat _mbccat
# pragma GCC poison wnsprintf wnsprintfA wnsprintfW sprintfW sprintfA wsprintf wsprintfW wsprintfA sprintf swprintf _stprintf _snwprintf _snprintf _sntprintf
# pragma GCC poison wvsprintf wvsprintfA wvsprintfW vsprintf _vstprintf vswprintf
# pragma GCC poison _vsnprintf _vsnwprintf _vsntprintf wvnsprintf wvnsprintfA wvnsprintfW
# pragma GCC poison strncpy wcsncpy _tcsncpy _mbsncpy _mbsnbcpy StrCpyN StrCpyNA StrCpyNW StrNCpy strcpynA StrNCpyA StrNCpyW lstrcpyn lstrcpynA lstrcpynW
# pragma GCC poison strncat wcsncat _tcsncat _mbsncat _mbsnbcat StrCatN StrCatNA StrCatNW StrNCat StrNCatA StrNCatW lstrncat lstrcatnA lstrcatnW lstrcatn
# pragma GCC poison strtok _tcstok wcstok _mbstok
# pragma GCC poison makepath _tmakepath _makepath _wmakepath
# pragma GCC poison _splitpath _tsplitpath _wsplitpath
# pragma GCC poison scanf wscanf _tscanf sscanf swscanf _stscanf snscanf snwscanf _sntscanf
//# pragma GCC poison _itoa _itow _i64toa _i64tow _ui64toa _ui64tot _ui64tow _ultoa _ultot _ultow
# pragma GCC poison gets _getts _gettws
# pragma GCC poison IsBadWritePtr IsBadHugeWritePtr IsBadReadPtr IsBadHugeReadPtr IsBadCodePtr IsBadStringPtr
# pragma GCC poison CharToOem CharToOemA CharToOemW OemToChar OemToCharA OemToCharW CharToOemBuffA CharToOemBuffW
//# pragma GCC poison alloca _alloca
# pragma GCC poison strlen wcslen _mbslen _mbstrlen StrLen lstrlen
# pragma GCC poison memcpy RtlCopyMemory CopyMemory
#endif
#endif /* _INC_BANNED */

10/19/2008

How to get you NIC MAC address

Here is a good reference, Thanks Khalid!
http://www.codeguru.com/Cpp/I-N/network/networkinformation/article.php/c5451/

Here is my code, just a little modification on Khaild's:



9/24/2008

How to "Refresh" Device Manager by programming

We are talking about: Device Manager->Action->Scan for hardware changes
The following CM APIs should work:



9/22/2008

Error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)"

Error 2 error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z) referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ) main.obj CPUTest

I met this error when programming a WMI C++ query application.

Research:
MSDN Says :When calling a function in a static library or DLL that takes a wchar_t type (note that BSTR and LPWSTR resolve to wchar_t*), you may get an LNK2001 unresolved external symbol error.This error is caused by the /Zc:wchar_t compiler option, which is set to on by default in new MFC projects. This option causes the compiler to treat wchar_t as a native type. Before Visual C++ .NET, wchar_t was treated as an unsigned short.If the main project and library do not use the same setting for /Zc:wchar_t, this will cause a mismatch of function signatures. To avoid this problem, rebuild the library with the /Zc:wchar_t compiler option, or turn it off in the main project using the Treat wchar_t as Built-in Type setting on the Language property page in the Property Pages dialog box.

Solution:
Add this:
#ifdef _DEBUG
# pragma comment(lib, "comsuppwd.lib")
#else
# pragma comment(lib, "comsuppw.lib")
#endif
# pragma comment(lib, "wbemuuid.lib")


Reference:
ConvertStringToBSTR
http://msdn.microsoft.com/en-us/library/t58y75c0.aspx