<linkerflag>--unique=.eh_frame</linkerflag>
<linkerflag>-static</linkerflag>
<linkerflag>-fno-leading-underscore</linkerflag>
+ <linkerflag>-shared</linkerflag>
<linkerflag>--exclude-all-symbols</linkerflag>
</group>
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
+#ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
+#define _TIMEZONE_DEFINED
struct timezone {
- int tz_minuteswest; /* minutes W of Greenwich */
- int tz_dsttime; /* type of dst correction */
+ int tz_minuteswest;
+ int tz_dsttime;
};
-int gettimeofday(struct timeval *tv, struct timezone *tz);
+ extern int __cdecl gettimeofday (struct timeval *p, struct timezone *z);
+#endif
<include base="ftp">.</include>
<define name="lint" />
- <!-- FIXME: workarounds until we have a proper oldnames library -->
- <define name="chdir">_chdir</define>
- <define name="getcwd">_getcwd</define>
- <define name="mktemp">_mktemp</define>
- <define name="unlink">_unlink</define>
- <define name="close">_close</define>
- <define name="fileno">_fileno</define>
- <define name="read">_read</define>
- <define name="write">_write</define>
- <define name="lseek">_lseek</define>
-
<library>ws2_32</library>
<library>iphlpapi</library>
+ <library>oldnames</library>
<file>cmds.c</file>
<file>cmdtab.c</file>
<file>domacro.c</file>
<include base="dhcp">.</include>
<include base="dhcp">include</include>
- <!-- FIXME: workarounds until we have a proper oldnames library -->
- <define name="tzset">_tzset</define>
- <define name="close">_close</define>
- <define name="read">_read</define>
- <define name="write">_write</define>
-
<library>ntdll</library>
<library>ws2_32</library>
<library>iphlpapi</library>
<library>advapi32</library>
+ <library>oldnames</library>
<file>adapter.c</file>
<file>alloc.c</file>
<file>api.c</file>
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<installfile installbase="system32/drivers/etc">quotes</installfile>
<module name="tcpsvcs" type="win32cui" installbase="system32" installname="tcpsvcs.exe" unicode="yes">
<include base="arp">.</include>
<library>ws2_32</library>
<file>explorer.rc</file>
<linkerflag>--enable-stdcall-fixup</linkerflag>
</module>
-<installfile>explorer-cfg-template.xml</installfile>
+<installfile installbase=".">explorer-cfg-template.xml</installfile>
<directory name="notifyhook">
<xi:include href="notifyhook/notifyhook.rbuild" />
</directory>
<property name="BASEADDRESS_PSTOREC" value="0x513d0000" />
<property name="BASEADDRESS_LPK" value="0x516c0000" />
<property name="BASEADDRESS_MSGSM32ACM" value="0x56db0000" />
+ <property name="BASEADDRESS_MSDVBNP" value="0x58280000" />
<property name="BASEADDRESS_MSG711ACM" value="0x584f0000" />
<property name="BASEADDRESS_IMAADP32ACM" value="0x585e0000" />
<property name="BASEADDRESS_BDAPLGIN" value="0x58600000" />
<property name="BASEADDRESS_MMSYS" value="0x588a0000" />
<property name="BASEADDRESS_JOY" value="0x589b0000" />
<property name="BASEADDRESS_QMGR" value="0x59620000" />
+ <property name="BASEADDRESS_MSVIDCTL" value="0x59660000" />
<property name="BASEADDRESS_UXTHEME" value="0x5ad70000" />
<property name="BASEADDRESS_VDMDBG" value="0x5b0d0000" />
<property name="BASEADDRESS_UNTFS" value="0x5b340000" />
+++ /dev/null
-[Version]
-Signature = "$ReactOS$"
-
-[AddReg]
-; Enable _one_ driver per section by removing the leading semicolon.
-
-;
-; Display driver section
-;
-
-; VBE SVGA driver
-HKLM,"SYSTEM\CurrentControlSet\Services\VBE","Start",0x00010001,0x00000001
-HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\VBE\Device0","DefaultSettings.VRefresh",0x00010001,1
-HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\VBE\Device0","DefaultSettings.BitsPerPel",0x00010001,16
-HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\VBE\Device0","DefaultSettings.XResolution",0x00010001,800
-HKLM,"SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\VBE\Device0","DefaultSettings.YResolution",0x00010001,600
-
-; VGA miniport driver
-HKLM,"SYSTEM\CurrentControlSet\Services\Vga","Start",0x00010001,0x00000001
--- /dev/null
+; Main ReactOS package
+
+.Set DiskLabelTemplate="ReactOS" ; Label of disk
+.Set CabinetNameTemplate="reactos.cab" ; reactos.cab
+.Set InfFileName="reactos.inf" ; reactos.inf
+
+
+;.Set Cabinet=on
+;.Set Compress=on
+
+.InfBegin
+[Version]
+Signature = "$ReactOS$"
+
+[Directories]
+1 = system32
+2 = system32\drivers
+3 = Fonts
+4 =
+5 = system32\drivers\etc
+6 = inf
+7 = bin
+8 = media
+
+.InfEnd
+
+; Contents of disk
+.InfBegin
+[SourceFiles]
+.InfEnd
+
+
+; Base files
+base\applications\cacls\cacls.exe 1
+base\applications\calc\calc.exe 1
+base\applications\charmap\charmap.exe 1
+base\applications\cmdutils\dbgprint\dbgprint.exe 1
+base\applications\cmdutils\doskey\doskey.exe 1
+base\applications\cmdutils\find\find.exe 1
+base\applications\cmdutils\hostname\hostname.exe 1
+base\applications\cmdutils\lodctr\lodctr.exe 1
+base\applications\cmdutils\more\more.exe 1
+base\applications\cmdutils\reg\reg.exe 1
+base\applications\cmdutils\xcopy\xcopy.exe 1
+base\applications\control\control.exe 1
+base\applications\dxdiag\dxdiag.exe 1
+base\applications\fontview\fontview.exe 1
+base\applications\mscutils\devmgmt\devmgmt.exe 1
+base\applications\mscutils\eventvwr\eventvwr.exe 1
+base\applications\games\solitaire\sol.exe 1
+base\applications\games\spider\spider.exe 1
+base\applications\games\winemine\winemine.exe 1
+base\applications\hh\hh.exe 4
+base\applications\kbswitch\kbswitch.exe 1
+base\applications\kbswitch\kbsdll\kbsdll.dll 1
+base\applications\logoff\logoff.exe 1
+base\applications\magnify\magnify.exe 1
+base\applications\mplay32\mplay32.exe 1
+base\applications\msconfig\msconfig.exe 1
+base\applications\mstsc\mstsc.exe 1
+base\applications\network\arp\arp.exe 1
+base\applications\network\dwnl\dwnl.exe 1
+base\applications\network\route\route.exe 1
+base\applications\network\finger\finger.exe 1
+base\applications\network\ftp\ftp.exe 1
+base\applications\network\ipconfig\ipconfig.exe 1
+base\applications\network\netstat\netstat.exe 1
+base\applications\network\nslookup\nslookup.exe 1
+base\applications\network\ping\ping.exe 1
+base\applications\network\telnet\telnet.exe 1
+base\applications\network\tracert\tracert.exe 1
+base\applications\network\whois\whois.exe 1
+base\applications\notepad\notepad.exe 1
+base\applications\paint\paint.exe 1
+base\applications\rapps\rapps.exe 1
+base\applications\regedit\regedit.exe 4
+base\applications\regedit\clb\clb.dll 1
+base\applications\regedt32\regedt32.exe 1
+base\applications\sc\sc.exe 1
+base\applications\screensavers\3dtext\3dtext.scr 1
+base\applications\screensavers\logon\logon.scr 1
+base\applications\mscutils\servman\servman.exe 1
+base\applications\shutdown\shutdown.exe 1
+base\applications\sndrec32\sndrec32.exe 1
+base\applications\sndvol32\sndvol32.exe 1
+base\applications\taskmgr\taskmgr.exe 1
+base\applications\winhlp32\winhlp32.exe 4
+base\applications\winver\winver.exe 1
+base\applications\wordpad\wordpad.exe 1
+base\applications\write\write.exe 1
+
+base\services\audiosrv\audiosrv.exe 1
+base\services\dhcp\dhcp.exe 1
+base\services\eventlog\eventlog.exe 1
+base\services\rpcss\rpcss.exe 1
+base\services\spoolsv\spoolsv.exe 1
+base\services\tcpsvcs\tcpsvcs.exe 1
+base\services\telnetd\telnetd.exe 1
+base\services\tcpsvcs\quotes 5
+base\services\umpnpmgr\umpnpmgr.exe 1
+base\services\wlansvc\wlansvc.exe 1
+base\services\svchost\svchost.exe 1
+
+base\setup\setup\setup.exe 1
+base\setup\vmwinst\vmwinst.exe 1
+
+base\shell\cmd\cmd.exe 1
+base\shell\explorer\explorer.exe 4
+base\shell\explorer\explorer-cfg-template.xml 4
+base\shell\explorer\notifyhook\notifyhook.dll 1
+base\shell\explorer-new\explorer_new.exe 4 optional
+
+base\system\autochk\autochk.exe 1
+base\system\bootok\bootok.exe 1
+base\system\format\format.exe 1
+base\system\lsass\lsass.exe 1
+base\system\msiexec\msiexec.exe 1
+base\system\regsvr32\regsvr32.exe 1
+base\system\rundll32\rundll32.exe 1
+base\system\runonce\runonce.exe 1
+base\system\services\services.exe 1
+base\system\userinit\userinit.exe 1
+base\system\winlogon\winlogon.exe 1
+base\system\expand\expand.exe 1
+base\system\smss\smss.exe 1
+
+
+; Dynamic Link Libraries
+dll\3rdparty\mesa32\mesa32.dll 1
+dll\3rdparty\libjpeg\libjpeg.dll 1
+dll\3rdparty\libxslt\libxslt.dll 1
+dll\3rdparty\dxtn\dxtn.dll 1 optional
+
+dll\cpl\access\access.cpl 1
+dll\cpl\appwiz\appwiz.cpl 1
+dll\cpl\console\console.dll 1
+dll\cpl\desk\desk.cpl 1
+dll\cpl\hdwwiz\hdwwiz.cpl 1
+dll\cpl\input\input.dll 1
+dll\cpl\intl\intl.cpl 1
+dll\cpl\joy\joy.cpl 1
+;dll\cpl\liccpa\liccpa.cpl 1
+dll\cpl\main\main.cpl 1
+dll\cpl\mmsys\mmsys.cpl 1
+dll\cpl\ncpa\ncpa.cpl 1
+;dll\cpl\odbccp32\odbccp32.cpl 1
+dll\cpl\powercfg\powercfg.cpl 1
+dll\cpl\sysdm\sysdm.cpl 1
+;dll\cpl\telephon\telephon.cpl 1
+dll\cpl\timedate\timedate.cpl 1
+;dll\cpl\usrmgr\usrmgr.cpl 1
+
+dll\directx\amstream\amstream.dll 1
+dll\directx\bdaplgin\bdaplgin.ax 1
+dll\directx\dinput\dinput.dll 1
+dll\directx\dinput8\dinput8.dll 1
+dll\directx\dmusic\dmusic.dll 1
+dll\directx\dplay\dplay.dll 1
+dll\directx\dplayx\dplayx.dll 1
+dll\directx\dsound\dsound.dll 1
+dll\directx\dxdiagn\dxdiagn.dll 1
+dll\directx\wine\ddraw\ddraw.dll 1
+dll\directx\d3d8thk\d3d8thk.dll 1
+dll\directx\devenum\devenum.dll 1
+dll\directx\ksproxy\ksproxy.ax 1
+dll\directx\ksuser\ksuser.dll 1
+dll\directx\msdmo\msdmo.dll 1
+dll\directx\msdvbnp\msdvbnp.ax 1
+dll\directx\msvidctl\msvidctl.dll 1
+dll\directx\quartz\quartz.dll 1
+dll\directx\qedit\qedit.dll 1
+dll\directx\wine\d3d8\d3d8.dll 1
+dll\directx\wine\wined3d\wined3d.dll 1
+dll\directx\wine\d3d9\d3d9.dll 1
+
+dll\keyboard\kbda1\kbda1.dll 1
+dll\keyboard\kbda2\kbda2.dll 1
+dll\keyboard\kbda3\kbda3.dll 1
+dll\keyboard\kbdal\kbdal.dll 1
+dll\keyboard\kbdarme\kbdarme.dll 1
+dll\keyboard\kbdarmw\kbdarmw.dll 1
+dll\keyboard\kbdaze\kbdaze.dll 1
+dll\keyboard\kbdazel\kbdazel.dll 1
+dll\keyboard\kbdbgm\kbdbgm.dll 1
+dll\keyboard\kbdbgt\kbdbgt.dll 1
+dll\keyboard\kbdblr\kbdblr.dll 1
+dll\keyboard\kbdbr\kbdbr.dll 1
+dll\keyboard\kbdbga\kbdbga.dll 1
+dll\keyboard\kbdbe\kbdbe.dll 1
+dll\keyboard\kbdbur\kbdbur.dll 1
+dll\keyboard\kbdcan\kbdcan.dll 1
+dll\keyboard\kbdcr\kbdcr.dll 1
+dll\keyboard\kbdcz\kbdcz.dll 1
+dll\keyboard\kbdcz1\kbdcz1.dll 1
+dll\keyboard\kbdda\kbdda.dll 1
+dll\keyboard\kbddv\kbddv.dll 1
+dll\keyboard\kbdes\kbdes.dll 1
+dll\keyboard\kbdest\kbdest.dll 1
+dll\keyboard\kbdfc\kbdfc.dll 1
+dll\keyboard\kbdfi\kbdfi.dll 1
+dll\keyboard\kbdfr\kbdfr.dll 1
+dll\keyboard\kbdgeo\kbdgeo.dll 1
+dll\keyboard\kbdgerg\kbdgerg.dll 1
+dll\keyboard\kbdgneo\kbdgneo.dll 1
+dll\keyboard\kbdgrist\kbdgrist.dll 1
+dll\keyboard\kbdgr\kbdgr.dll 1
+dll\keyboard\kbdhe\kbdhe.dll 1
+dll\keyboard\kbdheb\kbdheb.dll 1
+dll\keyboard\kbdhu\kbdhu.dll 1
+dll\keyboard\kbdic\kbdic.dll 1
+dll\keyboard\kbdinasa\kbdinasa.dll 1
+dll\keyboard\kbdinben\kbdinben.dll 1
+dll\keyboard\kbdindev\kbdindev.dll 1
+dll\keyboard\kbdinguj\kbdinguj.dll 1
+dll\keyboard\kbdinmal\kbdinmal.dll 1
+dll\keyboard\kbdir\kbdir.dll 1
+dll\keyboard\kbdit\kbdit.dll 1
+dll\keyboard\kbdja\kbdja.dll 1
+dll\keyboard\kbdkaz\kbdkaz.dll 1
+dll\keyboard\kbdla\kbdla.dll 1
+dll\keyboard\kbdlt1\kbdlt1.dll 1
+dll\keyboard\kbdlv\kbdlv.dll 1
+dll\keyboard\kbdmac\kbdmac.dll 1
+dll\keyboard\kbdne\kbdne.dll 1
+dll\keyboard\kbdno\kbdno.dll 1
+dll\keyboard\kbdpl1\kbdpl1.dll 1
+dll\keyboard\kbdpo\kbdpo.dll 1
+dll\keyboard\kbdro\kbdro.dll 1
+dll\keyboard\kbdru\kbdru.dll 1
+dll\keyboard\kbdru1\kbdru1.dll 1
+dll\keyboard\kbdsg\kbdsg.dll 1
+dll\keyboard\kbdsk\kbdsk.dll 1
+dll\keyboard\kbdsk1\kbdsk1.dll 1
+dll\keyboard\kbdsw\kbdsw.dll 1
+dll\keyboard\kbdtat\kbdtat.dll 1
+dll\keyboard\kbdth0\kbdth0.dll 1
+dll\keyboard\kbdth1\kbdth1.dll 1
+dll\keyboard\kbdth2\kbdth2.dll 1
+dll\keyboard\kbdth3\kbdth3.dll 1
+dll\keyboard\kbdtuf\kbdtuf.dll 1
+dll\keyboard\kbdtuq\kbdtuq.dll 1
+dll\keyboard\kbduk\kbduk.dll 1
+dll\keyboard\kbdur\kbdur.dll 1
+dll\keyboard\kbdurs\kbdurs.dll 1
+dll\keyboard\kbdus\kbdus.dll 1
+dll\keyboard\kbdusa\kbdusa.dll 1
+dll\keyboard\kbdusl\kbdusl.dll 1
+dll\keyboard\kbdusr\kbdusr.dll 1
+dll\keyboard\kbdusx\kbdusx.dll 1
+dll\keyboard\kbduzb\kbduzb.dll 1
+dll\keyboard\kbdvntc\kbdvntc.dll 1
+dll\keyboard\kbdycc\kbdycc.dll 1
+dll\keyboard\kbdycl\kbdycl.dll 1
+dll\keyboard\kbdko\kbdko.dll 1
+
+dll\ntdll\ntdll.dll 1
+
+dll\win32\acledit\acledit.dll 1
+dll\win32\aclui\aclui.dll 1
+dll\win32\activeds\activeds.dll 1
+dll\win32\advapi32\advapi32.dll 1
+dll\win32\advpack\advpack.dll 1
+dll\win32\actxprxy\actxprxy.dll 1
+dll\win32\atl\atl.dll 1
+dll\win32\authz\authz.dll 1
+dll\win32\avicap32\avicap32.dll 1
+dll\win32\avifil32\avifil32.dll 1
+dll\win32\batt\batt.dll 1
+dll\win32\bcrypt\bcrypt.dll 1
+dll\win32\beepmidi\beepmidi.dll 1
+dll\win32\browseui\browseui.dll 1
+dll\win32\cabinet\cabinet.dll 1
+dll\win32\cards\cards.dll 1
+dll\win32\cfgmgr32\cfgmgr32.dll 1
+dll\win32\clusapi\clusapi.dll 1
+dll\win32\comcat\comcat.dll 1
+dll\win32\comctl32\comctl32.dll 1
+dll\win32\comdlg32\comdlg32.dll 1
+dll\win32\compstui\compstui.dll 1
+dll\win32\credui\credui.dll 1
+dll\win32\crtdll\crtdll.dll 1
+dll\win32\crypt32\crypt32.dll 1
+dll\win32\cryptdlg\cryptdlg.dll 1
+dll\win32\cryptdll\cryptdll.dll 1
+dll\win32\cryptnet\cryptnet.dll 1
+dll\win32\cryptui\cryptui.dll 1
+dll\win32\dbghelp\dbghelp.dll 1
+dll\win32\dciman32\dciman32.dll 1
+dll\win32\dwmapi\dwmapi.dll 1
+dll\win32\devmgr\devmgr.dll 1
+dll\win32\dhcpcsvc\dhcpcsvc.dll 1
+dll\win32\dnsapi\dnsapi.dll 1
+dll\win32\faultrep\faultrep.dll 1
+dll\win32\fmifs\fmifs.dll 1
+dll\win32\fusion\fusion.dll 1
+dll\win32\gdi32\gdi32.dll 1
+dll\win32\gdiplus\gdiplus.dll 1
+dll\win32\getuname\getuname.dll 1
+dll\win32\glu32\glu32.dll 1
+dll\win32\hhctrl.ocx\hhctrl.ocx 1
+dll\win32\hid\hid.dll 1
+dll\win32\hlink\hlink.dll 1
+dll\win32\hnetcfg\hnetcfg.dll 1
+dll\win32\httpapi\httpapi.dll 1
+dll\win32\iccvid\iccvid.dll 1
+dll\win32\icmp\icmp.dll 1
+dll\win32\imaadp32.acm\imaadp32.acm 1
+dll\win32\imagehlp\imagehlp.dll 1
+dll\win32\imm32\imm32.dll 1
+dll\win32\inetcomm\inetcomm.dll 1
+dll\win32\inetmib1\inetmib1.dll 1
+dll\win32\initpki\initpki.dll 1
+dll\win32\inseng\inseng.dll 1
+dll\win32\iphlpapi\iphlpapi.dll 1
+dll\win32\itircl\itircl.dll 1
+dll\win32\itss\itss.dll 1
+dll\win32\jscript\jscript.dll 1
+dll\win32\kernel32\kernel32.dll 1
+dll\win32\loadperf\loadperf.dll 1
+dll\win32\localspl\localspl.dll 1
+dll\win32\localui\localui.dll 1
+dll\win32\lsasrv\lsasrv.dll 1
+dll\win32\lz32\lz32.dll 1
+dll\win32\mapi32\mapi32.dll 1
+dll\win32\mciavi32\mciavi32.dll 1
+dll\win32\mcicda\mcicda.dll 1
+dll\win32\mciqtz32\mciqtz32.dll 1
+dll\win32\mciseq\mciseq.dll 1
+dll\win32\mciwave\mciwave.dll 1
+dll\win32\mlang\mlang.dll 1
+dll\win32\mmdrv\mmdrv.dll 1
+dll\win32\modemui\modemui.dll 1
+dll\win32\mpr\mpr.dll 1
+dll\win32\mprapi\mprapi.dll 1
+dll\win32\msacm32\msacm32.dll 1
+dll\win32\msacm32\msacm32.drv\msacm32.drv 1
+dll\win32\msadp32.acm\msadp32.acm 1
+dll\win32\msafd\msafd.dll 1
+dll\win32\mscat32\mscat32.dll 1
+dll\win32\mscms\mscms.dll 1
+dll\win32\mscoree\mscoree.dll 1
+dll\win32\msctf\msctf.dll 1
+dll\win32\msftedit\msftedit.dll 1
+dll\win32\msg711.acm\msg711.acm 1
+dll\win32\msgina\msgina.dll 1
+dll\win32\msgsm32.acm\msgsm32.acm 1
+dll\win32\mshtml\mshtml.dll 1
+dll\win32\mshtml.tlb\mshtml.tlb 1
+dll\win32\msi\msi.dll 1
+dll\win32\msimg32\msimg32.dll 1
+dll\win32\msimtf\msimtf.dll 1
+dll\win32\msisip\msisip.dll 1
+dll\win32\msisys.ocx\msisys.ocx 1
+dll\win32\msnet32\msnet32.dll 1
+dll\win32\msrle32\msrle32.dll 1
+dll\win32\mssign32\mssign32.dll 1
+dll\win32\mssip32\mssip32.dll 1
+dll\win32\mstask\mstask.dll 1
+dll\win32\msvcrt\msvcrt.dll 1
+dll\win32\msvcrt20\msvcrt20.dll 1
+dll\win32\msvcrt40\msvcrt40.dll 1
+dll\win32\msvfw32\msvfw32.dll 1
+dll\win32\msvidc32\msvidc32.dll 1
+dll\win32\mswsock\mswsock.dll 1
+dll\win32\msxml3\msxml3.dll 1
+dll\win32\nddeapi\nddeapi.dll 1
+dll\win32\netapi32\netapi32.dll 1
+dll\win32\netcfgx\netcfgx.dll 1
+dll\win32\netid\netid.dll 1
+dll\win32\netshell\netshell.dll 1
+dll\win32\newdev\newdev.dll 1
+dll\win32\ntdsapi\ntdsapi.dll 1
+dll\win32\ntlanman\ntlanman.dll 1
+dll\win32\ntmarta\ntmarta.dll 1
+dll\win32\ntprint\ntprint.dll 1
+dll\win32\objsel\objsel.dll 1
+dll\win32\odbc32\odbc32.dll 1
+dll\win32\odbccp32\odbccp32.dll 1
+dll\win32\ole32\ole32.dll 1
+dll\win32\oleacc\oleacc.dll 1
+dll\win32\oleaut32\oleaut32.dll 1
+dll\win32\olecli32\olecli32.dll 1
+dll\win32\oledlg\oledlg.dll 1
+dll\win32\olepro32\olepro32.dll 1
+dll\win32\olesvr32\olesvr32.dll 1
+dll\win32\olethk32\olethk32.dll 1
+dll\win32\opengl32\opengl32.dll 1
+dll\win32\pdh\pdh.dll 1
+dll\win32\pidgen\pidgen.dll 1
+dll\win32\powrprof\powrprof.dll 1
+dll\win32\printui\printui.dll 1
+dll\win32\psapi\psapi.dll 1
+dll\win32\pstorec\pstorec.dll 1
+dll\win32\qmgr\qmgr.dll 1
+dll\win32\qmgrprxy\qmgrprxy.dll 1
+dll\win32\query\query.dll 1
+dll\win32\rasadhlp\rasadhlp.dll 1
+dll\win32\rasapi32\rasapi32.dll 1
+dll\win32\rasdlg\rasdlg.dll 1
+dll\win32\resutils\resutils.dll 1
+dll\win32\rasman\rasman.dll 1
+dll\win32\riched20\riched20.dll 1
+dll\win32\riched32\riched32.dll 1
+dll\win32\rpcrt4\rpcrt4.dll 1
+dll\win32\rsabase\rsabase.dll 1
+dll\win32\rsaenh\rsaenh.dll 1
+dll\win32\samlib\samlib.dll 1
+dll\win32\samsrv\samsrv.dll 1
+dll\win32\sccbase\sccbase.dll 1
+dll\win32\schannel\schannel.dll 1
+dll\win32\secur32\secur32.dll 1
+dll\win32\security\security.dll 1
+dll\win32\sensapi\sensapi.dll 1
+dll\win32\serialui\serialui.dll 1
+dll\win32\setupapi\setupapi.dll 1
+dll\win32\sfc\sfc.dll 1
+dll\win32\sfc_os\sfc_os.dll 1
+dll\win32\shdoclc\shdoclc.dll 1
+dll\win32\shdocvw\shdocvw.dll 1
+dll\win32\shell32\shell32.dll 1
+dll\win32\shfolder\shfolder.dll 1
+dll\win32\shimgvw\shimgvw.dll 1
+dll\win32\shlwapi\shlwapi.dll 1
+dll\win32\slbcsp\slbcsp.dll 1
+dll\win32\smdll\smdll.dll 1
+dll\win32\snmpapi\snmpapi.dll 1
+dll\win32\softpub\softpub.dll 1
+dll\win32\spoolss\spoolss.dll 1
+dll\win32\srclient\srclient.dll 1
+dll\win32\stdole2.tlb\stdole2.tlb 1
+dll\win32\stdole32.tlb\stdole32.tlb 1
+dll\win32\sti\sti.dll 1
+dll\win32\sxs\sxs.dll 1
+dll\win32\syssetup\syssetup.dll 1
+dll\win32\t2embed\t2embed.dll 1
+dll\win32\tapi32\tapi32.dll 1
+dll\win32\tapiui\tapiui.dll 1
+dll\win32\traffic\traffic.dll 1
+dll\win32\twain_32\twain_32.dll 1
+dll\win32\uext2\uext2.dll 1
+dll\win32\ufat\ufat.dll 1
+dll\win32\ufatx\ufatx.dll 1 optional
+dll\win32\untfs\untfs.dll 1
+dll\win32\updspapi\updspapi.dll 1
+dll\win32\url\url.dll 1
+dll\win32\urlmon\urlmon.dll 1
+dll\win32\user32\user32.dll 1
+dll\win32\userenv\userenv.dll 1
+dll\win32\usp10\usp10.dll 1
+dll\win32\uxtheme\uxtheme.dll 1
+dll\win32\vdmdbg\vdmdbg.dll 1
+dll\win32\version\version.dll 1
+dll\win32\windowscodecs\windowscodecs.dll 1
+dll\win32\winemp3.acm\winemp3.acm 1
+dll\win32\winfax\winfax.dll 1
+dll\win32\winhttp\winhttp.dll 1
+dll\win32\wininet\wininet.dll 1
+dll\win32\winmm\winmm.dll 1
+dll\win32\winspool\winspool.drv 1
+dll\win32\winsta\winsta.dll 1
+dll\win32\wlanapi\wlanapi.dll 1
+dll\win32\wintrust\wintrust.dll 1
+dll\win32\wldap32\wldap32.dll 1
+dll\win32\wmi\wmi.dll 1
+dll\win32\ws2_32\ws2_32.dll 1
+dll\win32\ws2help\ws2help.dll 1
+dll\win32\wshirda\wshirda.dll 1
+dll\win32\wshtcpip\wshtcpip.dll 1
+dll\win32\wsock32\wsock32.dll 1
+dll\win32\wtsapi32\wtsapi32.dll 1
+dll\win32\wuapi\wuapi.dll 1
+dll\win32\xinput1_1\xinput1_1.dll 1
+dll\win32\xinput1_2\xinput1_2.dll 1
+dll\win32\xinput1_3\xinput1_3.dll 1
+dll\win32\xinput9_1_0\xinput9_1_0.dll 1
+dll\win32\xmllite\xmllite.dll 1
+dll\win32\winmm\midimap\midimap.dll 1
+dll\win32\wdmaud.drv\wdmaud.drv 1
+
+; Shell Extensions
+dll\shellext\deskadp\deskadp.dll 1
+dll\shellext\deskmon\deskmon.dll 1
+
+; Drivers
+drivers\base\bootvid\bootvid.dll 1
+drivers\base\beep\beep.sys 2
+drivers\base\null\null.sys 2
+drivers\base\nmidebug\nmidebug.sys 2
+
+drivers\battery\battc\battc.sys 2
+
+drivers\bus\isapnp\isapnp.sys 2
+
+drivers\bus\acpi\cmbatt\cmbatt.sys 2
+drivers\bus\acpi\compbatt\compbatt.sys 2
+
+drivers\directx\dxapi\dxapi.sys 2
+drivers\directx\dxg\dxg.sys 2
+drivers\directx\dxgthk\dxgthk.sys 2
+
+drivers\filesystems\fs_rec\fs_rec.sys 2
+drivers\filesystems\msfs\msfs.sys 2
+drivers\filesystems\mup\mup.sys 2
+drivers\filesystems\npfs\npfs.sys 2
+
+drivers\input\mouclass\mouclass.sys 2
+drivers\input\sermouse\sermouse.sys 2
+
+drivers\ksfilter\ks\ks.sys 2
+drivers\multimedia\bdasup\bdasup.sys 2
+
+drivers\network\afd\afd.sys 2
+drivers\network\ndis\ndis.sys 2
+drivers\network\tcpip\tcpip.sys 2
+drivers\network\tdi\tdi.sys 2
+drivers\network\dd\ne2000\ne2000.sys 2
+drivers\network\dd\pcnet\pcnet.sys 2
+
+drivers\serial\serenum\serenum.sys 2
+drivers\serial\serial\serial.sys 2
+
+drivers\storage\ide\pciide\pciide.sys 2
+drivers\storage\ide\pciidex\pciidex.sys 2
+
+;drivers\usb\miniport\usbohci\usbohci.sys 2
+;drivers\usb\miniport\usbuhci\usbuhci.sys 2
+;drivers\usb\usbhub\usbhub.sys 2
+;drivers\usb\usbport\usbport.sys 2
+drivers\usb\nt4compat\usbdriver\usbdriver.sys 2
+
+drivers\video\displays\vga\vgaddi.dll 1
+drivers\video\displays\framebuf\framebuf.dll 1
+drivers\video\miniport\vga\vgamp.sys 2
+drivers\video\miniport\vbe\vbemp.sys 2
+drivers\video\videoprt\videoprt.sys 2
+drivers\video\font\ftfd\ftfd.dll 1
+
+drivers\wdm\audio\filters\kmixer\kmixer.sys 2
+drivers\wdm\audio\sysaudio\sysaudio.sys 2
+drivers\wdm\audio\legacy\wdmaud\wdmaud.sys 2
+drivers\wdm\audio\backpln\portcls\portcls.sys 2
+drivers\wdm\audio\drm\drmk\drmk.sys 2
+drivers\wmi\wmilib.sys 2
+
+; Media
+media\fonts\DejaVuSans.ttf 3
+media\fonts\DejaVuSans-Bold.ttf 3
+media\fonts\DejaVuSans-BoldOblique.ttf 3
+media\fonts\DejaVuSansMono.ttf 3
+media\fonts\DejaVuSansMono-Bold.ttf 3
+media\fonts\DejaVuSansMono-BoldOblique.ttf 3
+media\fonts\DejaVuSansMono-Oblique.ttf 3
+media\fonts\DejaVuSans-Oblique.ttf 3
+media\fonts\DejaVuSerif.ttf 3
+media\fonts\DejaVuSerif-Bold.ttf 3
+media\fonts\DejaVuSerif-BoldItalic.ttf 3
+media\fonts\DejaVuSerif-Italic.ttf 3
+
+media\fonts\FreeMono.ttf 3
+media\fonts\FreeMonoBold.ttf 3
+media\fonts\FreeMonoBoldOblique.ttf 3
+media\fonts\FreeMonoOblique.ttf 3
+
+media\fonts\LiberationMono-Bold.ttf 3
+media\fonts\LiberationMono-BoldItalic.ttf 3
+media\fonts\LiberationMono-Italic.ttf 3
+media\fonts\LiberationMono-Regular.ttf 3
+media\fonts\LiberationSans-Bold.ttf 3
+media\fonts\LiberationSans-BoldItalic.ttf 3
+media\fonts\LiberationSans-Italic.ttf 3
+media\fonts\LiberationSans-Regular.ttf 3
+media\fonts\LiberationSerif-Bold.ttf 3
+media\fonts\LiberationSerif-BoldItalic.ttf 3
+media\fonts\LiberationSerif-Italic.ttf 3
+media\fonts\LiberationSerif-Regular.ttf 3
+
+media\fonts\Marlett.ttf 3
+media\fonts\symbol.ttf 3
+media\fonts\tahoma.ttf 3
+media\fonts\tahomabd.ttf 3
+
+media\nls\c_037.nls 1
+media\nls\c_424.nls 1
+media\nls\c_500.nls 1
+media\nls\c_737.nls 1
+media\nls\c_775.nls 1
+media\nls\c_850.nls 1
+media\nls\c_852.nls 1
+media\nls\c_855.nls 1
+media\nls\c_856.nls 1
+media\nls\c_857.nls 1
+media\nls\c_860.nls 1
+media\nls\c_861.nls 1
+media\nls\c_862.nls 1
+media\nls\c_863.nls 1
+media\nls\c_864.nls 1
+media\nls\c_865.nls 1
+media\nls\c_866.nls 1
+media\nls\c_869.nls 1
+media\nls\c_874.nls 1
+media\nls\c_875.nls 1
+media\nls\c_878.nls 1
+media\nls\c_932.nls 1
+media\nls\c_936.nls 1
+media\nls\c_949.nls 1
+media\nls\c_950.nls 1
+media\nls\c_1006.nls 1
+media\nls\c_1026.nls 1
+media\nls\c_1250.nls 1
+media\nls\c_1251.nls 1
+media\nls\c_1253.nls 1
+media\nls\c_1254.nls 1
+media\nls\c_1255.nls 1
+media\nls\c_1256.nls 1
+media\nls\c_1257.nls 1
+media\nls\c_1258.nls 1
+media\nls\c_10000.nls 1
+media\nls\c_10006.nls 1
+media\nls\c_10007.nls 1
+media\nls\c_10029.nls 1
+media\nls\c_10079.nls 1
+media\nls\c_10081.nls 1
+media\nls\c_20866.nls 1
+media\nls\c_21866.nls 1
+media\nls\c_28591.nls 1
+media\nls\c_28592.nls 1
+media\nls\c_28593.nls 1
+media\nls\c_28594.nls 1
+media\nls\c_28595.nls 1
+media\nls\c_28596.nls 1
+media\nls\c_28597.nls 1
+media\nls\c_28598.nls 1
+media\nls\c_28599.nls 1
+media\nls\c_28600.nls 1
+media\nls\c_28603.nls 1
+media\nls\c_28604.nls 1
+media\nls\c_28605.nls 1
+media\nls\c_28606.nls 1
+media\drivers\etc\services 5
+media\inf\audio.inf 6
+media\inf\acpi.inf 6
+media\inf\battery.inf 6
+media\inf\cdrom.inf 6
+media\inf\cpu.inf 6
+media\inf\display.inf 6
+media\inf\font.inf 6
+media\inf\fdc.inf 6
+media\inf\hdc.inf 6
+media\inf\intl.inf 6
+media\inf\layout.inf 6
+media\inf\machine.inf 6
+media\inf\msmouse.inf 6
+media\inf\keyboard.inf 6
+media\inf\ks.inf 6
+media\inf\NET_NIC.inf 6
+media\inf\netamd.inf 6
+media\inf\netisa.inf 6
+media\inf\netrtpnt.inf 6
+media\inf\nettcpip.inf 6
+media\inf\ports.inf 6
+media\inf\scsi.inf 6
+media\inf\syssetup.inf 6
+media\inf\usbport.inf 6
+media\inf\usb.inf 6
+media\inf\usbstor.inf 6
+media\inf\xboxdisp.inf 6
+
+
+; Media Files
+media\sounds\ReactOS_LogOn.wav 8
+
+; Ini Files
+boot\bootdata\system.ini 4
+
+; Regression Testing
+boot\bootdata\bootcdregtest\regtest.cmd 7 optional
+
+; Subsystems
+subsystems\win32\csrss\csrss.exe 1
+subsystems\win32\csrss\win32csr\win32csr.dll 1
+subsystems\win32\csrss\csrsrv\csrsrv.dll 1
+subsystems\ntvdm\ntvdm.exe 1
+subsystems\win32\win32k\win32k.sys 1
+
+; Optional/proprietary files
+modules\optional\DroidSansFallback.ttf 3 optional
+modules\optional\NOTICE_for_Droid_Font.txt 4 optional
+modules\optional\netkvm2k.inf 6 optional
+modules\optional\netkvm2k.cat 6 optional
+modules\optional\netkvm.sys 2 optional
+modules\optional\alcxwdm.inf 6 optional
+modules\optional\alcxwdm.sys 2 optional
+modules\optional\mfc42.dll 1 optional
+modules\optional\mfc42u.dll 1 optional
+modules\optional\mfc71.dll 1 optional
+modules\optional\mfc71u.dll 1 optional
+modules\optional\msvbvm50.dll 1 optional
+modules\optional\msvbvm60.dll 1 optional
+modules\optional\msvcirt.dll 1 optional
+modules\optional\msvcp71.dll 1 optional
+modules\optional\msvcr71.dll 1 optional
+modules\optional\vmx_fb.dll 1 optional
+modules\optional\vmx_mode.dll 1 optional
+modules\optional\vmx_svga.inf 6 optional
+modules\optional\vmx_svga.sys 2 optional
+modules\optional\wine_gecko-1.0.0-x86.cab 4 optional
+
+; Rosapps
+modules\rosapps\applications\screensavers\cylfrac\cylfrac.scr 1 optional
+modules\rosapps\applications\screensavers\matrix\matrix.scr 1 optional
+modules\rosapps\applications\screensavers\blankscr\scrnsave.scr 1 optional
+modules\rosapps\applications\screensavers\starfield\starfield.scr 1 optional
+modules\rosapps\applications\screensavers\mazescr\mazescr.scr 1 optional
+modules\rosapps\applications\screensavers\butterflies\butterflies.scr 1 optional
+modules\rosapps\applications\cmdutils\comp\comp.exe 1 optional
+modules\rosapps\applications\cmdutils\mode\mode.exe 1 optional
+modules\rosapps\applications\cmdutils\sort\sort.exe 1 optional
+modules\rosapps\applications\cmdutils\tee\tee.exe 1 optional
+modules\rosapps\applications\cmdutils\touch\touch.exe 1 optional
+modules\rosapps\applications\cmdutils\uptime\uptime.exe 1 optional
+modules\rosapps\applications\cmdutils\y\y.exe 1 optional
+modules\rosapps\applications\devutils\gdb2\gdb2.exe 1 optional
+modules\rosapps\applications\devutils\gdihv\gdihv.exe 1 optional
+modules\rosapps\applications\devutils\genguid\genguid.exe 1 optional
+modules\rosapps\applications\sysutils\gettype\gettype.exe 1 optional
+modules\rosapps\applications\net\ncftp\ncftp.exe 1 optional
+modules\rosapps\applications\net\netreg\netreg.exe 1 optional
+modules\rosapps\applications\net\niclist\niclist.exe 1 optional
+modules\rosapps\applications\net\roshttpd\roshttpd.exe 1 optional
+modules\rosapps\applications\notevil\notevil.exe 1 optional
+modules\rosapps\applications\sysutils\chkdsk\chkdsk.exe 1 optional
+modules\rosapps\applications\sysutils\systeminfo\systeminfo.exe 1 optional
+modules\rosapps\applications\sysutils\chklib\chklib.exe 1 optional
+modules\rosapps\applications\sysutils\ctm\ctm.exe 1 optional
+modules\rosapps\applications\sysutils\kill\kill.exe 1 optional
+modules\rosapps\applications\sysutils\lsdd\lsdd.exe 1 optional
+modules\rosapps\applications\sysutils\man\man.exe 1 optional
+modules\rosapps\applications\sysutils\pedump\pedump.exe 1 optional
+modules\rosapps\applications\sysutils\regexpl\regexpl.exe 1 optional
+modules\rosapps\applications\sysutils\tcat\tcat.exe 1 optional
+modules\rosapps\applications\sysutils\tlist\tlist.exe 1 optional
+modules\rosapps\applications\sysutils\screenshot\screenshot.exe 1 optional
+modules\rosapps\applications\sysutils\utils\binpatch\binpatch.exe 1 optional
+modules\rosapps\applications\sysutils\utils\cat\cat.exe 1 optional
+modules\rosapps\applications\sysutils\utils\driver\load\load.exe 1 optional
+modules\rosapps\applications\sysutils\utils\driver\unload\unload.exe 1 optional
+modules\rosapps\applications\sysutils\utils\infinst\infinst.exe 1 optional
+modules\rosapps\applications\sysutils\utils\nts2w32err\nts2w32err.exe 1 optional
+modules\rosapps\applications\sysutils\utils\objdir\objdir.exe 1 optional
+modules\rosapps\applications\sysutils\utils\partinfo\partinfo.exe 1 optional
+modules\rosapps\applications\sysutils\utils\ps\ps.exe 1 optional
+modules\rosapps\applications\sysutils\utils\rosperf\rosperf.exe 1 optional
+modules\rosapps\applications\sysutils\utils\stats\stats.exe 1 optional
+modules\rosapps\applications\sysutils\utils\tickcount\tickcount.exe 1 optional
+modules\rosapps\applications\winfile\winfile.exe 1 optional
+modules\rosapps\demos\maze\maze.exe 1 optional
+modules\rosapps\drivers\green\green.sys 2 optional
+
+; Rostests
+modules\rostests\rosautotest\rosautotest.exe 1 optional
+modules\rostests\tests\pseh2\pseh2_test.exe 7 optional
+modules\rostests\winetests\advapi32\advapi32_winetest.exe 7 optional
+modules\rostests\winetests\advpack\advpack_winetest.exe 7 optional
+modules\rostests\winetests\browseui\browseui_winetest.exe 7 optional
+modules\rostests\winetests\cabinet\cabinet_winetest.exe 7 optional
+modules\rostests\winetests\comcat\comcat_winetest.exe 7 optional
+modules\rostests\winetests\comctl32\comctl32_winetest.exe 7 optional
+modules\rostests\winetests\comdlg32\comdlg32_winetest.exe 7 optional
+modules\rostests\winetests\crypt32\crypt32_winetest.exe 7 optional
+modules\rostests\winetests\cryptnet\cryptnet_winetest.exe 7 optional
+modules\rostests\winetests\dsound\dsound_winetest.exe 7 optional
+modules\rostests\winetests\gdi32\gdi32_winetest.exe 7 optional
+modules\rostests\winetests\gdiplus\gdiplus_winetest.exe 7 optional
+modules\rostests\winetests\hlink\hlink_winetest.exe 7 optional
+modules\rostests\winetests\icmp\icmp_winetest.exe 7 optional
+modules\rostests\winetests\iphlpapi\iphlpapi_winetest.exe 7 optional
+modules\rostests\winetests\jscript\jscript_winetest.exe 7 optional
+modules\rostests\winetests\kernel32\kernel32_winetest.exe 7 optional
+modules\rostests\winetests\lz32\lz32_winetest.exe 7 optional
+modules\rostests\winetests\mapi32\mapi32_winetest.exe 7 optional
+modules\rostests\winetests\mlang\mlang_winetest.exe 7 optional
+modules\rostests\winetests\mshtml\mshtml_winetest.exe 7 optional
+modules\rostests\winetests\msi\msi_winetest.exe 7 optional
+modules\rostests\winetests\mstask\mstask_winetest.exe 7 optional
+modules\rostests\winetests\msvcrt\msvcrt_winetest.exe 7 optional
+modules\rostests\winetests\msxml3\msxml3_winetest.exe 7 optional
+modules\rostests\winetests\netapi32\netapi32_winetest.exe 7 optional
+modules\rostests\winetests\ntdll\ntdll_winetest.exe 7 optional
+modules\rostests\winetests\odbccp32\odbccp32_winetest.exe 7 optional
+modules\rostests\winetests\ole32\ole32_winetest.exe 7 optional
+modules\rostests\winetests\oleaut32\oleaut32_winetest.exe 7 optional
+modules\rostests\winetests\powrprof\powrprof_winetest.exe 7 optional
+modules\rostests\winetests\psapi\psapi_winetest.exe 7 optional
+modules\rostests\winetests\riched20\riched20_winetest.exe 7 optional
+modules\rostests\winetests\rpcrt4\rpcrt4_winetest.exe 7 optional
+modules\rostests\winetests\rsabase\rsabase_winetest.exe 7 optional
+modules\rostests\winetests\rsaenh\rsaenh_winetest.exe 7 optional
+modules\rostests\winetests\schannel\schannel_winetest.exe 7 optional
+modules\rostests\winetests\secur32\secur32_winetest.exe 7 optional
+modules\rostests\winetests\setupapi\setupapi_winetest.exe 7 optional
+modules\rostests\winetests\shdocvw\shdocvw_winetest.exe 7 optional
+modules\rostests\winetests\shell32\shell32_winetest.exe 7 optional
+modules\rostests\winetests\shlwapi\shlwapi_winetest.exe 7 optional
+modules\rostests\winetests\urlmon\urlmon_winetest.exe 7 optional
+modules\rostests\winetests\user32\user32_winetest.exe 7 optional
+modules\rostests\winetests\usp10\usp10_winetest.exe 7 optional
+modules\rostests\winetests\uxtheme\uxtheme_winetest.exe 7 optional
+modules\rostests\winetests\version\version_winetest.exe 7 optional
+modules\rostests\winetests\winhttp\winhttp_winetest.exe 7 optional
+modules\rostests\winetests\wininet\wininet_winetest.exe 7 optional
+modules\rostests\winetests\winmm\winmm_winetest.exe 7 optional
+modules\rostests\winetests\wintrust\wintrust_winetest.exe 7 optional
+modules\rostests\winetests\wlanapi\wlanapi_winetest.exe 7 optional
+modules\rostests\winetests\ws2_32\ws2_32_winetest.exe 7 optional
+modules\rostests\winetests\xmllite\xmllite_winetest.exe 7 optional
+
+
+modules\wallpaper\Angelus_02_ROSWP.bmp 4 optional
<?xml version="1.0"?>
<!DOCTYPE directory SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="freeldr_arch" type="objectlibrary">
+<module name="freeldr_arch" type="objectlibrary" crt="static">
<include base="freeldr_base">include</include>
<include base="freeldr_base">cache</include>
<include base="ntoskrnl">include</include>
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="freeldr_base" type="objectlibrary">
+<module name="freeldr_base" type="objectlibrary" crt="static">
<include base="freeldr_base">include</include>
<include base="freeldr_base">cache</include>
<include base="cmlib">.</include>
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="freeldr_main" type="objectlibrary">
+<module name="freeldr_main" type="objectlibrary" crt="static">
<include base="freeldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHAL_" />
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="setupldr_main" type="objectlibrary">
+<module name="setupldr_main" type="objectlibrary" crt="static">
<include base="setupldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHAL_" />
PVOID DriverBase;
// Separate the path to file name and directory path
- snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
+ _snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
DriverNamePos = strrchr(DriverPath, '\\');
if (DriverNamePos != NULL)
{
}
// It's not loaded, we have to load it
- snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
+ _snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
Status = WinLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
if (!Status)
return FALSE;
enable this (except they/you purchased a license from the patent owner).
This settings is disabled (0) by default.
-->
-<property name="NSWPAT" value="0" />
+<property name="NSWPAT" value="1" />
<!--
Whether to compile with the KD protocol. This will disable support for KDBG
// build new bitmap
GetObject(pImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
dc = CreateCompatibleDC(GetDC(NULL));
+ if (dc == NULL)
+ {
+ break;
+ }
sdc = CreateCompatibleDC(dc);
+ if (sdc == NULL)
+ {
+ DeleteDC(dc);
+ break;
+ }
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
EDITTEXT IDC_USER_GENERAL_FULL_NAME,77,43,168,13,ES_AUTOHSCROLL
LTEXT "Beschreibung:", -1, 7, 64, 63, 8
EDITTEXT IDC_USER_GENERAL_DESCRIPTION,77,61,168,13,ES_AUTOHSCROLL
- AUTOCHECKBOX "Benutzer muss das Passwort bei der ersten Anmeldung ändern",IDC_USER_GENERAL_FORCE_CHANGE,7,82,210,10
- AUTOCHECKBOX "Benutzer kann das Passwort nicht ändern",IDC_USER_GENERAL_CANNOT_CHANGE,7,95,210,10
- AUTOCHECKBOX "Passwort läuft nie ab",IDC_USER_GENERAL_NEVER_EXPIRES,7,108,210,10
+ AUTOCHECKBOX "Benutzer muss das Passwort bei der ersten Anmeldung ändern",IDC_USER_GENERAL_FORCE_CHANGE,7,82,230,10
+ AUTOCHECKBOX "Benutzer kann das Passwort nicht ändern",IDC_USER_GENERAL_CANNOT_CHANGE,7,95,210,10
+ AUTOCHECKBOX "Passwort läuft nie ab",IDC_USER_GENERAL_NEVER_EXPIRES,7,108,210,10
AUTOCHECKBOX "Konto ist deativiert",IDC_USER_GENERAL_DISABLED,7,121,210,10
AUTOCHECKBOX "Konto ist gesperrt",IDC_USER_GENERAL_LOCKED,7,134,210,10
END
IDD_CHANGE_PASSWORD DIALOGEX DISCARDABLE 0, 0, 267, 74
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_SHELLFONT
-CAPTION "Passwort ändern"
+CAPTION "Passwort ändern"
FONT 8, "MS Shell Dlg"
BEGIN
EDITTEXT IDC_EDIT_PASSWORD1,107,7,153,14,ES_AUTOHSCROLL | ES_PASSWORD
EDITTEXT IDC_USER_NEW_NAME,107,7,153,14,ES_AUTOHSCROLL
RTEXT "Benutzername:", -1,7,10,96,8
EDITTEXT IDC_USER_NEW_FULL_NAME,107,25,153,14,ES_AUTOHSCROLL
- RTEXT "Vollständiger Name:", -1,7,28,96,8
+ RTEXT "Vollständiger Name:", -1,7,28,96,8
EDITTEXT IDC_USER_NEW_DESCRIPTION,107,43,153,14,ES_AUTOHSCROLL
RTEXT "Beschreibung:", -1,7,46,96,8
EDITTEXT IDC_USER_NEW_PASSWORD1,107,67,153,14,ES_AUTOHSCROLL | ES_PASSWORD
RTEXT "Passwort:", -1,7,70,96,8
EDITTEXT IDC_USER_NEW_PASSWORD2,107,85,153,14,ES_AUTOHSCROLL | ES_PASSWORD
RTEXT "Passwort wiederholen:", -1,7,88,96,8
- AUTOCHECKBOX "Benutzer muss das Passwort bei der ersten Anmeldung ändern",IDC_USER_NEW_FORCE_CHANGE,7,109,200,10
- AUTOCHECKBOX "Benutzer kann das Passwort nicht ändern",IDC_USER_NEW_CANNOT_CHANGE,7,123,200,10,WS_DISABLED
- AUTOCHECKBOX "Passwort läuft nie ab",IDC_USER_NEW_NEVER_EXPIRES,7,137,200,10,WS_DISABLED
+ AUTOCHECKBOX "Benutzer muss das Passwort bei der ersten Anmeldung ändern",IDC_USER_NEW_FORCE_CHANGE,7,109,230,10
+ AUTOCHECKBOX "Benutzer kann das Passwort nicht ändern",IDC_USER_NEW_CANNOT_CHANGE,7,123,200,10,WS_DISABLED
+ AUTOCHECKBOX "Passwort läuft nie ab",IDC_USER_NEW_NEVER_EXPIRES,7,137,200,10,WS_DISABLED
AUTOCHECKBOX "Konto ist deaktiviert",IDC_USER_NEW_DISABLED,7,151,200,10
DEFPUSHBUTTON "OK",IDOK,156,179,50,14,WS_DISABLED
PUSHBUTTON "Abbrechen",IDCANCEL,210,179,50,14
END
POPUP ""
BEGIN
- MENUITEM "Mitglied hinzufügen", IDM_GROUP_ADD_MEMBER, GRAYED
+ MENUITEM "Mitglied hinzufügen", IDM_GROUP_ADD_MEMBER, GRAYED
MENUITEM SEPARATOR
- MENUITEM "Löschen", IDM_GROUP_DELETE
+ MENUITEM "Löschen", IDM_GROUP_DELETE
MENUITEM "Umbenennen", IDM_GROUP_RENAME
MENUITEM SEPARATOR
MENUITEM "Eigenschaften", IDM_GROUP_PROPERTIES
END
POPUP ""
BEGIN
- MENUITEM "Passwort ändern", IDM_USER_CHANGE_PASSWORD
+ MENUITEM "Passwort ändern", IDM_USER_CHANGE_PASSWORD
MENUITEM SEPARATOR
- MENUITEM "Löschen", IDM_USER_DELETE
+ MENUITEM "Löschen", IDM_USER_DELETE
MENUITEM "Umbenennen", IDM_USER_RENAME
MENUITEM SEPARATOR
MENUITEM "Eigenschaften", IDM_USER_PROPERTIES
WINAPI
DllUnregisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass;
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ RegDeleteKeyW(hClass, pStr);
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
extern "C"
WINAPI
DllRegisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass, hKey, hSubKey;
+ static LPCWSTR ModuleName = L"bdaplgin.ax";
+ static LPCWSTR ThreadingModel = L"Both";
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
+ {
+ if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
+ RegCloseKey(hSubKey);
+ }
+ RegCloseKey(hKey);
+ }
+
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
KSDDKAPI
<group>
<module name="bdaplgin" type="win32dll" baseaddress="${BASEADDRESS_BDAPLGIN}" installbase="system32" installname="bdaplgin.ax">
<importlibrary definition="bdaplgin.spec" />
+ <autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<include base="bdaplgin">.</include>
<library>ntdll</library>
<library>kernel32</library>
return m_Ref;
}
- CControlNode(HANDLE hFile, ULONG NodeType, ULONG PinId) : m_Ref(0), m_hFile(hFile), m_NodeType(NodeType), m_PinId(PinId){};
+ CControlNode(IKsPropertySet * pProperty, ULONG NodeType, ULONG PinId) : m_Ref(0), m_pKsProperty(pProperty), m_NodeType(NodeType), m_PinId(PinId){};
virtual ~CControlNode(){};
protected:
LONG m_Ref;
- HANDLE m_hFile;
+ IKsPropertySet * m_pKsProperty;
ULONG m_NodeType;
ULONG m_PinId;
};
}
else if(IsEqualGUID(refiid, IID_IBDA_FrequencyFilter))
{
- return CBDAFrequencyFilter_fnConstructor(m_hFile, m_NodeType, refiid, Output);
+ return CBDAFrequencyFilter_fnConstructor(m_pKsProperty, m_NodeType, refiid, Output);
}
else if(IsEqualGUID(refiid, IID_IBDA_SignalStatistics))
{
- return CBDASignalStatistics_fnConstructor(m_hFile, m_NodeType, refiid, Output);
+ return CBDASignalStatistics_fnConstructor(m_pKsProperty, m_NodeType, refiid, Output);
}
else if(IsEqualGUID(refiid, IID_IBDA_LNBInfo))
{
- return CBDALNBInfo_fnConstructor(m_hFile, m_NodeType, refiid, Output);
+ return CBDALNBInfo_fnConstructor(m_pKsProperty, m_NodeType, refiid, Output);
}
else if(IsEqualGUID(refiid, IID_IBDA_DigitalDemodulator))
{
- return CBDADigitalDemodulator_fnConstructor(m_hFile, m_NodeType, refiid, Output);
+ return CBDADigitalDemodulator_fnConstructor(m_pKsProperty, m_NodeType, refiid, Output);
}
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[MAX_PATH];
WCHAR Buffer[100];
HRESULT hr;
IPin * pPin = NULL;
- IKsObject * pObject = NULL;
- HANDLE hFile = INVALID_HANDLE_VALUE;
+ IKsPropertySet * pProperty;
// store pin id
swprintf(Buffer, L"%u", PinId);
return hr;
}
- // query IKsObject interface
- hr = pPin->QueryInterface(IID_IKsObject, (void**)&pObject);
+ // query for IKsPropertySet interface
+ hr = pPin->QueryInterface(IID_IKsPropertySet, (void**)&pProperty);
+ if (FAILED(hr))
+ return hr;
#ifdef BDAPLGIN_TRACE
swprintf(Buffer, L"CControlNode_fnConstructor get IID_IKsObject status %lx\n", hr);
OutputDebugStringW(Buffer);
#endif
- if (SUCCEEDED(hr))
- {
- // get pin handle
- hFile = pObject->KsGetObjectHandle();
- // release IKsObject interface
- pObject->Release();
- }
// release IPin interface
pPin->Release();
// construct device control
- CControlNode * handler = new CControlNode(hFile, NodeType, PinId);
+ CControlNode * handler = new CControlNode(pProperty, NodeType, PinId);
#ifdef BDAPLGIN_TRACE
OutputDebugStringW(L"CControlNode_fnConstructor\n");
hr = KsSynchronousDeviceControl(m_Handle, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSP_BDA_NODE_PIN) + sizeof(ULONG), &PinId, sizeof(ULONG), &BytesReturned);
#ifdef BDAPLGIN_TRACE
- WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu\n", hr, BytesReturned, PinId);
+ WCHAR Buffer[200];
+ swprintf(Buffer, L"CBDADeviceControl::GetControlNode: hr %lx, BytesReturned %lu PinId %lu ulInputPinId %lu ulOutputPinId %lu ulNodeType %lu\n", hr, BytesReturned, PinId, ulInputPinId, ulOutputPinId, ulNodeType);
OutputDebugStringW(Buffer);
#endif
HRESULT STDMETHODCALLTYPE put_SpectralInversion(SpectralInversion *pSpectralInversion);
HRESULT STDMETHODCALLTYPE get_SpectralInversion(SpectralInversion *pSpectralInversion);
- CBDADigitalDemodulator(HANDLE hFile, ULONG NodeId) : m_Ref(0), m_hFile(hFile), m_NodeId(NodeId){};
+ CBDADigitalDemodulator(IKsPropertySet * pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
~CBDADigitalDemodulator(){};
protected:
LONG m_Ref;
- HANDLE m_hFile;
+ IKsPropertySet * m_pProperty;
ULONG m_NodeId;
};
swprintf(Buffer, L"CBDADigitalDemodulator::QueryInterface: NoInterface for %s", lpstr);
OutputDebugStringW(Buffer);
CoTaskMemFree(lpstr);
+DebugBreak();
#endif
return E_NOINTERFACE;
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
-
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_MODULATION_TYPE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pModulationType, sizeof(ModulationType), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_MODULATION_TYPE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pModulationType, sizeof(ModulationType));
+
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_ModulationType: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_ModulationType: pModulationType %lu hr %lx\n", *pModulationType, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_INNER_FEC_TYPE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pFECMethod, sizeof(FECMethod), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_INNER_FEC_TYPE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pFECMethod, sizeof(FECMethod));
+
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_InnerFECMethod: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_InnerFECMethod: pFECMethod %lu hr %lx\n", *pFECMethod, hr);
OutputDebugStringW(Buffer);
#endif
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
-
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_INNER_FEC_RATE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pFECRate, sizeof(BinaryConvolutionCodeRate), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_INNER_FEC_RATE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pFECRate, sizeof(BinaryConvolutionCodeRate));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_InnerFECRate: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_InnerFECRate: pFECRate %lu hr %lx\n", *pFECRate, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_OUTER_FEC_TYPE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pFECMethod, sizeof(FECMethod), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_OUTER_FEC_TYPE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pFECMethod, sizeof(FECMethod));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_OuterFECMethod: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_OuterFECMethod: pFECMethod %lu hr %lx\n", *pFECMethod, hr);
OutputDebugStringW(Buffer);
#endif
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
-
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_OUTER_FEC_RATE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pFECRate, sizeof(BinaryConvolutionCodeRate), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_OUTER_FEC_RATE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pFECRate, sizeof(BinaryConvolutionCodeRate));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_OuterFECRate: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_OuterFECRate: pFECRate %lu hr %lx\n", *pFECRate, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_SYMBOL_RATE;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pSymbolRate, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_SYMBOL_RATE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pSymbolRate, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_SymbolRate: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_SymbolRate: pSymbolRate %lu hr %lx\n", *pSymbolRate, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaDigitalDemodulator;
- Node.Property.Id = KSPROPERTY_BDA_SPECTRAL_INVERSION;
- Node.Property.Flags = KSPROPERTY_TYPE_TOPOLOGY | KSPROPERTY_TYPE_SET;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), pSpectralInversion, sizeof(SpectralInversion), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaDigitalDemodulator, KSPROPERTY_BDA_SPECTRAL_INVERSION, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), pSpectralInversion, sizeof(SpectralInversion));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDADigitalDemodulator::put_SpectralInversion: hr %lx, BytesReturned %lu\n", hr, BytesReturned);
+ swprintf(Buffer, L"CBDADigitalDemodulator::put_SpectralInversion: pSpectralInversion %lu hr %lx\n", *pSpectralInversion, hr);
OutputDebugStringW(Buffer);
#endif
HRESULT
WINAPI
CBDADigitalDemodulator_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv)
{
// construct device control
- CBDADigitalDemodulator * handler = new CBDADigitalDemodulator(hFile, NodeId);
+ CBDADigitalDemodulator * handler = new CBDADigitalDemodulator(pProperty, NodeId);
#ifdef BDAPLGIN_TRACE
OutputDebugStringW(L"CBDADigitalDemodulator_fnConstructor\n");
HRESULT STDMETHODCALLTYPE put_FrequencyMultiplier(ULONG ulMultiplier);
HRESULT STDMETHODCALLTYPE get_FrequencyMultiplier(ULONG *pulMultiplier);
- CBDAFrequencyFilter(HANDLE hFile, ULONG NodeId) : m_Ref(0), m_hFile(hFile), m_NodeId(NodeId){};
+ CBDAFrequencyFilter(IKsPropertySet * pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
virtual ~CBDAFrequencyFilter(){};
protected:
LONG m_Ref;
- HANDLE m_hFile;
+ IKsPropertySet * m_pProperty;
ULONG m_NodeId;
};
swprintf(Buffer, L"CControlNode::QueryInterface: NoInterface for %s", lpstr);
OutputDebugStringW(Buffer);
CoTaskMemFree(lpstr);
+DebugBreak();
#endif
return E_NOINTERFACE;
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
-
// setup request
- Node.Property.Set = KSPROPSETID_BdaFrequencyFilter;
- Node.Property.Id = KSPROPERTY_BDA_RF_TUNER_FREQUENCY;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulFrequency, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_FREQUENCY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulFrequency, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDAFrequencyFilter::put_Frequency: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDAFrequencyFilter::put_Frequency: m_NodeId %lu ulFrequency %lu hr %lx\n", m_NodeId, ulFrequency, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaFrequencyFilter;
- Node.Property.Id = KSPROPERTY_BDA_RF_TUNER_POLARITY;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &Polarity, sizeof(Polarisation), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_POLARITY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Polarity, sizeof(Polarisation));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDAFrequencyFilter::put_Polarity: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDAFrequencyFilter::put_Polarity: m_NodeId %lu Polarity %lu hr %lx\n", m_NodeId, Polarity, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaFrequencyFilter;
- Node.Property.Id = KSPROPERTY_BDA_RF_TUNER_RANGE;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulRange, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_RANGE, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulRange, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDAFrequencyFilter::put_Polarity: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDAFrequencyFilter::put_Range: m_NodeId %lu ulRange %lu hr %lx\n", m_NodeId, ulRange, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaFrequencyFilter;
- Node.Property.Id = KSPROPERTY_BDA_RF_TUNER_BANDWIDTH;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulBandwidth, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_BANDWIDTH, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulBandwidth, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDAFrequencyFilter::put_Bandwidth: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDAFrequencyFilter::put_Bandwidth: m_NodeId %lu ulBandwidth %lu hr %lx\n", m_NodeId, ulBandwidth, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaFrequencyFilter;
- Node.Property.Id = KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulMultiplier, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaFrequencyFilter, KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulMultiplier, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDAFrequencyFilter::put_FrequencyMultiplier: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDAFrequencyFilter::put_FrequencyMultiplier: m_NodeId %lu ulMultiplier %lu hr %lx\n", m_NodeId, ulMultiplier, hr);
OutputDebugStringW(Buffer);
#endif
HRESULT
WINAPI
CBDAFrequencyFilter_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet* pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv)
{
// construct device control
- CBDAFrequencyFilter * handler = new CBDAFrequencyFilter(hFile, NodeId);
+ CBDAFrequencyFilter * handler = new CBDAFrequencyFilter(pProperty, NodeId);
#ifdef BDAPLGIN_TRACE
OutputDebugStringW(L"CBDAFrequencyFilter_fnConstructor\n");
HRESULT STDMETHODCALLTYPE put_HighLowSwitchFrequency(ULONG ulSwitchFrequency);
HRESULT STDMETHODCALLTYPE get_HighLowSwitchFrequency(ULONG *pulSwitchFrequency);
- CBDALNBInfo(HANDLE hFile, ULONG NodeId) : m_Ref(0), m_hFile(hFile), m_NodeId(NodeId){};
+ CBDALNBInfo(IKsPropertySet *pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
~CBDALNBInfo(){};
protected:
LONG m_Ref;
- HANDLE m_hFile;
+ IKsPropertySet * m_pProperty;
ULONG m_NodeId;
};
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaLNBInfo;
- Node.Property.Id = KSPROPERTY_BDA_LNB_LOF_LOW_BAND;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulLOFLow, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_LOF_LOW_BAND, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulLOFLow, sizeof(LONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDALNBInfo::put_LocalOscilatorFrequencyLowBand: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDALNBInfo::put_LocalOscilatorFrequencyLowBand: m_NodeId %lu ulLOFLow %lu hr %lx\n", m_NodeId, ulLOFLow, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaLNBInfo;
- Node.Property.Id = KSPROPERTY_BDA_LNB_LOF_HIGH_BAND;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulLOFHigh, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_LOF_HIGH_BAND, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulLOFHigh, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDALNBInfo::put_LocalOscilatorFrequencyHighBand: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDALNBInfo::put_LocalOscilatorFrequencyHighBand: m_NodeId %lu ulLOFHigh %lu hr %lx\n", m_NodeId, ulLOFHigh, hr);
OutputDebugStringW(Buffer);
#endif
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaLNBInfo;
- Node.Property.Id = KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = m_NodeId;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &ulSwitchFrequency, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaLNBInfo, KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &ulSwitchFrequency, sizeof(ULONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDALNBInfo::put_HighLowSwitchFrequency: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDALNBInfo::put_HighLowSwitchFrequency: m_NodeId %lu ulSwitchFrequency %lu hr %lx\n", m_NodeId, ulSwitchFrequency, hr);
OutputDebugStringW(Buffer);
#endif
HRESULT
WINAPI
CBDALNBInfo_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet *pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv)
{
// construct device control
- CBDALNBInfo * handler = new CBDALNBInfo(hFile, NodeId);
+ CBDALNBInfo * handler = new CBDALNBInfo(pProperty, NodeId);
#ifdef BDAPLGIN_TRACE
OutputDebugStringW(L"CBDALNBInfo_fnConstructor\n");
reinterpret_cast<IBDA_PinControl*>(*Output)->AddRef();
return NOERROR;
}
-
+DebugBreak();
return E_NOINTERFACE;
}
//-------------------------------------------------------------------
if (!pUnkOuter)
return E_POINTER;
+ OutputDebugStringW(L"CBDAPinControl_fnConstructor\n");
+ //DebugBreak();
+
// query for IKsObject interface
hr = pUnkOuter->QueryInterface(IID_IKsObject, (void**)&pObject);
hr = E_UNEXPECTED;
}
}
+ else
+ {
+ WCHAR Buffer[100];
+ swprintf(Buffer, L"CBDAPinControl_fnConstructor failed to register filter with %lx\n", hr);
+ OutputDebugStringW(Buffer);
+ DebugBreak();
+ }
}
}
}
#ifndef PRECOMP_H__
#define PRECOMP_H__
-//#define BDAPLGIN_TRACE
+#define BDAPLGIN_TRACE
#define BUILDING_KS
#define _KSDDK_
#include <dshow.h>
HRESULT
WINAPI
CBDAFrequencyFilter_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv);
HRESULT
WINAPI
CBDASignalStatistics_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv);
HRESULT
WINAPI
CBDALNBInfo_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv);
HRESULT
WINAPI
CBDADigitalDemodulator_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv);
HRESULT STDMETHODCALLTYPE put_SampleTime(LONG lmsSampleTime);
HRESULT STDMETHODCALLTYPE get_SampleTime(LONG *plmsSampleTime);
- CBDASignalStatistics(HANDLE hFile, ULONG NodeId) : m_Ref(0), m_hFile(hFile), m_NodeId(NodeId){};
+ CBDASignalStatistics(IKsPropertySet * pProperty, ULONG NodeId) : m_Ref(0), m_pProperty(pProperty), m_NodeId(NodeId){};
~CBDASignalStatistics(){};
protected:
LONG m_Ref;
- HANDLE m_hFile;
+ IKsPropertySet * m_pProperty;
ULONG m_NodeId;
};
reinterpret_cast<IBDA_SignalStatistics*>(*Output)->AddRef();
return NOERROR;
}
-
return E_NOINTERFACE;
}
ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SIGNAL_STRENGTH;
- Node.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
+
+ assert(m_pProperty);
+
+ hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_STRENGTH, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plDbStrength, sizeof(LONG), &BytesReturned);
- // perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), plDbStrength, sizeof(LONG), &BytesReturned);
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SIGNAL_QUALITY;
- Node.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), plPercentQuality, sizeof(LONG), &BytesReturned);
+ hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_QUALITY, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plPercentQuality, sizeof(LONG), &BytesReturned);
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SIGNAL_PRESENT;
- Node.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &Present, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_PRESENT, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Present, sizeof(ULONG), &BytesReturned);
+
// store result
*pfPresent = Present;
ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SIGNAL_LOCKED;
- Node.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &Locked, sizeof(ULONG), &BytesReturned);
+ hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SIGNAL_LOCKED, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &Locked, sizeof(ULONG), &BytesReturned);
+
*pfLocked = Locked;
#ifdef BDAPLGIN_TRACE
{
KSP_NODE Node;
HRESULT hr;
- ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SAMPLE_TIME;
- Node.Property.Flags = KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), &lmsSampleTime, sizeof(LONG), &BytesReturned);
+ hr = m_pProperty->Set(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SAMPLE_TIME, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), &lmsSampleTime, sizeof(LONG));
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
- swprintf(Buffer, L"CBDASignalStatistics::put_SampleTime: m_NodeId %lu hr %lx, BytesReturned %lu\n", m_NodeId, hr, BytesReturned);
+ swprintf(Buffer, L"CBDASignalStatistics::put_SampleTime: m_NodeId %lu hr %lx\n", m_NodeId, hr);
OutputDebugStringW(Buffer);
#endif
ULONG BytesReturned;
// setup request
- Node.Property.Set = KSPROPSETID_BdaSignalStats;
- Node.Property.Id = KSPROPERTY_BDA_SAMPLE_TIME;
- Node.Property.Flags = KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY;
Node.NodeId = (ULONG)-1;
+ Node.Reserved = 0;
// perform request
- hr = KsSynchronousDeviceControl(m_hFile, IOCTL_KS_PROPERTY, (PVOID)&Node, sizeof(KSP_NODE), plmsSampleTime, sizeof(LONG), &BytesReturned);
+ hr = m_pProperty->Get(KSPROPSETID_BdaSignalStats, KSPROPERTY_BDA_SAMPLE_TIME, &Node.NodeId, sizeof(KSP_NODE)-sizeof(KSPROPERTY), plmsSampleTime, sizeof(LONG), &BytesReturned);
#ifdef BDAPLGIN_TRACE
WCHAR Buffer[100];
HRESULT
WINAPI
CBDASignalStatistics_fnConstructor(
- HANDLE hFile,
+ IKsPropertySet * pProperty,
ULONG NodeId,
REFIID riid,
LPVOID * ppv)
{
// construct device control
- CBDASignalStatistics * handler = new CBDASignalStatistics(hFile, NodeId);
+ CBDASignalStatistics * handler = new CBDASignalStatistics(pProperty, NodeId);
#ifdef BDAPLGIN_TRACE
OutputDebugStringW(L"CBDASignalStatistics_fnConstructor\n");
#include "wine/debug.h"
#include "mmddk.h"
+#include <regstr.h>
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
WCHAR wszRegKey[MAX_PATH];
HKEY hkey;
HKEY hbasekey;
+ BOOL bInterface = FALSE;
CreateDevEnumImpl *This = (CreateDevEnumImpl *)iface;
TRACE("(%p)->(%s, %p, %lx)\n\tDeviceClass:\t%s\n", This, debugstr_guid(clsidDeviceClass), ppEnumMoniker, dwFlags, debugstr_guid(clsidDeviceClass));
}
else
{
- FIXME("Category %s not found\n", debugstr_guid(clsidDeviceClass));
- return S_FALSE;
+ wcscpy(wszRegKey, REGSTR_PATH_DEVICE_CLASSES);
+ wcscat(wszRegKey, L"\\");
+
+ if (!StringFromGUID2(clsidDeviceClass, wszRegKey + wcslen(wszRegKey), MAX_PATH - CLSID_STR_LEN))
+ return E_OUTOFMEMORY;
+
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRegKey, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
+ {
+ FIXME("Category %s not found\n", debugstr_guid(clsidDeviceClass));
+ return S_FALSE;
+ }
+
+ bInterface = TRUE;
}
}
- return DEVENUM_IEnumMoniker_Construct(hkey, ppEnumMoniker);
+ return DEVENUM_IEnumMoniker_Construct(hkey, ppEnumMoniker, bInterface);
}
/**********************************************************************
LONG ref;
DWORD index;
HKEY hkey;
+ BOOL bInterface;
} EnumMonikerImpl;
typedef struct
LONG ref;
HKEY hkey;
+ BOOL bInterface;
} MediaCatMoniker;
MediaCatMoniker * DEVENUM_IMediaCatMoniker_Construct(void);
-HRESULT DEVENUM_IEnumMoniker_Construct(HKEY hkey, IEnumMoniker ** ppEnumMoniker);
+HRESULT DEVENUM_IEnumMoniker_Construct(HKEY hkey, IEnumMoniker ** ppEnumMoniker, BOOL bInterface);
HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
ICreateDevEnum * iface,
REFCLSID clsidDeviceClass,
IPropertyBagVtbl *lpVtbl;
LONG ref;
HKEY hkey;
+ BOOL bInterface;
} RegPropBagImpl;
RegPropBagImpl *This = (RegPropBagImpl *)iface;
HRESULT res = S_OK;
LONG reswin32;
+ WCHAR buffer[MAX_PATH];
+ HKEY hkey;
+ LPCOLESTR pszName;
TRACE("(%p)->(%s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
if (!pszPropName || !pVar)
return E_POINTER;
- reswin32 = RegQueryValueExW(This->hkey, pszPropName, NULL, NULL, NULL, &received);
+ hkey = This->hkey;
+ pszName = pszPropName;
+ if (This->bInterface)
+ {
+ buffer[0] = 0;
+ received = sizeof(buffer)/sizeof(WCHAR);
+ reswin32 = RegEnumKeyEx(This->hkey, 0, buffer, &received, NULL, NULL, NULL, NULL);
+
+ reswin32 = RegOpenKeyExW(This->hkey, buffer, 0, KEY_READ, &hkey);
+
+ if (!wcsicmp(pszPropName, L"DevicePath"))
+ pszName = L"SymbolicLink";
+
+ }
+
+ reswin32 = RegQueryValueExW(hkey, pszName, NULL, NULL, NULL, &received);
res = HRESULT_FROM_WIN32(reswin32);
if (SUCCEEDED(res))
pData = HeapAlloc(GetProcessHeap(), 0, received);
/* work around a GCC bug that occurs here unless we use the reswin32 variable as well */
- reswin32 = RegQueryValueExW(This->hkey, pszPropName, NULL, &type, pData, &received);
+ reswin32 = RegQueryValueExW(hkey, pszName, NULL, &type, pData, &received);
res = HRESULT_FROM_WIN32(reswin32);
}
if (pData)
HeapFree(GetProcessHeap(), 0, pData);
+ if (This->bInterface)
+ RegCloseKey(hkey);
+
TRACE("<- %lx\n", res);
return res;
}
DEVENUM_IPropertyBag_Write
};
-static HRESULT DEVENUM_IPropertyBag_Construct(HANDLE hkey, IPropertyBag **ppBag)
+static HRESULT DEVENUM_IPropertyBag_Construct(HANDLE hkey, IPropertyBag **ppBag, BOOL bInterface)
{
RegPropBagImpl * rpb = CoTaskMemAlloc(sizeof(RegPropBagImpl));
if (!rpb)
rpb->lpVtbl = &IPropertyBag_Vtbl;
rpb->ref = 1;
rpb->hkey = hkey;
+ rpb->bInterface = bInterface;
+
*ppBag = (IPropertyBag*)rpb;
DEVENUM_LockModule();
return S_OK;
{
IUnknown * pObj = NULL;
IPropertyBag * pProp = NULL;
+ IPersistPropertyBag * pBag;
CLSID clsID;
VARIANT var;
HRESULT res = E_FAIL;
if (pObj!=NULL)
{
+ if (This->bInterface)
+ {
+ res = IUnknown_QueryInterface(pObj, &IID_IPersistPropertyBag, (void**)&pBag);
+ if (SUCCEEDED(res))
+ {
+ res = IPersistPropertyBag_Load(pBag, pProp, NULL); /* FIXME */
+ IPersistPropertyBag_Release(pBag);
+ }
+ }
/* get the requested interface from the loaded class */
res= IUnknown_QueryInterface(pObj,riidResult,ppvResult);
}
{
HANDLE hkey;
DuplicateHandle(GetCurrentProcess(), This->hkey, GetCurrentProcess(), &hkey, 0, 0, DUPLICATE_SAME_ACCESS);
- return DEVENUM_IPropertyBag_Construct(hkey, (IPropertyBag**)ppvObj);
+ return DEVENUM_IPropertyBag_Construct(hkey, (IPropertyBag**)ppvObj, This->bInterface);
}
return MK_E_NOSTORAGE;
pMoniker->lpVtbl = &IMoniker_Vtbl;
pMoniker->ref = 0;
pMoniker->hkey = NULL;
+ pMoniker->bInterface = FALSE;
DEVENUM_IMediaCatMoniker_AddRef((LPMONIKER)pMoniker);
if (!pMoniker)
return E_OUTOFMEMORY;
+ pMoniker->bInterface = This->bInterface;
if (RegOpenKeyW(This->hkey, buffer, &pMoniker->hkey) != ERROR_SUCCESS)
{
DEVENUM_IMediaCatMoniker_Release((LPMONIKER)pMoniker);
DEVENUM_IEnumMoniker_Clone
};
-HRESULT DEVENUM_IEnumMoniker_Construct(HKEY hkey, IEnumMoniker ** ppEnumMoniker)
+HRESULT DEVENUM_IEnumMoniker_Construct(HKEY hkey, IEnumMoniker ** ppEnumMoniker, BOOL bInterface)
{
EnumMonikerImpl * pEnumMoniker = CoTaskMemAlloc(sizeof(EnumMonikerImpl));
if (!pEnumMoniker)
pEnumMoniker->ref = 1;
pEnumMoniker->index = 0;
pEnumMoniker->hkey = hkey;
+ pEnumMoniker->bInterface = bInterface;
*ppEnumMoniker = (IEnumMoniker *)pEnumMoniker;
<directory name="msdmo">
<xi:include href="msdmo/msdmo.rbuild" />
</directory>
+ <directory name="msdvbnp">
+ <xi:include href="msdvbnp/msdvbnp.rbuild" />
+ </directory>
+ <directory name="msvidctl">
+ <xi:include href="msvidctl/msvidctl.rbuild" />
+ </directory>
<directory name="qedit">
<xi:include href="qedit/qedit.rbuild" />
</directory>
return NOERROR;
}
+ WCHAR Buffer[100];
+ LPOLESTR lpstr;
+ StringFromCLSID(refiid, &lpstr);
+ swprintf(Buffer, L"CEnumPins::QueryInterface: NoInterface for %s\n", lpstr);
+ OutputDebugStringW(Buffer);
+ CoTaskMemFree(lpstr);
+
+DebugBreak();
return E_NOINTERFACE;
}
{
#ifdef KSPROXY_TRACE
OutputDebugStringW(L"CInputPin::CreatePinHandle GetSupportedSets failed\n");
+ DebugBreak();
#endif
return hr;
}
{
#ifdef KSPROXY_TRACE
OutputDebugStringW(L"CInputPin::CreatePinHandle LoadProxyPlugins failed\n");
+ DebugBreak();
#endif
return hr;
}
Length = NumProperty + NumMethods + NumEvents;
+ assert(Length);
+
// allocate guid buffer
pGuid = (LPGUID)CoTaskMemAlloc(Length);
if (!pGuid)
NumMethods /= sizeof(GUID);
NumEvents /= sizeof(GUID);
+#ifdef KSPROXY_TRACE
+ WCHAR Buffer[200];
+ swprintf(Buffer, L"CInputPin::GetSupportedSets NumProperty %lu NumMethods %lu NumEvents %lu\n", NumProperty, NumMethods, NumEvents);
+ OutputDebugStringW(Buffer);
+#endif
+
// get all properties
hr = KsSynchronousDeviceControl(m_hPin, IOCTL_KS_PROPERTY, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)pGuid, Length, &BytesReturned);
if (FAILED(hr))
Length -= BytesReturned;
// get all methods
- if (Length)
+ if (Length && NumMethods)
{
hr = KsSynchronousDeviceControl(m_hPin, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty], Length, &BytesReturned);
if (FAILED(hr))
}
// get all events
- if (Length)
+ if (Length && NumEvents)
{
hr = KsSynchronousDeviceControl(m_hPin, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty+NumMethods], Length, &BytesReturned);
if (FAILED(hr))
Length -= BytesReturned;
}
-#ifdef KSPROXY_TRACE
- WCHAR Buffer[200];
- swprintf(Buffer, L"NumProperty %lu NumMethods %lu NumEvents %lu\n", NumProperty, NumMethods, NumEvents);
- OutputDebugStringW(Buffer);
-#endif
-
*pOutGuid = pGuid;
*NumGuids = NumProperty+NumEvents+NumMethods;
return S_OK;
{
// store plugin
m_Plugins.push_back(pUnknown);
+DebugBreak();
}
// close key
RegCloseKey(hSubKey);
WINAPI
DllUnregisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass;
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ RegDeleteKeyW(hClass, pStr);
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
extern "C"
WINAPI
DllRegisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass, hKey, hSubKey;
+ static LPCWSTR ModuleName = L"ksproxy.ax";
+ static LPCWSTR ThreadingModel = L"Both";
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
+ {
+ if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
+ RegCloseKey(hSubKey);
+ }
+ RegCloseKey(hKey);
+ }
+
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
KSDDKAPI
<group>
<module name="ksproxy" type="win32dll" entrypoint="0" baseaddress="${BASEADDRESS_KSPROXY}" installbase="system32" installname="ksproxy.ax">
<importlibrary definition="ksproxy.spec" />
+ <autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<include base="ksproxy">.</include>
<library>ntdll</library>
<library>kernel32</library>
hr = CreatePinHandle(Medium, Interface, pmt);
if (FAILED(hr))
{
- m_InterfaceHandler->Release();
- m_InterfaceHandler = InterfaceHandler;
+#ifdef KSPROXY_TRACE
+ WCHAR Buffer[100];
+ swprintf(Buffer, L"COutputPin::CreatePinHandle failed with %lx\n", hr);
+ OutputDebugStringW(Buffer);
+#endif
+ return hr;
}
if (!m_InterfaceHandler)
{
#ifdef KSPROXY_TRACE
OutputDebugStringW(L"CInputPin::CreatePinHandle GetSupportedSets failed\n");
+ DebugBreak();
#endif
return hr;
}
{
#ifdef KSPROXY_TRACE
OutputDebugStringW(L"CInputPin::CreatePinHandle LoadProxyPlugins failed\n");
+ DebugBreak();
#endif
return hr;
}
Length = NumProperty + NumMethods + NumEvents;
+ assert(Length);
+
// allocate guid buffer
pGuid = (LPGUID)CoTaskMemAlloc(Length);
if (!pGuid)
Length -= BytesReturned;
// get all methods
- if (Length)
+ if (Length && NumMethods)
{
hr = KsSynchronousDeviceControl(m_hPin, IOCTL_KS_METHOD, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty], Length, &BytesReturned);
if (FAILED(hr))
}
// get all events
- if (Length)
+ if (Length && NumEvents)
{
hr = KsSynchronousDeviceControl(m_hPin, IOCTL_KS_ENABLE_EVENT, (PVOID)&Property, sizeof(KSPROPERTY), (PVOID)&pGuid[NumProperty+NumMethods], Length, &BytesReturned);
if (FAILED(hr))
{
// store plugin
m_Plugins.push_back(pUnknown);
+DebugBreak();
}
// close key
RegCloseKey(hSubKey);
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS BDA Proxy
+ * FILE: dll/directx/msdvbnp/ethernetfilter.cpp
+ * PURPOSE: IBDA_EthernetFilter interface
+ *
+ * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+class CEthernetFilter : public IBDA_EthernetFilter
+{
+public:
+ STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
+
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ //IBDA_EthernetFilter
+ HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses);
+ HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList);
+ HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList);
+ HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask);
+ HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask);
+
+
+ CEthernetFilter(IBDA_NetworkProvider * pNetworkProvider);
+ virtual ~CEthernetFilter();
+
+protected:
+ IBDA_NetworkProvider * m_pNetworkProvider;
+ ULONG m_ulcbAddresses;
+ BYTE * m_pAddressList;
+ ULONG m_ulModeMask;
+};
+
+CEthernetFilter::CEthernetFilter(
+ IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider),
+ m_ulcbAddresses(0),
+ m_pAddressList(0),
+ m_ulModeMask(0)
+{
+}
+
+CEthernetFilter::~CEthernetFilter()
+{
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::QueryInterface(
+ REFIID InterfaceId,
+ PVOID* Interface)
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->QueryInterface(InterfaceId, Interface);
+}
+
+ULONG
+STDMETHODCALLTYPE
+CEthernetFilter::AddRef()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->AddRef();
+}
+
+ULONG
+STDMETHODCALLTYPE
+CEthernetFilter::Release()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->Release();
+}
+
+//-------------------------------------------------------------------
+//IBDA_EthernetFilter
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::PutMulticastList(
+ ULONG ulcbAddresses,
+ BYTE * pAddressList)
+{
+ if (!ulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+
+ m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses);
+ if (!m_pAddressList)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(m_pAddressList, pAddressList, ulcbAddresses);
+ m_ulcbAddresses = ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::GetMulticastList(
+ ULONG *pulcbAddresses,
+ BYTE *pAddressList)
+{
+ if (!pulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (*pulcbAddresses < m_ulcbAddresses)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses);
+ *pulcbAddresses = m_ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::GetMulticastListSize(
+ ULONG *pulcbAddresses)
+{
+ if (!pulcbAddresses)
+ return E_POINTER;
+
+ *pulcbAddresses = m_ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::PutMulticastMode(
+ ULONG ulModeMask)
+{
+ m_ulModeMask = ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CEthernetFilter::GetMulticastMode(
+ ULONG *pulModeMask)
+{
+ *pulModeMask = m_ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+WINAPI
+CEthernetFilter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv)
+{
+ CEthernetFilter * filter = new CEthernetFilter(pNetworkProvider);
+
+ if (!filter)
+ return E_OUTOFMEMORY;
+
+ if (FAILED(filter->QueryInterface(riid, ppv)))
+ {
+ /* not supported */
+ delete filter;
+ return E_NOINTERFACE;
+ }
+
+ return NOERROR;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS BDA Proxy
+ * FILE: dll/directx/msdvbnp/ipv4.cpp
+ * PURPOSE: IBDA_IPV4Filter interface
+ *
+ * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+class CIPV4Filter : public IBDA_IPV4Filter
+{
+public:
+ STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ //IBDA_IPV4Filter
+ HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses);
+ HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList);
+ HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList);
+ HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask);
+ HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask);
+
+
+ CIPV4Filter(IBDA_NetworkProvider * pNetworkProvider);
+ virtual ~CIPV4Filter();
+
+protected:
+ IBDA_NetworkProvider * m_pNetworkProvider;
+ ULONG m_ulcbAddresses;
+ BYTE * m_pAddressList;
+ ULONG m_ulModeMask;
+};
+
+CIPV4Filter::CIPV4Filter(
+ IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider),
+ m_ulcbAddresses(0),
+ m_pAddressList(0),
+ m_ulModeMask(0)
+{
+}
+
+CIPV4Filter::~CIPV4Filter()
+{
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+}
+
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::QueryInterface(
+ REFIID InterfaceId,
+ PVOID* Interface)
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->QueryInterface(InterfaceId, Interface);
+}
+
+ULONG
+STDMETHODCALLTYPE
+CIPV4Filter::AddRef()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->AddRef();
+}
+
+ULONG
+STDMETHODCALLTYPE
+CIPV4Filter::Release()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->Release();
+}
+
+//-------------------------------------------------------------------
+//IBDA_IPV4Filter
+//
+
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::GetMulticastListSize(
+ ULONG *pulcbAddresses)
+{
+ if (!pulcbAddresses)
+ return E_POINTER;
+
+ *pulcbAddresses = 0;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::PutMulticastList(
+ ULONG ulcbAddresses,
+ BYTE * pAddressList)
+{
+ if (!ulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+
+ m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses);
+ if (!m_pAddressList)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(m_pAddressList, pAddressList, ulcbAddresses);
+ m_ulcbAddresses = ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::GetMulticastList(
+ ULONG *pulcbAddresses,
+ BYTE *pAddressList)
+{
+ if (!pulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (*pulcbAddresses < m_ulcbAddresses)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses);
+ *pulcbAddresses = m_ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::PutMulticastMode(
+ ULONG ulModeMask)
+{
+ m_ulModeMask = ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV4Filter::GetMulticastMode(
+ ULONG *pulModeMask)
+{
+ *pulModeMask = m_ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+WINAPI
+CIPV4Filter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv)
+{
+ CIPV4Filter * filter = new CIPV4Filter(pNetworkProvider);
+
+ if (!filter)
+ return E_OUTOFMEMORY;
+
+ if (FAILED(filter->QueryInterface(riid, ppv)))
+ {
+ /* not supported */
+ delete filter;
+ return E_NOINTERFACE;
+ }
+
+ return NOERROR;
+}
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS BDA Proxy
+ * FILE: dll/directx/msdvbnp/ipv6.cpp
+ * PURPOSE: IBDA_IPV6Filter interface
+ *
+ * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org)
+ */
+#include "precomp.h"
+
+class CIPV6Filter : public IBDA_IPV6Filter
+{
+public:
+ STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
+ STDMETHODIMP_(ULONG) AddRef();
+ STDMETHODIMP_(ULONG) Release();
+
+ //IBDA_IPV6Filter
+ HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses);
+ HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList);
+ HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList);
+ HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask);
+ HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask);
+
+ CIPV6Filter(IBDA_NetworkProvider * pNetworkProvider);
+ virtual ~CIPV6Filter();
+
+protected:
+ IBDA_NetworkProvider * m_pNetworkProvider;
+ ULONG m_ulcbAddresses;
+ BYTE * m_pAddressList;
+ ULONG m_ulModeMask;
+};
+
+CIPV6Filter::CIPV6Filter(
+ IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider),
+ m_ulcbAddresses(0),
+ m_pAddressList(0),
+ m_ulModeMask(0)
+{
+}
+
+CIPV6Filter::~CIPV6Filter()
+{
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::QueryInterface(
+ REFIID InterfaceId,
+ PVOID* Interface)
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->QueryInterface(InterfaceId, Interface);
+}
+
+ULONG
+STDMETHODCALLTYPE
+CIPV6Filter::AddRef()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->AddRef();
+}
+
+ULONG
+STDMETHODCALLTYPE
+CIPV6Filter::Release()
+{
+ assert(m_pNetworkProvider);
+ return m_pNetworkProvider->Release();
+}
+
+//-------------------------------------------------------------------
+//IBDA_IPV6Filter
+//
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::GetMulticastListSize(
+ ULONG *pulcbAddresses)
+{
+ if (!pulcbAddresses)
+ return E_POINTER;
+
+ *pulcbAddresses = 0;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::GetMulticastList(
+ ULONG *pulcbAddresses,
+ BYTE *pAddressList)
+{
+ if (!pulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (*pulcbAddresses < m_ulcbAddresses)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses);
+ *pulcbAddresses = m_ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::PutMulticastList(
+ ULONG ulcbAddresses,
+ BYTE * pAddressList)
+{
+ if (!ulcbAddresses || !pAddressList)
+ return E_POINTER;
+
+ if (m_pAddressList)
+ CoTaskMemFree(m_pAddressList);
+
+ m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses);
+ if (!m_pAddressList)
+ return E_OUTOFMEMORY;
+
+ CopyMemory(m_pAddressList, pAddressList, ulcbAddresses);
+ m_ulcbAddresses = ulcbAddresses;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::PutMulticastMode(
+ ULONG ulModeMask)
+{
+ m_ulModeMask = ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CIPV6Filter::GetMulticastMode(
+ ULONG *pulModeMask)
+{
+ *pulModeMask = m_ulModeMask;
+ return NOERROR;
+}
+
+HRESULT
+WINAPI
+CIPV6Filter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv)
+{
+ CIPV6Filter * filter = new CIPV6Filter(pNetworkProvider);
+
+ if (!filter)
+ return E_OUTOFMEMORY;
+
+ if (FAILED(filter->QueryInterface(riid, ppv)))
+ {
+ /* not supported */
+ delete filter;
+ return E_NOINTERFACE;
+ }
+
+ return NOERROR;
+}
#include "precomp.h"
-const GUID CLSID_DVBTNetworkProvider = {0x216c62df, 0x6d7f, 0x4e9a, {0x85, 0x71, 0x5, 0xf1, 0x4e, 0xdb, 0x76, 0x6a}};
-
static INTERFACE_TABLE InterfaceTable[] =
{
{&CLSID_DVBTNetworkProvider, CNetworkProvider_fnConstructor},
WINAPI
DllUnregisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass;
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ RegDeleteKeyW(hClass, pStr);
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
extern "C"
WINAPI
DllRegisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass, hKey, hSubKey;
+ static LPCWSTR ModuleName = L"msdvbnp.ax";
+ static LPCWSTR ThreadingModel = L"Both";
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
+ {
+ if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
+ RegCloseKey(hSubKey);
+ }
+ RegCloseKey(hKey);
+ }
+
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
KSDDKAPI
{
UINT i;
HRESULT hres = E_OUTOFMEMORY;
- IClassFactory * pcf = NULL;
+ IClassFactory * pcf = NULL;
if (!ppv)
return E_INVALIDARG;
}
}
- if (!pcf)
+ if (!pcf)
{
return CLASS_E_CLASSNOTAVAILABLE;
}
<group>
<module name="msdvbnp" type="win32dll" baseaddress="${BASEADDRESS_MSDVBNP}" installbase="system32" installname="msdvbnp.ax">
<importlibrary definition="msdvbnp.spec" />
+ <autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<include base="msdvbnp">.</include>
<library>ntdll</library>
<library>kernel32</library>
<file>classfactory.cpp</file>
<file>enum_mediatypes.cpp</file>
<file>enumpins.cpp</file>
+ <file>ethernetfilter.cpp</file>
<file>msdvbnp.cpp</file>
<file>msdvbnp.rc</file>
+ <file>ipv4.cpp</file>
+ <file>ipv6.cpp</file>
<file>networkprovider.cpp</file>
<file>pin.cpp</file>
<file>scanningtuner.cpp</file>
*/
#include "precomp.h"
+#define DEVICE_FILTER_MASK (0x80000000)
+
class CNetworkProvider : public IBaseFilter,
public IAMovieSetup,
public IBDA_NetworkProvider
{
public:
+ typedef std::vector<IUnknown*>DeviceFilterStack;
+
STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface);
STDMETHODIMP_(ULONG) AddRef()
HRESULT STDMETHODCALLTYPE RegisterDeviceFilter(IUnknown *pUnkFilterControl, ULONG *ppvRegisitrationContext);
HRESULT STDMETHODCALLTYPE UnRegisterDeviceFilter(ULONG pvRegistrationContext);
- CNetworkProvider() : m_Ref(0), m_pGraph(0), m_ReferenceClock(0), m_FilterState(State_Stopped) {m_Pins[0] = 0;};
+ CNetworkProvider(LPCGUID ClassID);
virtual ~CNetworkProvider(){};
protected:
IReferenceClock * m_ReferenceClock;
FILTER_STATE m_FilterState;
IPin * m_Pins[1];
+ GUID m_ClassID;
+ DeviceFilterStack m_DeviceFilters;
+ IScanningTuner * m_Tuner;
+ IBDA_IPV6Filter * m_IPV6Filter;
+ IBDA_IPV4Filter * m_IPV4Filter;
+ IBDA_EthernetFilter * m_EthernetFilter;
};
HRESULT
IN REFIID refiid,
OUT PVOID* Output)
{
+ ULONG Index;
+ HRESULT hr;
+
*Output = NULL;
if (IsEqualGUID(refiid, IID_IUnknown))
IsEqualGUID(refiid, IID_IScanningTuner))
{
// construct scanning tuner
- return CScanningTunner_fnConstructor(NULL, refiid, Output);
+ if (!m_Tuner)
+ {
+ HRESULT hr = CScanningTunner_fnConstructor(m_DeviceFilters, refiid, (void**)&m_Tuner);
+ if (FAILED(hr))
+ return hr;
+ }
+ m_Tuner->AddRef();
+ *Output = (IUnknown*)m_Tuner;
+
+ return NOERROR;
+ }
+
+ if (IsEqualGUID(refiid, IID_IBDA_IPV6Filter))
+ {
+ // construct scanning tuner
+ if (!m_IPV6Filter)
+ {
+ HRESULT hr = CIPV6Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV6Filter);
+ if (FAILED(hr))
+ return hr;
+ }
+ m_IPV6Filter->AddRef();
+ *Output = (IUnknown*)m_IPV6Filter;
+
+ return NOERROR;
+ }
+
+ if (IsEqualGUID(refiid, IID_IBDA_IPV4Filter))
+ {
+ // construct scanning tuner
+ if (!m_IPV4Filter)
+ {
+ HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV4Filter);
+ if (FAILED(hr))
+ return hr;
+ }
+ m_IPV4Filter->AddRef();
+ *Output = (IUnknown*)m_IPV4Filter;
+
+ return NOERROR;
+ }
+
+ if (IsEqualGUID(refiid, IID_IBDA_EthernetFilter))
+ {
+ // construct scanning tuner
+ if (!m_EthernetFilter)
+ {
+ HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_EthernetFilter);
+ if (FAILED(hr))
+ return hr;
+ }
+ m_EthernetFilter->AddRef();
+ *Output = (IUnknown*)m_EthernetFilter;
+
+ return NOERROR;
+ }
+
+ if (IsEqualGUID(refiid, IID_IBDA_NetworkProvider))
+ {
+ *Output = (IBDA_NetworkProvider*)(this);
+ reinterpret_cast<IBDA_NetworkProvider*>(*Output)->AddRef();
+ return NOERROR;
+ }
+
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get device filter
+ IUnknown *pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ // query for requested interface
+ hr = pFilter->QueryInterface(refiid, Output);
+ if (SUCCEEDED(hr))
+ {
+#ifdef MSDVBNP_TRACE
+ WCHAR Buffer[MAX_PATH];
+ LPOLESTR lpstr;
+ StringFromCLSID(refiid, &lpstr);
+ swprintf(Buffer, L"CNetworkProvider::QueryInterface: DeviceFilter %lu supports %s !!!\n", Index, lpstr);
+ OutputDebugStringW(Buffer);
+ CoTaskMemFree(lpstr);
+#endif
+ return hr;
+ }
}
WCHAR Buffer[MAX_PATH];
OutputDebugStringW(Buffer);
CoTaskMemFree(lpstr);
-
return E_NOINTERFACE;
}
+CNetworkProvider::CNetworkProvider(LPCGUID ClassID) : m_Ref(0),
+ m_pGraph(0),
+ m_ReferenceClock(0),
+ m_FilterState(State_Stopped),
+ m_DeviceFilters(),
+ m_Tuner(0),
+ m_IPV6Filter(0),
+ m_IPV4Filter(0),
+ m_EthernetFilter(0)
+{
+ m_Pins[0] = 0;
+
+ CopyMemory(&m_ClassID, ClassID, sizeof(GUID));
+};
+
//-------------------------------------------------------------------
// IBaseFilter interface
//
CNetworkProvider::GetClassID(
CLSID *pClassID)
{
- OutputDebugStringW(L"CNetworkProvider::GetClassID : NotImplemented\n");
- return E_NOTIMPL;
+ OutputDebugStringW(L"CNetworkProvider::GetClassID\n");
+ CopyMemory(&pClassID, &m_ClassID, sizeof(GUID));
+
+ return S_OK;
}
HRESULT
STDMETHODCALLTYPE
CNetworkProvider::Stop()
{
- OutputDebugStringW(L"CNetworkProvider::Stop : NotImplemented\n");
- return E_NOTIMPL;
+ OutputDebugStringW(L"CNetworkProvider::Stop\n");
+ m_FilterState = State_Stopped;
+ return S_OK;
}
HRESULT
STDMETHODCALLTYPE
CNetworkProvider::Pause()
{
- OutputDebugStringW(L"CNetworkProvider::Pause : NotImplemented\n");
- return E_NOTIMPL;
+ OutputDebugStringW(L"CNetworkProvider::Pause\n");
+
+ m_FilterState = State_Paused;
+ return S_OK;
}
HRESULT
CNetworkProvider::Run(
REFERENCE_TIME tStart)
{
- OutputDebugStringW(L"CNetworkProvider::Run : NotImplemented\n");
- return E_NOTIMPL;
+ OutputDebugStringW(L"CNetworkProvider::Run\n");
+
+ m_FilterState = State_Running;
+ return S_OK;
}
HRESULT
pClock->AddRef();
}
-
if (m_ReferenceClock)
{
m_ReferenceClock->Release();
pInfo->achName[0] = L'\0';
pInfo->pGraph = m_pGraph;
+ if (m_pGraph)
+ m_pGraph->AddRef();
+
return S_OK;
}
CNetworkProvider::QueryVendorInfo(
LPWSTR *pVendorInfo)
{
- OutputDebugStringW(L"CNetworkProvider::QueryVendorInfo : NotImplemented\n");
return E_NOTIMPL;
}
IUnknown *pUnkFilterControl,
ULONG *ppvRegisitrationContext)
{
- OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter : NotImplemented\n");
- return E_NOTIMPL;
+ HRESULT hr;
+ IBDA_DeviceControl * pDeviceControl = NULL;
+ IBDA_Topology *pTopology = NULL;
+
+ OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter\n");
+
+ if (!pUnkFilterControl || !ppvRegisitrationContext)
+ {
+ //invalid argument
+ return E_POINTER;
+ }
+
+ // the filter must support IBDA_DeviceControl and IBDA_Topology
+ hr = pUnkFilterControl->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
+ if (FAILED(hr))
+ {
+ OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IBDA_DeviceControl\n");
+ return hr;
+ }
+
+ hr = pUnkFilterControl->QueryInterface(IID_IBDA_Topology, (void**)&pTopology);
+ if (FAILED(hr))
+ {
+ pDeviceControl->Release();
+ OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter Filter does not support IID_IBDA_Topology\n");
+ return hr;
+ }
+
+ //TODO
+ // analyize device filter
+
+ // increment reference
+ pUnkFilterControl->AddRef();
+
+ // release IBDA_DeviceControl interface
+ pDeviceControl->Release();
+
+ // release IBDA_Topology interface
+ pTopology->Release();
+
+ // store registration ctx
+ *ppvRegisitrationContext = (m_DeviceFilters.size() | DEVICE_FILTER_MASK);
+
+ // store filter
+ m_DeviceFilters.push_back(pUnkFilterControl);
+
+ OutputDebugStringW(L"CNetworkProvider::RegisterDeviceFilter complete\n");
+
+ return S_OK;
}
HRESULT
STDMETHODCALLTYPE
CNetworkProvider::UnRegisterDeviceFilter(ULONG pvRegistrationContext)
{
- OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter : NotImplemented\n");
- return E_NOTIMPL;
+ ULONG Index;
+ IUnknown * pUnknown;
+
+ OutputDebugStringW(L"CNetworkProvider::UnRegisterDeviceFilter\n");
+
+ if (!(pvRegistrationContext & DEVICE_FILTER_MASK))
+ {
+ // invalid argument
+ return E_INVALIDARG;
+ }
+
+ // get real index
+ Index = pvRegistrationContext & ~DEVICE_FILTER_MASK;
+
+ if (Index >= m_DeviceFilters.size())
+ {
+ // invalid argument
+ return E_INVALIDARG;
+ }
+
+ pUnknown = m_DeviceFilters[Index];
+ if (!pUnknown)
+ {
+ // filter was already de-registered
+ return E_INVALIDARG;
+ }
+
+ // remove from vector
+ m_DeviceFilters[Index] = NULL;
+
+ // release extra reference
+ pUnknown->Release();
+
+ return NOERROR;
}
HRESULT
REFIID riid,
LPVOID * ppv)
{
- CNetworkProvider * handler = new CNetworkProvider();
+ CNetworkProvider * handler = new CNetworkProvider(&CLSID_DVBTNetworkProvider);
#ifdef MSDVBNP_TRACE
WCHAR Buffer[MAX_PATH];
*/
#include "precomp.h"
+#ifndef _MSC_VER
const GUID KSDATAFORMAT_TYPE_BDA_ANTENNA = {0x71985f41, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
+#endif
class CPin : public IPin
{
HRESULT STDMETHODCALLTYPE EndFlush();
HRESULT STDMETHODCALLTYPE NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- CPin(IBaseFilter * ParentFilter) : m_Ref(0), m_ParentFilter(ParentFilter){};
+ CPin(IBaseFilter * ParentFilter);
virtual ~CPin(){};
static LPCWSTR PIN_ID;
protected:
LONG m_Ref;
IBaseFilter * m_ParentFilter;
+ AM_MEDIA_TYPE m_MediaType;
+ IPin * m_Pin;
};
LPCWSTR CPin::PIN_ID = L"Antenna Out";
+
+CPin::CPin(
+ IBaseFilter * ParentFilter) : m_Ref(0),
+ m_ParentFilter(ParentFilter),
+ m_Pin(0)
+{
+ m_MediaType.majortype = KSDATAFORMAT_TYPE_BDA_ANTENNA;
+ m_MediaType.subtype = MEDIASUBTYPE_None;
+ m_MediaType.formattype = FORMAT_None;
+ m_MediaType.bFixedSizeSamples = true;
+ m_MediaType.bTemporalCompression = false;
+ m_MediaType.lSampleSize = sizeof(CHAR);
+ m_MediaType.pUnk = NULL;
+ m_MediaType.cbFormat = 0;
+ m_MediaType.pbFormat = NULL;
+}
+
+
HRESULT
STDMETHODCALLTYPE
CPin::QueryInterface(
STDMETHODCALLTYPE
CPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
{
+ HRESULT hr;
OutputDebugStringW(L"CPin::Connect called\n");
- return E_NOTIMPL;
+
+ if (pmt)
+ {
+ hr = pReceivePin->QueryAccept(pmt);
+ if (FAILED(hr))
+ {
+ OutputDebugStringW(L"CPin::Connect QueryAccept failed\n");
+ return hr;
+ }
+ }
+ else
+ {
+ // query accept
+ hr = pReceivePin->QueryAccept(&m_MediaType);
+ if (FAILED(hr))
+ {
+ OutputDebugStringW(L"CPin::Connect QueryAccept pmt default failed\n");
+ return hr;
+ }
+
+ pmt = &m_MediaType;
+ }
+
+ // receive connection;
+ hr = pReceivePin->ReceiveConnection((IPin*)this, pmt);
+ if (SUCCEEDED(hr))
+ {
+ // increment reference count
+ pReceivePin->AddRef();
+ m_Pin = pReceivePin;
+ OutputDebugStringW(L"CPin::Connect success\n");
+ }
+
+ return hr;
}
HRESULT
STDMETHODCALLTYPE
CPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE *pmt)
{
- OutputDebugStringW(L"CPin::ReceiveConnection called\n");
- return E_NOTIMPL;
+ return E_UNEXPECTED;
}
+
HRESULT
STDMETHODCALLTYPE
CPin::Disconnect( void)
{
- OutputDebugStringW(L"CPin::Disconnect called\n");
- return E_NOTIMPL;
+#ifdef MSDVBNP_TRACE
+ OutputDebugStringW(L"CPin::Disconnect\n");
+#endif
+
+ if (!m_Pin)
+ {
+ // pin was not connected
+ return S_FALSE;
+ }
+
+ m_Pin->Release();
+ m_Pin = NULL;
+
+ return S_OK;
}
HRESULT
STDMETHODCALLTYPE
CPin::ConnectedTo(IPin **pPin)
{
- OutputDebugStringW(L"CPin::ConnectedTo called\n");
+#ifdef MSDVBNP_TRACE
+ OutputDebugStringW(L"CPin::ConnectedTo\n");
+#endif
+
+ if (!pPin)
+ return E_POINTER;
+
+ if (m_Pin)
+ {
+ // increment reference count
+ m_Pin->AddRef();
+ *pPin = m_Pin;
+ return S_OK;
+ }
+
+ *pPin = NULL;
return VFW_E_NOT_CONNECTED;
}
HRESULT
STDMETHODCALLTYPE
CPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt)
{
- OutputDebugStringW(L"CPin::ConnectionMediaType called\n");
+ OutputDebugStringW(L"CPin::ConnectionMediaType NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::QueryAccept(const AM_MEDIA_TYPE *pmt)
{
- OutputDebugStringW(L"CPin::QueryAccept called\n");
+ OutputDebugStringW(L"CPin::QueryAccept NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::QueryInternalConnections(IPin **apPin, ULONG *nPin)
{
- OutputDebugStringW(L"CPin::QueryInternalConnections called\n");
+ OutputDebugStringW(L"CPin::QueryInternalConnections NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::EndOfStream( void)
{
- OutputDebugStringW(L"CPin::EndOfStream called\n");
+ OutputDebugStringW(L"CPin::EndOfStream NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::BeginFlush( void)
{
- OutputDebugStringW(L"CPin::BeginFlush called\n");
+ OutputDebugStringW(L"CPin::BeginFlush NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::EndFlush( void)
{
- OutputDebugStringW(L"CPin::EndFlush called\n");
+ OutputDebugStringW(L"CPin::EndFlush NotImplemented\n");
return E_NOTIMPL;
}
HRESULT
STDMETHODCALLTYPE
CPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- OutputDebugStringW(L"CPin::NewSegment called\n");
+ OutputDebugStringW(L"CPin::NewSegment NotImplemented\n");
return E_NOTIMPL;
}
#include <ks.h>
#define __STREAMS__
#include <ksproxy.h>
+#include <ksmedia.h>
#include <stdio.h>
#include <wchar.h>
#include <tchar.h>
#include <uuids.h>
#include <bdatypes.h>
#include <bdaiface.h>
+#include <bdatif.h>
#include <bdamedia.h>
#include <tuner.h>
#include <assert.h>
+#include <vector>
typedef HRESULT (CALLBACK *LPFNCREATEINSTANCE)(IUnknown* pUnkOuter, REFIID riid, LPVOID* ppvObject);
HRESULT
WINAPI
CScanningTunner_fnConstructor(
- IUnknown *pUnknown,
+ std::vector<IUnknown*> & m_DeviceFilter,
REFIID riid,
LPVOID * ppv);
REFIID riid,
LPVOID * ppv);
+/* ethernetfilter.cpp */
+HRESULT
+WINAPI
+CEthernetFilter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv);
+
+/* ipv6.cpp */
+HRESULT
+WINAPI
+CIPV6Filter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv);
+
+/* ipv4.cpp */
+HRESULT
+WINAPI
+CIPV4Filter_fnConstructor(
+ IBDA_NetworkProvider * pNetworkProvider,
+ REFIID riid,
+ LPVOID * ppv);
+
+#ifndef _MSC_VER
+extern const GUID CLSID_DVBTNetworkProvider;
+#endif
+
#endif
HRESULT STDMETHODCALLTYPE ScanDown(long MillisecondsPause);
HRESULT STDMETHODCALLTYPE AutoProgram();
- CScanningTunner() : m_Ref(0), m_TuningSpace(0){};
- virtual ~CScanningTunner(){};
-
+ CScanningTunner(std::vector<IUnknown*> & DeviceFilters) : m_Ref(0), m_TuningSpace(0), m_DeviceFilters(DeviceFilters){};
+ virtual ~CScanningTunner() {};
+ HRESULT STDMETHODCALLTYPE StartChanges();
+ HRESULT STDMETHODCALLTYPE CommitChanges();
+ HRESULT STDMETHODCALLTYPE CheckChanges();
+ HRESULT STDMETHODCALLTYPE SetLnbInfo(IBDA_LNBInfo * pLnbInfo, ULONG ulLOFLow, ULONG ulLOFHigh, ULONG ulSwitchFrequency);
+ HRESULT STDMETHODCALLTYPE SetDigitalDemodulator(IBDA_DigitalDemodulator * pDigitalDemo, ModulationType ModType, FECMethod InnerFEC, BinaryConvolutionCodeRate InnerFECRate, FECMethod OuterFEC, BinaryConvolutionCodeRate OuterFECRate, ULONG SymbolRate);
+ HRESULT SetFrequency(IBDA_FrequencyFilter * pFrequency, ULONG FrequencyMultiplier, ULONG Frequency, Polarisation Polarity, ULONG Range, ULONG Bandwidth);
+ HRESULT STDMETHODCALLTYPE performDVBTTune(IDVBTuneRequest * pDVBTRequest, IDVBTLocator *pDVBTLocator);
protected:
LONG m_Ref;
ITuningSpace * m_TuningSpace;
+ std::vector<IUnknown*> & m_DeviceFilters;
};
HRESULT
CScanningTunner::put_TuneRequest(
ITuneRequest *TuneRequest)
{
- OutputDebugStringW(L"CScanningTunner::put_TuneRequest : NotImplemented\n");
- return E_NOTIMPL;
+ IDVBTuneRequest * pDVBTRequest;
+ ILocator *pLocator;
+ IDVBTLocator *pDVBTLocator;
+ HRESULT hr;
+
+
+ OutputDebugStringW(L"CScanningTunner::put_TuneRequest\n");
+
+ // query for IDVBTuneRequest interface
+ hr = TuneRequest->QueryInterface(IID_IDVBTuneRequest, (void**)&pDVBTRequest);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ // get the IDVBTLocator
+ hr = pDVBTRequest->get_Locator((ILocator**)&pLocator);
+
+ // sanity check
+ assert(hr == NOERROR);
+ assert(pLocator);
+
+ hr = pLocator->QueryInterface(IID_ILocator, (void**)&pDVBTLocator);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+
+ StartChanges();
+ CommitChanges();
+ StartChanges();
+
+ hr = performDVBTTune(pDVBTRequest, pDVBTLocator);
+
+
+ pDVBTLocator->Release();
+ pDVBTRequest->Release();
+
+ CheckChanges();
+ CommitChanges();
+ StartChanges();
+
+ return NOERROR;
}
HRESULT
return E_NOTIMPL;
}
+//-------------------------------------------------------------------
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::performDVBTTune(
+ IDVBTuneRequest * pDVBTRequest,
+ IDVBTLocator *pDVBTLocator)
+{
+ HRESULT hr = S_OK;
+ ULONG Index;
+ IBDA_Topology *pTopo;
+ IUnknown *pNode;
+ IBDA_FrequencyFilter * pFrequency;
+ IBDA_LNBInfo * pLnbInfo;
+ IBDA_DigitalDemodulator *pDigitalDemo;
+ LONG BandWidth;
+ LONG Frequency;
+ LONG SymbolRate;
+ FECMethod InnerFEC, OuterFEC;
+ BinaryConvolutionCodeRate InnerFECRate, OuterFECRate;
+ ModulationType Modulation;
+
+ pDVBTLocator->get_Bandwidth(&BandWidth);
+ pDVBTLocator->get_CarrierFrequency(&Frequency);
+ pDVBTLocator->get_InnerFEC(&InnerFEC);
+ pDVBTLocator->get_InnerFECRate(&InnerFECRate);
+ pDVBTLocator->get_Modulation(&Modulation);
+ pDVBTLocator->get_OuterFEC(&OuterFEC);
+ pDVBTLocator->get_OuterFECRate(&OuterFECRate);
+ pDVBTLocator->get_SymbolRate(&SymbolRate);
+
+
+ WCHAR Buffer[1000];
+ swprintf(Buffer, L"BandWidth %lu Frequency %lu Rate %lu InnerFEC %ld OuterFEC %ld InnerFECRate %ld OuterFECRate %ld Modulation %lu\n",
+ BandWidth, Frequency, SymbolRate, InnerFEC, OuterFEC, InnerFECRate, OuterFECRate, Modulation);
+
+ OutputDebugStringW(Buffer);
+
+
+
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get device filter
+ IUnknown * pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ hr = pFilter->QueryInterface(IID_IBDA_Topology, (void**)&pTopo);
+ // sanity check
+ assert(hr == NOERROR);
+
+ pNode = NULL;
+ hr = pTopo->GetControlNode(0, 1, 0, &pNode); //HACK
+
+ WCHAR Buffer[100];
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune GetControlNode %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ if (FAILED(hr))
+ continue;
+
+ // sanity check
+ assert(hr == NOERROR);
+ assert(pNode);
+
+ hr = pNode->QueryInterface(IID_IBDA_FrequencyFilter, (void**)&pFrequency);
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune IID_IBDA_FrequencyFilter hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ hr = SetFrequency(pFrequency, 1000 /* FIXME */, Frequency, BDA_POLARISATION_NOT_DEFINED /* FIXME */, BDA_RANGE_NOT_SET /* FIXME */, BandWidth);
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune SetFrequency hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ //sanity check
+ assert(hr == NOERROR);
+
+ // release interface
+ pFrequency->Release();
+
+
+ hr = pNode->QueryInterface(IID_IBDA_LNBInfo, (void**)&pLnbInfo);
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune IID_IBDA_LNBInfo hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ hr = SetLnbInfo(pLnbInfo, ULONG_MAX /* FIXME */, ULONG_MAX /* FIXME*/, ULONG_MAX /*FIXME*/);
+
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune SetLnbInfo hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ // release interface
+ pLnbInfo->Release();
+
+ hr = pNode->QueryInterface(IID_IBDA_DigitalDemodulator, (void**)&pDigitalDemo);
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune IID_IBDA_DigitalDemodulator hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ hr = SetDigitalDemodulator(pDigitalDemo, Modulation, InnerFEC, InnerFECRate, OuterFEC, OuterFECRate, SymbolRate);
+
+ swprintf(Buffer, L"CScanningTunner::performDVBTTune SetDigitalDemodulator hr %lx\n", hr);
+ OutputDebugStringW(Buffer);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ // release interface
+ pDigitalDemo->Release();
+
+ // release control node
+ pNode->Release();
+
+ // release IBDA_Topology;
+ pTopo->Release();
+
+ }
+ return hr;
+}
+
+
+
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::CheckChanges()
+{
+ ULONG Index;
+ HRESULT hResult = NOERROR;
+ IBDA_DeviceControl * pDeviceControl;
+
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get filter
+ IUnknown * pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ // query for IBDA_DeviceControl interface
+ hResult = pFilter->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
+
+ // sanity check
+ assert(hResult == NOERROR);
+
+ //start changes
+ hResult = pDeviceControl->CheckChanges();
+
+ // fix for unimplemented
+ if (hResult == E_NOTIMPL)
+ hResult = NOERROR;
+
+ // release interface
+ pDeviceControl->Release();
+
+ if (FAILED(hResult))
+ {
+ //shouldnt happen
+ break;
+ }
+ }
+ // done
+ return hResult;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::CommitChanges()
+{
+ ULONG Index;
+ HRESULT hResult = NOERROR;
+ IBDA_DeviceControl * pDeviceControl;
+
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get filter
+ IUnknown * pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ // query for IBDA_DeviceControl interface
+ HRESULT hr = pFilter->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ //start changes
+ hr = pDeviceControl->CommitChanges();
+
+ // fix for unimplemented
+ if (hr == E_NOTIMPL)
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ {
+ pDeviceControl->StartChanges();
+ pDeviceControl->CommitChanges();
+ hResult = E_UNEXPECTED;
+ }
+
+ // release interface
+ pDeviceControl->Release();
+
+ }
+
+ //done
+ return hResult;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::StartChanges()
+{
+ ULONG Index;
+ IBDA_DeviceControl * pDeviceControl;
+
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get filter
+ IUnknown * pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ // query for IBDA_DeviceControl interface
+ HRESULT hr = pFilter->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ //start changes
+ hr = pDeviceControl->StartChanges();
+
+ // release interface
+ pDeviceControl->Release();
+
+ // fix for unimplemented
+ if (hr == E_NOTIMPL)
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ }
+
+ // now commit the changes
+ for(Index = 0; Index < m_DeviceFilters.size(); Index++)
+ {
+ // get filter
+ IUnknown * pFilter = m_DeviceFilters[Index];
+
+ if (!pFilter)
+ continue;
+
+ // query for IBDA_DeviceControl interface
+ HRESULT hr = pFilter->QueryInterface(IID_IBDA_DeviceControl, (void**)&pDeviceControl);
+
+ // sanity check
+ assert(hr == NOERROR);
+
+ hr = pDeviceControl->CommitChanges();
+
+ // release interface
+ pDeviceControl->Release();
+ }
+
+ // done
+ return NOERROR;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::SetLnbInfo(
+ IBDA_LNBInfo * pLnbInfo,
+ ULONG ulLOFLow,
+ ULONG ulLOFHigh,
+ ULONG ulSwitchFrequency)
+{
+ HRESULT hr;
+
+ hr = pLnbInfo->put_LocalOscilatorFrequencyLowBand(ulLOFLow);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ hr = pLnbInfo->put_LocalOscilatorFrequencyHighBand(ulLOFHigh);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ hr = pLnbInfo->put_HighLowSwitchFrequency(ulSwitchFrequency);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+
+ return hr;
+}
+
+HRESULT
+CScanningTunner::SetFrequency(
+ IBDA_FrequencyFilter * pFrequency,
+ ULONG FrequencyMultiplier,
+ ULONG Frequency,
+ Polarisation Polarity,
+ ULONG Range,
+ ULONG Bandwidth)
+{
+ HRESULT hr;
+
+ hr = pFrequency->put_FrequencyMultiplier(FrequencyMultiplier);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pFrequency->put_Frequency(Frequency);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pFrequency->put_Polarity(Polarity);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND))
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ hr = pFrequency->put_Range(Range);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND))
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ hr = pFrequency->put_Bandwidth(Bandwidth);
+ return hr;
+}
+
+HRESULT
+STDMETHODCALLTYPE
+CScanningTunner::SetDigitalDemodulator(
+ IBDA_DigitalDemodulator * pDigitalDemo,
+ ModulationType ModType,
+ FECMethod InnerFEC,
+ BinaryConvolutionCodeRate InnerFECRate,
+ FECMethod OuterFEC,
+ BinaryConvolutionCodeRate OuterFECRate,
+ ULONG SymbolRate)
+{
+ HRESULT hr;
+
+ hr = pDigitalDemo->put_ModulationType(&ModType);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDigitalDemo->put_InnerFECMethod(&InnerFEC);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDigitalDemo->put_InnerFECRate(&InnerFECRate);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDigitalDemo->put_OuterFECMethod(&OuterFEC);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDigitalDemo->put_OuterFECRate(&OuterFECRate);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+ if (FAILED(hr))
+ return hr;
+
+ hr = pDigitalDemo->put_SymbolRate(&SymbolRate);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+ if (FAILED(hr))
+ return hr;
+
+ SpectralInversion Inversion = BDA_SPECTRAL_INVERSION_NOT_DEFINED;
+ hr = pDigitalDemo->put_SpectralInversion(&Inversion);
+ if (hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND) || hr == MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_SET_NOT_FOUND))
+ hr = NOERROR;
+
+ return hr;
+}
+
+
HRESULT
WINAPI
CScanningTunner_fnConstructor(
- IUnknown *pUnknown,
+ std::vector<IUnknown*> & DeviceFilter,
REFIID riid,
LPVOID * ppv)
{
- CScanningTunner * handler = new CScanningTunner();
+ CScanningTunner * handler = new CScanningTunner(DeviceFilter);
#ifdef MSDVBNP_TRACE
WCHAR Buffer[MAX_PATH];
LPOLESTR lpstr;
StringFromCLSID(riid, &lpstr);
- swprintf(Buffer, L"CScanningTunner_fnConstructor riid %s pUnknown %p\n", lpstr, pUnknown);
+ swprintf(Buffer, L"CScanningTunner_fnConstructor riid %s\n", lpstr);
OutputDebugStringW(Buffer);
#endif
WINAPI
DllUnregisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass;
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ RegDeleteKeyW(hClass, pStr);
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
extern "C"
WINAPI
DllRegisterServer(void)
{
- return S_OK;
+ ULONG Index = 0;
+ LPOLESTR pStr;
+ HRESULT hr = S_OK;
+ HKEY hClass, hKey, hSubKey;
+ static LPCWSTR ModuleName = L"msvidctl.ax";
+ static LPCWSTR ThreadingModel = L"Both";
+
+ if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
+ return E_FAIL;
+
+ do
+ {
+ hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
+ if (FAILED(hr))
+ break;
+
+ if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
+ {
+ if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
+ {
+ RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
+ RegCloseKey(hSubKey);
+ }
+ RegCloseKey(hKey);
+ }
+
+ CoTaskMemFree(pStr);
+ Index++;
+ }while(InterfaceTable[Index].lpfnCI != 0);
+
+ RegCloseKey(hClass);
+ return hr;
}
KSDDKAPI
<group>
<module name="msvidctl" type="win32dll" baseaddress="${BASEADDRESS_MSVIDCTL}" installbase="system32" installname="msvidctl.dll">
<importlibrary definition="msvidctl.spec" />
+ <autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<include base="msvidctl">.</include>
<library>ntdll</library>
<library>kernel32</library>
<include base="ReactOS">include/reactos/subsys</include>
<define name="__NTDLL__" />
<define name="_NTOSKRNL_" />
+ <define name="CRTDLL" />
<library>rtl</library>
<library>ntdllsys</library>
<library>libcntpr</library>
<define name="USE_MSVCRT_PREFIX" />
<define name="_MSVCRT_LIB_" />
<define name="_MSVCRT_" />
+ <define name="CRTDLL" />
<define name="_CTYPE_DISABLE_MACROS" />
<define name="_NO_INLINING" />
/*
* @implemented
*/
-DWORD
+INT
WINAPI
SetRelAbs(
HDC hdc,
/*
* @implemented
*/
-DWORD
+LONG
WINAPI
GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height)
{
@ stdcall ResetWriteWatch(ptr long)
@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
@ stdcall ResumeThread(long)
+@ stdcall -arch=x86_64 RtlAddFunctionTable(ptr long double)
@ stdcall RtlCaptureContext(ptr) ntdll.RtlCaptureContext
@ stdcall RtlCaptureStackBackTrace(long long ptr ptr) ntdll.RtlCaptureStackBackTrace
+@ stdcall -arch=x86_64 RtlCompareMemory(ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlCopyMemory(ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlDeleteFunctionTable(ptr)
@ stdcall RtlFillMemory(ptr long long) ntdll.RtlFillMemory
+@ stdcall -arch=x86_64 RtlInstallFunctionTableCallback(double double long ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlLookupFunctionEntry(ptr ptr ptr) ntdll.RtlLookupFunctionEntry
@ stdcall RtlMoveMemory(ptr ptr long) ntdll.RtlMoveMemory
+@ stdcall -arch=x86_64 RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader
+@ stdcall -arch=x86_64 RtlRaiseException(ptr) ntdll.RtlRaiseException
+@ stdcall -arch=x86_64 RtlRestoreContext(ptr ptr) ntdll.RtlRestoreContext
@ stdcall RtlUnwind(ptr ptr ptr long) ntdll.RtlUnwind
-@ stdcall RtlVirtualUnwind(ptr ptr ptr long) ntdll.RtlVirtualUnwind
-@ stdcall RtlLookupFunctionEntry(ptr ptr ptr) ntdll.RtlLookupFunctionEntry
+@ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr) ntdll.RtlUnwindEx
+@ stdcall -arch=x86_64 RtlVirtualUnwind(ptr ptr ptr long) ntdll.RtlVirtualUnwind
@ stdcall RtlZeroMemory(ptr long) ntdll.RtlZeroMemory
@ stdcall ScrollConsoleScreenBufferA(long ptr ptr ptr ptr)
@ stdcall ScrollConsoleScreenBufferW(long ptr ptr ptr ptr)
__p__winminor @153
__p__winver @154
__p__wpgmptr @155
-; __pctype_func @156
+ __pctype_func @156
__pioinfo @157 DATA
-; __pwctype_func @158
+ __pwctype_func @158
__pxcptinfoptrs @159
__set_app_type @160
__setlc_active @161 DATA
_wcsupr @576
_wctime @577
; _wctime64 @578
-; _wctype @579
+ _wctype @579
_wenviron @580 DATA
_wexecl @581
_wexecle @582
<define name="_MT" />
<define name="_CTYPE_DISABLE_MACROS" />
<define name="_NO_INLINING" />
+ <define name="CRTDLL" />
<linkerflag linkerset="ld">-enable-stdcall-fixup</linkerflag>
<!-- __MINGW_IMPORT needs to be defined differently because it's defined
<include base="msvcrt20">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" />
+ <define name="CRTDLL" />
<file>msvcrt20.c</file>
<library>wine</library>
<library>msvcrt</library>
<include base="msvcrt40">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" />
+ <define name="CRTDLL" />
<file>msvcrt40.c</file>
<library>wine</library>
</module>
if (!(l = RegOpenKeyExW(HKLM,
lpKeyName,
0,
- 0,
+ samDesired,
&hClassesKey)))
{
if (MachineName != NULL)
DWORD OpenFlags,
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{
- FIXME("%p %s %08x %p\n",
+ struct DeviceInfoSet * list;
+ PCWSTR pEnd;
+ DWORD dwLength, dwError, dwIndex, dwKeyName, dwSubIndex;
+ CLSID ClassId;
+ WCHAR Buffer[MAX_PATH + 1];
+ WCHAR SymBuffer[MAX_PATH + 1];
+ WCHAR InstancePath[MAX_PATH + 1];
+ HKEY hKey, hDevKey, hSymKey;
+ struct DeviceInfo * deviceInfo;
+ struct DeviceInterface *deviceInterface;
+ BOOL Ret;
+ PLIST_ENTRY ItemList;
+ PLIST_ENTRY InterfaceListEntry;
+
+ TRACE("%p %s %08x %p\n",
DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData);
+
+
+ if (DeviceInterfaceData && DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ list = (struct DeviceInfoSet * )DeviceInfoSet;
+
+ dwLength = wcslen(DevicePath);
+ if (dwLength < 39)
+ {
+ /* path must be at least a guid length + L'\0' */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ if (DevicePath[0] != L'\\' ||
+ DevicePath[1] != L'\\' ||
+ (DevicePath[2] != L'?' && DevicePath[2] != L'.') ||
+ DevicePath[3] != L'\\')
+ {
+ /* invalid formatted path */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ /* check for reference strings */
+ pEnd = wcschr(&DevicePath[4], L'\\');
+ if (!pEnd)
+ {
+ /* no reference string */
+ pEnd = DevicePath + dwLength;
+ }
+
+ /* copy guid */
+ wcscpy(Buffer, pEnd - 37);
+ Buffer[36] = L'\0';
+
+ dwError = UuidFromStringW(Buffer, &ClassId);
+ if (dwError != NOERROR)
+ {
+ /* invalid formatted path */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ hKey = SetupDiOpenClassRegKeyExW(&ClassId, KEY_READ, DIOCR_INTERFACE, list->MachineName, NULL);
+
+ if (hKey == INVALID_HANDLE_VALUE)
+ {
+ /* invalid device class */
+ return FALSE;
+ }
+
+ ItemList = list->ListHead.Flink;
+ while (ItemList != &list->ListHead)
+ {
+ deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
+ InterfaceListEntry = deviceInfo->InterfaceListHead.Flink;
+ while (InterfaceListEntry != &deviceInfo->InterfaceListHead)
+ {
+ deviceInterface = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
+ if (!IsEqualIID(&deviceInterface->InterfaceClassGuid, &ClassId))
+ {
+ InterfaceListEntry = InterfaceListEntry->Flink;
+ continue;
+ }
+
+ if (!wcsicmp(deviceInterface->SymbolicLink, DevicePath))
+ {
+ if (DeviceInterfaceData)
+ {
+ DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
+ DeviceInterfaceData->Flags = deviceInterface->Flags;
+ CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ }
+
+ return TRUE;
+ }
+
+ }
+ }
+
+
+ dwIndex = 0;
+ do
+ {
+ Buffer[0] = 0;
+ dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
+ dwError = RegEnumKeyExW(hKey, dwIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
+
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ if (RegOpenKeyExW(hKey, Buffer, 0, KEY_READ, &hDevKey) != ERROR_SUCCESS)
+ break;
+
+ dwSubIndex = 0;
+ InstancePath[0] = 0;
+ dwKeyName = sizeof(InstancePath);
+
+ dwError = RegQueryValueExW(hDevKey, L"DeviceInstance", NULL, NULL, (LPBYTE)InstancePath, &dwKeyName);
+
+ while(TRUE)
+ {
+ Buffer[0] = 0;
+ dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
+ dwError = RegEnumKeyExW(hDevKey, dwSubIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
+
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ dwError = RegOpenKeyExW(hDevKey, Buffer, 0, KEY_READ, &hSymKey);
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ /* query for symbolic link */
+ dwKeyName = sizeof(SymBuffer);
+ SymBuffer[0] = L'\0';
+ dwError = RegQueryValueExW(hSymKey, L"SymbolicLink", NULL, NULL, (LPBYTE)SymBuffer, &dwKeyName);
+
+ if (dwError != ERROR_SUCCESS)
+ {
+ RegCloseKey(hSymKey);
+ break;
+ }
+
+ if (!wcsicmp(SymBuffer, DevicePath))
+ {
+ Ret = CreateDeviceInfo(list, InstancePath, &ClassId, &deviceInfo);
+ RegCloseKey(hSymKey);
+ RegCloseKey(hDevKey);
+ RegCloseKey(hKey);
+
+ if (Ret)
+ {
+ deviceInterface = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInterface) + (wcslen(SymBuffer) + 1) * sizeof(WCHAR));
+ if (deviceInterface)
+ {
+
+ CopyMemory(&deviceInterface->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ deviceInterface->DeviceInfo = deviceInfo;
+ deviceInterface->Flags = SPINT_ACTIVE; //FIXME
+
+ wcscpy(deviceInterface->SymbolicLink, SymBuffer);
+
+ InsertTailList(&deviceInfo->InterfaceListHead, &deviceInterface->ListEntry);
+ InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
+
+
+ if (DeviceInterfaceData)
+ {
+ DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
+ DeviceInterfaceData->Flags = deviceInterface->Flags;
+ CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ }
+ else
+ {
+ Ret = FALSE;
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ }
+ }
+ }
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, deviceInfo);
+ Ret = FALSE;
+ }
+ return Ret;
+ }
+ RegCloseKey(hSymKey);
+ dwSubIndex++;
+ }
+
+ RegCloseKey(hDevKey);
+ dwIndex++;
+ }while(TRUE);
+
+ RegCloseKey(hKey);
return FALSE;
}
ScrollTrackScrollBar(HWND Wnd, INT SBType, POINT Pt)
{
MSG Msg;
- RECT WindowRect;
- UINT XOffset, YOffset;
- POINT TopLeft;
-
- if (SB_CTL != SBType)
- {
- GetWindowRect(Wnd, &WindowRect);
-
- Pt.x -= WindowRect.left;
- Pt.y -= WindowRect.top;
+ UINT XOffset = 0, YOffset = 0;
- TopLeft.x = WindowRect.left;
- TopLeft.y = WindowRect.top;
- ScreenToClient(Wnd, &TopLeft);
- XOffset = - TopLeft.x;
- YOffset = - TopLeft.y;
- }
- else
- {
- XOffset = 0;
- YOffset = 0;
- }
+ if (SBType != SB_CTL)
+ {
+ PWND pwnd = ValidateHwnd(Wnd);
+ if (!pwnd) return;
+ XOffset = pwnd->rcClient.left - pwnd->rcWindow.left;
+ YOffset = pwnd->rcClient.top - pwnd->rcWindow.top;
+ ScreenToClient(Wnd, &Pt);
+ Pt.x += XOffset;
+ Pt.y += YOffset;
+ }
IntScrollHandleScrollEvent(Wnd, SBType, WM_LBUTTONDOWN, Pt);
do
- {
- if (! GetMessageW(&Msg, 0, 0, 0))
- {
- break;
- }
- if (CallMsgFilterW(&Msg, MSGF_SCROLLBAR))
- {
- continue;
- }
-
- switch(Msg.message)
- {
- case WM_SYSTIMER:
- case WM_LBUTTONUP:
- case WM_MOUSEMOVE:
- Pt.x = LOWORD(Msg.lParam) + XOffset;
- Pt.y = HIWORD(Msg.lParam) + YOffset;
- IntScrollHandleScrollEvent(Wnd, SBType, Msg.message, Pt);
- break;
- default:
- TranslateMessage(&Msg);
- DispatchMessageW(&Msg);
- break;
- }
-
- if (! IsWindow(Wnd))
- {
+ {
+ if (!GetMessageW(&Msg, 0, 0, 0)) break;
+ if (CallMsgFilterW(&Msg, MSGF_SCROLLBAR)) continue;
+ if ( Msg.message == WM_LBUTTONUP ||
+ Msg.message == WM_MOUSEMOVE ||
+ (Msg.message == WM_SYSTIMER && Msg.wParam == SCROLL_TIMER))
+ {
+ Pt.x = LOWORD(Msg.lParam) + XOffset;
+ Pt.y = HIWORD(Msg.lParam) + YOffset;
+ IntScrollHandleScrollEvent(Wnd, SBType, Msg.message, Pt);
+ }
+ else
+ {
+ TranslateMessage(&Msg);
+ DispatchMessageW(&Msg);
+ }
+ if (!IsWindow(Wnd))
+ {
ReleaseCapture();
break;
- }
- }
- while (WM_LBUTTONUP != Msg.message);
+ }
+ } while (Msg.message != WM_LBUTTONUP && GetCapture() == Wnd);
}
HDESK
WINAPI
OpenDesktopA(
- LPSTR lpszDesktop,
+ LPCSTR lpszDesktop,
DWORD dwFlags,
BOOL fInherit,
ACCESS_MASK dwDesiredAccess)
HDESK
WINAPI
OpenDesktopW(
- LPWSTR lpszDesktop,
+ LPCWSTR lpszDesktop,
DWORD dwFlags,
BOOL fInherit,
ACCESS_MASK dwDesiredAccess)
* @implemented
*/
HWINSTA WINAPI
-CreateWindowStationA(LPSTR lpwinsta,
+CreateWindowStationA(LPCSTR lpwinsta,
DWORD dwReserved,
ACCESS_MASK dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpsa)
* @implemented
*/
HWINSTA WINAPI
-CreateWindowStationW(LPWSTR lpwinsta,
+CreateWindowStationW(LPCWSTR lpwinsta,
DWORD dwReserved,
ACCESS_MASK dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpsa)
* @implemented
*/
HWINSTA WINAPI
-OpenWindowStationA(LPSTR lpszWinSta,
+OpenWindowStationA(LPCSTR lpszWinSta,
BOOL fInherit,
ACCESS_MASK dwDesiredAccess)
{
* @implemented
*/
HWINSTA WINAPI
-OpenWindowStationW(LPWSTR lpszWinSta,
+OpenWindowStationW(LPCWSTR lpszWinSta,
BOOL fInherit,
ACCESS_MASK dwDesiredAccess)
{
return 0;
}
-/* Undocumented flags. */
-#define SWP_NOCLIENTMOVE 0x0800
-#define SWP_NOCLIENTSIZE 0x1000
-
LRESULT
DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos)
{
/* GLOBALS *******************************************************************/
-#define DSS_DEFAULT 0x0040 /* Make it bold */
-
static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555,
0xaaaa, 0x5555, 0xaaaa, 0x5555 };
#pragma once
#define NOEXTAPI
-#include <ntddk.h>
+#include <ntifs.h>
#define NDEBUG
#include <halfuncs.h>
#include <stdio.h>
+++ /dev/null
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: drivers/battery/cmbatt/cmbatt.c
- * PURPOSE: Control Method Battery Miniclass Driver
- * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
- */
-
-#include <cmbatt.h>
-
-#define NDEBUG
-#include <debug.h>
-
-LIST_ENTRY BatteryList;
-KSPIN_LOCK BatteryListLock;
-
-VOID
-NTAPI
-CmBattUnload(PDRIVER_OBJECT DriverObject)
-{
- DPRINT("Control method battery miniclass driver unloaded\n");
-}
-
-NTSTATUS
-NTAPI
-CmBattDeviceControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
- NTSTATUS Status;
-
- Status = BatteryClassIoctl(DeviceExtension->BattClassHandle,
- Irp);
-
- if (Status == STATUS_NOT_SUPPORTED)
- {
- Irp->IoStatus.Status = Status;
- Irp->IoStatus.Information = 0;
-
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
-
- return Status;
-}
-
-NTSTATUS
-NTAPI
-CmBattPnP(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
-
- UNIMPLEMENTED
-
- IoSkipCurrentIrpStackLocation(Irp);
-
- return IoCallDriver(DeviceExtension->Ldo, Irp);
-}
-
-NTSTATUS
-NTAPI
-CmBattSystemControl(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- UNIMPLEMENTED
-
- Irp->IoStatus.Status = STATUS_WMI_GUID_NOT_FOUND;
- Irp->IoStatus.Information = 0;
-
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return STATUS_WMI_GUID_NOT_FOUND;
-}
-
-NTSTATUS
-NTAPI
-CmBattPower(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
-
- UNIMPLEMENTED
-
- IoSkipCurrentIrpStackLocation(Irp);
-
- PoStartNextPowerIrp(Irp);
-
- return PoCallDriver(DeviceExtension->Ldo, Irp);
-}
-
-NTSTATUS
-NTAPI
-CmBattCreateClose(PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
-
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-CmBattAddDevice(PDRIVER_OBJECT DriverObject,
- PDEVICE_OBJECT PhysicalDeviceObject)
-{
- NTSTATUS Status;
- PDEVICE_OBJECT DeviceObject;
- PCMBATT_DEVICE_EXTENSION DeviceExtension;
- BATTERY_MINIPORT_INFO BattInfo;
-
- Status = IoCreateDevice(DriverObject,
- sizeof(CMBATT_DEVICE_EXTENSION),
- NULL,
- FILE_DEVICE_BATTERY,
- 0,
- FALSE,
- &DeviceObject);
- if (!NT_SUCCESS(Status))
- return Status;
-
- DeviceExtension = DeviceObject->DeviceExtension;
-
- DeviceExtension->Pdo = PhysicalDeviceObject;
- DeviceExtension->Fdo = DeviceObject;
- DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(DeviceObject,
- PhysicalDeviceObject);
-
- DeviceObject->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE;
-
- /* We require an extra stack entry */
- DeviceObject->StackSize = PhysicalDeviceObject->StackSize + 2;
-
- BattInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION;
- BattInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION;
- BattInfo.Context = DeviceExtension;
- BattInfo.QueryTag = CmBattQueryTag;
- BattInfo.QueryInformation = CmBattQueryInformation;
- BattInfo.SetInformation = CmBattSetInformation;
- BattInfo.QueryStatus = CmBattQueryStatus;
- BattInfo.SetStatusNotify = CmBattSetStatusNotify;
- BattInfo.DisableStatusNotify = CmBattDisableStatusNotify;
- BattInfo.Pdo = PhysicalDeviceObject;
- BattInfo.DeviceName = NULL;
-
- Status = BatteryClassInitializeDevice(&BattInfo,
- &DeviceExtension->BattClassHandle);
- if (!NT_SUCCESS(Status))
- {
- IoDetachDevice(DeviceExtension->Ldo);
- IoDeleteDevice(DeviceObject);
- return Status;
- }
-
- ExInterlockedInsertTailList(&BatteryList,
- &DeviceExtension->ListEntry,
- &BatteryListLock);
-
- DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
-
- DPRINT("Successfully registered battery with battc (0x%x)\n", DeviceExtension->BattClassHandle);
-
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-DriverEntry(PDRIVER_OBJECT DriverObject,
- PUNICODE_STRING RegistryPath)
-{
- DPRINT("Control method battery miniclass driver initialized\n");
-
- DriverObject->DriverUnload = CmBattUnload;
- DriverObject->DriverExtension->AddDevice = CmBattAddDevice;
- DriverObject->MajorFunction[IRP_MJ_POWER] = CmBattPower;
- DriverObject->MajorFunction[IRP_MJ_PNP] = CmBattPnP;
- DriverObject->MajorFunction[IRP_MJ_CREATE] = CmBattCreateClose;
- DriverObject->MajorFunction[IRP_MJ_CLOSE] = CmBattCreateClose;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CmBattDeviceControl;
- DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CmBattSystemControl;
-
- KeInitializeSpinLock(&BatteryListLock);
- InitializeListHead(&BatteryList);
-
- return STATUS_SUCCESS;
-}
+++ /dev/null
-/*
-* PROJECT: ReactOS Kernel
-* LICENSE: GPL - See COPYING in the top level directory
-* FILE: drivers/battery/cmbatt/cmbatt.h
-* PURPOSE: Control Method Battery Miniclass Driver
-* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
-*/
-
-#pragma once
-
-#include <ntddk.h>
-#include <batclass.h>
-
-typedef struct _CMBATT_DEVICE_EXTENSION {
- PDEVICE_OBJECT Pdo;
- PDEVICE_OBJECT Ldo;
- PDEVICE_OBJECT Fdo;
- PVOID BattClassHandle;
- LIST_ENTRY ListEntry;
-} CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION;
-
-NTSTATUS
-NTAPI
-CmBattQueryTag(PVOID Context,
- PULONG BatteryTag);
-
-NTSTATUS
-NTAPI
-CmBattDisableStatusNotify(PVOID Context);
-
-NTSTATUS
-NTAPI
-CmBattSetStatusNotify(PVOID Context,
- ULONG BatteryTag,
- PBATTERY_NOTIFY BatteryNotify);
-
-NTSTATUS
-NTAPI
-CmBattQueryInformation(PVOID Context,
- ULONG BatteryTag,
- BATTERY_QUERY_INFORMATION_LEVEL Level,
- OPTIONAL LONG AtRate,
- PVOID Buffer,
- ULONG BufferLength,
- PULONG ReturnedLength);
-
-NTSTATUS
-NTAPI
-CmBattQueryStatus(PVOID Context,
- ULONG BatteryTag,
- PBATTERY_STATUS BatteryStatus);
-
-NTSTATUS
-NTAPI
-CmBattSetInformation(PVOID Context,
- ULONG BatteryTag,
- BATTERY_SET_INFORMATION_LEVEL Level,
- OPTIONAL PVOID Buffer);
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="cmbatt" type="kernelmodedriver" installbase="system32/drivers" installname="cmbatt.sys">
- <library>ntoskrnl</library>
- <library>hal</library>
- <library>battc</library>
- <include base="cmbatt">.</include>
- <file>cmbatt.c</file>
- <file>miniclass.c</file>
- <file>cmbatt.rc</file>
-</module>
+++ /dev/null
-#define REACTOS_VERSION_DLL
-#define REACTOS_STR_FILE_DESCRIPTION "Control Method Battery Miniclass Driver\0"
-#define REACTOS_STR_INTERNAL_NAME "cmbatt\0"
-#define REACTOS_STR_ORIGINAL_FILENAME "cmbatt.sys\0"
-#include <reactos/version.rc>
+++ /dev/null
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: drivers/battery/cmbatt/miniclass.c
- * PURPOSE: Control Method Battery Miniclass Driver
- * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
- */
-
-#include <cmbatt.h>
-
-#define NDEBUG
-#include <debug.h>
-
-NTSTATUS
-NTAPI
-CmBattQueryTag(PVOID Context,
- PULONG BatteryTag)
-{
- UNIMPLEMENTED
-
- *BatteryTag = 0;
-
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-CmBattDisableStatusNotify(PVOID Context)
-{
- UNIMPLEMENTED
-
- return STATUS_NOT_SUPPORTED;
-}
-
-NTSTATUS
-NTAPI
-CmBattSetStatusNotify(PVOID Context,
- ULONG BatteryTag,
- PBATTERY_NOTIFY BatteryNotify)
-{
- UNIMPLEMENTED
-
- return STATUS_NOT_SUPPORTED;
-}
-
-NTSTATUS
-NTAPI
-CmBattQueryInformation(PVOID Context,
- ULONG BatteryTag,
- BATTERY_QUERY_INFORMATION_LEVEL Level,
- OPTIONAL LONG AtRate,
- PVOID Buffer,
- ULONG BufferLength,
- PULONG ReturnedLength)
-{
- UNIMPLEMENTED
-
- return STATUS_NOT_SUPPORTED;
-}
-
-NTSTATUS
-NTAPI
-CmBattQueryStatus(PVOID Context,
- ULONG BatteryTag,
- PBATTERY_STATUS BatteryStatus)
-{
- UNIMPLEMENTED
-
- return STATUS_NOT_SUPPORTED;
-}
-
-NTSTATUS
-NTAPI
-CmBattSetInformation(PVOID Context,
- ULONG BatteryTag,
- BATTERY_SET_INFORMATION_LEVEL Level,
- OPTIONAL PVOID Buffer)
-{
- UNIMPLEMENTED
-
- return STATUS_NOT_SUPPORTED;
-}
<directory name="battc">
<xi:include href="battc/battc.rbuild" />
</directory>
-<directory name="cmbatt">
- <xi:include href="cmbatt/cmbatt.rbuild" />
-</directory>
</group>
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
-<module name="cmbattx" type="kernelmodedriver" installbase="system32/drivers" installname="cmbattx.sys">
+<module name="cmbatt" type="kernelmodedriver" installbase="system32/drivers" installname="cmbatt.sys">
<library>ntoskrnl</library>
<library>hal</library>
<library>battc</library>
}
/* Set FDO flags */
- FdoDeviceObject->Flags |= DO_BUFFERED_IO;
- FdoDeviceObject->Flags |= DO_MAP_IO_BUFFER;
+ FdoDeviceObject->Flags |= (DO_POWER_PAGABLE | DO_BUFFERED_IO);
FdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
/* Initialize the extension */
CompBattOpenClose(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PAGED_CODE();
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING OpenClose\n");
+
+ /* Complete the IRP with success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ /* Return success */
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: Exiting OpenClose\n");
+ return STATUS_SUCCESS;
}
NTSTATUS
CompBattSystemControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ NTSTATUS Status;
+ PAGED_CODE();
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING System Control\n");
+
+ /* Are we attached yet? */
+ if (DeviceExtension->AttachedDevice)
+ {
+ /* Send it up the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
+ }
+ else
+ {
+ /* We don't support WMI */
+ Status = STATUS_NOT_SUPPORTED;
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+
+ /* Return status */
+ return Status;
}
NTSTATUS
NTSTATUS
NTAPI
-CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_ENTRY BatteryData)
+CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_DATA BatteryData)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS
+VOID
NTAPI
CompBattRecalculateTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ ULONG Tag;
+ PLIST_ENTRY ListHead, NextEntry;
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING CompBattRecalculateTag\n");
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the battery information and check if it has a tag */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ if (BatteryData->Flags & COMPBATT_TAG_ASSIGNED)
+ {
+ /* Generate the next tag and exit */
+ Tag = DeviceExtension->NextTag;
+ DeviceExtension->Flags |= COMPBATT_TAG_ASSIGNED;
+ DeviceExtension->Tag = Tag;
+ DeviceExtension->NextTag = Tag + 1;
+ break;
+ }
+
+ /* No tag for this device extension, clear it */
+ DeviceExtension->Tag = 0;
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* We're done */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING CompBattRecalculateTag\n");
}
NTSTATUS
CompBattIoctl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ NTSTATUS Status;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING Ioctl\n");
+
+ /* Let the class driver handle it */
+ Status = BatteryClassIoctl(DeviceExtension->ClassData, Irp);
+ if (Status == STATUS_NOT_SUPPORTED)
+ {
+ /* It failed, try the next driver up the stack */
+ Irp->IoStatus.Status = Status;
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
+ }
+
+ /* Return status */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING Ioctl\n");
+ return Status;
}
NTSTATUS
CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
OUT PULONG Tag)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status;
+ PAGED_CODE();
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING QueryTag\n");
+
+ /* Was a tag assigned? */
+ if (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED))
+ {
+ /* Assign one */
+ CompBattRecalculateTag(DeviceExtension);
+ }
+
+ /* Do we have a tag now? */
+ if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && (DeviceExtension->Tag))
+ {
+ /* Return the tag */
+ *Tag = DeviceExtension->Tag;
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ /* No tag */
+ *Tag = 0;
+ Status = STATUS_NO_SUCH_DEVICE;
+ }
+
+ /* Return status */
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING QueryTag\n");
+ return Status;
}
NTSTATUS
NTAPI
CompBattDisableStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ PLIST_ENTRY ListHead, NextEntry;
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n");
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the battery information and clear capacity data */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ BatteryData->WaitStatus.LowCapacity = 0;
+ BatteryData->WaitStatus.HighCapacity = 0x7FFFFFFF;
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* Done */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING DisableStatusNotify\n");
+ return STATUS_SUCCESS;
}
NTSTATUS
NTSTATUS
NTAPI
-CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInformation,
+CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInfo,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status = STATUS_SUCCESS;
+ BATTERY_QUERY_INFORMATION InputBuffer;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ PLIST_ENTRY ListHead, NextEntry;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryInformation\n");
+
+ /* Set defaults */
+ BatteryInfo->DefaultAlert1 = 0;
+ BatteryInfo->DefaultAlert2 = 0;
+ BatteryInfo->CriticalBias = 0;
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Try to acquire the remove lock */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0)))
+ {
+ /* Now release the device lock since the battery can't go away */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+
+ /* Build the query */
+ InputBuffer.BatteryTag = BatteryData->Tag;
+ InputBuffer.InformationLevel = BatteryInformation;
+ InputBuffer.AtRate = 0;
+
+ /* Make sure the battery has a tag */
+ if (BatteryData->Tag)
+ {
+ /* Do we already have the data? */
+ if (!(BatteryData->Flags & COMPBATT_BATTERY_INFORMATION_PRESENT))
+ {
+ /* Send the IOCTL to query the information */
+ RtlZeroMemory(&BatteryData->BatteryInformation,
+ sizeof(BatteryData->BatteryInformation));
+ Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION,
+ BatteryData->DeviceObject,
+ &InputBuffer,
+ sizeof(InputBuffer),
+ &BatteryData->BatteryInformation,
+ sizeof(BatteryData->BatteryInformation),
+ 0);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail if the query had a problem */
+ if (Status == STATUS_DEVICE_REMOVED) Status = STATUS_NO_SUCH_DEVICE;
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ IoReleaseRemoveLock(&BatteryData->RemoveLock, 0);
+ break;
+ }
+
+ /* Next time we can use the static copy */
+ BatteryData->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT;
+ if (CompBattDebug & 2)
+ DbgPrint("CompBattGetBatteryInformation: Read individual BATTERY_INFORMATION\n"
+ "-------- Capabilities = %x\n-------- Technology = %x\n"
+ "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n"
+ "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n"
+ "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n"
+ "-------- CycleCount = %x\n",
+ BatteryData->BatteryInformation.Capabilities,
+ BatteryData->BatteryInformation.Technology,
+ BatteryData->BatteryInformation.Chemistry,
+ BatteryData->BatteryInformation.DesignedCapacity,
+ BatteryData->BatteryInformation.FullChargedCapacity,
+ BatteryData->BatteryInformation.DefaultAlert1,
+ BatteryData->BatteryInformation.DefaultAlert2,
+ BatteryData->BatteryInformation.CriticalBias,
+ BatteryData->BatteryInformation.CycleCount);
+ }
+
+ /* Combine capabilities */
+ BatteryInfo->Capabilities |= BatteryData->BatteryInformation.Capabilities;
+
+ /* Add-on capacity */
+ if (BatteryData->BatteryInformation.DesignedCapacity != BATTERY_UNKNOWN_CAPACITY)
+ {
+ BatteryInfo->DesignedCapacity += BatteryData->BatteryInformation.DesignedCapacity;
+ }
+
+ /* Add on fully charged capacity */
+ if (BatteryData->BatteryInformation.FullChargedCapacity != BATTERY_UNKNOWN_CAPACITY)
+ {
+ BatteryInfo->FullChargedCapacity += BatteryData->BatteryInformation.FullChargedCapacity;
+ }
+
+ /* Choose the highest alert */
+ BatteryInfo->DefaultAlert1 = max(BatteryInfo->DefaultAlert1,
+ BatteryData->BatteryInformation.DefaultAlert1);
+
+ /* Choose the highest alert */
+ BatteryInfo->DefaultAlert2 = max(BatteryInfo->DefaultAlert2,
+ BatteryData->BatteryInformation.DefaultAlert2);
+
+ /* Choose the highest critical bias */
+ BatteryInfo->CriticalBias = max(BatteryInfo->CriticalBias,
+ BatteryData->BatteryInformation.CriticalBias);
+ }
+
+ /* Re-acquire the device extension lock and release the remove lock */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ IoReleaseRemoveLock(&BatteryData->RemoveLock, 0);
+ }
+
+ /* Next entry */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* We are done with the list, check if the information was queried okay */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (NT_SUCCESS(Status))
+ {
+ /* If there's no fully charged capacity, use the design capacity */
+ if (!BatteryInfo->FullChargedCapacity)
+ {
+ BatteryInfo->FullChargedCapacity = BatteryInfo->DesignedCapacity;
+ }
+
+ /* Print out final combined data */
+ if (CompBattDebug & 2)
+ DbgPrint("CompBattGetBatteryInformation: Returning BATTERY_INFORMATION\n"
+ "-------- Capabilities = %x\n-------- Technology = %x\n"
+ "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n"
+ "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n"
+ "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n"
+ "-------- CycleCount = %x\n",
+ BatteryInfo->Capabilities,
+ BatteryInfo->Technology,
+ BatteryInfo->Chemistry,
+ BatteryInfo->DesignedCapacity,
+ BatteryInfo->FullChargedCapacity,
+ BatteryInfo->DefaultAlert1,
+ BatteryInfo->DefaultAlert2,
+ BatteryInfo->CriticalBias,
+ BatteryInfo->CycleCount);
+
+ /* Copy the data into the device extension */
+ RtlCopyMemory(&DeviceExtension->BatteryInformation,
+ BatteryInfo,
+ sizeof(DeviceExtension->BatteryInformation));
+ DeviceExtension->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT;
+ }
+
+ /* We are done */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryInformation\n");
+ return Status;
}
NTSTATUS
CompBattGetBatteryGranularity(OUT PBATTERY_REPORTING_SCALE ReportingScale,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status = STATUS_SUCCESS;
+ BATTERY_QUERY_INFORMATION InputBuffer;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ BATTERY_REPORTING_SCALE BatteryScale[4];
+ PLIST_ENTRY ListHead, NextEntry;
+ ULONG i;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryGranularity\n");
+
+ /* Set defaults */
+ ReportingScale[0].Granularity = -1;
+ ReportingScale[1].Granularity = -1;
+ ReportingScale[2].Granularity = -1;
+ ReportingScale[3].Granularity = -1;
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Try to acquire the remove lock */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0)))
+ {
+ /* Now release the device lock since the battery can't go away */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+
+ /* Build the query */
+ InputBuffer.BatteryTag = BatteryData->Tag;
+ InputBuffer.InformationLevel = BatteryGranularityInformation;
+
+ /* Make sure the battery has a tag */
+ if (BatteryData->Tag)
+ {
+ /* Send the IOCTL to query the information */
+ RtlZeroMemory(&BatteryData->BatteryInformation,
+ sizeof(BatteryData->BatteryInformation));
+ Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION,
+ BatteryData->DeviceObject,
+ &InputBuffer,
+ sizeof(InputBuffer),
+ &BatteryScale,
+ sizeof(BatteryScale),
+ 0);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail if the query had a problem */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ IoReleaseRemoveLock(&BatteryData->RemoveLock, 0);
+ break;
+ }
+
+ /* Loop all 4 scales */
+ for (i = 0; i < 4; i++)
+ {
+ /* Check for valid granularity */
+ if (BatteryScale[i].Granularity)
+ {
+ /* If it's smaller, use it instead */
+ ReportingScale[i].Granularity = min(BatteryScale[i].Granularity,
+ ReportingScale[i].Granularity);
+ }
+
+ }
+ }
+
+ /* Re-acquire the device extension lock and release the remove lock */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ IoReleaseRemoveLock(&BatteryData->RemoveLock, 0);
+ }
+
+ /* Next entry */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* All done */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryGranularity\n");
+ return STATUS_SUCCESS;
}
NTSTATUS
NTSTATUS
NTAPI
-CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION FdoExtension,
+CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
IN ULONG Tag,
IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel,
IN OPTIONAL LONG AtRate,
IN ULONG BufferLength,
OUT PULONG ReturnedLength)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ BATTERY_INFORMATION BatteryInfo;
+ BATTERY_REPORTING_SCALE BatteryGranularity[4];
+ PWCHAR BatteryName = L"Composite Battery";
+ BATTERY_MANUFACTURE_DATE Date;
+ ULONG Dummy, Time;
+ PVOID QueryData = NULL;
+ ULONG QueryLength = 0;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PAGED_CODE();
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING QueryInformation\n");
+
+ /* Check for valid/correct tag */
+ if ((Tag != DeviceExtension->Tag) ||
+ (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED)))
+ {
+ /* Not right, so fail */
+ return STATUS_NO_SUCH_DEVICE;
+ }
+
+ /* Check what caller wants */
+ switch (InfoLevel)
+ {
+ case BatteryInformation:
+
+ /* Query combined battery information */
+ RtlZeroMemory(&BatteryInfo, sizeof(BatteryInfo));
+ Status = CompBattGetBatteryInformation(&BatteryInfo, DeviceExtension);
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the data if successful */
+ QueryData = &BatteryInfo;
+ QueryLength = sizeof(BatteryInfo);
+ }
+ break;
+
+ case BatteryGranularityInformation:
+
+ /* Query combined granularity information */
+ RtlZeroMemory(&BatteryGranularity, sizeof(BatteryGranularity));
+ Status = CompBattGetBatteryGranularity(BatteryGranularity, DeviceExtension);
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the data if successful */
+ QueryLength = sizeof(BatteryGranularity);
+ QueryData = &BatteryGranularity;
+ }
+ break;
+
+ case BatteryEstimatedTime:
+
+ /* Query combined time estimate information */
+ RtlZeroMemory(&Time, sizeof(Time));
+ Status = CompBattGetEstimatedTime(&Time, DeviceExtension);
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the data if successful */
+ QueryLength = sizeof(Time);
+ QueryData = &Time;
+ }
+ break;
+
+ case BatteryManufactureName:
+ case BatteryDeviceName:
+
+ /* Return the static buffer */
+ QueryData = BatteryName;
+ QueryLength = sizeof(L"Composite Battery");
+ break;
+
+ case BatteryManufactureDate:
+
+ /* Static data */
+ Date.Day = 26;
+ Date.Month = 06;
+ Date.Year = 1997;
+ break;
+
+ case BatteryTemperature:
+ case BatteryUniqueID:
+
+ /* Return zero */
+ Dummy = 0;
+ QueryData = &Dummy;
+ QueryLength = sizeof(Dummy);
+ break;
+
+ default:
+
+ /* Everything else is unknown */
+ Status = STATUS_INVALID_PARAMETER;
+ break;
+ }
+
+ /* Return the required length and check if the caller supplied enough */
+ *ReturnedLength = QueryLength;
+ if (BufferLength < QueryLength) Status = STATUS_BUFFER_TOO_SMALL;
+
+ /* Copy the data if there's enough space and it exists */
+ if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength);
+
+ /* Return function result */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING QueryInformation\n");
+ return Status;
}
NTSTATUS
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ /* Register add device routine */
+ DriverObject->DriverExtension->AddDevice = CompBattAddDevice;
+
+ /* Register other handlers */
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = CompBattOpenClose;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = CompBattOpenClose;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CompBattIoctl;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = CompBattPowerDispatch;
+ DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CompBattSystemControl;
+ DriverObject->MajorFunction[IRP_MJ_PNP] = CompBattPnpDispatch;
+ return STATUS_SUCCESS;
}
/* EOF */
#include <initguid.h>
#include <batclass.h>
#include <debug.h>
+#include <wdmguid.h>
-typedef struct _COMPBATT_BATTERY_ENTRY
+#define COMPBATT_BATTERY_INFORMATION_PRESENT 0x04
+#define COMPBATT_TAG_ASSIGNED 0x80
+
+typedef struct _COMPBATT_BATTERY_DATA
{
LIST_ENTRY BatteryLink;
IO_REMOVE_LOCK RemoveLock;
BATTERY_STATUS BatteryStatus;
ULONGLONG InterruptTime;
UNICODE_STRING BatteryName;
-} COMPBATT_BATTERY_ENTRY, *PCOMPBATT_BATTERY_ENTRY;
+} COMPBATT_BATTERY_DATA, *PCOMPBATT_BATTERY_DATA;
typedef struct _COMPBATT_DEVICE_EXTENSION
{
PVOID NotificationEntry;
} COMPBATT_DEVICE_EXTENSION, *PCOMPBATT_DEVICE_EXTENSION;
-extern ULONG CmBattDebug;
+NTSTATUS
+NTAPI
+CompBattAddDevice(
+ IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT PdoDeviceObject
+);
+
+NTSTATUS
+NTAPI
+CompBattPowerDispatch(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp
+);
+
+NTSTATUS
+NTAPI
+CompBattPnpDispatch(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp
+);
+
+NTSTATUS
+NTAPI
+CompBattQueryInformation(
+ IN PCOMPBATT_DEVICE_EXTENSION FdoExtension,
+ IN ULONG Tag,
+ IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel,
+ IN OPTIONAL LONG AtRate,
+ IN PVOID Buffer,
+ IN ULONG BufferLength,
+ OUT PULONG ReturnedLength
+);
+
+NTSTATUS
+NTAPI
+CompBattQueryStatus(
+ IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
+ IN ULONG Tag,
+ IN PBATTERY_STATUS BatteryStatus
+);
+
+NTSTATUS
+NTAPI
+CompBattSetStatusNotify(
+ IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
+ IN ULONG BatteryTag,
+ IN PBATTERY_NOTIFY BatteryNotify
+);
+
+NTSTATUS
+NTAPI
+CompBattDisableStatusNotify(
+ IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension
+);
+
+NTSTATUS
+NTAPI
+CompBattQueryTag(
+ IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
+ OUT PULONG Tag
+);
+
+NTSTATUS
+NTAPI
+CompBattMonitorIrpComplete(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PKEVENT Event
+);
+
+NTSTATUS
+NTAPI
+CompBattMonitorIrpCompleteWorker(
+ IN PCOMPBATT_BATTERY_DATA BatteryData
+);
+
+NTSTATUS
+NTAPI
+CompBattGetDeviceObjectPointer(
+ IN PUNICODE_STRING DeviceName,
+ IN ACCESS_MASK DesiredAccess,
+ OUT PFILE_OBJECT *FileObject,
+ OUT PDEVICE_OBJECT *DeviceObject
+);
+
+NTSTATUS
+NTAPI
+BatteryIoctl(
+ IN ULONG IoControlCode,
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PVOID InputBuffer,
+ IN ULONG InputBufferLength,
+ IN PVOID OutputBuffer,
+ IN ULONG OutputBufferLength,
+ IN BOOLEAN InternalDeviceIoControl
+);
+
+extern ULONG CompBattDebug;
/* EOF */
IN ULONG OutputBufferLength,
IN BOOLEAN InternalDeviceIoControl)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ IO_STATUS_BLOCK IoStatusBlock;
+ KEVENT Event;
+ NTSTATUS Status;
+ PIRP Irp;
+ PAGED_CODE();
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING BatteryIoctl\n");
+
+ /* Initialize the event and IRP */
+ KeInitializeEvent(&Event, SynchronizationEvent, 0);
+ Irp = IoBuildDeviceIoControlRequest(IoControlCode,
+ DeviceObject,
+ InputBuffer,
+ InputBufferLength,
+ OutputBuffer,
+ OutputBufferLength,
+ InternalDeviceIoControl,
+ &Event,
+ &IoStatusBlock);
+ if (Irp)
+ {
+ /* Call the class driver miniport */
+ Status = IofCallDriver(DeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ /* Wait for result */
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ Status = IoStatusBlock.Status;
+ }
+
+ /* Print failure */
+ if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8))
+ DbgPrint("BatteryIoctl: Irp failed - %x\n", Status);
+
+ /* Done */
+ if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n");
+ }
+ else
+ {
+ /* Out of memory */
+ if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n");
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Return status */
+ return Status;
}
NTSTATUS
NTAPI
-CompBattGetDeviceObjectPointer(IN PCUNICODE_STRING DeviceName,
+CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName,
IN ACCESS_MASK DesiredAccess,
OUT PFILE_OBJECT *FileObject,
OUT PDEVICE_OBJECT *DeviceObject)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ PFILE_OBJECT LocalFileObject;
+ HANDLE DeviceHandle;
+ PAGED_CODE();
+
+ /* Open a file object handle to the device */
+ InitializeObjectAttributes(&ObjectAttributes, DeviceName, 0, NULL, NULL);
+ Status = ZwCreateFile(&DeviceHandle,
+ DesiredAccess,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ NULL,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ FILE_OPEN,
+ 0,
+ NULL,
+ 0);
+ if (NT_SUCCESS(Status))
+ {
+ /* Reference the file object */
+ Status = ObReferenceObjectByHandle(DeviceHandle,
+ 0,
+ IoFileObjectType,
+ KernelMode,
+ (PVOID)&LocalFileObject,
+ NULL);
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the FO and the associated DO */
+ *FileObject = LocalFileObject;
+ *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject);
+ }
+
+ /* Close the handle */
+ ZwClose(DeviceHandle);
+ }
+
+ /* Return status */
+ return Status;
}
/* EOF */
CompBattPowerDispatch(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: PowerDispatch recieved power IRP.\n");
+
+ /* Start the next IRP */
+ PoStartNextPowerIrp(Irp);
+
+ /* Call the next driver in the stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return PoCallDriver(DeviceExtension->AttachedDevice, Irp);
}
-PCOMPBATT_BATTERY_ENTRY
+PCOMPBATT_BATTERY_DATA
NTAPI
RemoveBatteryFromList(IN PCUNICODE_STRING BatteryName,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return NULL;
+ PLIST_ENTRY ListHead, NextEntry;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ if (CompBattDebug & 1)
+ DbgPrint("CompBatt: ENTERING RemoveBatteryFromList\n");
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the battery information and compare the name */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ if (!RtlCompareUnicodeString(BatteryName, &BatteryData->BatteryName, TRUE))
+ {
+ /* Flush pending deletes and any lock waiters */
+ IoAcquireRemoveLock(&BatteryData->RemoveLock, 0);
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ IoReleaseRemoveLockAndWait(&BatteryData->RemoveLock, 0);
+
+ /* Remove the entry from the list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ RemoveEntryList(&BatteryData->BatteryLink);
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ return BatteryData;
+ }
+
+ /* Next */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* Done */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING RemoveBatteryFromList\n");
+ return STATUS_SUCCESS;
}
BOOLEAN
IsBatteryAlreadyOnList(IN PCUNICODE_STRING BatteryName,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return FALSE;
+ PLIST_ENTRY ListHead, NextEntry;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ BOOLEAN Found = FALSE;
+ if (CompBattDebug & 1)
+ DbgPrint("CompBatt: ENTERING IsBatteryAlreadyOnList\n");
+
+ /* Loop the battery list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ ListHead = &DeviceExtension->BatteryList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the battery information and compare the name */
+ BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
+ if (!RtlCompareUnicodeString(BatteryName, &BatteryData->BatteryName, TRUE))
+ {
+ /* Got it */
+ Found = TRUE;
+ break;
+ }
+
+ /* Next */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* Release the lock and return search status */
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING IsBatteryAlreadyOnList\n");
+ return Found;
}
NTSTATUS
NTAPI
-CompBattAddNewBattery(IN PCUNICODE_STRING BatteryName,
+CompBattAddNewBattery(IN PUNICODE_STRING BatteryName,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ PIRP Irp;
+ PIO_STACK_LOCATION IoStackLocation;
+ PFILE_OBJECT FileObject;
+ PAGED_CODE();
+ if (CompBattDebug & 1)
+ DbgPrint("CompBatt: ENTERING AddNewBattery \"%w\" \n", BatteryName->Buffer);
+
+ /* Is this a new battery? */
+ if (!IsBatteryAlreadyOnList(BatteryName, DeviceExtension))
+ {
+ /* Allocate battery data */
+ BatteryData = ExAllocatePoolWithTag(NonPagedPool,
+ sizeof(COMPBATT_BATTERY_DATA) +
+ BatteryName->Length,
+ 'CtaB');
+ if (BatteryData)
+ {
+ /* Initialize the data and write the battery name */
+ RtlZeroMemory(BatteryData, sizeof(COMPBATT_BATTERY_DATA));
+ BatteryData->Tag = 0;
+ BatteryData->BatteryName.MaximumLength = BatteryName->Length;
+ BatteryData->BatteryName.Buffer = (PWCHAR)(BatteryData + 1);
+ RtlCopyUnicodeString(&BatteryData->BatteryName, BatteryName);
+
+ /* Get the device object */
+ Status = CompBattGetDeviceObjectPointer(BatteryName,
+ FILE_ALL_ACCESS,
+ &FileObject,
+ &BatteryData->DeviceObject);
+ if (NT_SUCCESS(Status))
+ {
+ /* Reference the DO and drop the FO */
+ ObfReferenceObject(BatteryData->DeviceObject);
+ ObfDereferenceObject(FileObject);
+
+ /* Allocate the battery IRP */
+ Irp = IoAllocateIrp(BatteryData->DeviceObject->StackSize + 1, 0);
+ if (Irp)
+ {
+ /* Save it */
+ BatteryData->Irp = Irp;
+
+ /* Setup the stack location */
+ IoStackLocation = IoGetNextIrpStackLocation(Irp);
+ IoStackLocation->Parameters.Others.Argument1 = DeviceExtension;
+ IoStackLocation->Parameters.Others.Argument2 = BatteryData;
+
+ /* Set IRP data */
+ IoSetNextIrpStackLocation(Irp);
+ Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
+ BatteryData->WaitFlag = 0;
+
+ /* Insert this battery in the list */
+ ExAcquireFastMutex(&DeviceExtension->Lock);
+ InsertTailList(&DeviceExtension->BatteryList,
+ &BatteryData->BatteryLink);
+ ExReleaseFastMutex(&DeviceExtension->Lock);
+
+ /* Initialize the work item and delete lock */
+ IoInitializeRemoveLock(&BatteryData->RemoveLock, 0, 0, 0);
+ ExInitializeWorkItem(&BatteryData->WorkItem,
+ (PVOID)CompBattMonitorIrpCompleteWorker,
+ BatteryData);
+
+ /* Setup the IRP work entry */
+ CompBattMonitorIrpComplete(BatteryData->DeviceObject, Irp, 0);
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ /* Fail, no memory */
+ if (CompBattDebug & 8)
+ DbgPrint("CompBatt: Couldn't allocate new battery Irp\n");
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ ObfDereferenceObject(BatteryData->DeviceObject);
+ }
+ }
+ else if (CompBattDebug & 8)
+ {
+ /* Fail */
+ DbgPrint("CompBattAddNewBattery: Failed to get device Object. status = %lx\n",
+ Status);
+ }
+
+ /* Free the battery data */
+ ExFreePool(BatteryData);
+ }
+ else
+ {
+ /* Fail, no memory */
+ if (CompBattDebug & 8)
+ DbgPrint("CompBatt: Couldn't allocate new battery node\n");
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+
+ /* We're done */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING AddNewBattery\n");
+ return Status;
}
NTSTATUS
CompBattRemoveBattery(IN PCUNICODE_STRING BatteryName,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PCOMPBATT_BATTERY_DATA BatteryData;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: RemoveBattery\n");
+
+ /* Remove the entry */
+ BatteryData = RemoveBatteryFromList(BatteryName, DeviceExtension);
+ if (BatteryData)
+ {
+ /* Dereference and free it */
+ ObfDereferenceObject(BatteryData->DeviceObject);
+ ExFreePool(BatteryData);
+
+ /* Notify class driver */
+ DeviceExtension->Flags = 0;
+ BatteryClassStatusNotify(DeviceExtension->ClassData);
+ }
+
+ /* It's done */
+ return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
CompBattGetBatteries(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PWCHAR p;
+ NTSTATUS Status;
+ PWCHAR LinkList;
+ UNICODE_STRING LinkString;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteries\n");
+
+ /* Get all battery links */
+ Status = IoGetDeviceInterfaces(&GUID_DEVICE_BATTERY, NULL, 0, &LinkList);
+ p = LinkList;
+ if (NT_SUCCESS(Status))
+ {
+ /* Loop all strings inside */
+ while (TRUE)
+ {
+ /* Create the string */
+ RtlInitUnicodeString(&LinkString, p);
+ if (!LinkString.Length) break;
+
+ /* Add this battery and move on */
+ Status = CompBattAddNewBattery(&LinkString, DeviceExtension);
+ p += (LinkString.Length / sizeof(WCHAR)) + sizeof(UNICODE_NULL);
+ }
+
+ /* Parsing complete, clean up buffer */
+ ExFreePool(LinkList);
+ }
+ else if (CompBattDebug & 8)
+ {
+ /* Fail */
+ DbgPrint("CompBatt: Couldn't get list of batteries\n");
+ }
+
+ /* Done */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteries\n");
+ return Status;
}
NTSTATUS
CompBattPnpEventHandler(IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification,
IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpEventHandler\n");
+ if (CompBattDebug & 2) DbgPrint("CompBatt: Received device interface change notification\n");
+
+ /* Check what happened */
+ if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL))
+ {
+ /* Add the new battery */
+ if (CompBattDebug & 2)
+ DbgPrint("CompBatt: Received notification of battery arrival\n");
+ CompBattAddNewBattery(Notification->SymbolicLinkName, DeviceExtension);
+ }
+ else if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL))
+ {
+ /* Don't do anything */
+ if (CompBattDebug & 2)
+ DbgPrint("CompBatt: Received notification of battery removal\n");
+ }
+ else
+ {
+ /* Shouldn't happen */
+ if (CompBattDebug & 2) DbgPrint("CompBatt: Received unhandled PnP event\n");
+ }
+
+ /* Done, return success */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpEventHandler\n");
+ return STATUS_SUCCESS;
}
NTSTATUS
CompBattAddDevice(IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PdoDeviceObject)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ NTSTATUS Status;
+ UNICODE_STRING DeviceName;
+ PCOMPBATT_DEVICE_EXTENSION DeviceExtension;
+ PDEVICE_OBJECT DeviceObject;
+ UNICODE_STRING SymbolicLinkName;
+ BATTERY_MINIPORT_INFO MiniportInfo;
+ if (CompBattDebug & 2) DbgPrint("CompBatt: Got an AddDevice - %x\n", PdoDeviceObject);
+
+ /* Create the device */
+ RtlInitUnicodeString(&DeviceName, L"\\Device\\CompositeBattery");
+ Status = IoCreateDevice(DriverObject,
+ sizeof(COMPBATT_DEVICE_EXTENSION),
+ &DeviceName,
+ FILE_DEVICE_BATTERY,
+ FILE_DEVICE_SECURE_OPEN,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Setup symbolic link for Win32 access */
+ RtlInitUnicodeString(&SymbolicLinkName, L"\\DosDevices\\CompositeBattery");
+ IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName);
+
+ /* Initialize the device extension */
+ DeviceExtension = DeviceObject->DeviceExtension;
+ RtlZeroMemory(DeviceExtension, 0x1B0u);
+
+ /* Attach to device stack and set DO pointers */
+ DeviceExtension->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
+ PdoDeviceObject);
+ DeviceExtension->DeviceObject = DeviceObject;
+ if (!DeviceExtension->AttachedDevice)
+ {
+ /* Fail */
+ if (CompBattDebug & 8)
+ DbgPrint("CompBattAddDevice: Could not attach to LowerDevice.\n");
+ IoDeleteDevice(DeviceObject);
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Set device object flags */
+ DeviceObject->Flags |= (DO_POWER_PAGABLE | DO_BUFFERED_IO);
+ DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
+
+ /* Setup the device extension */
+ ExInitializeFastMutex(&DeviceExtension->Lock);
+ InitializeListHead(&DeviceExtension->BatteryList);
+ DeviceExtension->Flags = 0;
+ DeviceExtension->NextTag = 1;
+
+ /* Setup the miniport data */
+ RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo));
+ MiniportInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION;
+ MiniportInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION;
+ MiniportInfo.Context = DeviceExtension;
+ MiniportInfo.DeviceName = &DeviceName;
+ MiniportInfo.QueryTag = (BCLASS_QUERY_TAG)CompBattQueryTag;
+ MiniportInfo.QueryInformation = (BCLASS_QUERY_INFORMATION)CompBattQueryInformation;
+ MiniportInfo.SetInformation = NULL;
+ MiniportInfo.QueryStatus = (BCLASS_QUERY_STATUS)CompBattQueryStatus;
+ MiniportInfo.SetStatusNotify = (BCLASS_SET_STATUS_NOTIFY)CompBattSetStatusNotify;
+ MiniportInfo.DisableStatusNotify = (BCLASS_DISABLE_STATUS_NOTIFY)CompBattDisableStatusNotify;
+ MiniportInfo.Pdo = NULL;
+
+ /* Register with the class driver */
+ Status = BatteryClassInitializeDevice(&MiniportInfo,
+ &DeviceExtension->ClassData);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Undo everything */
+ IoDetachDevice(DeviceExtension->AttachedDevice);
+ IoDeleteDevice(DeviceObject);
+ }
+
+ /* Return status */
+ return Status;
}
NTSTATUS
CompBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PIO_STACK_LOCATION IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
+ NTSTATUS Status;
+ PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpDispatch\n");
+
+ /* Set default error */
+ Status = STATUS_NOT_SUPPORTED;
+
+ /* Check what kind of PnP function this is */
+ switch (IoStackLocation->MinorFunction)
+ {
+ case IRP_MN_START_DEVICE:
+
+ /* Device is starting, register for new batteries and pick up current ones */
+ Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
+ 0,
+ (PVOID)&GUID_DEVICE_BATTERY,
+ DeviceObject->DriverObject,
+ (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)CompBattPnpEventHandler,
+ DeviceExtension,
+ &DeviceExtension->NotificationEntry);
+ if (NT_SUCCESS(Status))
+ {
+ /* Now go get the batteries */
+ if (CompBattDebug & 2)
+ DbgPrint("CompBatt: Successfully registered for PnP notification\n");
+ Status = CompBattGetBatteries(DeviceExtension);
+ }
+ else
+ {
+ /* We failed */
+ if (CompBattDebug & 8)
+ DbgPrint("CompBatt: Couldn't register for PnP notification - %x\n",
+ Status);
+ }
+
+ case IRP_MN_CANCEL_STOP_DEVICE:
+
+ /* Explicitly say ok */
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IRP_MN_CANCEL_REMOVE_DEVICE:
+
+ /* Explicitly say ok */
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IRP_MN_SURPRISE_REMOVAL:
+
+ /* Explicitly say ok */
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IRP_MN_QUERY_PNP_DEVICE_STATE:
+
+ /* Add this in */
+ Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
+ Status = STATUS_SUCCESS;
+ break;
+
+ default:
+
+ /* Not supported */
+ Status = STATUS_INVALID_DEVICE_REQUEST;
+ break;
+ }
+
+ /* Set IRP status if we have one */
+ if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
+
+ /* Did someone pick it up? */
+ if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED))
+ {
+ /* Still unsupported, try ACPI */
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
+ }
+ else
+ {
+ /* Complete the request */
+ Status = Irp->IoStatus.Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+
+ /* Release the remove lock and return status */
+ if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpDispatch\n");
+ return Status;
}
/* EOF */
Caps |= SYS_BUTTON_SLEEP;
}
}
- if (wcsstr(((PPDO_DEVICE_DATA)commonData)->HardwareIDs, L"PNP0C0C"))
+ else if (wcsstr(((PPDO_DEVICE_DATA)commonData)->HardwareIDs, L"PNP0C0C"))
{
DPRINT1("Control method power button reported to power manager\n");
Caps |= SYS_BUTTON_POWER;
<directory name="pci">
<xi:include href="pci/pci.rbuild" />
</directory>
+<directory name="pcix">
+ <xi:include href="pcix/pcix.rbuild" />
+</directory>
</group>
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/arb/ar_busno.c
+ * PURPOSE: Bus Number Arbitration
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/arb/ar_memiono.c
+ * PURPOSE: Memory and I/O Port Resource Arbitration
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/arb/arb_comn.c
+ * PURPOSE: Common Arbitration Code
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/arb/tr_irq.c
+ * PURPOSE: IRQ Resource Translation
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/debug.c
+ * PURPOSE: Debug Helpers
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/device.c
+ * PURPOSE: Device Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/dispatch.c
+ * PURPOSE: WDM Dispatch Routines
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/enum.c
+ * PURPOSE: PCI Bus/Device Enumeration
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/fdo.c
+ * PURPOSE: FDO Device Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/guid.c
+ * PURPOSE: GUID Data
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/hookhal.c
+ * PURPOSE: HAL Bus Handler Dispatch Routine Support
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/init.c
+ * PURPOSE: Driver Initialization
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+DriverEntry(IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath)
+{
+ DPRINT1("PCI: DriverEntry!\n");
+
+ /* FIXME: TODO */
+ return STATUS_NOT_SUPPORTED;
+}
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/agpintrf.c
+ * PURPOSE: AGP Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/busintrf.c
+ * PURPOSE: Bus Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/cardbus.c
+ * PURPOSE: CardBus Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/ideintrf.c
+ * PURPOSE: IDE Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/intrface.c
+ * PURPOSE: Common Interface Support Routines
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/lddintrf.c
+ * PURPOSE: Legacy Device Detection Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/locintrf.c
+ * PURPOSE: Location Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/pmeintf.c
+ * PURPOSE: Power Management Event# Signal Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/intrface/routinf.c
+ * PURPOSE: Routing Interface
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci.h
+ * PURPOSE: Main Header File
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+#include <ntddk.h>
+
+/* EOF */
--- /dev/null
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "PCI Bus Driver\0"
+#define REACTOS_STR_INTERNAL_NAME "pci\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "pci.sys\0"
+#include <reactos/version.rc>
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/busno.c
+ * PURPOSE: Bus Number Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/config.c
+ * PURPOSE: PCI Configuration Space Routines
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/devhere.c
+ * PURPOSE: PCI Device Detection and Location
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/id.c
+ * PURPOSE: PCI Device Identification
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/ppbridge.c
+ * PURPOSE: PCI-to-PCI Bridge Support
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/romimage.c
+ * PURPOSE: PCI ROM Image Support
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pci/state.c
+ * PURPOSE: Bus/Device State Support
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pcivrify.c
+ * PURPOSE: PCI Driver Verifier Support
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="pcix" type="kernelmodedriver" installbase="system32/drivers" installname="pcix.sys">
+ <bootstrap installbase="$(CDOUTPUT)" />
+ <include base="pcix">.</include>
+ <library>ntoskrnl</library>
+ <library>hal</library>
+ <directory name="arb">
+ <file>ar_busno.c</file>
+ <file>ar_memio.c</file>
+ <file>arb_comn.c</file>
+ <file>tr_irq.c</file>
+ </directory>
+ <directory name="intrface">
+ <file>agpintrf.c</file>
+ <file>busintrf.c</file>
+ <file>cardbus.c</file>
+ <file>ideintrf.c</file>
+ <file>intrface.c</file>
+ <file>lddintrf.c</file>
+ <file>locintrf.c</file>
+ <file>pmeintf.c</file>
+ <file>routintf.c</file>
+ </directory>
+ <directory name="pci">
+ <file>busno.c</file>
+ <file>config.c</file>
+ <file>devhere.c</file>
+ <file>id.c</file>
+ <file>ppbridge.c</file>
+ <file>romimage.c</file>
+ <file>state.c</file>
+ </directory>
+ <file>debug.c</file>
+ <file>device.c</file>
+ <file>dispatch.c</file>
+ <file>enum.c</file>
+ <file>fdo.c</file>
+ <file>guid.c</file>
+ <file>hookhal.c</file>
+ <file>init.c</file>
+ <file>pcivrify.c</file>
+ <file>pdo.c</file>
+ <file>power.c</file>
+ <file>usage.c</file>
+ <file>utils.c</file>
+ <file>pci.rc</file>
+ <pch>pci.h</pch>
+</module>
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/pdo.c
+ * PURPOSE: PDO Device Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/power.c
+ * PURPOSE: Bus/Device Power Management
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/usage.c
+ * PURPOSE: Bus/Device Usage Reporting
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS PCI Bus Driver
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: drivers/bus/pci/utils.c
+ * PURPOSE: Utility/Helper Support Code
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <pci.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* FUNCTIONS ******************************************************************/
+
+/* EOF */
IN PKSDEVICE Device)
{
IKsDevice *KsDevice;
- PKSIDEVICE_HEADER DeviceHeader = (PKSIDEVICE_HEADER)CONTAINING_RECORD(Device, KSIDEVICE_HEADER, KsDevice);
+ PKSIDEVICE_HEADER DeviceHeader;
+
+
+ DeviceHeader = (PKSIDEVICE_HEADER)CONTAINING_RECORD(Device, KSIDEVICE_HEADER, KsDevice);
/* get device interface*/
KsDevice = (IKsDevice*)&DeviceHeader->lpVtblIKsDevice;
BagEntry->Free = ExFreePool;
/* insert item */
- InsertTailList(&Bag->ObjectList, &Bag->Entry);
+ InsertTailList(&Bag->ObjectList, &BagEntry->Entry);
/* release mutex */
KeReleaseMutex(Bag->BagMutex, FALSE);
break;
}
- /* calculate size */
- Size = sizeof(KSMULTIPLE_ITEM);
- Size += max(1, Descriptor[Pin->PinId].InterfacesCount) * sizeof(KSPIN_INTERFACE);
-
- if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
+ if (Descriptor[Pin->PinId].Interfaces)
{
- Irp->IoStatus.Information = Size;
- Status = STATUS_MORE_ENTRIES;
- break;
- }
-
- Item = (KSMULTIPLE_ITEM*)Buffer;
- Item->Size = Size;
-
- if (Descriptor[Pin->PinId].InterfacesCount)
- {
- Item->Count = Descriptor[Pin->PinId].InterfacesCount;
- RtlMoveMemory((PVOID)(Item + 1), Descriptor[Pin->PinId].Interfaces, Descriptor[Pin->PinId].InterfacesCount * sizeof(KSPIN_INTERFACE));
+ /* use mediums provided by driver */
+ return KsHandleSizedListQuery(Irp, Descriptor[Pin->PinId].InterfacesCount, sizeof(KSPIN_MEDIUM), Descriptor[Pin->PinId].Interfaces);
}
else
{
- Item->Count = 1;
- RtlMoveMemory((PVOID)(Item + 1), &StandardPinInterface, sizeof(KSPIN_INTERFACE));
+ /* use standard medium */
+ return KsHandleSizedListQuery(Irp, 1, sizeof(KSPIN_INTERFACE), &StandardPinInterface);
}
-
- Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = Size;
break;
+
case KSPROPERTY_PIN_MEDIUMS:
Pin = (KSP_PIN*)Property;
if (Pin->PinId >= DescriptorsCount)
if (!Mutex)
{
/* use device mutex */
- Mutex = &This->DeviceMutex;
+ Mutex = &This->BagMutex;
}
/* initialize object bag */
PPNP_POSTSTART_CONTEXT Ctx = (PPNP_POSTSTART_CONTEXT)Context;
/* call driver pnp post routine */
- Status = Ctx->DeviceHeader->Descriptor->Dispatch->PostStart(&Ctx->DeviceHeader->KsDevice);
+ Status = Ctx->DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart(&Ctx->DeviceHeader->KsDevice);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Driver: PostStart Routine returned %x\n", Status);
-
/* set state to disabled */
Ctx->DeviceHeader->TargetState = KSTARGET_STATE_DISABLED;
}
{
/* set state to enabled */
Ctx->DeviceHeader->TargetState = KSTARGET_STATE_ENABLED;
+ Status = KspSetFilterFactoriesState(Ctx->DeviceHeader, TRUE);
}
/* free work item */
/* free work context */
FreeItem(Ctx);
+
+ DPRINT("IKsDevice_PnpPostStart: PostStart Routine returned %x\n", Status);
}
NTSTATUS
PKSIDEVICE_HEADER DeviceHeader;
PPNP_POSTSTART_CONTEXT Ctx = NULL;
NTSTATUS Status;
+ PCM_RESOURCE_LIST TranslatedResourceList;
+ PCM_RESOURCE_LIST UntranslatedResourceList;
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor, UnPartialDescriptor;
+ ULONG Index;
/* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
/* get device header */
DeviceHeader = DeviceExtension->DeviceHeader;
+ DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
+
/* first forward irp to lower device object */
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
return Status;
}
+ TranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated;
+ UntranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResources;
+
+ DPRINT("ResourceDescriptorCount %lu\n", TranslatedResourceList->List[0].PartialResourceList.Count);
+ for (Index = 0; Index < TranslatedResourceList->List[0].PartialResourceList.Count; Index ++ )
+ {
+ PartialDescriptor = &TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
+ UnPartialDescriptor = &UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index];
+ DPRINT("Descriptor Type %u\n", PartialDescriptor->Type);
+
+ if (PartialDescriptor->Type == CmResourceTypeInterrupt)
+ {
+ DPRINT("CmResourceTypeInterrupt Index %u TRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\n", Index, PartialDescriptor->u.Interrupt.Affinity, PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition);
+ DPRINT("CmResourceTypeInterrupt Index %u UNTRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\\n", Index, UnPartialDescriptor->u.Interrupt.Affinity, UnPartialDescriptor->u.Interrupt.Level, UnPartialDescriptor->u.Interrupt.Vector, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition);
+
+ }
+ else if (PartialDescriptor->Type == CmResourceTypePort)
+ {
+ DPRINT("CmResourceTypePort Index %u TRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, PartialDescriptor->u.Port.Length, PartialDescriptor->u.Port.Start.HighPart, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition);
+ DPRINT("CmResourceTypePort Index %u UNTRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, UnPartialDescriptor->u.Port.Length, UnPartialDescriptor->u.Port.Start.HighPart, UnPartialDescriptor->u.Port.Start.LowPart, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition);
+ }
+ else if (PartialDescriptor->Type == CmResourceTypeMemory)
+ {
+ DPRINT("CmResourceTypeMemory Index %u TRANS Start %x Length %u Flags %x Share %x\n", Index, PartialDescriptor->u.Memory.Start.LowPart, PartialDescriptor->u.Memory.Length, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition);
+ DPRINT("CmResourceTypeMemory Index %u TRANS Start %x Length %u Flags %x Share %x\n", Index, UnPartialDescriptor->u.Memory.Start.LowPart, UnPartialDescriptor->u.Memory.Length, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition);
+ }
+ }
+
+ ASSERT(DeviceHeader->KsDevice.Descriptor);
+ ASSERT(DeviceHeader->KsDevice.Descriptor->Dispatch);
+ ASSERT(DeviceHeader->KsDevice.Descriptor->Dispatch->Start);
+
+
/* do we have a device descriptor */
- if (DeviceHeader->Descriptor)
+ if (DeviceHeader->KsDevice.Descriptor)
{
/* does the device want pnp notifications */
- if (DeviceHeader->Descriptor->Dispatch)
+ if (DeviceHeader->KsDevice.Descriptor->Dispatch)
{
/* does the driver care about IRP_MN_START_DEVICE */
- if (DeviceHeader->Descriptor->Dispatch->Start)
+ if (DeviceHeader->KsDevice.Descriptor->Dispatch->Start)
{
/* call driver start device routine */
- Status = DeviceHeader->Descriptor->Dispatch->Start(&DeviceHeader->KsDevice, Irp,
- IoStack->Parameters.StartDevice.AllocatedResourcesTranslated,
- IoStack->Parameters.StartDevice.AllocatedResources);
+ Status = DeviceHeader->KsDevice.Descriptor->Dispatch->Start(&DeviceHeader->KsDevice, Irp,
+ TranslatedResourceList,
+ UntranslatedResourceList);
+
+ DPRINT("IKsDevice_PnpStartDevice Start %p, Context %p\n", DeviceHeader->KsDevice.Descriptor->Dispatch->Start, DeviceHeader->KsDevice.Context);
ASSERT(Status != STATUS_PENDING);
if (!NT_SUCCESS(Status))
}
/* does the driver need post start routine */
- if (DeviceHeader->Descriptor->Dispatch->PostStart)
+ if (DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart)
{
/* allocate pnp post workitem context */
Ctx = (PPNP_POSTSTART_CONTEXT)AllocateItem(NonPagedPool, sizeof(PNP_POSTSTART_CONTEXT));
{
/* set state to enabled, IRP_MJ_CREATE request may now succeed */
DeviceHeader->TargetState = KSTARGET_STATE_ENABLED;
+ Status = KspSetFilterFactoriesState(DeviceHeader, TRUE);
}
}
}
}
/* return result */
+ DPRINT1("IKsDevice_PnpStartDevice Status %x PostStartRoutine %p\n", Status, Ctx);
return Status;
}
DeviceHeader = DeviceExtension->DeviceHeader;
/* do we have a device descriptor */
- if (DeviceHeader->Descriptor)
+ if (DeviceHeader->KsDevice.Descriptor && DeviceHeader->KsDevice.Descriptor->Dispatch)
{
/* does the device want pnp notifications */
- Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->Descriptor->Dispatch;
+ Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->KsDevice.Descriptor->Dispatch;
}
switch (IoStack->MinorFunction)
/* pass the irp down the driver stack */
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
- DPRINT("Next Device: Status %x\n", Status);
+ DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status);
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
case IRP_MN_QUERY_DEVICE_RELATIONS:
{
- DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n");
-
/* pass the irp down the driver stack */
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
- DPRINT("Next Device: Status %x\n", Status);
+ DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status);
- Irp->IoStatus.Status = Status;
+ //Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
{
- DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
+ //Status = KspForwardIrpSynchronous(DeviceObject, Irp);
+ Status = Irp->IoStatus.Status;
+ DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
- DPRINT("Next Device: Status %x\n", Status);
-
- Irp->IoStatus.Status = Status;
+ //Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
{
- DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
/* pass the irp down the driver stack */
Status = KspForwardIrpSynchronous(DeviceObject, Irp);
- DPRINT("Next Device: Status %x\n", Status);
+ DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status);
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
PKSIOBJECT_HEADER ObjectHeader;
NTSTATUS Status;
- DPRINT("KS / CREATE\n");
+ DPRINT("IKsDevice_Create\n");
/* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
/* get device extension */
PDEVICE_EXTENSION DeviceExtension;
PKSIDEVICE_HEADER Header;
ULONG Index;
- IKsDevice * KsDevice;
+ PKSIOBJECT_BAG Bag;
NTSTATUS Status = STATUS_SUCCESS;
+ DPRINT("KsInitializeDevice Descriptor %p\n", Descriptor);
+
/* get device extension */
DeviceExtension = (PDEVICE_EXTENSION)FunctionalDeviceObject->DeviceExtension;
/* point to allocated header */
Header = DeviceExtension->DeviceHeader;
+ DPRINT("DeviceHeader %p\n", DeviceExtension->DeviceHeader);
+
+
/* check for success */
if (!NT_SUCCESS(Status))
{
- DPRINT1("Failed to allocate device header with %x\n", Status);
+ DPRINT1("KsInitializeDevice Failed to allocate device header with %x\n", Status);
return Status;
}
Header->lpVtblIKsDevice = &vt_IKsDevice;
Header->ref = 1;
- /* initialize object bag */
+ /* allocate object bag */
Header->KsDevice.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
if (!Header->KsDevice.Bag)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
- KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
- KsDevice->lpVtbl->InitializeObjectBag(KsDevice, Header->KsDevice.Bag, NULL);
+ /* initialize object bag */
+ KeInitializeMutex(&Header->BagMutex, 0);
+ KeInitializeMutex(&Header->DeviceMutex, 0);
+ Bag = (PKSIOBJECT_BAG)Header->KsDevice.Bag;
+ Bag->BagMutex = &Header->BagMutex;
+ InitializeListHead(&Header->ObjectBags);
+ InitializeListHead(&Bag->ObjectList);
+ Bag->DeviceHeader = (PVOID)Header;
+
+ /* insert bag into device list */
+ InsertTailList(&Header->ObjectBags, &Bag->Entry);
/* initialize device header */
Header->KsDevice.FunctionalDeviceObject = FunctionalDeviceObject;
Header->KsDevice.PhysicalDeviceObject = PhysicalDeviceObject;
Header->KsDevice.NextDeviceObject = NextDeviceObject;
Header->KsDevice.Descriptor = Descriptor;
+ Header->KsDevice.SystemPowerState = PowerSystemWorking;
+ Header->KsDevice.DevicePowerState = PowerDeviceD0;
+ Header->KsDevice.Started = FALSE;
+ Header->KsDevice.Context = NULL;
KsSetDevicePnpAndBaseObject(Header, PhysicalDeviceObject, NextDeviceObject);
- /* FIXME Power state */
+
if (Descriptor)
{
/* create a filter factory for each filter descriptor */
+ DPRINT("KsInitializeDevice FilterDescriptorCount %lu\n", Descriptor->FilterDescriptorsCount);
for(Index = 0; Index < Descriptor->FilterDescriptorsCount; Index++)
{
Status = KspCreateFilterFactory(FunctionalDeviceObject, Descriptor->FilterDescriptors[Index], NULL, NULL, 0, NULL, NULL, NULL);
+
+ DPRINT("KsInitializeDevice Index %lu KspCreateFilterFactory Status %lx\n", Index, Status);
/* check for success */
if (!NT_SUCCESS(Status))
{
Status = Descriptor->Dispatch->Add(&Header->KsDevice);
DPRINT("Driver: AddHandler Status %x\n", Status);
+ Header->KsDevice.Descriptor = Descriptor;
}
}
SymEntry = (PSYMBOLIC_LINK_ENTRY)CONTAINING_RECORD(Entry, SYMBOLIC_LINK_ENTRY, Entry);
/* set device interface state */
Status = IoSetDeviceInterfaceState(&SymEntry->SymbolicLink, Enable);
+
+ DPRINT("KspSetDeviceInterfacesState SymbolicLink '%S' Status %lx\n", SymEntry->SymbolicLink.Buffer, Status, Enable);
+
/* check for success */
if (!NT_SUCCESS(Status))
return Status;
return Status;
}
+NTSTATUS
+KspSetFilterFactoriesState(
+ IN PKSIDEVICE_HEADER DeviceHeader,
+ IN BOOLEAN NewState)
+{
+ PCREATE_ITEM_ENTRY CreateEntry;
+ PLIST_ENTRY Entry;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ /* grab first device interface */
+ Entry = DeviceHeader->ItemList.Flink;
+ while(Entry != &DeviceHeader->ItemList && Status == STATUS_SUCCESS)
+ {
+ /* grab create entry */
+ CreateEntry = CONTAINING_RECORD(Entry, CREATE_ITEM_ENTRY, Entry);
+
+ /* sanity check */
+ ASSERT(CreateEntry->CreateItem);
+ if (CreateEntry->CreateItem->Create == IKsFilterFactory_Create)
+ {
+ /* found our own filterfactory */
+ Status = KsFilterFactorySetDeviceClassesState((PKSFILTERFACTORY)CreateEntry->CreateItem->Context, NewState);
+ }
+
+ Entry = Entry->Flink;
+ }
+
+ /* store result */
+ return Status;
+}
KsGetDevice(
IN PVOID Object)
{
- PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)(ULONG_PTR)Object - sizeof(KSBASIC_HEADER);
+ PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)((ULONG_PTR)Object - sizeof(KSBASIC_HEADER));
+
+ DPRINT("KsGetDevice %p BasicHeader %p Type %x\n", Object, BasicHeader, BasicHeader->Type);
ASSERT(BasicHeader->Type == KsObjectTypeFilterFactory || BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == BasicHeader->Type);
+ ASSERT(BasicHeader->KsDevice);
return BasicHeader->KsDevice;
}
if (!ExtensionSize)
ExtensionSize = sizeof(KSDEVICE_HEADER);
+ DPRINT("KsCreateDevice Descriptor %p ExtensionSize %lu\n", Descriptor, ExtensionSize);
+
Status = IoCreateDevice(DriverObject, ExtensionSize, NULL, FILE_DEVICE_KS, FILE_DEVICE_SECURE_OPEN, FALSE, &FunctionalDeviceObject);
if (!NT_SUCCESS(Status))
return Status;
const KSDEVICE_DESCRIPTOR *Descriptor = NULL;
/* get stored driver object extension */
- DriverObjectExtension = IoGetDriverObjectExtension(DriverObject, (PVOID)KsAddDevice);
+
+ DriverObjectExtension = IoGetDriverObjectExtension(DriverObject, (PVOID)KsInitializeDriver);
if (DriverObjectExtension)
{
)
{
PKS_DRIVER_EXTENSION DriverObjectExtension;
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
if (Descriptor)
{
- Status = IoAllocateDriverObjectExtension(DriverObject, (PVOID)KsAddDevice, sizeof(KS_DRIVER_EXTENSION), (PVOID*)&DriverObjectExtension);
+ Status = IoAllocateDriverObjectExtension(DriverObject, (PVOID)KsInitializeDriver, sizeof(KS_DRIVER_EXTENSION), (PVOID*)&DriverObjectExtension);
if (NT_SUCCESS(Status))
{
DriverObjectExtension->Descriptor = Descriptor;
}
}
+ /* sanity check */
+ ASSERT(Status == STATUS_SUCCESS);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
/* Setting our IRP handlers */
DriverObject->MajorFunction[IRP_MJ_CREATE] = IKsDevice_Create;
DriverObject->MajorFunction[IRP_MJ_PNP] = IKsDevice_Pnp;
DriverObject->DriverExtension->AddDevice = KsAddDevice;
/* KS handles these */
- DPRINT1("Setting KS function handlers\n");
+ DPRINT1("KsInitializeDriver Setting KS function handlers\n");
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
PKSIOBJECT_HEADER ObjectHeader;
KSTOPOLOGY Topology;
+ KSPIN_DESCRIPTOR_EX * PinDescriptorsEx;
KSPIN_DESCRIPTOR * PinDescriptors;
ULONG PinDescriptorCount;
PKSFILTERFACTORY Factory;
IKsFilter * iface,
IN PKSPROCESSPIN ProcessPin)
{
- PKSPROCESSPIN *Pins;
+ NTSTATUS Status;
IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(iface, IKsFilterImpl, lpVtbl);
/* first acquire processing mutex */
KeWaitForSingleObject(&This->ProcessingMutex, Executive, KernelMode, FALSE, NULL);
- /* allocate new pins array */
- Pins = AllocateItem(NonPagedPool, sizeof(PKSPROCESSPIN) * (This->ProcessPinIndex.Count + 1));
+ /* edit process pin descriptor */
+ Status = _KsEdit(This->Filter.Bag,
+ (PVOID*)&This->ProcessPinIndex.Pins,
+ (This->ProcessPinIndex.Count + 1) * sizeof(PKSPROCESSPIN),
+ (This->ProcessPinIndex.Count) * sizeof(PKSPROCESSPIN),
+ 0);
- /* check if allocation succeeded */
- if (Pins)
+ if (NT_SUCCESS(Status))
{
- if (This->ProcessPinIndex.Count)
- {
- /* copy old pin index */
- RtlMoveMemory(Pins, This->ProcessPinIndex.Pins, sizeof(PKSPROCESSPIN) * This->ProcessPinIndex.Count);
- }
-
/* add new process pin */
- Pins[This->ProcessPinIndex.Count] = ProcessPin;
-
- /* free old process pin */
- FreeItem(This->ProcessPinIndex.Pins);
-
- /* store new process pin index */
- This->ProcessPinIndex.Pins = Pins;
+ This->ProcessPinIndex.Pins[This->ProcessPinIndex.Count] = ProcessPin;
This->ProcessPinIndex.Count++;
}
/* release process mutex */
KeReleaseMutex(&This->ProcessingMutex, FALSE);
- if (Pins)
- return STATUS_SUCCESS;
- else
- return STATUS_INSUFFICIENT_RESOURCES;
-
+ return Status;
}
NTSTATUS
KSPIN_CINSTANCES * Instances;
KSP_PIN * Pin = (KSP_PIN*)Request;
- if (!This->Factory->FilterDescriptor || !This->Factory->FilterDescriptor->PinDescriptorsCount)
+ if (!This->Factory->FilterDescriptor || !This->PinDescriptorCount)
{
/* no filter / pin descriptor */
IoStatus->Status = STATUS_NOT_IMPLEMENTED;
/* ignore custom structs for now */
ASSERT(This->Factory->FilterDescriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
- ASSERT(This->Factory->FilterDescriptor->PinDescriptorsCount > Pin->PinId);
+ ASSERT(This->PinDescriptorCount > Pin->PinId);
Instances = (KSPIN_CINSTANCES*)Data;
/* max instance count */
- Instances->PossibleCount = This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].InstancesPossible;
+ Instances->PossibleCount = This->PinDescriptorsEx[Pin->PinId].InstancesPossible;
/* current instance count */
Instances->CurrentCount = This->PinInstanceCount[Pin->PinId];
PULONG Result;
KSP_PIN * Pin = (KSP_PIN*)Request;
- if (!This->Factory->FilterDescriptor || !This->Factory->FilterDescriptor->PinDescriptorsCount)
+ if (!This->Factory->FilterDescriptor || !This->PinDescriptorCount)
{
/* no filter / pin descriptor */
IoStatus->Status = STATUS_NOT_IMPLEMENTED;
/* ignore custom structs for now */
ASSERT(This->Factory->FilterDescriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
- ASSERT(This->Factory->FilterDescriptor->PinDescriptorsCount > Pin->PinId);
+ ASSERT(This->PinDescriptorCount > Pin->PinId);
Result = (PULONG)Data;
- *Result = This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].InstancesNecessary;
+ *Result = This->PinDescriptorsEx[Pin->PinId].InstancesNecessary;
IoStatus->Information = sizeof(ULONG);
IoStatus->Status = STATUS_SUCCESS;
MultipleItem = (PKSMULTIPLE_ITEM)(Pin + 1);
DataRange = (PKSDATARANGE)(MultipleItem + 1);
- if (!This->Factory->FilterDescriptor || !This->Factory->FilterDescriptor->PinDescriptorsCount)
+ if (!This->Factory->FilterDescriptor || !This->PinDescriptorCount)
{
/* no filter / pin descriptor */
IoStatus->Status = STATUS_NOT_IMPLEMENTED;
/* ignore custom structs for now */
ASSERT(This->Factory->FilterDescriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
- ASSERT(This->Factory->FilterDescriptor->PinDescriptorsCount > Pin->PinId);
+ ASSERT(This->PinDescriptorCount > Pin->PinId);
- if (This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].IntersectHandler == NULL ||
- This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].PinDescriptor.DataRanges == NULL ||
- This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].PinDescriptor.DataRangesCount == 0)
+ if (This->PinDescriptorsEx[Pin->PinId].IntersectHandler == NULL ||
+ This->PinDescriptors[Pin->PinId].DataRanges == NULL ||
+ This->PinDescriptors[Pin->PinId].DataRangesCount == 0)
{
/* no driver supported intersect handler / no provided data ranges */
IoStatus->Status = STATUS_NOT_IMPLEMENTED;
for(Index = 0; Index < MultipleItem->Count; Index++)
{
/* Call miniport's properitary handler */
- Status = This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].IntersectHandler(NULL, /* context */
- Irp,
- Pin,
- DataRange,
- (PKSDATAFORMAT)This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].PinDescriptor.DataRanges,
- DataLength,
- Data,
- &Length);
+ Status = This->PinDescriptorsEx[Pin->PinId].IntersectHandler(NULL, /* context */
+ Irp,
+ Pin,
+ DataRange,
+ (PKSDATAFORMAT)This->Factory->FilterDescriptor->PinDescriptors[Pin->PinId].PinDescriptor.DataRanges,
+ DataLength,
+ Data,
+ &Length);
if (Status == STATUS_SUCCESS)
{
UNIMPLEMENTED
Status = STATUS_UNSUCCESSFUL;
}
+ DPRINT("KspPinPropertyHandler Pins %lu Request->Id %lu Status %lx\n", This->PinDescriptorCount, Request->Id, Status);
+
return Status;
}
}
/* call property handler supported by ks */
+ KSPROPERTY_ITEM_IRP_STORAGE(Irp) = (KSPROPERTY_ITEM*)This;
Status = KspPropertyHandler(Irp, 2, FilterPropertySet, NULL, sizeof(KSPROPERTY_ITEM));
if (Status == STATUS_NOT_FOUND)
}
}
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ if (Status != STATUS_PENDING)
+ {
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
/* done */
return Status;
KSFILTER_DESCRIPTOR* FilterDescriptor)
{
ULONG Index = 0;
+ NTSTATUS Status;
/* initialize pin descriptors */
+ This->FirstPin = NULL;
+ This->PinInstanceCount = NULL;
+ This->PinDescriptors = NULL;
+ This->PinDescriptorsEx = NULL;
+ This->PinDescriptorCount = 0;
+
+ /* initialize topology descriptor */
+ This->Topology.CategoriesCount = FilterDescriptor->CategoriesCount;
+ This->Topology.Categories = FilterDescriptor->Categories;
+ This->Topology.TopologyNodesCount = FilterDescriptor->NodeDescriptorsCount;
+ This->Topology.TopologyConnectionsCount = FilterDescriptor->ConnectionsCount;
+ This->Topology.TopologyConnections = FilterDescriptor->Connections;
+
+ /* are there any templates */
if (FilterDescriptor->PinDescriptorsCount)
{
- /* allocate pin instance count array */
- This->PinInstanceCount = AllocateItem(NonPagedPool, sizeof(ULONG) * FilterDescriptor->PinDescriptorsCount);
- if(!This->PinDescriptors)
+ /* sanity check */
+ ASSERT(FilterDescriptor->PinDescriptors);
+
+ /* FIXME handle variable sized pin descriptors */
+ ASSERT(FilterDescriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
+
+ /* store pin descriptors ex */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptorsEx, sizeof(KSPIN_DESCRIPTOR_EX) * FilterDescriptor->PinDescriptorsCount,
+ sizeof(KSPIN_DESCRIPTOR_EX) * FilterDescriptor->PinDescriptorsCount, 0);
+
+ if (!NT_SUCCESS(Status))
{
- return STATUS_INSUFFICIENT_RESOURCES;
+ DPRINT("IKsFilter_CreateDescriptors _KsEdit failed %lx\n", Status);
+ return Status;
}
- /* allocate first pin array */
- This->FirstPin = AllocateItem(NonPagedPool, sizeof(PKSPIN) * FilterDescriptor->PinDescriptorsCount);
- if(!This->FirstPin)
+ /* store pin descriptors */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptors, sizeof(KSPIN_DESCRIPTOR) * FilterDescriptor->PinDescriptorsCount,
+ sizeof(KSPIN_DESCRIPTOR) * FilterDescriptor->PinDescriptorsCount, 0);
+
+ if (!NT_SUCCESS(Status))
{
- FreeItem(This->PinDescriptors);
- return STATUS_INSUFFICIENT_RESOURCES;
+ DPRINT("IKsFilter_CreateDescriptors _KsEdit failed %lx\n", Status);
+ return Status;
}
+ /* store pin instance count ex */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinInstanceCount, sizeof(ULONG) * FilterDescriptor->PinDescriptorsCount,
+ sizeof(ULONG) * FilterDescriptor->PinDescriptorsCount, 0);
- /* allocate pin descriptor array */
- This->PinDescriptors = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR) * FilterDescriptor->PinDescriptorsCount);
- if(!This->PinDescriptors)
+ if (!NT_SUCCESS(Status))
{
- FreeItem(This->PinInstanceCount);
- return STATUS_INSUFFICIENT_RESOURCES;
+ DPRINT("IKsFilter_CreateDescriptors _KsEdit failed %lx\n", Status);
+ return Status;
}
- /* set pin count */
- This->PinDescriptorCount = FilterDescriptor->PinDescriptorsCount;
- /* now copy those pin descriptors over */
+ /* store instantiated pin arrays */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->FirstPin, sizeof(PKSPIN) * FilterDescriptor->PinDescriptorsCount,
+ sizeof(PKSPIN) * FilterDescriptor->PinDescriptorsCount, 0);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("IKsFilter_CreateDescriptors _KsEdit failed %lx\n", Status);
+ return Status;
+ }
+
+
+
+ /* add new pin factory */
+ RtlMoveMemory(This->PinDescriptorsEx, FilterDescriptor->PinDescriptors, sizeof(KSPIN_DESCRIPTOR_EX) * FilterDescriptor->PinDescriptorsCount);
+
for(Index = 0; Index < FilterDescriptor->PinDescriptorsCount; Index++)
{
- /* copy one pin per time */
RtlMoveMemory(&This->PinDescriptors[Index], &FilterDescriptor->PinDescriptors[Index].PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
}
- }
- /* initialize topology descriptor */
- This->Topology.CategoriesCount = FilterDescriptor->CategoriesCount;
- This->Topology.Categories = FilterDescriptor->Categories;
- This->Topology.TopologyNodesCount = FilterDescriptor->NodeDescriptorsCount;
- This->Topology.TopologyConnectionsCount = FilterDescriptor->ConnectionsCount;
- This->Topology.TopologyConnections = FilterDescriptor->Connections;
+ /* store new pin descriptor count */
+ This->PinDescriptorCount = FilterDescriptor->PinDescriptorsCount;
+ }
- if (This->Topology.TopologyNodesCount > 0)
+ if (FilterDescriptor->NodeDescriptorsCount)
{
- This->Topology.TopologyNodes = AllocateItem(NonPagedPool, sizeof(GUID) * This->Topology.TopologyNodesCount);
+ /* sanity check */
+ ASSERT(FilterDescriptor->NodeDescriptors);
+
+ /* FIXME handle variable sized node descriptors */
+ ASSERT(FilterDescriptor->NodeDescriptorSize == sizeof(KSNODE_DESCRIPTOR));
+
+ This->Topology.TopologyNodes = AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescriptor->NodeDescriptorsCount);
/* allocate topology node types array */
if (!This->Topology.TopologyNodes)
+ {
+ DPRINT("IKsFilter_CreateDescriptors OutOfMemory TopologyNodesCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
return STATUS_INSUFFICIENT_RESOURCES;
+ }
- This->Topology.TopologyNodesNames = AllocateItem(NonPagedPool, sizeof(GUID) * This->Topology.TopologyNodesCount);
+ This->Topology.TopologyNodesNames = AllocateItem(NonPagedPool, sizeof(GUID) * FilterDescriptor->NodeDescriptorsCount);
/* allocate topology names array */
if (!This->Topology.TopologyNodesNames)
{
FreeItem((PVOID)This->Topology.TopologyNodes);
+ DPRINT("IKsFilter_CreateDescriptors OutOfMemory TopologyNodesCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
return STATUS_INSUFFICIENT_RESOURCES;
}
- for(Index = 0; Index < This->Topology.TopologyNodesCount; Index++)
+ DPRINT("NodeDescriptorCount %lu\n", FilterDescriptor->NodeDescriptorsCount);
+ for(Index = 0; Index < FilterDescriptor->NodeDescriptorsCount; Index++)
{
+ DPRINT("Index %lu Type %p Name %p\n", Index, FilterDescriptor->NodeDescriptors[Index].Type, FilterDescriptor->NodeDescriptors[Index].Name);
+
/* copy topology type */
- RtlMoveMemory((PVOID)&This->Topology.TopologyNodes[Index], FilterDescriptor->NodeDescriptors[Index].Type, sizeof(GUID));
+ if (FilterDescriptor->NodeDescriptors[Index].Type)
+ RtlMoveMemory((PVOID)&This->Topology.TopologyNodes[Index], FilterDescriptor->NodeDescriptors[Index].Type, sizeof(GUID));
+
/* copy topology name */
- RtlMoveMemory((PVOID)&This->Topology.TopologyNodesNames[Index], FilterDescriptor->NodeDescriptors[Index].Name, sizeof(GUID));
+ if (FilterDescriptor->NodeDescriptors[Index].Name)
+ RtlMoveMemory((PVOID)&This->Topology.TopologyNodesNames[Index], FilterDescriptor->NodeDescriptors[Index].Name, sizeof(GUID));
}
}
-
/* done! */
return STATUS_SUCCESS;
}
IKsFilterImpl * This,
const KSFILTER_DESCRIPTOR* FilterDescriptor)
{
- This->Filter.Descriptor = (const KSFILTER_DESCRIPTOR*)AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
+ NTSTATUS Status;
+
+ This->Filter.Descriptor = AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
if (!This->Filter.Descriptor)
return STATUS_INSUFFICIENT_RESOURCES;
- /* copy all fields */
- RtlMoveMemory((PVOID)This->Filter.Descriptor, FilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
-
-
- /* perform deep copy of pin descriptors */
- if (FilterDescriptor->PinDescriptorsCount)
- {
- KSPIN_DESCRIPTOR_EX * PinDescriptors = (KSPIN_DESCRIPTOR_EX *)AllocateItem(NonPagedPool, FilterDescriptor->PinDescriptorSize * FilterDescriptor->PinDescriptorsCount);
-
-
- if (!PinDescriptors)
- {
- FreeItem((PVOID)This->Filter.Descriptor);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
- RtlMoveMemory((PVOID)PinDescriptors, FilterDescriptor->PinDescriptors, FilterDescriptor->PinDescriptorSize * FilterDescriptor->PinDescriptorsCount);
-
- /* brain-dead gcc hack */
- RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptors, PinDescriptors, sizeof(PKSPIN_DESCRIPTOR_EX));
-
- }
-
- /* perform deep copy of node descriptors */
- if (FilterDescriptor->NodeDescriptorsCount)
+ Status = KsAddItemToObjectBag(This->Filter.Bag, (PVOID)This->Filter.Descriptor, NULL);
+ if (!NT_SUCCESS(Status))
{
- KSNODE_DESCRIPTOR* NodeDescriptor = AllocateItem(NonPagedPool, FilterDescriptor->NodeDescriptorsCount * FilterDescriptor->NodeDescriptorSize);
- if (!NodeDescriptor)
- {
- if (This->Filter.Descriptor->PinDescriptors)
- FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
- FreeItem((PVOID)This->Filter.Descriptor);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
- RtlMoveMemory((PVOID)NodeDescriptor, FilterDescriptor->NodeDescriptors, FilterDescriptor->NodeDescriptorsCount * FilterDescriptor->NodeDescriptorSize);
-
- /* brain-dead gcc hack */
- RtlMoveMemory((PVOID)&This->Filter.Descriptor->NodeDescriptors, NodeDescriptor, sizeof(PKSNODE_DESCRIPTOR));
+ FreeItem((PVOID)This->Filter.Descriptor);
+ This->Filter.Descriptor = NULL;
+ return STATUS_INSUFFICIENT_RESOURCES;
}
- /* perform deep copy of connections descriptors */
- if (FilterDescriptor->NodeDescriptorsCount)
- {
- KSTOPOLOGY_CONNECTION* Connections = AllocateItem(NonPagedPool, sizeof(KSTOPOLOGY_CONNECTION) * FilterDescriptor->ConnectionsCount);
- if (!Connections)
- {
- if (This->Filter.Descriptor->PinDescriptors)
- FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-
- if (This->Filter.Descriptor->NodeDescriptors)
- FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
-
- FreeItem((PVOID)This->Filter.Descriptor);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- RtlMoveMemory((PVOID)Connections, FilterDescriptor->Connections, sizeof(KSTOPOLOGY_CONNECTION) * FilterDescriptor->ConnectionsCount);
-
- /* brain-dead gcc hack */
- RtlMoveMemory((PVOID)&This->Filter.Descriptor->Connections, Connections, sizeof(PKSTOPOLOGY_CONNECTION));
- }
+ /* copy filter descriptor fields */
+ RtlMoveMemory((PVOID)This->Filter.Descriptor, FilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
- return STATUS_SUCCESS;
+ return Status;
}
PKSPIN_CONNECT Connect;
NTSTATUS Status;
+ DPRINT("IKsFilter_DispatchCreatePin\n");
+
/* get the create item */
CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
/* get the filter object */
This = (IKsFilterImpl*)CreateItem->Context;
+ /* sanity check */
+ ASSERT(This->Header.Type == KsObjectTypeFilter);
+
/* acquire control mutex */
KeWaitForSingleObject(&This->Header.ControlMutex, Executive, KernelMode, FALSE, NULL);
/* now validate the connect request */
Status = KsValidateConnectRequest(Irp, This->PinDescriptorCount, This->PinDescriptors, &Connect);
+ DPRINT("IKsFilter_DispatchCreatePin KsValidateConnectRequest %lx\n", Status);
+
if (NT_SUCCESS(Status))
{
- if (This->PinInstanceCount[Connect->PinId] < This->Filter.Descriptor->PinDescriptors[Connect->PinId].InstancesPossible)
+ /* sanity check */
+ ASSERT(Connect->PinId < This->PinDescriptorCount);
+
+ DPRINT("IKsFilter_DispatchCreatePin KsValidateConnectRequest PinId %lu CurrentInstanceCount %lu MaxPossible %lu\n", Connect->PinId,
+ This->PinInstanceCount[Connect->PinId],
+ This->PinDescriptorsEx[Connect->PinId].InstancesPossible);
+
+ if (This->PinInstanceCount[Connect->PinId] < This->PinDescriptorsEx[Connect->PinId].InstancesPossible)
{
/* create the pin */
- Status = KspCreatePin(DeviceObject, Irp, This->Header.KsDevice, This->FilterFactory, (IKsFilter*)&This->lpVtbl, Connect, (KSPIN_DESCRIPTOR_EX*)&This->Filter.Descriptor->PinDescriptors[Connect->PinId]);
+ Status = KspCreatePin(DeviceObject, Irp, This->Header.KsDevice, This->FilterFactory, (IKsFilter*)&This->lpVtbl, Connect, &This->PinDescriptorsEx[Connect->PinId]);
+
+ DPRINT("IKsFilter_DispatchCreatePin KspCreatePin %lx\n", Status);
if (NT_SUCCESS(Status))
{
{
/* maximum instance count reached, bye-bye */
Status = STATUS_UNSUCCESSFUL;
+ DPRINT("IKsFilter_DispatchCreatePin MaxInstance %lu CurInstance %lu %lx\n", This->PinDescriptorsEx[Connect->PinId].InstancesPossible, This->PinInstanceCount[Connect->PinId]);
}
}
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
+
/* done */
+ DPRINT("IKsFilter_DispatchCreatePin Result %lx\n", Status);
return Status;
}
}
/* allocate filter instance */
- This = AllocateItem(NonPagedPool, sizeof(IKsFilterFactory));
+ This = AllocateItem(NonPagedPool, sizeof(IKsFilterImpl));
if (!This)
+ {
+ DPRINT("KspCreateFilter OutOfMemory\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* initialize object bag */
+ This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
+ if (!This->Filter.Bag)
+ {
+ /* no memory */
+ FreeItem(This);
+ DPRINT("KspCreateFilter OutOfMemory\n");
return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
+ KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->Filter.Bag, NULL);
/* copy filter descriptor */
Status = IKsFilter_CopyFilterDescriptor(This, Factory->FilterDescriptor);
if (!NT_SUCCESS(Status))
{
/* not enough memory */
+ FreeItem(This->Filter.Bag);
FreeItem(This);
+ DPRINT("KspCreateFilter IKsFilter_CopyFilterDescriptor failed %lx\n", Status);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* get current irp stack */
IoStack = IoGetCurrentIrpStackLocation(Irp);
- /* initialize object bag */
- This->Filter.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
- if (!This->Filter.Bag)
- {
- /* no memory */
- FreeItem(This);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
/* allocate create items */
CreateItem = AllocateItem(NonPagedPool, sizeof(KSOBJECT_CREATE_ITEM) * 2);
if (!CreateItem)
{
/* no memory */
+ FreeItem(This->Filter.Bag);
FreeItem(This);
+ DPRINT("KspCreateFilter OutOfMemory\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
RtlInitUnicodeString(&CreateItem[1].ObjectClass, KSSTRING_TopologyNode);
- KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice;
- KsDevice->lpVtbl->InitializeObjectBag(KsDevice, (PKSIOBJECT_BAG)This->Filter.Bag, NULL);
-
/* initialize filter instance */
This->ref = 1;
This->lpVtbl = &vt_IKsFilter;
/* what can go wrong, goes wrong */
FreeItem(This);
FreeItem(CreateItem);
+ DPRINT("IKsFilter_CreateDescriptors failed with %lx\n", Status);
return Status;
}
if (Factory->FilterDescriptor->Dispatch->Create)
{
/* now let driver initialize the filter instance */
+ DPRINT("Before instantiating filter Filter %p This %p KSBASIC_HEADER %u\n", &This->Filter, This, sizeof(KSBASIC_HEADER));
+ ASSERT(This->Header.KsDevice);
Status = Factory->FilterDescriptor->Dispatch->Create(&This->Filter, Irp);
if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
IKsFilter_AttachFilterToFilterFactory(This, This->Header.Parent.KsFilterFactory);
/* completed initialization */
+ DPRINT("KspCreateFilter done %lx\n", Status);
return Status;
}
OUT PULONG PinID)
{
ULONG Count;
- ULONG *PinInstanceCount;
- KSPIN_DESCRIPTOR_EX * PinDescriptorsEx;
- KSPIN_DESCRIPTOR * PinDescriptors;
- PKSPIN *FirstPin;
+ NTSTATUS Status;
IKsFilterImpl * This = (IKsFilterImpl*)CONTAINING_RECORD(Filter, IKsFilterImpl, Filter);
- /* calculate existing count */
+ DPRINT("KsFilterCreatePinFactory\n");
+
+ /* calculate new count */
Count = This->PinDescriptorCount + 1;
- /* allocate pin descriptors array */
- PinDescriptorsEx = AllocateItem(NonPagedPool, max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * Count);
- if (!PinDescriptorsEx)
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* sanity check */
+ ASSERT(This->Filter.Descriptor->PinDescriptorSize == sizeof(KSPIN_DESCRIPTOR_EX));
- /* allocate pin instance count array */
- PinInstanceCount = AllocateItem(NonPagedPool, sizeof(ULONG) * Count);
- if (!PinInstanceCount)
+ /* allocate pin descriptors ex array */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptorsEx, Count * sizeof(KSPIN_DESCRIPTOR_EX), This->PinDescriptorCount * sizeof(KSPIN_DESCRIPTOR_EX), 0);
+ if (!NT_SUCCESS(Status))
{
- /* not enough memory */
- FreeItem(PinDescriptorsEx);
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* failed */
+ DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+ return Status;
}
- /* allocate pin descriptor array for pin property handling */
- PinDescriptors = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR) * Count);
- if (!PinDescriptors)
+ /* allocate pin descriptors array */
+ Status = _KsEdit(This->Filter.Bag, (PVOID*)&This->PinDescriptors, Count * sizeof(KSPIN_DESCRIPTOR), This->PinDescriptorCount * sizeof(KSPIN_DESCRIPTOR), 0);
+ if (!NT_SUCCESS(Status))
{
- /* not enough memory */
- FreeItem(PinDescriptorsEx);
- FreeItem(PinInstanceCount);
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* failed */
+ DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+ return Status;
}
- /* allocate first pin array */
- FirstPin = AllocateItem(NonPagedPool, sizeof(PKSPIN) * Count);
- if (!FirstPin)
+
+ /* allocate pin instance count array */
+ Status = _KsEdit(This->Filter.Bag,(PVOID*)&This->PinInstanceCount, sizeof(ULONG) * Count, sizeof(ULONG) * This->PinDescriptorCount, 0);
+ if (!NT_SUCCESS(Status))
{
- /* not enough memory */
- FreeItem(PinDescriptorsEx);
- FreeItem(PinInstanceCount);
- FreeItem(PinDescriptors);
- return STATUS_INSUFFICIENT_RESOURCES;
+ /* failed */
+ DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+ return Status;
}
- /* now copy all fields */
- if (Count > 1)
+ /* allocate first pin array */
+ Status = _KsEdit(This->Filter.Bag,(PVOID*)&This->FirstPin, sizeof(PKSPIN) * Count, sizeof(PKSPIN) * This->PinDescriptorCount, 0);
+ if (!NT_SUCCESS(Status))
{
- /* copy old descriptors */
- RtlMoveMemory(PinDescriptorsEx, This->Filter.Descriptor->PinDescriptors, max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * This->PinDescriptorCount);
- RtlMoveMemory(PinInstanceCount, This->PinInstanceCount, This->PinDescriptorCount * sizeof(ULONG));
- RtlMoveMemory(PinDescriptors, This->PinDescriptors, sizeof(KSPIN_DESCRIPTOR) * This->PinDescriptorCount);
- RtlMoveMemory(FirstPin, This->FirstPin, sizeof(PKSPIN) * This->PinDescriptorCount);
-
- /* now free old descriptors */
- FreeItem(This->PinInstanceCount);
- FreeItem((PVOID)This->Filter.Descriptor->PinDescriptors);
- FreeItem(This->PinDescriptors);
- FreeItem(This->FirstPin);
+ /* failed */
+ DPRINT("KsFilterCreatePinFactory _KsEdit failed with %lx\n", Status);
+ return Status;
}
/* add new pin factory */
- RtlMoveMemory((PVOID)((ULONG_PTR)PinDescriptorsEx + max(This->Filter.Descriptor->PinDescriptorSize, sizeof(KSPIN_DESCRIPTOR_EX)) * This->PinDescriptorCount), InPinDescriptor, sizeof(KSPIN_DESCRIPTOR));
- RtlMoveMemory((PVOID)(PinDescriptors + This->PinDescriptorCount), &InPinDescriptor->PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
-
- /* replace old descriptor by using a gcc-compliant hack */
- RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptors, PinDescriptorsEx, sizeof(KSPIN_DESCRIPTOR_EX*));
- RtlMoveMemory((PVOID)&This->Filter.Descriptor->PinDescriptorsCount, &Count, sizeof(ULONG));
-
- This->PinDescriptors = PinDescriptors;
- This->PinInstanceCount = PinInstanceCount;
- This->FirstPin = FirstPin;
+ RtlMoveMemory(&This->PinDescriptorsEx[This->PinDescriptorCount], InPinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
+ RtlMoveMemory(&This->PinDescriptors[This->PinDescriptorCount], &InPinDescriptor->PinDescriptor, sizeof(KSPIN_DESCRIPTOR));
/* store new pin id */
*PinID = This->PinDescriptorCount;
/* increment pin descriptor count */
This->PinDescriptorCount++;
+
+ DPRINT("KsFilterCreatePinFactory done\n");
return STATUS_SUCCESS;
}
IN PIRP Irp)
{
PKSOBJECT_CREATE_ITEM CreateItem;
+ IKsFilterFactoryImpl * Factory;
IKsFilterFactory * iface;
NTSTATUS Status;
}
/* get filter factory interface */
- iface = (IKsFilterFactory*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
+ Factory = (IKsFilterFactoryImpl*)CONTAINING_RECORD(CreateItem->Context, IKsFilterFactoryImpl, FilterFactory);
+
+ /* get interface */
+ iface = (IKsFilterFactory*)&Factory->lpVtbl;
/* create a filter instance */
Status = KspCreateFilter(DeviceObject, Irp, iface);
FreeString = TRUE;
}
+ DPRINT("IKsFilterFactory_fnInitialize CategoriesCount %u ReferenceString '%S'\n", Descriptor->CategoriesCount,ReferenceString.Buffer);
+
/* now register the device interface */
Status = KspRegisterDeviceInterfaces(DeviceExtension->DeviceHeader->KsDevice.PhysicalDeviceObject,
Descriptor->CategoriesCount,
IKsFilterFactory * Filter;
NTSTATUS Status;
+ DPRINT("KsCreateFilterFactory\n");
+
/* Lets allocate a filterfactory */
This = AllocateItem(NonPagedPool, sizeof(IKsFilterFactoryImpl));
if (!This)
}
/* return result */
+ DPRINT("KsCreateFilterFactory %x\n", Status);
+ /* sanity check */
+ ASSERT(Status == STATUS_SUCCESS);
+
return Status;
}
IN PKSFILTERFACTORY FilterFactory,
IN BOOLEAN NewState)
{
- IKsFilterFactory * Factory = (IKsFilterFactory*)CONTAINING_RECORD(FilterFactory, IKsFilterFactoryImpl, FilterFactory);
+ IKsFilterFactory * Factory;
+ IKsFilterFactoryImpl * This = (IKsFilterFactoryImpl*)CONTAINING_RECORD(FilterFactory, IKsFilterFactoryImpl, FilterFactory);
+ Factory = (IKsFilterFactory*)&This->lpVtbl;
return Factory->lpVtbl->SetDeviceClassesState(Factory, NewState);
}
IN const KSFILTER_DESCRIPTOR* FilterDescriptor OPTIONAL)
{
UNIMPLEMENTED
+ DPRINT("KsFilterFactoryUpdateCacheData %p\n", FilterDescriptor);
- return STATUS_NOT_IMPLEMENTED;
+ return STATUS_SUCCESS;
}
#include "priv.h"
-const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}};
+const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}};
/* http://msdn2.microsoft.com/en-us/library/ms809781.aspx */
COMDDKAPI NTSTATUS NTAPI
IN const KSPROPERTY_SET* PropertySet,
IN PFNKSALLOCATOR Allocator OPTIONAL,
IN ULONG PropertyItemSize OPTIONAL);
+
+NTSTATUS
+NTAPI
+IKsFilterFactory_Create(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp);
+
+NTSTATUS
+KspSetFilterFactoriesState(
+ IN PKSIDEVICE_HEADER DeviceHeader,
+ IN BOOLEAN NewState);
+
LIST_ENTRY TargetDeviceList;
KMUTEX DeviceMutex;
- KSDEVICE_DESCRIPTOR* Descriptor;
+ KMUTEX BagMutex;
LIST_ENTRY PowerDispatchList;
LIST_ENTRY ObjectBags;
IoSetCompletionRoutine(Irp, KspForwardIrpSynchronousCompletion, (PVOID)&Event, TRUE, TRUE, TRUE);
/* now call the driver */
- Status = IoCallDriver(DeviceHeader->BaseDevice, Irp);
+ Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
/* did the request complete yet */
if (Status == STATUS_PENDING)
{
IN PKSPIN Pin,
IN BOOLEAN Asynchronous)
{
+ DPRINT("KsPinAttemptProcessing\n");
UNIMPLEMENTED
}
OUT PIKSREFERENCECLOCK* Interface)
{
UNIMPLEMENTED
+ DPRINT("KsPinGetReferenceClockInterface Pin %p Interface %p\n", Pin, Interface);
return STATUS_UNSUCCESSFUL;
}
PKSIOBJECT_HEADER ObjectHeader;
PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
+ DPRINT("KsGetPinFromIrp\n");
+
/* get object header */
ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->FsContext2;
/* return object type */
IN KSSTREAM_POINTER_STATE State)
{
UNIMPLEMENTED
+ DPRINT("KsPinGetLeadingEdgeStreamPointer Pin %p State %x\n", Pin, State);
return NULL;
}
IN BOOLEAN Eject)
{
UNIMPLEMENTED
+ DPRINT("KsStreamPointerUnlock\n");
}
/*
IN ULONG OutUsed,
IN BOOLEAN Eject)
{
+ DPRINT("KsStreamPointerAdvanceOffsets\n");
+
UNIMPLEMENTED
}
PKSISTREAM_POINTER Cur, Last;
PKSISTREAM_POINTER Pointer = (PKSISTREAM_POINTER)StreamPointer;
+ DPRINT("KsStreamPointerDelete\n");
+
This = (IKsPinImpl*)CONTAINING_RECORD(Pointer->StreamPointer.Pin, IKsPinImpl, Pin);
/* point to first stream pointer */
OUT PKSSTREAM_POINTER* CloneStreamPointer)
{
UNIMPLEMENTED
+ DPRINT("KsStreamPointerClone\n");
return STATUS_NOT_IMPLEMENTED;
}
KsPinGetFirstCloneStreamPointer(
IN PKSPIN Pin)
{
- IKsPinImpl * This = (IKsPinImpl*)CONTAINING_RECORD(Pin, IKsPinImpl, Pin);
+ IKsPinImpl * This;
+
+ DPRINT("KsPinGetFirstCloneStreamPointer %p\n", Pin);
+
+ This = (IKsPinImpl*)CONTAINING_RECORD(Pin, IKsPinImpl, Pin);
/* return first cloned stream pointer */
return &This->ClonedStreamPointer->StreamPointer;
}
{
PKSISTREAM_POINTER Pointer = (PKSISTREAM_POINTER)StreamPointer;
+ DPRINT("KsStreamPointerGetNextClone\n");
+
/* is there a another cloned stream pointer */
if (!Pointer->Next)
return NULL;
return &Pointer->Next->StreamPointer;
}
+NTSTATUS
+IKsPin_DispatchKsProperty(
+ PDEVICE_OBJECT DeviceObject,
+ PIRP Irp,
+ IKsPinImpl * This)
+{
+ NTSTATUS Status;
+ PKSPROPERTY Property;
+ PIO_STACK_LOCATION IoStack;
+ UNICODE_STRING GuidString;
+ ULONG PropertySetsCount = 0, PropertyItemSize = 0;
+ const KSPROPERTY_SET* PropertySets = NULL;
+
+ /* sanity check */
+ ASSERT(This->Pin.Descriptor);
+
+ /* get current irp stack */
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+
+ if (This->Pin.Descriptor->AutomationTable)
+ {
+ /* use available driver property sets */
+ PropertySetsCount = This->Pin.Descriptor->AutomationTable->PropertySetsCount;
+ PropertySets = This->Pin.Descriptor->AutomationTable->PropertySets;
+ PropertyItemSize = This->Pin.Descriptor->AutomationTable->PropertyItemSize;
+ }
+
+
+ /* try driver provided property sets */
+ Status = KspPropertyHandler(Irp,
+ PropertySetsCount,
+ PropertySets,
+ NULL,
+ PropertyItemSize);
+
+ DPRINT("IKsPin_DispatchKsProperty PropertySetCount %lu Status %lu\n", PropertySetsCount, Status);
+
+ if (Status != STATUS_NOT_FOUND)
+ {
+ /* property was handled by driver */
+ if (Status != STATUS_PENDING)
+ {
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ }
+ return Status;
+ }
+
+ /* property was not handled */
+ Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+
+ RtlStringFromGUID(&Property->Set, &GuidString);
+ DPRINT("IKsPin_DispatchKsProperty Unhandled property Set |%S| Id %u Flags %x\n", GuidString.Buffer, Property->Id, Property->Flags);
+ RtlFreeUnicodeString(&GuidString);
+
+ Irp->IoStatus.Status = STATUS_NOT_FOUND;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return STATUS_NOT_FOUND;
+
+}
+
NTSTATUS
NTAPI
IKsPin_DispatchDeviceIoControl(
/* get the object header */
ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->FsContext2;
- /* locate ks pin implemention fro KSPIN offset */
+ /* locate ks pin implemention from KSPIN offset */
This = (IKsPinImpl*)CONTAINING_RECORD(ObjectHeader->ObjectType, IKsPinImpl, Pin);
- if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_WRITE_STREAM && IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_READ_STREAM)
+ if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KS_PROPERTY)
+ {
+ /* handle ks properties */
+ return IKsPin_DispatchKsProperty(DeviceObject, Irp, This);
+ }
+
+
+ if (IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_WRITE_STREAM && IoStack->Parameters.DeviceIoControl.IoControlCode != IOCTL_KS_READ_STREAM)
{
UNIMPLEMENTED;
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
PDEVICE_EXTENSION DeviceExtension;
PKSOBJECT_CREATE_ITEM CreateItem;
NTSTATUS Status;
+ PKSDATAFORMAT DataFormat;
/* sanity checks */
ASSERT(Descriptor->Dispatch);
- ASSERT(Descriptor->Dispatch->Create);
+
+ DPRINT("KspCreatePin\n");
/* get current irp stack */
IoStack = IoGetCurrentIrpStackLocation(Irp);
{
/* not enough memory */
FreeItem(This);
+ DPRINT("KspCreatePin OutOfMemory\n");
return STATUS_INSUFFICIENT_RESOURCES;
}
InitializeListHead(&This->IrpList);
KeInitializeSpinLock(&This->IrpListLock);
- /* initialize ks pin descriptor */
- This->Pin.Descriptor = Descriptor;
- This->Pin.Id = Connect->PinId;
/* allocate object bag */
This->Pin.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG));
/* initialize object bag */
Device->lpVtbl->InitializeObjectBag(Device, This->Pin.Bag, &This->BasicHeader.ControlMutex); /* is using control mutex right? */
+ /* get format */
+ DataFormat = (PKSDATAFORMAT)(Connect + 1);
+
+ /* initialize ks pin descriptor */
+ This->Pin.Descriptor = Descriptor;
+ This->Pin.Context = NULL;
+ This->Pin.Id = Connect->PinId;
This->Pin.Communication = Descriptor->PinDescriptor.Communication;
- This->Pin.ConnectionIsExternal = FALSE; /* FIXME */
- //FIXME This->Pin.ConnectionInterface = Descriptor->PinDescriptor.Interfaces;
- //FIXME This->Pin.ConnectionMedium = Descriptor->PinDescriptor.Mediums;
- //FIXME This->Pin.ConnectionPriority = KSPRIORITY_NORMAL;
- This->Pin.ConnectionFormat = (PKSDATAFORMAT) (Connect + 1);
+ This->Pin.ConnectionIsExternal = FALSE; //FIXME
+ RtlMoveMemory(&This->Pin.ConnectionInterface, &Connect->Interface, sizeof(KSPIN_INTERFACE));
+ RtlMoveMemory(&This->Pin.ConnectionMedium, &Connect->Medium, sizeof(KSPIN_MEDIUM));
+ RtlMoveMemory(&This->Pin.ConnectionPriority, &Connect->Priority, sizeof(KSPRIORITY));
+
+ /* allocate format */
+ Status = _KsEdit(This->Pin.Bag, (PVOID*)&This->Pin.ConnectionFormat, DataFormat->FormatSize, DataFormat->FormatSize, 0);
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed to allocate format */
+ KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
+ FreeItem(This);
+ FreeItem(CreateItem);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* copy format */
+ RtlMoveMemory((PVOID)This->Pin.ConnectionFormat, DataFormat, DataFormat->FormatSize);
+
This->Pin.AttributeList = NULL; //FIXME
This->Pin.StreamHeaderSize = sizeof(KSSTREAM_HEADER);
This->Pin.DataFlow = Descriptor->PinDescriptor.DataFlow;
if (!NT_SUCCESS(Status))
{
/* failed to create object header */
+ DPRINT("KspCreatePin KsAllocateObjectHeader failed %lx\n", Status);
KsFreeObjectBag((KSOBJECT_BAG)This->Pin.Bag);
FreeItem(This);
FreeItem(CreateItem);
*/
Status = Filter->lpVtbl->AddProcessPin(Filter, &This->ProcessPin);
+ DPRINT("KspCreatePin AddProcessPin %lx\n", Status);
+
if (!NT_SUCCESS(Status))
{
/* failed to add process pin */
{
/* now inform the driver to create a new pin */
Status = Descriptor->Dispatch->Create(&This->Pin, Irp);
+ DPRINT("KspCreatePin DispatchCreate %lx\n", Status);
}
+ DPRINT("KspCreatePin Status %lx\n", Status);
+
if (!NT_SUCCESS(Status) && Status != STATUS_PENDING)
{
/* failed to create pin, release resources */
KSAUTOMATION_TABLE FilterAutomationTable =
{
1,
- sizeof(KSPROPERTY_SET),
+ sizeof(KSPROPERTY_ITEM),
&FilterPropertySet,
1,
- sizeof(KSMETHOD_SET),
+ sizeof(KSMETHOD_ITEM),
&FilterMethodSet,
0,
- sizeof(KSEVENT_SET),
+ sizeof(KSEVENT_ITEM),
NULL
};
KSAUTOMATION_TABLE PinAutomationTable =
{
1,
- sizeof(KSPROPERTY_SET),
+ sizeof(KSPROPERTY_ITEM),
&PinPropertySet,
0,
- sizeof(KSMETHOD_SET),
+ sizeof(KSMETHOD_ITEM),
NULL,
0,
- sizeof(KSEVENT_SET),
+ sizeof(KSEVENT_ITEM),
NULL
};
DllInitialize(
PUNICODE_STRING RegistryPath)
{
+ DPRINT("BDASUP::DllInitialize\n");
+
KeInitializeSpinLock(&g_Settings.FilterFactoryInstanceListLock);
InitializeListHead(&g_Settings.FilterFactoryInstanceList);
g_Settings.Initialized = TRUE;
NTAPI
BdaCheckChanges(IN PIRP Irp)
{
+ DPRINT("BdaCheckChanges\n");
+
if (!Irp)
return STATUS_INVALID_PARAMETER;
NTAPI
BdaCommitChanges(IN PIRP Irp)
{
+ DPRINT("BdaCommitChanges\n");
+
if (!Irp)
return STATUS_INVALID_PARAMETER;
PBDA_FILTER_INSTANCE_ENTRY FilterInstance;
KIRQL OldLevel;
NTSTATUS Status;
- KSFILTER_DESCRIPTOR FilterDescriptor;
+ PKSFILTER_DESCRIPTOR FilterDescriptor;
+
+ DPRINT("BdaCreateFilterFactoryEx\n");
+
+ FilterDescriptor = AllocateItem(NonPagedPool, sizeof(KSFILTER_DESCRIPTOR));
+ if (!FilterDescriptor)
+ {
+ /* no memory */
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
- /* backup filter descriptor */
- RtlMoveMemory(&FilterDescriptor, pFilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
+ /* copy filter descriptor template */
+ RtlMoveMemory(FilterDescriptor, pFilterDescriptor, sizeof(KSFILTER_DESCRIPTOR));
+
+ /* erase pin / nodes / connections from filter descriptor */
+ FilterDescriptor->PinDescriptorsCount = 0;
+ FilterDescriptor->PinDescriptors = NULL;
+ FilterDescriptor->NodeDescriptorsCount = 0;
+ FilterDescriptor->NodeDescriptors = NULL;
+ FilterDescriptor->ConnectionsCount = 0;
+ FilterDescriptor->Connections = NULL;
/* merge the automation tables */
- Status = KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&FilterDescriptor.AutomationTable, (PKSAUTOMATION_TABLE)pFilterDescriptor->AutomationTable, &FilterAutomationTable, NULL);
+ Status = KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&FilterDescriptor->AutomationTable, (PKSAUTOMATION_TABLE)pFilterDescriptor->AutomationTable, &FilterAutomationTable, NULL);
/* check for success */
if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("KsMergeAutomationTables failed with %lx\n", Status);
+ FreeItem(FilterDescriptor);
return Status;
+ }
/* allocate filter instance */
FilterInstance = AllocateItem(NonPagedPool, sizeof(BDA_FILTER_INSTANCE_ENTRY));
if (!FilterInstance)
{
/* not enough memory */
+ FreeItem(FilterDescriptor);
return STATUS_INSUFFICIENT_RESOURCES;
}
/* create the filter factory */
- Status = KsCreateFilterFactory(pKSDevice->FunctionalDeviceObject, &FilterDescriptor, NULL, NULL, 0, NULL, NULL, &FilterFactory);
+ Status = KsCreateFilterFactory(pKSDevice->FunctionalDeviceObject, FilterDescriptor, NULL, NULL, 0, NULL, NULL, &FilterFactory);
/* check for success */
if (NT_SUCCESS(Status))
{
-
- /* add the item to filter object bag */
- Status = KsAddItemToObjectBag(FilterFactory->Bag, FilterInstance, FreeFilterInstance);
- if (!NT_SUCCESS(Status))
+ if (FilterDescriptor->AutomationTable != &FilterAutomationTable)
{
- /* destroy filter instance */
- FreeItem(FilterInstance);
- KsDeleteFilterFactory(FilterFactory);
- return Status;
+ /* add the item to filter object bag */
+ KsAddItemToObjectBag(FilterFactory->Bag, (PVOID)FilterDescriptor->AutomationTable, FreeFilterInstance);
+ }
+ else
+ {
+ /* make sure the automation table is not-read only */
+ Status = _KsEdit(FilterFactory->Bag, (PVOID*)&FilterDescriptor->AutomationTable, sizeof(KSAUTOMATION_TABLE), sizeof(KSAUTOMATION_TABLE), 0);
+
+ /* sanity check */
+ ASSERT(Status == STATUS_SUCCESS);
+
+ /* add to object bag */
+ KsAddItemToObjectBag(FilterFactory->Bag, (PVOID)FilterDescriptor->AutomationTable, FreeFilterInstance);
}
/* initialize filter instance entry */
{
/* failed to create filter factory */
FreeItem(FilterInstance);
+ FreeItem(FilterDescriptor);
}
/* done */
+ DPRINT("BdaCreateFilterFactoryEx Status %x\n", Status);
return Status;
}
PBDA_FILTER_INSTANCE_ENTRY InstanceEntry;
NTSTATUS Status;
ULONG PinId;
- KSPIN_DESCRIPTOR_EX NewPinDescriptor;
+ PKSPIN_DESCRIPTOR_EX NewPinDescriptor;
+
+ DPRINT("BdaCreatePin\n");
if (!pulPinId || !pKSFilter)
return STATUS_INVALID_PARAMETER;
if (!InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount)
{
/* no pins supported */
+ DPRINT("BdaCreatePin NoPins supported\n");
return STATUS_UNSUCCESSFUL;
}
if (InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount <= ulPinType)
{
/* pin request is out of bounds */
+ DPRINT("BdaCreatePin ulPinType %lu >= PinDescriptorCount %lu\n", ulPinType, InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptorsCount);
return STATUS_INVALID_PARAMETER;
}
/* get pin descriptor */
PinDescriptor = (PKSPIN_DESCRIPTOR_EX)&InstanceEntry->FilterTemplate->pFilterDescriptor->PinDescriptors[ulPinType];
+ /* allocate pin descriptor */
+ NewPinDescriptor = AllocateItem(NonPagedPool, sizeof(KSPIN_DESCRIPTOR_EX));
+ if (!NewPinDescriptor)
+ {
+ /* no memory */
+ DPRINT("BdaCreatePin OutOfMemory\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
/* make a copy of the pin descriptor */
- RtlMoveMemory(&NewPinDescriptor, PinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
+ RtlMoveMemory(NewPinDescriptor, PinDescriptor, sizeof(KSPIN_DESCRIPTOR_EX));
/* merge the automation tables */
- Status = KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&NewPinDescriptor.AutomationTable, (PKSAUTOMATION_TABLE)PinDescriptor->AutomationTable, &PinAutomationTable, pKSFilter->Bag);
+ Status = KsMergeAutomationTables((PKSAUTOMATION_TABLE*)&NewPinDescriptor->AutomationTable, (PKSAUTOMATION_TABLE)PinDescriptor->AutomationTable, &PinAutomationTable, pKSFilter->Bag);
/* check for success */
if (NT_SUCCESS(Status))
{
/* create the pin factory */
- Status = KsFilterCreatePinFactory(pKSFilter, &NewPinDescriptor, &PinId);
+ Status = KsFilterCreatePinFactory(pKSFilter, NewPinDescriptor, &PinId);
/* check for success */
if (NT_SUCCESS(Status))
}
- DPRINT("BdaCreatePin Result %x\n", Status);
+ DPRINT("BdaCreatePin Result %x PinId %u\n", Status, PinId);
return Status;
}
PKSM_PIN Pin;
PKSFILTER Filter;
+ DPRINT("BdaMethodCreatePin\n");
+
if (!Irp)
{
/* invalid parameter */
ULONG Index, PinId;
NTSTATUS Status = STATUS_SUCCESS;
+ DPRINT("BdaInitFilter %p\n", pBdaFilterTemplate);
+
/* check input parameters */
if (!pKSFilter)
return STATUS_INVALID_PARAMETER;
/* sanity check */
ASSERT(InstanceEntry);
- ASSERT(InstanceEntry->FilterTemplate == pBdaFilterTemplate);
+
+ if (!pBdaFilterTemplate)
+ {
+ /* use template from BdaCreateFilterFactoryEx */
+ pBdaFilterTemplate = InstanceEntry->FilterTemplate;
+ }
/* now create the pins */
for(Index = 0; Index < pBdaFilterTemplate->pFilterDescriptor->PinDescriptorsCount; Index++)
PKSFILTERFACTORY FilterFactory;
KSTOPOLOGY_CONNECTION Connection;
+ DPRINT("BdaCreateTopology\n");
+
/* check input parameters */
if (!pKSFilter)
return STATUS_INVALID_PARAMETER;
IN ULONG *pulPinId)
{
UNIMPLEMENTED
+ DPRINT("BdaDeletePin\n");
return STATUS_NOT_IMPLEMENTED;
}
IN PKSFILTERFACTORY FilterFactory,
IN const KSFILTER_DESCRIPTOR *FilterDescriptor OPTIONAL)
{
+ DPRINT("BdaFilterFactoryUpdateCacheData\n");
return KsFilterFactoryUpdateCacheData(FilterFactory, FilterDescriptor);
}
IN PIRP Irp,
OUT BDA_CHANGE_STATE *ChangeState)
{
+ DPRINT("BdaGetChangeState\n");
+
if (Irp && ChangeState)
{
*ChangeState = BDA_CHANGES_COMPLETE;
PKSFILTER Filter;
PKSP_BDA_NODE_PIN Node;
+ DPRINT("BdaMethodCreateTopology\n");
+
/* check input parameters */
if (!Irp || !pKSMethod)
return STATUS_INVALID_PARAMETER;
IN KSMETHOD *pKSMethod,
OPTIONAL PVOID pvIgnored)
{
+ DPRINT("BdaMethodDeletePin\n");
+
if (!Irp)
return STATUS_INVALID_PARAMETER;
OUT ULONG *pulControllingPinId)
{
UNIMPLEMENTED
+ DPRINT("BdaPropertyGetControllingPinId\n");
return STATUS_NOT_IMPLEMENTED;
}
PKSFILTERFACTORY FilterFactory;
PBDA_FILTER_INSTANCE_ENTRY InstanceEntry;
+ DPRINT("BdaPropertyGetPinControl\n");
+
/* first get the pin */
Pin = KsGetPinFromIrp(Irp);
ASSERT(Pin);
OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty)
{
UNIMPLEMENTED
+ DPRINT("BdaPropertyNodeDescriptors\n");
return STATUS_NOT_IMPLEMENTED;
}
OUT GUID *pguidProperty)
{
UNIMPLEMENTED
+ DPRINT("BdaPropertyNodeEvents\n");
return STATUS_NOT_IMPLEMENTED;
}
OUT GUID *pguidProperty)
{
UNIMPLEMENTED
+ DPRINT("BdaPropertyNodeMethods\n");
return STATUS_NOT_IMPLEMENTED;
}
OUT GUID *pguidProperty)
{
UNIMPLEMENTED
+ DPRINT("BdaPropertyNodeProperties\n");
return STATUS_NOT_IMPLEMENTED;
}
PIO_STACK_LOCATION IoStack;
ULONG Index;
+ DPRINT("BdaPropertyNodeTypes\n");
+
/* check input parameter */
if (!Irp || !pKSProperty)
return STATUS_INVALID_PARAMETER;
PIO_STACK_LOCATION IoStack;
ULONG Index;
+ DPRINT("BdaPropertyPinTypes\n");
+
/* check input parameter */
if (!Irp || !pKSProperty)
return STATUS_INVALID_PARAMETER;
PIO_STACK_LOCATION IoStack;
ULONG Index;
+ DPRINT("BdaPropertyTemplateConnections\n");
+
/* validate parameters */
if (!Irp || !pKSProperty)
return STATUS_INVALID_PARAMETER;
NTAPI
BdaStartChanges(IN PIRP Irp)
{
+ DPRINT("BdaStartChanges\n");
+
if (Irp)
return STATUS_SUCCESS;
else
NTAPI
BdaUninitFilter(IN PKSFILTER pKSFilter)
{
+ DPRINT("BdaUninitFilter\n");
return STATUS_SUCCESS;
}
IN PIRP Irp,
IN KSPROPERTY *KSProperty)
{
+ DPRINT("BdaValidateNodeProperty\n");
+
/* check for valid parameter */
if (Irp && KSProperty)
return STATUS_SUCCESS;
#include <bdamedia.h>
#include <bdasup.h>
-#define NDEBUG
+#define YDEBUG
#include <debug.h>
#endif
if( FCB->Flags & AFD_ENDPOINT_CONNECTIONLESS )
- return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0 );
+ {
+ if( FCB->RemoteAddress ) ExFreePool( FCB->RemoteAddress );
+ FCB->RemoteAddress =
+ TaCopyTransportAddress( &ConnectReq->RemoteAddress );
+
+ if( !FCB->RemoteAddress )
+ Status = STATUS_NO_MEMORY;
+ else
+ Status = STATUS_SUCCESS;
+
+ return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
+ }
switch( FCB->State ) {
case SOCKET_STATE_CONNECTED:
PTDI_CONNECTION_INFORMATION TargetAddress;
/* Check that the socket is bound */
- if( FCB->State != SOCKET_STATE_BOUND )
+ if( FCB->State != SOCKET_STATE_BOUND || !FCB->RemoteAddress )
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp,
0 );
tmp = READ_REGISTER_ULONG((PULONG)((Base + EHCI_PORTSC) + (4 * i)));
- DPRINT("port tmp %x\n", tmp);
GetDeviceDescriptor(FdoDeviceExtension, 0, 0, FALSE);
PdoDeviceExtension->ChildDeviceCount++;
+ PdoDeviceExtension->Ports[i].PortStatus |= USB_PORT_STATUS_HIGH_SPEED | USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
WorkItemData = ExAllocatePool(NonPagedPool, sizeof(WORKITEM_DATA));
if (!WorkItemData) ASSERT(FALSE);
WorkItemData->IoWorkItem = IoAllocateWorkItem(PdoDeviceExtension->DeviceObject);
if (UsbDevice == NULL)
UsbDevice = DeviceExtension->UsbDevices[0];
+ /* Assume URB success */
+ Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
+ /* Set the DeviceHandle to the Internal Device */
+ Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
+
switch (Urb->UrbHeader.Function)
{
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
{
- /* Are we suppose to only return on this request when a device is connected
- or is it the RootHubInitNotification Callback */
DPRINT1("URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:\n");
DPRINT1("--->TransferBufferLength %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
DPRINT1("--->TransferBuffer %x\n",Urb->UrbBulkOrInterruptTransfer.TransferBuffer);
DPRINT1("--->PipeHandle %x\n",Urb->UrbBulkOrInterruptTransfer.PipeHandle);
+ DPRINT1("---->(PVOID)&UsbDevice->EndPointDescriptor %x\n", (PVOID)&UsbDevice->EndPointDescriptor);
DPRINT1("--->TransferFlags %x\n", Urb->UrbBulkOrInterruptTransfer.TransferFlags);
- /* FIXME */
+
RtlZeroMemory(Urb->UrbBulkOrInterruptTransfer.TransferBuffer, Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
- ((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1;
- /* Turn off Irp handling as nothing is handled beyond this */
- DeviceExtension->HaltUrbHandling = TRUE;
+ if (UsbDevice == DeviceExtension->UsbDevices[0])
+ {
+ if (Urb->UrbBulkOrInterruptTransfer.TransferFlags & (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK))
+ {
+ LONG i;
+ for (i = 0; i < 8; i++)
+ {
+ if (DeviceExtension->Ports[i].PortChange)
+ {
+ DPRINT1("Inform hub driver that port %d has changed\n", i+1);
+ ((PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer)[0] = 1 << (i + 1);
+ }
+ }
+ }
+ else
+ {
+ Urb->UrbHeader.Status = USBD_STATUS_INVALID_PARAMETER;
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ }
break;
}
case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
{
- DPRINT1("Get Status from Device\n");
+ DPRINT("Get Status from Device\n");
+ DPRINT("Index : %d\n", Urb->UrbControlGetStatusRequest.Index);
+
+ /* Copied from pvdrivers */
+ if (Urb->UrbControlGetStatusRequest.Index == 0)
+ {
+ *(PUSHORT)Urb->UrbControlGetStatusRequest.TransferBuffer = USB_PORT_STATUS_CONNECT | USB_PORT_STATUS_ENABLE;
+ }
+ else
+ {
+ DPRINT1("Uknown identifier\n");
+ Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
+ Status = STATUS_UNSUCCESSFUL;
+ }
break;
}
case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
{
- Urb->UrbHeader.Function = 0x08;
- Urb->UrbHeader.UsbdFlags = 0;
- Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
-
switch(Urb->UrbControlDescriptorRequest.DescriptorType)
{
case USB_DEVICE_DESCRIPTOR_TYPE:
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
&UsbDevice->DeviceDescriptor,
Urb->UrbControlDescriptorRequest.TransferBufferLength);
-
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
-
break;
}
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
&UsbDevice->ConfigurationDescriptor,
Urb->UrbControlDescriptorRequest.TransferBufferLength);
-
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
-
break;
}
case USB_STRING_DESCRIPTOR_TYPE:
}
InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length);
}
-
- Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
- Urb->UrbHeader.UsbdFlags = 0;
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
}
else
{
DPRINT1("TransferFlags %x\n", Urb->UrbControlVendorClassRequest.TransferFlags);
DPRINT1("Urb->UrbControlVendorClassRequest.Value %x\n", Urb->UrbControlVendorClassRequest.Value);
-
switch (Urb->UrbControlVendorClassRequest.Value >> 8)
{
case USB_DEVICE_CLASS_AUDIO:
DPRINT1("Unknown UrbControlVendorClassRequest Value\n");
}
}
- Urb->UrbHeader.Function = 0x08;
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
- Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
- Urb->UrbHeader.UsbdFlags = 0;
+ break;
+ }
+ case USB_REQUEST_GET_STATUS:
+ {
+ DPRINT1("DEVICE: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
+
+ if (Urb->UrbControlVendorClassRequest.Index == 1)
+ {
+ ((PULONG)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = 0;
+ }
break;
}
default:
{
case USB_REQUEST_GET_STATUS:
{
- DPRINT1("USB_REQUEST_GET_STATUS\n");
+ DPRINT1("OTHER: USB_REQUEST_GET_STATUS for port %d\n", Urb->UrbControlVendorClassRequest.Index);
+
+ ((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[0] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortStatus;
+ ((PUSHORT)Urb->UrbControlVendorClassRequest.TransferBuffer)[1] = DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange;
break;
}
case USB_REQUEST_CLEAR_FEATURE:
{
- DPRINT1("USB_REQUEST_CLEAR_FEATURE\n");
+ DPRINT1("USB_REQUEST_CLEAR_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
+ Urb->UrbControlVendorClassRequest.Value);
+ switch (Urb->UrbControlVendorClassRequest.Value)
+ {
+ case C_PORT_CONNECTION:
+ DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_CONNECT;
+ break;
+ case C_PORT_RESET:
+ DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange &= ~USB_PORT_STATUS_RESET;
+ break;
+ default:
+ DPRINT1("Unknown Value for Clear Feature %x \n", Urb->UrbControlVendorClassRequest.Value);
+ break;
+ }
break;
}
case USB_REQUEST_SET_FEATURE:
{
- DPRINT1("USB_REQUEST_SET_FEATURE value %x\n", Urb->UrbControlVendorClassRequest.Value);
+ DPRINT1("USB_REQUEST_SET_FEATURE Port %d, value %x\n", Urb->UrbControlVendorClassRequest.Index,
+ Urb->UrbControlVendorClassRequest.Value);
+
switch(Urb->UrbControlVendorClassRequest.Value)
{
- /* FIXME: Needs research */
- case 0x01:
+ case PORT_RESET:
{
+ DeviceExtension->Ports[Urb->UrbControlVendorClassRequest.Index-1].PortChange |= USB_PORT_STATUS_RESET;
+ break;
+ }
+ case PORT_ENABLE:
+ {
+ DPRINT1("Unhandled Set Feature\n");
+ break;
+ }
+ default:
+ {
+ DPRINT1("Unknown Set Feature!\n");
+ break;
}
}
break;
case USB_REQUEST_SET_ADDRESS:
{
DPRINT1("USB_REQUEST_SET_ADDRESS\n");
+ ASSERT(FALSE);
break;
}
case USB_REQUEST_GET_DESCRIPTOR:
DPRINT1("USB_REQUEST_SYNC_FRAME\n");
break;
}
+ default:
+ {
+ DPRINT1("Unknown Function Class Unknown request\n");
+ ASSERT(FALSE);
+ break;
+ }
}
break;
}
{
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
+ ASSERT(FALSE);
}
}
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Information;
+ if (Urb->UrbHeader.Status == USBD_STATUS_SUCCESS)
+ {
+ /* Fake a successful Control Transfer */
+ Urb->UrbHeader.Function = 0x08;
+ Urb->UrbHeader.UsbdFlags = 0;
+ }
+
IoCompleteRequest(Irp, IO_NO_INCREMENT);
KeAcquireSpinLock(&DeviceExtension->IrpQueueLock, &oldIrql);
}
}
case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE:
{
- DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
+ DPRINT1("IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE %x\n", IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE);
+ if (Stack->Parameters.Others.Argument1)
+ {
+ /* Return the root hubs devicehandle */
+ *(PVOID *)Stack->Parameters.Others.Argument1 = (PVOID)PdoDeviceExtension->UsbDevices[0];
+ }
+ else
+ Status = STATUS_INVALID_DEVICE_REQUEST;
break;
}
case IOCTL_INTERNAL_USB_GET_HUB_COUNT:
{
- DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_COUNT\n");
-
+ DPRINT1("IOCTL_INTERNAL_USB_GET_HUB_COUNT %x\n", IOCTL_INTERNAL_USB_GET_HUB_COUNT);
if (Stack->Parameters.Others.Argument1)
{
/* FIXME: Determine the number of hubs between the usb device and root hub */
- /* For now return 0 */
- *(PVOID *)Stack->Parameters.Others.Argument1 = 0;
+ /* For now return 1, the root hub */
+ *(PVOID *)Stack->Parameters.Others.Argument1 = (PVOID)1;
}
break;
}
if (Stack->Parameters.Others.Argument2)
*(PVOID *)Stack->Parameters.Others.Argument2 = IoGetAttachedDevice(FdoDeviceExtension->DeviceObject);
- Irp->IoStatus.Information = 0;
- Irp->IoStatus.Status = STATUS_SUCCESS;
- return STATUS_SUCCESS;
+ Information = 0;
+ Status = STATUS_SUCCESS;
break;
}
case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION:
}
}
- /* Lifted from hpoussin */
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&SourceString,
&String);
PPDO_DEVICE_EXTENSION PdoDeviceExtension;
PFDO_DEVICE_EXTENSION FdoDeviceExtension;
UNICODE_STRING InterfaceSymLinkName;
+ LONG i;
PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
FdoDeviceExtension = (PFDO_DEVICE_EXTENSION)PdoDeviceExtension->ControllerFdo->DeviceExtension;
/* Create the root hub */
RootHubDevice = InternalCreateUsbDevice(1, 0, NULL, TRUE);
+ for (i = 0; i < 8; i++)
+ {
+ PdoDeviceExtension->Ports[i].PortStatus = USB_PORT_STATUS_ENABLE;
+ PdoDeviceExtension->Ports[i].PortChange = 0;
+ }
+
RtlCopyMemory(&RootHubDevice->DeviceDescriptor,
ROOTHUB2_DEVICE_DESCRIPTOR,
sizeof(ROOTHUB2_DEVICE_DESCRIPTOR));
break;
}
case BusRelations:
+ DPRINT1("BusRelations!!!!!\n");
case RemovalRelations:
case EjectionRelations:
+ {
+ /* Ignore the request */
+ Information = Irp->IoStatus.Information;
+ Status = Irp->IoStatus.Status;
+ break;
+
+ }
default:
{
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unhandled type 0x%lx\n",
else
{
DPRINT1("Not Supported\n");
- Status = STATUS_NOT_SUPPORTED;
+ Status = Irp->IoStatus.Status;
+ Information = Irp->IoStatus.Information;
}
break;
}
#define PING_STATE_DO_OUT 0x00
#define PING_STATE_DO_PING 0x01
+#define C_HUB_LOCAL_POWER 0
+#define C_HUB_OVER_CURRENT 1
+#define PORT_CONNECTION 0
+#define PORT_ENABLE 1
+#define PORT_SUSPEND 2
+#define PORT_OVER_CURRENT 3
+#define PORT_RESET 4
+#define PORT_POWER 8
+#define PORT_LOW_SPEED 9
+#define PORT_HIGH_SPEED 9
+#define C_PORT_CONNECTION 16
+#define C_PORT_ENABLE 17
+#define C_PORT_SUSPEND 18
+#define C_PORT_OVER_CURRENT 19
+#define C_PORT_RESET 20
+#define PORT_TEST 21
+#define PORT_INDICATOR 22
+#define USB_PORT_STATUS_CHANGE 0x4000
+
/* QUEUE ELEMENT TRANSFER DESCRIPTOR TOKEN */
typedef struct _QETD_TOKEN_BITS
{
} EHCI_HCC_CONTENT, *PEHCI_HCC_CONTENT;
typedef struct _EHCI_CAPS {
- UCHAR Length;
- UCHAR Reserved;
- USHORT HCIVersion;
+ UCHAR Length;
+ UCHAR Reserved;
+ USHORT HCIVersion;
union
{
- EHCI_HCS_CONTENT HCSParams;
- ULONG HCSParamsLong;
+ EHCI_HCS_CONTENT HCSParams;
+ ULONG HCSParamsLong;
};
- ULONG HCCParams;
- UCHAR PortRoute [8];
+ ULONG HCCParams;
+ UCHAR PortRoute [8];
} EHCI_CAPS, *PEHCI_CAPS;
typedef struct _COMMON_DEVICE_EXTENSION
PDEVICE_OBJECT DeviceObject;
} COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
+typedef struct _EHCIPORTS
+{
+ ULONG PortNumber;
+ ULONG PortType;
+ USHORT PortStatus;
+ USHORT PortChange;
+} EHCIPORTS, *PEHCIPORTS;
+
typedef struct _FDO_DEVICE_EXTENSION
{
COMMON_DEVICE_EXTENSION Common;
PULONG PeriodicFramList;
PULONG AsyncListQueueHeadPtr;
- PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
- PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
+ PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
+ PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
BOOLEAN AsyncComplete;
BOOLEAN HaltUrbHandling;
PVOID CallbackContext;
PRH_INIT_CALLBACK CallbackRoutine;
+ ULONG NumberOfPorts;
+ EHCIPORTS Ports[32];
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
typedef struct _WORKITEM_DATA
<xi:include href="hal_generic.rbuild" />
<xi:include href="hal_generic_up.rbuild" />
<xi:include href="hal_generic_mp.rbuild" />
-
+ <xi:include href="hal_generic_pcat.rbuild" />
+ <xi:include href="hal_generic_acpi.rbuild" />
+
<if property="ARCH" value="i386">
<xi:include href="hal.rbuild" />
+ <xi:include href="halacpi.rbuild" />
<xi:include href="halxbox.rbuild" />
<if property="BUILD_MP" value="1">
<xi:include href="halmps.rbuild" />
--- /dev/null
+/*
+ * PROJECT: ReactOS HAL
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: hal/halx86/generic/acpi/halacpi.c
+ * PURPOSE: HAL ACPI Code
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+LIST_ENTRY HalpAcpiTableCacheList;
+FAST_MUTEX HalpAcpiTableCacheLock;
+
+BOOLEAN HalpProcessedACPIPhase0;
+BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB;
+
+FADT HalpFixedAcpiDescTable;
+PDEBUG_PORT_TABLE HalpDebugPortTable;
+PACPI_SRAT HalpAcpiSrat;
+PBOOT_TABLE HalpSimpleBootFlagTable;
+
+PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress;
+PHYSICAL_ADDRESS HalpLowStubPhysicalAddress;
+PHARDWARE_PTE HalpPteForFlush;
+PVOID HalpVirtAddrForFlush;
+PVOID HalpLowStub;
+
+PACPI_BIOS_MULTI_NODE HalpAcpiMultiNode;
+
+LIST_ENTRY HalpAcpiTableMatchList;
+
+ULONG HalpInvalidAcpiTable;
+
+ULONG HalpPicVectorRedirect[] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15};
+
+/* This determines the HAL type */
+BOOLEAN HalDisableFirmwareMapper = TRUE;
+PWCHAR HalHardwareIdString = L"acpipic_up";
+PWCHAR HalName = L"ACPI Compatible Eisa/Isa HAL";
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+PDESCRIPTION_HEADER
+NTAPI
+HalpAcpiGetCachedTable(IN ULONG Signature)
+{
+ PLIST_ENTRY ListHead, NextEntry;
+ PACPI_CACHED_TABLE CachedTable;
+
+ /* Loop cached tables */
+ ListHead = &HalpAcpiTableCacheList;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the table */
+ CachedTable = CONTAINING_RECORD(NextEntry, ACPI_CACHED_TABLE, Links);
+
+ /* Compare signatures */
+ if (CachedTable->Header.Signature == Signature) return &CachedTable->Header;
+
+ /* Keep going */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* Nothing found */
+ return NULL;
+}
+
+VOID
+NTAPI
+HalpAcpiCacheTable(IN PDESCRIPTION_HEADER TableHeader)
+{
+ PACPI_CACHED_TABLE CachedTable;
+
+ /* Get the cached table and link it */
+ CachedTable = CONTAINING_RECORD(TableHeader, ACPI_CACHED_TABLE, Header);
+ InsertTailList(&HalpAcpiTableCacheList, &CachedTable->Links);
+}
+
+PVOID
+NTAPI
+HalpAcpiCopyBiosTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN PDESCRIPTION_HEADER TableHeader)
+{
+ ULONG Size;
+ PFN_NUMBER PageCount;
+ PHYSICAL_ADDRESS PhysAddress;
+ PACPI_CACHED_TABLE CachedTable;
+ PDESCRIPTION_HEADER CopiedTable;
+
+ /* Size we'll need for the cached table */
+ Size = TableHeader->Length + FIELD_OFFSET(ACPI_CACHED_TABLE, Header);
+ if (LoaderBlock)
+ {
+ /* Phase 0: Convert to pages and use the HAL heap */
+ PageCount = BYTES_TO_PAGES(Size);
+ PhysAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock,
+ 0x1000000,
+ PageCount,
+ FALSE);
+ if (PhysAddress.LowPart)
+ {
+ /* Map it */
+ CachedTable = HalpMapPhysicalMemory64(PhysAddress, PageCount);
+ }
+ else
+ {
+ /* No memory, so nothing to map */
+ CachedTable = NULL;
+ }
+ }
+ else
+ {
+ /* Use Mm pool */
+ CachedTable = ExAllocatePoolWithTag(NonPagedPool, Size, ' laH');
+ }
+
+ /* Do we have the cached table? */
+ if (CachedTable)
+ {
+ /* Copy the data */
+ CopiedTable = &CachedTable->Header;
+ RtlCopyMemory(CopiedTable, TableHeader, TableHeader->Length);
+ }
+ else
+ {
+ /* Nothing to return */
+ CopiedTable = NULL;
+ }
+
+ /* Return the table */
+ return CopiedTable;
+}
+
+PVOID
+NTAPI
+HalpAcpiGetTableFromBios(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG Signature)
+{
+ PHYSICAL_ADDRESS PhysicalAddress;
+ PXSDT Xsdt;
+ PRSDT Rsdt;
+ PFADT Fadt;
+ PDESCRIPTION_HEADER Header = NULL;
+ ULONG TableLength;
+ CHAR CheckSum = 0;
+ ULONG Offset;
+ ULONG EntryCount, CurrentEntry;
+ PCHAR CurrentByte;
+ PFN_NUMBER PageCount;
+
+ /* Should not query the RSDT/XSDT by itself */
+ if ((Signature == RSDT_SIGNATURE) || (Signature == XSDT_SIGNATURE)) return NULL;
+
+ /* Special case request for DSDT, because the FADT points to it */
+ if (Signature == DSDT_SIGNATURE)
+ {
+ /* Grab the FADT */
+ Fadt = HalpAcpiGetTable(LoaderBlock, FADT_SIGNATURE);
+ if (Fadt)
+ {
+ /* Grab the DSDT address and assume 2 pages */
+ PhysicalAddress.LowPart = Fadt->dsdt;
+ TableLength = 2 * PAGE_SIZE;
+
+ /* Map it */
+ if (LoaderBlock)
+ {
+ /* Phase 0, use HAL heap */
+ Header = HalpMapPhysicalMemory64(PhysicalAddress, 2u);
+ }
+ else
+ {
+ /* Phase 1, use Mm */
+ Header = MmMapIoSpace(PhysicalAddress, 2 * PAGE_SIZE, 0);
+ }
+
+ /* Fail if we couldn't map it */
+ if (!Header)
+ {
+ DbgPrint("HAL: Failed to map ACPI table.\n");
+ return NULL;
+ }
+
+ /* Validate the signature */
+ DPRINT1("ACPI DSDT at 0x%p\n", Header);
+ if (Header->Signature != DSDT_SIGNATURE)
+ {
+ /* Fail and unmap */
+ if (LoaderBlock)
+ {
+ /* Using HAL heap */
+ HalpUnmapVirtualAddress(Header, 2);
+ }
+ else
+ {
+ /* Using Mm */
+ MmUnmapIoSpace(Header, 2 * PAGE_SIZE);
+ }
+
+ /* Didn't find anything */
+ return NULL;
+ }
+ }
+ else
+ {
+ /* Couldn't find it */
+ return NULL;
+ }
+ }
+ else
+ {
+ /* To find tables, we need the RSDT */
+ Rsdt = HalpAcpiGetTable(LoaderBlock, RSDT_SIGNATURE);
+ if (Rsdt)
+ {
+ /* Won't be using the XSDT */
+ Xsdt = NULL;
+ }
+ else
+ {
+ /* Only other choice is to use the XSDT */
+ Xsdt = HalpAcpiGetTable(LoaderBlock, XSDT_SIGNATURE);
+ if (!Xsdt) return NULL;
+
+ /* Won't be using the RSDT */
+ DPRINT1("ACPI XSDT at 0x%p\n", Xsdt);
+ Rsdt = NULL;
+ }
+
+ /* Smallest RSDT/XSDT is one without table entries */
+ Offset = FIELD_OFFSET(RSDT, Tables);
+ if (Xsdt)
+ {
+ /* Figure out total size of table and the offset */
+ TableLength = Xsdt->Header.Length;
+ if (TableLength < Offset) Offset = Xsdt->Header.Length;
+
+ /* The entries are each 64-bits, so count them */
+ EntryCount = (TableLength - Offset) / sizeof(PHYSICAL_ADDRESS);
+ }
+ else
+ {
+ /* Figure out total size of table and the offset */
+ TableLength = Rsdt->Header.Length;
+ if (TableLength < Offset) Offset = Rsdt->Header.Length;
+
+ /* The entries are each 32-bits, so count them */
+ EntryCount = (TableLength - Offset) / sizeof(ULONG);
+ }
+
+ /* Start at the beginning of the array and loop it */
+ for (CurrentEntry = 0; CurrentEntry < EntryCount; CurrentEntry++)
+ {
+ /* Are we using the XSDT? */
+ if (!Xsdt)
+ {
+ /* Read the 32-bit physical address */
+ PhysicalAddress.LowPart = Rsdt->Tables[CurrentEntry];
+ }
+ else
+ {
+ /* Read the 64-bit physical address */
+ PhysicalAddress = Xsdt->Tables[CurrentEntry];
+ }
+
+ /* Had we already mapped a table? */
+ if (Header)
+ {
+ /* Yes, unmap it */
+ if (LoaderBlock)
+ {
+ /* Using HAL heap */
+ HalpUnmapVirtualAddress(Header, 2);
+ }
+ else
+ {
+ /* Using Mm */
+ MmUnmapIoSpace(Header, 2 * PAGE_SIZE);
+ }
+ }
+
+ /* Now map this table */
+ if (!LoaderBlock)
+ {
+ /* Phase 1: Use HAL heap */
+ Header = MmMapIoSpace(PhysicalAddress, 2 * PAGE_SIZE, MmNonCached);
+ }
+ else
+ {
+ /* Phase 0: Use Mm */
+ Header = HalpMapPhysicalMemory64(PhysicalAddress, 2);
+ }
+
+ /* Check if we mapped it */
+ if (!Header)
+ {
+ /* Game over */
+ DbgPrint("HAL: Failed to map ACPI table.\n");
+ return NULL;
+ }
+
+ /* We found it, break out */
+ DPRINT("Found ACPI table %c%c%c%c at 0x%p\n",
+ Header->Signature & 0xFF,
+ (Header->Signature & 0xFF00) >> 8,
+ (Header->Signature & 0xFF0000) >> 16,
+ (Header->Signature & 0xFF000000) >> 24,
+ Header);
+ if (Header->Signature == Signature) break;
+ }
+
+ /* Did we end up here back at the last entry? */
+ if (CurrentEntry == EntryCount)
+ {
+ /* Yes, unmap the last table we processed */
+ if (LoaderBlock)
+ {
+ /* Using HAL heap */
+ HalpUnmapVirtualAddress(Header, 2);
+ }
+ else
+ {
+ /* Using Mm */
+ MmUnmapIoSpace(Header, 2 * PAGE_SIZE);
+ }
+
+ /* Didn't find anything */
+ return NULL;
+ }
+ }
+
+ /* Past this point, we assume something was found */
+ ASSERT(Header);
+
+ /* How many pages do we need? */
+ PageCount = BYTES_TO_PAGES(Header->Length);
+ if (PageCount != 2)
+ {
+ /* We assumed two, but this is not the case, free the current mapping */
+ if (LoaderBlock)
+ {
+ /* Using HAL heap */
+ HalpUnmapVirtualAddress(Header, 2);
+ }
+ else
+ {
+ /* Using Mm */
+ MmUnmapIoSpace(Header, 2 * PAGE_SIZE);
+ }
+
+ /* Now map this table using its correct size */
+ if (!LoaderBlock)
+ {
+ /* Phase 1: Use HAL heap */
+ Header = MmMapIoSpace(PhysicalAddress, PageCount << PAGE_SHIFT, MmNonCached);
+ }
+ else
+ {
+ /* Phase 0: Use Mm */
+ Header = HalpMapPhysicalMemory64(PhysicalAddress, PageCount);
+ }
+ }
+
+ /* Fail if the remapped failed */
+ if (!Header) return NULL;
+
+ /* All tables in ACPI 3.0 other than the FACP should have correct checksum */
+ if ((Header->Signature != FADT_SIGNATURE) || (Header->Revision > 2))
+ {
+ /* Go to the end of the table */
+ CheckSum = 0;
+ CurrentByte = (PCHAR)Header + Header->Length;
+ while (CurrentByte-- != (PCHAR)Header)
+ {
+ /* Add this byte */
+ CheckSum += *CurrentByte;
+ }
+
+ /* The correct checksum is always 0, anything else is illegal */
+ if (CheckSum) HalpInvalidAcpiTable = Header->Signature;
+ }
+
+ /* Return the table */
+ return Header;
+}
+
+PVOID
+NTAPI
+HalpAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG Signature)
+{
+ PFN_NUMBER PageCount;
+ PDESCRIPTION_HEADER TableAddress, BiosCopy;
+
+ /* See if we have a cached table? */
+ TableAddress = HalpAcpiGetCachedTable(Signature);
+ if (!TableAddress)
+ {
+ /* No cache, search the BIOS */
+ TableAddress = HalpAcpiGetTableFromBios(LoaderBlock, Signature);
+ if (TableAddress)
+ {
+ /* Found it, copy it into our own memory */
+ BiosCopy = HalpAcpiCopyBiosTable(LoaderBlock, TableAddress);
+
+ /* Get the pages, and unmap the BIOS copy */
+ PageCount = BYTES_TO_PAGES(TableAddress->Length);
+ if (LoaderBlock)
+ {
+ /* Phase 0, use the HAL heap */
+ HalpUnmapVirtualAddress(TableAddress, PageCount);
+ }
+ else
+ {
+ /* Phase 1, use Mm */
+ MmUnmapIoSpace(TableAddress, PageCount << 12);
+ }
+
+ /* Cache the bios copy */
+ TableAddress = BiosCopy;
+ if (BiosCopy) HalpAcpiCacheTable(BiosCopy);
+ }
+ }
+
+ /* Return the table */
+ return TableAddress;
+}
+
+PVOID
+NTAPI
+HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG Signature)
+{
+ PDESCRIPTION_HEADER TableHeader;
+
+ /* Is this phase0 */
+ if (LoaderBlock)
+ {
+ /* Initialize the cache first */
+ if (!NT_SUCCESS(HalpAcpiTableCacheInit(LoaderBlock))) return NULL;
+ }
+ else
+ {
+ /* Lock the cache */
+ ExAcquireFastMutex(&HalpAcpiTableCacheLock);
+ }
+
+ /* Get the table */
+ TableHeader = HalpAcpiGetTable(LoaderBlock, Signature);
+
+ /* Release the lock in phase 1 */
+ if (!LoaderBlock) ExReleaseFastMutex(&HalpAcpiTableCacheLock);
+
+ /* Return the table */
+ return TableHeader;
+}
+
+VOID
+NTAPI
+HalpNumaInitializeStaticConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ PACPI_SRAT SratTable;
+
+ /* Get the SRAT, bail out if it doesn't exist */
+ SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE);
+ HalpAcpiSrat = SratTable;
+ if (!SratTable) return;
+}
+
+VOID
+NTAPI
+HalpGetHotPlugMemoryInfo(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ PACPI_SRAT SratTable;
+
+ /* Get the SRAT, bail out if it doesn't exist */
+ SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE);
+ HalpAcpiSrat = SratTable;
+ if (!SratTable) return;
+}
+
+VOID
+NTAPI
+HalpDynamicSystemResourceConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ /* For this HAL, it means to get hot plug memory information */
+ HalpGetHotPlugMemoryInfo(LoaderBlock);
+}
+
+VOID
+NTAPI
+HalpAcpiDetectMachineSpecificActions(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN PFADT DescriptionTable)
+{
+ /* Does this HAL specify something? */
+ if (HalpAcpiTableMatchList.Flink)
+ {
+ /* Great, but we don't support it */
+ DPRINT1("WARNING: Your HAL has specific ACPI hacks to apply!\n");
+ }
+}
+
+VOID
+NTAPI
+HalpInitBootTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ PBOOT_TABLE BootTable;
+
+ /* Get the boot table */
+ BootTable = HalAcpiGetTable(LoaderBlock, BOOT_SIGNATURE);
+ HalpSimpleBootFlagTable = BootTable;
+ DPRINT1("ACPI BOOT at 0x%p\n", HalpSimpleBootFlagTable);
+
+ /* Validate it */
+ if ((BootTable) &&
+ (BootTable->Header.Length >= sizeof(BOOT_TABLE)) &&
+ (BootTable->CMOSIndex >= 9))
+ {
+ DPRINT1("ACPI Boot table found, but not supported!\n");
+ }
+ else
+ {
+ /* Invalid or doesn't exist, ignore it */
+ HalpSimpleBootFlagTable = 0;
+ }
+
+ /* Install the end of boot handler */
+// HalEndOfBoot = HalpEndOfBoot;
+}
+
+NTSTATUS
+NTAPI
+HalpAcpiFindRsdtPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ OUT PACPI_BIOS_MULTI_NODE* AcpiMultiNode)
+{
+ PCONFIGURATION_COMPONENT_DATA ComponentEntry;
+ PCONFIGURATION_COMPONENT_DATA Next = NULL;
+ PCM_PARTIAL_RESOURCE_LIST ResourceList;
+ PACPI_BIOS_MULTI_NODE NodeData;
+ ULONG NodeLength;
+ PFN_NUMBER PageCount;
+ PVOID MappedAddress;
+ PHYSICAL_ADDRESS PhysicalAddress;
+
+ /* Did we already do this once? */
+ if (HalpAcpiMultiNode)
+ {
+ /* Return what we know */
+ *AcpiMultiNode = HalpAcpiMultiNode;
+ return STATUS_SUCCESS;
+ }
+
+ /* Assume failure */
+ *AcpiMultiNode = NULL;
+
+ /* Find the multi function adapter key */
+ ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot,
+ AdapterClass,
+ MultiFunctionAdapter,
+ 0,
+ &Next);
+ while (ComponentEntry)
+ {
+ /* Find the ACPI BIOS key */
+ if (!_stricmp(ComponentEntry->ComponentEntry.Identifier, "ACPI BIOS"))
+ {
+ /* Found it */
+ break;
+ }
+
+ /* Keep searching */
+ Next = ComponentEntry;
+ ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot,
+ AdapterClass,
+ MultiFunctionAdapter,
+ NULL,
+ &Next);
+ }
+
+ /* Make sure we found it */
+ if (!ComponentEntry)
+ {
+ DbgPrint("**** HalpAcpiFindRsdtPhase0: did NOT find RSDT\n");
+ return STATUS_NOT_FOUND;
+ }
+
+ /* The configuration data is a resource list, and the BIOS node follows */
+ ResourceList = ComponentEntry->ConfigurationData;
+ NodeData = (PACPI_BIOS_MULTI_NODE)(ResourceList + 1);
+
+ /* How many E820 memory entries are there? */
+ NodeLength = sizeof(ACPI_BIOS_MULTI_NODE) +
+ (NodeData->Count - 1) * sizeof(ACPI_E820_ENTRY);
+
+ /* Convert to pages */
+ PageCount = BYTES_TO_PAGES(NodeLength);
+
+ /* Allocate the memory */
+ PhysicalAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock,
+ 0x1000000,
+ PageCount,
+ FALSE);
+ if (PhysicalAddress.LowPart)
+ {
+ /* Map it if the allocation worked */
+ MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, PageCount);
+ }
+ else
+ {
+ /* Otherwise we'll have to fail */
+ MappedAddress = NULL;
+ }
+
+ /* Save the multi node, bail out if we didn't find it */
+ HalpAcpiMultiNode = MappedAddress;
+ if (!MappedAddress) return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Copy the multi-node data */
+ RtlCopyMemory(MappedAddress, NodeData, NodeLength);
+
+ /* Return the data */
+ *AcpiMultiNode = HalpAcpiMultiNode;
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+HalpAcpiTableCacheInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ PACPI_BIOS_MULTI_NODE AcpiMultiNode;
+ NTSTATUS Status = STATUS_SUCCESS;
+ PHYSICAL_ADDRESS PhysicalAddress;
+ PVOID MappedAddress;
+ ULONG TableLength;
+ PRSDT Rsdt;
+ PLOADER_PARAMETER_EXTENSION LoaderExtension;
+
+ /* Only initialize once */
+ if (HalpAcpiTableCacheList.Flink) return Status;
+
+ /* Setup the lock and table */
+ ExInitializeFastMutex(&HalpAcpiTableCacheLock);
+ InitializeListHead(&HalpAcpiTableCacheList);
+
+ /* Find the RSDT */
+ Status = HalpAcpiFindRsdtPhase0(LoaderBlock, &AcpiMultiNode);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Map the RSDT */
+ if (LoaderBlock)
+ {
+ /* Phase0: Use HAL Heap to map the RSDT, we assume it's about 2 pages */
+ PhysicalAddress.QuadPart = AcpiMultiNode->RsdtAddress.QuadPart;
+ MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, 2);
+ }
+ else
+ {
+ /* Use an I/O map */
+ MappedAddress = MmMapIoSpace(PhysicalAddress, PAGE_SIZE * 2, MmNonCached);
+ }
+
+ /* Get the RSDT */
+ Rsdt = MappedAddress;
+ if (!MappedAddress)
+ {
+ /* Fail, no memory */
+ DbgPrint("HAL: Failed to map RSDT\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Validate it */
+ DPRINT1("ACPI RSDT at 0x%p\n", Rsdt);
+ if ((Rsdt->Header.Signature != RSDT_SIGNATURE) &&
+ (Rsdt->Header.Signature != XSDT_SIGNATURE))
+ {
+ /* Very bad: crash */
+ HalDisplayString("Bad RSDT pointer\n");
+ KeBugCheckEx(MISMATCHED_HAL, 4, __LINE__, 0, 0);
+ }
+
+ /* We assumed two pages -- do we need less or more? */
+ TableLength = ADDRESS_AND_SIZE_TO_SPAN_PAGES(PhysicalAddress.LowPart,
+ Rsdt->Header.Length);
+ if (TableLength != 2)
+ {
+ /* Are we in phase 0 or 1? */
+ if (!LoaderBlock)
+ {
+ /* Unmap the old table, remap the new one, using Mm I/O space */
+ MmUnmapIoSpace(MappedAddress, 2 * PAGE_SIZE);
+ MappedAddress = MmMapIoSpace(PhysicalAddress,
+ TableLength << PAGE_SHIFT,
+ MmNonCached);
+ }
+ else
+ {
+ /* Unmap the old table, remap the new one, using HAL heap */
+ HalpUnmapVirtualAddress(MappedAddress, 2);
+ MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, TableLength);
+ }
+
+ /* Get the remapped table */
+ Rsdt = MappedAddress;
+ if (!MappedAddress)
+ {
+ /* Fail, no memory */
+ DbgPrint("HAL: Couldn't remap RSDT\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+
+ /* Now take the BIOS copy and make our own local copy */
+ Rsdt = HalpAcpiCopyBiosTable(LoaderBlock, &Rsdt->Header);
+ if (!Rsdt)
+ {
+ /* Fail, no memory */
+ DbgPrint("HAL: Couldn't remap RSDT\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Get rid of the BIOS mapping */
+ if (LoaderBlock)
+ {
+ /* Use HAL heap */
+ HalpUnmapVirtualAddress(MappedAddress, TableLength);
+ }
+ else
+ {
+ /* Use Mm */
+ MmUnmapIoSpace(MappedAddress, TableLength << PAGE_SHIFT);
+ }
+
+ /* Cache the RSDT */
+ HalpAcpiCacheTable(&Rsdt->Header);
+
+ /* Check for compatible loader block extension */
+ LoaderExtension = LoaderBlock->Extension;
+ if (LoaderExtension->Size >= 0x58)
+ {
+ /* Compatible loader: did it provide an ACPI table override? */
+ if ((LoaderExtension->AcpiTable) && (LoaderExtension->AcpiTableSize))
+ {
+ /* Great, because we don't support it! */
+ DPRINT1("ACPI Table Overrides Not Supported!\n");
+ }
+ }
+
+ /* Done */
+ return Status;
+}
+
+VOID
+NTAPI
+HaliAcpiTimerInit(IN ULONG TimerPort,
+ IN ULONG TimerValExt)
+{
+ PAGED_CODE();
+
+ /* Is this in the init phase? */
+ if (!TimerPort )
+ {
+ /* Get the data from the FADT */
+ TimerPort = HalpFixedAcpiDescTable.pm_tmr_blk_io_port;
+ TimerValExt = HalpFixedAcpiDescTable.flags & ACPI_TMR_VAL_EXT;
+ }
+
+ /* FIXME: Now proceed to the timer initialization */
+ DPRINT1("ACPI Timer at: %Xh (EXT: %d)\n", TimerPort, TimerValExt);
+ //HalaAcpiTimerInit(TimerPort, TimerValExt);
+}
+
+NTSTATUS
+NTAPI
+HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ NTSTATUS Status;
+ PFADT Fadt;
+ ULONG TableLength;
+ PHYSICAL_ADDRESS PhysicalAddress;
+
+ /* Only do this once */
+ DPRINT1("You are booting the ACPI HAL!\n");
+ if (HalpProcessedACPIPhase0) return STATUS_SUCCESS;
+
+ /* Setup the ACPI table cache */
+ Status = HalpAcpiTableCacheInit(LoaderBlock);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Grab the FADT */
+ Fadt = HalAcpiGetTable(LoaderBlock, FADT_SIGNATURE);
+ if (!Fadt)
+ {
+ /* Fail */
+ DbgPrint("HAL: Didn't find the FACP\n");
+ return STATUS_NOT_FOUND;
+ }
+
+ /* Assume typical size, otherwise whatever the descriptor table says */
+ DPRINT1("ACPI FACP at 0x%p\n", Fadt);
+ TableLength = sizeof(FADT);
+ if (Fadt->Header.Length < sizeof(FADT)) TableLength = Fadt->Header.Length;
+
+ /* Copy it in the HAL static buffer */
+ RtlCopyMemory(&HalpFixedAcpiDescTable, Fadt, TableLength);
+
+ /* Anything special this HAL needs to do? */
+ HalpAcpiDetectMachineSpecificActions(LoaderBlock, &HalpFixedAcpiDescTable);
+
+ /* Get the debug table for KD */
+ HalpDebugPortTable = HalAcpiGetTable(LoaderBlock, DBGP_SIGNATURE);
+ DPRINT1("ACPI DBGP at 0x%p\n", HalpDebugPortTable);
+
+ /* Initialize NUMA through the SRAT */
+ HalpNumaInitializeStaticConfiguration(LoaderBlock);
+
+ /* Initialize hotplug through the SRAT */
+ HalpDynamicSystemResourceConfiguration(LoaderBlock);
+ DPRINT1("ACPI SRAT at 0x%p\n", HalpAcpiSrat);
+ if (HalpAcpiSrat)
+ {
+ DPRINT1("Your machine has a SRAT, but NUMA/HotPlug are not supported!\n");
+ }
+
+ /* Can there be memory higher than 4GB? */
+ if (HalpMaxHotPlugMemoryAddress.HighPart >= 1)
+ {
+ /* We'll need this for DMA later */
+ HalpPhysicalMemoryMayAppearAbove4GB = TRUE;
+ }
+
+ /* Setup the ACPI timer */
+ HaliAcpiTimerInit(0, 0);
+
+ /* Do we have a low stub address yet? */
+ if (!HalpLowStubPhysicalAddress.LowPart)
+ {
+ /* Allocate it */
+ HalpLowStubPhysicalAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock,
+ 0x100000,
+ 1,
+ FALSE);
+ if (HalpLowStubPhysicalAddress.LowPart)
+ {
+ /* Map it */
+ HalpLowStub = HalpMapPhysicalMemory64(HalpLowStubPhysicalAddress, 1);
+ }
+ }
+
+ /* Grab a page for flushes */
+ PhysicalAddress.QuadPart = 0x100000;
+ HalpVirtAddrForFlush = HalpMapPhysicalMemory64(PhysicalAddress, 1);
+ HalpPteForFlush = HalAddressToPte(HalpVirtAddrForFlush);
+
+ /* Don't do this again */
+ HalpProcessedACPIPhase0 = TRUE;
+
+ /* Setup the boot table */
+ HalpInitBootTable(LoaderBlock);
+
+ /* Return success */
+ return STATUS_SUCCESS;
+}
+
+VOID
+NTAPI
+HalpInitializePciBus(VOID)
+{
+ /* Setup the PCI stub support */
+ HalpInitializePciStubs();
+
+ /* Set the NMI crash flag */
+ HalpGetNMICrashFlag();
+}
+
+VOID
+NTAPI
+HalpBuildAddressMap(VOID)
+{
+ /* ACPI is magic baby */
+}
+
+BOOLEAN
+NTAPI
+HalpGetDebugPortTable(VOID)
+{
+ return ((HalpDebugPortTable) &&
+ (HalpDebugPortTable->BaseAddress.AddressSpaceID == 1));
+}
+
+ULONG
+NTAPI
+HalpIs16BitPortDecodeSupported(VOID)
+{
+ /* All ACPI systems are at least "EISA" so they support this */
+ return CM_RESOURCE_PORT_16_BIT_DECODE;
+}
+
+VOID
+NTAPI
+HalpAcpiDetectResourceListSize(OUT PULONG ListSize)
+{
+ PAGED_CODE();
+
+ /* One element if there is a SCI */
+ *ListSize = HalpFixedAcpiDescTable.sci_int_vector ? 1: 0;
+}
+
+NTSTATUS
+NTAPI
+HalpBuildAcpiResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceList)
+{
+ ULONG Interrupt;
+ PAGED_CODE();
+ ASSERT(ResourceList != NULL);
+
+ /* Initialize the list */
+ ResourceList->BusNumber = -1;
+ ResourceList->AlternativeLists = 1;
+ ResourceList->InterfaceType = PNPBus;
+ ResourceList->List[0].Version = 1;
+ ResourceList->List[0].Revision = 1;
+
+ /* Is there a SCI? */
+ if (HalpFixedAcpiDescTable.sci_int_vector)
+ {
+ /* Fill out the entry for it */
+ ResourceList->List[0].Descriptors[0].Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+ ResourceList->List[0].Descriptors[0].Type = CmResourceTypeInterrupt;
+ ResourceList->List[0].Descriptors[0].ShareDisposition = CmResourceShareShared;
+
+ /* Get the interrupt number */
+ Interrupt = HalpPicVectorRedirect[HalpFixedAcpiDescTable.sci_int_vector];
+ ResourceList->List[0].Descriptors[0].u.Interrupt.MinimumVector = Interrupt;
+ ResourceList->List[0].Descriptors[0].u.Interrupt.MaximumVector = Interrupt;
+
+ /* One more */
+ ++ResourceList->List[0].Count;
+ }
+
+ /* All good */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryAcpiResourceRequirements(OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
+{
+ PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
+ ULONG Count = 0, ListSize;
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Get ACPI resources */
+ HalpAcpiDetectResourceListSize(&Count);
+
+ /* Compute size of the list and allocate it */
+ ListSize = sizeof(IO_RESOURCE_LIST) * (Count - 1) +
+ sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
+ RequirementsList = ExAllocatePoolWithTag(PagedPool, ListSize, ' laH');
+ if (RequirementsList)
+ {
+ /* Initialize it */
+ RtlZeroMemory(RequirementsList, ListSize);
+ RequirementsList->ListSize = ListSize;
+
+ /* Build it */
+ Status = HalpBuildAcpiResourceList(RequirementsList);
+ if (NT_SUCCESS(Status))
+ {
+ /* It worked, return it */
+ *Requirements = RequirementsList;
+ }
+ else
+ {
+ /* Fail */
+ ExFreePoolWithTag(RequirementsList, 0);
+ Status = STATUS_NO_SUCH_DEVICE;
+ }
+ }
+ else
+ {
+ /* Not enough memory */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Return the status */
+ return Status;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalReportResourceUsage(VOID)
+{
+ INTERFACE_TYPE InterfaceType;
+ UNICODE_STRING HalString;
+
+ /* FIXME: Initialize DMA 64-bit support */
+
+ /* FIXME: Initialize MCA bus */
+
+ /* Initialize PCI bus. */
+ HalpInitializePciBus();
+
+ /* What kind of bus is this? */
+ switch (HalpBusType)
+ {
+ /* ISA Machine */
+ case MACHINE_TYPE_ISA:
+ InterfaceType = Isa;
+ break;
+
+ /* EISA Machine */
+ case MACHINE_TYPE_EISA:
+ InterfaceType = Eisa;
+ break;
+
+ /* MCA Machine */
+ case MACHINE_TYPE_MCA:
+ InterfaceType = MicroChannel;
+ break;
+
+ /* Unknown */
+ default:
+ InterfaceType = Internal;
+ break;
+ }
+
+ /* Build HAL usage */
+ RtlInitUnicodeString(&HalString, HalName);
+ HalpReportResourceUsage(&HalString, InterfaceType);
+
+ /* Setup PCI debugging and Hibernation */
+ HalpRegisterPciDebuggingDeviceInfo();
+}
+
+/* EOF */
--- /dev/null
+/*
+ * PROJECT: ReactOS HAL
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: hal/halx86/generic/acpi/halpnpdd.c
+ * PURPOSE: HAL Plug and Play Device Driver
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+typedef enum _EXTENSION_TYPE
+{
+ PdoExtensionType = 0xC0,
+ FdoExtensionType
+} EXTENSION_TYPE;
+
+typedef enum _PDO_TYPE
+{
+ AcpiPdo = 0x80,
+ WdPdo
+} PDO_TYPE;
+
+typedef struct _FDO_EXTENSION
+{
+ EXTENSION_TYPE ExtensionType;
+ struct _PDO_EXTENSION* ChildPdoList;
+ PDEVICE_OBJECT PhysicalDeviceObject;
+ PDEVICE_OBJECT FunctionalDeviceObject;
+ PDEVICE_OBJECT AttachedDeviceObject;
+} FDO_EXTENSION, *PFDO_EXTENSION;
+
+typedef struct _PDO_EXTENSION
+{
+ EXTENSION_TYPE ExtensionType;
+ struct _PDO_EXTENSION* Next;
+ PDEVICE_OBJECT PhysicalDeviceObject;
+ PFDO_EXTENSION ParentFdoExtension;
+ PDO_TYPE PdoType;
+ PDESCRIPTION_HEADER WdTable;
+ LONG InterfaceReferenceCount;
+} PDO_EXTENSION, *PPDO_EXTENSION;
+
+/* GLOBALS ********************************************************************/
+
+PDRIVER_OBJECT HalpDriverObject;
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+NTSTATUS
+NTAPI
+HalpAddDevice(IN PDRIVER_OBJECT DriverObject,
+ IN PDEVICE_OBJECT TargetDevice)
+{
+ NTSTATUS Status;
+ PFDO_EXTENSION FdoExtension;
+ PPDO_EXTENSION PdoExtension;
+ PDEVICE_OBJECT DeviceObject, PdoDeviceObject, AttachedDevice;
+ PDESCRIPTION_HEADER Wdrt;
+ DbgPrint("HAL: PnP Driver ADD!\n");
+
+ /* Create the FDO */
+ Status = IoCreateDevice(DriverObject,
+ sizeof(FDO_EXTENSION),
+ NULL,
+ FILE_DEVICE_BUS_EXTENDER,
+ 0,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Should not happen */
+ DbgBreakPoint();
+ return Status;
+ }
+
+ /* Setup the FDO extension */
+ FdoExtension = DeviceObject->DeviceExtension;
+ FdoExtension->ExtensionType = FdoExtensionType;
+ FdoExtension->PhysicalDeviceObject = TargetDevice;
+ FdoExtension->FunctionalDeviceObject = DeviceObject;
+
+ /* FDO is done initializing */
+ DeviceObject->Flags &= DO_DEVICE_INITIALIZING;
+
+ /* Attach to the physical device object (the bus) */
+ AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject, TargetDevice);
+ if (!AttachedDevice)
+ {
+ /* Failed, undo everything */
+ IoDeleteDevice(DeviceObject);
+ return STATUS_NO_SUCH_DEVICE;
+ }
+
+ /* Save the attachment */
+ FdoExtension->AttachedDeviceObject = AttachedDevice;
+
+ /* Create the PDO */
+ Status = IoCreateDevice(DriverObject,
+ sizeof(PDO_EXTENSION),
+ NULL,
+ FILE_DEVICE_BUS_EXTENDER,
+ FILE_AUTOGENERATED_DEVICE_NAME,
+ FALSE,
+ &PdoDeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Fail */
+ DbgPrint("HAL: Could not create ACPI device object status=0x%08x\n", Status);
+ return Status;
+ }
+
+ /* Setup the PDO device extension */
+ PdoExtension = PdoDeviceObject->DeviceExtension;
+ PdoExtension->Next = NULL;
+ PdoExtension->ExtensionType = PdoExtensionType;
+ PdoExtension->PhysicalDeviceObject = PdoDeviceObject;
+ PdoExtension->ParentFdoExtension = FdoExtension;
+ PdoExtension->PdoType = AcpiPdo;
+
+ /* Find the ACPI watchdog table */
+ Wdrt = HalAcpiGetTable(0, 'TRDW');
+ if (!Wdrt)
+ {
+ /* None exists, there is nothing to do more */
+ PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING;
+ FdoExtension->ChildPdoList = PdoExtension;
+ }
+ else
+ {
+ /* FIXME: TODO */
+ DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n");
+ PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING;
+ FdoExtension->ChildPdoList = PdoExtension;
+ }
+
+ /* Return status */
+ DPRINT1("Device added %lx\n", Status);
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject,
+ IN CONST GUID* InterfaceType,
+ IN USHORT Version,
+ IN PVOID InterfaceSpecificData,
+ IN ULONG InterfaceBufferSize,
+ IN PINTERFACE Interface,
+ OUT PULONG Length)
+{
+ UNIMPLEMENTED;
+ while (TRUE);
+ return STATUS_NO_SUCH_DEVICE;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject,
+ IN DEVICE_RELATION_TYPE RelationType,
+ OUT PDEVICE_RELATIONS* DeviceRelations)
+{
+ EXTENSION_TYPE ExtensionType;
+ PPDO_EXTENSION PdoExtension;
+ PFDO_EXTENSION FdoExtension;
+ PDEVICE_RELATIONS PdoRelations, FdoRelations;
+ PDEVICE_OBJECT* ObjectEntry;
+ ULONG i = 0, PdoCount = 0;
+
+ /* Get FDO device extension and PDO count */
+ FdoExtension = DeviceObject->DeviceExtension;
+ ExtensionType = FdoExtension->ExtensionType;
+
+ /* What do they want? */
+ if (RelationType == BusRelations)
+ {
+ /* This better be an FDO */
+ if (ExtensionType == FdoExtensionType)
+ {
+ /* Count how many PDOs we have */
+ PdoExtension = FdoExtension->ChildPdoList;
+ while (PdoExtension)
+ {
+ /* Next one */
+ PdoExtension = PdoExtension->Next;
+ PdoCount++;
+ }
+
+ /* Allocate our structure */
+ FdoRelations = ExAllocatePoolWithTag(PagedPool,
+ FIELD_OFFSET(DEVICE_RELATIONS,
+ Objects) +
+ 4 * PdoCount,
+ ' laH');
+ if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Save our count */
+ FdoRelations->Count = PdoCount;
+
+ /* Query existing relations */
+ ObjectEntry = FdoRelations->Objects;
+ if (*DeviceRelations)
+ {
+ /* Check if there were any */
+ if ((*DeviceRelations)->Count)
+ {
+ /* Loop them all */
+ do
+ {
+ /* Copy into our structure */
+ *ObjectEntry++ = (*DeviceRelations)->Objects[i];
+ }
+ while (++i < (*DeviceRelations)->Count);
+ }
+
+ /* Free existing structure */
+ ExFreePoolWithTag(*DeviceRelations, 0);
+ }
+
+ /* Now check if we have a PDO list */
+ PdoExtension = FdoExtension->ChildPdoList;
+ if (PdoExtension)
+ {
+ /* Loop the PDOs */
+ do
+ {
+ /* Save our own PDO and reference it */
+ *ObjectEntry++ = PdoExtension->PhysicalDeviceObject;
+ ObfReferenceObject(PdoExtension->PhysicalDeviceObject);
+
+ /* Go to our next PDO */
+ PdoExtension = PdoExtension->Next;
+ }
+ while (PdoExtension);
+ }
+
+ /* Return the new structure */
+ *DeviceRelations = FdoRelations;
+ return STATUS_SUCCESS;
+ }
+ }
+ else
+ {
+ /* The only other thing we support is a target relation for the PDO */
+ if ((RelationType == TargetDeviceRelation) &&
+ (ExtensionType == PdoExtensionType))
+ {
+ /* Only one entry */
+ PdoRelations = ExAllocatePoolWithTag(PagedPool,
+ sizeof(DEVICE_RELATIONS),
+ ' laH');
+ if (!PdoRelations) return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Fill it out and reference us */
+ PdoRelations->Count = 1;
+ PdoRelations->Objects[0] = DeviceObject;
+ ObfReferenceObject(DeviceObject);
+
+ /* Return it */
+ *DeviceRelations = PdoRelations;
+ return STATUS_SUCCESS;
+ }
+ }
+
+ /* We don't support anything else */
+ return STATUS_NOT_SUPPORTED;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject,
+ OUT PDEVICE_CAPABILITIES Capabilities)
+{
+ PPDO_EXTENSION PdoExtension;
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Get the extension and check for valid version */
+ PdoExtension = DeviceObject->DeviceExtension;
+ ASSERT(Capabilities->Version == 1);
+ if (Capabilities->Version == 1)
+ {
+ /* Can't lock or eject us */
+ Capabilities->LockSupported = FALSE;
+ Capabilities->EjectSupported = FALSE;
+
+ /* Can't remove or dock us */
+ Capabilities->Removable = FALSE;
+ Capabilities->DockDevice = FALSE;
+
+ /* Can't access us raw */
+ Capabilities->RawDeviceOK = FALSE;
+
+ /* We have a unique ID, and don't bother the user */
+ Capabilities->UniqueID = TRUE;
+ Capabilities->SilentInstall = TRUE;
+
+ /* Fill out the adress */
+ Capabilities->Address = InterfaceTypeUndefined;
+ Capabilities->UINumber = InterfaceTypeUndefined;
+
+ /* Fill out latencies */
+ Capabilities->D1Latency = 0;
+ Capabilities->D2Latency = 0;
+ Capabilities->D3Latency = 0;
+
+ /* Fill out supported device states */
+ Capabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0;
+ Capabilities->DeviceState[PowerSystemHibernate] = PowerDeviceD3;
+ Capabilities->DeviceState[PowerSystemShutdown] = PowerDeviceD3;
+ Capabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3;
+
+ /* Done */
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ /* Fail */
+ Status = STATUS_NOT_SUPPORTED;
+ }
+
+ /* Return status */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
+ OUT PCM_RESOURCE_LIST *Resources)
+{
+ PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ NTSTATUS Status;
+ PCM_RESOURCE_LIST ResourceList;
+ PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
+ PIO_RESOURCE_DESCRIPTOR Descriptor;
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc;
+ ULONG i;
+ PAGED_CODE();
+
+ /* Only the ACPI PDO has requirements */
+ if (DeviceExtension->PdoType == AcpiPdo)
+ {
+ /* Query ACPI requirements */
+ Status = HalpQueryAcpiResourceRequirements(&RequirementsList);
+ ASSERT(RequirementsList->AlternativeLists == 1);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Allocate the resourcel ist */
+ ResourceList = ExAllocatePoolWithTag(PagedPool,
+ sizeof(CM_RESOURCE_LIST),
+ ' laH');
+ if (!ResourceList )
+ {
+ /* Fail, no memory */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ ExFreePoolWithTag(RequirementsList, 0);
+ return Status;
+ }
+
+ /* Initialize it */
+ RtlZeroMemory(ResourceList, sizeof(CM_RESOURCE_LIST));
+ ResourceList->Count = 1;
+
+ /* Setup the list fields */
+ ResourceList->List[0].BusNumber = -1;
+ ResourceList->List[0].InterfaceType = PNPBus;
+ ResourceList->List[0].PartialResourceList.Version = 1;
+ ResourceList->List[0].PartialResourceList.Revision = 1;
+ ResourceList->List[0].PartialResourceList.Count = 1;
+
+ /* Setup the first descriptor */
+ PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
+ PartialDesc->Type = CmResourceTypeInterrupt;
+
+ /* Find the requirement descriptor for the SCI */
+ for (i = 0; i < RequirementsList->List[0].Count; i++)
+ {
+ /* Get this descriptor */
+ Descriptor = &RequirementsList->List[0].Descriptors[i];
+ if (Descriptor->Type == CmResourceTypeInterrupt) break;
+ Descriptor = NULL;
+ }
+
+ /* Make sure we found the descriptor */
+ if (Descriptor)
+ {
+ /* Copy requirements descriptor into resource descriptor */
+ PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
+ PartialDesc->Flags = Descriptor->Flags;
+ ASSERT(Descriptor->u.Interrupt.MinimumVector ==
+ Descriptor->u.Interrupt.MaximumVector);
+ PartialDesc->u.Interrupt.Vector = Descriptor->u.Interrupt.MinimumVector;
+ PartialDesc->u.Interrupt.Level = Descriptor->u.Interrupt.MinimumVector;
+ PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
+
+ /* Return resources and success */
+ *Resources = ResourceList;
+ ExFreePoolWithTag(RequirementsList, 0);
+ return STATUS_SUCCESS;
+ }
+
+ /* Free memory and fail */
+ ExFreePoolWithTag(RequirementsList, 0);
+ ExFreePoolWithTag(ResourceList, 0);
+ Status = STATUS_NOT_FOUND;
+ }
+ else if (DeviceExtension->PdoType == WdPdo)
+ {
+ /* Watchdog doesn't */
+ return STATUS_NOT_SUPPORTED;
+ }
+ else
+ {
+ /* This shouldn't happen */
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Return the status */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject,
+ OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
+{
+ PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Only the ACPI PDO has requirements */
+ if (DeviceExtension->PdoType == AcpiPdo)
+ {
+ /* Query ACPI requirements */
+ Status = HalpQueryAcpiResourceRequirements(Requirements);
+ }
+ else if (DeviceExtension->PdoType == WdPdo)
+ {
+ /* Watchdog doesn't */
+ return STATUS_NOT_SUPPORTED;
+ }
+ else
+ {
+ /* This shouldn't happen */
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Return the status */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject,
+ IN BUS_QUERY_ID_TYPE IdType,
+ OUT PUSHORT *BusQueryId)
+{
+ PPDO_EXTENSION PdoExtension;
+ PDO_TYPE PdoType;
+ PWCHAR Id;
+ NTSTATUS Status;
+ ULONG Length;
+ PWCHAR Buffer;
+
+ /* Get the PDO type */
+ PdoExtension = DeviceObject->DeviceExtension;
+ PdoType = PdoExtension->PdoType;
+
+ /* What kind of ID is being requested? */
+ DPRINT("ID: %d\n", IdType);
+ switch (IdType)
+ {
+ case BusQueryDeviceID:
+ case BusQueryHardwareIDs:
+
+ /* What kind of PDO is this? */
+ if (PdoType == AcpiPdo)
+ {
+ /* PCI ID */
+ Id = L"ACPI_HAL\\PNP0C08";
+ }
+ else if (PdoType == WdPdo)
+ {
+ /* WatchDog ID */
+ Id = L"ACPI_HAL\\PNP0C18";
+ }
+ else
+ {
+ /* Unknown */
+ return STATUS_NOT_SUPPORTED;
+ }
+
+ /* Static length */
+ Length = 32;
+ break;
+
+ case BusQueryInstanceID:
+
+ /* And our instance ID */
+ Id = L"0";
+ Length = sizeof(L"0") + sizeof(UNICODE_NULL);
+ break;
+
+ case BusQueryCompatibleIDs:
+ default:
+
+ /* We don't support anything else */
+ return STATUS_NOT_SUPPORTED;
+ }
+
+ /* Allocate the buffer */
+ Buffer = ExAllocatePoolWithTag(PagedPool,
+ Length + sizeof(UNICODE_NULL),
+ ' laH');
+ if (Buffer)
+ {
+ /* Copy the string and null-terminate it */
+ RtlCopyMemory(Buffer, Id, Length);
+ Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ /* Return string */
+ *BusQueryId = Buffer;
+ Status = STATUS_SUCCESS;
+ DPRINT("Returning: %S\n", *BusQueryId);
+ }
+ else
+ {
+ /* Fail */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Return status */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject,
+ IN BUS_QUERY_ID_TYPE IdType,
+ OUT PUSHORT *BusQueryId)
+{
+ NTSTATUS Status;
+ ULONG Length;
+ PWCHAR Id;
+ PWCHAR Buffer;
+
+ /* What kind of ID is being requested? */
+ DPRINT("ID: %d\n", IdType);
+ switch (IdType)
+ {
+ case BusQueryDeviceID:
+ case BusQueryHardwareIDs:
+
+ /* This is our hardware ID */
+ Id = HalHardwareIdString;
+ Length = wcslen(HalHardwareIdString) + sizeof(UNICODE_NULL);
+ break;
+
+ case BusQueryInstanceID:
+
+ /* And our instance ID */
+ Id = L"0";
+ Length = sizeof(L"0") + sizeof(UNICODE_NULL);
+ break;
+
+ default:
+
+ /* We don't support anything else */
+ return STATUS_NOT_SUPPORTED;
+ }
+
+ /* Allocate the buffer */
+ Buffer = ExAllocatePoolWithTag(PagedPool,
+ Length + sizeof(UNICODE_NULL),
+ ' laH');
+ if (Buffer)
+ {
+ /* Copy the string and null-terminate it */
+ RtlCopyMemory(Buffer, Id, Length);
+ Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
+
+ /* Return string */
+ *BusQueryId = Buffer;
+ Status = STATUS_SUCCESS;
+ DPRINT("Returning: %S\n", *BusQueryId);
+ }
+ else
+ {
+ /* Fail */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Return status */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HalpPassIrpFromFdoToPdo(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PFDO_EXTENSION FdoExtension;
+
+ /* Get the extension */
+ FdoExtension = DeviceObject->DeviceExtension;
+
+ /* Pass it to the attached device (our PDO) */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(FdoExtension->AttachedDeviceObject, Irp);
+}
+
+NTSTATUS
+NTAPI
+HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ PIO_STACK_LOCATION IoStackLocation;
+ PPDO_EXTENSION PdoExtension;
+ PFDO_EXTENSION FdoExtension;
+ NTSTATUS Status;
+ UCHAR Minor;
+
+ /* Get the device extension and stack location */
+ FdoExtension = DeviceObject->DeviceExtension;
+ IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
+ Minor = IoStackLocation->MinorFunction;
+
+ /* FDO? */
+ if (FdoExtension->ExtensionType == FdoExtensionType)
+ {
+ /* Query the IRP type */
+ switch (Minor)
+ {
+ case IRP_MN_QUERY_DEVICE_RELATIONS:
+
+ /* Call the worker */
+ DPRINT("Querying device relations for FDO\n");
+ Status = HalpQueryDeviceRelations(DeviceObject,
+ IoStackLocation->Parameters.QueryDeviceRelations.Type,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ case IRP_MN_QUERY_INTERFACE:
+
+ /* Call the worker */
+ DPRINT("Querying interface for FDO\n");
+ Status = HalpQueryInterface(DeviceObject,
+ IoStackLocation->Parameters.QueryInterface.InterfaceType,
+ IoStackLocation->Parameters.QueryInterface.Size,
+ IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
+ IoStackLocation->Parameters.QueryInterface.Version,
+ IoStackLocation->Parameters.QueryInterface.Interface,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+
+ case IRP_MN_QUERY_ID:
+
+ /* Call the worker */
+ DPRINT("Querying ID for FDO\n");
+ Status = HalpQueryIdFdo(DeviceObject,
+ IoStackLocation->Parameters.QueryId.IdType,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ default:
+
+ /* Pass it to the PDO */
+ DPRINT("Other IRP: %lx\n", Minor);
+ return HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
+ }
+
+ /* What happpened? */
+ if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED))
+ {
+ /* Set the IRP status, unless this isn't understood */
+ if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
+
+ /* Pass it on */
+ DPRINT("Passing IRP to PDO\n");
+ return HalpPassIrpFromFdoToPdo(DeviceObject, Irp);
+ }
+
+ /* Otherwise, we failed, so set the status and complete the request */
+ DPRINT1("IRP failed with status: %lx\n", Status);
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+ else
+ {
+ /* This is a PDO instead */
+ ASSERT(FdoExtension->ExtensionType == PdoExtensionType);
+ PdoExtension = (PPDO_EXTENSION)FdoExtension;
+
+ /* Query the IRP type */
+ Status = STATUS_SUCCESS;
+ switch (Minor)
+ {
+ case IRP_MN_START_DEVICE:
+
+ /* We only care about a PCI PDO */
+ DPRINT1("Start device received\n");
+ /* Complete the IRP normally */
+ break;
+
+ case IRP_MN_REMOVE_DEVICE:
+
+ /* Check if this is a PCI device */
+ DPRINT1("Remove device received\n");
+
+ /* We're done */
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IRP_MN_SURPRISE_REMOVAL:
+
+ /* Inherit whatever status we had */
+ DPRINT1("Surprise removal IRP\n");
+ Status = Irp->IoStatus.Status;
+ break;
+
+ case IRP_MN_QUERY_DEVICE_RELATIONS:
+
+ /* Query the device relations */
+ DPRINT("Querying PDO relations\n");
+ Status = HalpQueryDeviceRelations(DeviceObject,
+ IoStackLocation->Parameters.QueryDeviceRelations.Type,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ case IRP_MN_QUERY_INTERFACE:
+
+ /* Call the worker */
+ DPRINT("Querying interface for PDO\n");
+ Status = HalpQueryInterface(DeviceObject,
+ IoStackLocation->Parameters.QueryInterface.InterfaceType,
+ IoStackLocation->Parameters.QueryInterface.Size,
+ IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData,
+ IoStackLocation->Parameters.QueryInterface.Version,
+ IoStackLocation->Parameters.QueryInterface.Interface,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ case IRP_MN_QUERY_CAPABILITIES:
+
+ /* Call the worker */
+ DPRINT("Querying the capabilities for the PDO\n");
+ Status = HalpQueryCapabilities(DeviceObject,
+ IoStackLocation->Parameters.DeviceCapabilities.Capabilities);
+ break;
+
+ case IRP_MN_QUERY_RESOURCES:
+
+ /* Call the worker */
+ DPRINT("Querying the resources for the PDO\n");
+ Status = HalpQueryResources(DeviceObject, (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
+
+ /* Call the worker */
+ DPRINT("Querying the resource requirements for the PDO\n");
+ Status = HalpQueryResourceRequirements(DeviceObject,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ case IRP_MN_QUERY_ID:
+
+ /* Call the worker */
+ DPRINT("Query the ID for the PDO\n");
+ Status = HalpQueryIdPdo(DeviceObject,
+ IoStackLocation->Parameters.QueryId.IdType,
+ (PVOID)&Irp->IoStatus.Information);
+ break;
+
+ default:
+
+ /* We don't handle anything else, so inherit the old state */
+ DPRINT("Illegal IRP: %lx\n", Minor);
+ Status = Irp->IoStatus.Status;
+ break;
+ }
+
+ /* If it's not supported, inherit the old status */
+ if (Status == STATUS_NOT_SUPPORTED) Status = Irp->IoStatus.Status;
+
+ /* Complete the IRP */
+ DPRINT("IRP completed with status: %lx\n", Status);
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+}
+
+NTSTATUS
+NTAPI
+HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DbgPrint("HAL: PnP Driver WMI!\n");
+ while (TRUE);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
+{
+ DbgPrint("HAL: PnP Driver Power!\n");
+ while (TRUE);
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+HalpDriverEntry(IN PDRIVER_OBJECT DriverObject,
+ IN PUNICODE_STRING RegistryPath)
+{
+ NTSTATUS Status;
+ PDEVICE_OBJECT TargetDevice = NULL;
+ DPRINT("HAL: PnP Driver ENTRY!\n");
+
+ /* This is us */
+ HalpDriverObject = DriverObject;
+
+ /* Set up add device */
+ DriverObject->DriverExtension->AddDevice = HalpAddDevice;
+
+ /* Set up the callouts */
+ DriverObject->MajorFunction[IRP_MJ_PNP] = HalpDispatchPnp;
+ DriverObject->MajorFunction[IRP_MJ_POWER] = HalpDispatchPower;
+ DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HalpDispatchWmi;
+
+ /* Tell the PnP about us */
+ Status = IoReportDetectedDevice(DriverObject,
+ InterfaceTypeUndefined,
+ -1,
+ -1,
+ NULL,
+ NULL,
+ FALSE,
+ &TargetDevice);
+
+ /* Now add us */
+ if (NT_SUCCESS(Status)) Status = HalpAddDevice(DriverObject, TargetDevice);
+
+ /* Force re-enumeration??? */
+ IoInvalidateDeviceRelations(TargetDevice, 0);
+
+ /* Return to kernel */
+ return Status;
+}
+
+NTSTATUS
+NTAPI
+HaliInitPnpDriver(VOID)
+{
+ NTSTATUS Status;
+ UNICODE_STRING DriverString;
+ PAGED_CODE();
+
+ /* Create the driver */
+ RtlInitUnicodeString(&DriverString, L"\\Driver\\ACPI_HAL");
+ Status = IoCreateDriver(&DriverString, HalpDriverEntry);
+
+ /* Return status */
+ return Status;
+}
+
+/* EOF */
/* GLOBALS *******************************************************************/
+PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}};
+
BOOLEAN HalpPCIConfigInitialized;
ULONG HalpMinPciBus, HalpMaxPciBus;
KSPIN_LOCK HalpPCIConfigLock;
return STATUS_NOT_IMPLEMENTED;
}
+VOID
+NTAPI
+HalpRegisterPciDebuggingDeviceInfo(VOID)
+{
+ BOOLEAN Found = FALSE;
+ ULONG i;
+ PAGED_CODE();
+
+ /* Loop PCI debugging devices */
+ for (i = 0; i < 2; i++)
+ {
+ /* Reserved bit is set if we found one */
+ if (HalpPciDebuggingDevice[i].u.bits.Reserved1)
+ {
+ Found = TRUE;
+ break;
+ }
+ }
+
+ /* Bail out if there aren't any */
+ if (!Found) return;
+
+ /* FIXME: TODO */
+ DPRINT1("You have implemented the KD routines for searching PCI debugger"
+ "devices, but you have forgotten to implement this routine\n");
+ while (TRUE);
+}
+
static ULONG NTAPI
PciSize(ULONG Base, ULONG Mask)
{
HalpPCIConfigInitialized = TRUE;
}
-VOID
-NTAPI
-HalpInitializePciBus(VOID)
-{
- /* FIXME: Initialize NMI Crash Flag */
-}
/* GLOBALS *******************************************************************/
+/* Share with Mm headers? */
+#define MM_HAL_VA_START (PVOID)0xFFC00000
+#define MM_HAL_HEAP_START (PVOID)((ULONG_PTR)MM_HAL_VA_START + (1024 * 1024))
+
BOOLEAN HalpPciLockSettings;
+ULONG HalpUsedAllocDescriptors;
+MEMORY_ALLOCATION_DESCRIPTOR HalpAllocationDescriptorArray[64];
+PVOID HalpHeapStart = MM_HAL_HEAP_START;
/* PRIVATE FUNCTIONS *********************************************************/
+ULONG
+NTAPI
+HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG MaxAddress,
+ IN ULONG PageCount,
+ IN BOOLEAN Aligned)
+{
+ ULONG UsedDescriptors, Alignment, PhysicalAddress;
+ PFN_NUMBER MaxPage, BasePage;
+ PLIST_ENTRY NextEntry;
+ PMEMORY_ALLOCATION_DESCRIPTOR MdBlock, NewBlock, FreeBlock;
+
+ /* Highest page we'll go */
+ MaxPage = MaxAddress >> PAGE_SHIFT;
+
+ /* We need at least two blocks */
+ if ((HalpUsedAllocDescriptors + 2) > 64) return 0;
+
+ /* Remember how many we have now */
+ UsedDescriptors = HalpUsedAllocDescriptors;
+
+ /* Loop the loader block memory descriptors */
+ NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
+ while (NextEntry != &LoaderBlock->MemoryDescriptorListHead)
+ {
+ /* Get the block */
+ MdBlock = CONTAINING_RECORD(NextEntry,
+ MEMORY_ALLOCATION_DESCRIPTOR,
+ ListEntry);
+
+ /* No alignment by default */
+ Alignment = 0;
+
+ /* Unless requested, in which case we use a 64KB block alignment */
+ if (Aligned) Alignment = ((MdBlock->BasePage + 0x0F) & ~0x0F) - MdBlock->BasePage;
+
+ /* Search for free memory */
+ if ((MdBlock->MemoryType == LoaderFree) ||
+ (MdBlock->MemoryType == MemoryFirmwareTemporary))
+ {
+ /* Make sure the page is within bounds, including alignment */
+ BasePage = MdBlock->BasePage;
+ if ((BasePage) &&
+ (MdBlock->PageCount >= PageCount + Alignment) &&
+ (BasePage + PageCount + Alignment < MaxPage))
+ {
+
+ /* We found an address */
+ PhysicalAddress = (BasePage + Alignment) << PAGE_SHIFT;
+ break;
+ }
+ }
+
+ /* Keep trying */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* If we didn't find anything, get out of here */
+ if (NextEntry == &LoaderBlock->MemoryDescriptorListHead) return 0;
+
+ /* Okay, now get a descriptor */
+ NewBlock = &HalpAllocationDescriptorArray[HalpUsedAllocDescriptors];
+ NewBlock->PageCount = PageCount;
+ NewBlock->BasePage = MdBlock->BasePage + Alignment;
+ NewBlock->MemoryType = LoaderHALCachedMemory;
+
+ /* Update count */
+ UsedDescriptors++;
+ HalpUsedAllocDescriptors = UsedDescriptors;
+
+ /* Check if we had any alignment */
+ if (Alignment)
+ {
+ /* Check if we had leftovers */
+ if ((MdBlock->PageCount - Alignment) != PageCount)
+ {
+ /* Get the next descriptor */
+ FreeBlock = &HalpAllocationDescriptorArray[UsedDescriptors];
+ FreeBlock->PageCount = MdBlock->PageCount - Alignment - PageCount;
+ FreeBlock->BasePage = MdBlock->BasePage + Alignment + PageCount;
+
+ /* One more */
+ HalpUsedAllocDescriptors++;
+
+ /* Insert it into the list */
+ InsertHeadList(&MdBlock->ListEntry, &FreeBlock->ListEntry);
+ }
+
+ /* Use this descriptor */
+ NewBlock->PageCount = Alignment;
+ InsertHeadList(&MdBlock->ListEntry, &NewBlock->ListEntry);
+ }
+ else
+ {
+ /* Consume memory from this block */
+ MdBlock->BasePage += PageCount;
+ MdBlock->PageCount -= PageCount;
+
+ /* Insert the descriptor */
+ InsertTailList(&MdBlock->ListEntry, &NewBlock->ListEntry);
+
+ /* Remove the entry if the whole block was allocated */
+ if (!MdBlock->PageCount == 0) RemoveEntryList(&MdBlock->ListEntry);
+ }
+
+ /* Return the address */
+ return PhysicalAddress;
+}
+
+PVOID
+NTAPI
+HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN ULONG PageCount)
+{
+ PHARDWARE_PTE PointerPte;
+ ULONG UsedPages = 0;
+ PVOID VirtualAddress, BaseAddress;
+
+ /* Start at the current HAL heap base */
+ BaseAddress = HalpHeapStart;
+
+ /* Loop until we have all the pages required */
+ while (UsedPages < PageCount)
+ {
+ /* Begin a new loop cycle */
+ UsedPages = 0;
+ VirtualAddress = BaseAddress;
+
+ /* If this overflows past the HAL heap, it means there's no space */
+ if (BaseAddress == NULL) return NULL;
+
+ /* Loop until we have all the pages required in a single run */
+ while (UsedPages < PageCount)
+ {
+ /* Get the PTE for this address and check if it's available */
+ PointerPte = HalAddressToPte(VirtualAddress);
+ if (*(PULONG)PointerPte)
+ {
+ /* PTE has data, skip it and start with a new base address */
+ BaseAddress = (PVOID)((ULONG_PTR)VirtualAddress + PAGE_SIZE);
+ break;
+ }
+
+ /* PTE is available, keep going on this run */
+ VirtualAddress = (PVOID)((ULONG_PTR)VirtualAddress + PAGE_SIZE);
+ UsedPages++;
+ }
+ }
+
+ /* Take the base address of the page plus the actual offset in the address */
+ VirtualAddress = (PVOID)((ULONG_PTR)BaseAddress +
+ BYTE_OFFSET(PhysicalAddress.LowPart));
+
+ /* If we are starting at the heap, move the heap */
+ if (BaseAddress == HalpHeapStart)
+ {
+ /* Past this allocation */
+ HalpHeapStart = (PVOID)((ULONG_PTR)BaseAddress + (PageCount * PAGE_SIZE));
+ }
+
+ /* Loop pages that can be mapped */
+ while (UsedPages--)
+ {
+ /* Fill out the PTE */
+ PointerPte = HalAddressToPte(BaseAddress);
+ PointerPte->PageFrameNumber = PhysicalAddress.QuadPart >> PAGE_SHIFT;
+ PointerPte->Valid = 1;
+ PointerPte->Write = 1;
+
+ /* Move to the next address */
+ PhysicalAddress.QuadPart += PAGE_SIZE;
+ BaseAddress = (PVOID)((ULONG_PTR)BaseAddress + PAGE_SIZE);
+ }
+
+ /* Flush the TLB and return the address */
+ HalpFlushTLB();
+ return VirtualAddress;
+}
+
+VOID
+NTAPI
+HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
+ IN ULONG PageCount)
+{
+ PHARDWARE_PTE PointerPte;
+ ULONG i;
+
+ /* Only accept valid addresses */
+ if (VirtualAddress < MM_HAL_VA_START) return;
+
+ /* Align it down to page size */
+ VirtualAddress = (PVOID)((ULONG_PTR)VirtualAddress & ~(PAGE_SIZE - 1));
+
+ /* Loop PTEs */
+ PointerPte = HalAddressToPte(VirtualAddress);
+ for (i = 0; i < PageCount; i++)
+ {
+ *(PULONG)PointerPte = 0;
+ PointerPte++;
+ }
+
+ /* Flush the TLB */
+ HalpFlushTLB();
+
+ /* Put the heap back */
+ if (HalpHeapStart > VirtualAddress) HalpHeapStart = VirtualAddress;
+}
+
VOID
NTAPI
HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
}
#ifndef _MINIHAL_
+ /* Initialize ACPI */
+ HalpSetupAcpiPhase0(LoaderBlock);
+
/* Initialize the PICs */
HalpInitializePICs(TRUE);
#endif
--- /dev/null
+/*
+ * PROJECT: ReactOS HAL
+ * LICENSE: BSD - See COPYING.ARM in the top level directory
+ * FILE: hal/halx86/generic/acpi/halpcat.c
+ * PURPOSE: HAL Legacy Support Code
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* GLOBALS ********************************************************************/
+
+/* This determines the HAL type */
+BOOLEAN HalDisableFirmwareMapper = FALSE;
+PWCHAR HalHardwareIdString = L"e_isa_up";
+PWCHAR HalName = L"PC Compatible Eisa/Isa HAL";
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+NTSTATUS
+NTAPI
+HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
+{
+ /* There is no ACPI on these HALs */
+ return STATUS_NO_SUCH_DEVICE;
+}
+
+VOID
+NTAPI
+HalpInitializePciBus(VOID)
+{
+ /* FIXME: Should do legacy PCI bus detection */
+
+ /* FIXME: Should detect chipset hacks */
+
+ /* FIXME: Should detect broken PCI hardware and apply hacks */
+
+ /* FIXME: Should build resource ranges */
+}
+
+VOID
+NTAPI
+HalpBuildAddressMap(VOID)
+{
+ /* FIXME: Inherit ROM blocks from the registry */
+ //HalpInheritROMBlocks();
+
+ /* FIXME: Add the ROM blocks to our ranges */
+ //HalpAddROMRanges();
+}
+
+BOOLEAN
+NTAPI
+HalpGetDebugPortTable(VOID)
+{
+ /* No ACPI */
+ return FALSE;
+}
+
+ULONG
+NTAPI
+HalpIs16BitPortDecodeSupported(VOID)
+{
+ /* Only EISA systems support this */
+ return (HalpBusType == MACHINE_TYPE_EISA) ? CM_RESOURCE_PORT_16_BIT_DECODE : 0;
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+HalReportResourceUsage(VOID)
+{
+ INTERFACE_TYPE InterfaceType;
+ UNICODE_STRING HalString;
+
+ /* FIXME: Initialize MCA bus */
+
+ /* Initialize PCI bus. */
+ HalpInitializePciBus();
+
+ /* Initialize the stubs */
+ HalpInitializePciStubs();
+
+ /* What kind of bus is this? */
+ switch (HalpBusType)
+ {
+ /* ISA Machine */
+ case MACHINE_TYPE_ISA:
+ InterfaceType = Isa;
+ break;
+
+ /* EISA Machine */
+ case MACHINE_TYPE_EISA:
+ InterfaceType = Eisa;
+ break;
+
+ /* MCA Machine */
+ case MACHINE_TYPE_MCA:
+ InterfaceType = MicroChannel;
+ break;
+
+ /* Unknown */
+ default:
+ InterfaceType = Internal;
+ break;
+ }
+
+ /* Build HAL usage */
+ RtlInitUnicodeString(&HalString, HalName);
+ HalpReportResourceUsage(&HalString, InterfaceType);
+
+ /* Setup PCI debugging and Hibernation */
+ HalpRegisterPciDebuggingDeviceInfo();
+}
+
+/* EOF */
BOOLEAN HalpNMIInProgress;
+UCHAR HalpSerialLen;
+CHAR HalpSerialNumber[31];
+
/* PRIVATE FUNCTIONS **********************************************************/
+#ifndef _MINIHAL_
VOID
NTAPI
-HalpCheckPowerButton(VOID)
+HalpReportSerialNumber(VOID)
{
- //
- // Nothing to do on non-ACPI
- //
- return;
+ NTSTATUS Status;
+ UNICODE_STRING KeyString;
+ HANDLE Handle;
+
+ /* Make sure there is a serial number */
+ if (!HalpSerialLen) return;
+
+ /* Open the system key */
+ RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
+ Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE);
+ if (NT_SUCCESS(Status))
+ {
+ /* Add the serial number */
+ RtlInitUnicodeString(&KeyString, L"Serial Number");
+ ZwSetValueKey(Handle,
+ &KeyString,
+ 0,
+ REG_BINARY,
+ HalpSerialNumber,
+ HalpSerialLen);
+
+ /* Close the handle */
+ ZwClose(Handle);
+ }
}
-#ifndef _MINIHAL_
-PVOID
+NTSTATUS
NTAPI
-HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
- IN ULONG NumberPage)
+HalpMarkAcpiHal(VOID)
{
- //
- // Use kernel memory manager I/O map facilities
- //
- return MmMapIoSpace(PhysicalAddress,
- NumberPage << PAGE_SHIFT,
- MmNonCached);
+ NTSTATUS Status;
+ UNICODE_STRING KeyString;
+ HANDLE KeyHandle;
+ HANDLE Handle;
+
+ /* Open the control set key */
+ RtlInitUnicodeString(&KeyString,
+ L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
+ Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE);
+ if (NT_SUCCESS(Status))
+ {
+ /* Open the PNP key */
+ RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
+ Status = HalpOpenRegistryKey(&KeyHandle,
+ Handle,
+ &KeyString,
+ KEY_ALL_ACCESS,
+ TRUE);
+ /* Close root key */
+ ZwClose(Handle);
+
+ /* Check if PNP BIOS key exists */
+ if (NT_SUCCESS(Status))
+ {
+ /* Set the disable value to false -- we need the mapper */
+ RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
+ Status = ZwSetValueKey(KeyHandle,
+ &KeyString,
+ 0,
+ REG_DWORD,
+ &HalDisableFirmwareMapper,
+ sizeof(HalDisableFirmwareMapper));
+
+ /* Close subkey */
+ ZwClose(KeyHandle);
+ }
+ }
+
+ /* Return status */
+ return Status;
}
+NTSTATUS
+NTAPI
+HalpOpenRegistryKey(IN PHANDLE KeyHandle,
+ IN HANDLE RootKey,
+ IN PUNICODE_STRING KeyName,
+ IN ACCESS_MASK DesiredAccess,
+ IN BOOLEAN Create)
+{
+ NTSTATUS Status;
+ ULONG Disposition;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+
+ /* Setup the attributes we received */
+ InitializeObjectAttributes(&ObjectAttributes,
+ KeyName,
+ OBJ_CASE_INSENSITIVE,
+ RootKey,
+ NULL);
+
+ /* What to do? */
+ if ( Create )
+ {
+ /* Create the key */
+ Status = ZwCreateKey(KeyHandle,
+ DesiredAccess,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ }
+ else
+ {
+ /* Open the key */
+ Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes);
+ }
+
+ /* We're done */
+ return Status;
+}
+#endif
+
VOID
NTAPI
-HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
- IN ULONG NumberPages)
+HalpCheckPowerButton(VOID)
{
//
- // Use kernel memory manager I/O map facilities
+ // Nothing to do on non-ACPI
//
- MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
+ return;
}
-#endif
VOID
NTAPI
/* GLOBALS ********************************************************************/
+BOOLEAN HalpGetInfoFromACPI;
+BOOLEAN HalpNMIDumpFlag;
PUCHAR KdComPortInUse;
PADDRESS_USAGE HalpAddressUsageList;
IDTUsageFlags HalpIDTUsageFlags[MAXIMUM_IDTVECTOR];
IDTUsage HalpIDTUsage[MAXIMUM_IDTVECTOR];
+USHORT HalpComPortIrqMapping[5][2] =
+{
+ {0x3F8, 4},
+ {0x2F8, 3},
+ {0x3E8, 4},
+ {0x2E8, 3},
+ {0, 0}
+};
+
+ADDRESS_USAGE HalpComIoSpace =
+{
+ NULL, CmResourceTypePort, IDT_INTERNAL,
+ {
+ {0x2F8, 0x8}, /* COM 1 */
+ {0,0},
+ }
+};
+
ADDRESS_USAGE HalpDefaultIoSpace =
{
NULL, CmResourceTypePort, IDT_INTERNAL,
{
- {0x2000, 0xC000}, /* PIC?? */
+ {0x2000, 0xC000}, /* Everything */
{0xC000, 0x1000}, /* DMA 2 */
{0x8000, 0x1000}, /* DMA 1 */
{0x2000, 0x200}, /* PIC 1 */
{0xA000, 0x200}, /* PIC 2 */
{0x4000, 0x400}, /* PIT 1 */
{0x4800, 0x400}, /* PIT 2 */
- {0x9200, 0x100}, /* ????? */
+ {0x9200, 0x100}, /* System Control Port A */
{0x7000, 0x200}, /* CMOS */
- {0xF000, 0x1000}, /* ????? */
+ {0xF000, 0x1000}, /* x87 Coprocessor */
{0xCF800, 0x800}, /* PCI 0 */
{0,0},
}
/* FUNCTIONS ******************************************************************/
+#ifndef _MINIHAL_
+VOID
+NTAPI
+HalpGetResourceSortValue(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor,
+ OUT PULONG Scale,
+ OUT PLARGE_INTEGER Value)
+{
+ /* Sorting depends on resource type */
+ switch (Descriptor->Type)
+ {
+ case CmResourceTypeInterrupt:
+
+ /* Interrupt goes by level */
+ *Scale = 0;
+ *Value = RtlConvertUlongToLargeInteger(Descriptor->u.Interrupt.Level);
+ break;
+
+ case CmResourceTypePort:
+
+ /* Port goes by port address */
+ *Scale = 1;
+ *Value = Descriptor->u.Port.Start;
+ break;
+
+ case CmResourceTypeMemory:
+
+ /* Memory goes by base address */
+ *Scale = 2;
+ *Value = Descriptor->u.Memory.Start;
+ break;
+
+ default:
+
+ /* Anything else */
+ *Scale = 4;
+ *Value = RtlConvertUlongToLargeInteger(0);
+ break;
+ }
+}
+
+VOID
+NTAPI
+HalpBuildPartialFromIdt(IN ULONG Entry,
+ IN PCM_PARTIAL_RESOURCE_DESCRIPTOR RawDescriptor,
+ IN PCM_PARTIAL_RESOURCE_DESCRIPTOR TranslatedDescriptor)
+{
+ /* Exclusive interrupt entry */
+ RawDescriptor->Type = CmResourceTypeInterrupt;
+ RawDescriptor->ShareDisposition = CmResourceShareDriverExclusive;
+
+ /* Check the interrupt type */
+ if (HalpIDTUsageFlags[Entry].Flags & IDT_LATCHED)
+ {
+ /* Latched */
+ RawDescriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
+ }
+ else
+ {
+ /* Level */
+ RawDescriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+ }
+
+ /* Get vector and level from IDT usage */
+ RawDescriptor->u.Interrupt.Vector = HalpIDTUsage[Entry].BusReleativeVector;
+ RawDescriptor->u.Interrupt.Level = HalpIDTUsage[Entry].BusReleativeVector;
+
+ /* Affinity is all the CPUs */
+ RawDescriptor->u.Interrupt.Affinity = HalpActiveProcessors;
+
+ /* The translated copy is identical */
+ RtlCopyMemory(TranslatedDescriptor, RawDescriptor, sizeof(TranslatedDescriptor));
+
+ /* But the vector and IRQL must be set correctly */
+ TranslatedDescriptor->u.Interrupt.Vector = Entry;
+ TranslatedDescriptor->u.Interrupt.Level = HalpIDTUsage[Entry].Irql;
+}
+
+VOID
+NTAPI
+HalpBuildPartialFromAddress(IN INTERFACE_TYPE Interface,
+ IN PADDRESS_USAGE CurrentAddress,
+ IN ULONG Element,
+ IN PCM_PARTIAL_RESOURCE_DESCRIPTOR RawDescriptor,
+ IN PCM_PARTIAL_RESOURCE_DESCRIPTOR TranslatedDescriptor)
+{
+ ULONG AddressSpace;
+
+ /* Set the type and make it exclusive */
+ RawDescriptor->Type = CurrentAddress->Type;
+ RawDescriptor->ShareDisposition = CmResourceShareDriverExclusive;
+
+ /* Check what this is */
+ if (RawDescriptor->Type == CmResourceTypePort)
+ {
+ /* Write out port data */
+ AddressSpace = 1;
+ RawDescriptor->Flags = CM_RESOURCE_PORT_IO;
+ RawDescriptor->u.Port.Start.HighPart = 0;
+ RawDescriptor->u.Port.Start.LowPart = CurrentAddress->Element[Element].Start;
+ RawDescriptor->u.Port.Length = CurrentAddress->Element[Element].Length;
+
+ /* Determine if 16-bit port addresses are allowed */
+ RawDescriptor->Flags |= HalpIs16BitPortDecodeSupported();
+ }
+ else
+ {
+ /* Write out memory data */
+ AddressSpace = 0;
+ RawDescriptor->Flags = (CurrentAddress->Flags & IDT_READ_ONLY) ?
+ CM_RESOURCE_MEMORY_READ_ONLY :
+ CM_RESOURCE_MEMORY_READ_WRITE;
+ RawDescriptor->u.Memory.Start.HighPart = 0;
+ RawDescriptor->u.Memory.Start.LowPart = CurrentAddress->Element[Element].Start;
+ RawDescriptor->u.Memory.Length = CurrentAddress->Element[Element].Length;
+ }
+
+ /* Make an identical copy to begin with */
+ RtlCopyMemory(TranslatedDescriptor, RawDescriptor, sizeof(TranslatedDescriptor));
+
+ /* Check what this is */
+ if (RawDescriptor->Type == CmResourceTypePort)
+ {
+ /* Translate the port */
+ HalTranslateBusAddress(Interface,
+ 0,
+ RawDescriptor->u.Port.Start,
+ &AddressSpace,
+ &TranslatedDescriptor->u.Port.Start);
+
+ /* If it turns out this is memory once translated, flag it */
+ if (AddressSpace == 0) TranslatedDescriptor->Flags = CM_RESOURCE_PORT_MEMORY;
+
+ }
+ else
+ {
+ /* Translate the memory */
+ HalTranslateBusAddress(Interface,
+ 0,
+ RawDescriptor->u.Memory.Start,
+ &AddressSpace,
+ &TranslatedDescriptor->u.Memory.Start);
+ }
+}
+
VOID
NTAPI
HalpReportResourceUsage(IN PUNICODE_STRING HalName,
IN INTERFACE_TYPE InterfaceType)
{
- DbgPrint("%wZ has been initialized\n", HalName);
+ PCM_RESOURCE_LIST RawList, TranslatedList;
+ PCM_FULL_RESOURCE_DESCRIPTOR RawFull, TranslatedFull;
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR CurrentRaw, CurrentTranslated, SortedRaw, SortedTranslated;
+ CM_PARTIAL_RESOURCE_DESCRIPTOR RawPartial, TranslatedPartial;
+ PCM_PARTIAL_RESOURCE_LIST RawPartialList = NULL, TranslatedPartialList = NULL;
+ INTERFACE_TYPE Interface;
+ ULONG i, j, k, ListSize, Count, Port, Element, CurrentScale, SortScale, ReportType, FlagMatch;
+ ADDRESS_USAGE *CurrentAddress;
+ LARGE_INTEGER CurrentSortValue, SortValue;
+ DbgPrint("%wZ Detected\n", HalName);
+
+ /* Check if KD is using a COM port */
+ if (KdComPortInUse)
+ {
+ /* Enter it into the I/O space */
+ HalpComIoSpace.Element[0].Start = (ULONG_PTR)KdComPortInUse;
+ HalpComIoSpace.Next = HalpAddressUsageList;
+ HalpAddressUsageList = &HalpComIoSpace;
+
+ /* Use the debug port table if we have one */
+ HalpGetInfoFromACPI = HalpGetDebugPortTable();
+
+ /* Check if we're using ACPI */
+ if (!HalpGetInfoFromACPI)
+ {
+ /* No, so use our local table */
+ Port = HalpComPortIrqMapping[0][0];
+ for (i = 0; Port; i++)
+ {
+ /* Is this the port we want? */
+ if (Port == (ULONG_PTR)KdComPortInUse)
+ {
+ /* Register it */
+ HalpRegisterVector(IDT_DEVICE | IDT_LATCHED,
+ HalpComPortIrqMapping[i][1],
+ HalpComPortIrqMapping[i][1] +
+ PRIMARY_VECTOR_BASE,
+ HIGH_LEVEL);
+ }
+
+ /* Next port */
+ Port = HalpComPortIrqMapping[i][0];
+ }
+ }
+ }
+
+ /* On non-ACPI systems, we need to build an address map */
+ HalpBuildAddressMap();
+
+ /* Allocate the master raw and translated lists */
+ RawList = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE * 2, ' laH');
+ TranslatedList = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE * 2, ' laH');
+ if (!(RawList) || !(TranslatedList))
+ {
+ /* Bugcheck the system */
+ KeBugCheckEx(HAL_MEMORY_ALLOCATION,
+ 4 * PAGE_SIZE,
+ 1,
+ (ULONG_PTR)__FILE__,
+ __LINE__);
+ }
+
+ /* Zero out the lists */
+ RtlZeroMemory(RawList, PAGE_SIZE * 2);
+ RtlZeroMemory(TranslatedList, PAGE_SIZE * 2);
+
+ /* Set the interface type to begin with */
+ RawList->List[0].InterfaceType = InterfaceTypeUndefined;
+
+ /* Loop all IDT entries that are not IRQs */
+ for (i = 0; i < PRIMARY_VECTOR_BASE; i++)
+ {
+ /* Check if the IDT isn't owned */
+ if (!(HalpIDTUsageFlags[i].Flags & IDT_REGISTERED))
+ {
+ /* Then register it for internal usage */
+ HalpIDTUsageFlags[i].Flags = IDT_INTERNAL;
+ HalpIDTUsage[i].BusReleativeVector = i;
+ }
+ }
+
+ /* Our full raw descriptors start here */
+ RawFull = RawList->List;
+
+ /* Keep track of the current partial raw and translated descriptors */
+ CurrentRaw = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)RawList->List;
+ CurrentTranslated = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)TranslatedList->List;
+
+ /* Do two passes */
+ for (ReportType = 0; ReportType < 2; ReportType++)
+ {
+ /* Pass 0 is for device usage */
+ if (ReportType == 0)
+ {
+ FlagMatch = IDT_DEVICE & ~IDT_REGISTERED;
+ Interface = InterfaceType;
+ }
+ else
+ {
+ /* Past 1 is for internal HAL usage */
+ FlagMatch = IDT_INTERNAL & ~IDT_REGISTERED;
+ Interface = Internal;
+ }
+
+ /* Reset loop variables */
+ i = Element = 0;
+
+ /* Start looping our address uage list and interrupts */
+ CurrentAddress = HalpAddressUsageList;
+ while (TRUE)
+ {
+ /* Check for valid vector number */
+ if (i <= MAXIMUM_IDTVECTOR)
+ {
+ /* Check if this entry should be parsed */
+ if ((HalpIDTUsageFlags[i].Flags & FlagMatch))
+ {
+ /* Parse it */
+ HalpBuildPartialFromIdt(i, &RawPartial, &TranslatedPartial);
+ i++;
+ }
+ else
+ {
+ /* Skip this entry */
+ i++;
+ continue;
+ }
+ }
+ else
+ {
+ /* This is an address instead */
+ if (!CurrentAddress) break;
+
+ /* Check if the address should be reported */
+ if (!(CurrentAddress->Flags & FlagMatch) ||
+ !(CurrentAddress->Element[Element].Length))
+ {
+ /* Nope, skip it */
+ Element = 0;
+ CurrentAddress = CurrentAddress->Next;
+ continue;
+ }
+
+ /* Otherwise, parse the entry */
+ HalpBuildPartialFromAddress(Interface,
+ CurrentAddress,
+ Element,
+ &RawPartial,
+ &TranslatedPartial);
+ Element++;
+ }
+
+ /* Check for interface change */
+ if (RawFull->InterfaceType != Interface)
+ {
+ /* We need to add another full descriptor */
+ RawList->Count++;
+ TranslatedList->Count++;
+
+ /* The full descriptor follows wherever we were */
+ RawFull = (PCM_FULL_RESOURCE_DESCRIPTOR)CurrentRaw;
+ TranslatedFull = (PCM_FULL_RESOURCE_DESCRIPTOR)CurrentTranslated;
+
+ /* And it is of this new interface type */
+ RawFull->InterfaceType = Interface;
+ TranslatedFull->InterfaceType = Interface;
+
+ /* And its partial descriptors begin here */
+ RawPartialList = &RawFull->PartialResourceList;
+ TranslatedPartialList = &TranslatedFull->PartialResourceList;
+
+ /* And our next full descriptor should follow here */
+ CurrentRaw = RawFull->PartialResourceList.PartialDescriptors;
+ CurrentTranslated = TranslatedFull->PartialResourceList.PartialDescriptors;
+ }
+
+ /* We have written a new partial descriptor */
+ RawPartialList->Count++;
+ TranslatedPartialList->Count++;
+
+ /* Copy our local descriptors into the actual list */
+ RtlCopyMemory(CurrentRaw, &RawPartial, sizeof(RawPartial));
+ RtlCopyMemory(CurrentTranslated, &TranslatedPartial, sizeof(TranslatedPartial));
+
+ /* Move to the next partial descriptor */
+ CurrentRaw++;
+ CurrentTranslated++;
+ }
+ }
+
+ /* Get the final list of the size for the kernel call later */
+ ListSize = (ULONG_PTR)CurrentRaw - (ULONG_PTR)RawList;
+
+ /* Now reset back to the first full descriptor */
+ RawFull = RawList->List;
+ TranslatedFull = TranslatedList->List;
+
+ /* And loop all the full descriptors */
+ for (i = 0; i < RawList->Count; i++)
+ {
+ /* Get the first partial descriptor in this list */
+ CurrentRaw = RawFull->PartialResourceList.PartialDescriptors;
+ CurrentTranslated = TranslatedFull->PartialResourceList.PartialDescriptors;
+
+ /* Get the count of partials in this list */
+ Count = RawFull->PartialResourceList.Count;
+
+ /* Loop all the partials in this list */
+ for (j = 0; j < Count; j++)
+ {
+ /* Get the sort value at this point */
+ HalpGetResourceSortValue(CurrentRaw, &CurrentScale, &CurrentSortValue);
+
+ /* Save the current sort pointer */
+ SortedRaw = CurrentRaw;
+ SortedTranslated = CurrentTranslated;
+
+ /* Loop all descriptors starting from this one */
+ for (k = j; k < Count; k++)
+ {
+ /* Get the sort value at the sort point */
+ HalpGetResourceSortValue(SortedRaw, &SortScale, &SortValue);
+
+ /* Check if a swap needs to occur */
+ if ((SortScale < CurrentScale) ||
+ ((SortScale == CurrentScale) &&
+ (SortValue.QuadPart <= CurrentSortValue.QuadPart)))
+ {
+ /* Swap raw partial with the sort location partial */
+ RtlCopyMemory(&RawPartial, CurrentRaw, sizeof(RawPartial));
+ RtlCopyMemory(CurrentRaw, SortedRaw, sizeof(RawPartial));
+ RtlCopyMemory(SortedRaw, &RawPartial, sizeof(RawPartial));
+
+ /* Swap translated partial in the same way */
+ RtlCopyMemory(&TranslatedPartial, CurrentTranslated, sizeof(TranslatedPartial));
+ RtlCopyMemory(CurrentTranslated, SortedTranslated, sizeof(TranslatedPartial));
+ RtlCopyMemory(SortedTranslated, &TranslatedPartial, sizeof(TranslatedPartial));
+
+ /* Update the sort value at this point */
+ HalpGetResourceSortValue(CurrentRaw, &CurrentScale, &CurrentSortValue);
+ }
+
+ /* The sort location has been updated */
+ SortedRaw++;
+ SortedTranslated++;
+ }
+
+ /* Move to the next partial */
+ CurrentRaw++;
+ CurrentTranslated++;
+ }
+
+ /* Move to the next full descriptor */
+ RawFull = (PCM_FULL_RESOURCE_DESCRIPTOR)CurrentRaw;
+ TranslatedFull = (PCM_FULL_RESOURCE_DESCRIPTOR)CurrentTranslated;
+ }
+
+ /* Mark this is an ACPI system, if it is */
+ HalpMarkAcpiHal();
+
+ /* Tell the kernel about all this */
+ IoReportHalResourceUsage(HalName,
+ RawList,
+ TranslatedList,
+ ListSize);
+
+ /* Free our lists */
+ ExFreePool(RawList);
+ ExFreePool(TranslatedList);
+
+ /* Get the machine's serial number */
+ HalpReportSerialNumber();
}
+#endif
VOID
NTAPI
/* Enable the interrupt */
HalEnableSystemInterrupt(SystemVector, Irql, Mode);
}
-#endif
-/*
- * @unimplemented
- */
VOID
NTAPI
-HalReportResourceUsage(VOID)
+HalpGetNMICrashFlag(VOID)
{
- INTERFACE_TYPE InterfaceType;
- UNICODE_STRING HalString;
-
- /* FIXME: Initialize DMA 64-bit support */
+ UNICODE_STRING ValueName;
+ UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\CrashControl");
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ ULONG ResultLength;
+ HANDLE Handle;
+ NTSTATUS Status;
+ KEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
- /* FIXME: Initialize MCA bus */
+ /* Set default */
+ HalpNMIDumpFlag = 0;
- /* Initialize PCI bus. */
- HalpInitializePciBus();
+ /* Initialize attributes */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
- /* Initialize the stubs */
- HalpInitializePciStubs();
-
- /* What kind of bus is this? */
- switch (HalpBusType)
+ /* Open crash key */
+ Status = ZwOpenKey(&Handle, KEY_READ, &ObjectAttributes);
+ if (NT_SUCCESS(Status))
{
- /* ISA Machine */
- case MACHINE_TYPE_ISA:
- InterfaceType = Isa;
- break;
-
- /* EISA Machine */
- case MACHINE_TYPE_EISA:
- InterfaceType = Eisa;
- break;
-
- /* MCA Machine */
- case MACHINE_TYPE_MCA:
- InterfaceType = MicroChannel;
- break;
-
- /* Unknown */
- default:
- InterfaceType = Internal;
- break;
+ /* Query key value */
+ RtlInitUnicodeString(&ValueName, L"NMICrashDump");
+ Status = ZwQueryValueKey(Handle,
+ &ValueName,
+ KeyValuePartialInformation,
+ &KeyValueInformation,
+ sizeof(KeyValueInformation),
+ &ResultLength);
+ if (NT_SUCCESS(Status))
+ {
+ /* Check for valid data */
+ if (ResultLength == sizeof(KEY_VALUE_PARTIAL_INFORMATION))
+ {
+ /* Read the flag */
+ HalpNMIDumpFlag = KeyValueInformation.Data[0];
+ }
+ }
+
+ /* We're done */
+ ZwClose(Handle);
}
+}
+#endif
- /* Build HAL usage */
- RtlInitUnicodeString(&HalString, L"PC Compatible Eisa/Isa HAL");
- HalpReportResourceUsage(&HalString, InterfaceType);
+/* EOF */
- /* FIXME: Setup PCI debugging and Hibernation */
-}
<define name="_NTHALDLL_" />
<define name="_NTHAL_" />
<library>hal_generic</library>
+ <library>hal_generic_pcat</library>
<library>hal_generic_up</library>
<library>ntoskrnl</library>
<library>libcntpr</library>
</directory>
</module>
- <module name="mini_hal" type="objectlibrary">
+ <module name="mini_hal" type="objectlibrary" crt="static">
<include>include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHALDLL_" />
<file>systimer.S</file>
</directory>
</if>
- </directory>
+ </directory>
<directory name="up">
<file>halinit_up.c</file>
<file>pic.c</file>
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
+<group>
+ <module name="hal_generic_acpi" type="objectlibrary">
+ <include>include</include>
+ <include base="ntoskrnl">include</include>
+ <define name="_NTHALDLL_" />
+ <define name="_NTHAL_" />
+ <directory name="generic">
+ <directory name="acpi">
+ <file>halacpi.c</file>
+ <file>halpnpdd.c</file>
+ </directory>
+ </directory>
+ </module>
+</group>
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
+<group>
+ <module name="hal_generic_pcat" type="objectlibrary">
+ <include>include</include>
+ <include base="ntoskrnl">include</include>
+ <define name="_NTHALDLL_" />
+ <define name="_NTHAL_" />
+ <directory name="generic">
+ <directory name="legacy">
+ <file>halpcat.c</file>
+ </directory>
+ </directory>
+ </module>
+</group>
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
+<group xmlns:xi="http://www.w3.org/2001/XInclude">
+ <module name="halacpi" type="kernelmodedll" entrypoint="HalInitSystem@8" installbase="system32" installname="halacpi.dll">
+ <importlibrary base="hal" definition="../hal.pspec" />
+ <bootstrap installbase="$(CDOUTPUT)" />
+ <include>include</include>
+ <include base="ntoskrnl">include</include>
+ <define name="_NTHALDLL_" />
+ <define name="_NTHAL_" />
+ <library>hal_generic</library>
+ <library>hal_generic_acpi</library>
+ <library>hal_generic_up</library>
+ <library>ntoskrnl</library>
+ <library>libcntpr</library>
+ <directory name="up">
+ <file>halinit_up.c</file>
+ <file>halup.rc</file>
+ </directory>
+ </module>
+</group>
<define name="_NTHAL_" />
<define name="_X86BIOS_" />
<library>hal_generic</library>
+ <library>hal_generic_acpi</library>
<library>hal_generic_up</library>
<library>ntoskrnl</library>
<!-- library>x86emu</library -->
<define name="_NTHALDLL_" />
<define name="_NTHAL_" />
<library>hal_generic</library>
+ <library>hal_generic_pcat</library>
<library>hal_generic_mp</library>
<library>ntoskrnl</library>
<library>libcntpr</library>
<define name="_NTHAL_" />
<define name="SARCH_XBOX" />
<library>hal_generic</library>
+ <library>hal_generic_pcat</library>
<library>hal_generic_up</library>
<library>ntoskrnl</library>
<library>libcntpr</library>
PCI_CARD_DESCRIPTOR CardList[ANYSIZE_ARRAY];
} PCI_REGISTRY_INFO_INTERNAL, *PPCI_REGISTRY_INFO_INTERNAL;
+typedef struct _PCI_TYPE0_CFG_CYCLE_BITS
+{
+ union
+ {
+ struct
+ {
+ ULONG Reserved1:2;
+ ULONG RegisterNumber:6;
+ ULONG FunctionNumber:3;
+ ULONG Reserved2:21;
+ } bits;
+ ULONG AsULONG;
+ } u;
+} PCI_TYPE0_CFG_CYCLE_BITS, *PPCI_TYPE0_CFG_CYCLE_BITS;
+
+typedef struct _PCI_TYPE1_CFG_CYCLE_BITS
+{
+ union
+ {
+ struct
+ {
+ ULONG Reserved1:2;
+ ULONG RegisterNumber:6;
+ ULONG FunctionNumber:3;
+ ULONG DeviceNumber:5;
+ ULONG BusNumber:8;
+ ULONG Reserved2:8;
+ } bits;
+ ULONG AsULONG;
+ } u;
+} PCI_TYPE1_CFG_CYCLE_BITS, *PPCI_TYPE1_CFG_CYCLE_BITS;
+
typedef struct _ARRAY
{
ULONG ArraySize;
IN BOOLEAN NextBus
);
+VOID
+NTAPI
+HalpRegisterPciDebuggingDeviceInfo(
+ VOID
+);
+
extern ULONG HalpBusType;
extern BOOLEAN HalpPCIConfigInitialized;
extern BUS_HANDLER HalpFakePciBusHandler;
#include "halp.h"
#include "mps.h"
#include "ioapic.h"
+#include "halacpi.h"
/* EOF */
--- /dev/null
+#pragma once
+
+//
+// Should be shared with FreeLDR
+//
+typedef struct _ACPI_E820_ENTRY
+{
+ PHYSICAL_ADDRESS Base;
+ LARGE_INTEGER Length;
+ ULONGLONG Type;
+} ACPI_E820_ENTRY, *PACPI_E820_ENTRY;
+
+typedef struct _ACPI_BIOS_MULTI_NODE
+{
+ PHYSICAL_ADDRESS RsdtAddress;
+ ULONGLONG Count;
+ ACPI_E820_ENTRY E820Entry[1];
+} ACPI_BIOS_MULTI_NODE, *PACPI_BIOS_MULTI_NODE;
+
+//
+// ACPI Signatures
+//
+#define RSDP_SIGNATURE 0x2052545020445352 // "RSD PTR "
+#define FACS_SIGNATURE 0x53434146 // "FACS"
+#define FADT_SIGNATURE 0x50434146 // "FACP"
+#define RSDT_SIGNATURE 0x54445352 // "RSDT"
+#define APIC_SIGNATURE 0x43495041 // "APIC"
+#define DSDT_SIGNATURE 0x54445344 // "DSDT"
+#define SSDT_SIGNATURE 0x54445353 // "SSDT"
+#define PSDT_SIGNATURE 0x54445350 // "PSDT"
+#define SBST_SIGNATURE 0x54534253 // "SBST"
+#define DBGP_SIGNATURE 0x50474244 // "DBGP"
+#define XSDT_SIGNATURE 'TDSX'
+#define BOOT_SIGNATURE 'TOOB'
+#define SRAT_SIGNATURE 'TARS'
+
+//
+// FADT Flags
+//
+#define ACPI_TMR_VAL_EXT 0x100
+
+//
+// ACPI Generic Register Address
+//
+typedef struct _GEN_ADDR
+{
+ UCHAR AddressSpaceID;
+ UCHAR BitWidth;
+ UCHAR BitOffset;
+ UCHAR Reserved;
+ PHYSICAL_ADDRESS Address;
+} GEN_ADDR, *PGEN_ADDR;
+
+//
+// ACPI BIOS Structures (packed)
+//
+#include <pshpack1.h>
+typedef struct _RSDP
+{
+ ULONGLONG Signature;
+ UCHAR Checksum;
+ UCHAR OEMID[6];
+ UCHAR Reserved[1];
+ ULONG RsdtAddress;
+} RSDP;
+typedef RSDP *PRSDP;
+
+typedef struct _DESCRIPTION_HEADER
+{
+ ULONG Signature;
+ ULONG Length;
+ UCHAR Revision;
+ UCHAR Checksum;
+ UCHAR OEMID[6];
+ UCHAR OEMTableID[8];
+ ULONG OEMRevision;
+ UCHAR CreatorID[4];
+ ULONG CreatorRev;
+} DESCRIPTION_HEADER;
+typedef DESCRIPTION_HEADER *PDESCRIPTION_HEADER;
+
+typedef struct _FACS
+{
+ ULONG Signature;
+ ULONG Length;
+ ULONG HardwareSignature;
+ ULONG pFirmwareWakingVector;
+ ULONG GlobalLock;
+ ULONG Flags;
+ PHYSICAL_ADDRESS x_FirmwareWakingVector;
+ UCHAR version;
+ UCHAR Reserved[32];
+} FACS;
+typedef FACS *PFACS;
+
+typedef struct _FADT
+{
+ DESCRIPTION_HEADER Header;
+ ULONG facs;
+ ULONG dsdt;
+ UCHAR int_model;
+ UCHAR pm_profile;
+ USHORT sci_int_vector;
+ ULONG smi_cmd_io_port;
+ UCHAR acpi_on_value;
+ UCHAR acpi_off_value;
+ UCHAR s4bios_req;
+ UCHAR pstate_control;
+ ULONG pm1a_evt_blk_io_port;
+ ULONG pm1b_evt_blk_io_port;
+ ULONG pm1a_ctrl_blk_io_port;
+ ULONG pm1b_ctrl_blk_io_port;
+ ULONG pm2_ctrl_blk_io_port;
+ ULONG pm_tmr_blk_io_port;
+ ULONG gp0_blk_io_port;
+ ULONG gp1_blk_io_port;
+ UCHAR pm1_evt_len;
+ UCHAR pm1_ctrl_len;
+ UCHAR pm2_ctrl_len;
+ UCHAR pm_tmr_len;
+ UCHAR gp0_blk_len;
+ UCHAR gp1_blk_len;
+ UCHAR gp1_base;
+ UCHAR cstate_control;
+ USHORT lvl2_latency;
+ USHORT lvl3_latency;
+ USHORT flush_size;
+ USHORT flush_stride;
+ UCHAR duty_offset;
+ UCHAR duty_width;
+ UCHAR day_alarm_index;
+ UCHAR month_alarm_index;
+ UCHAR century_alarm_index;
+ USHORT boot_arch;
+ UCHAR reserved3[1];
+ ULONG flags;
+ GEN_ADDR reset_reg;
+ UCHAR reset_val;
+ UCHAR reserved4[3];
+ PHYSICAL_ADDRESS x_firmware_ctrl;
+ PHYSICAL_ADDRESS x_dsdt;
+ GEN_ADDR x_pm1a_evt_blk;
+ GEN_ADDR x_pm1b_evt_blk;
+ GEN_ADDR x_pm1a_ctrl_blk;
+ GEN_ADDR x_pm1b_ctrl_blk;
+ GEN_ADDR x_pm2_ctrl_blk;
+ GEN_ADDR x_pm_tmr_blk;
+ GEN_ADDR x_gp0_blk;
+ GEN_ADDR x_gp1_blk;
+} FADT;
+typedef FADT *PFADT;
+
+typedef struct _DSDT
+{
+ DESCRIPTION_HEADER Header;
+ UCHAR DiffDefBlock[ANYSIZE_ARRAY];
+} DSDT;
+typedef DSDT *PDSDT;
+
+typedef struct _RSDT
+{
+ DESCRIPTION_HEADER Header;
+ ULONG Tables[ANYSIZE_ARRAY];
+} RSDT;
+typedef RSDT *PRSDT;
+
+typedef struct _XSDT
+{
+ DESCRIPTION_HEADER Header;
+ PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY];
+} XSDT;
+typedef XSDT *PXSDT;
+#include <poppack.h>
+
+//
+// Microsoft-specific (pretty much) ACPI Tables, normal MS ABI packing
+//
+typedef struct _DEBUG_PORT_TABLE
+{
+ DESCRIPTION_HEADER Header;
+ UCHAR InterfaceType;
+ UCHAR Reserved[3];
+ GEN_ADDR BaseAddress;
+} DEBUG_PORT_TABLE, *PDEBUG_PORT_TABLE;
+
+typedef struct _BOOT_TABLE
+{
+ DESCRIPTION_HEADER Header;
+ UCHAR CMOSIndex;
+ UCHAR Reserved[3];
+} BOOT_TABLE, *PBOOT_TABLE;
+
+typedef struct _ACPI_SRAT
+{
+ DESCRIPTION_HEADER Header;
+ UCHAR TableRevision;
+ ULONG Reserved[2];
+} ACPI_SRAT, *PACPI_SRAT;
+
+//
+// Internal HAL structure
+//
+typedef struct _ACPI_CACHED_TABLE
+{
+ LIST_ENTRY Links;
+ DESCRIPTION_HEADER Header;
+ // table follows
+ // ...
+} ACPI_CACHED_TABLE, *PACPI_CACHED_TABLE;
+
+NTSTATUS
+NTAPI
+HalpAcpiTableCacheInit(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
+);
+
+PVOID
+NTAPI
+HalpAcpiGetTable(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG Signature
+);
+
+NTSTATUS
+NTAPI
+HalpSetupAcpiPhase0(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
+);
+
+PVOID
+NTAPI
+HalAcpiGetTable(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG Signature
+);
+
+/* EOF */
/* Usage flags */
#define IDT_REGISTERED 0x01
#define IDT_LATCHED 0x02
+#define IDT_READ_ONLY 0x04
#define IDT_INTERNAL 0x11
#define IDT_DEVICE 0x21
VOID
);
+ULONG
+NTAPI
+HalpAllocPhysicalMemory(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG MaxAddress,
+ IN ULONG PageCount,
+ IN BOOLEAN Aligned
+);
+
+PVOID
+NTAPI
+HalpMapPhysicalMemory64(
+ IN PHYSICAL_ADDRESS PhysicalAddress,
+ IN ULONG PageCount
+);
+
+NTSTATUS
+NTAPI
+HalpOpenRegistryKey(
+ IN PHANDLE KeyHandle,
+ IN HANDLE RootKey,
+ IN PUNICODE_STRING KeyName,
+ IN ACCESS_MASK DesiredAccess,
+ IN BOOLEAN Create
+);
+
+VOID
+NTAPI
+HalpGetNMICrashFlag(
+ VOID
+);
+
+BOOLEAN
+NTAPI
+HalpGetDebugPortTable(
+ VOID
+);
+
+VOID
+NTAPI
+HalpReportSerialNumber(
+ VOID
+);
+
+NTSTATUS
+NTAPI
+HalpMarkAcpiHal(
+ VOID
+);
+
+VOID
+NTAPI
+HalpBuildAddressMap(
+ VOID
+);
+
+VOID
+NTAPI
+HalpReportResourceUsage(
+ IN PUNICODE_STRING HalName,
+ IN INTERFACE_TYPE InterfaceType
+);
+
+ULONG
+NTAPI
+HalpIs16BitPortDecodeSupported(
+ VOID
+);
+NTSTATUS
+NTAPI
+HalpQueryAcpiResourceRequirements(
+ OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
+);
VOID
FASTCALL
extern PADDRESS_USAGE HalpAddressUsageList;
extern LARGE_INTEGER HalpPerfCounter;
+
+extern KAFFINITY HalpActiveProcessors;
+
+extern BOOLEAN HalDisableFirmwareMapper;
+extern PWCHAR HalHardwareIdString;
+extern PWCHAR HalName;
#define NDEBUG
#include <debug.h>
+KAFFINITY HalpActiveProcessors;
+
/* PRIVATE FUNCTIONS *********************************************************/
VOID
#define NDEBUG
#include <debug.h>
-LONG HalpActiveProcessors;
+KAFFINITY HalpActiveProcessors;
KAFFINITY HalpDefaultInterruptAffinity;
/* PRIVATE FUNCTIONS *********************************************************/
KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
/* Update the interrupt affinity and processor mask */
- InterlockedBitTestAndSet(&HalpActiveProcessors, ProcessorNumber);
+ InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber);
InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity,
ProcessorNumber);
#define USE_MINGW_SETJMP_TWO_ARGS
#endif
-/* Diable deprecation for now! */
+/* Disable deprecation for now! */
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE_CORE
#ifdef __WINESRC__
#define _CRT_UNUSED(x) (void)x
#endif
+#include "_mingw_mac.h"
+
#endif /* !_INC_MINGW */
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _INC_CRTDEFS_MACRO
+#define _INC_CRTDEFS_MACRO
+
+#define __STRINGIFY(x) #x
+#define __MINGW64_STRINGIFY(x) __STRINGIFY(x)
+
+#define __MINGW64_VERSION_MAJOR 1
+#define __MINGW64_VERSION_MINOR 1
+#define __MINGW64_VERSION_STR __MINGW64_STRINGIFY(__MINGW64_VERSION_MAJOR) "." __MINGW64_STRINGIFY(__MINGW64_VERSION_MINOR)
+#define __MINGW64_VERSION_STATE "alpha"
+
+/* mingw.org's version macros: these make gcc to define
+ MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global
+ and the __mingwthr_key_dtor() function from the MinGW
+ CRT in its private gthr-win32.h header. */
+#define __MINGW32_MAJOR_VERSION 3
+#define __MINGW32_MINOR_VERSION 11
+
+#ifdef _WIN64
+/* MS does not prefix symbols by underscores for 64-bit. */
+#ifndef __MINGW_USE_UNDERSCORE_PREFIX
+/* As we have to support older gcc version, which are using underscores
+ as symbol prefix for x64, we have to check here for the user label
+ prefix defined by gcc. */
+#ifdef __USER_LABEL_PREFIX__
+#pragma push_macro ("_")
+#undef _
+#define _ 1
+#if (__USER_LABEL_PREFIX__ + 0) != 0
+#define __MINGW_USE_UNDERSCORE_PREFIX 1
+#else
+#define __MINGW_USE_UNDERSCORE_PREFIX 0
+#endif
+#undef _
+#pragma pop_macro ("_")
+#else
+#define __MINGW_USE_UNDERSCORE_PREFIX 0
+#endif
+#endif
+#else
+/* For 32-bits we have always to prefix by underscore. */
+#undef __MINGW_USE_UNDERSCORE_PREFIX
+#define __MINGW_USE_UNDERSCORE_PREFIX 1
+#endif
+
+#if __MINGW_USE_UNDERSCORE_PREFIX == 0
+#define __MINGW_IMP_SYMBOL(sym) __imp_##sym
+#define __MINGW_USYMBOL(sym) sym
+#define __MINGW_LSYMBOL(sym) _##sym
+#else
+#define __MINGW_IMP_SYMBOL(sym) _imp__##sym
+#define __MINGW_USYMBOL(sym) _##sym
+#define __MINGW_LSYMBOL(sym) sym
+#endif
+
+/* Use alias for msvcr80 export of get/set_output_format. */
+#ifndef __USE_MINGW_OUTPUT_FORMAT_EMU
+#define __USE_MINGW_OUTPUT_FORMAT_EMU 1
+#endif
+
+/* Set VC specific compiler target macros. */
+#if defined(__x86_64) && defined(_X86_)
+#undef _X86_ /* _X86_ is not for __x86_64 */
+#endif
+
+#if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) \
+ && !defined(_M_AMD64) && !defined(__x86_64)
+#if defined(__i486__)
+#define _M_IX86 400
+#elif defined(__i586__)
+#define _M_IX86 500
+#else
+/* This gives wrong (600 instead of 300) value if -march=i386 is specified
+ but we cannot check for__i386__ as it is defined for all 32-bit CPUs. */
+#define _M_IX86 600
+#endif
+#endif
+
+#if defined(__x86_64) && !defined(_M_IX86) && !defined(_M_IA64) \
+ && !defined(_M_AMD64)
+#define _M_AMD64 100
+#define _M_X64 100
+#endif
+
+#if defined(__ia64__) && !defined(_M_IX86) && !defined(_M_IA64) \
+ && !defined(_M_AMD64) && !defined(_X86_) && !defined(__x86_64)
+#define _M_IA64 100
+#endif
+
+#ifndef __PTRDIFF_TYPE__
+#ifdef _WIN64
+#define __PTRDIFF_TYPE__ long long int
+#else
+#define __PTRDIFF_TYPE__ long int
+#endif
+#endif
+
+#ifndef __SIZE_TYPE__
+#ifdef _WIN64
+#define __SIZE_TYPE__ long long unsigned int
+#else
+#define __SIZE_TYPE__ long unsigned int
+#endif
+#endif
+
+#ifndef __WCHAR_TYPE__
+#define __WCHAR_TYPE__ unsigned short
+#endif
+#ifndef __WINT_TYPE__
+#define __WINT_TYPE__ unsigned short
+#endif
+
+#if defined(__GNUC__) || defined(__GNUG__)
+#define __MINGW_EXTENSION __extension__
+#else
+#define __MINGW_EXTENSION
+#endif
+
+#ifdef UNICODE
+# define __MINGW_NAME_AW(func) func##W
+#else
+# define __MINGW_NAME_AW(func) func##A
+#endif
+#define __MINGW_TYPEDEF_AW(type) \
+ typedef __MINGW_NAME_AW(type) type;
+
+#endif /* _INC_CRTDEFS_MACRO */
+
//#define NO_OLDNAMES
//#endif
+
/** Properties ***************************************************************/
#undef _CRT_PACKING
#endif
#ifndef _CRTIMP
- #ifdef _DLL
+ #ifdef CRTDLL /* Defined for ntdll, crtdll, msvcrt, etc */
+ #define _CRTIMP __declspec(dllexport)
+ #elif defined(_DLL)
#define _CRTIMP __declspec(dllimport)
- #else
- #define _CRTIMP
- #endif
-#endif
+ #else /* !CRTDLL && !_DLL */
+ #define _CRTIMP
+ #endif /* CRTDLL || _DLL */
+#endif /* !_CRTIMP */
//#define _CRT_ALTERNATIVE_INLINES
#define _CRT_OBSOLETE(_NewItem)
#endif
+
/** Constants ****************************************************************/
#define _ARGMAX 100
#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
-
/** Type definitions *********************************************************/
#ifdef __cplusplus
#ifndef _CRT_WCTYPEDATA_DEFINED
#define _CRT_WCTYPEDATA_DEFINED
# ifndef _CTYPE_DISABLE_MACROS
- _CRTDATA(extern unsigned short *_wctype);
+ _CRTDATA(extern const unsigned short _wctype[]);
_CRTIMP const wctype_t * __cdecl __pwctype_func(void);
# ifndef _M_CEE_PURE
_CRTDATA(extern const wctype_t *_pwctype);
#define _AddressOfReturnAddress() (&(((void **)(__builtin_frame_address(0)))[1]))
/* TODO: __getcallerseflags but how??? */
+/* Maybe the same for x86? */
+#ifdef _x86_64
+#define _alloca(s) __builtin_alloca(s)
+#endif
/*** Atomic operations ***/
);
}
+#ifdef _M_AMD64
+__INTRIN_INLINE void __stosq(unsigned __int64 * Dest, const unsigned __int64 Data, size_t Count)
+{
+ __asm__ __volatile__
+ (
+ "rep; stosq" :
+ [Dest] "=D" (Dest), [Count] "=c" (Count) :
+ "[Dest]" (Dest), "a" (Data), "[Count]" (Count)
+ );
+}
+#endif
+
__INTRIN_INLINE void __movsb(unsigned char * Destination, const unsigned char * Source, size_t Count)
{
__asm__ __volatile__
);
}
+#ifdef _M_AMD64
+__INTRIN_INLINE void __movsq(unsigned long * Destination, const unsigned long * Source, size_t Count)
+{
+ __asm__ __volatile__
+ (
+ "rep; movsq" :
+ [Destination] "=D" (Destination), [Source] "=S" (Source), [Count] "=c" (Count) :
+ "[Destination]" (Destination), "[Source]" (Source), "[Count]" (Count)
+ );
+}
+#endif
+
#if defined(_M_AMD64)
/*** GS segment addressing ***/
return retval;
}
+#ifdef _M_AMD64
+__INTRIN_INLINE unsigned char _bittest64(const __int64 * const a, const __int64 b)
+{
+ unsigned char retval;
+
+ if(__builtin_constant_p(b))
+ __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*(a + (b / 64))), [b] "Ir" (b % 64));
+ else
+ __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*a), [b] "r" (b));
+
+ return retval;
+}
+#endif
+
__INTRIN_INLINE unsigned char _bittestandcomplement(long * const a, const long b)
{
unsigned char retval;
_CRTIMP int __cdecl putenv(const char *_EnvString);
_CRTIMP void __cdecl swab(char *_Buf1,char *_Buf2,int _SizeInBytes);
_CRTIMP char *__cdecl ultoa(unsigned long _Val,char *_Dstbuf,int _Radix);
- _CRTIMP onexit_t __cdecl onexit(onexit_t _Func);
+ onexit_t __cdecl onexit(onexit_t _Func);
#endif
#endif
#define _tcscpy_s strcpy_s
#define _tcsdup _strdup
#define _tcslen strlen
-#if 0
#define _tcsnlen strnlen
-#endif
#define _tcsxfrm strxfrm
#define _tcsxfrm_l _strxfrm_l
#define _tcserror strerror
} IMAGE_NT_HEADERS32;
#ifdef _WIN64
-typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
+typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS;
#else
-typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
+typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS;
#endif
#ifndef _NTDDK_
-typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
-typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
-typedef IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS;
+
+typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32;
+typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
+
+#ifdef _WIN64
+typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS;
+#else
+typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS;
+#endif
+
#endif /* _NTDDK_ */
//
-/*
- * Definitions for print provider, monitor, processor and spooler
- *
- * Copyright 2005 Detlef Riekenberg
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- *
- *
- * "providor" is not a spelling error in this file. It's the real name.
- *
- */
-
-#ifndef _WINSPLP_
-#define _WINSPLP_
+#pragma once
#ifdef __cplusplus
extern "C" {
#define PRINTER_NOTIFY_STATUS_POLL 2
#define PRINTER_NOTIFY_STATUS_INFO 4
-
#define ROUTER_UNKNOWN 0
#define ROUTER_SUCCESS 1
#define ROUTER_STOP_ROUTING 2
+#if (NTDDI_VERSION >= NTDDI_WS03)
+#ifndef __ATTRIBUTE_INFO_3__
+#define __ATTRIBUTE_INFO_3__
+typedef struct _ATTRIBUTE_INFO_3 {
+ DWORD dwJobNumberOfPagesPerSide;
+ DWORD dwDrvNumberOfPagesPerSide;
+ DWORD dwNupBorderFlags;
+ DWORD dwJobPageOrderFlags;
+ DWORD dwDrvPageOrderFlags;
+ DWORD dwJobNumberOfCopies;
+ DWORD dwDrvNumberOfCopies;
+ DWORD dwColorOptimization;
+ short dmPrintQuality;
+ short dmYResolution;
+} ATTRIBUTE_INFO_3, *PATTRIBUTE_INFO_3;
+#endif
+#endif /* (NTDDI_VERSION >= NTDDI_WS03) */
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+
+#ifndef __ATTRIBUTE_INFO_4__
+#define __ATTRIBUTE_INFO_4__
+
+typedef struct _ATTRIBUTE_INFO_4 {
+ DWORD dwJobNumberOfPagesPerSide;
+ DWORD dwDrvNumberOfPagesPerSide;
+ DWORD dwNupBorderFlags;
+ DWORD dwJobPageOrderFlags;
+ DWORD dwDrvPageOrderFlags;
+ DWORD dwJobNumberOfCopies;
+ DWORD dwDrvNumberOfCopies;
+ DWORD dwColorOptimization;
+ short dmPrintQuality;
+ short dmYResolution;
+ DWORD dwDuplexFlags;
+ DWORD dwNupDirection;
+ DWORD dwBookletFlags;
+ DWORD dwScalingPercentX;
+ DWORD dwScalingPercentY;
+} ATTRIBUTE_INFO_4, *PATTRIBUTE_INFO_4;
+
+#define REVERSE_PAGES_FOR_REVERSE_DUPLEX (0x00000001)
+#define DONT_SEND_EXTRA_PAGES_FOR_DUPLEX (0x00000001 << 1)
+
+#define RIGHT_THEN_DOWN (0x00000001)
+#define DOWN_THEN_RIGHT (0x00000001 << 1)
+#define LEFT_THEN_DOWN (0x00000001 << 2)
+#define DOWN_THEN_LEFT (0x00000001 << 3)
+
+#define BOOKLET_EDGE_LEFT 0x00000000
+#define BOOKLET_EDGE_RIGHT 0x00000001
+
+#endif /* __ATTRIBUTE_INFO_4__ */
+
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+
+typedef struct _PRINTER_NOTIFY_INIT {
+ DWORD Size;
+ DWORD Reserved;
+ DWORD PollTime;
+} PRINTER_NOTIFY_INIT, *LPPRINTER_NOTIFY_INIT, *PPRINTER_NOTIFY_INIT;
+
+typedef struct _SPLCLIENT_INFO_1 {
+ DWORD dwSize;
+ LPWSTR pMachineName;
+ LPWSTR pUserName;
+ DWORD dwBuildNum;
+ DWORD dwMajorVersion;
+ DWORD dwMinorVersion;
+ WORD wProcessorArchitecture;
+} SPLCLIENT_INFO_1, *LPSPLCLIENT_INFO_1, *PSPLCLIENT_INFO_1;
+
+typedef struct _SPLCLIENT_INFO_2_V1{
+ ULONG_PTR hSplPrinter;
+} SPLCLIENT_INFO_2_W2K;
+
+typedef struct _SPLCLIENT_INFO_2_V2{
+#ifdef _WIN64
+ DWORD64 hSplPrinter;
+#else
+ DWORD32 hSplPrinter;
+#endif
+} SPLCLIENT_INFO_2_WINXP;
+
+typedef struct _SPLCLIENT_INFO_2_V3{
+ UINT64 hSplPrinter;
+} SPLCLIENT_INFO_2_LONGHORN;
+
+#if (OSVER(NTDDI_VERSION) == NTDDI_W2K)
+typedef SPLCLIENT_INFO_2_W2K SPLCLIENT_INFO_2, *PSPLCLIENT_INFO_2, *LPSPLCLIENT_INFO_2;
+#elif ((OSVER(NTDDI_VERSION) == NTDDI_WINXP) || (OSVER(NTDDI_VERSION) == NTDDI_WS03))
+typedef SPLCLIENT_INFO_2_WINXP SPLCLIENT_INFO_2, *PSPLCLIENT_INFO_2, *LPSPLCLIENT_INFO_2;
+#else
+typedef SPLCLIENT_INFO_2_LONGHORN SPLCLIENT_INFO_2, *PSPLCLIENT_INFO_2, *LPSPLCLIENT_INFO_2;
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_VISTA)
+typedef struct _SPLCLIENT_INFO_3 {
+ UINT cbSize;
+ DWORD dwFlags;
+ DWORD dwSize;
+ PWSTR pMachineName;
+ PWSTR pUserName;
+ DWORD dwBuildNum;
+ DWORD dwMajorVersion;
+ DWORD dwMinorVersion;
+ WORD wProcessorArchitecture;
+ UINT64 hSplPrinter;
+} SPLCLIENT_INFO_3, *PSPLCLIENT_INFO_3, *LPSPLCLIENT_INFO_3;
+#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
+
+typedef struct _PRINTPROVIDOR {
+ BOOL (WINAPI *fpOpenPrinter)(PWSTR lpPrinterName, HANDLE *phPrinter,
+ PPRINTER_DEFAULTSW pDefault);
+ BOOL (WINAPI *fpSetJob)(HANDLE hPrinter, DWORD JobID, DWORD Level,
+ LPBYTE pJob, DWORD Command);
+ BOOL (WINAPI *fpGetJob)(HANDLE hPrinter, DWORD JobID, DWORD Level,
+ LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpEnumJobs)(HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs,
+ DWORD Level, LPBYTE pJob, DWORD cbBuf, LPDWORD pcbNeeded,
+ LPDWORD pcReturned);
+ HANDLE (WINAPI *fpAddPrinter)(LPWSTR pName, DWORD Level, LPBYTE pPrinter);
+ BOOL (WINAPI *fpDeletePrinter)(HANDLE hPrinter);
+ BOOL (WINAPI *fpSetPrinter)(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
+ DWORD Command);
+ BOOL (WINAPI *fpGetPrinter)(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
+ DWORD cbBuf, LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpEnumPrinters)(DWORD dwType, LPWSTR lpszName, DWORD dwLevel,
+ LPBYTE lpbPrinters, DWORD cbBuf, LPDWORD lpdwNeeded,
+ LPDWORD lpdwReturned);
+ BOOL (WINAPI *fpAddPrinterDriver)(LPWSTR pName, DWORD Level,
+ LPBYTE pDriverInfo);
+ BOOL (WINAPI *fpEnumPrinterDrivers)(LPWSTR pName, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf,
+ LPDWORD pcbNeeded, LPDWORD pcbReturned);
+ BOOL (WINAPI *fpGetPrinterDriver)(HANDLE hPrinter, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf,
+ LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpGetPrinterDriverDirectory)(LPWSTR pName, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pDriverDirectory, DWORD cbBuf,
+ LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpDeletePrinterDriver)(LPWSTR pName, LPWSTR pEnvironment,
+ LPWSTR pDriverName);
+ BOOL (WINAPI *fpAddPrintProcessor)(LPWSTR pName, LPWSTR pEnvironment,
+ LPWSTR pPathName, LPWSTR pPrintProcessorName);
+ BOOL (WINAPI *fpEnumPrintProcessors)(LPWSTR pName, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf,
+ LPDWORD pcbNeeded, LPDWORD pcbReturned);
+ BOOL (WINAPI *fpGetPrintProcessorDirectory)(LPWSTR pName, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf,
+ LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpDeletePrintProcessor)(LPWSTR pName, LPWSTR pEnvironment,
+ LPWSTR pPrintProcessorName);
+ BOOL (WINAPI *fpEnumPrintProcessorDatatypes)(LPWSTR pName,
+ LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes,
+ DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcbReturned);
+ DWORD (WINAPI *fpStartDocPrinter)(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo);
+ BOOL (WINAPI *fpStartPagePrinter)(HANDLE hPrinter);
+ BOOL (WINAPI *fpWritePrinter)(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf,
+ LPDWORD pcWritten);
+ BOOL (WINAPI *fpEndPagePrinter)(HANDLE hPrinter);
+ BOOL (WINAPI *fpAbortPrinter)(HANDLE hPrinter);
+ BOOL (WINAPI *fpReadPrinter)(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf,
+ LPDWORD pNoBytesRead);
+ BOOL (WINAPI *fpEndDocPrinter)(HANDLE hPrinter);
+ BOOL (WINAPI *fpAddJob)(HANDLE hPrinter, DWORD Level, LPBYTE pData,
+ DWORD cbBuf, LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpScheduleJob)(HANDLE hPrinter, DWORD JobID);
+ DWORD (WINAPI *fpGetPrinterData)(HANDLE hPrinter, LPWSTR pValueName,
+ LPDWORD pType, LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded);
+ DWORD (WINAPI *fpSetPrinterData)(HANDLE hPrinter, LPWSTR pValueName,
+ DWORD Type, LPBYTE pData, DWORD cbData);
+ DWORD (WINAPI *fpWaitForPrinterChange)(HANDLE hPrinter, DWORD Flags);
+ BOOL (WINAPI *fpClosePrinter)(HANDLE phPrinter);
+ BOOL (WINAPI *fpAddForm)(HANDLE hPrinter, DWORD Level, LPBYTE pForm);
+ BOOL (WINAPI *fpDeleteForm)(HANDLE hPrinter, LPWSTR pFormName);
+ BOOL (WINAPI *fpGetForm)(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
+ LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded);
+ BOOL (WINAPI *fpSetForm)(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
+ LPBYTE pForm);
+ BOOL (WINAPI *fpEnumForms)(HANDLE hPrinter, DWORD Level, LPBYTE pForm,
+ DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
+ BOOL (WINAPI *fpEnumMonitors)(LPWSTR pName, DWORD Level, LPBYTE pMonitors,
+ DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
+ BOOL (WINAPI *fpEnumPorts)(LPWSTR pName, DWORD Level, LPBYTE pPorts,
+ DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
+ BOOL (WINAPI *fpAddPort)(LPWSTR pName, HWND hWnd, LPWSTR pMonitorName);
+ BOOL (WINAPI *fpConfigurePort)(LPWSTR pName, HWND hWnd, LPWSTR pPortName);
+ BOOL (WINAPI *fpDeletePort)(LPWSTR pName, HWND hWnd, LPWSTR pPortName);
+ HANDLE (WINAPI *fpCreatePrinterIC)(HANDLE hPrinter, LPDEVMODEW pDevMode);
+ BOOL (WINAPI *fpPlayGdiScriptOnPrinterIC)(HANDLE hPrinterIC, LPBYTE pIn,
+ DWORD cIn, LPBYTE pOut, DWORD cOut, DWORD ul);
+ BOOL (WINAPI *fpDeletePrinterIC)(HANDLE hPrinterIC);
+ BOOL (WINAPI *fpAddPrinterConnection)(LPWSTR pName);
+ BOOL (WINAPI *fpDeletePrinterConnection)(LPWSTR pName);
+ DWORD (WINAPI *fpPrinterMessageBox)(HANDLE hPrinter, DWORD Error, HWND hWnd,
+ LPWSTR pText, LPWSTR pCaption, DWORD dwType);
+ BOOL (WINAPI *fpAddMonitor)(LPWSTR pName, DWORD Level, LPBYTE pMonitors);
+ BOOL (WINAPI *fpDeleteMonitor)(LPWSTR pName, LPWSTR pEnvironment,
+ LPWSTR pMonitorName);
+ BOOL (WINAPI *fpResetPrinter)(HANDLE hPrinter, LPPRINTER_DEFAULTSW pDefault);
+ BOOL (WINAPI *fpGetPrinterDriverEx)(HANDLE hPrinter, LPWSTR pEnvironment,
+ DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded,
+ DWORD dwClientMajorVersion, DWORD dwClientMinorVersion,
+ PDWORD pdwServerMajorVersion, PDWORD pdwServerMinorVersion);
+ HANDLE (WINAPI *fpFindFirstPrinterChangeNotification)(HANDLE hPrinter,
+ DWORD fdwFlags, DWORD fdwOptions, LPVOID pPrinterNotifyOptions);
+ BOOL (WINAPI *fpFindClosePrinterChangeNotification)(HANDLE hChange);
+ BOOL (WINAPI *fpAddPortEx)(HANDLE hMonitor, LPWSTR pName, DWORD Level,
+ LPBYTE lpBuffer, LPWSTR lpMonitorName);
+ BOOL (WINAPI *fpShutDown)(LPVOID pvReserved);
+ BOOL (WINAPI *fpRefreshPrinterChangeNotification)(HANDLE hPrinter,
+ DWORD Reserved, PVOID pvReserved, PVOID pPrinterNotifyInfo);
+ BOOL (WINAPI *fpOpenPrinterEx)(LPWSTR pPrinterName, LPHANDLE phPrinter,
+ LPPRINTER_DEFAULTSW pDefault, LPBYTE pClientInfo, DWORD Level);
+ HANDLE (WINAPI *fpAddPrinterEx)(LPWSTR pName, DWORD Level, LPBYTE pPrinter,
+ LPBYTE pClientInfo, DWORD ClientInfoLevel);
+ BOOL (WINAPI *fpSetPort)(LPWSTR pName, LPWSTR pPortName, DWORD dwLevel,
+ LPBYTE pPortInfo);
+ DWORD (WINAPI *fpEnumPrinterData)( HANDLE hPrinter, DWORD dwIndex,
+ LPWSTR pValueName, DWORD cbValueName, LPDWORD pcbValueName,
+ LPDWORD pType, LPBYTE pData, DWORD cbData, LPDWORD pcbData);
+ DWORD (WINAPI *fpDeletePrinterData)(HANDLE hPrinter, LPWSTR pValueName);
+ DWORD (WINAPI *fpClusterSplOpen)(LPCWSTR pszServer, LPCWSTR pszResource,
+ PHANDLE phSpooler, LPCWSTR pszName, LPCWSTR pszAddress);
+ DWORD (WINAPI *fpClusterSplClose)(HANDLE hSpooler);
+ DWORD (WINAPI *fpClusterSplIsAlive)(HANDLE hSpooler);
+ DWORD (WINAPI *fpSetPrinterDataEx)(HANDLE hPrinter, LPCWSTR pKeyName,
+ LPCWSTR pValueName, DWORD Type, LPBYTE pData, DWORD cbData);
+ DWORD (WINAPI *fpGetPrinterDataEx)(HANDLE hPrinter, LPCWSTR pKeyName,
+ LPCWSTR pValueName, LPDWORD pType, LPBYTE pData, DWORD nSize,
+ LPDWORD pcbNeeded);
+ DWORD (WINAPI *fpEnumPrinterDataEx)(HANDLE hPrinter, LPCWSTR pKeyName,
+ LPBYTE pEnumValues, DWORD cbEnumValues, LPDWORD pcbEnumValues,
+ LPDWORD pnEnumValues);
+ DWORD (WINAPI *fpEnumPrinterKey)(HANDLE hPrinter, LPCWSTR pKeyName,
+ LPWSTR pSubkey, DWORD cbSubkey, LPDWORD pcbSubkey);
+ DWORD (WINAPI *fpDeletePrinterDataEx)(HANDLE hPrinter, LPCWSTR pKeyName,
+ LPCWSTR pValueName);
+ DWORD (WINAPI *fpDeletePrinterKey)(HANDLE hPrinter, LPCWSTR pKeyName);
+ BOOL (WINAPI *fpSeekPrinter)(HANDLE hPrinter, LARGE_INTEGER liDistanceToMove,
+ PLARGE_INTEGER pliNewPointer, DWORD dwMoveMethod, BOOL bWrite);
+ BOOL (WINAPI *fpDeletePrinterDriverEx)(LPWSTR pName, LPWSTR pEnvironment,
+ LPWSTR pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum);
+ BOOL (WINAPI *fpAddPerMachineConnection)(LPCWSTR pServer,
+ LPCWSTR pPrinterName, LPCWSTR pPrintServer, LPCWSTR pProvider);
+ BOOL (WINAPI *fpDeletePerMachineConnection)(LPCWSTR pServer,
+ LPCWSTR pPrinterName);
+ BOOL (WINAPI *fpEnumPerMachineConnections)(LPCWSTR pServer,
+ LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded,
+ LPDWORD pcReturned);
+ BOOL (WINAPI *fpXcvData)(HANDLE hXcv, LPCWSTR pszDataName, PBYTE pInputData,
+ DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData,
+ PDWORD pcbOutputNeeded, PDWORD pdwStatus);
+ BOOL (WINAPI *fpAddPrinterDriverEx)(LPWSTR pName, DWORD Level,
+ LPBYTE pDriverInfo, DWORD dwFileCopyFlags);
+ BOOL (WINAPI *fpSplReadPrinter)(HANDLE hPrinter, LPBYTE *pBuf, DWORD cbBuf);
+ BOOL (WINAPI *fpDriverUnloadComplete)(LPWSTR pDriverFile);
+ BOOL (WINAPI *fpGetSpoolFileInfo)(HANDLE hPrinter, LPWSTR *pSpoolDir,
+ LPHANDLE phFile, HANDLE hSpoolerProcess, HANDLE hAppProcess);
+ BOOL (WINAPI *fpCommitSpoolData)(HANDLE hPrinter, DWORD cbCommit);
+ BOOL (WINAPI *fpCloseSpoolFileHandle)(HANDLE hPrinter);
+ BOOL (WINAPI *fpFlushPrinter)(HANDLE hPrinter, LPBYTE pBuf, DWORD cbBuf,
+ LPDWORD pcWritten, DWORD cSleep);
+ DWORD (WINAPI *fpSendRecvBidiData)(HANDLE hPort, LPCWSTR pAction,
+ LPBIDI_REQUEST_CONTAINER pReqData,
+ LPBIDI_RESPONSE_CONTAINER *ppResData);
+ BOOL (WINAPI *fpAddDriverCatalog)(HANDLE hPrinter, DWORD dwLevel,
+ VOID *pvDriverInfCatInfo, DWORD dwCatalogCopyFlags);
+} PRINTPROVIDOR, *LPPRINTPROVIDOR;
+
+
+
+
+
/*
* WARNING: Many Functions are declared as "BOOL", but return ROUTER_*
*/
BOOL (WINAPI *pfnDeletePortUI)(PCWSTR pszServer, HWND hWnd, PCWSTR pszPortName);
}MONITORUI, *PMONITORUI;
-typedef struct _PRINTER_NOTIFY_INIT {
- DWORD Size;
- DWORD Reserved;
- DWORD PollTime;
-} PRINTER_NOTIFY_INIT, *LPPRINTER_NOTIFY_INIT, *PPRINTER_NOTIFY_INIT;
-
typedef struct _PRINTPROCESSOROPENDATA {
PDEVMODEW pDevMode;
LPWSTR pDatatype;
VOID *pvDriverInfCatInfo, DWORD dwCatalogCopyFlags);
} PRINTPROVIDOR, *LPPRINTPROVIDOR;
-typedef struct _SPLCLIENT_INFO_1 {
- DWORD dwSize;
- LPWSTR pMachineName;
- LPWSTR pUserName;
- DWORD dwBuildNum;
- DWORD dwMajorVersion;
- DWORD dwMinorVersion;
- WORD wProcessorArchitecture;
-} SPLCLIENT_INFO_1, *LPSPLCLIENT_INFO_1, *PSPLCLIENT_INFO_1;
-
/* DECLARATIONS */
HANDLE WINAPI CreatePrinterIC(HANDLE hPrinter, LPDEVMODEW pDevMode);
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* _WINSPLP_ */
IN PDEVICE_OBJECT DeviceObject,
IN DEVICE_RELATION_TYPE Type
);
+
+NTSTATUS
+NTAPI
+IoCreateDriver(
+ IN PUNICODE_STRING DriverName OPTIONAL,
+ IN PDRIVER_INITIALIZE InitializationFunction
+);
+
+NTSTATUS
+NTAPI
+IoReportHalResourceUsage(
+ IN PUNICODE_STRING HalName,
+ IN PCM_RESOURCE_LIST RawResourceList,
+ IN PCM_RESOURCE_LIST TranslatedResourceList,
+ IN ULONG ResourceListSize
+);
#endif
//
const KSAUTOMATION_TABLE* AutomationTable;
const GUID* Type;
const GUID* Name;
+#if !defined(_WIN64)
+ PVOID Alignment;
+#endif
};
struct _KSFILTER_DESCRIPTOR
IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL,
OUT PKSFILTERFACTORY *FilterFactory OPTIONAL);
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsFilterFactorySetDeviceClassesState(
+ IN PKSFILTERFACTORY FilterFactory,
+ IN BOOLEAN NewState
+ );
+
KSDDKAPI
NTSTATUS
NTAPI
#define DI_MASK 1
#define DI_NORMAL 3
#define DI_APPBANDING 1
+#define DI_NOMIRROR 16
#define EMR_HEADER 1
#define EMR_POLYBEZIER 2
#define EMR_POLYGON 3
#define EMR_SETICMPROFILEW 113
#define EMR_ALPHABLEND 114
#define EMR_ALPHADIBBLEND 115
+#define EMR_SETLAYOUT 115
#define EMR_TRANSPARENTBLT 116
#define EMR_TRANSPARENTDIB 117
+#define EMR_RESERVED_117 117
#define EMR_GRADIENTFILL 118
#define EMR_SETLINKEDUFIS 119
#define EMR_SETTEXTJUSTIFICATION 120
#define EMR_COLORMATCHTOTARGETW 121
+#define EMR_CREATECOLORSPACEW 122
+
+#define EMR_MIN 1
+#define EMR_MAX 122
+
#endif
#define ENHMETA_SIGNATURE 1179469088
#define EPS_SIGNATURE 0x46535045
#define META_CREATEFONTINDIRECT 0x2FB
#define META_CREATEBRUSHINDIRECT 0x2FC
#define META_CREATEREGION 0x6FF
+#define META_DRAWTEXT 0x062F
+#define META_RESETDC 0x014C
+#define META_STARTDOC 0x014D
+#define META_STARTPAGE 0x004F
+#define META_ENDPAGE 0x0050
+#define META_ABORTDOC 0x0052
+#define META_ENDDOC 0x005E
+#define META_CREATEBRUSH 0x00F8
+#define META_CREATEBITMAPINDIRECT 0x02FD
+#define META_CREATEBITMAP 0x06FE
#define PT_MOVETO 6
#define PT_LINETO 2
#define PT_BEZIERTO 4
#define JOHAB_CHARSET 130
#define VIETNAMESE_CHARSET 163
#define MAC_CHARSET 77
+/* I don't know if the values of *_CHARSET macros are defined in Windows
+ * or if we can choose them as we want. -- srtxg
+ */
+#define VISCII_CHARSET (BYTE)240 /* viscii1.1-1 */
+#define TCVN_CHARSET (BYTE)241 /* tcvn-0 */
+#define KOI8_CHARSET (BYTE)242 /* koi8-{r,u,ru} */
+#define ISO3_CHARSET (BYTE)243 /* iso8859-3 */
+#define ISO4_CHARSET (BYTE)244 /* iso8859-4 */
+#define ISO10_CHARSET (BYTE)245 /* iso8859-10 */
+#define CELTIC_CHARSET (BYTE)246 /* iso8859-14 */
+
#define OUT_DEFAULT_PRECIS 0
#define OUT_STRING_PRECIS 1
#define OUT_CHARACTER_PRECIS 2
#define PROOF_QUALITY 2
#define NONANTIALIASED_QUALITY 3
#define ANTIALIASED_QUALITY 4
+#define CLEARTYPE_QUALITY 5
+#define CLEARTYPE_NATURAL_QUALITY 6
#define DEFAULT_PITCH 0
#define FIXED_PITCH 1
#define VARIABLE_PITCH 2
#define PS_TYPE_MASK 983040
#define ALTERNATE 1
#define WINDING 2
+#define POLYFILL_LAST 2
#define DC_BINNAMES 12
#define DC_BINS 6
#define DC_COPIES 18
#define DCBA_FACEDOWNRIGHT 259
#define FLOODFILLBORDER 0
#define FLOODFILLSURFACE 1
+#define ETO_GRAYED 0x00001
#define ETO_OPAQUE 0x00002
#define ETO_CLIPPED 0x00004
#if (WINVER >= 0x0400)
#define GGO_GRAY8_BITMAP 6
#define GGO_GLYPH_INDEX 128
#define GGO_UNHINTED 256
+#ifdef __WINESRC__
+#define WINE_GGO_GRAY16_BITMAP 0x10
+#define WINE_GGO_HRGB_BITMAP 0x11
+#define WINE_GGO_HBGR_BITMAP 0x12
+#define WINE_GGO_VRGB_BITMAP 0x13
+#define WINE_GGO_VBGR_BITMAP 0x14
+#endif
#define GM_COMPATIBLE 1
#define GM_ADVANCED 2
+#define GM_LAST 2
#define MM_ANISOTROPIC 8
#define MM_HIENGLISH 5
#define MM_HIMETRIC 3
#define PT_CLOSEFIGURE 1
#define TT_AVAILABLE 1
#define TT_ENABLED 2
+
+#ifdef __WINESRC__
+#define WINE_TT_SUBPIXEL_RENDERING_ENABLED 0x4000
+#define WINE_TT_HINTER_ENABLED 0x8000
+#endif
+
#define BLACK_BRUSH 4
#define DKGRAY_BRUSH 3
#define GRAY_BRUSH 2
#define MWT_MAX MWT_RIGHTMULTIPLY
#define OPAQUE 2
#define TRANSPARENT 1
+#define BKMODE_LAST 2
#define BLACKONWHITE 1
#define WHITEONBLACK 2
#define COLORONCOLOR 3
#define BS_DIBPATTERNPT 6
#define BS_PATTERN8X8 7
#define BS_DIBPATTERN8X8 8
+#define BS_MONOPATTERN 9
#define LCS_CALIBRATED_RGB 0
#define LCS_DEVICE_RGB 1
#define LCS_DEVICE_CMYK 2
LONG cxSrc;
LONG cySrc;
} EMRSTRETCHBLT,*PEMRSTRETCHBLT;
+typedef struct tagEMRALPHABLEND {
+ EMR emr;
+ RECTL rclBounds;
+ LONG xDest;
+ LONG yDest;
+ LONG cxDest;
+ LONG cyDest;
+ DWORD dwRop;
+ LONG xSrc;
+ LONG ySrc;
+ XFORM xformSrc;
+ COLORREF crBkColorSrc;
+ DWORD iUsageSrc;
+ DWORD offBmiSrc;
+ DWORD cbBmiSrc;
+ DWORD offBitsSrc;
+ DWORD cbBitsSrc;
+ LONG cxSrc;
+ LONG cySrc;
+} EMRALPHABLEND, *PEMRALPHABLEND;
typedef struct tagEMRSTRETCHDIBITS {
EMR emr;
RECTL rclBounds;
BOOL WINAPI FixBrushOrgEx(HDC,int,int,LPPOINT);
BOOL WINAPI FlattenPath(HDC);
BOOL WINAPI FloodFill(HDC,int,int,COLORREF);
+BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT);
BOOL WINAPI GdiAlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION);
BOOL WINAPI GdiComment(HDC,UINT,const BYTE*);
-DEVMODEW* WINAPI GdiConvertToDevmodeW(const DEVMODEA *);
+DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *);
BOOL WINAPI GdiFlush(void);
+LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *);
+DWORD WINAPI GdiGetCodePage(HDC);
DWORD WINAPI GdiGetBatchLimit(void);
DWORD WINAPI GdiSetBatchLimit(DWORD);
+BOOL WINAPI GdiGradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG);
+BOOL WINAPI GdiIsMetaFileDC(HDC);
#define GetCValue(cmyk) ((BYTE)(cmyk))
#define GetMValue(cmyk) ((BYTE)((cmyk)>> 8))
#define GetYValue(cmyk) ((BYTE)((cmyk)>>16))
UINT WINAPI GetTextAlign(HDC);
int WINAPI GetTextCharacterExtra(HDC);
int WINAPI GetTextCharset(HDC);
-int WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD);
+UINT WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD);
COLORREF WINAPI GetTextColor(HDC);
BOOL WINAPI GetTextExtentExPointA(HDC,LPCSTR,int,int,LPINT,LPINT,LPSIZE);
BOOL WINAPI GetTextExtentExPointW( HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE );
BOOL WINAPI SetPixelV(HDC,int,int,COLORREF);
int WINAPI SetPolyFillMode(HDC,int);
BOOL WINAPI SetRectRgn(HRGN,int,int,int,int);
+INT WINAPI SetRelAbs(HDC,INT);
int WINAPI SetROP2(HDC,int);
int WINAPI SetStretchBltMode(HDC,int);
UINT WINAPI SetSystemPaletteUse(HDC,UINT);
#endif
#endif
+#ifdef __WINESRC__
+/* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */
+
+#define DCHC_INVALIDVISRGN 0x0001
+#define DCHC_DELETEDC 0x0002
+#define DCHF_INVALIDATEVISRGN 0x0001
+#define DCHF_VALIDATEVISRGN 0x0002
+
+typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM);
+
+WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*);
+WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR);
+WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
+WINGDIAPI INT WINAPI SelectVisRgn(HDC,HRGN);
+#endif /* __WINESRC__ */
+
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#define ES_LOWERCASE 16
#define ES_MULTILINE 4
#define ES_NOHIDESEL 256
+#ifdef _WINE
+#define ES_COMBO 0x200 /* Undocumented. Parent is a combobox */
+#endif
#define ES_NUMBER 0x2000
#define ES_OEMCONVERT 0x400
#define ES_PASSWORD 32
#define WS_EX_COMPOSITED 0x2000000 /* XP */
#define WS_EX_CONTEXTHELP 0x400
#define WS_EX_CONTROLPARENT 0x10000
+#define WS_EX_DRAGDETECT 0x00000002L
#define WS_EX_DLGMODALFRAME 1
#define WS_EX_LAYERED 0x80000 /* w2k */
#define WS_EX_LAYOUTRTL 0x400000 /* w98, w2k */
#define DSS_NORMAL 0
#define DSS_UNION 16
#define DSS_DISABLED 32
+#define DSS_DEFAULT 64
#define DSS_MONO 128
#define DSS_HIDEPREFIX 0x0200
#define DSS_PREFIXONLY 0x0400
#endif
#define QS_SENDMESSAGE 64
#define QS_TIMER 16
+/* Extra (undocumented) queue wake bits - see "Undoc. Windows" */
+#define QS_SMRESULT 0x8000
#define USER_TIMER_MAXIMUM 2147483647
#define USER_TIMER_MINIMUM 10
#define MSGF_NEXTWINDOW 6
#define MSGF_MAINLOOP 8
#define MSGF_USER 4096
+#define MSGF_MAX 8
#define MOUSEEVENTF_MOVE 1
#define MOUSEEVENTF_LEFTDOWN 2
#define MOUSEEVENTF_LEFTUP 4
#define MOUSEEVENTF_RIGHTUP 16
#define MOUSEEVENTF_MIDDLEDOWN 32
#define MOUSEEVENTF_MIDDLEUP 64
+#define MOUSEEVENTF_XDOWN 128
+#define MOUSEEVENTF_XUP 256
#define MOUSEEVENTF_WHEEL 0x0800
#define MOUSEEVENTF_ABSOLUTE 32768
#define PM_NOREMOVE 0
#define SWP_NOSENDCHANGING 1024
#define SWP_DEFERERASE 8192
#define SWP_ASYNCWINDOWPOS 16384
+/* undocumented SWP flags - from SDK 3.1 */
+#define SWP_NOCLIENTSIZE 0x0800
+#define SWP_NOCLIENTMOVE 0x1000
+#define SWP_STATECHANGED 0x8000
#define HSHELL_WINDOWCREATED 1
#define HSHELL_WINDOWDESTROYED 2
#define WM_ACTIVATE 6
#define WM_SETFOCUS 7
#define WM_KILLFOCUS 8
+#ifdef _WINE
+#define WM_SETVISIBLE 9
+#endif
#define WM_ENABLE 10
#define WM_SETREDRAW 11
#define WM_SETTEXT 12
#define WM_GETFONT 49
#define WM_SETHOTKEY 50
#define WM_GETHOTKEY 51
+#define WM_ISACTIVEICON 53
+#define WM_QUERYPARKICON 54
#define WM_QUERYDRAGICON 55
#define WM_COMPAREITEM 57
#if (WINVER >= 0x0500)
#define WM_NCXBUTTONDBLCLK 173
#endif /* (_WIN32_WINNT >= 0x0500) */
+#define WM_KEYF1 0x004d
#define WM_KEYFIRST 256
#define WM_KEYDOWN 256
#define WM_KEYUP 257
#define WM_VSCROLL 277
#define WM_INITMENU 278
#define WM_INITMENUPOPUP 279
+#define WM_SYSTIMER 280
#define WM_MENUSELECT 287
#define WM_MENUCHAR 288
#define WM_ENTERIDLE 289
#endif /* _WIN32_WCE */
#endif /* (WINVER >= 0x0500) */
+/* D&D messages */
+#define WM_DROPOBJECT 0x022A
+#define WM_QUERYDROPOBJECT 0x022B
+#define WM_BEGINDRAG 0x022C
+#define WM_DRAGLOOP 0x022D
+#define WM_DRAGSELECT 0x022E
+#define WM_DRAGMOVE 0x022F
+
+#define WM_CTLCOLOR 25
#define WM_CTLCOLORMSGBOX 306
#define WM_CTLCOLOREDIT 307
#define WM_CTLCOLORLISTBOX 308
#define MN_GETHMENU 481
#define WM_MOUSEFIRST 512
#define WM_MOUSEMOVE 512
+#define WM_LBTRACKPOINT 0x0131
#define WM_LBUTTONDOWN 513
#define WM_LBUTTONUP 514
#define WM_LBUTTONDBLCLK 515
#define WM_HOTKEY 786
#define WM_PRINT 791
#define WM_PRINTCLIENT 792
+#define WM_APPCOMMAND 793
#define WM_DWMCOMPOSITIONCHANGED 0x031E
#define WM_DWMNCRENDERINGCHANGED 0x031F
#define WM_APP 32768
#define WM_GETTITLEBARINFOEX 0x033F
+#define XBUTTON1 0x0001
+#define XBUTTON2 0x0002
#if (_WIN32_WINNT >= 0x0400)
#define WHEEL_DELTA 120
#define CB_SETLOCALE 345
#define CB_SETTOPINDEX 348
#define CB_SHOWDROPDOWN 335
+#define CB_MSGMAX 357
#define CBN_CLOSEUP 8
#define CBN_DBLCLK 2
#define CBN_DROPDOWN 7
#define LB_ADDFILE 406
#define LB_ADDSTRING 384
#ifdef _WINE
+#define LB_CARETON 419
#define LB_CARETOFF 420
#endif
#define LB_DELETESTRING 386
#define VK_F24 0x87
#define VK_NUMLOCK 0x90
#define VK_SCROLL 0x91
+#define VK_OEM_NEC_EQUAL 0x92
#define VK_LSHIFT 0xA0
#define VK_RSHIFT 0xA1
#define VK_LCONTROL 0xA2
BOOL WINAPI BringWindowToTop(HWND);
long WINAPI BroadcastSystemMessage(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
#if (_WIN32_WINNT >= 0x0400)
-long WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
-long WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
+LONG WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
+LONG WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
#endif /* (_WIN32_WINNT >= 0x0400) */
#if (_WIN32_WINNT >= 0x0501)
-long WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO);
-long WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO);
+LONG WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO);
+LONG WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO);
#endif /* (_WIN32_WINNT >= 0x0501) */
+void WINAPI CalcChildScroll(HWND, INT);
BOOL WINAPI CallMsgFilterA(LPMSG,INT);
BOOL WINAPI CallMsgFilterW(LPMSG,INT);
LRESULT WINAPI CallNextHookEx(HHOOK,int,WPARAM,LPARAM);
HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
HWND WINAPI CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID);
#ifndef NOWINDOWSTATION
-HWINSTA WINAPI CreateWindowStationA(LPSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES);
-HWINSTA WINAPI CreateWindowStationW(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES);
+HWINSTA WINAPI CreateWindowStationA(LPCSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
+HWINSTA WINAPI CreateWindowStationW(LPCWSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES);
#endif
LRESULT WINAPI DefDlgProcA(HWND,UINT,WPARAM,LPARAM);
LRESULT WINAPI DefDlgProcW(HWND,UINT,WPARAM,LPARAM);
HDC WINAPI GetDC(HWND);
HDC WINAPI GetDCEx(HWND,HRGN,DWORD);
HWND WINAPI GetDesktopWindow(void);
-long WINAPI GetDialogBaseUnits(void);
+LONG WINAPI GetDialogBaseUnits(void);
int WINAPI GetDlgCtrlID(HWND);
HWND WINAPI GetDlgItem(HWND,int);
UINT WINAPI GetDlgItemInt(HWND,int,PBOOL,BOOL);
BOOL WINAPI IsZoomed(HWND);
VOID WINAPI keybd_event(BYTE,BYTE,DWORD,ULONG_PTR);
BOOL WINAPI KillTimer(HWND,UINT_PTR);
+BOOL WINAPI KillSystemTimer(HWND,UINT_PTR);
HACCEL WINAPI LoadAcceleratorsA(HINSTANCE,LPCSTR);
HACCEL WINAPI LoadAcceleratorsW(HINSTANCE,LPCWSTR);
HBITMAP WINAPI LoadBitmapA(HINSTANCE,LPCSTR);
BOOL WINAPI OemToCharW(LPCSTR,LPWSTR);
BOOL WINAPI OffsetRect(LPRECT,int,int);
BOOL WINAPI OpenClipboard(HWND);
-HDESK WINAPI OpenDesktopA(LPSTR,DWORD,BOOL,DWORD);
-HDESK WINAPI OpenDesktopW(LPWSTR,DWORD,BOOL,DWORD);
+HDESK WINAPI OpenDesktopA(LPCSTR,DWORD,BOOL,DWORD);
+HDESK WINAPI OpenDesktopW(LPCWSTR,DWORD,BOOL,DWORD);
BOOL WINAPI OpenIcon(HWND);
HDESK WINAPI OpenInputDesktop(DWORD,BOOL,DWORD);
-HWINSTA WINAPI OpenWindowStationA(LPSTR,BOOL,DWORD);
-HWINSTA WINAPI OpenWindowStationW(LPWSTR,BOOL,DWORD);
+HWINSTA WINAPI OpenWindowStationA(LPCSTR,BOOL,DWORD);
+HWINSTA WINAPI OpenWindowStationW(LPCWSTR,BOOL,DWORD);
BOOL WINAPI PaintDesktop(HDC);
BOOL WINAPI PeekMessageA(LPMSG,HWND,UINT,UINT,UINT);
BOOL WINAPI PeekMessageW(LPMSG,HWND,UINT,UINT,UINT);
HANDLE WINAPI RemovePropW(HWND,LPCWSTR);
BOOL WINAPI ReplyMessage(LRESULT);
BOOL WINAPI ScreenToClient(HWND,LPPOINT);
+VOID WINAPI ScrollChildren(HWND,UINT,WPARAM,LPARAM);
BOOL WINAPI ScrollDC(HDC,int,int,LPCRECT,LPCRECT,HRGN,LPRECT);
BOOL WINAPI ScrollWindow(HWND,int,int,LPCRECT,LPCRECT);
int WINAPI ScrollWindowEx(HWND,int,int,LPCRECT,LPCRECT,HRGN,LPRECT,UINT);
HCURSOR WINAPI SetCursor(HCURSOR);
BOOL WINAPI SetCursorPos(int,int);
VOID WINAPI SetDebugErrorLevel(DWORD);
+BOOL WINAPI SetDeskWallPaper(LPCSTR);
BOOL WINAPI SetDlgItemInt(HWND,int,UINT,BOOL);
BOOL WINAPI SetDlgItemTextA(HWND,int,LPCSTR);
BOOL WINAPI SetDlgItemTextW(HWND,int,LPCWSTR);
DWORD WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD);
#define SetSysModalWindow(h) (NULL)
BOOL WINAPI SetSystemCursor(HCURSOR,DWORD);
+BOOL WINAPI SetSystemMenu(HWND,HMENU);
BOOL WINAPI SetThreadDesktop(HDESK);
UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC);
+UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC);
BOOL WINAPI SetUserObjectInformationA(HANDLE,int,PVOID,DWORD);
BOOL WINAPI SetUserObjectInformationW(HANDLE,int,PVOID,DWORD);
BOOL WINAPI SetUserObjectSecurity(HANDLE,PSECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_INTERNAL
#pragma pack(push,_CRT_PACKING)
+#ifndef __INTERNAL_FUNC_DEFINED
+#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
+#endif
-#if defined (SPECIAL_CRTEXE) && defined (_DLL)
+#if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
extern int _commode;
#else
_CRTIMP extern int _commode;
#define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
#ifndef __badioinfo
- extern ioinfo ** _imp____badioinfo[];
-#define __badioinfo (*_imp____badioinfo)
+ extern ioinfo ** __MINGW_IMP_SYMBOL(__badioinfo)[];
+#define __badioinfo (* __MINGW_IMP_SYMBOL(__badioinfo))
#endif
#ifndef __pioinfo
- extern ioinfo ** _imp____pioinfo[];
-#define __pioinfo (*_imp____pioinfo)
+ extern ioinfo ** __MINGW_IMP_SYMBOL(__pioinfo)[];
+#define __pioinfo (* __MINGW_IMP_SYMBOL(__pioinfo))
#endif
#define _NO_CONSOLE_FILENO (intptr_t)-2
extern int _newmode;
#ifndef __winitenv
-extern wchar_t ***_imp____winitenv;
-#define __winitenv (*_imp____winitenv)
+extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
+#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
#endif
#ifndef __initenv
-extern char ***_imp____initenv;
-#define __initenv (*_imp____initenv)
+extern char *** __MINGW_IMP_SYMBOL(__initenv);
+#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
#ifndef _acmdln
-extern char **_imp___acmdln;
-#define _acmdln (*_imp___acmdln)
+extern char ** __MINGW_IMP_SYMBOL(_acmdln);
+#define _acmdln (* __MINGW_IMP_SYMBOL(_acmdln))
/* _CRTIMP extern char *_acmdln; */
#endif
#ifndef _wcmdln
-extern char **_imp___wcmdln;
-#define _wcmdln (*_imp___wcmdln)
+extern char ** __MINGW_IMP_SYMBOL(_wcmdln);
+#define _wcmdln (* __MINGW_IMP_SYMBOL(_wcmdln))
/* __CRTIMP extern wchar_t *_wcmdln; */
#endif
#include <errno.h>
void * __cdecl _encode_pointer(void *);
- void * __cdecl _encoded_null(void);
+ void * __cdecl _encoded_null();
void * __cdecl _decode_pointer(void *);
BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_OSCALLS
--- /dev/null
+Index: internal.h
+===================================================================
+--- internal.h (Revision 46537)
++++ internal.h (Arbeitskopie)
+@@ -35,6 +35,12 @@
+ #define __IOINFO_TM_UTF8 1
+ #define __IOINFO_TM_UTF16LE 2
+
++#ifdef _MSC_VER
++#pragma warning(push)
++#pragma warning(disable:4214)
++#pragma warning(disable:4820)
++#endif
++
+ typedef struct {
+ intptr_t osfhnd;
+ char osfile;
+@@ -46,6 +52,10 @@
+ char pipech2[2];
+ } ioinfo;
+
++#ifdef _MSC_VER
++#pragma warning(pop)
++#endif
++
+ #define IOINFO_ARRAY_ELTS (1 << 5)
+
+ #define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
+Index: oscalls.h
+===================================================================
+--- oscalls.h (Revision 46537)
++++ oscalls.h (Arbeitskopie)
+@@ -30,6 +30,11 @@
+ #endif
+ #endif
+
++#ifdef _MSC_VER
++#pragma warning(push)
++#pragma warning(disable:4214)
++#endif
++
+ typedef struct _FTIME
+ {
+ unsigned short twosecs : 5;
+@@ -46,6 +51,10 @@
+ unsigned short year : 7;
+ } FDATE;
+
++#ifdef _MSC_VER
++#pragma warning(pop)
++#endif
++
+ typedef FDATE *PFDATE;
+
+ #endif
+Index: sect_attribs.h
+===================================================================
+--- sect_attribs.h (Revision 46537)
++++ sect_attribs.h (Arbeitskopie)
+@@ -10,7 +10,7 @@
+ #define _ATTRIBUTES shared
+ #endif
+
+-#if 0
++#if defined(_MSC_VER)
+ /* Reference list of existing section for msvcrt. */
+ #pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
+ #pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
+@@ -55,6 +55,14 @@
+ #pragma section(".rtc$IZZ",long,read)
+ #pragma section(".rtc$TAA",long,read)
+ #pragma section(".rtc$TZZ",long,read)
++#pragma section(".tls",long,read,write)
++#pragma section(".tls$ZZZ",long,read,write)
+ #endif
+
++#if defined(_MSC_VER)
++#define _CRTALLOC(x) __declspec(allocate(x))
++#elif defined(__GNUC__)
+ #define _CRTALLOC(x) __attribute__ ((section (x) ))
++#else
++#error
++#endif
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if defined (__ia64__) || defined (__x86_64)
#define free libwine_free
#define realloc libwine_realloc
#define _strdup libwine__strdup
+#define interlocked_xchg_add InterlockedExchangeAdd
#include "debug.c"
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
+void _fpreset (void);
+
void _fpreset (void)
{
#ifdef __GNUC__
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
-extern void (*_imp___fpreset)(void) ;
+#include <_mingw.h>
+
+extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void);
+void _fpreset (void);
+
void _fpreset (void)
-{ (*_imp___fpreset)(); }
+{
+ (* __MINGW_IMP_SYMBOL(_fpreset))();
+}
#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);
--- /dev/null
+/*
+ * CRT_glob.c
+ * This file has no copyright is assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within the package.
+ *
+ * Include this object file to set _dowildcard to a state that will turn on
+ * command line globbing by default. (wildcard.o which goes into libmingw32.a
+ * has a default state of off.)
+ *
+ * To use this object include the object file in your link command:
+ * gcc -o foo.exe foo.o CRT_glob.o
+ *
+ */
+
+int _dowildcard = -1;
+
--- /dev/null
+/*
+ * CRT_noglob.c
+ * This file has no copyright is assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within the package.
+ *
+ * Include this object file to set _dowildcard to a state that will turn off
+ * command line globbing by default. (wildcard.o which goes into libmingw32.a
+ * has a default state of off if not configured with --enable-wildcard.)
+ *
+ * To use this object include the object file in your link command:
+ * gcc -o foo.exe foo.o CRT_noglob.o
+ *
+ */
+
+int _dowildcard = 0;
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _newmode = 0;
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL
_PVFV *__onexitend;
extern _CRTIMP _onexit_t __dllonexit (_onexit_t, _PVFV**, _PVFV**);
-extern _onexit_t (__cdecl *_imp___onexit) (_onexit_t func);
+extern _onexit_t (__cdecl * __MINGW_IMP_SYMBOL(_onexit)) (_onexit_t func);
/* Choose a different name to prevent name conflicts. The CRT one works fine. */
+_onexit_t __cdecl mingw_onexit(_onexit_t func);
+
_onexit_t __cdecl mingw_onexit(_onexit_t func)
{
_PVFV *onexitbegin;
onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
if (onexitbegin == (_PVFV *) -1)
- return (*_imp___onexit) (func);
+ return (* __MINGW_IMP_SYMBOL(_onexit)) (func);
_lock (_EXIT_LOCK1);
onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
onexitend = (_PVFV *) _decode_pointer (__onexitend);
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define SPECIAL_CRTEXE
+
+#include <fcntl.h>
+#include <stdlib.h>
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <sect_attribs.h>
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
-int main (int flags, char **cmdline, char **inst)
+extern HINSTANCE __mingw_winmain_hInstance;
+extern LPSTR __mingw_winmain_lpCmdLine;
+extern DWORD __mingw_winmain_nShowCmd;
+
+/*ARGSUSED*/
+int main (int flags __attribute__ ((__unused__)),
+ char **cmdline __attribute__ ((__unused__)),
+ char **inst __attribute__ ((__unused__)))
{
- return (int) WinMain ((HINSTANCE) inst, NULL, (LPSTR) cmdline,(DWORD) flags);
+ return (int) WinMain (__mingw_winmain_hInstance, NULL,
+ __mingw_winmain_lpCmdLine, __mingw_winmain_nShowCmd);
}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
-
#include <windows.h>
-extern void __main(void);
-
+/* Do the UNICODE prototyping of WinMain. Be aware that in winbase.h WinMain is a macro
+ defined to wWinMain. */
int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nShowCmd);
-int wmain (int flags, wchar_t **cmdline, wchar_t **inst)
+extern HINSTANCE __mingw_winmain_hInstance;
+extern LPWSTR __mingw_winmain_lpCmdLine;
+extern DWORD __mingw_winmain_nShowCmd;
+
+int wmain (int, wchar_t **, wchar_t **);
+
+/*ARGSUSED*/
+int wmain (int flags __attribute__ ((__unused__)),
+ wchar_t **cmdline __attribute__ ((__unused__)),
+ wchar_t **inst __attribute__ ((__unused__)))
{
- return (int) wWinMain ((HINSTANCE) inst, NULL, (LPWSTR) cmdline,(DWORD) flags);
+ return (int) wWinMain (__mingw_winmain_hInstance, NULL,
+ __mingw_winmain_lpCmdLine, __mingw_winmain_nShowCmd);
}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <windows.h>
+#include <excpt.h>
+#include <string.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+
+#if defined (_WIN64) && defined (__ia64__)
+#error FIXME: Unsupported __ImageBase implementation.
+#else
+#define __ImageBase __MINGW_LSYMBOL(_image_base__)
+/* This symbol is defined by the linker. */
+extern IMAGE_DOS_HEADER __ImageBase;
+#endif
+
+#pragma pack(push,1)
+typedef struct _UNWIND_INFO {
+ BYTE VersionAndFlags;
+ BYTE PrologSize;
+ BYTE CountOfUnwindCodes;
+ BYTE FrameRegisterAndOffset;
+ ULONG AddressOfExceptionHandler;
+} UNWIND_INFO,*PUNWIND_INFO;
+#pragma pack(pop)
+
+PIMAGE_SECTION_HEADER _FindPESectionByName (const char *);
+PIMAGE_SECTION_HEADER _FindPESectionExec (size_t);
+PBYTE _GetPEImageBase (void);
+
+int __mingw_init_ehandler (void);
+
+#ifdef _WIN64
+EXCEPTION_DISPOSITION __mingw_SEH_error_handler(struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, void *);
+
+#define MAX_PDATA_ENTRIES 32
+static RUNTIME_FUNCTION emu_pdata[MAX_PDATA_ENTRIES];
+static UNWIND_INFO emu_xdata[MAX_PDATA_ENTRIES];
+
+int
+__mingw_init_ehandler (void)
+{
+ static int was_here = 0;
+ size_t e = 0;
+ PIMAGE_SECTION_HEADER pSec;
+ PBYTE _ImageBase = _GetPEImageBase ();
+
+ if (was_here || !_ImageBase)
+ return was_here;
+ was_here = 1;
+ if (_FindPESectionByName (".pdata") != NULL)
+ return 1;
+
+ /* Allocate # of e tables and entries. */
+ memset (emu_pdata, 0, sizeof (RUNTIME_FUNCTION) * MAX_PDATA_ENTRIES);
+ memset (emu_xdata, 0, sizeof (UNWIND_INFO) * MAX_PDATA_ENTRIES);
+
+ e = 0;
+ /* Fill tables and entries. */
+ while (e < MAX_PDATA_ENTRIES && (pSec = _FindPESectionExec (e)) != NULL)
+ {
+ emu_xdata[e].VersionAndFlags = 9; /* UNW_FLAG_EHANDLER | UNW_VERSION */
+ emu_xdata[e].AddressOfExceptionHandler =
+ (DWORD)(size_t) ((LPBYTE)__mingw_SEH_error_handler - _ImageBase);
+ emu_pdata[e].BeginAddress = pSec->VirtualAddress;
+ emu_pdata[e].EndAddress = pSec->VirtualAddress + pSec->Misc.VirtualSize;
+ emu_pdata[e].UnwindData =
+ (DWORD)(size_t)((LPBYTE)&emu_xdata[e] - _ImageBase);
+ ++e;
+ }
+#ifdef _DEBUG_CRT
+ if (!e || e > MAX_PDATA_ENTRIES)
+ abort ();
+#endif
+ /* RtlAddFunctionTable. */
+ if (e != 0)
+ RtlAddFunctionTable (emu_pdata, e, (DWORD64)_ImageBase);
+ return 1;
+}
+
+extern void _fpreset (void);
+
+EXCEPTION_DISPOSITION
+__mingw_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
+ void *EstablisherFrame __attribute__ ((unused)),
+ struct _CONTEXT* ContextRecord __attribute__ ((unused)),
+ void *DispatcherContext __attribute__ ((unused)))
+{
+ EXCEPTION_DISPOSITION action = EXCEPTION_CONTINUE_SEARCH;
+ void (*old_handler) (int);
+ int reset_fpu = 0;
+
+ switch (ExceptionRecord->ExceptionCode)
+ {
+ case EXCEPTION_ACCESS_VIOLATION:
+ /* test if the user has set SIGSEGV */
+ old_handler = signal (SIGSEGV, SIG_DFL);
+ if (old_handler == SIG_IGN)
+ {
+ /* this is undefined if the signal was raised by anything other
+ than raise (). */
+ signal (SIGSEGV, SIG_IGN);
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else if (old_handler != SIG_DFL)
+ {
+ /* This means 'old' is a user defined function. Call it */
+ (*old_handler) (SIGSEGV);
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else
+ action = EXCEPTION_EXECUTE_HANDLER;
+ break;
+ case EXCEPTION_ILLEGAL_INSTRUCTION:
+ case EXCEPTION_PRIV_INSTRUCTION:
+ /* test if the user has set SIGILL */
+ old_handler = signal (SIGILL, SIG_DFL);
+ if (old_handler == SIG_IGN)
+ {
+ /* this is undefined if the signal was raised by anything other
+ than raise (). */
+ signal (SIGILL, SIG_IGN);
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else if (old_handler != SIG_DFL)
+ {
+ /* This means 'old' is a user defined function. Call it */
+ (*old_handler) (SIGILL);
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else
+ action = EXCEPTION_EXECUTE_HANDLER;
+ break;
+ case EXCEPTION_FLT_INVALID_OPERATION:
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ case EXCEPTION_FLT_DENORMAL_OPERAND:
+ case EXCEPTION_FLT_OVERFLOW:
+ case EXCEPTION_FLT_UNDERFLOW:
+ case EXCEPTION_FLT_INEXACT_RESULT:
+ reset_fpu = 1;
+ /* fall through. */
+
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ /* test if the user has set SIGFPE */
+ old_handler = signal (SIGFPE, SIG_DFL);
+ if (old_handler == SIG_IGN)
+ {
+ signal (SIGFPE, SIG_IGN);
+ if (reset_fpu)
+ _fpreset ();
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ else if (old_handler != SIG_DFL)
+ {
+ /* This means 'old' is a user defined function. Call it */
+ (*old_handler) (SIGFPE);
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ }
+ break;
+ case EXCEPTION_DATATYPE_MISALIGNMENT:
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+ case EXCEPTION_FLT_STACK_CHECK:
+ case EXCEPTION_INT_OVERFLOW:
+ case EXCEPTION_INVALID_HANDLE:
+ /*case EXCEPTION_POSSIBLE_DEADLOCK: */
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ break;
+ default:
+ break;
+ }
+ return action;
+}
+
+#endif
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
+/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
static int __proc_attached = 0;
extern int mingw_app_type;
-extern BOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
+extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
-extern BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
+extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
static int pre_c_init (void);
return 0;
}
-BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
+WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
if (dwReason == DLL_PROCESS_DETACH)
{
}
if (! nested)
{
- InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
+ (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
}
- if (__dyn_tls_init_callback != NULL &&
- _IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
+ if (__dyn_tls_init_callback != NULL)
{
__dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved);
}
__onexitbegin = __onexitend = (_PVFV *) NULL;
}
__native_startup_state = __uninitialized;
- InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
+ (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
}
}
return TRUE;
}
-static BOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
+static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
-BOOL WINAPI
-DllMainCRTStartup(HANDLE hDllHandle,DWORD dwReason,LPVOID lpreserved)
+WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
+int __mingw_init_ehandler (void);
+
+WINBOOL WINAPI
+DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
mingw_app_type = 0;
if (dwReason == DLL_PROCESS_ATTACH)
{
__security_init_cookie ();
+#ifdef _WIN64
+ __mingw_init_ehandler ();
+#endif
}
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
}
-__declspec(noinline) BOOL
+__declspec(noinline) WINBOOL
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
- BOOL retcode = TRUE;
+ WINBOOL retcode = TRUE;
__native_dllmain_reason = dwReason;
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL
#include <intrin.h>
#ifndef __winitenv
-extern wchar_t ***_imp____winitenv;
-#define __winitenv (*_imp____winitenv)
+extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
+#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
#endif
#ifndef __initenv
-extern char ***_imp____initenv;
-#define __initenv (*_imp____initenv)
+extern char *** __MINGW_IMP_SYMBOL(__initenv);
+#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
/* Hack, for bug in ld. Will be removed soon. */
-#define __ImageBase _image_base__
+#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by ld. */
extern IMAGE_DOS_HEADER __ImageBase;
__declspec(dllimport) void __setusermatherr(int (__cdecl *)(struct _exception *));
-extern int *_imp___fmode;
-extern int *_imp___commode;
+extern int * __MINGW_IMP_SYMBOL(_fmode);
+extern int * __MINGW_IMP_SYMBOL(_commode);
#undef _fmode
extern int _fmode;
-extern int *_imp___commode;
-#define _commode (*_imp___commode)
+extern int * __MINGW_IMP_SYMBOL(_commode);
+#define _commode (* __MINGW_IMP_SYMBOL(_commode))
extern int _dowildcard;
#if defined(__GNUC__)
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
+/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
extern _PVFV *__onexitbegin;
extern int mingw_app_type;
+HINSTANCE __mingw_winmain_hInstance;
+_TCHAR *__mingw_winmain_lpCmdLine;
+DWORD __mingw_winmain_nShowCmd;
+
static int argc;
#ifdef WPRFLAG
extern void __main(void);
static int managedapp;
static int has_cctor = 0;
static _startupinfo startinfo;
+static LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler = NULL;
extern void _pei386_runtime_relocator (void);
static long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
-//static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
#ifdef WPRFLAG
static void duplicate_ppstrings (int ac, wchar_t ***av);
#else
static int __cdecl pre_c_init (void);
static void __cdecl pre_cpp_init (void);
-
+static void __cdecl __mingw_prepare_except_for_msvcr80_and_higher (void);
_CRTALLOC(".CRT$XIAA") _PIFV mingw_pcinit = pre_c_init;
_CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init;
__set_app_type (_CONSOLE_APP);
__onexitbegin = __onexitend = (_PVFV *) _encode_pointer ((_PVFV *)(-1));
- *_imp___fmode = _fmode;
- *_imp___commode = _commode;
+ * __MINGW_IMP_SYMBOL(_fmode) = _fmode;
+ * __MINGW_IMP_SYMBOL(_commode) = _commode;
#ifdef WPRFLAG
_wsetargv();
static int __tmainCRTStartup (void);
+int WinMainCRTStartup (void);
+
int WinMainCRTStartup (void)
{
mingw_app_type = 1;
return __tmainCRTStartup ();
}
+int mainCRTStartup (void);
+
+#ifdef _WIN64
+int __mingw_init_ehandler (void);
+#endif
+
int mainCRTStartup (void)
{
mingw_app_type = 0;
return __tmainCRTStartup ();
}
-
+static
__declspec(noinline) int
__tmainCRTStartup (void)
{
_TCHAR *lpszCommandLine = NULL;
STARTUPINFO StartupInfo;
- BOOL inDoubleQuote = FALSE;
+ WINBOOL inDoubleQuote = FALSE;
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
-
+
if (mingw_app_type)
GetStartupInfo (&StartupInfo);
{
_ASSERTE(__native_startup_state == __initialized);
if (! nested)
(VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
-
- if (__dyn_tls_init_callback != NULL && _IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
+
+ if (__dyn_tls_init_callback != NULL)
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
-
+
_pei386_runtime_relocator ();
-
-#if defined(__i386__) || defined(_M_IX86)
- __writefsdword(0, 0xffffffff);
+ __mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
+#ifdef _WIN64
+ __mingw_init_ehandler ();
#endif
- //AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
- SetUnhandledExceptionFilter (_gnu_exception_handler);
-
+ __mingw_prepare_except_for_msvcr80_and_higher ();
+
_fpreset ();
if (mingw_app_type)
#ifdef _MBCS
if (_ismbblead (*lpszCommandLine))
{
- if (lpszCommandLine)
+ if (*lpszCommandLine)
lpszCommandLine++;
}
#endif
while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
lpszCommandLine++;
-#ifdef WPRFLAG
- /* C++ initialization.
- gcc inserts this call automatically for a function called main, but not for wmain. */
- __main ();
- mainret = wmain (
- (int) (StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT),
- (wchar_t **) lpszCommandLine, (wchar_t **) (HINSTANCE) &__ImageBase);
-#else
- mainret = main (
- (int) (StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT),
- (char **) lpszCommandLine, (char **) (HINSTANCE) &__ImageBase);
-#endif
+ __mingw_winmain_hInstance = (HINSTANCE) &__ImageBase;
+ __mingw_winmain_lpCmdLine = lpszCommandLine;
+ __mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ?
+ StartupInfo.wShowWindow : SW_SHOWDEFAULT;
}
- else
- {
duplicate_ppstrings (argc, &argv);
#ifdef WPRFLAG
__winitenv = envp;
__initenv = envp;
mainret = main (argc, argv, envp);
#endif
- }
if (!managedapp)
exit (mainret);
}
static long CALLBACK
-_gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
+_gnu_exception_handler (EXCEPTION_POINTERS *exception_data)
{
void (*old_handler) (int);
long action = EXCEPTION_CONTINUE_SEARCH;
action = EXCEPTION_CONTINUE_EXECUTION;
}
break;
-
+#ifdef _WIN64
+ case EXCEPTION_DATATYPE_MISALIGNMENT:
+ case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
+ case EXCEPTION_FLT_STACK_CHECK:
+ case EXCEPTION_INT_OVERFLOW:
+ case EXCEPTION_INVALID_HANDLE:
+ /*case EXCEPTION_POSSIBLE_DEADLOCK: */
+ action = EXCEPTION_CONTINUE_EXECUTION;
+ break;
+#endif
default:
break;
}
- return action;
-}
-#if 0
-static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data)
-{
- /* TODO this is not chainablem, therefore need rewrite. Disabled the ill code. */
- #if 0
- #ifdef _WIN64
- __asm__ __volatile__ (
- "movq %gs:0,%rax" "\n\t"
- "orq %rax,%rax\n\t"
- "jz l1\n\t"
- "jmp *8(%rax)\n\r"
- "l1:\n\t"
- "nop\n");
-#else
- __asm__ __volatile__ (
- "movl %fs:0,%eax" "\n\t"
- "orl %eax,%eax\n\t"
- "jz l1\n\t"
- "jmp *4(%eax)\n\r"
- "l1:\n\t"
- "nop\n");
-#endif
-#endif
- return _gnu_exception_handler(exception_data);
+ if (action == EXCEPTION_CONTINUE_SEARCH && __mingw_oldexcpt_handler)
+ action = (*__mingw_oldexcpt_handler)(exception_data);
+ return action;
}
-#endif
#ifdef WPRFLAG
-
static size_t wbytelen(const wchar_t *p)
{
size_t ret = 1;
char **avl;
int i;
char **n = (char **) malloc (sizeof (char *) * (ac + 1));
-
+
avl=*av;
for (i=0; i < ac; i++)
{
*av = n;
}
#endif
+
+static void
+__mingw_invalidParameterHandler (const wchar_t *expression __attribute__ ((__unused__)),
+ const wchar_t *function __attribute__ ((__unused__)),
+ const wchar_t *file __attribute__ ((__unused__)),
+ unsigned int line __attribute__ ((__unused__)),
+ uintptr_t pReserved __attribute__ ((__unused__)))
+{
+#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
+ wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
+ wprintf(L"Expression: %s\n", expression);
+#endif
+}
+
+static void __cdecl
+__mingw_prepare_except_for_msvcr80_and_higher (void)
+{
+ _invalid_parameter_handler (*fIPH)(_invalid_parameter_handler) = NULL;
+ HMODULE hmsv = GetModuleHandleA ("msvcr80.dll");
+ if(!hmsv)
+ hmsv = GetModuleHandleA ("msvcr70.dll");
+ if (!hmsv)
+ hmsv = GetModuleHandleA ("msvcrt.dll");
+ if (!hmsv)
+ hmsv = LoadLibraryA ("msvcrt.dll");
+ if (!hmsv)
+ return;
+ fIPH = (_invalid_parameter_handler (*)(_invalid_parameter_handler))
+ GetProcAddress (hmsv, "_set_invalid_parameter_handler");
+ if (fIPH)
+ (*fIPH)(__mingw_invalidParameterHandler);
+}
--- /dev/null
+
+void _assert(int);
+
+void __cxa_pure_virtual()
+{
+ _assert(0);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifdef CRTDLL
+#undef CRTDLL
+#endif
+
+#include <internal.h>
+
+extern int _dowildcard;
+
+#ifdef WPRFLAG
+int __CRTDECL
+__wsetargv (void)
+#else
+int __CRTDECL
+__setargv (void)
+#endif
+{
+ _dowildcard = 1;
+ return 0;
+}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>
#define _DECL_DLLMAIN
#include <process.h>
-BOOL WINAPI DllEntryPoint(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
+BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
+
+BOOL WINAPI DllEntryPoint (HANDLE hDllHandle __attribute__ ((__unused__)),
+ DWORD dwReason __attribute__ ((__unused__)),
+ LPVOID lpreserved __attribute__ ((__unused__)))
{
return TRUE;
}
#define _DECL_DLLMAIN
#include <process.h>
-BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
+BOOL WINAPI DllMain (HANDLE hDllHandle __attribute__ ((__unused__)),
+ DWORD dwReason __attribute__ ((__unused__)),
+ LPVOID lpreserved __attribute__ ((__unused__)))
{
return TRUE;
}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
extern func_ptr __DTOR_LIST__[];
static HMODULE hMsvcrt = NULL;
+static int free_Msvcrt = 0;
typedef void __cdecl flongjmp(jmp_buf _Buf,int _Value);
flongjmp *fctMsvcrtLongJmp = NULL;
+void __do_global_dtors (void);
+void __do_global_ctors (void);
+void __main (void);
+
void
__do_global_dtors (void)
{
(*(p)) ();
p++;
}
- if (hMsvcrt)
+ if (free_Msvcrt && hMsvcrt)
{
+ free_Msvcrt = 0;
FreeLibrary (hMsvcrt);
hMsvcrt = NULL;
}
unsigned long i;
if (!hMsvcrt) {
- hMsvcrt = LoadLibrary ("msvcrt.dll");
+ hMsvcrt = GetModuleHandleA ("msvcr80.dll");
+ if (!hMsvcrt)
+ hMsvcrt = GetModuleHandleA ("msvcr70.dll");
+ if (!hMsvcrt)
+ hMsvcrt = GetModuleHandleA ("msvcrt.dll");
+ if (!hMsvcrt) {
+ hMsvcrt = LoadLibraryA ("msvcrt.dll");
+ free_Msvcrt = 1;
+ }
fctMsvcrtLongJmp = (flongjmp *) GetProcAddress( hMsvcrt, "longjmp");
}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
DECLSPEC_SELECTANY UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE;
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE);
+void __cdecl __security_init_cookie (void);
+
void __cdecl
__security_init_cookie (void)
{
__security_cookie_complement = ~cookie;
}
+__declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
+
__declspec(noreturn) void __cdecl
__report_gsfailure (ULONGLONG StackCookie)
{
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <ctype.h>
+
+#undef isascii
+int isascii (int);
+
+int
+isascii (int c)
+{
+ return __isascii(c);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <ctype.h>
+#undef iscsym
+
+int iscsym (int);
+
+int
+iscsym (int c)
+{
+ return __iscsym(c);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <ctype.h>
+#undef iscsymf
+
+int iscsymf (int);
+
+int
+iscsymf (int c)
+{
+ return __iscsymf(c);
+}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <internal.h>
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <_mingw.h>
+#include "../revstamp.h"
+
+const char *__mingw_get_crt_info (void)
+{
+ return "MinGW-W64 Runtime " __MINGW64_VERSION_STR " ("
+ __MINGW64_VERSION_STATE " - "
+ "rev. " __MINGW_W64_REV ") " __MINGW_W64_REV_STAMP;
+}
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>
+LIBRARY msvcrt.dll
+
EXPORTS
-access
-chdir
-chmod
-chsize
-close
-creat
-cwait
-daylight DATA
-dup
-dup2
-ecvt
-eof
-execl
-execle
-execlp
-execlpe
-execv
-execve
-execvp
-execvpe
-fcvt
-fdopen
-fgetchar
-fgetwchar
-filelength
-fileno
-; fpreset
-fputchar
-fputwchar
-;fstat
-ftime
-gcvt
-getch
-getche
-getcwd
-getpid
-getw
-heapwalk
-isatty
-itoa
-kbhit
-lfind
-lsearch
-lseek
-ltoa
-memccpy
-memicmp
-mkdir
-mktemp
-open
-pclose
-popen
-putch
-putenv
-putw
-read
-rmdir
-rmtmp
-searchenv
-setmode
-sopen
-spawnl
-spawnle
-spawnlp
-spawnlpe
-spawnv
-spawnve
-spawnvp
-spawnvpe
-;stat
-strcmpi
-strdup
-stricmp
-stricoll
-strlwr
-strnicmp
-strnset
-strrev
-strset
-strupr
-swab
-tell
-tempnam
-timezone DATA
-tzname DATA
-tzset
-umask
-ungetch
-unlink
-utime
-wcsdup
-wcsicmp
-wcsicoll
-wcslwr
-wcsnicmp
-wcsnset
-wcsrev
-wcsset
-wcsupr
-wpopen
-write
+access==_access
+chdir==_chdir
+chmod==_chmod
+chsize==_chsize
+close==_close
+creat==_creat
+cwait==_cwait
+daylight==_daylight
+dup==_dup
+dup2==_dup2
+ecvt==_ecvt
+eof==_eof
+execl==_execl
+execle==_execle
+execlp==_execlp
+execlpe==_execlpe
+execv==_execv
+execve==_execve
+execvp==_execvp
+execvpe==_execvpe
+fcvt==_fcvt
+fdopen==_fdopen
+fgetchar==_fgetchar
+fgetwchar==_fgetwchar
+filelength==_filelength
+fileno==_fileno
+fpreset==_fpreset
+fputchar==_fputchar
+fputwchar==_fputwchar
+fstat==_fstat
+ftime==_ftime
+gcvt==_gcvt
+getch==_getch
+getche==_getche
+getcwd==_getcwd
+getpid==_getpid
+getw==_getw
+heapwalk==_heapwalk
+isatty==_isatty
+itoa==_itoa
+kbhit==_kbhit
+lfind==_lfind
+lsearch==_lsearch
+lseek==_lseek
+ltoa==_ltoa
+memccpy==_memccpy
+memicmp==_memicmp
+mkdir==_mkdir
+mktemp==_mktemp
+open==_open
+pclose==_pclose
+popen==_popen
+putch==_putch
+putenv==_putenv
+putw==_putw
+read==_read
+rmdir==_rmdir
+rmtmp==_rmtmp
+searchenv==_searchenv
+setmode==_setmode
+snprintf=_snprintf
+sopen==_sopen
+spawnl==_spawnl
+spawnle==_spawnle
+spawnlp==_spawnlp
+spawnlpe==_spawnlpe
+spawnv==_spawnv
+spawnve==_spawnve
+spawnvp==_spawnvp
+spawnvpe==_spawnvpe
+stat==_stat
+strcmpi==_strcmpi
+strdup==_strdup
+stricmp==_stricmp
+stricoll==_stricoll
+strlwr==_strlwr
+strnicmp==_strnicmp
+strnset==_strnset
+strrev==_strrev
+strset==_strset
+strupr==_strupr
+swab==_swab
+tell==_tell
+tempnam==_tempnam
+timezone==_timezone
+tzname==_tzname
+tzset==_tzset
+umask==_umask
+ungetch==_ungetch
+unlink==_unlink
+utime==_utime
+wcsdup==_wcsdup
+wcsicmp==_wcsicmp
+wcsicoll==_wcsicoll
+wcslwr==_wcslwr
+wcsnicmp==_wcsnicmp
+wcsnset==_wcsnset
+wcsrev==_wcsrev
+wcsset==_wcsset
+wcsupr==_wcsupr
+wpopen==_wpopen
+write==_write
; non-ANSI functions declared in math.h
-j0
-j1
-jn
-y0
-y1
-yn
-chgsign
-;scalb
-finite
-fpclass
+j0==_j0
+j1==_j1
+jn==_jn
+y0==_y0
+y1==_y1
+yn==_yn
+chgsign==_chgsign
+scalb==_scalb
+finite==_finite
+fpclass==_fpclass
; C99 functions
-cabs
-hypot
-logb
-nextafter
+cabs==_cabs
+hypot==_hypot
+logb==_logb
+nextafter==_nextafter
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <crtdefs.h>
--- /dev/null
+
+int _get_output_format(void)
+{
+ return 0;
+}
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
+#include <string.h>
#if defined (_WIN64) && defined (__ia64__)
#error FIXME: Unsupported __ImageBase implementation.
#else
/* Hack, for bug in ld. Will be removed soon. */
-#define __ImageBase _image_base__
+#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by the linker. */
extern IMAGE_DOS_HEADER __ImageBase;
#endif
-BOOL
+WINBOOL _ValidateImageBase (PBYTE);
+
+WINBOOL
_ValidateImageBase (PBYTE pImageBase)
{
PIMAGE_DOS_HEADER pDOSHeader;
return TRUE;
}
+PIMAGE_SECTION_HEADER _FindPESection (PBYTE, DWORD_PTR);
+
PIMAGE_SECTION_HEADER
_FindPESection (PBYTE pImageBase, DWORD_PTR rva)
{
return NULL;
}
-BOOL
+PIMAGE_SECTION_HEADER _FindPESectionByName (const char *);
+
+PIMAGE_SECTION_HEADER
+_FindPESectionByName (const char *pName)
+{
+ PBYTE pImageBase;
+ PIMAGE_NT_HEADERS pNTHeader;
+ PIMAGE_SECTION_HEADER pSection;
+ unsigned int iSection;
+
+ /* Long names aren't supported. */
+ if (strlen (pName) > IMAGE_SIZEOF_SHORT_NAME)
+ return NULL;
+
+ pImageBase = (PBYTE) &__ImageBase;
+ if (! _ValidateImageBase (pImageBase))
+ return NULL;
+
+ pNTHeader = (PIMAGE_NT_HEADERS) (pImageBase + ((PIMAGE_DOS_HEADER) pImageBase)->e_lfanew);
+
+ for (iSection = 0, pSection = IMAGE_FIRST_SECTION (pNTHeader);
+ iSection < pNTHeader->FileHeader.NumberOfSections;
+ ++iSection,++pSection)
+ {
+ if (!strncmp ((char *) &pSection->Name[0], pName, IMAGE_SIZEOF_SHORT_NAME))
+ return pSection;
+ }
+ return NULL;
+}
+
+PIMAGE_SECTION_HEADER _FindPESectionExec (size_t);
+
+PIMAGE_SECTION_HEADER
+_FindPESectionExec (size_t eNo)
+{
+ PBYTE pImageBase;
+ PIMAGE_NT_HEADERS pNTHeader;
+ PIMAGE_SECTION_HEADER pSection;
+ unsigned int iSection;
+
+ pImageBase = (PBYTE) &__ImageBase;
+ if (! _ValidateImageBase (pImageBase))
+ return NULL;
+
+ pNTHeader = (PIMAGE_NT_HEADERS) (pImageBase + ((PIMAGE_DOS_HEADER) pImageBase)->e_lfanew);
+
+ for (iSection = 0, pSection = IMAGE_FIRST_SECTION (pNTHeader);
+ iSection < pNTHeader->FileHeader.NumberOfSections;
+ ++iSection,++pSection)
+ {
+ if ((pSection->Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0)
+ {
+ if (!eNo)
+ return pSection;
+ --eNo;
+ }
+ }
+ return NULL;
+}
+
+PBYTE _GetPEImageBase (void);
+
+PBYTE
+_GetPEImageBase (void)
+{
+ PBYTE pImageBase;
+ pImageBase = (PBYTE) &__ImageBase;
+ if (! _ValidateImageBase (pImageBase))
+ return NULL;
+ return pImageBase;
+}
+
+WINBOOL _IsNonwritableInCurrentImage (PBYTE);
+
+WINBOOL
_IsNonwritableInCurrentImage (PBYTE pTarget)
{
PBYTE pImageBase;
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
- */
+/* pseudo-reloc.c
+
+ Contributed by Egor Duda <deo@logos-m.ru>
+ Modified by addition of runtime_pseudo_reloc version 2
+ by Kai Tietz <kai.tietz@onevision.com>
+
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ This source code is offered for use in the public domain. You may
+ use, modify or distribute it freely.
+
+ This code is distributed in the hope that it will be useful but
+ WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
+ DISCLAMED. This includes but is not limited to warrenties of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <memory.h>
+#if defined(__CYGWIN__)
+#include <wchar.h>
+#include <ntdef.h>
+#include <sys/cygwin.h>
+/* copied from winsup.h */
+# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
+/* custom status code: */
+#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
+#define SHORT_MSG_BUF_SZ 128
+#else
+# define NO_COPY
+#endif
+
+#ifdef __GNUC__
+#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#else
+#define ATTRIBUTE_NORETURN
+#endif
+
+#ifndef __MINGW_LSYMBOL
+#define __MINGW_LSYMBOL(sym) sym
+#endif
+
extern char __RUNTIME_PSEUDO_RELOC_LIST__;
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
-extern char _image_base__;
+extern char __MINGW_LSYMBOL(_image_base__);
+void _pei386_runtime_relocator (void);
+
+/* v1 relocation is basically:
+ * *(base + .target) += .addend
+ * where (base + .target) is always assumed to point
+ * to a DWORD (4 bytes).
+ */
typedef struct {
DWORD addend;
DWORD target;
} runtime_pseudo_reloc_item_v1;
+/* v2 relocation is more complex. In effect, it is
+ * *(base + .target) += *(base + .sym) - (base + .sym)
+ * with care taken in both reading, sign extension, and writing
+ * because .flags may indicate that (base + .target) may point
+ * to a BYTE, WORD, DWORD, or QWORD (w64).
+ */
typedef struct {
DWORD sym;
DWORD target;
} runtime_pseudo_reloc_item_v2;
typedef struct {
- DWORD magic1;
- DWORD magic2;
- DWORD version;
+ DWORD magic1;
+ DWORD magic2;
+ DWORD version;
} runtime_pseudo_reloc_v2;
+static void ATTRIBUTE_NORETURN
+__report_error (const char *msg, ...)
+{
+#ifdef __CYGWIN__
+ /* This function is used to print short error messages
+ * to stderr, which may occur during DLL initialization
+ * while fixing up 'pseudo' relocations. This early, we
+ * may not be able to use cygwin stdio functions, so we
+ * use the win32 WriteFile api. This should work with both
+ * normal win32 console IO handles, redirected ones, and
+ * cygwin ptys.
+ */
+ char buf[SHORT_MSG_BUF_SZ];
+ wchar_t module[MAX_PATH];
+ char * posix_module = NULL;
+ static const char UNKNOWN_MODULE[] = "<unknown module>: ";
+ static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1;
+ static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: ";
+ static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1;
+ DWORD len;
+ DWORD done;
+ va_list args;
+ HANDLE errh = GetStdHandle (STD_ERROR_HANDLE);
+ ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module));
+
+ if (errh == INVALID_HANDLE_VALUE)
+ cygwin_internal (CW_EXIT_PROCESS,
+ STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
+ 1);
+
+ if (modulelen > 0)
+ posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module);
+
+ va_start (args, msg);
+ len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args);
+ va_end (args);
+ buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */
+
+ if (posix_module)
+ {
+ WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
+ CYGWIN_FAILURE_MSG_LEN, &done, NULL);
+ WriteFile (errh, (PCVOID)posix_module,
+ strlen(posix_module), &done, NULL);
+ WriteFile (errh, (PCVOID)": ", 2, &done, NULL);
+ WriteFile (errh, (PCVOID)buf, len, &done, NULL);
+ free (posix_module);
+ }
+ else
+ {
+ WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
+ CYGWIN_FAILURE_MSG_LEN, &done, NULL);
+ WriteFile (errh, (PCVOID)UNKNOWN_MODULE,
+ UNKNOWN_MODULE_LEN, &done, NULL);
+ WriteFile (errh, (PCVOID)buf, len, &done, NULL);
+ }
+ WriteFile (errh, (PCVOID)"\n", 1, &done, NULL);
+
+ cygwin_internal (CW_EXIT_PROCESS,
+ STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
+ 1);
+ /* not reached, but silences noreturn warning */
+ abort ();
+#else
+ va_list argp;
+ va_start (argp, msg);
+# ifdef __MINGW64_VERSION_MAJOR
+ fprintf (stderr, "Mingw-w64 runtime failure:\n");
+# else
+ fprintf (stderr, "Mingw runtime failure:\n");
+# endif
+ vfprintf (stderr, msg, argp);
+ va_end (argp);
+ abort ();
+#endif
+}
+
+/* This function temporarily marks the page containing addr
+ * writable, before copying len bytes from *src to *addr, and
+ * then restores the original protection settings to the page.
+ *
+ * Using this function eliminates the requirement with older
+ * pseudo-reloc implementations, that sections containing
+ * pseudo-relocs (such as .text and .rdata) be permanently
+ * marked writable. This older behavior sabotaged any memory
+ * savings achieved by shared libraries on win32 -- and was
+ * slower, too. However, on cygwin as of binutils 2.20 the
+ * .text section is still marked writable, and the .rdata section
+ * is folded into the (writable) .data when --enable-auto-import.
+ */
static void
-__write_memory (void *addr,const void *src,size_t len)
+__write_memory (void *addr, const void *src, size_t len)
{
MEMORY_BASIC_INFORMATION b;
DWORD oldprot;
+
if (!len)
return;
+
if (!VirtualQuery (addr, &b, sizeof(b)))
- abort ();
- // Protect
+ {
+ __report_error (" VirtualQuery failed for %d bytes at address %p",
+ (int) sizeof(b), addr);
+ }
+
+ /* Temporarily allow write access to read-only protected memory. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
&oldprot);
+ /* write the data. */
memcpy (addr, src, len);
+ /* Restore original protection. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot);
}
#define RP_VERSION_V2 1
static void
-do_pseudo_reloc (void* start,void *end,void *base)
+do_pseudo_reloc (void * start, void * end, void * base)
{
ptrdiff_t addr_imp, reldata;
ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start);
runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start;
runtime_pseudo_reloc_item_v2 *r;
+ /* A valid relocation list will contain at least one entry, and
+ * one v1 data structure (the smallest one) requires two DWORDs.
+ * So, if the relocation list is smaller than 8 bytes, bail.
+ */
if (reloc_target < 8)
return;
- /* Check if this is old version pseudo relocation version. */
+
+ /* Check if this is the old pseudo relocation version. */
+ /* There are two kinds of v1 relocation lists:
+ * 1) With a (v2-style) version header. In this case, the
+ * first entry in the list is a 3-DWORD structure, with
+ * value:
+ * { 0, 0, RP_VERSION_V1 }
+ * In this case, we skip to the next entry in the list,
+ * knowing that all elements after the head item can
+ * be cast to runtime_pseudo_reloc_item_v1.
+ * 2) Without a (v2-style) version header. In this case, the
+ * first element in the list IS an actual v1 relocation
+ * record, which is two DWORDs. Because there will never
+ * be a case where a v1 relocation record has both
+ * addend == 0 and target == 0, this case will not be
+ * confused with the prior one.
+ * All current binutils, when generating a v1 relocation list,
+ * use the second (e.g. original) form -- that is, without the
+ * v2-style version header.
+ */
if (reloc_target >= 12
&& v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0
&& v2_hdr->version == RP_VERSION_V1)
+ {
+ /* We have a list header item indicating that the rest
+ * of the list contains v1 entries. Move the pointer to
+ * the first true v1 relocation record. By definition,
+ * that v1 element will not have both addend == 0 and
+ * target == 0 (and thus, when interpreted as a
+ * runtime_pseudo_reloc_v2, it will not have both
+ * magic1 == 0 and magic2 == 0).
+ */
v2_hdr++;
+ }
+
if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0)
{
- runtime_pseudo_reloc_item_v1 *o;
- for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; o < (runtime_pseudo_reloc_item_v1 *)end; o++)
- {
- DWORD newval;
+ /*************************
+ * Handle v1 relocations *
+ *************************/
+ runtime_pseudo_reloc_item_v1 * o;
+ for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr;
+ o < (runtime_pseudo_reloc_item_v1 *)end;
+ o++)
+ {
+ DWORD newval;
reloc_target = (ptrdiff_t) base + o->target;
newval = (*((DWORD*) reloc_target)) + o->addend;
__write_memory ((void *) reloc_target, &newval, sizeof(DWORD));
- }
+ }
return;
}
+
+ /* If we got this far, then we have relocations of version 2 or newer */
+
/* Check if this is a known version. */
if (v2_hdr->version != RP_VERSION_V2)
{
- fprintf (stderr, "pseudo_relocation protocol version %d is unknown to this runtime.\n",
- (int) v2_hdr->version);
+ __report_error (" Unknown pseudo relocation protocol version %d.\n",
+ (int) v2_hdr->version);
return;
}
- /* Walk over header. */
+
+ /*************************
+ * Handle v2 relocations *
+ *************************/
+
+ /* Walk over header. */
r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1];
for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++)
{
+ /* location where new address will be written */
reloc_target = (ptrdiff_t) base + r->target;
+
+ /* get sym pointer. It points either to the iat entry
+ * of the referenced element, or to the stub function.
+ */
addr_imp = (ptrdiff_t) base + r->sym;
addr_imp = *((ptrdiff_t *) addr_imp);
- switch ((r->flags&0xff))
+ /* read existing relocation value from image, casting to the
+ * bitsize indicated by the 8 LSBs of flags. If the value is
+ * negative, manually sign-extend to ptrdiff_t width. Raise an
+ * error if the bitsize indicated by the 8 LSBs of flags is not
+ * supported.
+ */
+ switch ((r->flags & 0xff))
{
case 8:
reldata = (ptrdiff_t) (*((unsigned char *)reloc_target));
- if ((reldata&0x80) != 0)
+ if ((reldata & 0x80) != 0)
reldata |= ~((ptrdiff_t) 0xff);
break;
case 16:
reldata = (ptrdiff_t) (*((unsigned short *)reloc_target));
- if ((reldata&0x8000) != 0)
+ if ((reldata & 0x8000) != 0)
reldata |= ~((ptrdiff_t) 0xffff);
break;
case 32:
reldata = (ptrdiff_t) (*((unsigned int *)reloc_target));
#ifdef _WIN64
- if ((reldata&0x80000000) != 0)
+ if ((reldata & 0x80000000) != 0)
reldata |= ~((ptrdiff_t) 0xffffffff);
#endif
break;
#endif
default:
reldata=0;
- fprintf(stderr, "Unknown pseudo relocation bit size %d\n",(int) (r->flags & 0xff));
+ __report_error (" Unknown pseudo relocation bit size %d.\n",
+ (int) (r->flags & 0xff));
break;
}
+
+ /* Adjust the relocation value */
reldata -= ((ptrdiff_t) base + r->sym);
reldata += addr_imp;
+
+ /* Write the new relocation value back to *reloc_target */
switch ((r->flags & 0xff))
- {
+ {
case 8:
__write_memory ((void *) reloc_target, &reldata, 1);
break;
__write_memory ((void *) reloc_target, &reldata, 8);
break;
#endif
- }
- }
+ }
+ }
}
void
-_pei386_runtime_relocator ()
+_pei386_runtime_relocator (void)
{
- static int was_init = 0;
+ static NO_COPY int was_init = 0;
if (was_init)
return;
++was_init;
- do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__);
+ do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
+ &__RUNTIME_PSEUDO_RELOC_LIST_END__,
+ &__MINGW_LSYMBOL(_image_base__));
}
--- /dev/null
+Index: CRT_fp10.c
+===================================================================
+--- CRT_fp10.c (Revision 43956)
++++ CRT_fp10.c (Arbeitskopie)
+@@ -7,6 +7,16 @@
+ void _fpreset (void);
+
+ void _fpreset (void)
+- { __asm__ ("fninit" ) ;}
++{
++#ifdef __GNUC__
++ __asm__ ("fninit" );
++#else
++ __asm fninit;
++#endif
++}
+
++#ifdef __GNUC__
+ void __attribute__ ((alias ("_fpreset"))) fpreset(void);
++#else
++void fpreset(void) { _fpreset(); }
++#endif
+Index: CRT_fp8.c
+===================================================================
+--- CRT_fp8.c (Revision 43956)
++++ CRT_fp8.c (Arbeitskopie)
+@@ -14,4 +14,8 @@
+ (* __MINGW_IMP_SYMBOL(_fpreset))();
+ }
+
++#ifdef __GNUC__
+ void __attribute__ ((alias ("_fpreset"))) fpreset(void);
++#else
++void fpreset(void) { _fpreset(); }
++#endif
+Index: crtexe.c
+===================================================================
+--- crtexe.c (Revision 43956)
++++ crtexe.c (Arbeitskopie)
+@@ -20,6 +20,7 @@
+ #include <tchar.h>
+ #include <sect_attribs.h>
+ #include <locale.h>
++#include <intrin.h>
+
+ #ifndef __winitenv
+ extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
+@@ -51,7 +52,11 @@
+ #define _commode (* __MINGW_IMP_SYMBOL(_commode))
+ extern int _dowildcard;
+
++#if defined(__GNUC__)
+ int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
++#else
++int _MINGW_INSTALL_DEBUG_MATHERR = 0;
++#endif
+ extern int __defaultmatherr;
+ extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
+
+Index: gs_support.c
+===================================================================
+--- gs_support.c (Revision 43956)
++++ gs_support.c (Arbeitskopie)
+@@ -112,6 +112,7 @@
+ else
+ #endif
+ {
++#ifdef __GNUC__
+ #ifdef _WIN64
+ GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
+ GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
+@@ -119,6 +120,15 @@
+ GS_ContextRecord.Eip = (DWORD) __builtin_return_address (0);
+ GS_ContextRecord.Esp = (DWORD) __builtin_frame_address (0) + 4;
+ #endif
++#else
++#ifdef _WIN64
++ GS_ContextRecord.Rip = (ULONGLONG) _ReturnAddress();
++ GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress();
++#else
++ GS_ContextRecord.Eip = (DWORD) _ReturnAddress();
++ GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress();
++#endif
++#endif
+ }
+
+ #ifdef _WIN64
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define __CRT__NO_INLINE
+#include <string.h>
+
+#undef strcasecmp
+int strcasecmp (const char *, const char *);
+int
+strcasecmp (const char *sz1, const char *sz2)
+{
+ return _stricmp (sz1,sz2);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define __CRT__NO_INLINE
+#include <string.h>
+
+#undef strncasecmp
+int strncasecmp (const char *, const char *, size_t);
+
+int
+strncasecmp (const char *sz1,const char *sz2,size_t sizeMaxCompare)
+{
+ return _strnicmp (sz1,sz2,sizeMaxCompare);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ *
+ * Written by Kai Tietz <kai.tietz@onevision.com>
+ */
+
+/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1,
+ otherwise
+ we do tls cleanup in runtime and _CRT_MT has value 2. */
+int _CRT_MT = 2;
+
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ *
+ * Written by Kai Tietz <kai.tietz@onevision.com>
+ */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <stdlib.h>
+
+int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
+int __mingwthr_remove_key_dtor (DWORD key);
+
+extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
+extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
+
+
+#ifndef _WIN64
+#define MINGWM10_DLL "mingwm10.dll"
+typedef int (*fMTRemoveKeyDtor)(DWORD key);
+typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
+extern fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
+extern fMTKeyDtor __mingw_gMTKeyDtor;
+extern int __mingw_usemthread_dll;
+#endif
+
+int
+__mingwthr_remove_key_dtor (DWORD key)
+{
+#ifndef _WIN64
+ if (!__mingw_usemthread_dll)
+#endif
+ return ___w64_mingwthr_remove_key_dtor (key);
+#ifndef _WIN64
+ if (__mingw_gMTRemoveKeyDtor)
+ return (*__mingw_gMTRemoveKeyDtor) (key);
+ return 0;
+#endif
+}
+
+int
+__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
+{
+ if (dtor)
+ {
+#ifndef _WIN64
+ if (!__mingw_usemthread_dll)
+#endif
+ return ___w64_mingwthr_add_key_dtor (key, dtor);
+#ifndef _WIN64
+ if (__mingw_gMTKeyDtor)
+ return (*__mingw_gMTKeyDtor) (key, dtor);
+#endif
+ }
+ return 0;
+}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ *
+ * Written by Kai Tietz <kai.tietz@onevision.com>
*/
#ifdef CRTDLL
#undef CRTDLL
#endif
-#include <internal.h>
-#include <sect_attribs.h>
#include <windows.h>
+#include <stdio.h>
+#include <memory.h>
#include <malloc.h>
-#include <crtdbg.h>
+
+#ifndef _CRTALLOC
+#define _CRTALLOC(x) __attribute__ ((section (x) ))
+#endif
+
+#ifndef __INTERNAL_FUNC_DEFINED
+#define __INTERNAL_FUNC_DEFINED
+ typedef void (__cdecl *_PVFV)(void);
+ typedef int (__cdecl *_PIFV)(void);
+ typedef void (__cdecl *_PVFI)(int);
+#endif
+
+extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
#define FUNCS_PER_NODE 30
ULONG _tls_index = 0;
-_CRTALLOC(".tls") char _tls_start = 0;
+/* TLS raw template data start and end. */
+_CRTALLOC(".tls$AAA") char _tls_start = 0;
_CRTALLOC(".tls$ZZZ") char _tls_end = 0;
_CRTALLOC(".CRT$XLA") PIMAGE_TLS_CALLBACK __xl_a = 0;
_CRTALLOC(".CRT$XLZ") PIMAGE_TLS_CALLBACK __xl_z = 0;
#ifdef _WIN64
-_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY64 _tls_used = {
- (ULONGLONG) &_tls_start, (ULONGLONG) &_tls_end, (ULONGLONG) &_tls_index,
+_CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY64 _tls_used = {
+ (ULONGLONG) &_tls_start+1, (ULONGLONG) &_tls_end, (ULONGLONG) &_tls_index,
(ULONGLONG) (&__xl_a+1), (ULONG) 0, (ULONG) 0
};
#else
-_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = {
- (ULONG)(ULONG_PTR) &_tls_start, (ULONG)(ULONG_PTR) &_tls_end,
+_CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY _tls_used = {
+ (ULONG)(ULONG_PTR) &_tls_start+1, (ULONG)(ULONG_PTR) &_tls_end,
(ULONG)(ULONG_PTR) &_tls_index, (ULONG)(ULONG_PTR) (&__xl_a+1),
(ULONG) 0, (ULONG) 0
};
#ifdef HAVE_ATTRIBUTE_THREAD
#define __CRT_THREAD __declspec(thread)
#else
-#define __CRT_THREAD
+#define __CRT_THREAD __thread
#endif
#endif
+#define DISABLE_MS_TLS 1
+
static _CRTALLOC(".CRT$XDA") _PVFV __xd_a = 0;
static _CRTALLOC(".CRT$XDZ") _PVFV __xd_z = 0;
+
+#if !defined (DISABLE_MS_TLS)
static __CRT_THREAD TlsDtorNode *dtor_list;
static __CRT_THREAD TlsDtorNode dtor_list_head;
+#endif
+
+extern int _CRT_MT;
+
+#ifndef _WIN64
+#define MINGWM10_DLL "mingwm10.dll"
+typedef int (*fMTRemoveKeyDtor)(DWORD key);
+typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
+fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
+fMTKeyDtor __mingw_gMTKeyDtor;
+int __mingw_usemthread_dll;
+static HANDLE __mingw_mthread_hdll;
+#endif
+
+BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID);
BOOL WINAPI
__dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
_PVFV *pfunc;
- if (dwReason != DLL_THREAD_ATTACH)
+#ifndef _WIN64
+ if (_winmajor < 4)
+ {
+ __mingw_usemthread_dll = 1;
+ __mingw_mthread_hdll = LoadLibrary (MINGWM10_DLL);
+ if (__mingw_mthread_hdll != NULL)
+ {
+ __mingw_gMTRemoveKeyDtor = (fMTRemoveKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_remove_key_dtor");
+ __mingw_gMTKeyDtor = (fMTKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_key_dtor");
+ }
+ if (__mingw_mthread_hdll == NULL || !__mingw_gMTRemoveKeyDtor || !__mingw_gMTKeyDtor)
+ {
+ __mingw_gMTKeyDtor = NULL;
+ __mingw_gMTRemoveKeyDtor = NULL;
+ if (__mingw_mthread_hdll)
+ FreeLibrary (__mingw_mthread_hdll);
+ __mingw_mthread_hdll = NULL;
+ _CRT_MT = 0;
+ return TRUE;
+ }
+ _CRT_MT = 1;
return TRUE;
+ }
+#endif
+ /* We don't let us trick here. */
+ if (_CRT_MT != 2)
+ _CRT_MT = 2;
+
+ if (dwReason != DLL_THREAD_ATTACH)
+ {
+ if (dwReason == DLL_PROCESS_ATTACH)
+ __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
+ return TRUE;
+ }
for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
{
if (*pfunc != NULL)
(*pfunc)();
}
-
return TRUE;
}
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = (const PIMAGE_TLS_CALLBACK) __dyn_tls_init;
_CRTALLOC(".CRT$XLC") PIMAGE_TLS_CALLBACK __xl_c = (PIMAGE_TLS_CALLBACK) __dyn_tls_init;
+int __cdecl __tlregdtor (_PVFV);
+
int __cdecl
__tlregdtor (_PVFV func)
{
+ if (!func)
+ return 0;
+#if !defined (DISABLE_MS_TLS)
if (dtor_list == NULL)
{
dtor_list = &dtor_list_head;
dtor_list->count = 0;
}
dtor_list->funcs[dtor_list->count++] = func;
+#endif
return 0;
}
static BOOL WINAPI
__dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
+#if !defined (DISABLE_MS_TLS)
TlsDtorNode *pnode, *pnext;
int i;
+#endif
if (dwReason != DLL_THREAD_DETACH && dwReason != DLL_PROCESS_DETACH)
return TRUE;
-
- for (pnode = dtor_list; pnode != NULL; pnode = pnext)
+ /* As TLS variables are detroyed already by DLL_THREAD_DETACH
+ call, we have to avoid access on the possible DLL_PROCESS_DETACH
+ call the already destroyed TLS vars.
+ TODO: The used local thread based variables have to be handled
+ manually, so that we can control their lifetime here. */
+#if !defined (DISABLE_MS_TLS)
+ if (dwReason != DLL_PROCESS_DETACH)
{
- for (i = pnode->count - 1; i >= 0; --i)
- {
- if (pnode->funcs[i] != NULL)
- (*pnode->funcs[i])();
- }
- pnext = pnode->next;
- if (pnext != NULL)
- free ((void *) pnode);
+ for (pnode = dtor_list; pnode != NULL; pnode = pnext)
+ {
+ for (i = pnode->count - 1; i >= 0; --i)
+ {
+ if (pnode->funcs[i] != NULL)
+ (*pnode->funcs[i])();
+ }
+ pnext = pnode->next;
+ if (pnext != NULL)
+ free ((void *) pnode);
+ }
}
+#endif
+ __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
return TRUE;
}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ *
+ * Written by Kai Tietz <kai.tietz@onevision.com>
+ *
+ * This file is used by if gcc is built with --enable-threads=win32.
+ *
+ * Based on version created by Mumit Khan <khan@nanotech.wisc.edu>
+ *
+ */
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <stdlib.h>
+
+WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
+int ___w64_mingwthr_remove_key_dtor (DWORD key);
+int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
+
+/* To protect the thread/key association data structure modifications. */
+static CRITICAL_SECTION __mingwthr_cs;
+static volatile int __mingwthr_cs_init = 0;
+
+typedef struct __mingwthr_key __mingwthr_key_t;
+
+/* The list of threads active with key/dtor pairs. */
+struct __mingwthr_key {
+ DWORD key;
+ void (*dtor)(void *);
+ __mingwthr_key_t volatile *next;
+};
+
+
+static __mingwthr_key_t volatile *key_dtor_list;
+
+int
+___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *))
+{
+ __mingwthr_key_t *new_key;
+
+ if (__mingwthr_cs_init == 0)
+ return 0;
+ new_key = (__mingwthr_key_t *) calloc (1, sizeof (__mingwthr_key_t));
+ if (new_key == NULL)
+ return -1;
+
+ new_key->key = key;
+ new_key->dtor = dtor;
+
+ EnterCriticalSection (&__mingwthr_cs);
+
+ new_key->next = key_dtor_list;
+ key_dtor_list = new_key;
+
+ LeaveCriticalSection (&__mingwthr_cs);
+ return 0;
+}
+
+int
+___w64_mingwthr_remove_key_dtor (DWORD key)
+{
+ __mingwthr_key_t volatile *prev_key;
+ __mingwthr_key_t volatile *cur_key;
+
+ if (__mingwthr_cs_init == 0)
+ return 0;
+
+ EnterCriticalSection (&__mingwthr_cs);
+
+ prev_key = NULL;
+ cur_key = key_dtor_list;
+
+ while (cur_key != NULL)
+ {
+ if ( cur_key->key == key)
+ {
+ if (prev_key == NULL)
+ key_dtor_list = cur_key->next;
+ else
+ prev_key->next = cur_key->next;
+
+ free ((void*)cur_key);
+ break;
+ }
+ prev_key = cur_key;
+ cur_key = cur_key->next;
+ }
+
+ LeaveCriticalSection (&__mingwthr_cs);
+ return 0;
+}
+
+static void
+__mingwthr_run_key_dtors (void)
+{
+ __mingwthr_key_t volatile *keyp;
+
+ if (__mingwthr_cs_init == 0)
+ return;
+ EnterCriticalSection (&__mingwthr_cs);
+
+ for (keyp = key_dtor_list; keyp; )
+ {
+ LPVOID value = TlsGetValue (keyp->key);
+ if (GetLastError () == ERROR_SUCCESS)
+ {
+ if (value)
+ (*keyp->dtor) (value);
+ }
+ keyp = keyp->next;
+ }
+
+ LeaveCriticalSection (&__mingwthr_cs);
+}
+
+WINBOOL
+__mingw_TLScallback (HANDLE hDllHandle __attribute__ ((__unused__)),
+ DWORD reason,
+ LPVOID reserved __attribute__ ((__unused__)))
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ if (__mingwthr_cs_init == 0)
+ InitializeCriticalSection (&__mingwthr_cs);
+ __mingwthr_cs_init = 1;
+ break;
+ case DLL_PROCESS_DETACH:
+ __mingwthr_run_key_dtors();
+ if (__mingwthr_cs_init == 1)
+ {
+ __mingwthr_cs_init = 0;
+ DeleteCriticalSection (&__mingwthr_cs);
+ }
+ break;
+ case DLL_THREAD_ATTACH:
+ break;
+ case DLL_THREAD_DETACH:
+ __mingwthr_run_key_dtors();
+ break;
+ }
+ return TRUE;
+}
+
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <ctype.h>
+
+#undef toascii
+
+int toascii (int);
+
+int
+toascii (int c)
+{
+ return __toascii(c);
+}
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <fcntl.h>
+
+/* Set default file mode to text */
+
+/* Is this correct? Default value of _fmode in msvcrt.dll is 0. */
+
+int _fmode = _O_TEXT;
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#define WPRFLAG 1
+
+#include "crtexe.c"
+
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#define WPRFLAG 1
+
+#include "dll_argv.c"
+
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#define WPRFLAG 1
+
+#include "dllargv.c"
+
--- /dev/null
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#define __CRT__NO_INLINE
+#include <string.h>
+
+#undef wcscmpi
+int wcscmpi (const wchar_t *, const wchar_t *);
+
+int
+wcscmpi (const wchar_t * ws1,const wchar_t * ws2)
+{
+ return _wcsicmp (ws1,ws2);
+}
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
-int _dowildcard = 0;
+/* _dowildcard is an int that controls the globbing of the command line.
+ * If _dowildcard is non-zero, the command line will be globbed: *.*
+ * will be expanded to be all files in the startup directory.
+ *
+ * In the mingw-w64 library the _dowildcard variable is defined as being
+ * 0, therefore command line globbing is DISABLED by default. To turn it
+ * on and to leave wildcard command line processing MS's globbing code,
+ * include a line in one of your source modules defining _dowildcard and
+ * setting it to -1, like so:
+ * int _dowildcard = -1;
+ *
+ * Alternatively, the mingw-w64 library can be configured using the
+ * --enable-wildcard option and compiled thusly upon which the resulting
+ * library will have _dowildcard as -1 and command line globbing will be
+ * enabled by default.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef __ENABLE_GLOBBING
+#define __ENABLE_GLOBBING 0 /* -1 */
+#endif
+
+int _dowildcard = __ENABLE_GLOBBING;
+
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _commode = 0;
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int __globallocalestatus = ~0x1;
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _fmode = 0;
/* Check if we need the current user key */
if (RelativeTo == RTL_REGISTRY_USER)
{
- /* Get the path */
+ /* Get the user key path */
Status = RtlFormatCurrentUserKeyPath(&KeyPath);
- if (!NT_SUCCESS(Status)) return(Status);
- /* Append it */
- Status = RtlAppendUnicodeStringToString(&KeyName, &KeyPath);
- RtlFreeUnicodeString (&KeyPath);
+ /* Check if it worked */
+ if (NT_SUCCESS(Status))
+ {
+ /* Append the user key path */
+ Status = RtlAppendUnicodeStringToString(&KeyName, &KeyPath);
+
+ /* Free the user key path */
+ RtlFreeUnicodeString (&KeyPath);
+ }
+ else
+ {
+ /* It didn't work so fall back to the default user key */
+ Status = RtlAppendUnicodeToString(&KeyName, RtlpRegPaths[RTL_REGISTRY_USER]);
+ }
}
else
{
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
-<module name="rtl" type="staticlibrary">
+<module name="rtl" type="staticlibrary" crt="static">
<define name="_NTOSKRNL_" />
<define name="NO_RTL_INLINES" />
<define name="_NTSYSTEM_" />
<define name="_MSVCRT_LIB_" />
<define name="_MSVCRT_" />
<define name="_MT" />
+ <define name="_CRTBLD" />
<directory name="conio">
<file>cgets.c</file>
<file>cprintf.c</file>
return ret;
}
-int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
+int CDECL __CppXcptFilter(unsigned long ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
union
{
double* __x;
- double_t *x;
+ double_s *x;
} u;
u.__x = &__x;
union
{
double* __d;
- double_t* d;
+ double_s* d;
} d;
union
{
double* __s;
- double_t* s;
+ double_s* s;
} s;
d.__d = &__d;
s.__s = &__s;
#define _FPCLASS_PINF 0x0200 /* positive infinity */
-#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
+//#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
#define FP_SNAN 0x0001 // signaling NaN
#define FP_QNAN 0x0002 // quiet NaN
#define FP_NNORM 0x0080 // negative normalized non-zero
#define FP_PNORM 0x0100 // positive normalized non-zero
-#endif
+//#endif
typedef int fpclass_t;
union
{
double* __d;
- double_t* d;
+ double_s* d;
} d;
d.__d = &__d;
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
union
{
long double* __x;
- long_double_t* x;
+ long_double_s* x;
} x;
x.__x = &__x;
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
union
{
long double* __x;
- long_double_t* x;
+ long_double_s* x;
} x;
x.__x = &__x;
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
-} float_t;
+} float_s;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:20;
unsigned int exponent:11;
unsigned int sign:1;
-} double_t;
+} double_s;
typedef struct {
unsigned int mantissal:32;
unsigned int exponent:15;
unsigned int sign:1;
unsigned int empty:16;
-} long_double_t;
+} long_double_s;
#endif
<define name="_NTSYSTEM_" />
<define name="_NTDLLBUILD_" />
<define name="_LIBCNT_" />
+ <define name="_CRTBLD" />
<if property="ARCH" value="i386">
<define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
</if>
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
#include <internal/ieee.h>
#undef _HUGE
-double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
+double_s _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
union
{
long double* __x;
- long_double_t* x;
+ long_double_s* x;
} x;
union
{
long double* __i;
- long_double_t* iptr;
+ long_double_s* iptr;
} iptr;
int j0;
0 /* 0xff */
};
+const unsigned short _wctype[] = {
+ 0, /* <EOF>, 0xFFFF */
+ _CONTROL, /* CTRL+@, 0x00 */
+ _CONTROL, /* CTRL+A, 0x01 */
+ _CONTROL, /* CTRL+B, 0x02 */
+ _CONTROL, /* CTRL+C, 0x03 */
+ _CONTROL, /* CTRL+D, 0x04 */
+ _CONTROL, /* CTRL+E, 0x05 */
+ _CONTROL, /* CTRL+F, 0x06 */
+ _CONTROL, /* CTRL+G, 0x07 */
+ _CONTROL, /* CTRL+H, 0x08 */
+ _BLANK | _CONTROL | _SPACE, /* CTRL+I, 0x09 */
+ _CONTROL | _SPACE, /* CTRL+J, 0x0a */
+ _CONTROL | _SPACE, /* CTRL+K, 0x0b */
+ _CONTROL | _SPACE, /* CTRL+L, 0x0c */
+ _CONTROL | _SPACE, /* CTRL+M, 0x0d */
+ _CONTROL, /* CTRL+N, 0x0e */
+ _CONTROL, /* CTRL+O, 0x0f */
+ _CONTROL, /* CTRL+P, 0x10 */
+ _CONTROL, /* CTRL+Q, 0x11 */
+ _CONTROL, /* CTRL+R, 0x12 */
+ _CONTROL, /* CTRL+S, 0x13 */
+ _CONTROL, /* CTRL+T, 0x14 */
+ _CONTROL, /* CTRL+U, 0x15 */
+ _CONTROL, /* CTRL+V, 0x16 */
+ _CONTROL, /* CTRL+W, 0x17 */
+ _CONTROL, /* CTRL+X, 0x18 */
+ _CONTROL, /* CTRL+Y, 0x19 */
+ _CONTROL, /* CTRL+Z, 0x1a */
+ _CONTROL, /* CTRL+[, 0x1b */
+ _CONTROL, /* CTRL+\, 0x1c */
+ _CONTROL, /* CTRL+], 0x1d */
+ _CONTROL, /* CTRL+^, 0x1e */
+ _CONTROL, /* CTRL+_, 0x1f */
+ _SPACE | _BLANK, /* ` ', 0x20 */
+ _PUNCT, /* `!', 0x21 */
+ _PUNCT, /* 0x22 */
+ _PUNCT, /* `#', 0x23 */
+ _PUNCT, /* `$', 0x24 */
+ _PUNCT, /* `%', 0x25 */
+ _PUNCT, /* `&', 0x26 */
+ _PUNCT, /* 0x27 */
+ _PUNCT, /* `(', 0x28 */
+ _PUNCT, /* `)', 0x29 */
+ _PUNCT, /* `*', 0x2a */
+ _PUNCT, /* `+', 0x2b */
+ _PUNCT, /* `,', 0x2c */
+ _PUNCT, /* `-', 0x2d */
+ _PUNCT, /* `.', 0x2e */
+ _PUNCT, /* `/', 0x2f */
+ _DIGIT | _HEX, /* `0', 0x30 */
+ _DIGIT | _HEX, /* `1', 0x31 */
+ _DIGIT | _HEX, /* `2', 0x32 */
+ _DIGIT | _HEX, /* `3', 0x33 */
+ _DIGIT | _HEX, /* `4', 0x34 */
+ _DIGIT | _HEX, /* `5', 0x35 */
+ _DIGIT | _HEX, /* `6', 0x36 */
+ _DIGIT | _HEX, /* `7', 0x37 */
+ _DIGIT | _HEX, /* `8', 0x38 */
+ _DIGIT | _HEX, /* `9', 0x39 */
+ _PUNCT, /* `:', 0x3a */
+ _PUNCT, /* `;', 0x3b */
+ _PUNCT, /* `<', 0x3c */
+ _PUNCT, /* `=', 0x3d */
+ _PUNCT, /* `>', 0x3e */
+ _PUNCT, /* `?', 0x3f */
+ _PUNCT, /* `@', 0x40 */
+ 0x0100 | _UPPER | _HEX, /* `A', 0x41 */
+ 0x0100 | _UPPER | _HEX, /* `B', 0x42 */
+ 0x0100 | _UPPER | _HEX, /* `C', 0x43 */
+ 0x0100 | _UPPER | _HEX, /* `D', 0x44 */
+ 0x0100 | _UPPER | _HEX, /* `E', 0x45 */
+ 0x0100 | _UPPER | _HEX, /* `F', 0x46 */
+ 0x0100 | _UPPER, /* `G', 0x47 */
+ 0x0100 | _UPPER, /* `H', 0x48 */
+ 0x0100 | _UPPER, /* `I', 0x49 */
+ 0x0100 | _UPPER, /* `J', 0x4a */
+ 0x0100 | _UPPER, /* `K', 0x4b */
+ 0x0100 | _UPPER, /* `L', 0x4c */
+ 0x0100 | _UPPER, /* `M', 0x4d */
+ 0x0100 | _UPPER, /* `N', 0x4e */
+ 0x0100 | _UPPER, /* `O', 0x4f */
+ 0x0100 | _UPPER, /* `P', 0x50 */
+ 0x0100 | _UPPER, /* `Q', 0x51 */
+ 0x0100 | _UPPER, /* `R', 0x52 */
+ 0x0100 | _UPPER, /* `S', 0x53 */
+ 0x0100 | _UPPER, /* `T', 0x54 */
+ 0x0100 | _UPPER, /* `U', 0x55 */
+ 0x0100 | _UPPER, /* `V', 0x56 */
+ 0x0100 | _UPPER, /* `W', 0x57 */
+ 0x0100 | _UPPER, /* `X', 0x58 */
+ 0x0100 | _UPPER, /* `Y', 0x59 */
+ 0x0100 | _UPPER, /* `Z', 0x5a */
+ _PUNCT, /* `[', 0x5b */
+ _PUNCT, /* 0x5c */
+ _PUNCT, /* `]', 0x5d */
+ _PUNCT, /* `^', 0x5e */
+ _PUNCT, /* `_', 0x5f */
+ _PUNCT, /* 0x60 */
+ 0x0100 | _LOWER | _HEX, /* `a', 0x61 */
+ 0x0100 | _LOWER | _HEX, /* `b', 0x62 */
+ 0x0100 | _LOWER | _HEX, /* `c', 0x63 */
+ 0x0100 | _LOWER | _HEX, /* `d', 0x64 */
+ 0x0100 | _LOWER | _HEX, /* `e', 0x65 */
+ 0x0100 | _LOWER | _HEX, /* `f', 0x66 */
+ 0x0100 | _LOWER, /* `g', 0x67 */
+ 0x0100 | _LOWER, /* `h', 0x68 */
+ 0x0100 | _LOWER, /* `i', 0x69 */
+ 0x0100 | _LOWER, /* `j', 0x6a */
+ 0x0100 | _LOWER, /* `k', 0x6b */
+ 0x0100 | _LOWER, /* `l', 0x6c */
+ 0x0100 | _LOWER, /* `m', 0x6d */
+ 0x0100 | _LOWER, /* `n', 0x6e */
+ 0x0100 | _LOWER, /* `o', 0x6f */
+ 0x0100 | _LOWER, /* `p', 0x70 */
+ 0x0100 | _LOWER, /* `q', 0x71 */
+ 0x0100 | _LOWER, /* `r', 0x72 */
+ 0x0100 | _LOWER, /* `s', 0x73 */
+ 0x0100 | _LOWER, /* `t', 0x74 */
+ 0x0100 | _LOWER, /* `u', 0x75 */
+ 0x0100 | _LOWER, /* `v', 0x76 */
+ 0x0100 | _LOWER, /* `w', 0x77 */
+ 0x0100 | _LOWER, /* `x', 0x78 */
+ 0x0100 | _LOWER, /* `y', 0x79 */
+ 0x0100 | _LOWER, /* `z', 0x7a */
+ _PUNCT, /* `{', 0x7b */
+ _PUNCT, /* `|', 0x7c */
+ _PUNCT, /* `}', 0x7d */
+ _PUNCT, /* `~', 0x7e */
+ _CONTROL, /* 0x7f */
+ _CONTROL, /* 0x80 */
+ _CONTROL, /* 0x81 */
+ _CONTROL, /* 0x82 */
+ _CONTROL, /* 0x83 */
+ _CONTROL, /* 0x84 */
+ _CONTROL, /* 0x85 */
+ _CONTROL, /* 0x86 */
+ _CONTROL, /* 0x87 */
+ _CONTROL, /* 0x88 */
+ _CONTROL, /* 0x89 */
+ _CONTROL, /* 0x8a */
+ _CONTROL, /* 0x8b */
+ _CONTROL, /* 0x8c */
+ _CONTROL, /* 0x8d */
+ _CONTROL, /* 0x8e */
+ _CONTROL, /* 0x8f */
+ _CONTROL, /* 0x90 */
+ _CONTROL, /* 0x91 */
+ _CONTROL, /* 0x92 */
+ _CONTROL, /* 0x93 */
+ _CONTROL, /* 0x94 */
+ _CONTROL, /* 0x95 */
+ _CONTROL, /* 0x96 */
+ _CONTROL, /* 0x97 */
+ _CONTROL, /* 0x98 */
+ _CONTROL, /* 0x99 */
+ _CONTROL, /* 0x9a */
+ _CONTROL, /* 0x9b */
+ _CONTROL, /* 0x9c */
+ _CONTROL, /* 0x9d */
+ _CONTROL, /* 0x9e */
+ _CONTROL, /* 0x9f */
+ _BLANK | _SPACE, /* 0xa0 */
+ _PUNCT, /* 0xa1 */
+ _PUNCT, /* 0xa2 */
+ _PUNCT, /* 0xa3 */
+ _PUNCT, /* 0xa4 */
+ _PUNCT, /* 0xa5 */
+ _PUNCT, /* 0xa6 */
+ _PUNCT, /* 0xa7 */
+ _PUNCT, /* 0xa8 */
+ _PUNCT, /* 0xa9 */
+ _PUNCT, /* 0xaa */
+ _PUNCT, /* 0xab */
+ _PUNCT, /* 0xac */
+ _PUNCT, /* 0xad */
+ _PUNCT, /* 0xae */
+ _PUNCT, /* 0xaf */
+ _PUNCT, /* 0xb0 */
+ _PUNCT, /* 0xb1 */
+ _PUNCT | _DIGIT, /* 0xb2 */
+ _PUNCT | _DIGIT, /* 0xb3 */
+ _PUNCT, /* 0xb4 */
+ _PUNCT, /* 0xb5 */
+ _PUNCT, /* 0xb6 */
+ _PUNCT, /* 0xb7 */
+ _PUNCT, /* 0xb8 */
+ _PUNCT | _DIGIT, /* 0xb9 */
+ _PUNCT, /* 0xba */
+ _PUNCT, /* 0xbb */
+ _PUNCT, /* 0xbc */
+ _PUNCT, /* 0xbd */
+ _PUNCT, /* 0xbe */
+ _PUNCT, /* 0xbf */
+ 0x0100 | _UPPER, /* 0xc0 */
+ 0x0100 | _UPPER, /* 0xc1 */
+ 0x0100 | _UPPER, /* 0xc2 */
+ 0x0100 | _UPPER, /* 0xc3 */
+ 0x0100 | _UPPER, /* 0xc4 */
+ 0x0100 | _UPPER, /* 0xc5 */
+ 0x0100 | _UPPER, /* 0xc6 */
+ 0x0100 | _UPPER, /* 0xc7 */
+ 0x0100 | _UPPER, /* 0xc8 */
+ 0x0100 | _UPPER, /* 0xc9 */
+ 0x0100 | _UPPER, /* 0xca */
+ 0x0100 | _UPPER, /* 0xcb */
+ 0x0100 | _UPPER, /* 0xcc */
+ 0x0100 | _UPPER, /* 0xcd */
+ 0x0100 | _UPPER, /* 0xce */
+ 0x0100 | _UPPER, /* 0xcf */
+ 0x0100 | _UPPER, /* 0xd0 */
+ 0x0100 | _UPPER, /* 0xd1 */
+ 0x0100 | _UPPER, /* 0xd2 */
+ 0x0100 | _UPPER, /* 0xd3 */
+ 0x0100 | _UPPER, /* 0xd4 */
+ 0x0100 | _UPPER, /* 0xd5 */
+ 0x0100 | _UPPER, /* 0xd6 */
+ _PUNCT, /* 0xd7 */
+ 0x0100 | _UPPER, /* 0xd8 */
+ 0x0100 | _UPPER, /* 0xd9 */
+ 0x0100 | _UPPER, /* 0xda */
+ 0x0100 | _UPPER, /* 0xdb */
+ 0x0100 | _UPPER, /* 0xdc */
+ 0x0100 | _UPPER, /* 0xdd */
+ 0x0100 | _UPPER, /* 0xde */
+ 0x0100 | _LOWER, /* 0xdf */
+ 0x0100 | _LOWER, /* 0xe0 */
+ 0x0100 | _LOWER, /* 0xe1 */
+ 0x0100 | _LOWER, /* 0xe2 */
+ 0x0100 | _LOWER, /* 0xe3 */
+ 0x0100 | _LOWER, /* 0xe4 */
+ 0x0100 | _LOWER, /* 0xe5 */
+ 0x0100 | _LOWER, /* 0xe6 */
+ 0x0100 | _LOWER, /* 0xe7 */
+ 0x0100 | _LOWER, /* 0xe8 */
+ 0x0100 | _LOWER, /* 0xe9 */
+ 0x0100 | _LOWER, /* 0xea */
+ 0x0100 | _LOWER, /* 0xeb */
+ 0x0100 | _LOWER, /* 0xec */
+ 0x0100 | _LOWER, /* 0xed */
+ 0x0100 | _LOWER, /* 0xee */
+ 0x0100 | _LOWER, /* 0xef */
+ 0x0100 | _LOWER, /* 0xf0 */
+ 0x0100 | _LOWER, /* 0xf1 */
+ 0x0100 | _LOWER, /* 0xf2 */
+ 0x0100 | _LOWER, /* 0xf3 */
+ 0x0100 | _LOWER, /* 0xf4 */
+ 0x0100 | _LOWER, /* 0xf5 */
+ 0x0100 | _LOWER, /* 0xf6 */
+ _PUNCT, /* 0xf7 */
+ 0x0100 | _LOWER, /* 0xf8 */
+ 0x0100 | _LOWER, /* 0xf9 */
+ 0x0100 | _LOWER, /* 0xfa */
+ 0x0100 | _LOWER, /* 0xfb */
+ 0x0100 | _LOWER, /* 0xfc */
+ 0x0100 | _LOWER, /* 0xfd */
+ 0x0100 | _LOWER, /* 0xfe */
+ 0x0100 | _LOWER /* 0xff */
+};
const unsigned short *_pctype = _ctype + 1;
-const unsigned short *_pwctype = _ctype + 1;
+const unsigned short *_pwctype = _wctype + 1;
/*
* @implemented
return &_pctype;
}
+const unsigned short* __cdecl __pctype_func(void)
+{
+ return _pctype;
+}
+
/*
* @implemented
*/
return &_pwctype;
}
+const unsigned short* __cdecl __pwctype_func(void)
+{
+ return _pwctype;
+}
+
int _isctype (int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
<installfile installbase="inf">acpi.inf</installfile>
<installfile installbase="inf">audio.inf</installfile>
<installfile installbase="inf">battery.inf</installfile>
+ <installfile installbase="inf">bda.inf</installfile>
<installfile installbase="inf">cdrom.inf</installfile>
<installfile installbase="inf">cpu.inf</installfile>
<installfile installbase="inf">display.inf</installfile>
<installfile installbase="inf">intl.inf</installfile>
<installfile installbase="inf">keyboard.inf</installfile>
<installfile installbase="inf">ks.inf</installfile>
+ <installfile installbase="inf">kscaptur.inf</installfile>
<installfile installbase="inf">layout.inf</installfile>
<installfile installbase="inf">machine.inf</installfile>
<installfile installbase="inf">msmouse.inf</installfile>
--- /dev/null
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/config/cmwraprs.c
+ * PURPOSE: Configuration Manager - Wrappers for Hive Operations
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "ntoskrnl.h"
+#define NDEBUG
+#include "debug.h"
+
+/* FUNCTIONS *****************************************************************/
+
+/* EOF */
\ No newline at end of file
--- /dev/null
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/config/cmwraprs.c
+ * PURPOSE: Configuration Manager - Wrappers for Hive Operations
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "ntoskrnl.h"
+#define NDEBUG
+#include "debug.h"
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+NTAPI
+CmpReportNotify(IN PCM_KEY_CONTROL_BLOCK Kcb,
+ IN PHHIVE Hive,
+ IN HCELL_INDEX Cell,
+ IN ULONG Filter)
+{
+ /* FIXME: TODO */
+ return;
+}
+
+VOID
+NTAPI
+CmpFlushNotify(IN PCM_KEY_BODY KeyBody,
+ IN BOOLEAN LockHeld)
+{
+ /* FIXME: TODO */
+ return;
+}
+
--- /dev/null
+/*
+ * PROJECT: ReactOS Kernel
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: ntoskrnl/config/cmwraprs.c
+ * PURPOSE: Configuration Manager - Wrappers for Hive Operations
+ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "ntoskrnl.h"
+#define NDEBUG
+#include "debug.h"
+
+BOOLEAN CmpGlobalQuota;
+BOOLEAN CmpGlobalQuotaAllowed;
+
+/* FUNCTIONS *****************************************************************/
+
+VOID
+NTAPI
+CmpSetGlobalQuotaAllowed(VOID)
+{
+ /* Set flag ON if quota enabled */
+ CmpGlobalQuotaAllowed = CmpGlobalQuota;
+}
BOOLEAN CmpSpecialBootCondition;
BOOLEAN CmpNoWrite;
BOOLEAN CmpWasSetupBoot;
+BOOLEAN CmpProfileLoaded;
ULONG CmpTraceLevel = 0;
extern LONG CmpFlushStarveWriters;
return !ExIsResourceAcquiredExclusiveLite(&CmpRegistryLock) ? FALSE : TRUE;
}
+VOID
+NTAPI
+CmpLockHiveFlusherExclusive(IN PCMHIVE Hive)
+{
+ /* Lock the flusher. We should already be in a critical section */
+ CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive);
+ ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) &&
+ (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0));
+ ExAcquireResourceExclusiveLite(Hive->FlusherLock, TRUE);
+}
+
+VOID
+NTAPI
+CmpLockHiveFlusherShared(IN PCMHIVE Hive)
+{
+ /* Lock the flusher. We should already be in a critical section */
+ CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive);
+ ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) &&
+ (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0));
+ ExAcquireResourceSharedLite(Hive->FlusherLock, TRUE);
+}
+
+VOID
+NTAPI
+CmpUnlockHiveFlusher(IN PCMHIVE Hive)
+{
+ /* Sanity check */
+ CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive);
+ CMP_ASSERT_FLUSH_LOCK(Hive);
+
+ /* Release the lock */
+ ExReleaseResourceLite(Hive->FlusherLock);
+}
+
+BOOLEAN
+NTAPI
+CmpTestHiveFlusherLockShared(IN PCMHIVE Hive)
+{
+ /* Test the lock */
+ return !ExIsResourceAcquiredSharedLite(Hive->FlusherLock) ? FALSE : TRUE;
+}
+
+BOOLEAN
+NTAPI
+CmpTestHiveFlusherLockExclusive(IN PCMHIVE Hive)
+{
+ /* Test the lock */
+ return !ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) ? FALSE : TRUE;
+}
+
VOID
NTAPI
CmpUnlockRegistry(VOID)
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS Kernel
+ * FILE: ntoskrnl/include/amd64/asmmacro.S
+ * PURPOSE: Macros for x64 assembly
+ * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
+ */
+
+.intel_syntax noprefix
+.code64
+
+/* Macros for x64 stack unwind OPs */
+
+.macro .proc name
+ .func name
+ .global _\name
+ _\name:
+ .cfi_startproc
+ .equ cfa_current_offset, -8
+.endm
+
+.macro .endproc
+ .cfi_endproc
+ .endfunc
+.endm
+
+.macro .allocstack size
+ .cfi_adjust_cfa_offset \size
+ .set cfa_current_offset, cfa_current_offset - \size
+.endm
+
+.macro .pushframe code
+ .if (\code == 0)
+ .cfi_adjust_cfa_offset 0x28
+ .set cfa_current_offset, cfa_current_offset - 0x28
+ .else
+ .cfi_adjust_cfa_offset 0x30
+ .set cfa_current_offset, cfa_current_offset - 0x30
+ .endif
+.endm
+
+.macro .pushreg reg
+ .cfi_adjust_cfa_offset 8
+ .equ cfa_current_offset, cfa_current_offset - 8
+ .cfi_offset \reg, cfa_current_offset
+.endm
+
+.macro .savereg reg, offset
+ // checkme!!!
+ .cfi_offset \reg, \offset
+.endm
+
+.macro .savexmm128 reg, offset
+ // checkme!!!
+ .cfi_offset \reg, \offset
+.endm
+
+.macro .setframe reg, offset
+ .cfi_def_cfa reg, \offset
+ .equ cfa_current_offset, \offset
+.endm
+
+.macro .endprolog
+.endm
+
+.macro UNIMPLEMENTED2 line, func
+ jmp 3f
+ .equ expr, 12
+1: .asciz "\func"
+2: .asciz __FILE__
+3:
+ sub rsp, 0x20
+ lea rcx, _MsgUnimplemented[rip]
+ lea rdx, 1b[rip]
+ lea r8, 2b[rip]
+ mov r9, \line
+ call _DbgPrint
+ add rsp, 0x20
+.endm
+#define UNIMPLEMENTED UNIMPLEMENTED2 __LINE__,
+
--- /dev/null
+#ifndef _INTRIN_INTERNAL_
+#define _INTRIN_INTERNAL_
+
+VOID
+FORCEINLINE
+KeSetCurrentIrql(KIRQL Irql)
+{
+ __writecr8(Irql);
+}
+
+PKGDTENTRY64
+FORCEINLINE
+KiGetGdtEntry(PVOID pGdt, USHORT Selector)
+{
+ return (PKGDTENTRY64)((ULONG64)pGdt + (Selector & ~RPL_MASK));
+}
+
+PVOID
+FORCEINLINE
+KiGetGdtDescriptorBase(PKGDTENTRY Entry)
+{
+ return (PVOID)((ULONG64)Entry->BaseLow |
+ (ULONG64)Entry->Bytes.BaseMiddle << 16 |
+ (ULONG64)Entry->Bytes.BaseHigh << 24 |
+ (ULONG64)Entry->BaseUpper << 32);
+}
+
+VOID
+FORCEINLINE
+KiSetGdtDescriptorBase(PKGDTENTRY Entry, ULONG64 Base)
+{
+ Entry->BaseLow = Base & 0xffff;
+ Entry->Bits.BaseMiddle = (Base >> 16) & 0xff;
+ Entry->Bits.BaseHigh = (Base >> 24) & 0xff;
+ Entry->BaseUpper = Base >> 32;
+}
+
+VOID
+FORCEINLINE
+KiSetGdtDescriptorLimit(PKGDTENTRY Entry, ULONG Limit)
+{
+ Entry->LimitLow = Limit & 0xffff;
+ Entry->Bits.LimitHigh = Limit >> 16;
+}
+
+VOID
+FORCEINLINE
+KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl)
+{
+ KiSetGdtDescriptorBase(Entry, Base);
+ KiSetGdtDescriptorLimit(Entry, Size - 1);
+ Entry->Bits.Type = Type;
+ Entry->Bits.Dpl = Dpl;
+ Entry->Bits.Present = 1;
+ Entry->Bits.System = 0;
+ Entry->Bits.LongMode = 0;
+ Entry->Bits.DefaultBig = 0;
+ Entry->Bits.Granularity = 0;
+ Entry->MustBeZero = 0;
+}
+
+#if defined(__GNUC__)
+
+static __inline__ __attribute__((always_inline)) void __lgdt(void *Source)
+{
+ __asm__ __volatile__("lgdt %0" : : "m"(*(short*)Source));
+}
+
+static __inline__ __attribute__((always_inline)) void __sgdt(void *Destination)
+{
+ __asm__ __volatile__("sgdt %0" : : "m"(*(short*)Destination) : "memory");
+}
+
+static __inline__ __attribute__((always_inline)) void __lldt(unsigned short Value)
+{
+ __asm__ __volatile__("lldt %0" : : "rm"(Value));
+}
+
+static __inline__ __attribute__((always_inline)) void __sldt(void *Destination)
+{
+ __asm__ __volatile__("sldt %0" : : "m"(*(short*)Destination) : "memory");
+}
+
+static __inline__ __attribute__((always_inline)) void __ldmxcsr(unsigned long *Source)
+{
+ __asm__ __volatile__("ldmxcsr %0" : : "m"(*Source));
+}
+
+static __inline__ __attribute__((always_inline)) void __stmxcsr(unsigned long *Destination)
+{
+ __asm__ __volatile__("stmxcsr %0" : : "m"(*Destination) : "memory");
+}
+
+static __inline__ __attribute__((always_inline)) void __ltr(unsigned short Source)
+{
+ __asm__ __volatile__("ltr %0" : : "rm"(Source));
+}
+
+static __inline__ __attribute__((always_inline)) void __str(unsigned short *Destination)
+{
+ __asm__ __volatile__("str %0" : : "m"(*Destination) : "memory");
+}
+
+
+#elif defined(_MSC_VER)
+
+#define UNIMPLEMENTED DbgPrint("%s is unimplemented!!!\n", __FUNCTION__);
+
+void __lgdt(void *Source);
+
+void __sgdt(void *Destination);
+
+void __lldt(unsigned short Value);
+
+void __sldt(void *Destination);
+
+void __ltr(unsigned short Source);
+
+void __str(unsigned short *Destination);
+
+
+#else
+#error Unknown compiler for inline assembler
+#endif
+
+#endif
+
+/* EOF */
--- /dev/null
+#ifndef __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H
+#define __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H
+
+#define X86_EFLAGS_TF 0x00000100 /* Trap flag */
+#define X86_EFLAGS_IF 0x00000200 /* Interrupt Enable flag */
+#define X86_EFLAGS_IOPL 0x00003000 /* I/O Privilege Level bits */
+#define X86_EFLAGS_NT 0x00004000 /* Nested Task flag */
+#define X86_EFLAGS_RF 0x00010000 /* Resume flag */
+#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
+#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
+
+#define X86_CR0_PE 0x00000001 /* enable Protected Mode */
+#define X86_CR0_NE 0x00000020 /* enable native FPU error reporting */
+#define X86_CR0_TS 0x00000008 /* enable exception on FPU instruction for task switch */
+#define X86_CR0_EM 0x00000004 /* enable FPU emulation (disable FPU) */
+#define X86_CR0_MP 0x00000002 /* enable FPU monitoring */
+#define X86_CR0_WP 0x00010000 /* enable Write Protect (copy on write) */
+#define X86_CR0_PG 0x80000000 /* enable Paging */
+
+#define X86_CR4_PAE 0x00000020 /* enable physical address extensions */
+#define X86_CR4_PGE 0x00000080 /* enable global pages */
+#define X86_CR4_OSFXSR 0x00000200 /* enable FXSAVE/FXRSTOR instructions */
+#define X86_CR4_OSXMMEXCPT 0x00000400 /* enable #XF exception */
+
+#define X86_FEATURE_VME 0x00000002 /* Virtual 8086 Extensions are present */
+#define X86_FEATURE_TSC 0x00000010 /* time stamp counters are present */
+#define X86_FEATURE_PAE 0x00000040 /* physical address extension is present */
+#define X86_FEATURE_CX8 0x00000100 /* CMPXCHG8B instruction present */
+#define X86_FEATURE_SYSCALL 0x00000800 /* SYSCALL/SYSRET support present */
+#define X86_FEATURE_PGE 0x00002000 /* Page Global Enable */
+#define X86_FEATURE_MMX 0x00800000 /* MMX extension present */
+#define X86_FEATURE_FXSR 0x01000000 /* FXSAVE/FXRSTOR instructions present */
+#define X86_FEATURE_SSE 0x02000000 /* SSE extension present */
+#define X86_FEATURE_SSE2 0x04000000 /* SSE2 extension present */
+#define X86_FEATURE_HT 0x10000000 /* Hyper-Threading present */
+
+#define X86_EXT_FEATURE_SSE3 0x00000001 /* SSE3 extension present */
+#define X86_EXT_FEATURE_3DNOW 0x40000000 /* 3DNOW! extension present */
+
+#define FRAME_EDITED 0xFFF8
+
+#define X86_MSR_GSBASE 0xC0000101
+#define X86_MSR_KERNEL_GSBASE 0xC0000102
+#define X86_MSR_EFER 0xC0000080
+#define X86_MSR_STAR 0xC0000081
+#define X86_MSR_LSTAR 0xC0000082
+#define X86_MSR_CSTAR 0xC0000083
+#define X86_MSR_SFMASK 0xC0000084
+
+#define EFER_SCE 0x01
+#define EFER_LME 0x10
+#define EFER_LMA 0x40
+#define EFER_NXE 0x80
+#define EFER_SVME 0x100
+#define EFER_FFXSR 0x400
+
+#define AMD64_TSS 9
+
+#ifndef __ASM__
+
+#include "intrin_i.h"
+
+typedef struct _KIDT_INIT
+{
+ UCHAR InterruptId;
+ UCHAR Dpl;
+ UCHAR IstIndex;
+ PVOID ServiceRoutine;
+} KIDT_INIT, *PKIDT_INIT;
+
+extern ULONG Ke386CacheAlignment;
+extern ULONG KeI386NpxPresent;
+extern ULONG KeI386XMMIPresent;
+extern ULONG KeI386FxsrPresent;
+extern ULONG KeI386CpuType;
+extern ULONG KeI386CpuStep;
+
+#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_AMD64
+
+//
+// INT3 is 1 byte long
+//
+#define KD_BREAKPOINT_TYPE UCHAR
+#define KD_BREAKPOINT_SIZE sizeof(UCHAR)
+#define KD_BREAKPOINT_VALUE 0xCC
+
+//
+// Macros for getting and setting special purpose registers in portable code
+//
+#define KeGetContextPc(Context) \
+ ((Context)->Rip)
+
+#define KeSetContextPc(Context, ProgramCounter) \
+ ((Context)->Rip = (ProgramCounter))
+
+#define KeGetTrapFramePc(TrapFrame) \
+ ((TrapFrame)->Rip)
+
+#define KeGetContextReturnRegister(Context) \
+ ((Context)->Rax)
+
+#define KeSetContextReturnRegister(Context, ReturnValue) \
+ ((Context)->Rax = (ReturnValue))
+
+//
+// Macro to get trap and exception frame from a thread stack
+//
+#define KeGetTrapFrame(Thread) \
+ (PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
+ sizeof(KTRAP_FRAME))
+
+//
+// Macro to get context switches from the PRCB
+// All architectures but x86 have it in the PRCB's KeContextSwitches
+//
+#define KeGetContextSwitches(Prcb) \
+ (Prcb->KeContextSwitches)
+
+#define KeGetExceptionFrame(Thread) \
+ (PKEXCEPTION_FRAME)((ULONG_PTR)KeGetTrapFrame(Thread) - \
+ sizeof(KEXCEPTION_FRAME))
+
+//
+// Returns the Interrupt State from a Trap Frame.
+// ON = TRUE, OFF = FALSE
+//
+#define KeGetTrapFrameInterruptState(TrapFrame) \
+ BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK)
+
+//
+// Invalidates the TLB entry for a specified address
+//
+FORCEINLINE
+VOID
+KeInvalidateTlbEntry(IN PVOID Address)
+{
+ /* Invalidate the TLB entry for this address */
+ __invlpg(Address);
+}
+
+FORCEINLINE
+VOID
+KeFlushProcessTb(VOID)
+{
+ /* Flush the TLB by resetting CR3 */
+ __writecr3(__readcr3());
+}
+
+FORCEINLINE
+VOID
+KiRundownThread(IN PKTHREAD Thread)
+{
+#ifndef CONFIG_SMP
+ DbgPrint("KiRundownThread is unimplemented\n");
+#else
+ /* Nothing to do */
+#endif
+}
+
+VOID
+FORCEINLINE
+KiEndInterrupt(IN KIRQL Irql,
+ IN PKTRAP_FRAME TrapFrame)
+{
+ DbgPrint("KiEndInterrupt is unimplemented\n");
+}
+
+#define Ki386PerfEnd(x)
+
+struct _KPCR;
+
+VOID
+FASTCALL
+KiInitializeTss(IN PKTSS Tss, IN UINT64 Stack);
+
+VOID KiDivideErrorFault();
+VOID KiDebugTrapOrFault();
+VOID KiNmiInterrupt();
+VOID KiBreakpointTrap();
+VOID KiOverflowTrap();
+VOID KiBoundFault();
+VOID KiInvalidOpcodeFault();
+VOID KiNpxNotAvailableFault();
+VOID KiDoubleFaultAbort();
+VOID KiNpxSegmentOverrunAbort();
+VOID KiInvalidTssFault();
+VOID KiSegmentNotPresentFault();
+VOID KiStackFault();
+VOID KiGeneralProtectionFault();
+VOID KiPageFault();
+VOID KiFloatingErrorFault();
+VOID KiAlignmentFault();
+VOID KiMcheckAbort();
+VOID KiXmmException();
+VOID KiApcInterrupt();
+VOID KiRaiseAssertion();
+VOID KiDebugServiceTrap();
+VOID KiDpcInterrupt();
+VOID KiIpiInterrupt();
+
+VOID
+KiGdtPrepareForApplicationProcessorInit(ULONG Id);
+VOID
+Ki386InitializeLdt(VOID);
+VOID
+Ki386SetProcessorFeatures(VOID);
+
+VOID
+NTAPI
+KiGetCacheInformation(VOID);
+
+BOOLEAN
+NTAPI
+KiIsNpxPresent(
+ VOID
+);
+
+BOOLEAN
+NTAPI
+KiIsNpxErrataPresent(
+ VOID
+);
+
+VOID
+NTAPI
+KiSetProcessorType(VOID);
+
+ULONG
+NTAPI
+KiGetFeatureBits(VOID);
+
+VOID
+NTAPI
+KiInitializeCpuFeatures();
+
+ULONG KeAllocateGdtSelector(ULONG Desc[2]);
+VOID KeFreeGdtSelector(ULONG Entry);
+VOID
+NtEarlyInitVdm(VOID);
+VOID
+KeApplicationProcessorInitDispatcher(VOID);
+VOID
+KeCreateApplicationProcessorIdleThread(ULONG Id);
+
+VOID
+NTAPI
+Ke386InitThreadWithContext(PKTHREAD Thread,
+ PKSYSTEM_ROUTINE SystemRoutine,
+ PKSTART_ROUTINE StartRoutine,
+ PVOID StartContext,
+ PCONTEXT Context);
+#define KeArchInitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context) \
+ Ke386InitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context)
+
+#ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */
+VOID
+NTAPI
+KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine,
+ PKSTART_ROUTINE StartRoutine,
+ PVOID StartContext,
+ BOOLEAN UserThread,
+ KTRAP_FRAME TrapFrame);
+#endif
+
+#endif
+#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */
+
+/* EOF */
--- /dev/null
+/*
+ * Lowlevel memory managment definitions
+ */
+
+#pragma once
+
+/* Helper macros */
+#define PAGE_MASK(x) ((x)&(~0xfff))
+#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL))
+
+/* Memory layout base addresses */
+#define HYPER_SPACE 0xFFFFF70000000000ULL
+#define HYPER_SPACE_END 0xFFFFF77FFFFFFFFFULL
+#define MI_SESSION_SPACE_MINIMUM (PVOID)0xFFFFF90000000000ULL
+#define MI_SESSION_VIEW_END (PVOID)0xFFFFF97FFF000000ULL
+#define MI_SESSION_SPACE_END (PVOID)0xFFFFF98000000000ULL
+#define MI_SYSTEM_PTE_START (PVOID)0xFFFFFAA000000000ULL
+#define MI_PAGED_POOL_START (PVOID)0xFFFFFA8000000000ULL
+#define MI_NON_PAGED_SYSTEM_START_MIN 0xFFFFFAA000000000ULL
+#define MI_PFN_DATABASE (PVOID)0xFFFFFAC000000000ULL
+#define MI_NONPAGED_POOL_END (PVOID)0xFFFFFAE000000000ULL
+#define MI_DEBUG_MAPPING (PVOID)0xFFFFFFFF80000000ULL // FIXME
+#define MI_HIGHEST_SYSTEM_ADDRESS (PVOID)0xFFFFFFFFFFFFFFFFULL
+#define MI_SYSTEM_CACHE_WS_START (PVOID)0xFFFFF78000001000ULL // CHECKME
+
+/* Memory sizes */
+#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING ((255*1024*1024) >> PAGE_SHIFT)
+#define MI_MIN_PAGES_FOR_SYSPTE_TUNING ((19*1024*1024) >> PAGE_SHIFT)
+#define MI_MIN_PAGES_FOR_SYSPTE_BOOST ((32*1024*1024) >> PAGE_SHIFT)
+#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
+#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024)
+#define MI_MAX_FREE_PAGE_LISTS 4
+#define MI_MIN_INIT_PAGED_POOLSIZE (32 * 1024 * 1024)
+#define MI_SESSION_VIEW_SIZE (20 * 1024 * 1024)
+#define MI_SESSION_POOL_SIZE (16 * 1024 * 1024)
+#define MI_SESSION_IMAGE_SIZE (8 * 1024 * 1024)
+#define MI_SESSION_WORKING_SET_SIZE (4 * 1024 * 1024)
+#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \
+ MI_SESSION_POOL_SIZE + \
+ MI_SESSION_IMAGE_SIZE + \
+ MI_SESSION_WORKING_SET_SIZE)
+#define MI_SYSTEM_VIEW_SIZE (16 * 1024 * 1024)
+#define MI_NUMBER_SYSTEM_PTES 22000
+
+PULONG64
+FORCEINLINE
+MmGetPageDirectory(VOID)
+{
+ return (PULONG64)__readcr3();
+}
+
+PMMPTE
+FORCEINLINE
+MiAddressToPxe(PVOID Address)
+{
+ ULONG64 Offset = (ULONG64)Address >> (PXI_SHIFT - 3);
+ Offset &= PXI_MASK << 3;
+ return (PMMPTE)(PXE_BASE + Offset);
+}
+
+PMMPTE
+FORCEINLINE
+MiAddressToPpe(PVOID Address)
+{
+ ULONG64 Offset = (ULONG64)Address >> (PPI_SHIFT - 3);
+ Offset &= 0x3FFFF << 3;
+ return (PMMPTE)(PPE_BASE + Offset);
+}
+
+PMMPTE
+FORCEINLINE
+_MiAddressToPde(PVOID Address)
+{
+ ULONG64 Offset = (ULONG64)Address >> (PDI_SHIFT - 3);
+ Offset &= 0x7FFFFFF << 3;
+ return (PMMPTE)(PDE_BASE + Offset);
+}
+#define MiAddressToPde(x) _MiAddressToPde((PVOID)(x))
+
+PMMPTE
+FORCEINLINE
+_MiAddressToPte(PVOID Address)
+{
+ ULONG64 Offset = (ULONG64)Address >> (PTI_SHIFT - 3);
+ Offset &= 0xFFFFFFFFFULL << 3;
+ return (PMMPTE)(PTE_BASE + Offset);
+}
+#define MiAddressToPte(x) _MiAddressToPte((PVOID)(x))
+
+/* Convert a PTE into a corresponding address */
+PVOID
+FORCEINLINE
+MiPteToAddress(PMMPTE Pte)
+{
+ /* Use signed math */
+ LONG64 Temp = (LONG64)Pte;
+ Temp <<= 25;
+ Temp >>= 16;
+ return (PVOID)Temp;
+}
+
+BOOLEAN
+FORCEINLINE
+MiIsPdeForAddressValid(PVOID Address)
+{
+ return ((MiAddressToPxe(Address)->u.Hard.Valid) &&
+ (MiAddressToPpe(Address)->u.Hard.Valid) &&
+ (MiAddressToPde(Address)->u.Hard.Valid));
+}
+
+#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE))
+#define ADDR_TO_PDE_OFFSET(v) ((((ULONG_PTR)(v)) / (512 * PAGE_SIZE)))
+#define ADDR_TO_PTE_OFFSET(v) ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE)
+
+#define VAtoPXI(va) ((((ULONG64)va) >> PXI_SHIFT) & 0x1FF)
+#define VAtoPPI(va) ((((ULONG64)va) >> PPI_SHIFT) & 0x1FF)
+#define VAtoPDI(va) ((((ULONG64)va) >> PDI_SHIFT) & 0x1FF)
+#define VAtoPTI(va) ((((ULONG64)va) >> PTI_SHIFT) & 0x1FF)
+
+/* We don't use these hacks */
+VOID
+FORCEINLINE
+MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
+{
+ /* Nothing to do */
+}
+
+VOID
+FORCEINLINE
+MmInitGlobalKernelPageDirectory(VOID)
+{
+ /* Nothing to do */
+}
+
+#define IS_ALIGNED(addr, align) (((ULONG64)(addr) & (align - 1)) == 0)
+#define IS_PAGE_ALIGNED(addr) IS_ALIGNED(addr, PAGE_SIZE)
+
+/* Easy accessing PFN in PTE */
+#define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber)
+
+// FIXME, only copied from x86
+#define MI_MAKE_LOCAL_PAGE(x) ((x)->u.Hard.Global = 0)
+#define MI_MAKE_DIRTY_PAGE(x) ((x)->u.Hard.Dirty = 1)
+#define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.CacheDisable = 1)
+#define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.WriteThrough = 1)
+#define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.WriteThrough = 0)
+#if !defined(CONFIG_SMP)
+#define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Write == 1)
+#else
+#define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Writable == 1)
+#endif
+#define MI_IS_PAGE_COPY_ON_WRITE(x)((x)->u.Hard.CopyOnWrite == 1)
+#define MI_IS_PAGE_DIRTY(x) ((x)->u.Hard.Dirty == 1)
+#define MI_MAKE_OWNER_PAGE(x) ((x)->u.Hard.Owner = 1)
+#if !defined(CONFIG_SMP)
+#define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Write = 1)
+#else
+#define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Writable = 1)
+#endif
+
+// FIXME!!!
+#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
+ ((x) / (4*1024*1024))
+
+#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \
+ ((((x)) % (4*1024*1024)) / (4*1024))
+
+#define NR_SECTION_PAGE_TABLES 1024
+#define NR_SECTION_PAGE_ENTRIES 1024
+
+//#define TEB_BASE 0x7FFDE000
+
+#define MI_HYPERSPACE_PTES (256 - 1)
+#define MI_ZERO_PTES (32)
+#define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE
+#define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \
+ MI_HYPERSPACE_PTES * PAGE_SIZE)
+#define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \
+ PAGE_SIZE)
+
+/* On x86, these two are the same */
+#define MMPDE MMPTE
+#define PMMPDE PMMPTE
+
+/*
+* FIXME - different architectures have different cache line sizes...
+*/
+#define MM_CACHE_LINE_SIZE 32
+
#include "../mips/intrin_i.h"
#elif defined(_M_ARM)
#include "../arm/intrin_i.h"
+#elif defined(_M_AMD64)
+#include "../amd64/intrin_i.h"
#else
#error "Unknown processor"
#endif
#include "../mips/ke.h"
#elif defined(_M_ARM)
#include "../arm/ke.h"
+#elif defined(_M_AMD64)
+#include "../amd64/ke.h"
#else
#error "Unknown processor"
#endif
#include <internal/mips/mm.h>
#elif defined(_M_ARM)
#include <internal/arm/mm.h>
+#elif defined(_M_AMD64)
+#include <internal/amd64/mm.h>
#else
#error "Unknown processor"
#endif
IN ULONG Flags
);
+//
+// Hive List Routines
+//
+NTSTATUS
+NTAPI
+CmpAddToHiveFileList(
+ IN PCMHIVE Hive
+);
+
+//
+// Quota Routines
+//
+VOID
+NTAPI
+CmpSetGlobalQuotaAllowed(
+ VOID
+);
+
//
// Notification Routines
//
IN ULONG Filter
);
+VOID
+NTAPI
+CmpFlushNotify(
+ IN PCM_KEY_BODY KeyBody,
+ IN BOOLEAN LockHeld
+);
+
VOID
NTAPI
CmpInitCallback(
VOID
);
+VOID
+NTAPI
+CmpLockHiveFlusherExclusive(
+ IN PCMHIVE Hive
+);
+
+VOID
+NTAPI
+CmpLockHiveFlusherShared(
+ IN PCMHIVE Hive
+);
+
+BOOLEAN
+NTAPI
+CmpTestHiveFlusherLockExclusive(
+ IN PCMHIVE Hive
+);
+
+BOOLEAN
+NTAPI
+CmpTestHiveFlusherLockShared(
+ IN PCMHIVE Hive
+);
+
+VOID
+NTAPI
+CmpUnlockHiveFlusher(
+ IN PCMHIVE Hive
+);
+
//
// Delay Functions
//
IN ULONG ConvKey2
);
+VOID
+NTAPI
+CmpFlushNotifiesOnKeyBodyList(
+ IN PCM_KEY_CONTROL_BLOCK Kcb,
+ IN BOOLEAN LockHeld
+);
+
//
// Name Functions
//
extern BOOLEAN CmpNoWrite;
extern BOOLEAN CmpForceForceFlush;
extern BOOLEAN CmpWasSetupBoot;
+extern BOOLEAN CmpProfileLoaded;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
extern BOOLEAN CmpHoldLazyFlush;
ASSERT((CmpSpecialBootCondition == TRUE) || \
(CmpTestRegistryLock() == TRUE))
+//
+// Makes sure that the registry is locked or loading
+//
+#define CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(h) \
+ ASSERT((CmpSpecialBootCondition == TRUE) || \
+ (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
+ (CmpTestRegistryLock() == TRUE))
+
//
// Makes sure that the registry is exclusively locked
//
ASSERT((CmpSpecialBootCondition == TRUE) || \
(CmpTestRegistryLockExclusive() == TRUE))
+//
+// Makes sure that the registry is exclusively locked or loading
+//
+#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(h) \
+ ASSERT((CmpSpecialBootCondition == TRUE) || \
+ (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
+ (CmpTestRegistryLockExclusive() == TRUE))
+
//
// Makes sure this is a valid KCB
//
(k)).Lock); \
}
+//
+// Asserts that either the registry or the hash entry is locked
+//
+#define CMP_ASSERT_HASH_ENTRY_LOCK(k) \
+{ \
+ ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k).Owner == \
+ KeGetCurrentThread())) || \
+ (CmpTestRegistryLockExclusive() == TRUE)); \
+}
+
+//
+// Asserts that either the registry or the KCB is locked
+//
+#define CMP_ASSERT_KCB_LOCK(k) \
+{ \
+ ASSERT((CmpIsKcbLockedExclusive(k) == TRUE) || \
+ (CmpTestRegistryLockExclusive() == TRUE)); \
+}
+
+//
+// Gets the page attached to the KCB
+//
+#define CmpGetAllocPageFromKcb(k) \
+ (PCM_ALLOC_PAGE)(((ULONG_PTR)(k)) & ~(PAGE_SIZE - 1))
+
+//
+// Gets the page attached to the delayed allocation
+//
+#define CmpGetAllocPageFromDelayAlloc(a) \
+ (PCM_ALLOC_PAGE)(((ULONG_PTR)(a)) & ~(PAGE_SIZE - 1))
+
+//
+// Makes sure that the registry is locked for flushes
+//
+#define CMP_ASSERT_FLUSH_LOCK(h) \
+ ASSERT((CmpSpecialBootCondition == TRUE) || \
+ (((PCMHIVE)h)->HiveIsLoading == TRUE) || \
+ (CmpTestHiveFlusherLockShared((PCMHIVE)h) == TRUE) || \
+ (CmpTestHiveFlusherLockExclusive((PCMHIVE)h) == TRUE) || \
+ (CmpTestRegistryLockExclusive() == TRUE));
+
//
// Asserts that either the registry or the KCB is locked
//
NTSTATUS
PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName,
- IN OUT PDEVICE_OBJECT *PhysicalDeviceObject
+ OUT PDEVICE_OBJECT *PhysicalDeviceObject,
+ OUT OPTIONAL PUNICODE_STRING FullInstancePath
);
//
IN ACCESS_MASK DesiredAccess,
OUT PHANDLE DeviceInterfaceKey)
{
- return STATUS_NOT_IMPLEMENTED;
+ WCHAR StrBuff[MAX_PATH], PathBuff[MAX_PATH];
+ PWCHAR Guid;
+ UNICODE_STRING EnumU = RTL_CONSTANT_STRING(ENUM_ROOT L"\\");
+ UNICODE_STRING DevParamU = RTL_CONSTANT_STRING(L"\\Device Parameters");
+ UNICODE_STRING PrefixU = RTL_CONSTANT_STRING(L"\\??\\");
+ UNICODE_STRING KeyPath, KeyName;
+ UNICODE_STRING MatchableGuid;
+ HANDLE GuidKey, ChildKey;
+ ULONG Index = 0;
+ PKEY_BASIC_INFORMATION KeyInformation;
+ ULONG KeyInformationLength;
+ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
+ ULONG KeyValueInformationLength;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ NTSTATUS Status;
+ ULONG RequiredLength;
+
+ MatchableGuid.Length = 0;
+ MatchableGuid.Length += swprintf(StrBuff,
+ L"##?#%ls",
+ &SymbolicLinkName->Buffer[PrefixU.Length / sizeof(WCHAR)]);
+ StrBuff[++MatchableGuid.Length] = UNICODE_NULL;
+
+ MatchableGuid.Buffer = StrBuff;
+ MatchableGuid.MaximumLength = MAX_PATH * sizeof(WCHAR);
+ MatchableGuid.Length = (MatchableGuid.Length-1) * sizeof(WCHAR);
+
+ Guid = wcsstr(StrBuff, L"{");
+ if (!Guid)
+ return STATUS_OBJECT_NAME_NOT_FOUND;
+
+ KeyPath.Buffer = PathBuff;
+ KeyPath.Length = 0;
+ KeyPath.MaximumLength = MAX_PATH * sizeof(WCHAR);
+
+ RtlAppendUnicodeToString(&KeyPath, BaseKeyString);
+ RtlAppendUnicodeToString(&KeyPath, Guid);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyPath,
+ OBJ_CASE_INSENSITIVE,
+ 0,
+ NULL);
+
+ Status = ZwOpenKey(&GuidKey, KEY_CREATE_SUB_KEY, &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ while (TRUE)
+ {
+ Status = ZwEnumerateKey(GuidKey,
+ Index,
+ KeyBasicInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ break;
+ else if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyInformationLength = RequiredLength;
+ KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength);
+ if (!KeyInformation)
+ {
+ ZwClose(GuidKey);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ Status = ZwEnumerateKey(GuidKey,
+ Index,
+ KeyBasicInformation,
+ KeyInformation,
+ KeyInformationLength,
+ &RequiredLength);
+ }
+ else
+ {
+ ZwClose(GuidKey);
+ return STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+ Index++;
+
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(GuidKey);
+ return Status;
+ }
+
+ KeyName.Length = KeyName.MaximumLength = KeyInformation->NameLength;
+ KeyName.Buffer = KeyInformation->Name;
+
+ if (!RtlEqualUnicodeString(&KeyName, &MatchableGuid, TRUE))
+ continue;
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ GuidKey,
+ NULL);
+ Status = ZwOpenKey(&ChildKey, KEY_QUERY_VALUE, &ObjectAttributes);
+ ZwClose(GuidKey);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, L"DeviceInstance");
+ Status = ZwQueryValueKey(ChildKey,
+ &KeyName,
+ KeyValuePartialInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyValueInformationLength = RequiredLength;
+ KeyValueInformation = ExAllocatePool(PagedPool, KeyValueInformationLength);
+ if (!KeyValueInformation)
+ {
+ ZwClose(ChildKey);
+ return Status;
+ }
+
+ Status = ZwQueryValueKey(ChildKey,
+ &KeyName,
+ KeyValuePartialInformation,
+ KeyValueInformation,
+ KeyValueInformationLength,
+ &RequiredLength);
+ }
+ else
+ {
+ ZwClose(ChildKey);
+ return STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+ ZwClose(ChildKey);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ KeyPath.Length = 0;
+
+ KeyName.Length = KeyName.MaximumLength = KeyValueInformation->DataLength;
+ KeyName.Buffer = (PWCHAR)KeyValueInformation->Data;
+
+ RtlAppendUnicodeStringToString(&KeyPath, &EnumU);
+ RtlAppendUnicodeStringToString(&KeyPath, &KeyName);
+ RtlAppendUnicodeStringToString(&KeyPath, &DevParamU);
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyPath,
+ OBJ_CASE_INSENSITIVE,
+ 0,
+ NULL);
+ Status = ZwCreateKey(DeviceInterfaceKey,
+ DesiredAccess,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ NULL);
+ return Status;
+ }
+
+ return STATUS_OBJECT_PATH_NOT_FOUND;
}
/*++
#define NDEBUG
#include <debug.h>
-#define ENABLE_ACPI
+//#define ENABLE_ACPI
/* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/
-static NTSTATUS
+NTSTATUS
IopAssignDeviceResources(
IN PDEVICE_NODE DeviceNode,
OUT ULONG *pRequiredSize);
-static NTSTATUS
+
+NTSTATUS
IopTranslateDeviceResources(
IN PDEVICE_NODE DeviceNode,
IN ULONG RequiredSize);
+NTSTATUS
+IopUpdateResourceMapForPnPDevice(
+ IN PDEVICE_NODE DeviceNode);
+
+NTSTATUS
+NTAPI
+IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
+ OUT PHANDLE Handle);
+
PDEVICE_NODE
FASTCALL
IopGetDeviceNode(PDEVICE_OBJECT DeviceObject)
IO_STACK_LOCATION Stack;
ULONG RequiredLength;
NTSTATUS Status;
+ HANDLE InstanceHandle, ControlHandle;
+ UNICODE_STRING KeyName;
+ OBJECT_ATTRIBUTES ObjectAttributes;
IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES);
DPRINT("Sending IRP_MN_FILTER_RESOURCE_REQUIREMENTS to device stack\n");
DPRINT("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n");
return Status;
}
- DeviceNode->ResourceRequirements = Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList;
+ DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information;
Status = IopAssignDeviceResources(DeviceNode, &RequiredLength);
if (NT_SUCCESS(Status))
Status = IopTranslateDeviceResources(DeviceNode, RequiredLength);
if (NT_SUCCESS(Status))
{
- IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_ASSIGNED);
+ Status = IopUpdateResourceMapForPnPDevice(DeviceNode);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("IopUpdateResourceMap() failed (Status 0x%08lx)\n", Status);
+ }
}
else
{
}
}
+ Status = IopCreateDeviceKeyPath(&DeviceNode->InstancePath, &InstanceHandle);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, L"Control");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ InstanceHandle,
+ NULL);
+ Status = ZwCreateKey(&ControlHandle, KEY_SET_VALUE, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(InstanceHandle);
+ return Status;
+ }
+
+ RtlInitUnicodeString(&KeyName, L"ActiveService");
+ Status = ZwSetValueKey(ControlHandle, &KeyName, 0, REG_SZ, DeviceNode->ServiceName.Buffer, DeviceNode->ServiceName.Length);
+
if (NT_SUCCESS(Status))
IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED);
+ ZwClose(ControlHandle);
+ ZwClose(InstanceHandle);
+
return Status;
}
PDEVICE_NODE Node;
NTSTATUS Status;
KIRQL OldIrql;
+ UNICODE_STRING FullServiceName;
+ UNICODE_STRING LegacyPrefix = RTL_CONSTANT_STRING(L"LEGACY_");
+ UNICODE_STRING UnknownDeviceName = RTL_CONSTANT_STRING(L"UNKNOWN");
+ HANDLE TempHandle;
DPRINT("ParentNode 0x%p PhysicalDeviceObject 0x%p ServiceName %wZ\n",
ParentNode, PhysicalDeviceObject, ServiceName);
RtlZeroMemory(Node, sizeof(DEVICE_NODE));
+ if (!ServiceName)
+ ServiceName = &UnknownDeviceName;
+
if (!PhysicalDeviceObject)
{
- Status = PnpRootCreateDevice(ServiceName, &PhysicalDeviceObject);
+ FullServiceName.MaximumLength = LegacyPrefix.Length + ServiceName->Length;
+ FullServiceName.Length = 0;
+ FullServiceName.Buffer = ExAllocatePool(PagedPool, FullServiceName.MaximumLength);
+ if (!FullServiceName.Buffer)
+ {
+ ExFreePool(Node);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ RtlAppendUnicodeStringToString(&FullServiceName, &LegacyPrefix);
+ RtlAppendUnicodeStringToString(&FullServiceName, ServiceName);
+
+ Status = PnpRootCreateDevice(&FullServiceName, &PhysicalDeviceObject, &Node->InstancePath);
if (!NT_SUCCESS(Status))
{
DPRINT1("PnpRootCreateDevice() failed with status 0x%08X\n", Status);
return Status;
}
+ /* Create the device key for legacy drivers */
+ Status = IopCreateDeviceKeyPath(&Node->InstancePath, &TempHandle);
+ if (NT_SUCCESS(Status))
+ ZwClose(TempHandle);
+
+ ExFreePool(FullServiceName.Buffer);
+
/* This is for drivers passed on the command line to ntoskrnl.exe */
IopDeviceNodeSetFlag(Node, DNF_STARTED);
IopDeviceNodeSetFlag(Node, DNF_LEGACY_DRIVER);
return STATUS_UNSUCCESSFUL;
}
+NTSTATUS
+IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2Key)
+{
+ NTSTATUS Status;
+ ULONG Disposition;
+ HANDLE PnpMgrLevel1, PnpMgrLevel2, ResourceMapKey;
+ UNICODE_STRING KeyName;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+
+ RtlInitUnicodeString(&KeyName,
+ L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
+ 0,
+ NULL);
+ Status = ZwCreateKey(&ResourceMapKey,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, Level1Key);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
+ ResourceMapKey,
+ NULL);
+ Status = ZwCreateKey(&PnpMgrLevel1,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ ZwClose(ResourceMapKey);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ RtlInitUnicodeString(&KeyName, Level2Key);
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_OPENIF,
+ PnpMgrLevel1,
+ NULL);
+ Status = ZwCreateKey(&PnpMgrLevel2,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ REG_OPTION_VOLATILE,
+ &Disposition);
+ ZwClose(PnpMgrLevel1);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ if (DeviceNode->ResourceList)
+ {
+ WCHAR NameBuff[256];
+ UNICODE_STRING NameU;
+ UNICODE_STRING Suffix;
+ ULONG OldLength;
+
+ ASSERT(DeviceNode->ResourceListTranslated);
+
+ NameU.Buffer = NameBuff;
+ NameU.Length = 0;
+ NameU.MaximumLength = 256 * sizeof(WCHAR);
+
+ Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject,
+ DevicePropertyPhysicalDeviceObjectName,
+ NameU.MaximumLength,
+ NameU.Buffer,
+ &OldLength);
+ ASSERT(Status == STATUS_SUCCESS);
+
+ NameU.Length = (USHORT)OldLength;
+
+ RtlInitUnicodeString(&Suffix, L".Raw");
+ RtlAppendUnicodeStringToString(&NameU, &Suffix);
+
+ Status = ZwSetValueKey(PnpMgrLevel2,
+ &NameU,
+ 0,
+ REG_RESOURCE_LIST,
+ DeviceNode->ResourceList,
+ CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceList));
+ if (!NT_SUCCESS(Status))
+ {
+ ZwClose(PnpMgrLevel2);
+ return Status;
+ }
+
+ /* "Remove" the suffix by setting the length back to what it used to be */
+ NameU.Length = (USHORT)OldLength;
+
+ RtlInitUnicodeString(&Suffix, L".Translated");
+ RtlAppendUnicodeStringToString(&NameU, &Suffix);
+
+ Status = ZwSetValueKey(PnpMgrLevel2,
+ &NameU,
+ 0,
+ REG_RESOURCE_LIST,
+ DeviceNode->ResourceListTranslated,
+ CM_RESOURCE_LIST_SIZE(DeviceNode->ResourceListTranslated));
+ ZwClose(PnpMgrLevel2);
+ if (!NT_SUCCESS(Status))
+ return Status;
+ }
+ else
+ {
+ ZwClose(PnpMgrLevel2);
+ }
+
+ IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_ASSIGNED);
+
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+IopUpdateResourceMapForPnPDevice(IN PDEVICE_NODE DeviceNode)
+{
+ return IopUpdateResourceMap(DeviceNode, L"PnP Manager", L"PnpManager");
+}
-static
NTSTATUS
IopSetDeviceInstanceData(HANDLE InstanceKey,
PDEVICE_NODE DeviceNode)
ULONG ResCount;
ULONG ListSize, ResultLength;
NTSTATUS Status;
+ HANDLE ControlHandle;
DPRINT("IopSetDeviceInstanceData() called\n");
sizeof(DefaultConfigFlags));
}
+ /* Create the 'Control' key */
+ RtlInitUnicodeString(&KeyName, L"Control");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ InstanceKey,
+ NULL);
+ Status = ZwCreateKey(&ControlHandle, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL);
+
+ if (NT_SUCCESS(Status))
+ ZwClose(ControlHandle);
+
DPRINT("IopSetDeviceInstanceData() done\n");
- return STATUS_SUCCESS;
+ return Status;
+}
+
+BOOLEAN
+IopCheckForResourceConflict(
+ IN PCM_RESOURCE_LIST ResourceList1,
+ IN PCM_RESOURCE_LIST ResourceList2)
+{
+ ULONG i1, i2, ii1, ii2;
+ BOOLEAN Result = FALSE;
+
+ for (i1 = 0; i1 < ResourceList1->Count; i1++)
+ {
+ PCM_PARTIAL_RESOURCE_LIST ResList1 = &ResourceList1->List[i1].PartialResourceList;
+ for (i2 = 0; i2 < ResourceList2->Count; i2++)
+ {
+ PCM_PARTIAL_RESOURCE_LIST ResList2 = &ResourceList2->List[i2].PartialResourceList;
+ for (ii1 = 0; ii1 < ResList1->Count; ii1++)
+ {
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc1 = &ResList1->PartialDescriptors[ii1];
+
+ if (ResDesc1->ShareDisposition == CmResourceShareShared)
+ continue;
+
+ for (ii2 = 0; ii2 < ResList2->Count; ii2++)
+ {
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR ResDesc2 = &ResList2->PartialDescriptors[ii2];
+
+ /* We don't care about shared resources */
+ if (ResDesc2->ShareDisposition == CmResourceShareShared)
+ continue;
+
+ /* Make sure we're comparing the same types */
+ if (ResDesc1->Type != ResDesc2->Type)
+ continue;
+
+ switch (ResDesc1->Type)
+ {
+ case CmResourceTypeMemory:
+ if ((ResDesc1->u.Memory.Start.QuadPart < ResDesc2->u.Memory.Start.QuadPart &&
+ ResDesc1->u.Memory.Start.QuadPart + ResDesc1->u.Memory.Length >
+ ResDesc2->u.Memory.Start.QuadPart) || (ResDesc2->u.Memory.Start.QuadPart <
+ ResDesc1->u.Memory.Start.QuadPart && ResDesc2->u.Memory.Start.QuadPart +
+ ResDesc2->u.Memory.Length > ResDesc1->u.Memory.Start.QuadPart))
+ {
+ DPRINT1("Resource conflict: Memory (0x%x to 0x%x vs. 0x%x to 0x%x)\n",
+ ResDesc1->u.Memory.Start.QuadPart, ResDesc1->u.Memory.Start.QuadPart +
+ ResDesc1->u.Memory.Length, ResDesc2->u.Memory.Start.QuadPart,
+ ResDesc2->u.Memory.Start.QuadPart + ResDesc2->u.Memory.Length);
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+
+ case CmResourceTypePort:
+ if ((ResDesc1->u.Port.Start.QuadPart < ResDesc2->u.Port.Start.QuadPart &&
+ ResDesc1->u.Port.Start.QuadPart + ResDesc1->u.Port.Length >
+ ResDesc2->u.Port.Start.QuadPart) || (ResDesc2->u.Port.Start.QuadPart <
+ ResDesc1->u.Port.Start.QuadPart && ResDesc2->u.Port.Start.QuadPart +
+ ResDesc2->u.Port.Length > ResDesc1->u.Port.Start.QuadPart))
+ {
+ DPRINT1("Resource conflict: Port (0x%x to 0x%x vs. 0x%x to 0x%x)\n",
+ ResDesc1->u.Port.Start.QuadPart, ResDesc1->u.Port.Start.QuadPart +
+ ResDesc1->u.Port.Length, ResDesc2->u.Port.Start.QuadPart,
+ ResDesc2->u.Port.Start.QuadPart + ResDesc2->u.Port.Length);
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+
+ case CmResourceTypeInterrupt:
+ if (ResDesc1->u.Interrupt.Vector == ResDesc2->u.Interrupt.Vector)
+ {
+ DPRINT1("Resource conflict: IRQ (0x%x 0x%x vs. 0x%x 0x%x)\n",
+ ResDesc1->u.Interrupt.Vector, ResDesc1->u.Interrupt.Level,
+ ResDesc2->u.Interrupt.Vector, ResDesc2->u.Interrupt.Level);
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+
+ case CmResourceTypeBusNumber:
+ if ((ResDesc1->u.BusNumber.Start < ResDesc2->u.BusNumber.Start &&
+ ResDesc1->u.BusNumber.Start + ResDesc1->u.BusNumber.Length >
+ ResDesc2->u.BusNumber.Start) || (ResDesc2->u.BusNumber.Start <
+ ResDesc1->u.BusNumber.Start && ResDesc2->u.BusNumber.Start +
+ ResDesc2->u.BusNumber.Length > ResDesc1->u.BusNumber.Start))
+ {
+ DPRINT1("Resource conflict: Bus number (0x%x to 0x%x vs. 0x%x to 0x%x)\n",
+ ResDesc1->u.BusNumber.Start, ResDesc1->u.BusNumber.Start +
+ ResDesc1->u.BusNumber.Length, ResDesc2->u.BusNumber.Start,
+ ResDesc2->u.BusNumber.Start + ResDesc2->u.BusNumber.Length);
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+
+ case CmResourceTypeDma:
+ if (ResDesc1->u.Dma.Channel == ResDesc2->u.Dma.Channel)
+ {
+ DPRINT1("Resource conflict: Dma (0x%x 0x%x vs. 0x%x 0x%x)\n",
+ ResDesc1->u.Dma.Channel, ResDesc1->u.Dma.Port,
+ ResDesc2->u.Dma.Channel, ResDesc2->u.Dma.Port);
+
+ Result = TRUE;
+
+ goto ByeBye;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ByeBye:
+
+#ifdef ENABLE_RESOURCE_CONFLICT_DETECTION
+ return Result;
+#else
+ return FALSE;
+#endif
}
+NTSTATUS
+IopDetectResourceConflict(
+ IN PCM_RESOURCE_LIST ResourceList)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING KeyName;
+ HANDLE ResourceMapKey = INVALID_HANDLE_VALUE, ChildKey2 = INVALID_HANDLE_VALUE, ChildKey3 = INVALID_HANDLE_VALUE;
+ ULONG KeyInformationLength, RequiredLength, KeyValueInformationLength, KeyNameInformationLength;
+ PKEY_BASIC_INFORMATION KeyInformation;
+ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
+ PKEY_VALUE_BASIC_INFORMATION KeyNameInformation;
+ ULONG ChildKeyIndex1 = 0, ChildKeyIndex2 = 0, ChildKeyIndex3 = 0;
+ NTSTATUS Status;
+
+ RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP");
+ InitializeObjectAttributes(&ObjectAttributes, &KeyName, OBJ_CASE_INSENSITIVE, 0, NULL);
+ Status = ZwOpenKey(&ResourceMapKey, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ /* The key is missing which means we are the first device */
+ return STATUS_SUCCESS;
+ }
+
+ while (TRUE)
+ {
+ Status = ZwEnumerateKey(ResourceMapKey,
+ ChildKeyIndex1,
+ KeyBasicInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ break;
+ else if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyInformationLength = RequiredLength;
+ KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength);
+ if (!KeyInformation)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto cleanup;
+ }
+
+ Status = ZwEnumerateKey(ResourceMapKey,
+ ChildKeyIndex1,
+ KeyBasicInformation,
+ KeyInformation,
+ KeyInformationLength,
+ &RequiredLength);
+ }
+ else
+ goto cleanup;
+ ChildKeyIndex1++;
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ KeyName.Buffer = KeyInformation->Name;
+ KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ResourceMapKey,
+ NULL);
+ Status = ZwOpenKey(&ChildKey2, KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &ObjectAttributes);
+ ExFreePool(KeyInformation);
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ while (TRUE)
+ {
+ Status = ZwEnumerateKey(ChildKey2,
+ ChildKeyIndex2,
+ KeyBasicInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ break;
+ else if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyInformationLength = RequiredLength;
+ KeyInformation = ExAllocatePool(PagedPool, KeyInformationLength);
+ if (!KeyInformation)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto cleanup;
+ }
+
+ Status = ZwEnumerateKey(ChildKey2,
+ ChildKeyIndex2,
+ KeyBasicInformation,
+ KeyInformation,
+ KeyInformationLength,
+ &RequiredLength);
+ }
+ else
+ goto cleanup;
+ ChildKeyIndex2++;
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ KeyName.Buffer = KeyInformation->Name;
+ KeyName.MaximumLength = KeyName.Length = KeyInformation->NameLength;
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ChildKey2,
+ NULL);
+ Status = ZwOpenKey(&ChildKey3, KEY_QUERY_VALUE, &ObjectAttributes);
+ ExFreePool(KeyInformation);
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ while (TRUE)
+ {
+ Status = ZwEnumerateValueKey(ChildKey3,
+ ChildKeyIndex3,
+ KeyValuePartialInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ break;
+ else if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyValueInformationLength = RequiredLength;
+ KeyValueInformation = ExAllocatePool(PagedPool, KeyValueInformationLength);
+ if (!KeyValueInformation)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto cleanup;
+ }
+
+ Status = ZwEnumerateValueKey(ChildKey3,
+ ChildKeyIndex3,
+ KeyValuePartialInformation,
+ KeyValueInformation,
+ KeyValueInformationLength,
+ &RequiredLength);
+ }
+ else
+ goto cleanup;
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ Status = ZwEnumerateValueKey(ChildKey3,
+ ChildKeyIndex3,
+ KeyValueBasicInformation,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_BUFFER_TOO_SMALL)
+ {
+ KeyNameInformationLength = RequiredLength;
+ KeyNameInformation = ExAllocatePool(PagedPool, KeyNameInformationLength + sizeof(WCHAR));
+ if (!KeyNameInformation)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto cleanup;
+ }
-static NTSTATUS
+ Status = ZwEnumerateValueKey(ChildKey3,
+ ChildKeyIndex3,
+ KeyValueBasicInformation,
+ KeyNameInformation,
+ KeyNameInformationLength,
+ &RequiredLength);
+ }
+ else
+ goto cleanup;
+
+ ChildKeyIndex3++;
+
+ if (!NT_SUCCESS(Status))
+ goto cleanup;
+
+ KeyNameInformation->Name[KeyNameInformation->NameLength / sizeof(WCHAR)] = UNICODE_NULL;
+
+ /* Skip translated entries */
+ if (wcsstr(KeyNameInformation->Name, L".Translated"))
+ {
+ ExFreePool(KeyNameInformation);
+ continue;
+ }
+
+ ExFreePool(KeyNameInformation);
+
+ if (IopCheckForResourceConflict(ResourceList,
+ (PCM_RESOURCE_LIST)KeyValueInformation->Data))
+ {
+ ExFreePool(KeyValueInformation);
+ Status = STATUS_CONFLICTING_ADDRESSES;
+ goto cleanup;
+ }
+
+ ExFreePool(KeyValueInformation);
+ }
+ }
+ }
+
+cleanup:
+ if (ResourceMapKey != INVALID_HANDLE_VALUE)
+ ZwClose(ResourceMapKey);
+ if (ChildKey2 != INVALID_HANDLE_VALUE)
+ ZwClose(ChildKey2);
+ if (ChildKey3 != INVALID_HANDLE_VALUE)
+ ZwClose(ChildKey3);
+
+ if (Status == STATUS_NO_MORE_ENTRIES)
+ Status = STATUS_SUCCESS;
+
+ return Status;
+}
+
+NTSTATUS
IopAssignDeviceResources(
IN PDEVICE_NODE DeviceNode,
OUT ULONG *pRequiredSize)
}
RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, Size);
+ Status = IopDetectResourceConflict(DeviceNode->ResourceList);
+ if (!NT_SUCCESS(Status))
+ goto ByeBye;
+
*pRequiredSize = Size;
return STATUS_SUCCESS;
}
DeviceNode->ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
+ Status = IopDetectResourceConflict(DeviceNode->ResourceList);
+ if (!NT_SUCCESS(Status))
+ goto ByeBye;
+
*pRequiredSize = Size;
return STATUS_SUCCESS;
}
-static NTSTATUS
+NTSTATUS
IopTranslateDeviceResources(
IN PDEVICE_NODE DeviceNode,
IN ULONG RequiredSize)
const UNICODE_STRING IdentifierPci = RTL_CONSTANT_STRING(L"PCI");
UNICODE_STRING HardwareIdPci = RTL_CONSTANT_STRING(L"*PNP0A03\0");
static ULONG DeviceIndexPci = 0;
-#ifdef ENABLE_ACPI
- const UNICODE_STRING IdentifierAcpi = RTL_CONSTANT_STRING(L"ACPI BIOS");
- UNICODE_STRING HardwareIdAcpi = RTL_CONSTANT_STRING(L"*PNP0C08\0");
- static ULONG DeviceIndexAcpi = 0;
-#endif
const UNICODE_STRING IdentifierSerial = RTL_CONSTANT_STRING(L"SerialController");
UNICODE_STRING HardwareIdSerial = RTL_CONSTANT_STRING(L"*PNP0501\0");
static ULONG DeviceIndexSerial = 0;
const UNICODE_STRING IdentifierMouse = RTL_CONSTANT_STRING(L"PointerController");
UNICODE_STRING HardwareIdMouse = RTL_CONSTANT_STRING(L"*PNP0F13\0");
static ULONG DeviceIndexMouse = 0;
+ const UNICODE_STRING IdentifierParallel = RTL_CONSTANT_STRING(L"ParallelController");
+ UNICODE_STRING HardwareIdParallel = RTL_CONSTANT_STRING(L"*PNP0400\0");
+ static ULONG DeviceIndexParallel = 0;
+ const UNICODE_STRING IdentifierFloppy = RTL_CONSTANT_STRING(L"FloppyDiskPeripheral");
+ UNICODE_STRING HardwareIdFloppy = RTL_CONSTANT_STRING(L"*PNP0700\0");
+ static ULONG DeviceIndexFloppy = 0;
+ const UNICODE_STRING IdentifierIsa = RTL_CONSTANT_STRING(L"ISA");
+ UNICODE_STRING HardwareIdIsa = RTL_CONSTANT_STRING(L"*PNP0A00\0");
+ static ULONG DeviceIndexIsa = 0;
UNICODE_STRING HardwareIdKey;
PUNICODE_STRING pHardwareId;
ULONG DeviceIndex = 0;
+ BOOLEAN IsDeviceDesc;
if (RelativePath)
{
{
pHardwareId = &HardwareIdSerial;
DeviceIndex = DeviceIndexSerial++;
+ IsDeviceDesc = TRUE;
}
else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierKeyboard, FALSE) == 0)
{
pHardwareId = &HardwareIdKeyboard;
DeviceIndex = DeviceIndexKeyboard++;
+ IsDeviceDesc = FALSE;
}
else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierMouse, FALSE) == 0)
{
pHardwareId = &HardwareIdMouse;
DeviceIndex = DeviceIndexMouse++;
+ IsDeviceDesc = FALSE;
+ }
+ else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierParallel, FALSE) == 0)
+ {
+ pHardwareId = &HardwareIdParallel;
+ DeviceIndex = DeviceIndexParallel++;
+ IsDeviceDesc = FALSE;
+ }
+ else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierFloppy, FALSE) == 0)
+ {
+ pHardwareId = &HardwareIdFloppy;
+ DeviceIndex = DeviceIndexFloppy++;
+ IsDeviceDesc = FALSE;
}
else if (NT_SUCCESS(Status))
{
{
pHardwareId = &HardwareIdPci;
DeviceIndex = DeviceIndexPci++;
+ IsDeviceDesc = FALSE;
}
-#ifdef ENABLE_ACPI
- else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0)
+ else if (RtlCompareUnicodeString(&ValueName, &IdentifierIsa, FALSE) == 0)
{
- pHardwareId = &HardwareIdAcpi;
- DeviceIndex = DeviceIndexAcpi++;
+ pHardwareId = &HardwareIdIsa;
+ DeviceIndex = DeviceIndexIsa++;
+ IsDeviceDesc = FALSE;
}
-#endif
else
{
- /* Unknown device */
DPRINT("Unknown device '%wZ'\n", &ValueName);
goto nextdevice;
}
goto nextdevice;
}
DPRINT("Found %wZ #%lu (%wZ)\n", &ValueName, DeviceIndex, &HardwareIdKey);
- Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength);
- if (!NT_SUCCESS(Status))
+ if (IsDeviceDesc)
{
- DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
- ZwDeleteKey(hLevel2Key);
- goto nextdevice;
+ Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status);
+ ZwDeleteKey(hLevel2Key);
+ goto nextdevice;
+ }
}
Status = ZwSetValueKey(hLevel2Key, &HardwareIDU, 0, REG_MULTI_SZ, pHardwareId->Buffer, pHardwareId->MaximumLength);
if (!NT_SUCCESS(Status))
NTSTATUS Status;
BOOLEAN ret = FALSE;
- InitializeObjectAttributes(&ObjectAttributes, &MultiKeyPathU, OBJ_KERNEL_HANDLE, NULL, NULL);
+ InitializeObjectAttributes(&ObjectAttributes, &MultiKeyPathU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwOpenKey(&hDevicesKey, KEY_ENUMERATE_SUB_KEYS, &ObjectAttributes);
if (!NT_SUCCESS(Status))
{
if (IopIsAcpiComputer())
{
InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hRoot, NULL);
- Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL);
+ Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL);
ZwClose(hRoot);
if (!NT_SUCCESS(Status))
return Status;
InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL);
- Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL);
+ Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL);
ZwClose(hHalAcpiDevice);
if (!NT_SUCCESS(Status))
return Status;
/* PUBLIC FUNCTIONS **********************************************************/
/*
- * @unimplemented
+ * @implemented
*/
NTSTATUS
NTAPI
PVOID Data = NULL;
PWSTR Ptr;
NTSTATUS Status;
+ POBJECT_NAME_INFORMATION ObjectNameInfo = NULL;
+ ULONG RequiredLength, ObjectNameInfoLength;
DPRINT("IoGetDeviceProperty(0x%p %d)\n", DeviceObject, DeviceProperty);
break;
case DevicePropertyPhysicalDeviceObjectName:
- /* InstancePath buffer is NULL terminated, so we can do this */
- Length = DeviceNode->InstancePath.MaximumLength;
- Data = DeviceNode->InstancePath.Buffer;
+ Status = ObQueryNameString(DeviceNode->PhysicalDeviceObject,
+ NULL,
+ 0,
+ &RequiredLength);
+ if (Status == STATUS_SUCCESS)
+ {
+ Length = 0;
+ Data = L"";
+ }
+ else if (Status == STATUS_INFO_LENGTH_MISMATCH)
+ {
+ ObjectNameInfoLength = RequiredLength;
+ ObjectNameInfo = ExAllocatePool(PagedPool, ObjectNameInfoLength);
+ if (!ObjectNameInfo)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Status = ObQueryNameString(DeviceNode->PhysicalDeviceObject,
+ ObjectNameInfo,
+ ObjectNameInfoLength,
+ &RequiredLength);
+ if (NT_SUCCESS(Status))
+ {
+ Length = ObjectNameInfo->Name.Length;
+ Data = ObjectNameInfo->Name.Buffer;
+ }
+ else
+ return Status;
+ }
+ else
+ return Status;
break;
default:
/* Prepare returned values */
*ResultLength = Length;
if (BufferLength < Length)
+ {
+ if (ObjectNameInfo != NULL)
+ ExFreePool(ObjectNameInfo);
+
return STATUS_BUFFER_TOO_SMALL;
+ }
RtlCopyMemory(PropertyBuffer, Data, Length);
/* NULL terminate the string (if required) */
- if (DeviceProperty == DevicePropertyEnumeratorName)
+ if (DeviceProperty == DevicePropertyEnumeratorName ||
+ DeviceProperty == DevicePropertyPhysicalDeviceObjectName)
((LPWSTR)PropertyBuffer)[Length / sizeof(WCHAR)] = UNICODE_NULL;
+ if (ObjectNameInfo != NULL)
+ ExFreePool(ObjectNameInfo);
+
return STATUS_SUCCESS;
}
* COPYRIGHT: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/io/pnpmgr/pnpreport.c
* PURPOSE: Device Changes Reporting Functions
- * PROGRAMMERS: Filip Navara (xnavara@volny.cz)
+ * PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
*/
/* INCLUDES ******************************************************************/
#define NDEBUG
#include <debug.h>
+NTSTATUS
+NTAPI
+IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
+ OUT PHANDLE Handle);
+
+NTSTATUS
+IopAssignDeviceResources(
+ IN PDEVICE_NODE DeviceNode,
+ OUT ULONG *pRequiredSize);
+
+NTSTATUS
+IopSetDeviceInstanceData(HANDLE InstanceKey,
+ PDEVICE_NODE DeviceNode);
+
+NTSTATUS
+IopTranslateDeviceResources(
+ IN PDEVICE_NODE DeviceNode,
+ IN ULONG RequiredSize);
+
+NTSTATUS
+IopActionInterrogateDeviceStack(PDEVICE_NODE DeviceNode,
+ PVOID Context);
+
+NTSTATUS
+IopUpdateResourceMapForPnPDevice(
+ IN PDEVICE_NODE DeviceNode);
+
+NTSTATUS
+IopDetectResourceConflict(
+ IN PCM_RESOURCE_LIST ResourceList);
+
+/* PRIVATE FUNCTIONS *********************************************************/
+
+PWCHAR
+IopGetInterfaceTypeString(INTERFACE_TYPE IfType)
+{
+ switch (IfType)
+ {
+ case Internal:
+ return L"Internal";
+
+ case Isa:
+ return L"Isa";
+
+ case Eisa:
+ return L"Eisa";
+
+ case MicroChannel:
+ return L"MicroChannel";
+
+ case TurboChannel:
+ return L"TurboChannel";
+
+ case PCIBus:
+ return L"PCIBus";
+
+ case VMEBus:
+ return L"VMEBus";
+
+ case NuBus:
+ return L"NuBus";
+
+ case PCMCIABus:
+ return L"PCMCIABus";
+
+ case CBus:
+ return L"CBus";
+
+ case MPIBus:
+ return L"MPIBus";
+
+ case MPSABus:
+ return L"MPSABus";
+
+ case ProcessorInternal:
+ return L"ProcessorInternal";
+
+ case PNPISABus:
+ return L"PNPISABus";
+
+ case PNPBus:
+ return L"PNPBus";
+
+ case Vmcs:
+ return L"Vmcs";
+
+ default:
+ DPRINT1("Invalid bus type: %d\n", IfType);
+ return NULL;
+ }
+}
+
/* PUBLIC FUNCTIONS **********************************************************/
/*
{
PDEVICE_NODE DeviceNode;
PDEVICE_OBJECT Pdo;
- NTSTATUS Status = STATUS_SUCCESS;
+ NTSTATUS Status;
+ HANDLE InstanceKey;
+ ULONG RequiredLength;
+ UNICODE_STRING ValueName, ServiceName;
+ WCHAR HardwareId[256];
+ PWCHAR IfString;
+ ULONG IdLength;
- DPRINT("__FUNCTION__ (DeviceObject %p, *DeviceObject %p)\n",
+ DPRINT("IoReportDetectedDevice (DeviceObject %p, *DeviceObject %p)\n",
DeviceObject, DeviceObject ? *DeviceObject : NULL);
- /* if *DeviceObject is not NULL, we must use it as a PDO, and don't create a new one */
+ /* Create the service name (eg. ACPI_HAL) */
+ ServiceName.Buffer = DriverObject->DriverName.Buffer +
+ sizeof(DRIVER_ROOT_NAME) / sizeof(WCHAR) - 1;
+ ServiceName.Length = DriverObject->DriverName.Length -
+ sizeof(DRIVER_ROOT_NAME) + sizeof(WCHAR);
+ ServiceName.MaximumLength = ServiceName.Length;
+
+ /* If the interface type is unknown, treat it as internal */
+ if (LegacyBusType == InterfaceTypeUndefined)
+ LegacyBusType = Internal;
+
+ /* Get the string equivalent of the interface type */
+ IfString = IopGetInterfaceTypeString(LegacyBusType);
+
+ /* If NULL is returned then it's a bad type */
+ if (!IfString)
+ return STATUS_INVALID_PARAMETER;
+
+ /* We use the caller's PDO if they supplied one */
if (DeviceObject && *DeviceObject)
{
Pdo = *DeviceObject;
+ DeviceNode = IopGetDeviceNode(*DeviceObject);
}
else
{
- UNICODE_STRING ServiceName;
- ServiceName.Buffer = DriverObject->DriverName.Buffer +
- sizeof(DRIVER_ROOT_NAME) / sizeof(WCHAR) - 1;
- ServiceName.Length = DriverObject->DriverName.Length -
- sizeof(DRIVER_ROOT_NAME) + sizeof(WCHAR);
- ServiceName.MaximumLength = ServiceName.Length;
-
- /* create a new PDO and return it in *DeviceObject */
+ /* Create the PDO */
+ Status = PnpRootCreateDevice(&ServiceName,
+ &Pdo,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
+
+ /* Create the device node for the new PDO */
Status = IopCreateDeviceNode(IopRootDeviceNode,
+ Pdo,
NULL,
- &ServiceName,
&DeviceNode);
if (!NT_SUCCESS(Status))
DPRINT("IopCreateDeviceNode() failed (Status 0x%08lx)\n", Status);
return Status;
}
+ }
- Pdo = DeviceNode->PhysicalDeviceObject;
- if (DeviceObject) *DeviceObject = Pdo;
- }
+ /* We don't call AddDevice for devices reported this way */
+ IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
- /* we don't need to call AddDevice and send IRP_MN_START_DEVICE */
- return Status;
+ /* We don't send IRP_MN_START_DEVICE */
+ IopDeviceNodeSetFlag(DeviceNode, DNF_STARTED);
+
+ /* This is a legacy driver for this device */
+ IopDeviceNodeSetFlag(DeviceNode, DNF_LEGACY_DRIVER);
+
+ /* Perform a manual configuration of our device */
+ IopActionInterrogateDeviceStack(DeviceNode, DeviceNode->Parent);
+ IopActionConfigureChildServices(DeviceNode, DeviceNode->Parent);
+
+ /* Open a handle to the instance path key */
+ Status = IopCreateDeviceKeyPath(&DeviceNode->InstancePath, &InstanceKey);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Add DETECTEDInterfaceType\DriverName */
+ IdLength = 0;
+ IdLength += swprintf(&HardwareId[IdLength],
+ L"DETECTED%ls\\%wZ",
+ IfString,
+ &ServiceName);
+ HardwareId[IdLength++] = UNICODE_NULL;
+
+ /* Add DETECTED\DriverName */
+ IdLength += swprintf(&HardwareId[IdLength],
+ L"DETECTED\\%wZ",
+ &ServiceName);
+ HardwareId[IdLength++] = UNICODE_NULL;
+
+ /* Terminate the string with another null */
+ HardwareId[IdLength] = UNICODE_NULL;
+
+ /* Store the value for CompatibleIDs */
+ RtlInitUnicodeString(&ValueName, L"CompatibleIDs");
+ Status = ZwSetValueKey(InstanceKey, &ValueName, 0, REG_MULTI_SZ, HardwareId, IdLength * sizeof(WCHAR));
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Failed to write the compatible IDs: 0x%x\n", Status);
+ ZwClose(InstanceKey);
+ return Status;
+ }
+
+ /* Add a hardware ID if the driver didn't report one */
+ RtlInitUnicodeString(&ValueName, L"HardwareID");
+ if (ZwQueryValueKey(InstanceKey, &ValueName, KeyValueBasicInformation, NULL, 0, &RequiredLength) == STATUS_OBJECT_NAME_NOT_FOUND)
+ {
+ /* Just use our most specific compatible ID */
+ IdLength = 0;
+ IdLength += swprintf(&HardwareId[IdLength],
+ L"DETECTED%ls\\%wZ",
+ IfString,
+ &ServiceName);
+ HardwareId[++IdLength] = UNICODE_NULL;
+
+ /* Write the value to the registry */
+ Status = ZwSetValueKey(InstanceKey, &ValueName, 0, REG_SZ, HardwareId, IdLength * sizeof(WCHAR));
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Failed to write the hardware ID: 0x%x\n", Status);
+ ZwClose(InstanceKey);
+ return Status;
+ }
+ }
+
+ /* Assign the resources to the device node */
+ DeviceNode->BootResources = ResourceList;
+ DeviceNode->ResourceRequirements = ResourceRequirements;
+
+ /* Set appropriate flags */
+ if (DeviceNode->BootResources)
+ IopDeviceNodeSetFlag(DeviceNode, DNF_HAS_BOOT_CONFIG);
+
+ if (DeviceNode->ResourceRequirements)
+ IopDeviceNodeSetFlag(DeviceNode, DNF_RESOURCE_REPORTED);
+ else
+ IopDeviceNodeSetFlag(DeviceNode, DNF_NO_RESOURCE_REQUIRED);
+
+ /* Write the resource information to the registry */
+ IopSetDeviceInstanceData(InstanceKey, DeviceNode);
+
+ /* Close the instance key handle */
+ ZwClose(InstanceKey);
+
+ /* If the caller didn't get the resources assigned for us, do it now */
+ if (!ResourceAssigned)
+ {
+ IopDeviceNodeSetFlag(DeviceNode, DNF_ASSIGNING_RESOURCES);
+ Status = IopAssignDeviceResources(DeviceNode, &RequiredLength);
+ if (NT_SUCCESS(Status))
+ {
+ Status = IopTranslateDeviceResources(DeviceNode, RequiredLength);
+ if (NT_SUCCESS(Status))
+ Status = IopUpdateResourceMapForPnPDevice(DeviceNode);
+ }
+ IopDeviceNodeClearFlag(DeviceNode, DNF_ASSIGNING_RESOURCES);
+
+ /* See if we failed */
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Assigning resources failed: 0x%x\n", Status);
+ return Status;
+ }
+ }
+
+ /* Report the device's enumeration to umpnpmgr */
+ IopQueueTargetDeviceEvent(&GUID_DEVICE_ENUMERATED,
+ &DeviceNode->InstancePath);
+
+ /* Report the device's arrival to umpnpmgr */
+ IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL,
+ &DeviceNode->InstancePath);
+
+ DPRINT1("Reported device: %S (%wZ)\n", HardwareId, &DeviceNode->InstancePath);
+
+ /* Return the PDO */
+ if (DeviceObject) *DeviceObject = Pdo;
+
+ return STATUS_SUCCESS;
}
/*
- * @unimplemented
+ * @halfplemented
*/
NTSTATUS
NTAPI
IN ULONG DeviceListSize OPTIONAL,
OUT PBOOLEAN ConflictDetected)
{
- static int warned = 0;
- if (!warned)
- {
- DPRINT1("IoReportResourceForDetection partly implemented\n");
- warned = 1;
- }
+ PCM_RESOURCE_LIST ResourceList;
+ NTSTATUS Status;
*ConflictDetected = FALSE;
- if (PopSystemPowerDeviceNode && DriverListSize > 0)
+ if (!DriverList && !DeviceList)
+ return STATUS_INVALID_PARAMETER;
+
+ /* Find the real list */
+ if (!DriverList)
+ ResourceList = DeviceList;
+ else
+ ResourceList = DriverList;
+
+ /* Look for a resource conflict */
+ Status = IopDetectResourceConflict(ResourceList);
+ if (Status == STATUS_CONFLICTING_ADDRESSES)
{
- /* We hope legacy devices will be enumerated by ACPI */
+ /* Oh noes */
*ConflictDetected = TRUE;
- return STATUS_CONFLICTING_ADDRESSES;
}
+ else if (NT_SUCCESS(Status))
+ {
+ /* Looks like we're good to go */
- return STATUS_SUCCESS;
+ /* TODO: Claim the resources in the ResourceMap */
+ }
+
+ return Status;
}
VOID
NTSTATUS
PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName,
- IN PDEVICE_OBJECT *PhysicalDeviceObject)
+ OUT PDEVICE_OBJECT *PhysicalDeviceObject,
+ OUT OPTIONAL PUNICODE_STRING FullInstancePath)
{
PPNPROOT_FDO_DEVICE_EXTENSION DeviceExtension;
- UNICODE_STRING UnknownServiceName = RTL_CONSTANT_STRING(L"UNKNOWN");
- PUNICODE_STRING LocalServiceName;
PPNPROOT_PDO_DEVICE_EXTENSION PdoDeviceExtension;
WCHAR DevicePath[MAX_PATH + 1];
WCHAR InstancePath[5];
PPNPROOT_DEVICE Device = NULL;
NTSTATUS Status;
ULONG i;
+ UNICODE_STRING PathSep = RTL_CONSTANT_STRING(L"\\");
DeviceExtension = PnpRootDeviceObject->DeviceExtension;
KeAcquireGuardedMutex(&DeviceExtension->DeviceListLock);
- if (ServiceName)
- LocalServiceName = ServiceName;
- else
- LocalServiceName = &UnknownServiceName;
-
- DPRINT("Creating a PnP root device for service '%wZ'\n", LocalServiceName);
+ DPRINT("Creating a PnP root device for service '%wZ'\n", ServiceName);
/* Search for a free instance ID */
- _snwprintf(DevicePath, sizeof(DevicePath) / sizeof(WCHAR), L"%s\\LEGACY_%wZ", REGSTR_KEY_ROOTENUM, LocalServiceName);
+ _snwprintf(DevicePath, sizeof(DevicePath) / sizeof(WCHAR), L"%s\\%wZ", REGSTR_KEY_ROOTENUM, ServiceName);
for (i = 0; i < 9999; i++)
{
_snwprintf(InstancePath, sizeof(InstancePath) / sizeof(WCHAR), L"%04lu", i);
}
if (i == 9999)
{
- DPRINT1("Too much legacy devices reported for service '%wZ'\n", &LocalServiceName);
+ DPRINT1("Too much legacy devices reported for service '%wZ'\n", ServiceName);
Status = STATUS_INSUFFICIENT_RESOURCES;
goto cleanup;
}
goto cleanup;
}
+ if (FullInstancePath)
+ {
+ FullInstancePath->MaximumLength = Device->DeviceID.Length + PathSep.Length + Device->InstanceID.Length;
+ FullInstancePath->Length = 0;
+ FullInstancePath->Buffer = ExAllocatePool(PagedPool, FullInstancePath->MaximumLength);
+ if (!FullInstancePath->Buffer)
+ {
+ Status = STATUS_NO_MEMORY;
+ goto cleanup;
+ }
+
+ RtlAppendUnicodeStringToString(FullInstancePath, &Device->DeviceID);
+ RtlAppendUnicodeStringToString(FullInstancePath, &PathSep);
+ RtlAppendUnicodeStringToString(FullInstancePath, &Device->InstanceID);
+ }
+
/* Initialize a device object */
Status = IoCreateDevice(
PnpRootDeviceObject->DriverObject,
<file>cmdelay.c</file>
<file>cmindex.c</file>
<file>cminit.c</file>
+ <file>cmhvlist.c</file>
<file>cmhook.c</file>
<file>cmkcbncb.c</file>
<file>cmkeydel.c</file>
<file>cmlazy.c</file>
<file>cmmapvw.c</file>
<file>cmname.c</file>
+ <file>cmnotify.c</file>
<file>cmparse.c</file>
+ <file>cmquota.c</file>
<file>cmse.c</file>
<file>cmsecach.c</file>
<file>cmsysini.c</file>
#include <msvctarget.h>
+#undef i386
@ stdcall CcCanIWrite(ptr long long long)
@ stdcall CcCopyRead(ptr ptr long long ptr ptr)
@ stdcall DbgPrompt(str ptr long)
@ stdcall DbgQueryDebugFilterState(long long)
@ stdcall DbgSetDebugFilterState(long long long)
+@ stdcall -arch=x86_64 ExAcquireFastMutex(ptr)
@ fastcall ExAcquireFastMutexUnsafe(ptr)
@ stdcall ExAcquireResourceExclusiveLite(ptr long)
@ stdcall ExAcquireResourceSharedLite(ptr long)
@ stdcall ExInitializeRundownProtectionCacheAware(ptr long)
@ stdcall ExInitializeZone(ptr long ptr long)
@ stdcall ExInterlockedAddLargeInteger(ptr long long ptr)
+#ifndef __x86_64__
@ fastcall ExInterlockedAddLargeStatistic(ptr long)
+#endif
@ stdcall ExInterlockedAddUlong(ptr long ptr)
+#ifndef __x86_64__
@ fastcall ExInterlockedCompareExchange64(ptr ptr ptr ptr)
@ stdcall ExInterlockedDecrementLong(ptr ptr)
@ stdcall ExInterlockedExchangeUlong(ptr long ptr)
+#endif
@ stdcall ExInterlockedExtendZone(ptr ptr long ptr)
+#ifndef __x86_64__
@ fastcall ExInterlockedFlushSList(ptr)
@ stdcall ExInterlockedIncrementLong(ptr ptr)
+#endif
@ stdcall ExInterlockedInsertHeadList(ptr ptr ptr)
@ stdcall ExInterlockedInsertTailList(ptr ptr ptr)
@ stdcall ExInterlockedPopEntryList(ptr ptr)
+#ifndef __x86_64__
@ fastcall ExInterlockedPopEntrySList(ptr ptr)
+#endif
@ stdcall ExInterlockedPushEntryList(ptr ptr ptr)
+#ifndef __x86_64__
@ fastcall ExInterlockedPushEntrySList(ptr ptr ptr)
+#endif
@ stdcall ExInterlockedRemoveHeadList(ptr ptr)
@ stdcall ExIsProcessorFeaturePresent(long)
@ stdcall ExIsResourceAcquiredExclusiveLite(ptr)
@ stdcall ExIsResourceAcquiredSharedLite(ptr)
@ stdcall ExLocalTimeToSystemTime(ptr ptr)
@ stdcall ExNotifyCallback(ptr ptr ptr)
+@ stdcall -arch=x86_64 ExQueryDepthSList(ptr)
@ stdcall ExQueryPoolBlockSize(ptr ptr)
@ stdcall ExQueueWorkItem(ptr long)
@ stdcall ExRaiseAccessViolation()
@ fastcall ExReInitializeRundownProtectionCacheAware(ptr) ExfReInitializeRundownProtectionCacheAware
@ stdcall ExRegisterCallback(ptr ptr ptr)
@ stdcall ExReinitializeResourceLite(ptr)
+@ stdcall -arch=x86_64 ExReleaseFastMutex(ptr)
@ fastcall ExReleaseFastMutexUnsafe(ptr)
@ fastcall ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(ptr)
@ fastcall ExReleaseResourceAndLeaveCriticalRegion(ptr)
@ stdcall ExSizeOfRundownProtectionCacheAware()
@ stdcall ExSystemExceptionFilter()
@ stdcall ExSystemTimeToLocalTime(ptr ptr)
+@ stdcall -arch=x86_64 ExTryToAcquireFastMutex(ptr)
@ stdcall ExUnregisterCallback(ptr)
@ stdcall ExUuidCreate(ptr)
@ stdcall ExVerifySuite(long)
@ extern ExWindowStationObjectType
@ fastcall ExfAcquirePushLockExclusive(ptr)
@ fastcall ExfAcquirePushLockShared(ptr)
+#ifndef __x86_64__
@ fastcall ExfInterlockedAddUlong(ptr long ptr)
@ fastcall ExfInterlockedCompareExchange64(ptr ptr ptr)
@ fastcall ExfInterlockedInsertHeadList(ptr ptr ptr)
@ fastcall ExfInterlockedPopEntryList(ptr ptr)
@ fastcall ExfInterlockedPushEntryList(ptr ptr ptr)
@ fastcall ExfInterlockedRemoveHeadList(ptr ptr)
+#endif
@ fastcall ExfReleasePushLock(ptr)
@ fastcall ExfReleasePushLockExclusive(ptr)
@ fastcall ExfReleasePushLockShared(ptr)
@ fastcall ExfTryToWakePushLock(ptr)
@ fastcall ExfUnblockPushLock(ptr ptr)
-#ifdef _M_IX86
-@ fastcall Exfi386InterlockedDecrementLong(ptr)
-@ fastcall Exfi386InterlockedExchangeUlong(ptr long)
-@ fastcall Exfi386InterlockedIncrementLong(ptr)
-@ stdcall Exi386InterlockedDecrementLong(ptr)
-@ stdcall Exi386InterlockedExchangeUlong(ptr long long)
-@ stdcall Exi386InterlockedIncrementLong(ptr)
-#endif
-@ fastcall ExiAcquireFastMutex(ptr) ExAcquireFastMutex
-@ fastcall ExiReleaseFastMutex(ptr) ExReleaseFastMutex
-@ fastcall ExiTryToAcquireFastMutex(ptr) ExTryToAcquireFastMutex
+@ stdcall -arch=x86_64 ExpInterlockedFlushSList(ptr)
+@ stdcall -arch=x86_64 ExpInterlockedPopEntrySList(ptr ptr)
+@ stdcall -arch=x86_64 ExpInterlockedPushEntrySList(ptr ptr)
+@ fastcall -arch=i386 Exfi386InterlockedDecrementLong(ptr)
+@ fastcall -arch=i386 Exfi386InterlockedExchangeUlong(ptr long)
+@ fastcall -arch=i386 Exfi386InterlockedIncrementLong(ptr)
+@ stdcall -arch=i386 Exi386InterlockedDecrementLong(ptr)
+@ stdcall -arch=i386 Exi386InterlockedExchangeUlong(ptr long long)
+@ stdcall -arch=i386 Exi386InterlockedIncrementLong(ptr)
+@ fastcall -arch=i386 ExiAcquireFastMutex(ptr) ExAcquireFastMutex
+@ fastcall -arch=i386 ExiReleaseFastMutex(ptr) ExReleaseFastMutex
+@ fastcall -arch=i386 ExiTryToAcquireFastMutex(ptr) ExTryToAcquireFastMutex
@ stdcall FsRtlAcquireFileExclusive(ptr)
;FsRtlAddBaseMcbEntry
@ stdcall FsRtlAddLargeMcbEntry(ptr long long long long long long)
@ stdcall InbvSetTextColor(long)
@ stdcall InbvSolidColorFill(long long long long long)
@ extern InitSafeBootMode
+#ifndef __x86_64__
@ fastcall InterlockedCompareExchange(ptr long long)
@ fastcall InterlockedDecrement(ptr)
@ fastcall InterlockedExchange(ptr long)
@ fastcall InterlockedIncrement(ptr)
@ fastcall InterlockedPopEntrySList(ptr)
@ fastcall InterlockedPushEntrySList(ptr ptr)
+#else
+@ stdcall InitializeSListHead(ptr) RtlInitializeSListHead
+#endif
@ stdcall IoAcquireCancelSpinLock(ptr)
@ stdcall IoAcquireRemoveLockEx(ptr ptr str long long)
@ stdcall IoAcquireVpbSpinLock(ptr)
@ stdcall KdPowerTransition(long)
@ stdcall KdRefreshDebuggerNotPresent()
@ stdcall KdSystemDebugControl(long ptr long ptr long ptr long)
-#ifdef _M_IX86
-@ stdcall Ke386CallBios(long ptr)
-@ stdcall Ke386IoSetAccessProcess(ptr long)
-@ stdcall Ke386QueryIoAccessMap(long ptr)
-@ stdcall Ke386SetIoAccessMap(long ptr)
-#endif
+@ stdcall -arch=i386 Ke386CallBios(long ptr)
+@ stdcall -arch=i386 Ke386IoSetAccessProcess(ptr long)
+@ stdcall -arch=i386 Ke386QueryIoAccessMap(long ptr)
+@ stdcall -arch=i386 Ke386SetIoAccessMap(long ptr)
@ fastcall KeAcquireGuardedMutex(ptr)
@ fastcall KeAcquireGuardedMutexUnsafe(ptr)
@ fastcall KeAcquireInStackQueuedSpinLockAtDpcLevel(ptr ptr)
@ stdcall KeAcquireInterruptSpinLock(ptr)
@ stdcall KeAcquireSpinLockAtDpcLevel(ptr)
@ fastcall KeAcquireSpinLockForDpc(ptr)
+@ stdcall -arch=x86_64 KeAcquireSpinLockRaiseToDpc(ptr)
@ stdcall KeAddSystemServiceTable(ptr ptr long ptr long)
@ stdcall KeAreAllApcsDisabled()
@ stdcall KeAreApcsDisabled()
@ stdcall KeGetCurrentThread()
@ stdcall KeGetPreviousMode()
@ stdcall KeGetRecommendedSharedDataAlignment()
-#ifdef _M_IX86
;KeI386AbiosCall
-@ stdcall KeI386AllocateGdtSelectors(ptr long)
-;KeI386Call16BitCStyleFunction
-;KeI386Call16BitFunction
-@ stdcall KeI386FlatToGdtSelector(long long long)
-;KeI386GetLid
-@ extern KeI386MachineType
-@ stdcall KeI386ReleaseGdtSelectors(ptr long)
-;KeI386ReleaseLid
-;KeI386SetGdtSelector
-#endif
+@ stdcall -arch=i386 KeI386AllocateGdtSelectors(ptr long)
+; -arch=i386 KeI386Call16BitCStyleFunction
+; -arch=i386 KeI386Call16BitFunction
+@ stdcall -arch=i386 KeI386FlatToGdtSelector(long long long)
+; -arch=i386 KeI386GetLid
+@ extern -arch=i386 KeI386MachineType
+@ stdcall -arch=i386 KeI386ReleaseGdtSelectors(ptr long)
+; -arch=i386 KeI386ReleaseLid
+; -arch=i386 KeI386SetGdtSelector
@ stdcall KeInitializeApc(ptr ptr long ptr ptr ptr long ptr)
@ stdcall KeInitializeCrashDumpHeader(long long ptr long ptr)
@ stdcall KeInitializeDeviceQueue(ptr)
@ stdcall KeInitializeMutex(ptr long)
@ stdcall KeInitializeQueue(ptr long)
@ stdcall KeInitializeSemaphore(ptr long long)
+#ifndef __x86_64__
@ stdcall KeInitializeSpinLock(ptr) _KeInitializeSpinLock
+#endif
@ stdcall KeInitializeThreadedDpc(ptr ptr ptr)
@ stdcall KeInitializeTimer(ptr)
@ stdcall KeInitializeTimerEx(ptr long)
@ stdcall KeProfileInterruptWithSource(ptr long)
@ stdcall KePulseEvent(ptr long long)
@ stdcall KeQueryActiveProcessors()
+#ifndef __x86_64__
@ stdcall KeQueryInterruptTime()
+#endif
@ stdcall KeQueryPriorityThread(ptr)
@ stdcall KeQueryRuntimeThread(ptr ptr)
+#ifndef __x86_64__
@ stdcall KeQuerySystemTime(ptr)
+#endif
@ stdcall KeQueryTickCount(ptr)
@ stdcall KeQueryTimeIncrement()
@ stdcall KeRaiseUserException(long)
@ stdcall KeReleaseMutant(ptr long long long)
@ stdcall KeReleaseMutex(ptr long)
@ stdcall KeReleaseSemaphore(ptr long long long)
+#ifdef __x86_64__
+@ stdcall KeReleaseSpinLock(ptr long)
+#endif
@ fastcall KeReleaseSpinLockForDpc(ptr long)
@ stdcall KeReleaseSpinLockFromDpcLevel(ptr)
@ stdcall KeRemoveByKeyDeviceQueue(ptr long)
@ stdcall KeWaitForSingleObject(ptr long long long ptr)
@ fastcall KefAcquireSpinLockAtDpcLevel(ptr)
@ fastcall KefReleaseSpinLockFromDpcLevel(ptr)
-#ifdef _M_IX86
-@ stdcall Kei386EoiHelper()
-@ fastcall KiEoiHelper(ptr) /* FIXME: Evaluate decision */
-#endif
+@ stdcall -arch=i386 Kei386EoiHelper()
+@ fastcall -arch=i386 KiEoiHelper(ptr) /* FIXME: Evaluate decision */
@ fastcall KiAcquireSpinLock(ptr)
@ extern KiBugCheckData
@ stdcall KiCheckForKernelApcDelivery()
;KiCheckForSListAddress
-#ifdef _M_IX86
-@ stdcall KiCoprocessorError()
-#endif
+@ stdcall -arch=i386 KiCoprocessorError()
@ stdcall KiDeliverApc(long ptr ptr)
-#ifdef _M_IX86
-@ stdcall KiDispatchInterrupt()
-#endif
+@ stdcall -arch=i386 KiDispatchInterrupt()
@ extern KiEnableTimerWatchdog
@ stdcall KiIpiServiceRoutine(ptr ptr)
@ fastcall KiReleaseSpinLock(ptr)
@ stdcall PsTerminateSystemThread(long)
@ extern PsThreadType _PsThreadType
;PsWrapApcWow64Thread
+#ifndef __x86_64__
@ stdcall READ_REGISTER_BUFFER_UCHAR(ptr ptr long)
@ stdcall READ_REGISTER_BUFFER_ULONG(ptr ptr long)
@ stdcall READ_REGISTER_BUFFER_USHORT(ptr ptr long)
@ stdcall READ_REGISTER_UCHAR(ptr)
@ stdcall READ_REGISTER_ULONG(ptr)
@ stdcall READ_REGISTER_USHORT(ptr)
+#endif
@ stdcall RtlAbsoluteToSelfRelativeSD(ptr ptr ptr)
@ stdcall RtlAddAccessAllowedAce(ptr long long ptr)
@ stdcall RtlAddAccessAllowedAceEx(ptr long long long ptr)
;RtlTraceDatabaseLock
;RtlTraceDatabaseUnlock
;RtlTraceDatabaseValidate
+#ifndef __x86_64__
@ fastcall RtlUlongByteSwap(long)
@ fastcall RtlUlonglongByteSwap(long long)
+#endif
@ stdcall RtlUnicodeStringToAnsiSize(ptr) RtlxUnicodeStringToAnsiSize
@ stdcall RtlUnicodeStringToAnsiString(ptr ptr long)
@ stdcall RtlUnicodeStringToCountedOemString(ptr ptr long)
@ stdcall RtlUpcaseUnicodeToOemN(ptr long ptr wstr long)
@ stdcall RtlUpperChar(long)
@ stdcall RtlUpperString(ptr ptr)
+#ifndef __x86_64__
@ fastcall RtlUshortByteSwap(long)
+#endif
@ stdcall RtlValidRelativeSecurityDescriptor(ptr long long)
@ stdcall RtlValidSecurityDescriptor(ptr)
@ stdcall RtlValidSid(ptr)
;VfFailDriver
;VfFailSystemBIOS
;VfIsVerificationEnabled
+#ifndef __x86_64__
@ stdcall WRITE_REGISTER_BUFFER_UCHAR(ptr ptr long)
@ stdcall WRITE_REGISTER_BUFFER_ULONG(ptr ptr long)
@ stdcall WRITE_REGISTER_BUFFER_USHORT(ptr ptr long)
@ stdcall WRITE_REGISTER_UCHAR(ptr long)
@ stdcall WRITE_REGISTER_ULONG(ptr long)
@ stdcall WRITE_REGISTER_USHORT(ptr long)
+#endif
;WmiFlushTrace
;WmiGetClock
;WmiQueryTrace
;_CIcos
;_CIsin
;_CIsqrt
+#ifndef __x86_64
@ cdecl _abnormal_termination()
-#ifdef _M_IX86
-@ cdecl _alldiv()
-@ cdecl _alldvrm()
-@ cdecl _allmul()
-@ cdecl _alloca_probe()
-@ cdecl _allrem()
-@ cdecl _allshl()
-@ cdecl _allshr()
-@ cdecl _aulldiv()
-@ cdecl _aulldvrm()
-@ cdecl _aullrem()
-@ cdecl _aullshr()
#endif
+@ cdecl -arch=i386 _alldiv()
+@ cdecl -arch=i386 _alldvrm()
+@ cdecl -arch=i386 _allmul()
+@ cdecl -arch=i386 _alloca_probe()
+@ cdecl -arch=i386 _allrem()
+@ cdecl -arch=i386 _allshl()
+@ cdecl -arch=i386 _allshr()
+@ cdecl -arch=i386 _aulldiv()
+@ cdecl -arch=i386 _aulldvrm()
+@ cdecl -arch=i386 _aullrem()
+@ cdecl -arch=i386 _aullshr()
+#ifndef __x86_64
@ cdecl _except_handler2()
@ cdecl _except_handler3()
@ cdecl _global_unwind2()
+#endif
@ cdecl _itoa()
@ cdecl _itow()
+#ifndef __x86_64
@ cdecl _local_unwind2()
+#endif
@ cdecl _purecall()
@ cdecl _snprintf()
@ cdecl _snwprintf()
BOOLEAN NTAPI
SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext,
- IN BOOLEAN SubjectContextLocked,
IN ACCESS_MASK DesiredAccess,
IN ACCESS_MASK PreviouslyGrantedAccess,
OUT PPRIVILEGE_SET* Privileges,
IN PGENERIC_MAPPING GenericMapping,
IN KPROCESSOR_MODE AccessMode,
OUT PACCESS_MASK GrantedAccess,
- OUT PNTSTATUS AccessStatus,
- SECURITY_IMPERSONATION_LEVEL LowestImpersonationLevel)
+ OUT PNTSTATUS AccessStatus)
{
LUID_AND_ATTRIBUTES Privilege;
ACCESS_MASK CurrentAccess, AccessMask;
NTSTATUS Status;
PAGED_CODE();
- /* Check if this is kernel mode */
- if (AccessMode == KernelMode)
- {
- /* Check if kernel wants everything */
- if (DesiredAccess & MAXIMUM_ALLOWED)
- {
- /* Give it */
- *GrantedAccess = GenericMapping->GenericAll;
- *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED);
- *GrantedAccess |= PreviouslyGrantedAccess;
- }
- else
- {
- /* Give the desired and previous access */
- *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess;
- }
-
- /* Success */
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
-
- /* Check if we didn't get an SD */
- if (!SecurityDescriptor)
- {
- /* Automatic failure */
- *AccessStatus = STATUS_ACCESS_DENIED;
- return FALSE;
- }
-
- /* Check for invalid impersonation */
- if ((SubjectSecurityContext->ClientToken) &&
- (SubjectSecurityContext->ImpersonationLevel < LowestImpersonationLevel))
- {
- *AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL;
- return FALSE;
- }
-
/* Check for no access desired */
if (!DesiredAccess)
{
return TRUE;
}
- /* Acquire the lock if needed */
- if (!SubjectContextLocked) SeLockSubjectContext(SubjectSecurityContext);
-
/* Map given accesses */
RtlMapGenericMask(&DesiredAccess, GenericMapping);
if (PreviouslyGrantedAccess)
&Defaulted);
if (!NT_SUCCESS(Status))
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*AccessStatus = Status;
return FALSE;
}
/* RULE 1: Grant desired access if the object is unprotected */
- if (Present == TRUE && Dacl == NULL)
+ if (Present == FALSE || Dacl == NULL)
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
if (DesiredAccess & MAXIMUM_ALLOWED)
{
*GrantedAccess = GenericMapping->GenericAll;
if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
(CurrentAccess & ~VALID_INHERIT_FLAGS))
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*GrantedAccess = CurrentAccess;
*AccessStatus = STATUS_SUCCESS;
return TRUE;
}
}
+ /* Deny access if the DACL is empty */
+ if (Dacl->AceCount == 0)
+ {
+ *GrantedAccess = 0;
+ *AccessStatus = STATUS_ACCESS_DENIED;
+ return FALSE;
+ }
+
/* RULE 3: Check whether the token is the owner */
Status = RtlGetOwnerSecurityDescriptor(SecurityDescriptor,
&Sid,
if (!NT_SUCCESS(Status))
{
DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status);
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*AccessStatus = Status;
return FALSE;
}
if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
(CurrentAccess & ~VALID_INHERIT_FLAGS))
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*GrantedAccess = CurrentAccess;
*AccessStatus = STATUS_SUCCESS;
return TRUE;
/* Fail if DACL is absent */
if (Present == FALSE)
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*GrantedAccess = 0;
*AccessStatus = STATUS_ACCESS_DENIED;
return FALSE;
{
if (SepSidInToken(Token, Sid))
{
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
*GrantedAccess = 0;
*AccessStatus = STATUS_ACCESS_DENIED;
return FALSE;
CurrentAce = (PACE)((ULONG_PTR)CurrentAce + CurrentAce->Header.AceSize);
}
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
CurrentAccess, DesiredAccess);
}
}
+static PSID
+SepGetSDOwner(IN PSECURITY_DESCRIPTOR _SecurityDescriptor)
+{
+ PISECURITY_DESCRIPTOR SecurityDescriptor = _SecurityDescriptor;
+ PSID Owner;
+
+ if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
+ Owner = (PSID)((ULONG_PTR)SecurityDescriptor->Owner +
+ (ULONG_PTR)SecurityDescriptor);
+ else
+ Owner = (PSID)SecurityDescriptor->Owner;
+
+ return Owner;
+}
+
+static PSID
+SepGetSDGroup(IN PSECURITY_DESCRIPTOR _SecurityDescriptor)
+{
+ PISECURITY_DESCRIPTOR SecurityDescriptor = _SecurityDescriptor;
+ PSID Group;
+
+ if (SecurityDescriptor->Control & SE_SELF_RELATIVE)
+ Group = (PSID)((ULONG_PTR)SecurityDescriptor->Group +
+ (ULONG_PTR)SecurityDescriptor);
+ else
+ Group = (PSID)SecurityDescriptor->Group;
+
+ return Group;
+}
+
+
/* PUBLIC FUNCTIONS ***********************************************************/
/*
OUT PACCESS_MASK GrantedAccess,
OUT PNTSTATUS AccessStatus)
{
+ BOOLEAN ret;
+
+ PAGED_CODE();
+
+ /* Check if this is kernel mode */
+ if (AccessMode == KernelMode)
+ {
+ /* Check if kernel wants everything */
+ if (DesiredAccess & MAXIMUM_ALLOWED)
+ {
+ /* Give it */
+ *GrantedAccess = GenericMapping->GenericAll;
+ *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED);
+ *GrantedAccess |= PreviouslyGrantedAccess;
+ }
+ else
+ {
+ /* Give the desired and previous access */
+ *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess;
+ }
+
+ /* Success */
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+
+ /* Check if we didn't get an SD */
+ if (!SecurityDescriptor)
+ {
+ /* Automatic failure */
+ *AccessStatus = STATUS_ACCESS_DENIED;
+ return FALSE;
+ }
+
+ /* Check for invalid impersonation */
+ if ((SubjectSecurityContext->ClientToken) &&
+ (SubjectSecurityContext->ImpersonationLevel < SecurityImpersonation))
+ {
+ *AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL;
+ return FALSE;
+ }
+
+ /* Acquire the lock if needed */
+ if (!SubjectContextLocked)
+ SeLockSubjectContext(SubjectSecurityContext);
+
/* Call the internal function */
- return SepAccessCheck(SecurityDescriptor,
- SubjectSecurityContext,
- SubjectContextLocked,
- DesiredAccess,
- PreviouslyGrantedAccess,
- Privileges,
- GenericMapping,
- AccessMode,
- GrantedAccess,
- AccessStatus,
- SecurityImpersonation);
+ ret = SepAccessCheck(SecurityDescriptor,
+ SubjectSecurityContext,
+ DesiredAccess,
+ PreviouslyGrantedAccess,
+ Privileges,
+ GenericMapping,
+ AccessMode,
+ GrantedAccess,
+ AccessStatus);
+
+ /* Release the lock if needed */
+ if (!SubjectContextLocked)
+ SeUnlockSubjectContext(SubjectSecurityContext);
+
+ return ret;
}
/* SYSTEM CALLS ***************************************************************/
OUT PACCESS_MASK GrantedAccess,
OUT PNTSTATUS AccessStatus)
{
+ PSECURITY_DESCRIPTOR CapturedSecurityDescriptor = NULL;
SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PTOKEN Token;
NULL);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Failed to reference token (Status %lx)\n", Status);
+ DPRINT("Failed to reference token (Status %lx)\n", Status);
return Status;
}
/* Check token type */
if (Token->TokenType != TokenImpersonation)
{
- DPRINT1("No impersonation token\n");
+ DPRINT("No impersonation token\n");
ObDereferenceObject(Token);
return STATUS_NO_IMPERSONATION_TOKEN;
}
/* Check the impersonation level */
if (Token->ImpersonationLevel < SecurityIdentification)
{
- DPRINT1("Impersonation level < SecurityIdentification\n");
+ DPRINT("Impersonation level < SecurityIdentification\n");
ObDereferenceObject(Token);
return STATUS_BAD_IMPERSONATION_LEVEL;
}
+ /* Capture the security descriptor */
+ Status = SeCaptureSecurityDescriptor(SecurityDescriptor,
+ PreviousMode,
+ PagedPool,
+ FALSE,
+ &CapturedSecurityDescriptor);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("Failed to capture the Security Descriptor\n");
+ ObDereferenceObject(Token);
+ return Status;
+ }
+
+ /* Check the captured security descriptor */
+ if (CapturedSecurityDescriptor == NULL)
+ {
+ DPRINT("Security Descriptor is NULL\n");
+ ObDereferenceObject(Token);
+ return STATUS_INVALID_SECURITY_DESCR;
+ }
+
+ /* Check security descriptor for valid owner and group */
+ if (SepGetSDOwner(SecurityDescriptor) == NULL || // FIXME: use CapturedSecurityDescriptor
+ SepGetSDGroup(SecurityDescriptor) == NULL) // FIXME: use CapturedSecurityDescriptor
+ {
+ DPRINT("Security Descriptor does not have a valid group or owner\n");
+ SeReleaseSecurityDescriptor(CapturedSecurityDescriptor,
+ PreviousMode,
+ FALSE);
+ ObDereferenceObject(Token);
+ return STATUS_INVALID_SECURITY_DESCR;
+ }
+
/* Set up the subject context, and lock it */
SubjectSecurityContext.ClientToken = Token;
SubjectSecurityContext.ImpersonationLevel = Token->ImpersonationLevel;
SeLockSubjectContext(&SubjectSecurityContext);
/* Now perform the access check */
- SepAccessCheck(SecurityDescriptor,
+ SepAccessCheck(SecurityDescriptor, // FIXME: use CapturedSecurityDescriptor
&SubjectSecurityContext,
- TRUE,
DesiredAccess,
0,
&PrivilegeSet, //FIXME
GenericMapping,
PreviousMode,
GrantedAccess,
- AccessStatus,
- SecurityIdentification);
+ AccessStatus);
- /* Unlock subject context and dereference the token */
+ /* Unlock subject context */
SeUnlockSubjectContext(&SubjectSecurityContext);
+
+ /* Release the captured security descriptor */
+ SeReleaseSecurityDescriptor(CapturedSecurityDescriptor,
+ PreviousMode,
+ FALSE);
+
+ /* Dereference the token */
ObDereferenceObject(Token);
/* Check succeeded */
PTIMER FASTCALL FindSystemTimer(PMSG);
BOOL FASTCALL ValidateTimerCallback(PTHREADINFO,PWINDOW_OBJECT,WPARAM,LPARAM);
VOID CALLBACK SystemTimerProc(HWND,UINT,UINT_PTR,DWORD);
-UINT_PTR FASTCALL SetSystemTimer(PWINDOW_OBJECT,UINT_PTR,UINT,TIMERPROC);
+UINT_PTR FASTCALL SystemTimerSet(PWINDOW_OBJECT,UINT_PTR,UINT,TIMERPROC);
BOOL FASTCALL PostTimerMessages(PWINDOW_OBJECT);
VOID FASTCALL ProcessTimers(VOID);
VOID FASTCALL StartTheTimers(VOID);
#pragma once
-/* Undocumented flags. */
-#define SWP_NOCLIENTMOVE 0x0800
-#define SWP_NOCLIENTSIZE 0x1000
-
#define IntPtInWindow(WndObject,x,y) \
((x) >= (WndObject)->Wnd->rcWindow.left && \
(x) < (WndObject)->Wnd->rcWindow.right && \
UINT_PTR
FASTCALL
-SetSystemTimer( PWINDOW_OBJECT Window,
+SystemTimerSet( PWINDOW_OBJECT Window,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc)
Hit = TRUE;
}
}
+ else
+ {
+ if (!GreGetObjectOwner(pdce->hDC, GDIObjType_DC_TYPE))
+ DC_SetOwnership( pdce->hDC, PsGetCurrentProcess());
+ }
if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE);