diff --git a/ReactOS-amd64.rbuild b/ReactOS-amd64.rbuild
index 8b74473637f..6d9f8640d08 100644
--- a/ReactOS-amd64.rbuild
+++ b/ReactOS-amd64.rbuild
@@ -45,6 +45,7 @@
--unique=.eh_frame
-static
-fno-leading-underscore
+ -shared
--exclude-all-symbols
diff --git a/base/applications/network/ftp/fake.h b/base/applications/network/ftp/fake.h
index f622c401970..a22009886bd 100644
--- a/base/applications/network/ftp/fake.h
+++ b/base/applications/network/ftp/fake.h
@@ -9,9 +9,12 @@
#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
diff --git a/base/applications/network/ftp/ftp.rbuild b/base/applications/network/ftp/ftp.rbuild
index 193fa6e8ebd..fce05853523 100644
--- a/base/applications/network/ftp/ftp.rbuild
+++ b/base/applications/network/ftp/ftp.rbuild
@@ -4,19 +4,9 @@
.
-
- _chdir
- _getcwd
- _mktemp
- _unlink
- _close
- _fileno
- _read
- _write
- _lseek
-
ws2_32
iphlpapi
+ oldnames
cmds.c
cmdtab.c
domacro.c
diff --git a/base/services/dhcp/dhcp.rbuild b/base/services/dhcp/dhcp.rbuild
index c886e4a4918..ffa05b78465 100644
--- a/base/services/dhcp/dhcp.rbuild
+++ b/base/services/dhcp/dhcp.rbuild
@@ -4,16 +4,11 @@
.
include
-
- _tzset
- _close
- _read
- _write
-
ntdll
ws2_32
iphlpapi
advapi32
+ oldnames
adapter.c
alloc.c
api.c
diff --git a/base/services/tcpsvcs/tcpsvcs.rbuild b/base/services/tcpsvcs/tcpsvcs.rbuild
index 5d1618f93dd..f2b435f5aa9 100644
--- a/base/services/tcpsvcs/tcpsvcs.rbuild
+++ b/base/services/tcpsvcs/tcpsvcs.rbuild
@@ -1,6 +1,5 @@
-quotes
.
ws2_32
diff --git a/base/shell/explorer/explorer.rbuild b/base/shell/explorer/explorer.rbuild
index 7ee58711d85..7d64e7f42c3 100644
--- a/base/shell/explorer/explorer.rbuild
+++ b/base/shell/explorer/explorer.rbuild
@@ -64,7 +64,7 @@
explorer.rc
--enable-stdcall-fixup
-explorer-cfg-template.xml
+explorer-cfg-template.xml
diff --git a/baseaddress.rbuild b/baseaddress.rbuild
index 80401c1db46..58a65efc7bc 100644
--- a/baseaddress.rbuild
+++ b/baseaddress.rbuild
@@ -24,6 +24,7 @@
+
@@ -32,6 +33,7 @@
+
diff --git a/boot/bootdata/hiveinst_amd64.inf b/boot/bootdata/hiveinst_amd64.inf
deleted file mode 100644
index dd7fcdf4268..00000000000
--- a/boot/bootdata/hiveinst_amd64.inf
+++ /dev/null
@@ -1,19 +0,0 @@
-[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
diff --git a/boot/bootdata/packages/reactos.dff b/boot/bootdata/packages/reactos.dff
new file mode 100644
index 00000000000..895b3fc2fb5
--- /dev/null
+++ b/boot/bootdata/packages/reactos.dff
@@ -0,0 +1,818 @@
+; 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
diff --git a/boot/freeldr/freeldr/freeldr_arch.rbuild b/boot/freeldr/freeldr/freeldr_arch.rbuild
index 05ca7b327f1..2b8a8b288ab 100644
--- a/boot/freeldr/freeldr/freeldr_arch.rbuild
+++ b/boot/freeldr/freeldr/freeldr_arch.rbuild
@@ -1,6 +1,6 @@
-
+
include
cache
include
diff --git a/boot/freeldr/freeldr/freeldr_base.rbuild b/boot/freeldr/freeldr/freeldr_base.rbuild
index 8edcd8ef4d0..c8c2ab113c1 100644
--- a/boot/freeldr/freeldr/freeldr_base.rbuild
+++ b/boot/freeldr/freeldr/freeldr_base.rbuild
@@ -1,6 +1,6 @@
-
+
include
cache
.
diff --git a/boot/freeldr/freeldr/freeldr_main.rbuild b/boot/freeldr/freeldr/freeldr_main.rbuild
index fbb410e86a4..f45ef931fdc 100644
--- a/boot/freeldr/freeldr/freeldr_main.rbuild
+++ b/boot/freeldr/freeldr/freeldr_main.rbuild
@@ -1,6 +1,6 @@
-
+
include
include
diff --git a/boot/freeldr/freeldr/setupldr_main.rbuild b/boot/freeldr/freeldr/setupldr_main.rbuild
index c89e46ba0c5..ec99ca9c962 100644
--- a/boot/freeldr/freeldr/setupldr_main.rbuild
+++ b/boot/freeldr/freeldr/setupldr_main.rbuild
@@ -1,6 +1,6 @@
-
+
include
include
diff --git a/boot/freeldr/freeldr/windows/winldr.c b/boot/freeldr/freeldr/windows/winldr.c
index f3f7cd199b7..d130472ebae 100644
--- a/boot/freeldr/freeldr/windows/winldr.c
+++ b/boot/freeldr/freeldr/windows/winldr.c
@@ -232,7 +232,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
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)
{
@@ -261,7 +261,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
}
// 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;
diff --git a/config-amd64.template.rbuild b/config-amd64.template.rbuild
index 942da261250..7ffc0899ebd 100644
--- a/config-amd64.template.rbuild
+++ b/config-amd64.template.rbuild
@@ -65,7 +65,7 @@
enable this (except they/you purchased a license from the patent owner).
This settings is disabled (0) by default.
-->
-
+
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:
@@ -130,9 +160,6 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
&UsbDevice->DeviceDescriptor,
Urb->UrbControlDescriptorRequest.TransferBufferLength);
-
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
-
break;
}
case USB_CONFIGURATION_DESCRIPTOR_TYPE:
@@ -150,9 +177,6 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
RtlCopyMemory(Urb->UrbControlDescriptorRequest.TransferBuffer,
&UsbDevice->ConfigurationDescriptor,
Urb->UrbControlDescriptorRequest.TransferBufferLength);
-
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
-
break;
}
case USB_STRING_DESCRIPTOR_TYPE:
@@ -232,10 +256,6 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
}
InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)((PUCHAR)InterfaceInfo + InterfaceInfo->Length);
}
-
- Urb->UrbHeader.UsbdDeviceHandle = UsbDevice;
- Urb->UrbHeader.UsbdFlags = 0;
- Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
}
else
{
@@ -252,7 +272,6 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
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:
@@ -328,10 +347,16 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
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:
@@ -348,22 +373,51 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
{
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;
@@ -371,6 +425,7 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
case USB_REQUEST_SET_ADDRESS:
{
DPRINT1("USB_REQUEST_SET_ADDRESS\n");
+ ASSERT(FALSE);
break;
}
case USB_REQUEST_GET_DESCRIPTOR:
@@ -408,6 +463,12 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
DPRINT1("USB_REQUEST_SYNC_FRAME\n");
break;
}
+ default:
+ {
+ DPRINT1("Unknown Function Class Unknown request\n");
+ ASSERT(FALSE);
+ break;
+ }
}
break;
}
@@ -415,6 +476,7 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
{
DPRINT1("Unhandled URB %x\n", Urb->UrbHeader.Function);
Urb->UrbHeader.Status = USBD_STATUS_INVALID_URB_FUNCTION;
+ ASSERT(FALSE);
}
}
@@ -424,6 +486,13 @@ CompletePendingURBRequest(PPDO_DEVICE_EXTENSION DeviceExtension)
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);
}
diff --git a/drivers/usb/usbehci/pdo.c b/drivers/usb/usbehci/pdo.c
index 3ab717f0f56..6a0d735e851 100644
--- a/drivers/usb/usbehci/pdo.c
+++ b/drivers/usb/usbehci/pdo.c
@@ -172,18 +172,24 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
}
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;
}
@@ -216,9 +222,8 @@ PdoDispatchInternalDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
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:
@@ -287,7 +292,6 @@ PdoQueryId(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG_PTR* Information)
}
}
- /* Lifted from hpoussin */
Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
&SourceString,
&String);
@@ -350,6 +354,7 @@ PdoDispatchPnp(
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;
@@ -357,6 +362,12 @@ PdoDispatchPnp(
/* 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));
@@ -409,8 +420,16 @@ PdoDispatchPnp(
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",
@@ -534,7 +553,8 @@ PdoDispatchPnp(
else
{
DPRINT1("Not Supported\n");
- Status = STATUS_NOT_SUPPORTED;
+ Status = Irp->IoStatus.Status;
+ Information = Irp->IoStatus.Information;
}
break;
}
diff --git a/drivers/usb/usbehci/usbehci.h b/drivers/usb/usbehci/usbehci.h
index f4c440df616..13bfabb3657 100644
--- a/drivers/usb/usbehci/usbehci.h
+++ b/drivers/usb/usbehci/usbehci.h
@@ -75,6 +75,25 @@ OR with QUEUE_TRANSFER_DESCRIPTOR Token.SplitTransactionState */
#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
{
@@ -273,16 +292,16 @@ typedef struct _EHCI_HCC_CONTENT
} 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
@@ -292,6 +311,14 @@ 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;
@@ -333,8 +360,8 @@ typedef struct _FDO_DEVICE_EXTENSION
PULONG PeriodicFramList;
PULONG AsyncListQueueHeadPtr;
- PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
- PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
+ PHYSICAL_ADDRESS PeriodicFramListPhysAddr;
+ PHYSICAL_ADDRESS AsyncListQueueHeadPtrPhysAddr;
BOOLEAN AsyncComplete;
@@ -356,6 +383,8 @@ typedef struct _PDO_DEVICE_EXTENSION
BOOLEAN HaltUrbHandling;
PVOID CallbackContext;
PRH_INIT_CALLBACK CallbackRoutine;
+ ULONG NumberOfPorts;
+ EHCIPORTS Ports[32];
} PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
typedef struct _WORKITEM_DATA
diff --git a/hal/halx86/directory.rbuild b/hal/halx86/directory.rbuild
index 81a989facea..7cea4c006fa 100644
--- a/hal/halx86/directory.rbuild
+++ b/hal/halx86/directory.rbuild
@@ -5,9 +5,12 @@
-
+
+
+
+
diff --git a/hal/halx86/generic/acpi/halacpi.c b/hal/halx86/generic/acpi/halacpi.c
new file mode 100644
index 00000000000..1efee7996a4
--- /dev/null
+++ b/hal/halx86/generic/acpi/halacpi.c
@@ -0,0 +1,1046 @@
+/*
+ * 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
+#define NDEBUG
+#include
+
+/* 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 */
diff --git a/hal/halx86/generic/acpi/halpnpdd.c b/hal/halx86/generic/acpi/halpnpdd.c
new file mode 100644
index 00000000000..ca85188bcaf
--- /dev/null
+++ b/hal/halx86/generic/acpi/halpnpdd.c
@@ -0,0 +1,875 @@
+/*
+ * 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
+#define NDEBUG
+#include
+
+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 */
diff --git a/hal/halx86/generic/bus/pcibus.c b/hal/halx86/generic/bus/pcibus.c
index 50f1add18d8..2440cd4182b 100644
--- a/hal/halx86/generic/bus/pcibus.c
+++ b/hal/halx86/generic/bus/pcibus.c
@@ -14,6 +14,8 @@
/* GLOBALS *******************************************************************/
+PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}};
+
BOOLEAN HalpPCIConfigInitialized;
ULONG HalpMinPciBus, HalpMaxPciBus;
KSPIN_LOCK HalpPCIConfigLock;
@@ -521,6 +523,34 @@ HalpReleasePciDeviceForDebugging(IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
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)
{
@@ -1026,9 +1056,3 @@ HalpInitializePciStubs(VOID)
HalpPCIConfigInitialized = TRUE;
}
-VOID
-NTAPI
-HalpInitializePciBus(VOID)
-{
- /* FIXME: Initialize NMI Crash Flag */
-}
diff --git a/hal/halx86/generic/halinit.c b/hal/halx86/generic/halinit.c
index 498bf5cc5bb..4309ac1a16e 100644
--- a/hal/halx86/generic/halinit.c
+++ b/hal/halx86/generic/halinit.c
@@ -14,10 +14,225 @@
/* 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)
@@ -92,6 +307,9 @@ HalInitSystem(IN ULONG BootPhase,
}
#ifndef _MINIHAL_
+ /* Initialize ACPI */
+ HalpSetupAcpiPhase0(LoaderBlock);
+
/* Initialize the PICs */
HalpInitializePICs(TRUE);
#endif
diff --git a/hal/halx86/generic/legacy/halpcat.c b/hal/halx86/generic/legacy/halpcat.c
new file mode 100644
index 00000000000..ea16403676e
--- /dev/null
+++ b/hal/halx86/generic/legacy/halpcat.c
@@ -0,0 +1,122 @@
+/*
+ * 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
+#define NDEBUG
+#include
+
+/* 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 */
diff --git a/hal/halx86/generic/misc.c b/hal/halx86/generic/misc.c
index 4ddd30ee589..f138e5f9871 100644
--- a/hal/halx86/generic/misc.c
+++ b/hal/halx86/generic/misc.c
@@ -16,8 +16,130 @@
BOOLEAN HalpNMIInProgress;
+UCHAR HalpSerialLen;
+CHAR HalpSerialNumber[31];
+
/* PRIVATE FUNCTIONS **********************************************************/
+#ifndef _MINIHAL_
+VOID
+NTAPI
+HalpReportSerialNumber(VOID)
+{
+ 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);
+ }
+}
+
+NTSTATUS
+NTAPI
+HalpMarkAcpiHal(VOID)
+{
+ 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
HalpCheckPowerButton(VOID)
@@ -28,32 +150,6 @@ HalpCheckPowerButton(VOID)
return;
}
-#ifndef _MINIHAL_
-PVOID
-NTAPI
-HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
- IN ULONG NumberPage)
-{
- //
- // Use kernel memory manager I/O map facilities
- //
- return MmMapIoSpace(PhysicalAddress,
- NumberPage << PAGE_SHIFT,
- MmNonCached);
-}
-
-VOID
-NTAPI
-HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
- IN ULONG NumberPages)
-{
- //
- // Use kernel memory manager I/O map facilities
- //
- MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
-}
-#endif
-
VOID
NTAPI
HalpFlushTLB(VOID)
diff --git a/hal/halx86/generic/usage.c b/hal/halx86/generic/usage.c
index d35a3e3a964..02c86e2a046 100644
--- a/hal/halx86/generic/usage.c
+++ b/hal/halx86/generic/usage.c
@@ -14,25 +14,45 @@
/* 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},
}
@@ -40,13 +60,429 @@ ADDRESS_USAGE HalpDefaultIoSpace =
/* 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
@@ -88,55 +524,56 @@ HalpEnableInterruptHandler(IN UCHAR Flags,
/* Enable the interrupt */
HalEnableSystemInterrupt(SystemVector, Irql, Mode);
}
-#endif
-/*
- * @unimplemented
- */
VOID
NTAPI
-HalReportResourceUsage(VOID)
+HalpGetNMICrashFlag(VOID)
{
- INTERFACE_TYPE InterfaceType;
- UNICODE_STRING HalString;
+ 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 DMA 64-bit support */
+ /* Set default */
+ HalpNMIDumpFlag = 0;
- /* FIXME: Initialize MCA bus */
-
- /* 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);
}
-
- /* Build HAL usage */
- RtlInitUnicodeString(&HalString, L"PC Compatible Eisa/Isa HAL");
- HalpReportResourceUsage(&HalString, InterfaceType);
-
- /* FIXME: Setup PCI debugging and Hibernation */
}
+#endif
+
+/* EOF */
+
diff --git a/hal/halx86/hal.rbuild b/hal/halx86/hal.rbuild
index 2c672c2f5f4..17ffea9c4a0 100644
--- a/hal/halx86/hal.rbuild
+++ b/hal/halx86/hal.rbuild
@@ -9,6 +9,7 @@
hal_generic
+ hal_generic_pcat
hal_generic_up
ntoskrnl
libcntpr
diff --git a/hal/halx86/hal_generic.rbuild b/hal/halx86/hal_generic.rbuild
index 154379fa8a9..166bb930404 100644
--- a/hal/halx86/hal_generic.rbuild
+++ b/hal/halx86/hal_generic.rbuild
@@ -47,7 +47,7 @@
-
+
include
include
@@ -82,7 +82,7 @@
systimer.S
-
+
halinit_up.c
pic.c
diff --git a/hal/halx86/hal_generic_acpi.rbuild b/hal/halx86/hal_generic_acpi.rbuild
new file mode 100644
index 00000000000..3784394b642
--- /dev/null
+++ b/hal/halx86/hal_generic_acpi.rbuild
@@ -0,0 +1,16 @@
+
+
+
+
+ include
+ include
+
+
+
+
+ halacpi.c
+ halpnpdd.c
+
+
+
+
diff --git a/hal/halx86/hal_generic_pcat.rbuild b/hal/halx86/hal_generic_pcat.rbuild
new file mode 100644
index 00000000000..e00ed5bdb4e
--- /dev/null
+++ b/hal/halx86/hal_generic_pcat.rbuild
@@ -0,0 +1,15 @@
+
+
+
+
+ include
+ include
+
+
+
+
+ halpcat.c
+
+
+
+
diff --git a/hal/halx86/halacpi.rbuild b/hal/halx86/halacpi.rbuild
new file mode 100644
index 00000000000..d380cf6889e
--- /dev/null
+++ b/hal/halx86/halacpi.rbuild
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ include
+ include
+
+
+ hal_generic
+ hal_generic_acpi
+ hal_generic_up
+ ntoskrnl
+ libcntpr
+
+ halinit_up.c
+ halup.rc
+
+
+
diff --git a/hal/halx86/halamd64.rbuild b/hal/halx86/halamd64.rbuild
index 4a09aa2c838..0b60f7615dc 100644
--- a/hal/halx86/halamd64.rbuild
+++ b/hal/halx86/halamd64.rbuild
@@ -11,6 +11,7 @@
hal_generic
+ hal_generic_acpi
hal_generic_up
ntoskrnl
diff --git a/hal/halx86/halmps.rbuild b/hal/halx86/halmps.rbuild
index ad17eac9002..d76c49f39da 100644
--- a/hal/halx86/halmps.rbuild
+++ b/hal/halx86/halmps.rbuild
@@ -10,6 +10,7 @@
hal_generic
+ hal_generic_pcat
hal_generic_mp
ntoskrnl
libcntpr
diff --git a/hal/halx86/halxbox.rbuild b/hal/halx86/halxbox.rbuild
index cee7f614e90..ad13545b405 100644
--- a/hal/halx86/halxbox.rbuild
+++ b/hal/halx86/halxbox.rbuild
@@ -9,6 +9,7 @@
hal_generic
+ hal_generic_pcat
hal_generic_up
ntoskrnl
libcntpr
diff --git a/hal/halx86/include/bus.h b/hal/halx86/include/bus.h
index 3e07190f470..03840227411 100644
--- a/hal/halx86/include/bus.h
+++ b/hal/halx86/include/bus.h
@@ -158,6 +158,38 @@ typedef struct _PCI_REGISTRY_INFO_INTERNAL
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;
@@ -359,6 +391,12 @@ HalpFindBusAddressTranslation(
IN BOOLEAN NextBus
);
+VOID
+NTAPI
+HalpRegisterPciDebuggingDeviceInfo(
+ VOID
+);
+
extern ULONG HalpBusType;
extern BOOLEAN HalpPCIConfigInitialized;
extern BUS_HANDLER HalpFakePciBusHandler;
diff --git a/hal/halx86/include/hal.h b/hal/halx86/include/hal.h
index 3eff1e74b58..97e8f4a810e 100644
--- a/hal/halx86/include/hal.h
+++ b/hal/halx86/include/hal.h
@@ -48,5 +48,6 @@
#include "halp.h"
#include "mps.h"
#include "ioapic.h"
+#include "halacpi.h"
/* EOF */
diff --git a/hal/halx86/include/halacpi.h b/hal/halx86/include/halacpi.h
new file mode 100644
index 00000000000..1b4e16bf37d
--- /dev/null
+++ b/hal/halx86/include/halacpi.h
@@ -0,0 +1,237 @@
+#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
+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
+
+//
+// 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 */
diff --git a/hal/halx86/include/halp.h b/hal/halx86/include/halp.h
index 6fd63fa3e17..6edb85570d7 100644
--- a/hal/halx86/include/halp.h
+++ b/hal/halx86/include/halp.h
@@ -49,6 +49,7 @@ DECLSPEC_NORETURN
/* Usage flags */
#define IDT_REGISTERED 0x01
#define IDT_LATCHED 0x02
+#define IDT_READ_ONLY 0x04
#define IDT_INTERNAL 0x11
#define IDT_DEVICE 0x21
@@ -681,7 +682,80 @@ HalpReleaseCmosSpinLock(
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
@@ -711,3 +785,9 @@ extern KSPIN_LOCK HalpSystemHardwareLock;
extern PADDRESS_USAGE HalpAddressUsageList;
extern LARGE_INTEGER HalpPerfCounter;
+
+extern KAFFINITY HalpActiveProcessors;
+
+extern BOOLEAN HalDisableFirmwareMapper;
+extern PWCHAR HalHardwareIdString;
+extern PWCHAR HalName;
diff --git a/hal/halx86/mp/processor_mp.c b/hal/halx86/mp/processor_mp.c
index 126bccbcbf6..069a96bb269 100644
--- a/hal/halx86/mp/processor_mp.c
+++ b/hal/halx86/mp/processor_mp.c
@@ -18,6 +18,8 @@
#define NDEBUG
#include
+KAFFINITY HalpActiveProcessors;
+
/* PRIVATE FUNCTIONS *********************************************************/
VOID
diff --git a/hal/halx86/up/processor.c b/hal/halx86/up/processor.c
index 662514b19cf..2e92a2c6c86 100644
--- a/hal/halx86/up/processor.c
+++ b/hal/halx86/up/processor.c
@@ -12,7 +12,7 @@
#define NDEBUG
#include
-LONG HalpActiveProcessors;
+KAFFINITY HalpActiveProcessors;
KAFFINITY HalpDefaultInterruptAffinity;
/* PRIVATE FUNCTIONS *********************************************************/
@@ -41,7 +41,7 @@ HalInitializeProcessor(IN ULONG ProcessorNumber,
KeGetPcr()->StallScaleFactor = INITIAL_STALL_COUNT;
/* Update the interrupt affinity and processor mask */
- InterlockedBitTestAndSet(&HalpActiveProcessors, ProcessorNumber);
+ InterlockedBitTestAndSet((PLONG)&HalpActiveProcessors, ProcessorNumber);
InterlockedBitTestAndSet((PLONG)&HalpDefaultInterruptAffinity,
ProcessorNumber);
diff --git a/include/crt/_mingw.h b/include/crt/_mingw.h
index 26757379ce6..d4e53ff435a 100644
--- a/include/crt/_mingw.h
+++ b/include/crt/_mingw.h
@@ -184,7 +184,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */
#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__
@@ -197,5 +197,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */
#define _CRT_UNUSED(x) (void)x
#endif
+#include "_mingw_mac.h"
+
#endif /* !_INC_MINGW */
diff --git a/include/crt/_mingw_mac.h b/include/crt/_mingw_mac.h
new file mode 100644
index 00000000000..de7351943f8
--- /dev/null
+++ b/include/crt/_mingw_mac.h
@@ -0,0 +1,134 @@
+/**
+ * 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 */
+
diff --git a/include/crt/crtdefs.h b/include/crt/crtdefs.h
index 8ff8d0d3764..96a534b81fc 100644
--- a/include/crt/crtdefs.h
+++ b/include/crt/crtdefs.h
@@ -25,6 +25,7 @@
//#define NO_OLDNAMES
//#endif
+
/** Properties ***************************************************************/
#undef _CRT_PACKING
@@ -50,12 +51,14 @@
#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
@@ -218,6 +221,7 @@
#define _CRT_OBSOLETE(_NewItem)
#endif
+
/** Constants ****************************************************************/
#define _ARGMAX 100
@@ -231,7 +235,6 @@
#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
-
/** Type definitions *********************************************************/
#ifdef __cplusplus
diff --git a/include/crt/ctype.h b/include/crt/ctype.h
index 74f7b1eb170..294e0171111 100644
--- a/include/crt/ctype.h
+++ b/include/crt/ctype.h
@@ -38,7 +38,7 @@ extern "C" {
#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);
diff --git a/include/crt/mingw32/intrin_x86.h b/include/crt/mingw32/intrin_x86.h
index 84c1e663996..9e83ed81838 100644
--- a/include/crt/mingw32/intrin_x86.h
+++ b/include/crt/mingw32/intrin_x86.h
@@ -74,6 +74,10 @@ extern "C" {
#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 ***/
@@ -565,6 +569,18 @@ __INTRIN_INLINE void __stosd(unsigned long * Dest, const unsigned long Data, siz
);
}
+#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__
@@ -595,6 +611,18 @@ __INTRIN_INLINE void __movsd(unsigned long * Destination, const unsigned long *
);
}
+#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 ***/
@@ -787,6 +815,20 @@ __INTRIN_INLINE unsigned char _bittest(const long * const a, const long b)
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;
diff --git a/include/crt/stdlib.h b/include/crt/stdlib.h
index baa0d8d419a..d4846fa2c71 100644
--- a/include/crt/stdlib.h
+++ b/include/crt/stdlib.h
@@ -535,7 +535,7 @@ extern "C" {
_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
diff --git a/include/crt/tchar.h b/include/crt/tchar.h
index 0b5011eadd0..d7c31478341 100644
--- a/include/crt/tchar.h
+++ b/include/crt/tchar.h
@@ -624,9 +624,7 @@ extern "C" {
#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
diff --git a/include/ddk/ntimage.h b/include/ddk/ntimage.h
index 9703bb1e3e0..8df984763f7 100644
--- a/include/ddk/ntimage.h
+++ b/include/ddk/ntimage.h
@@ -403,15 +403,22 @@ typedef struct _IMAGE_NT_HEADERS {
} 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_ */
//
diff --git a/include/ddk/winsplp.h b/include/ddk/winsplp.h
index 4dfdb5b834e..cc4bf6f15cc 100644
--- a/include/ddk/winsplp.h
+++ b/include/ddk/winsplp.h
@@ -1,29 +1,4 @@
-/*
- * 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" {
@@ -35,11 +10,285 @@ 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_*
*/
@@ -162,12 +411,6 @@ typedef struct _MONITORUI {
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;
@@ -343,16 +586,6 @@ typedef struct _PRINTPROVIDOR {
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);
@@ -424,5 +657,3 @@ BOOL WINAPI SpoolerFindClosePrinterChangeNotification(HANDLE hPrinter);
#ifdef __cplusplus
} /* extern "C" */
#endif
-
-#endif /* _WINSPLP_ */
diff --git a/include/ndk/iofuncs.h b/include/ndk/iofuncs.h
index 06648fd596c..2aab3a1a798 100644
--- a/include/ndk/iofuncs.h
+++ b/include/ndk/iofuncs.h
@@ -44,6 +44,22 @@ IoSynchronousInvalidateDeviceRelations(
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
//
diff --git a/include/psdk/ks.h b/include/psdk/ks.h
index 2249af3711a..f728bfb0f78 100644
--- a/include/psdk/ks.h
+++ b/include/psdk/ks.h
@@ -2987,6 +2987,9 @@ struct _KSNODE_DESCRIPTOR
const KSAUTOMATION_TABLE* AutomationTable;
const GUID* Type;
const GUID* Name;
+#if !defined(_WIN64)
+ PVOID Alignment;
+#endif
};
struct _KSFILTER_DESCRIPTOR
@@ -4068,6 +4071,14 @@ KsCreateFilterFactory(
IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL,
OUT PKSFILTERFACTORY *FilterFactory OPTIONAL);
+KSDDKAPI
+NTSTATUS
+NTAPI
+KsFilterFactorySetDeviceClassesState(
+ IN PKSFILTERFACTORY FilterFactory,
+ IN BOOLEAN NewState
+ );
+
KSDDKAPI
NTSTATUS
NTAPI
diff --git a/include/psdk/wingdi.h b/include/psdk/wingdi.h
index a4338d2d64a..edfbae652f3 100644
--- a/include/psdk/wingdi.h
+++ b/include/psdk/wingdi.h
@@ -69,6 +69,7 @@ extern "C" {
#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
@@ -184,12 +185,19 @@ extern "C" {
#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
@@ -265,6 +273,16 @@ extern "C" {
#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
@@ -379,6 +397,17 @@ extern "C" {
#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
@@ -400,6 +429,8 @@ extern "C" {
#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
@@ -562,6 +593,7 @@ extern "C" {
#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
@@ -601,6 +633,7 @@ extern "C" {
#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)
@@ -811,8 +844,16 @@ extern "C" {
#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
@@ -836,6 +877,12 @@ extern "C" {
#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
@@ -891,6 +938,7 @@ extern "C" {
#define MWT_MAX MWT_RIGHTMULTIPLY
#define OPAQUE 2
#define TRANSPARENT 1
+#define BKMODE_LAST 2
#define BLACKONWHITE 1
#define WHITEONBLACK 2
#define COLORONCOLOR 3
@@ -1017,6 +1065,7 @@ extern "C" {
#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
@@ -2162,6 +2211,26 @@ typedef struct tagEMRSTRETCHBLT {
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;
@@ -2915,12 +2984,17 @@ int WINAPI FillRgn(HDC,HRGN,HBRUSH);
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))
@@ -3018,7 +3092,7 @@ UINT WINAPI GetSystemPaletteUse(HDC);
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 );
@@ -3130,6 +3204,7 @@ BOOL WINAPI SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR*);
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);
@@ -3349,6 +3424,22 @@ typedef DISPLAY_DEVICEA DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE;
#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
diff --git a/include/psdk/winuser.h b/include/psdk/winuser.h
index 563904bcbd7..bea47d14f05 100644
--- a/include/psdk/winuser.h
+++ b/include/psdk/winuser.h
@@ -299,6 +299,9 @@ extern "C" {
#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
@@ -386,6 +389,7 @@ extern "C" {
#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 */
@@ -518,6 +522,7 @@ extern "C" {
#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
@@ -864,6 +869,8 @@ extern "C" {
#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
@@ -1135,6 +1142,7 @@ extern "C" {
#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
@@ -1142,6 +1150,8 @@ extern "C" {
#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
@@ -1202,6 +1212,10 @@ extern "C" {
#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
@@ -1560,6 +1574,9 @@ extern "C" {
#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
@@ -1599,6 +1616,8 @@ extern "C" {
#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)
@@ -1653,6 +1672,7 @@ extern "C" {
#define WM_NCXBUTTONDBLCLK 173
#endif /* (_WIN32_WINNT >= 0x0500) */
+#define WM_KEYF1 0x004d
#define WM_KEYFIRST 256
#define WM_KEYDOWN 256
#define WM_KEYUP 257
@@ -1686,6 +1706,7 @@ extern "C" {
#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
@@ -1705,6 +1726,15 @@ extern "C" {
#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
@@ -1715,6 +1745,7 @@ extern "C" {
#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
@@ -1803,6 +1834,7 @@ extern "C" {
#define WM_HOTKEY 786
#define WM_PRINT 791
#define WM_PRINTCLIENT 792
+#define WM_APPCOMMAND 793
#define WM_DWMCOMPOSITIONCHANGED 0x031E
#define WM_DWMNCRENDERINGCHANGED 0x031F
@@ -1819,6 +1851,8 @@ extern "C" {
#define WM_APP 32768
#define WM_GETTITLEBARINFOEX 0x033F
+#define XBUTTON1 0x0001
+#define XBUTTON2 0x0002
#if (_WIN32_WINNT >= 0x0400)
#define WHEEL_DELTA 120
@@ -1882,6 +1916,7 @@ extern "C" {
#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
@@ -1943,6 +1978,7 @@ extern "C" {
#define LB_ADDFILE 406
#define LB_ADDSTRING 384
#ifdef _WINE
+#define LB_CARETON 419
#define LB_CARETOFF 420
#endif
#define LB_DELETESTRING 386
@@ -2190,6 +2226,7 @@ extern "C" {
#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
@@ -3815,13 +3852,14 @@ HDC WINAPI BeginPaint(HWND,LPPAINTSTRUCT);
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);
@@ -3905,8 +3943,8 @@ HMENU WINAPI CreatePopupMenu(void);
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);
@@ -4051,7 +4089,7 @@ BOOL WINAPI GetCursorPos(LPPOINT);
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);
@@ -4227,6 +4265,7 @@ BOOL WINAPI IsWinEventHookInstalled(DWORD);
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);
@@ -4286,12 +4325,12 @@ BOOL WINAPI OemToCharBuffW(LPCSTR,LPWSTR,DWORD);
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);
@@ -4337,6 +4376,7 @@ HANDLE WINAPI RemovePropA(HWND,LPCSTR);
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);
@@ -4372,6 +4412,7 @@ HWND WINAPI SetClipboardViewer(HWND);
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);
@@ -4404,8 +4445,10 @@ BOOL WINAPI SetSysColors(int,const INT *,const COLORREF *);
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);
diff --git a/include/reactos/mingw-w64/internal.h b/include/reactos/mingw-w64/internal.h
index 7d4785797da..7f58a3d540d 100644
--- a/include/reactos/mingw-w64/internal.h
+++ b/include/reactos/mingw-w64/internal.h
@@ -1,7 +1,7 @@
/**
* 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
@@ -18,11 +18,14 @@ extern "C" {
#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;
@@ -69,13 +72,13 @@ extern "C" {
#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
@@ -107,24 +110,24 @@ extern "C" {
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
@@ -169,7 +172,7 @@ extern char **_imp___wcmdln;
#include
void * __cdecl _encode_pointer(void *);
- void * __cdecl _encoded_null(void);
+ void * __cdecl _encoded_null();
void * __cdecl _decode_pointer(void *);
BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);
diff --git a/include/reactos/mingw-w64/oscalls.h b/include/reactos/mingw-w64/oscalls.h
index 132686d15c4..81356767001 100644
--- a/include/reactos/mingw-w64/oscalls.h
+++ b/include/reactos/mingw-w64/oscalls.h
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/include/reactos/mingw-w64/reactos.diff b/include/reactos/mingw-w64/reactos.diff
new file mode 100644
index 00000000000..905f7ba3377
--- /dev/null
+++ b/include/reactos/mingw-w64/reactos.diff
@@ -0,0 +1,83 @@
+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
diff --git a/include/reactos/mingw-w64/sect_attribs.h b/include/reactos/mingw-w64/sect_attribs.h
index da09e9bbad2..8dde10a6552 100644
--- a/include/reactos/mingw-w64/sect_attribs.h
+++ b/include/reactos/mingw-w64/sect_attribs.h
@@ -1,7 +1,7 @@
/**
* 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)
diff --git a/lib/3rdparty/libwine/debug_ros.c b/lib/3rdparty/libwine/debug_ros.c
index fd1e6775257..66904ba33e2 100644
--- a/lib/3rdparty/libwine/debug_ros.c
+++ b/lib/3rdparty/libwine/debug_ros.c
@@ -5,6 +5,7 @@
#define free libwine_free
#define realloc libwine_realloc
#define _strdup libwine__strdup
+#define interlocked_xchg_add InterlockedExchangeAdd
#include "debug.c"
diff --git a/lib/3rdparty/mingw/CRT_fp10.c b/lib/3rdparty/mingw/CRT_fp10.c
index b809ce0b447..b81937edcd6 100644
--- a/lib/3rdparty/mingw/CRT_fp10.c
+++ b/lib/3rdparty/mingw/CRT_fp10.c
@@ -1,9 +1,11 @@
/**
* 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__
diff --git a/lib/3rdparty/mingw/CRT_fp8.c b/lib/3rdparty/mingw/CRT_fp8.c
index 817f16fa587..e7921f1739f 100644
--- a/lib/3rdparty/mingw/CRT_fp8.c
+++ b/lib/3rdparty/mingw/CRT_fp8.c
@@ -1,12 +1,18 @@
/**
* 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);
diff --git a/lib/3rdparty/mingw/CRT_glob.c b/lib/3rdparty/mingw/CRT_glob.c
new file mode 100644
index 00000000000..60500031403
--- /dev/null
+++ b/lib/3rdparty/mingw/CRT_glob.c
@@ -0,0 +1,17 @@
+/*
+ * 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;
+
diff --git a/lib/3rdparty/mingw/CRT_noglob.c b/lib/3rdparty/mingw/CRT_noglob.c
new file mode 100644
index 00000000000..f458db97493
--- /dev/null
+++ b/lib/3rdparty/mingw/CRT_noglob.c
@@ -0,0 +1,17 @@
+/*
+ * 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;
+
diff --git a/lib/3rdparty/mingw/_newmode.c b/lib/3rdparty/mingw/_newmode.c
index e154284c3bf..f2fa3966f70 100644
--- a/lib/3rdparty/mingw/_newmode.c
+++ b/lib/3rdparty/mingw/_newmode.c
@@ -1,7 +1,7 @@
/**
* 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;
diff --git a/lib/3rdparty/mingw/atonexit.c b/lib/3rdparty/mingw/atonexit.c
index 9e4b3a5e6fa..442be353d88 100644
--- a/lib/3rdparty/mingw/atonexit.c
+++ b/lib/3rdparty/mingw/atonexit.c
@@ -1,7 +1,7 @@
/**
* 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
@@ -25,9 +25,11 @@ _PVFV *__onexitbegin;
_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;
@@ -37,7 +39,7 @@ _onexit_t __cdecl mingw_onexit(_onexit_t func)
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);
diff --git a/lib/3rdparty/mingw/binmode.c b/lib/3rdparty/mingw/binmode.c
new file mode 100644
index 00000000000..e7b3965cd43
--- /dev/null
+++ b/lib/3rdparty/mingw/binmode.c
@@ -0,0 +1,10 @@
+/**
+ * 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
+#include
diff --git a/lib/3rdparty/mingw/charmax.c b/lib/3rdparty/mingw/charmax.c
index 7442633fe6c..fbd10c4b923 100644
--- a/lib/3rdparty/mingw/charmax.c
+++ b/lib/3rdparty/mingw/charmax.c
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/lib/3rdparty/mingw/crt0_c.c b/lib/3rdparty/mingw/crt0_c.c
index 577fa8772be..f36772ebc1e 100644
--- a/lib/3rdparty/mingw/crt0_c.c
+++ b/lib/3rdparty/mingw/crt0_c.c
@@ -1,12 +1,20 @@
/**
* 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
-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);
}
diff --git a/lib/3rdparty/mingw/crt0_w.c b/lib/3rdparty/mingw/crt0_w.c
index 4e096483e11..ebd78840820 100644
--- a/lib/3rdparty/mingw/crt0_w.c
+++ b/lib/3rdparty/mingw/crt0_w.c
@@ -1,16 +1,25 @@
/**
* 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
-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);
}
diff --git a/lib/3rdparty/mingw/crt_handler.c b/lib/3rdparty/mingw/crt_handler.c
new file mode 100644
index 00000000000..8e47df0a6c1
--- /dev/null
+++ b/lib/3rdparty/mingw/crt_handler.c
@@ -0,0 +1,181 @@
+/**
+ * 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#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
diff --git a/lib/3rdparty/mingw/crtbegin.c b/lib/3rdparty/mingw/crtbegin.c
new file mode 100644
index 00000000000..c917f9bd42a
--- /dev/null
+++ b/lib/3rdparty/mingw/crtbegin.c
@@ -0,0 +1,6 @@
+/**
+ * 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.
+ */
+
diff --git a/lib/3rdparty/mingw/crtdll.c b/lib/3rdparty/mingw/crtdll.c
index c14a7a0310c..f930f0d6a5a 100644
--- a/lib/3rdparty/mingw/crtdll.c
+++ b/lib/3rdparty/mingw/crtdll.c
@@ -1,7 +1,7 @@
/**
* 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
@@ -40,6 +40,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
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;
@@ -49,9 +50,9 @@ extern _PVFV *__onexitend;
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);
@@ -71,7 +72,7 @@ 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)
{
@@ -110,10 +111,9 @@ BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
}
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);
}
@@ -143,29 +143,35 @@ BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID 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)
diff --git a/lib/3rdparty/mingw/crtend.c b/lib/3rdparty/mingw/crtend.c
new file mode 100644
index 00000000000..c917f9bd42a
--- /dev/null
+++ b/lib/3rdparty/mingw/crtend.c
@@ -0,0 +1,6 @@
+/**
+ * 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.
+ */
+
diff --git a/lib/3rdparty/mingw/crtexe.c b/lib/3rdparty/mingw/crtexe.c
index a3421ff25d9..cc8f1976350 100644
--- a/lib/3rdparty/mingw/crtexe.c
+++ b/lib/3rdparty/mingw/crtexe.c
@@ -1,7 +1,7 @@
/**
* 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
@@ -23,17 +23,17 @@
#include
#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;
@@ -43,13 +43,13 @@ extern void _fpreset (void);
__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__)
@@ -67,6 +67,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
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;
@@ -74,6 +75,10 @@ extern _PVFV *__onexitend;
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);
@@ -89,10 +94,10 @@ static int mainret=0;
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
@@ -101,7 +106,7 @@ static void duplicate_ppstrings (int ac, char ***av);
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;
@@ -115,8 +120,8 @@ pre_c_init (void)
__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();
@@ -152,6 +157,8 @@ pre_cpp_init (void)
static int __tmainCRTStartup (void);
+int WinMainCRTStartup (void);
+
int WinMainCRTStartup (void)
{
mingw_app_type = 1;
@@ -159,6 +166,12 @@ int WinMainCRTStartup (void)
return __tmainCRTStartup ();
}
+int mainCRTStartup (void);
+
+#ifdef _WIN64
+int __mingw_init_ehandler (void);
+#endif
+
int mainCRTStartup (void)
{
mingw_app_type = 0;
@@ -166,15 +179,15 @@ int mainCRTStartup (void)
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);
{
@@ -211,18 +224,17 @@ __tmainCRTStartup (void)
_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)
@@ -239,7 +251,7 @@ __tmainCRTStartup (void)
#ifdef _MBCS
if (_ismbblead (*lpszCommandLine))
{
- if (lpszCommandLine)
+ if (*lpszCommandLine)
lpszCommandLine++;
}
#endif
@@ -248,21 +260,11 @@ __tmainCRTStartup (void)
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;
@@ -274,7 +276,6 @@ __tmainCRTStartup (void)
__initenv = envp;
mainret = main (argc, argv, envp);
#endif
- }
if (!managedapp)
exit (mainret);
@@ -328,7 +329,7 @@ check_managed_app (void)
}
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;
@@ -399,42 +400,26 @@ _gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
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;
}
+
+ if (action == EXCEPTION_CONTINUE_SEARCH && __mingw_oldexcpt_handler)
+ action = (*__mingw_oldexcpt_handler)(exception_data);
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);
-}
-#endif
-
#ifdef WPRFLAG
-
static size_t wbytelen(const wchar_t *p)
{
size_t ret = 1;
@@ -465,7 +450,7 @@ static void duplicate_ppstrings (int ac, char ***av)
char **avl;
int i;
char **n = (char **) malloc (sizeof (char *) * (ac + 1));
-
+
avl=*av;
for (i=0; i < ac; i++)
{
@@ -477,3 +462,35 @@ static void duplicate_ppstrings (int ac, char ***av)
*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);
+}
diff --git a/lib/3rdparty/mingw/cxa_pure_virtual.c b/lib/3rdparty/mingw/cxa_pure_virtual.c
new file mode 100644
index 00000000000..2db21a00fbe
--- /dev/null
+++ b/lib/3rdparty/mingw/cxa_pure_virtual.c
@@ -0,0 +1,7 @@
+
+void _assert(int);
+
+void __cxa_pure_virtual()
+{
+ _assert(0);
+}
diff --git a/lib/3rdparty/mingw/dll_argv.c b/lib/3rdparty/mingw/dll_argv.c
new file mode 100644
index 00000000000..06abb8dfddf
--- /dev/null
+++ b/lib/3rdparty/mingw/dll_argv.c
@@ -0,0 +1,25 @@
+/**
+ * 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
+
+extern int _dowildcard;
+
+#ifdef WPRFLAG
+int __CRTDECL
+__wsetargv (void)
+#else
+int __CRTDECL
+__setargv (void)
+#endif
+{
+ _dowildcard = 1;
+ return 0;
+}
diff --git a/lib/3rdparty/mingw/dllargv.c b/lib/3rdparty/mingw/dllargv.c
index 376479c4d72..769b8353685 100644
--- a/lib/3rdparty/mingw/dllargv.c
+++ b/lib/3rdparty/mingw/dllargv.c
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/lib/3rdparty/mingw/dllentry.c b/lib/3rdparty/mingw/dllentry.c
index dc0aaa25fdf..e7658954c19 100644
--- a/lib/3rdparty/mingw/dllentry.c
+++ b/lib/3rdparty/mingw/dllentry.c
@@ -1,14 +1,18 @@
/**
* 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
#define _DECL_DLLMAIN
#include
-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;
}
diff --git a/lib/3rdparty/mingw/dllmain.c b/lib/3rdparty/mingw/dllmain.c
index 1e52c8598d6..834e5a89a66 100644
--- a/lib/3rdparty/mingw/dllmain.c
+++ b/lib/3rdparty/mingw/dllmain.c
@@ -2,7 +2,9 @@
#define _DECL_DLLMAIN
#include
-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;
}
diff --git a/lib/3rdparty/mingw/gccmain.c b/lib/3rdparty/mingw/gccmain.c
index b2db698c3ad..c046e8d77dc 100644
--- a/lib/3rdparty/mingw/gccmain.c
+++ b/lib/3rdparty/mingw/gccmain.c
@@ -1,7 +1,7 @@
/**
* 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
@@ -13,11 +13,16 @@ extern func_ptr __CTOR_LIST__[];
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)
{
@@ -28,8 +33,9 @@ __do_global_dtors (void)
(*(p)) ();
p++;
}
- if (hMsvcrt)
+ if (free_Msvcrt && hMsvcrt)
{
+ free_Msvcrt = 0;
FreeLibrary (hMsvcrt);
hMsvcrt = NULL;
}
@@ -42,7 +48,15 @@ __do_global_ctors (void)
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");
}
diff --git a/lib/3rdparty/mingw/gs_support.c b/lib/3rdparty/mingw/gs_support.c
index 90bd8831cf9..12aa3f6cb88 100644
--- a/lib/3rdparty/mingw/gs_support.c
+++ b/lib/3rdparty/mingw/gs_support.c
@@ -1,7 +1,7 @@
/**
* 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
@@ -43,6 +43,8 @@ static const EXCEPTION_POINTERS GS_ExceptionPointers = {
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)
{
@@ -86,6 +88,8 @@ __security_init_cookie (void)
__security_cookie_complement = ~cookie;
}
+__declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
+
__declspec(noreturn) void __cdecl
__report_gsfailure (ULONGLONG StackCookie)
{
diff --git a/lib/3rdparty/mingw/isascii.c b/lib/3rdparty/mingw/isascii.c
new file mode 100644
index 00000000000..067b9969c8c
--- /dev/null
+++ b/lib/3rdparty/mingw/isascii.c
@@ -0,0 +1,16 @@
+/**
+ * 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
+
+#undef isascii
+int isascii (int);
+
+int
+isascii (int c)
+{
+ return __isascii(c);
+}
diff --git a/lib/3rdparty/mingw/iscsym.c b/lib/3rdparty/mingw/iscsym.c
new file mode 100644
index 00000000000..f98e990c331
--- /dev/null
+++ b/lib/3rdparty/mingw/iscsym.c
@@ -0,0 +1,16 @@
+/**
+ * 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
+#undef iscsym
+
+int iscsym (int);
+
+int
+iscsym (int c)
+{
+ return __iscsym(c);
+}
diff --git a/lib/3rdparty/mingw/iscsymf.c b/lib/3rdparty/mingw/iscsymf.c
new file mode 100644
index 00000000000..9ff88af9b2a
--- /dev/null
+++ b/lib/3rdparty/mingw/iscsymf.c
@@ -0,0 +1,16 @@
+/**
+ * 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
+#undef iscsymf
+
+int iscsymf (int);
+
+int
+iscsymf (int c)
+{
+ return __iscsymf(c);
+}
diff --git a/lib/3rdparty/mingw/merr.c b/lib/3rdparty/mingw/merr.c
index 2645e216e00..134e10fae62 100644
--- a/lib/3rdparty/mingw/merr.c
+++ b/lib/3rdparty/mingw/merr.c
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/lib/3rdparty/mingw/mingw_custom.c b/lib/3rdparty/mingw/mingw_custom.c
new file mode 100644
index 00000000000..59201987ceb
--- /dev/null
+++ b/lib/3rdparty/mingw/mingw_custom.c
@@ -0,0 +1,16 @@
+/**
+ * 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;
+}
+
diff --git a/lib/3rdparty/mingw/mingw_helpers.c b/lib/3rdparty/mingw/mingw_helpers.c
index 72103dca437..b1bafd35653 100644
--- a/lib/3rdparty/mingw/mingw_helpers.c
+++ b/lib/3rdparty/mingw/mingw_helpers.c
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/lib/3rdparty/mingw/moldname-msvcrt.def b/lib/3rdparty/mingw/moldname-msvcrt.def
index afd7694d40a..af6661fada4 100644
--- a/lib/3rdparty/mingw/moldname-msvcrt.def
+++ b/lib/3rdparty/mingw/moldname-msvcrt.def
@@ -1,118 +1,121 @@
+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
diff --git a/lib/3rdparty/mingw/natstart.c b/lib/3rdparty/mingw/natstart.c
index dfea54e4a36..1122d19f3de 100644
--- a/lib/3rdparty/mingw/natstart.c
+++ b/lib/3rdparty/mingw/natstart.c
@@ -1,7 +1,7 @@
/**
* 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
diff --git a/lib/3rdparty/mingw/ofmt_stub.c b/lib/3rdparty/mingw/ofmt_stub.c
new file mode 100644
index 00000000000..73e206dcf2b
--- /dev/null
+++ b/lib/3rdparty/mingw/ofmt_stub.c
@@ -0,0 +1,6 @@
+
+int _get_output_format(void)
+{
+ return 0;
+}
+
diff --git a/lib/3rdparty/mingw/pesect.c b/lib/3rdparty/mingw/pesect.c
index d9bbf55513c..60bbbc4c0d0 100644
--- a/lib/3rdparty/mingw/pesect.c
+++ b/lib/3rdparty/mingw/pesect.c
@@ -1,21 +1,24 @@
/**
* 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
+#include
#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;
@@ -34,6 +37,8 @@ _ValidateImageBase (PBYTE pImageBase)
return TRUE;
}
+PIMAGE_SECTION_HEADER _FindPESection (PBYTE, DWORD_PTR);
+
PIMAGE_SECTION_HEADER
_FindPESection (PBYTE pImageBase, DWORD_PTR rva)
{
@@ -54,7 +59,81 @@ _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;
diff --git a/lib/3rdparty/mingw/pseudo-reloc-list.c b/lib/3rdparty/mingw/pseudo-reloc-list.c
index b723bb8cb97..4ce46bbb29b 100644
--- a/lib/3rdparty/mingw/pseudo-reloc-list.c
+++ b/lib/3rdparty/mingw/pseudo-reloc-list.c
@@ -1,7 +1,7 @@
/**
* 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;
diff --git a/lib/3rdparty/mingw/pseudo-reloc.c b/lib/3rdparty/mingw/pseudo-reloc.c
index b107f62a68a..77f041114d7 100644
--- a/lib/3rdparty/mingw/pseudo-reloc.c
+++ b/lib/3rdparty/mingw/pseudo-reloc.c
@@ -1,23 +1,71 @@
-/**
- * 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
+ Modified by addition of runtime_pseudo_reloc version 2
+ by Kai Tietz
+
+ 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
#include
#include
+#include
#include
+#if defined(__CYGWIN__)
+#include
+#include
+#include
+/* 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;
@@ -25,25 +73,123 @@ typedef struct {
} 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[] = ": ";
+ 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);
}
@@ -52,64 +198,122 @@ __write_memory (void *addr,const void *src,size_t len)
#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;
@@ -120,13 +324,18 @@ do_pseudo_reloc (void* start,void *end,void *base)
#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;
@@ -141,16 +350,18 @@ do_pseudo_reloc (void* start,void *end,void *base)
__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__));
}
diff --git a/lib/3rdparty/mingw/reactos.diff b/lib/3rdparty/mingw/reactos.diff
new file mode 100644
index 00000000000..88d81ed1570
--- /dev/null
+++ b/lib/3rdparty/mingw/reactos.diff
@@ -0,0 +1,87 @@
+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
+ #include
+ #include
++#include
+
+ #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
diff --git a/lib/3rdparty/mingw/strcasecmp.c b/lib/3rdparty/mingw/strcasecmp.c
new file mode 100644
index 00000000000..17aba0b0b3c
--- /dev/null
+++ b/lib/3rdparty/mingw/strcasecmp.c
@@ -0,0 +1,16 @@
+/**
+ * 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
+
+#undef strcasecmp
+int strcasecmp (const char *, const char *);
+int
+strcasecmp (const char *sz1, const char *sz2)
+{
+ return _stricmp (sz1,sz2);
+}
diff --git a/lib/3rdparty/mingw/strncasecmp.c b/lib/3rdparty/mingw/strncasecmp.c
new file mode 100644
index 00000000000..b06afdac648
--- /dev/null
+++ b/lib/3rdparty/mingw/strncasecmp.c
@@ -0,0 +1,17 @@
+/**
+ * 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
+
+#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);
+}
diff --git a/lib/3rdparty/mingw/tlsmcrt.c b/lib/3rdparty/mingw/tlsmcrt.c
new file mode 100644
index 00000000000..2450b8b9216
--- /dev/null
+++ b/lib/3rdparty/mingw/tlsmcrt.c
@@ -0,0 +1,13 @@
+/**
+ * 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
+ */
+
+/* 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;
+
diff --git a/lib/3rdparty/mingw/tlsmthread.c b/lib/3rdparty/mingw/tlsmthread.c
new file mode 100644
index 00000000000..c018abfd21e
--- /dev/null
+++ b/lib/3rdparty/mingw/tlsmthread.c
@@ -0,0 +1,59 @@
+/**
+ * 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
+ */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include
+#include
+
+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;
+}
diff --git a/lib/3rdparty/mingw/tlssup.c b/lib/3rdparty/mingw/tlssup.c
index f933fa652dd..aec217dba5e 100644
--- a/lib/3rdparty/mingw/tlssup.c
+++ b/lib/3rdparty/mingw/tlssup.c
@@ -1,18 +1,32 @@
/**
* 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
*/
#ifdef CRTDLL
#undef CRTDLL
#endif
-#include
-#include
#include
+#include
+#include
#include
-#include
+
+#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
@@ -24,20 +38,21 @@ typedef struct TlsDtorNode {
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
};
@@ -47,38 +62,93 @@ _CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = {
#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;
@@ -96,29 +166,42 @@ __tlregdtor (_PVFV func)
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;
}
diff --git a/lib/3rdparty/mingw/tlsthrd.c b/lib/3rdparty/mingw/tlsthrd.c
new file mode 100644
index 00000000000..2e76727d20d
--- /dev/null
+++ b/lib/3rdparty/mingw/tlsthrd.c
@@ -0,0 +1,148 @@
+/**
+ * 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
+ *
+ * This file is used by if gcc is built with --enable-threads=win32.
+ *
+ * Based on version created by Mumit Khan
+ *
+ */
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include
+#include
+
+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;
+}
+
diff --git a/lib/3rdparty/mingw/toascii.c b/lib/3rdparty/mingw/toascii.c
new file mode 100644
index 00000000000..946b321af41
--- /dev/null
+++ b/lib/3rdparty/mingw/toascii.c
@@ -0,0 +1,17 @@
+/**
+ * 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
+
+#undef toascii
+
+int toascii (int);
+
+int
+toascii (int c)
+{
+ return __toascii(c);
+}
diff --git a/lib/3rdparty/mingw/txtmode.c b/lib/3rdparty/mingw/txtmode.c
new file mode 100644
index 00000000000..0c700ee1a19
--- /dev/null
+++ b/lib/3rdparty/mingw/txtmode.c
@@ -0,0 +1,13 @@
+/**
+ * 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
+
+/* Set default file mode to text */
+
+/* Is this correct? Default value of _fmode in msvcrt.dll is 0. */
+
+int _fmode = _O_TEXT;
diff --git a/lib/3rdparty/mingw/ucrtexe.c b/lib/3rdparty/mingw/ucrtexe.c
new file mode 100644
index 00000000000..76e0e0cc205
--- /dev/null
+++ b/lib/3rdparty/mingw/ucrtexe.c
@@ -0,0 +1,14 @@
+/**
+ * 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"
+
diff --git a/lib/3rdparty/mingw/udll_argv.c b/lib/3rdparty/mingw/udll_argv.c
new file mode 100644
index 00000000000..3511925afa2
--- /dev/null
+++ b/lib/3rdparty/mingw/udll_argv.c
@@ -0,0 +1,14 @@
+/**
+ * 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"
+
diff --git a/lib/3rdparty/mingw/udllargc.c b/lib/3rdparty/mingw/udllargc.c
new file mode 100644
index 00000000000..bcec7546726
--- /dev/null
+++ b/lib/3rdparty/mingw/udllargc.c
@@ -0,0 +1,14 @@
+/**
+ * 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"
+
diff --git a/lib/3rdparty/mingw/wcscmpi.c b/lib/3rdparty/mingw/wcscmpi.c
new file mode 100644
index 00000000000..2fce2b41706
--- /dev/null
+++ b/lib/3rdparty/mingw/wcscmpi.c
@@ -0,0 +1,17 @@
+/**
+ * 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
+
+#undef wcscmpi
+int wcscmpi (const wchar_t *, const wchar_t *);
+
+int
+wcscmpi (const wchar_t * ws1,const wchar_t * ws2)
+{
+ return _wcsicmp (ws1,ws2);
+}
diff --git a/lib/3rdparty/mingw/wildcard.c b/lib/3rdparty/mingw/wildcard.c
index bb7ff704e94..f996577bf27 100644
--- a/lib/3rdparty/mingw/wildcard.c
+++ b/lib/3rdparty/mingw/wildcard.c
@@ -1,7 +1,33 @@
/**
* 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;
+
diff --git a/lib/3rdparty/mingw/xncommod.c b/lib/3rdparty/mingw/xncommod.c
index 462c8267a68..f4efddb49ea 100644
--- a/lib/3rdparty/mingw/xncommod.c
+++ b/lib/3rdparty/mingw/xncommod.c
@@ -1,7 +1,7 @@
/**
* 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;
diff --git a/lib/3rdparty/mingw/xthdloc.c b/lib/3rdparty/mingw/xthdloc.c
index 1f7e59ac31e..285bc958037 100644
--- a/lib/3rdparty/mingw/xthdloc.c
+++ b/lib/3rdparty/mingw/xthdloc.c
@@ -1,7 +1,7 @@
/**
* 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;
diff --git a/lib/3rdparty/mingw/xtxtmode.c b/lib/3rdparty/mingw/xtxtmode.c
index 6f1a195a88f..6da7d6b9d63 100644
--- a/lib/3rdparty/mingw/xtxtmode.c
+++ b/lib/3rdparty/mingw/xtxtmode.c
@@ -1,7 +1,7 @@
/**
* 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;
diff --git a/lib/rtl/registry.c b/lib/rtl/registry.c
index e302590ebcc..d6e4458981b 100644
--- a/lib/rtl/registry.c
+++ b/lib/rtl/registry.c
@@ -474,13 +474,23 @@ RtlpGetRegistryHandle(IN ULONG RelativeTo,
/* 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
{
diff --git a/lib/rtl/rtl.rbuild b/lib/rtl/rtl.rbuild
index 0b15a1c8cda..5627f5f9cac 100644
--- a/lib/rtl/rtl.rbuild
+++ b/lib/rtl/rtl.rbuild
@@ -1,6 +1,6 @@
-
+
diff --git a/lib/sdk/crt/crt.rbuild b/lib/sdk/crt/crt.rbuild
index 7a6026cfc3d..c87fd5f81f4 100644
--- a/lib/sdk/crt/crt.rbuild
+++ b/lib/sdk/crt/crt.rbuild
@@ -25,6 +25,7 @@
+
cgets.c
cprintf.c
diff --git a/lib/sdk/crt/except/xcptfil.c b/lib/sdk/crt/except/xcptfil.c
index e617af5119e..e294e127a81 100644
--- a/lib/sdk/crt/except/xcptfil.c
+++ b/lib/sdk/crt/except/xcptfil.c
@@ -94,7 +94,7 @@ _XcptFilter(DWORD ExceptionCode,
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;
diff --git a/lib/sdk/crt/float/chgsign.c b/lib/sdk/crt/float/chgsign.c
index 2cc440ff9de..a9d9a1d3aed 100644
--- a/lib/sdk/crt/float/chgsign.c
+++ b/lib/sdk/crt/float/chgsign.c
@@ -20,7 +20,7 @@ double _chgsign( double __x )
union
{
double* __x;
- double_t *x;
+ double_s *x;
} u;
u.__x = &__x;
diff --git a/lib/sdk/crt/float/copysign.c b/lib/sdk/crt/float/copysign.c
index 992f82c3cea..5ebdeb1e854 100644
--- a/lib/sdk/crt/float/copysign.c
+++ b/lib/sdk/crt/float/copysign.c
@@ -19,12 +19,12 @@ double _copysign (double __d, double __s)
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;
diff --git a/lib/sdk/crt/float/fpclass.c b/lib/sdk/crt/float/fpclass.c
index 665379c21bf..6d61b4252f5 100644
--- a/lib/sdk/crt/float/fpclass.c
+++ b/lib/sdk/crt/float/fpclass.c
@@ -25,7 +25,7 @@
#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
@@ -38,7 +38,7 @@
#define FP_NNORM 0x0080 // negative normalized non-zero
#define FP_PNORM 0x0100 // positive normalized non-zero
-#endif
+//#endif
typedef int fpclass_t;
@@ -50,7 +50,7 @@ fpclass_t _fpclass(double __d)
union
{
double* __d;
- double_t* d;
+ double_s* d;
} d;
d.__d = &__d;
diff --git a/lib/sdk/crt/float/isnan.c b/lib/sdk/crt/float/isnan.c
index 1269df14e7e..fb328d30d97 100644
--- a/lib/sdk/crt/float/isnan.c
+++ b/lib/sdk/crt/float/isnan.c
@@ -28,7 +28,7 @@ int _isnan(double __x)
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 ));
@@ -41,7 +41,7 @@ int _isnanl(long double __x)
union
{
long double* __x;
- long_double_t* x;
+ long_double_s* x;
} x;
x.__x = &__x;
@@ -59,7 +59,7 @@ int _isinf(double __x)
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
@@ -81,7 +81,7 @@ int _isinfl(long double __x)
union
{
long double* __x;
- long_double_t* x;
+ long_double_s* x;
} x;
x.__x = &__x;
diff --git a/lib/sdk/crt/float/scalb.c b/lib/sdk/crt/float/scalb.c
index ac521d0e127..f147a6e03cc 100644
--- a/lib/sdk/crt/float/scalb.c
+++ b/lib/sdk/crt/float/scalb.c
@@ -19,7 +19,7 @@ double _scalb( double __x, long e )
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
diff --git a/lib/sdk/crt/include/internal/ieee.h b/lib/sdk/crt/include/internal/ieee.h
index f397723feae..bcc693d94a6 100644
--- a/lib/sdk/crt/include/internal/ieee.h
+++ b/lib/sdk/crt/include/internal/ieee.h
@@ -5,14 +5,14 @@ typedef struct {
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;
@@ -20,6 +20,6 @@ typedef struct {
unsigned int exponent:15;
unsigned int sign:1;
unsigned int empty:16;
-} long_double_t;
+} long_double_s;
#endif
diff --git a/lib/sdk/crt/libcntpr.rbuild b/lib/sdk/crt/libcntpr.rbuild
index de0bb3033e6..6156fe08242 100644
--- a/lib/sdk/crt/libcntpr.rbuild
+++ b/lib/sdk/crt/libcntpr.rbuild
@@ -7,6 +7,7 @@
+
"extern __attribute__ ((dllexport))"
diff --git a/lib/sdk/crt/math/frexp.c b/lib/sdk/crt/math/frexp.c
index 913cc5c7271..fa8de1e01da 100644
--- a/lib/sdk/crt/math/frexp.c
+++ b/lib/sdk/crt/math/frexp.c
@@ -11,7 +11,7 @@ frexp(double __x, int *exptr)
union
{
double* __x;
- double_t* x;
+ double_s* x;
} x;
x.__x = &__x;
diff --git a/lib/sdk/crt/math/huge_val.c b/lib/sdk/crt/math/huge_val.c
index 66b5716bf80..4bab35cf60c 100644
--- a/lib/sdk/crt/math/huge_val.c
+++ b/lib/sdk/crt/math/huge_val.c
@@ -3,4 +3,4 @@
#include
#undef _HUGE
-double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
+double_s _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
diff --git a/lib/sdk/crt/math/modf.c b/lib/sdk/crt/math/modf.c
index 72b937c36d5..8212070e2c8 100644
--- a/lib/sdk/crt/math/modf.c
+++ b/lib/sdk/crt/math/modf.c
@@ -21,12 +21,12 @@ long double modfl(long double __x, long double *__i)
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;
diff --git a/lib/sdk/crt/string/ctype.c b/lib/sdk/crt/string/ctype.c
index a4873cebdd4..28dcda5ab66 100644
--- a/lib/sdk/crt/string/ctype.c
+++ b/lib/sdk/crt/string/ctype.c
@@ -289,8 +289,267 @@ const unsigned short _ctype[] = {
0 /* 0xff */
};
+const unsigned short _wctype[] = {
+ 0, /* , 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
@@ -300,6 +559,11 @@ const unsigned short **__p__pctype(void)
return &_pctype;
}
+const unsigned short* __cdecl __pctype_func(void)
+{
+ return _pctype;
+}
+
/*
* @implemented
*/
@@ -308,6 +572,11 @@ const unsigned short **__p__pwctype(void)
return &_pwctype;
}
+const unsigned short* __cdecl __pwctype_func(void)
+{
+ return _pwctype;
+}
+
int _isctype (int c, int ctypeFlags)
{
return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags);
diff --git a/media/inf/bda.inf b/media/inf/bda.inf
new file mode 100644
index 00000000000..dab09018b89
Binary files /dev/null and b/media/inf/bda.inf differ
diff --git a/media/inf/cpu.inf b/media/inf/cpu.inf
index 7f5dc35d4bb..bc2517dcaa0 100644
Binary files a/media/inf/cpu.inf and b/media/inf/cpu.inf differ
diff --git a/media/inf/inf.rbuild b/media/inf/inf.rbuild
index 34d024bee2b..4acd24b101f 100644
--- a/media/inf/inf.rbuild
+++ b/media/inf/inf.rbuild
@@ -4,6 +4,7 @@
acpi.inf
audio.inf
battery.inf
+ bda.inf
cdrom.inf
cpu.inf
display.inf
@@ -13,6 +14,7 @@
intl.inf
keyboard.inf
ks.inf
+ kscaptur.inf
layout.inf
machine.inf
msmouse.inf
diff --git a/media/inf/kscaptur.inf b/media/inf/kscaptur.inf
new file mode 100644
index 00000000000..aa93ffb61b5
Binary files /dev/null and b/media/inf/kscaptur.inf differ
diff --git a/media/inf/machine.inf b/media/inf/machine.inf
index 7b7e0a9d302..ecc90375e8d 100644
Binary files a/media/inf/machine.inf and b/media/inf/machine.inf differ
diff --git a/ntoskrnl/config/cmhvlist.c b/ntoskrnl/config/cmhvlist.c
new file mode 100644
index 00000000000..f4e97814bbd
--- /dev/null
+++ b/ntoskrnl/config/cmhvlist.c
@@ -0,0 +1,17 @@
+/*
+ * 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
diff --git a/ntoskrnl/config/cmnotify.c b/ntoskrnl/config/cmnotify.c
new file mode 100644
index 00000000000..afb5d4dfecb
--- /dev/null
+++ b/ntoskrnl/config/cmnotify.c
@@ -0,0 +1,36 @@
+/*
+ * 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;
+}
+
diff --git a/ntoskrnl/config/cmquota.c b/ntoskrnl/config/cmquota.c
new file mode 100644
index 00000000000..b5c5a582167
--- /dev/null
+++ b/ntoskrnl/config/cmquota.c
@@ -0,0 +1,26 @@
+/*
+ * 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;
+}
diff --git a/ntoskrnl/config/cmsysini.c b/ntoskrnl/config/cmsysini.c
index ab3b1d46bb1..0326e88e619 100644
--- a/ntoskrnl/config/cmsysini.c
+++ b/ntoskrnl/config/cmsysini.c
@@ -27,6 +27,7 @@ BOOLEAN CmpFlushOnLockRelease;
BOOLEAN CmpSpecialBootCondition;
BOOLEAN CmpNoWrite;
BOOLEAN CmpWasSetupBoot;
+BOOLEAN CmpProfileLoaded;
ULONG CmpTraceLevel = 0;
extern LONG CmpFlushStarveWriters;
@@ -1622,6 +1623,56 @@ CmpTestRegistryLockExclusive(VOID)
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)
diff --git a/ntoskrnl/include/internal/amd64/asmmacro.S b/ntoskrnl/include/internal/amd64/asmmacro.S
new file mode 100644
index 00000000000..9d7a1807321
--- /dev/null
+++ b/ntoskrnl/include/internal/amd64/asmmacro.S
@@ -0,0 +1,81 @@
+/*
+ * 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__,
+
diff --git a/ntoskrnl/include/internal/amd64/intrin_i.h b/ntoskrnl/include/internal/amd64/intrin_i.h
new file mode 100644
index 00000000000..d3dca40eaf2
--- /dev/null
+++ b/ntoskrnl/include/internal/amd64/intrin_i.h
@@ -0,0 +1,128 @@
+#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 */
diff --git a/ntoskrnl/include/internal/amd64/ke.h b/ntoskrnl/include/internal/amd64/ke.h
new file mode 100644
index 00000000000..2e43edc248d
--- /dev/null
+++ b/ntoskrnl/include/internal/amd64/ke.h
@@ -0,0 +1,268 @@
+#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 */
diff --git a/ntoskrnl/include/internal/amd64/mm.h b/ntoskrnl/include/internal/amd64/mm.h
new file mode 100644
index 00000000000..6f0b2fd390c
--- /dev/null
+++ b/ntoskrnl/include/internal/amd64/mm.h
@@ -0,0 +1,189 @@
+/*
+ * 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
+
diff --git a/ntoskrnl/include/internal/arch/intrin_i.h b/ntoskrnl/include/internal/arch/intrin_i.h
index f8ce285678c..7d6dfab3557 100644
--- a/ntoskrnl/include/internal/arch/intrin_i.h
+++ b/ntoskrnl/include/internal/arch/intrin_i.h
@@ -27,6 +27,8 @@
#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
diff --git a/ntoskrnl/include/internal/arch/ke.h b/ntoskrnl/include/internal/arch/ke.h
index ef8a27bd951..3e1b8a5b290 100644
--- a/ntoskrnl/include/internal/arch/ke.h
+++ b/ntoskrnl/include/internal/arch/ke.h
@@ -27,6 +27,8 @@
#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
diff --git a/ntoskrnl/include/internal/arch/mm.h b/ntoskrnl/include/internal/arch/mm.h
index a2a97919259..f5ee0276ca2 100644
--- a/ntoskrnl/include/internal/arch/mm.h
+++ b/ntoskrnl/include/internal/arch/mm.h
@@ -27,6 +27,8 @@
#include
#elif defined(_M_ARM)
#include
+#elif defined(_M_AMD64)
+#include
#else
#error "Unknown processor"
#endif
diff --git a/ntoskrnl/include/internal/cm.h b/ntoskrnl/include/internal/cm.h
index 537111a4f29..4880dc08026 100644
--- a/ntoskrnl/include/internal/cm.h
+++ b/ntoskrnl/include/internal/cm.h
@@ -621,6 +621,24 @@ CmCheckRegistry(
IN ULONG Flags
);
+//
+// Hive List Routines
+//
+NTSTATUS
+NTAPI
+CmpAddToHiveFileList(
+ IN PCMHIVE Hive
+);
+
+//
+// Quota Routines
+//
+VOID
+NTAPI
+CmpSetGlobalQuotaAllowed(
+ VOID
+);
+
//
// Notification Routines
//
@@ -633,6 +651,13 @@ CmpReportNotify(
IN ULONG Filter
);
+VOID
+NTAPI
+CmpFlushNotify(
+ IN PCM_KEY_BODY KeyBody,
+ IN BOOLEAN LockHeld
+);
+
VOID
NTAPI
CmpInitCallback(
@@ -822,6 +847,36 @@ CmpUnlockRegistry(
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
//
@@ -978,6 +1033,13 @@ CmpReleaseTwoKcbLockByKey(
IN ULONG ConvKey2
);
+VOID
+NTAPI
+CmpFlushNotifiesOnKeyBodyList(
+ IN PCM_KEY_CONTROL_BLOCK Kcb,
+ IN BOOLEAN LockHeld
+);
+
//
// Name Functions
//
@@ -1507,6 +1569,7 @@ extern ULONG CmpDelayedCloseSize, CmpDelayedCloseIndex;
extern BOOLEAN CmpNoWrite;
extern BOOLEAN CmpForceForceFlush;
extern BOOLEAN CmpWasSetupBoot;
+extern BOOLEAN CmpProfileLoaded;
extern PCMHIVE CmiVolatileHive;
extern LIST_ENTRY CmiKeyObjectListHead;
extern BOOLEAN CmpHoldLazyFlush;
diff --git a/ntoskrnl/include/internal/cm_x.h b/ntoskrnl/include/internal/cm_x.h
index 581a336d636..02e84219635 100644
--- a/ntoskrnl/include/internal/cm_x.h
+++ b/ntoskrnl/include/internal/cm_x.h
@@ -91,6 +91,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive,
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
//
@@ -98,6 +106,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive,
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
//
@@ -255,6 +271,47 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
(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
//
diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index c8b671693af..2519a8134d2 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -852,7 +852,8 @@ PnpRootDriverEntry(
NTSTATUS
PnpRootCreateDevice(
IN PUNICODE_STRING ServiceName,
- IN OUT PDEVICE_OBJECT *PhysicalDeviceObject
+ OUT PDEVICE_OBJECT *PhysicalDeviceObject,
+ OUT OPTIONAL PUNICODE_STRING FullInstancePath
);
//
diff --git a/ntoskrnl/io/iomgr/deviface.c b/ntoskrnl/io/iomgr/deviface.c
index cc6d5444de3..2b0789b5a60 100644
--- a/ntoskrnl/io/iomgr/deviface.c
+++ b/ntoskrnl/io/iomgr/deviface.c
@@ -50,7 +50,169 @@ IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName,
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;
}
/*++
diff --git a/ntoskrnl/io/pnpmgr/pnpmgr.c b/ntoskrnl/io/pnpmgr/pnpmgr.c
index 9cd6347e957..44283968d0c 100644
--- a/ntoskrnl/io/pnpmgr/pnpmgr.c
+++ b/ntoskrnl/io/pnpmgr/pnpmgr.c
@@ -13,7 +13,7 @@
#define NDEBUG
#include
-#define ENABLE_ACPI
+//#define ENABLE_ACPI
/* GLOBALS *******************************************************************/
@@ -46,15 +46,25 @@ typedef struct _INVALIDATE_DEVICE_RELATION_DATA
/* 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)
@@ -136,6 +146,9 @@ IopStartDevice(
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");
@@ -150,7 +163,7 @@ IopStartDevice(
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))
@@ -158,7 +171,11 @@ IopStartDevice(
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
{
@@ -206,9 +223,32 @@ IopStartDevice(
}
}
+ 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;
}
@@ -361,6 +401,10 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
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);
@@ -373,9 +417,24 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
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);
@@ -383,6 +442,13 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
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);
@@ -708,8 +774,135 @@ IopCreateDeviceKeyPath(IN PCUNICODE_STRING RegistryPath,
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)
@@ -720,6 +913,7 @@ IopSetDeviceInstanceData(HANDLE InstanceKey,
ULONG ResCount;
ULONG ListSize, ResultLength;
NTSTATUS Status;
+ HANDLE ControlHandle;
DPRINT("IopSetDeviceInstanceData() called\n");
@@ -793,13 +987,367 @@ IopSetDeviceInstanceData(HANDLE InstanceKey,
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;
-static NTSTATUS
+ 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;
+ }
+
+ 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)
@@ -850,6 +1398,10 @@ IopAssignDeviceResources(
}
RtlCopyMemory(DeviceNode->ResourceList, DeviceNode->BootResources, Size);
+ Status = IopDetectResourceConflict(DeviceNode->ResourceList);
+ if (!NT_SUCCESS(Status))
+ goto ByeBye;
+
*pRequiredSize = Size;
return STATUS_SUCCESS;
}
@@ -1000,6 +1552,10 @@ IopAssignDeviceResources(
DeviceNode->ResourceList->List[0].PartialResourceList.Count = NumberOfResources;
+ Status = IopDetectResourceConflict(DeviceNode->ResourceList);
+ if (!NT_SUCCESS(Status))
+ goto ByeBye;
+
*pRequiredSize = Size;
return STATUS_SUCCESS;
@@ -1014,7 +1570,7 @@ ByeBye:
}
-static NTSTATUS
+NTSTATUS
IopTranslateDeviceResources(
IN PDEVICE_NODE DeviceNode,
IN ULONG RequiredSize)
@@ -2166,11 +2722,6 @@ IopEnumerateDetectedDevices(
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;
@@ -2180,9 +2731,19 @@ IopEnumerateDetectedDevices(
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)
{
@@ -2409,16 +2970,31 @@ IopEnumerateDetectedDevices(
{
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))
{
@@ -2427,17 +3003,16 @@ IopEnumerateDetectedDevices(
{
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;
}
@@ -2486,12 +3061,15 @@ IopEnumerateDetectedDevices(
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))
@@ -2581,7 +3159,7 @@ IopIsAcpiComputer(VOID)
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))
{
@@ -2736,12 +3314,12 @@ IopUpdateRootKey(VOID)
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;
@@ -3030,7 +3608,7 @@ PpInitSystem(VOID)
/* PUBLIC FUNCTIONS **********************************************************/
/*
- * @unimplemented
+ * @implemented
*/
NTSTATUS
NTAPI
@@ -3046,6 +3624,8 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
PVOID Data = NULL;
PWSTR Ptr;
NTSTATUS Status;
+ POBJECT_NAME_INFORMATION ObjectNameInfo = NULL;
+ ULONG RequiredLength, ObjectNameInfoLength;
DPRINT("IoGetDeviceProperty(0x%p %d)\n", DeviceObject, DeviceProperty);
@@ -3259,9 +3839,36 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
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:
@@ -3271,13 +3878,22 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject,
/* 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;
}
diff --git a/ntoskrnl/io/pnpmgr/pnpreport.c b/ntoskrnl/io/pnpmgr/pnpreport.c
index e11c4b0263e..c75e566b0d4 100644
--- a/ntoskrnl/io/pnpmgr/pnpreport.c
+++ b/ntoskrnl/io/pnpmgr/pnpreport.c
@@ -3,7 +3,7 @@
* 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 ******************************************************************/
@@ -12,6 +12,98 @@
#define NDEBUG
#include
+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 **********************************************************/
/*
@@ -30,29 +122,57 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
{
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 the PDO */
+ Status = PnpRootCreateDevice(&ServiceName,
+ &Pdo,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("PnpRootCreateDevice() failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
- /* create a new PDO and return it in *DeviceObject */
+ /* Create the device node for the new PDO */
Status = IopCreateDeviceNode(IopRootDeviceNode,
+ Pdo,
NULL,
- &ServiceName,
&DeviceNode);
if (!NT_SUCCESS(Status))
@@ -60,17 +180,133 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject,
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
@@ -82,23 +318,35 @@ IoReportResourceForDetection(IN PDRIVER_OBJECT DriverObject,
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 */
+
+ /* TODO: Claim the resources in the ResourceMap */
}
- return STATUS_SUCCESS;
+ return Status;
}
VOID
diff --git a/ntoskrnl/io/pnpmgr/pnproot.c b/ntoskrnl/io/pnpmgr/pnproot.c
index 5a5bf85c3eb..a5fa2a04f0c 100644
--- a/ntoskrnl/io/pnpmgr/pnproot.c
+++ b/ntoskrnl/io/pnpmgr/pnproot.c
@@ -131,30 +131,25 @@ LocateChildDevice(
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);
@@ -164,7 +159,7 @@ PnpRootCreateDevice(
}
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;
}
@@ -189,6 +184,22 @@ PnpRootCreateDevice(
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,
diff --git a/ntoskrnl/ntoskrnl-generic.rbuild b/ntoskrnl/ntoskrnl-generic.rbuild
index 0427f1bceeb..a605ee1b147 100644
--- a/ntoskrnl/ntoskrnl-generic.rbuild
+++ b/ntoskrnl/ntoskrnl-generic.rbuild
@@ -144,13 +144,16 @@
cmdelay.c
cmindex.c
cminit.c
+ cmhvlist.c
cmhook.c
cmkcbncb.c
cmkeydel.c
cmlazy.c
cmmapvw.c
cmname.c
+ cmnotify.c
cmparse.c
+ cmquota.c
cmse.c
cmsecach.c
cmsysini.c
diff --git a/ntoskrnl/ntoskrnl.pspec b/ntoskrnl/ntoskrnl.pspec
index 68e79a20741..5016dbd2b87 100644
--- a/ntoskrnl/ntoskrnl.pspec
+++ b/ntoskrnl/ntoskrnl.pspec
@@ -1,4 +1,5 @@
#include
+#undef i386
@ stdcall CcCanIWrite(ptr long long long)
@ stdcall CcCopyRead(ptr ptr long long ptr ptr)
@@ -55,6 +56,7 @@
@ 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)
@@ -101,26 +103,37 @@
@ 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()
@@ -132,6 +145,7 @@
@ 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)
@@ -149,6 +163,7 @@
@ stdcall ExSizeOfRundownProtectionCacheAware()
@ stdcall ExSystemExceptionFilter()
@ stdcall ExSystemTimeToLocalTime(ptr ptr)
+@ stdcall -arch=x86_64 ExTryToAcquireFastMutex(ptr)
@ stdcall ExUnregisterCallback(ptr)
@ stdcall ExUuidCreate(ptr)
@ stdcall ExVerifySuite(long)
@@ -157,6 +172,7 @@
@ 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)
@@ -164,22 +180,24 @@
@ 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)
@@ -316,6 +334,7 @@
@ 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)
@@ -323,6 +342,9 @@
@ 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)
@@ -536,12 +558,10 @@
@ 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)
@@ -549,6 +569,7 @@
@ 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()
@@ -576,18 +597,16 @@
@ 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)
@@ -599,7 +618,9 @@
@ 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)
@@ -622,10 +643,14 @@
@ 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)
@@ -646,6 +671,9 @@
@ 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)
@@ -695,21 +723,15 @@
@ 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)
@@ -1021,12 +1043,14 @@
@ 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)
@@ -1273,8 +1297,10 @@
;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)
@@ -1297,7 +1323,9 @@
@ 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)
@@ -1368,12 +1396,14 @@
;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
@@ -1512,26 +1542,30 @@
;_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()
diff --git a/ntoskrnl/se/semgr.c b/ntoskrnl/se/semgr.c
index 38b1274970c..d06fb04bbb6 100644
--- a/ntoskrnl/se/semgr.c
+++ b/ntoskrnl/se/semgr.c
@@ -355,15 +355,13 @@ SeSetSecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation,
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;
@@ -377,6 +375,238 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
NTSTATUS Status;
PAGED_CODE();
+ /* Check for no access desired */
+ if (!DesiredAccess)
+ {
+ /* Check if we had no previous access */
+ if (!PreviouslyGrantedAccess)
+ {
+ /* Then there's nothing to give */
+ *AccessStatus = STATUS_ACCESS_DENIED;
+ return FALSE;
+ }
+
+ /* Return the previous access only */
+ *GrantedAccess = PreviouslyGrantedAccess;
+ *AccessStatus = STATUS_SUCCESS;
+ *Privileges = NULL;
+ return TRUE;
+ }
+
+ /* Map given accesses */
+ RtlMapGenericMask(&DesiredAccess, GenericMapping);
+ if (PreviouslyGrantedAccess)
+ RtlMapGenericMask(&PreviouslyGrantedAccess, GenericMapping);
+
+
+
+ CurrentAccess = PreviouslyGrantedAccess;
+
+
+
+ Token = SubjectSecurityContext->ClientToken ?
+ SubjectSecurityContext->ClientToken : SubjectSecurityContext->PrimaryToken;
+
+ /* Get the DACL */
+ Status = RtlGetDaclSecurityDescriptor(SecurityDescriptor,
+ &Present,
+ &Dacl,
+ &Defaulted);
+ if (!NT_SUCCESS(Status))
+ {
+ *AccessStatus = Status;
+ return FALSE;
+ }
+
+ /* RULE 1: Grant desired access if the object is unprotected */
+ if (Present == FALSE || Dacl == NULL)
+ {
+ if (DesiredAccess & MAXIMUM_ALLOWED)
+ {
+ *GrantedAccess = GenericMapping->GenericAll;
+ *GrantedAccess |= (DesiredAccess & ~MAXIMUM_ALLOWED);
+ }
+ else
+ {
+ *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess;
+ }
+
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+
+ CurrentAccess = PreviouslyGrantedAccess;
+
+ /* RULE 2: Check token for 'take ownership' privilege */
+ Privilege.Luid = SeTakeOwnershipPrivilege;
+ Privilege.Attributes = SE_PRIVILEGE_ENABLED;
+
+ if (SepPrivilegeCheck(Token,
+ &Privilege,
+ 1,
+ PRIVILEGE_SET_ALL_NECESSARY,
+ AccessMode))
+ {
+ CurrentAccess |= WRITE_OWNER;
+ if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
+ (CurrentAccess & ~VALID_INHERIT_FLAGS))
+ {
+ *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,
+ &Defaulted);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status);
+ *AccessStatus = Status;
+ return FALSE;
+ }
+
+ if (Sid && SepSidInToken(Token, Sid))
+ {
+ CurrentAccess |= (READ_CONTROL | WRITE_DAC);
+ if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
+ (CurrentAccess & ~VALID_INHERIT_FLAGS))
+ {
+ *GrantedAccess = CurrentAccess;
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+ }
+
+ /* Fail if DACL is absent */
+ if (Present == FALSE)
+ {
+ *GrantedAccess = 0;
+ *AccessStatus = STATUS_ACCESS_DENIED;
+ return FALSE;
+ }
+
+ /* RULE 4: Grant rights according to the DACL */
+ CurrentAce = (PACE)(Dacl + 1);
+ for (i = 0; i < Dacl->AceCount; i++)
+ {
+ Sid = (PSID)(CurrentAce + 1);
+ if (CurrentAce->Header.AceType == ACCESS_DENIED_ACE_TYPE)
+ {
+ if (SepSidInToken(Token, Sid))
+ {
+ *GrantedAccess = 0;
+ *AccessStatus = STATUS_ACCESS_DENIED;
+ return FALSE;
+ }
+ }
+
+ else if (CurrentAce->Header.AceType == ACCESS_ALLOWED_ACE_TYPE)
+ {
+ if (SepSidInToken(Token, Sid))
+ {
+ AccessMask = CurrentAce->AccessMask;
+ RtlMapGenericMask(&AccessMask, GenericMapping);
+ CurrentAccess |= AccessMask;
+ }
+ }
+ else
+ {
+ DPRINT1("Unknown Ace type 0x%lx\n", CurrentAce->Header.AceType);
+ }
+ CurrentAce = (PACE)((ULONG_PTR)CurrentAce + CurrentAce->Header.AceSize);
+ }
+
+ DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
+ CurrentAccess, DesiredAccess);
+
+ *GrantedAccess = CurrentAccess & DesiredAccess;
+
+ if (DesiredAccess & MAXIMUM_ALLOWED)
+ {
+ *GrantedAccess = CurrentAccess;
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+ else if ((*GrantedAccess & ~VALID_INHERIT_FLAGS) ==
+ (DesiredAccess & ~VALID_INHERIT_FLAGS))
+ {
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+ else
+ {
+ DPRINT1("HACK: Should deny access for caller: granted 0x%lx, desired 0x%lx (generic mapping %p).\n",
+ *GrantedAccess, DesiredAccess, GenericMapping);
+ //*AccessStatus = STATUS_ACCESS_DENIED;
+ //return FALSE;
+ *AccessStatus = STATUS_SUCCESS;
+ return TRUE;
+ }
+}
+
+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 ***********************************************************/
+
+/*
+ * @implemented
+ */
+BOOLEAN NTAPI
+SeAccessCheck(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)
+{
+ BOOLEAN ret;
+
+ PAGED_CODE();
+
/* Check if this is kernel mode */
if (AccessMode == KernelMode)
{
@@ -409,256 +639,32 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
/* Check for invalid impersonation */
if ((SubjectSecurityContext->ClientToken) &&
- (SubjectSecurityContext->ImpersonationLevel < LowestImpersonationLevel))
+ (SubjectSecurityContext->ImpersonationLevel < SecurityImpersonation))
{
*AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL;
return FALSE;
}
- /* Check for no access desired */
- if (!DesiredAccess)
- {
- /* Check if we had no previous access */
- if (!PreviouslyGrantedAccess)
- {
- /* Then there's nothing to give */
- *AccessStatus = STATUS_ACCESS_DENIED;
- return FALSE;
- }
-
- /* Return the previous access only */
- *GrantedAccess = PreviouslyGrantedAccess;
- *AccessStatus = STATUS_SUCCESS;
- *Privileges = NULL;
- return TRUE;
- }
-
/* Acquire the lock if needed */
- if (!SubjectContextLocked) SeLockSubjectContext(SubjectSecurityContext);
+ if (!SubjectContextLocked)
+ SeLockSubjectContext(SubjectSecurityContext);
- /* Map given accesses */
- RtlMapGenericMask(&DesiredAccess, GenericMapping);
- if (PreviouslyGrantedAccess)
- RtlMapGenericMask(&PreviouslyGrantedAccess, GenericMapping);
-
-
-
- CurrentAccess = PreviouslyGrantedAccess;
-
-
-
- Token = SubjectSecurityContext->ClientToken ?
- SubjectSecurityContext->ClientToken : SubjectSecurityContext->PrimaryToken;
-
- /* Get the DACL */
- Status = RtlGetDaclSecurityDescriptor(SecurityDescriptor,
- &Present,
- &Dacl,
- &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 (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
- if (DesiredAccess & MAXIMUM_ALLOWED)
- {
- *GrantedAccess = GenericMapping->GenericAll;
- *GrantedAccess |= (DesiredAccess & ~MAXIMUM_ALLOWED);
- }
- else
- {
- *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess;
- }
-
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
-
- CurrentAccess = PreviouslyGrantedAccess;
-
- /* RULE 2: Check token for 'take ownership' privilege */
- Privilege.Luid = SeTakeOwnershipPrivilege;
- Privilege.Attributes = SE_PRIVILEGE_ENABLED;
-
- if (SepPrivilegeCheck(Token,
- &Privilege,
- 1,
- PRIVILEGE_SET_ALL_NECESSARY,
- AccessMode))
- {
- CurrentAccess |= WRITE_OWNER;
- if ((DesiredAccess & ~VALID_INHERIT_FLAGS) ==
- (CurrentAccess & ~VALID_INHERIT_FLAGS))
- {
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
- *GrantedAccess = CurrentAccess;
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
- }
-
- /* RULE 3: Check whether the token is the owner */
- Status = RtlGetOwnerSecurityDescriptor(SecurityDescriptor,
- &Sid,
- &Defaulted);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status);
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
- *AccessStatus = Status;
- return FALSE;
- }
-
- if (Sid && SepSidInToken(Token, Sid))
- {
- CurrentAccess |= (READ_CONTROL | WRITE_DAC);
- 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;
- }
-
- /* RULE 4: Grant rights according to the DACL */
- CurrentAce = (PACE)(Dacl + 1);
- for (i = 0; i < Dacl->AceCount; i++)
- {
- Sid = (PSID)(CurrentAce + 1);
- if (CurrentAce->Header.AceType == ACCESS_DENIED_ACE_TYPE)
- {
- if (SepSidInToken(Token, Sid))
- {
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
- *GrantedAccess = 0;
- *AccessStatus = STATUS_ACCESS_DENIED;
- return FALSE;
- }
- }
-
- else if (CurrentAce->Header.AceType == ACCESS_ALLOWED_ACE_TYPE)
- {
- if (SepSidInToken(Token, Sid))
- {
- AccessMask = CurrentAce->AccessMask;
- RtlMapGenericMask(&AccessMask, GenericMapping);
- CurrentAccess |= AccessMask;
- }
- }
- else
- {
- DPRINT1("Unknown Ace type 0x%lx\n", CurrentAce->Header.AceType);
- }
- CurrentAce = (PACE)((ULONG_PTR)CurrentAce + CurrentAce->Header.AceSize);
- }
-
- if (SubjectContextLocked == FALSE)
- {
- SeUnlockSubjectContext(SubjectSecurityContext);
- }
-
- DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n",
- CurrentAccess, DesiredAccess);
-
- *GrantedAccess = CurrentAccess & DesiredAccess;
-
- if (DesiredAccess & MAXIMUM_ALLOWED)
- {
- *GrantedAccess = CurrentAccess;
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
- else if ((*GrantedAccess & ~VALID_INHERIT_FLAGS) ==
- (DesiredAccess & ~VALID_INHERIT_FLAGS))
- {
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
- else
- {
- DPRINT1("HACK: Should deny access for caller: granted 0x%lx, desired 0x%lx (generic mapping %p).\n",
- *GrantedAccess, DesiredAccess, GenericMapping);
- //*AccessStatus = STATUS_ACCESS_DENIED;
- //return FALSE;
- *AccessStatus = STATUS_SUCCESS;
- return TRUE;
- }
-}
-
-/* PUBLIC FUNCTIONS ***********************************************************/
-
-/*
- * @implemented
- */
-BOOLEAN NTAPI
-SeAccessCheck(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)
-{
/* 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 ***************************************************************/
@@ -677,6 +683,7 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PACCESS_MASK GrantedAccess,
OUT PNTSTATUS AccessStatus)
{
+ PSECURITY_DESCRIPTOR CapturedSecurityDescriptor = NULL;
SECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
PTOKEN Token;
@@ -734,14 +741,14 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
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;
}
@@ -749,11 +756,44 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
/* 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;
@@ -762,20 +802,25 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
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 */
diff --git a/subsystems/win32/win32k/include/timer.h b/subsystems/win32/win32k/include/timer.h
index 73b2c36afae..2b65b0e55d8 100644
--- a/subsystems/win32/win32k/include/timer.h
+++ b/subsystems/win32/win32k/include/timer.h
@@ -32,7 +32,7 @@ UINT_PTR FASTCALL IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC
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);
diff --git a/subsystems/win32/win32k/include/winpos.h b/subsystems/win32/win32k/include/winpos.h
index 47f6b389cec..9bb6cfffaba 100644
--- a/subsystems/win32/win32k/include/winpos.h
+++ b/subsystems/win32/win32k/include/winpos.h
@@ -1,9 +1,5 @@
#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 && \
diff --git a/subsystems/win32/win32k/ntuser/timer.c b/subsystems/win32/win32k/ntuser/timer.c
index b65a2ebfb61..c706805a9c8 100644
--- a/subsystems/win32/win32k/ntuser/timer.c
+++ b/subsystems/win32/win32k/ntuser/timer.c
@@ -253,7 +253,7 @@ StartTheTimers(VOID)
UINT_PTR
FASTCALL
-SetSystemTimer( PWINDOW_OBJECT Window,
+SystemTimerSet( PWINDOW_OBJECT Window,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc)
diff --git a/subsystems/win32/win32k/ntuser/windc.c b/subsystems/win32/win32k/ntuser/windc.c
index 0b5386597f9..bde42e1396c 100644
--- a/subsystems/win32/win32k/ntuser/windc.c
+++ b/subsystems/win32/win32k/ntuser/windc.c
@@ -643,6 +643,11 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
Hit = TRUE;
}
}
+ else
+ {
+ if (!GreGetObjectOwner(pdce->hDC, GDIObjType_DC_TYPE))
+ DC_SetOwnership( pdce->hDC, PsGetCurrentProcess());
+ }
if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE);