Sync with trunk (r48545)
authorJérôme Gardou <jerome.gardou@reactos.org>
Sat, 14 Aug 2010 15:15:44 +0000 (15:15 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sat, 14 Aug 2010 15:15:44 +0000 (15:15 +0000)
svn path=/branches/reactos-yarotows/; revision=48547

183 files changed:
base/applications/taskmgr/applpage.c
base/applications/taskmgr/debug.c
base/applications/taskmgr/endproc.c
base/applications/taskmgr/graph.c
base/applications/taskmgr/graphctl.c
base/applications/taskmgr/graphctl.h
base/applications/taskmgr/optnmenu.c
base/applications/taskmgr/perfdata.c
base/applications/taskmgr/perfpage.c
base/applications/taskmgr/procpage.c
base/applications/taskmgr/taskmgr.c
base/applications/taskmgr/taskmgr.h
base/system/winlogon/winlogon.c
dll/win32/dhcpcsvc/dhcp/adapter.c
dll/win32/iphlpapi/iphlpapi_main.c
dll/win32/iphlpapi/iphlpapi_private.h
dll/win32/kernel32/file/backup.c
dll/win32/kernel32/file/bintype.c
dll/win32/kernel32/file/cnotify.c
dll/win32/kernel32/file/copy.c
dll/win32/kernel32/file/create.c
dll/win32/kernel32/file/curdir.c
dll/win32/kernel32/file/delete.c
dll/win32/kernel32/file/deviceio.c
dll/win32/kernel32/file/dir.c
dll/win32/kernel32/file/dosdev.c
dll/win32/kernel32/file/file.c
dll/win32/kernel32/file/find.c
dll/win32/kernel32/file/hardlink.c
dll/win32/kernel32/file/iocompl.c
dll/win32/kernel32/file/lfile.c
dll/win32/kernel32/file/lock.c
dll/win32/kernel32/file/mailslot.c
dll/win32/kernel32/file/move.c
dll/win32/kernel32/file/npipe.c
dll/win32/kernel32/file/pipe.c
dll/win32/kernel32/file/rw.c
dll/win32/kernel32/file/tape.c
dll/win32/kernel32/file/volume.c
dll/win32/kernel32/include/kernel32.h
dll/win32/kernel32/kernel32.def [new file with mode: 0644]
dll/win32/kernel32/kernel32.pspec
dll/win32/kernel32/kernel32.rbuild
dll/win32/kernel32/misc/actctx.c
dll/win32/kernel32/misc/console.c
dll/win32/kernel32/misc/format_msg.c
dll/win32/kernel32/misc/lcformat.c
dll/win32/kernel32/misc/profile.c
dll/win32/kernel32/misc/stubs.c
dll/win32/kernel32/misc/version.c
dll/win32/kernel32/process/session.c
dll/win32/msafd/misc/dllmain.c
dll/win32/msvcrt/msvcrt.spec
dll/win32/shell32/iconcache.c
dll/win32/shlwapi/string.c
dll/win32/ws2_32/misc/dllmain.c
drivers/bus/pcix/device.c
drivers/bus/pcix/enum.c
drivers/bus/pcix/pci.h
drivers/bus/pcix/utils.c
drivers/filesystems/cdfs/fsctl.c
drivers/filesystems/cdfs/misc.c
drivers/filesystems/fastfat/create.c
drivers/filesystems/fastfat_new/cleanup.c
drivers/filesystems/fastfat_new/close.c
drivers/filesystems/fastfat_new/create.c
drivers/filesystems/fastfat_new/dir.c
drivers/filesystems/fastfat_new/fastfat.c
drivers/filesystems/fastfat_new/fastfat.h
drivers/filesystems/fastfat_new/fat.c
drivers/filesystems/fastfat_new/fatstruc.h
drivers/filesystems/fastfat_new/fcb.c
drivers/filesystems/fastfat_new/finfo.c
drivers/filesystems/fastfat_new/fsctl.c
drivers/filesystems/fastfat_new/lock.c
drivers/filesystems/fastfat_new/rw.c
drivers/filesystems/fastfat_new/volume.c
drivers/network/ndis/include/miniport.h
include/ddk/acpiioct.h
include/ddk/bdasup.h
include/ddk/d3dhal.h
include/ddk/d3dhalex.h
include/ddk/d3dnthal.h [deleted file]
include/ddk/ddkernel.h [deleted file]
include/ddk/ddrawi.h [deleted file]
include/ddk/ddrawint.h [deleted file]
include/ddk/dmusicks.h
include/ddk/drivinit.h
include/ddk/drmk.h
include/ddk/dxapi.h
include/ddk/hubbusif.h
include/ddk/ide.h
include/ddk/imm.h [deleted file]
include/ddk/ioaccess.h
include/ddk/isguids.h [deleted file]
include/ddk/mcd.h
include/ddk/mce.h
include/ddk/miniport.h
include/ddk/minitape.h
include/ddk/mountmgr.h
include/ddk/ndis.h
include/ddk/ndistapi.h
include/ddk/ndiswan.h
include/ddk/ntddbeep.h [deleted file]
include/ddk/ntddpcm.h
include/ddk/ntddsnd.h
include/ddk/ntimage.h
include/ddk/ntnls.h
include/ddk/ntpoapi.h
include/ddk/ntstrsafe.h
include/ddk/oprghdlr.h
include/ddk/portcls.h
include/ddk/punknown.h
include/ddk/smbus.h
include/ddk/stdunk.h
include/ddk/storport.h
include/ddk/strmini.h
include/ddk/swenum.h
include/ddk/tdikrnl.h
include/ddk/tdistat.h
include/ddk/upssvc.h
include/ddk/usbbusif.h
include/ddk/usbdlib.h
include/ddk/usbprotocoldefs.h
include/ddk/wdm.h
include/ddk/wmilib.h
include/psdk/d3dnthal.h [new file with mode: 0644]
include/psdk/ddkernel.h [new file with mode: 0644]
include/psdk/ddkmapi.h [moved from include/ddk/ddkmapi.h with 59% similarity]
include/psdk/ddraw.h [moved from include/dxsdk/ddraw.h with 99% similarity]
include/psdk/ddrawi.h [new file with mode: 0644]
include/psdk/ddrawint.h [new file with mode: 0644]
include/psdk/dinput.h
include/psdk/diskguid.h [moved from include/ddk/diskguid.h with 100% similarity]
include/psdk/dmemmgr.h [moved from include/ddk/dmemmgr.h with 99% similarity]
include/psdk/dmksctrl.h [moved from include/ddk/dmksctrl.h with 66% similarity]
include/psdk/driverspecs.h [moved from include/ddk/driverspecs.h with 95% similarity]
include/psdk/dvp.h [moved from include/ddk/dvp.h with 99% similarity]
include/psdk/hidpi.h [moved from include/ddk/hidpi.h with 100% similarity]
include/psdk/hidusage.h [moved from include/ddk/hidusage.h with 100% similarity]
include/psdk/ieverp.h [moved from include/ddk/ieverp.h with 100% similarity]
include/psdk/imm.h
include/psdk/ntdd1394.h [moved from include/ddk/ntdd1394.h with 70% similarity]
include/psdk/ntdd8042.h [moved from include/ddk/ntdd8042.h with 98% similarity]
include/psdk/ntddbeep.h [new file with mode: 0644]
include/psdk/ntddcdrm.h [moved from include/ddk/ntddcdrm.h with 99% similarity]
include/psdk/ntddcdvd.h [moved from include/ddk/ntddcdvd.h with 98% similarity]
include/psdk/ntdddisk.h [moved from include/ddk/ntdddisk.h with 99% similarity]
include/psdk/ntddft.h [moved from include/ddk/ntddft.h with 51% similarity]
include/psdk/ntddndis.h
include/psdk/ntddpar.h [moved from include/ddk/ntddpar.h with 98% similarity]
include/psdk/ntddser.h [moved from include/ddk/ntddser.h with 99% similarity]
include/psdk/ntddtape.h [moved from include/ddk/ntddtape.h with 97% similarity]
include/psdk/ntddtdi.h [moved from include/ddk/ntddtdi.h with 73% similarity]
include/psdk/ntddvdeo.h [moved from include/ddk/ntddvdeo.h with 99% similarity]
include/psdk/ntddvol.h [moved from include/ddk/ntddvol.h with 98% similarity]
include/psdk/objerror.h [moved from include/ddk/objerror.h with 100% similarity]
include/psdk/polarity.h [moved from include/ddk/polarity.h with 100% similarity]
include/psdk/prntfont.h [moved from include/ddk/prntfont.h with 100% similarity]
include/psdk/sti.h
include/psdk/stierr.h [moved from include/ddk/stierr.h with 100% similarity]
include/psdk/stireg.h [moved from include/ddk/stireg.h with 100% similarity]
include/psdk/tdi.h [moved from include/ddk/tdi.h with 100% similarity]
include/psdk/tdiinfo.h [moved from include/ddk/tdiinfo.h with 100% similarity]
include/psdk/unknown.h [moved from include/ddk/unknown.h with 67% similarity]
include/psdk/warning.h [moved from include/ddk/warning.h with 100% similarity]
include/psdk/winddi.h
include/reactos/debug.h
include/reactos/wine/ddk/imm.h [new file with mode: 0644]
include/reactos/wine/imm.h [new file with mode: 0644]
include/xdk/exfuncs.h
include/xdk/iofuncs.h
include/xdk/iotypes.h
include/xdk/ketypes.h
include/xdk/wmifuncs.h
include/xdk/x86/ke.h
lib/sdk/crt/locale/locale.c
ntoskrnl/ex/init.c
subsystems/win32/win32k/eng/bitblt.c
subsystems/win32/win32k/include/xlateobj.h
subsystems/win32/win32k/ntuser/cursoricon.c
subsystems/win32/win32k/objects/bitblt.c
subsystems/win32/win32k/objects/bitmaps.c

index 0c20e81..88c5207 100644 (file)
@@ -38,7 +38,6 @@ HWND            hApplicationPageSwitchToButton; /* Application Switch To button
 HWND            hApplicationPageNewTaskButton;  /* Application New Task button */
 static int      nApplicationPageWidth;
 static int      nApplicationPageHeight;
-static HANDLE   hApplicationPageEvent = NULL;   /* When this event becomes signaled then we refresh the app list */
 static BOOL     bSortAscending = TRUE;
 DWORD WINAPI    ApplicationPageRefreshThread(void *lpParameter);
 BOOL            noApps;
@@ -51,6 +50,11 @@ void            ApplicationPageShowContextMenu2(void);
 int CALLBACK    ApplicationPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
 int             ProcGetIndexByProcessId(DWORD dwProcessId);
 
+#ifdef RUN_APPS_PAGE
+static HANDLE   hApplicationThread = NULL;
+static DWORD    dwApplicationThread;
+#endif
+
 #if 0
 void SwitchToThisWindow (
 HWND hWnd,   /* Handle to the window that should be activated */
@@ -92,7 +96,6 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     LV_COLUMN  column;
     WCHAR      szTemp[256];
     int        cx, cy;
-    HANDLE     hRefreshThread = NULL;
 
     switch (message) {
     case WM_INITDIALOG:
@@ -132,15 +135,16 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         UpdateApplicationListControlViewSetting();
 
         /* Start our refresh thread */
-        hRefreshThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, NULL);
-
+#ifdef RUN_APPS_PAGE
+        hApplicationThread = CreateThread(NULL, 0, ApplicationPageRefreshThread, NULL, 0, &dwApplicationThread);
+#endif
         return TRUE;
 
     case WM_DESTROY:
-        /* Close the event handle, this will make the */
-        /* refresh thread exit when the wait fails */
-        CloseHandle(hApplicationPageEvent);
-        CloseHandle(hRefreshThread);
+        /* Close refresh thread */
+#ifdef RUN_APPS_PAGE
+        EndLocalThread(&hApplicationThread, dwApplicationThread);
+#endif
         break;
 
     case WM_COMMAND:
@@ -213,9 +217,11 @@ ApplicationPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
 void RefreshApplicationPage(void)
 {
+#ifdef RUN_APPS_PAGE
     /* Signal the event so that our refresh thread */
     /* will wake up and refresh the application page */
-    SetEvent(hApplicationPageEvent);
+    PostThreadMessage(dwApplicationThread, WM_TIMER, 0, 0);
+#endif
 }
 
 void UpdateApplicationListControlViewSetting(void)
@@ -236,6 +242,7 @@ void UpdateApplicationListControlViewSetting(void)
 
 DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter)
 {
+    MSG msg;
     INT i;
     BOOL                            bItemRemoved = FALSE;
     LV_ITEM                         item;
@@ -243,30 +250,15 @@ DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter)
     HIMAGELIST                      hImageListLarge;
     HIMAGELIST                      hImageListSmall;
 
-    /* Create the event */
-    hApplicationPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
-
     /* If we couldn't create the event then exit the thread */
-    if (!hApplicationPageEvent)
-        return 0;
-
     while (1)
     {
-        DWORD   dwWaitVal;
-
-        /* Wait on the event */
-        dwWaitVal = WaitForSingleObject(hApplicationPageEvent, INFINITE);
-
-        /* If the wait failed then the event object must have been */
-        /* closed and the task manager is exiting so exit this thread */
-        if (dwWaitVal == WAIT_FAILED)
+        /*  Wait for an the event or application close */
+        if (GetMessage(&msg, NULL, 0, 0) <= 0)
             return 0;
 
-        if (dwWaitVal == WAIT_OBJECT_0)
+        if (msg.message == WM_TIMER)
         {
-            /* Reset our event */
-            ResetEvent(hApplicationPageEvent);
-
             /*
              * FIXME:
              *
index fb11fc7..f72ba26 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  debug.cpp
+ *  debug.c
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *                2005         Klemens Friedl <frik85@reactos.at>
index 3ae716f..be080ff 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  endproc.cpp
+ *  endproc.c
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *                2005         Klemens Friedl <frik85@reactos.at>
index 6045a8f..b7b937e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  graph.cpp
+ *  graph.c
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *
index a1abf77..5735e8b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  GraphCtrl.cpp
+ *  graphctl.c
  *
  *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
  *
@@ -425,7 +425,7 @@ void GraphCtrl_DrawPoint(TGraphCtrl* this)
          *  note: the m_dcPlot covers the entire client
          *        but we only shift bitmap that is the size
          *        of the plot rectangle
-         *  grab the right side of the plot (exluding m_nShiftPixels on the left)
+         *  grab the right side of the plot (excluding m_nShiftPixels on the left)
          *  move this grabbed bitmap to the left by m_nShiftPixels
          */
         BitBlt(this->m_dcPlot, this->m_rectPlot.left, this->m_rectPlot.top+1,
index e924716..3a5b838 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  GraphCtrl.h
+ *  graphctl.h
  *
  *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
  *
index 931e00c..4ba1fa6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  optnmenu.cpp
+ *  optnmenu.c
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *
@@ -110,7 +110,7 @@ void TaskManager_OnOptionsShow16BitTasks(void)
 
     /*
      * FIXME: Currently this is useless because the
-     * current implemetation doesn't list the 16-bit
+     * current implementation doesn't list the 16-bit
      * processes. I believe that would require querying
      * each ntvdm.exe process for it's children.
      */
index a1095e5..a82eb78 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- *  perfdata.cpp
+ *  perfdata.c
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *
index 8ba87eb..872a014 100644 (file)
@@ -51,11 +51,14 @@ HWND  hPerformancePageTotalsHandleCountEdit;          /*  Total Handles Edit Con
 HWND  hPerformancePageTotalsProcessCountEdit;         /*  Total Processes Edit Control */
 HWND  hPerformancePageTotalsThreadCountEdit;          /*  Total Threads Edit Control */
 
+#ifdef RUN_PERF_PAGE
+static HANDLE hPerformanceThread = NULL;
+static DWORD  dwPerformanceThread;
+#endif
 
 static int     nPerformancePageWidth;
 static int     nPerformancePageHeight;
 static int     lastX, lastY;
-static HANDLE  hPerformancePageEvent = NULL;    /*  When this event becomes signaled then we refresh the performance page */
 DWORD WINAPI   PerformancePageRefreshThread(void *lpParameter);
 
 void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference, int pos)
@@ -94,12 +97,12 @@ void AdjustFrameSize(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference,
     InvalidateRect(hCntrl, NULL, TRUE);
 }
 
-void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
+static void AdjustControlPostion(HWND hCntrl, HWND hDlg, int nXDifference, int nYDifference)
 {
     AdjustFrameSize(hCntrl, hDlg, nXDifference, nYDifference, 0);
 }
 
-void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
+static void AdjustCntrlPos(int ctrl_id, HWND hDlg, int nXDifference, int nYDifference)
 {
     AdjustFrameSize(GetDlgItem(hDlg, ctrl_id), hDlg, nXDifference, nYDifference, 0);
 }
@@ -110,9 +113,6 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     RECT  rc;
     int   nXDifference;
     int   nYDifference;
-#ifdef RUN_PERF_PAGE
-    HANDLE  hRefreshThread = NULL;
-#endif
 /*     HDC hdc; */
 /*     PAINTSTRUCT ps; */
 
@@ -121,7 +121,7 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         GraphCtrl_Dispose(&PerformancePageCpuUsageHistoryGraph);
         GraphCtrl_Dispose(&PerformancePageMemUsageHistoryGraph);
 #ifdef RUN_PERF_PAGE
-        CloseHandle(hRefreshThread);
+        EndLocalThread(&hPerformanceThread, dwPerformanceThread);
 #endif
         break;
 
@@ -192,7 +192,7 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         GraphCtrl_SetPlotColor(&PerformancePageMemUsageHistoryGraph, 0, RGB(255, 255, 0)) ;
         /*  Start our refresh thread */
 #ifdef RUN_PERF_PAGE
-        hRefreshThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, NULL);
+        hPerformanceThread = CreateThread(NULL, 0, PerformancePageRefreshThread, NULL, 0, &dwPerformanceThread);
 #endif
 
         /*
@@ -303,9 +303,11 @@ PerformancePageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
 void RefreshPerformancePage(void)
 {
+#ifdef RUN_PERF_PAGE
     /*  Signal the event so that our refresh thread */
     /*  will wake up and refresh the performance page */
-    SetEvent(hPerformancePageEvent);
+    PostThreadMessage(dwPerformanceThread, WM_TIMER, 0, 0);
+#endif
 }
 
 DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
@@ -332,35 +334,21 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
     WCHAR  Text[260];
     WCHAR  szMemUsage[256];
 
-    /*  Create the event */
-    hPerformancePageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
-
-    /*  If we couldn't create the event then exit the thread */
-    if (!hPerformancePageEvent)
-        return 0;
+    MSG    msg;
 
     LoadStringW(hInst, IDS_STATUS_MEMUSAGE, szMemUsage, 256);
 
     while (1)
     {
-        DWORD  dwWaitVal;
-
         int nBarsUsed1;
         int nBarsUsed2;
 
-        /*  Wait on the event */
-        dwWaitVal = WaitForSingleObject(hPerformancePageEvent, INFINITE);
-
-        /*  If the wait failed then the event object must have been */
-        /*  closed and the task manager is exiting so exit this thread */
-        if (dwWaitVal == WAIT_FAILED)
+        /*  Wait for an the event or application close */
+        if (GetMessage(&msg, NULL, 0, 0) <= 0)
             return 0;
 
-        if (dwWaitVal == WAIT_OBJECT_0)
+        if (msg.message == WM_TIMER)
         {
-            /*  Reset our event */
-            ResetEvent(hPerformancePageEvent);
-
             /*
              *  Update the commit charge info
              */
@@ -449,8 +437,6 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
             PhysicalMemoryAvailable = PerfDataGetPhysicalMemoryAvailableK();
             nBarsUsed2 = PhysicalMemoryTotal ? ((PhysicalMemoryAvailable * 100) / PhysicalMemoryTotal) : 0;
 
-
-
             GraphCtrl_AppendPoint(&PerformancePageCpuUsageHistoryGraph, CpuUsage, CpuKernelUsage, 0.0, 0.0);
             GraphCtrl_AppendPoint(&PerformancePageMemUsageHistoryGraph, nBarsUsed1, nBarsUsed2, 0.0, 0.0);
             /* PerformancePageMemUsageHistoryGraph.SetRange(0.0, 100.0, 10) ; */
@@ -458,7 +444,7 @@ DWORD WINAPI PerformancePageRefreshThread(void *lpParameter)
             InvalidateRect(hPerformancePageCpuUsageHistoryGraph, NULL, FALSE);
         }
     }
-        return 0;
+    return 0;
 }
 
 void PerformancePage_OnViewShowKernelTimes(void)
index 42bf594..acaa159 100644 (file)
@@ -40,7 +40,10 @@ HWND hProcessPageShowAllProcessesButton;/* Process Show All Processes checkbox *
 
 static int  nProcessPageWidth;
 static int  nProcessPageHeight;
-static HANDLE  hProcessPageEvent = NULL;    /* When this event becomes signaled then we refresh the process list */
+#ifdef RUN_PROC_PAGE
+static HANDLE   hProcessThread = NULL;
+static DWORD    dwProcessThread;
+#endif
 
 int CALLBACK    ProcessPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
 void AddProcess(ULONG Index);
@@ -104,7 +107,6 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     int     nXDifference;
     int     nYDifference;
     int     cx, cy;
-    HANDLE  hRefreshThread = NULL;
 
     switch (message) {
     case WM_INITDIALOG:
@@ -139,19 +141,19 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
          */
         OldProcessListWndProc = (WNDPROC)(LONG_PTR) SetWindowLongPtrW(hProcessPageListCtrl, GWL_WNDPROC, (LONG_PTR)ProcessListWndProc);
 
+#ifdef RUN_PROC_PAGE
         /* Start our refresh thread */
-        hRefreshThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, NULL);
-
+        hProcessThread = CreateThread(NULL, 0, ProcessPageRefreshThread, NULL, 0, &dwProcessThread);
+#endif
         return TRUE;
 
     case WM_DESTROY:
         /* Close the event handle, this will make the */
         /* refresh thread exit when the wait fails */
-        CloseHandle(hProcessPageEvent);
-        CloseHandle(hRefreshThread);
-
+#ifdef RUN_PROC_PAGE
+        EndLocalThread(&hProcessThread, dwProcessThread);
+#endif
         SaveColumnSettings();
-
         break;
 
     case WM_COMMAND:
@@ -194,11 +196,9 @@ ProcessPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         cy = rc.top + nYDifference;
         SetWindowPos(hProcessPageShowAllProcessesButton, NULL, cx, cy, 0, 0, SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSIZE|SWP_NOZORDER);
         InvalidateRect(hProcessPageShowAllProcessesButton, NULL, TRUE);
-
         break;
 
     case WM_NOTIFY:
-
         ProcessPageOnNotify(wParam, lParam);
         break;
     }
@@ -372,9 +372,11 @@ void ProcessPageShowContextMenu(DWORD dwProcessId)
 
 void RefreshProcessPage(void)
 {
+#ifdef RUN_PROC_PAGE
     /* Signal the event so that our refresh thread */
     /* will wake up and refresh the process page */
-    SetEvent(hProcessPageEvent);
+    PostThreadMessage(dwProcessThread, WM_TIMER, 0, 0);
+#endif
 }
 
 DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
@@ -382,34 +384,19 @@ DWORD WINAPI ProcessPageRefreshThread(void *lpParameter)
     ULONG    OldProcessorUsage = 0;
     ULONG    OldProcessCount = 0;
     WCHAR    szCpuUsage[256], szProcesses[256];
-
-    /* Create the event */
-    hProcessPageEvent = CreateEventW(NULL, TRUE, TRUE, NULL);
-
-    /* If we couldn't create the event then exit the thread */
-    if (!hProcessPageEvent)
-        return 0;
+    MSG      msg;
 
     LoadStringW(hInst, IDS_STATUS_CPUUSAGE, szCpuUsage, 256);
     LoadStringW(hInst, IDS_STATUS_PROCESSES, szProcesses, 256);
 
     while (1) {
-        DWORD    dwWaitVal;
-
-        /* Wait on the event */
-        dwWaitVal = WaitForSingleObject(hProcessPageEvent, INFINITE);
-
-        /* If the wait failed then the event object must have been */
-        /* closed and the task manager is exiting so exit this thread */
-        if (dwWaitVal == WAIT_FAILED)
+        /*  Wait for an the event or application close */
+        if (GetMessage(&msg, NULL, 0, 0) <= 0)
             return 0;
 
-        if (dwWaitVal == WAIT_OBJECT_0) {
+        if (msg.message == WM_TIMER) {
             WCHAR    text[260];
 
-            /* Reset our event */
-            ResetEvent(hProcessPageEvent);
-
             UpdateProcesses();
 
             if (IsWindowVisible(hProcessPage))
index c409f80..c6d11c0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ReactOS Task Manager
  *
- * TaskMgr.c : Defines the entry point for the application.
+ * taskmgr.c : Defines the entry point for the application.
  *
  *  Copyright (C) 1999 - 2001  Brian Palmer  <brianp@reactos.org>
  *                2005         Klemens Friedl <frik85@reactos.at>
@@ -856,11 +856,6 @@ void TaskManager_OnViewUpdateSpeed(DWORD dwSpeed)
     SetUpdateSpeed(hMainWnd);
 }
 
-void TaskManager_OnViewRefresh(void)
-{
-    PostMessageW(hMainWnd, WM_TIMER, 0, 0);
-}
-
 void TaskManager_OnTabWndSelChange(void)
 {
     int    i;
@@ -1012,3 +1007,27 @@ LPWSTR GetLastErrorText(LPWSTR lpszBuf, DWORD dwSize)
     }
     return lpszBuf;
 }
+
+DWORD EndLocalThread(HANDLE *hThread, DWORD dwThread)
+{
+    DWORD dwExitCodeThread = 0;
+
+    if (*hThread != NULL) {
+        PostThreadMessage(dwThread,WM_QUIT,0,0);
+        for (;;) {
+            MSG msg;
+
+            if (WAIT_OBJECT_0 == WaitForSingleObject(*hThread, 500))
+                break;
+            while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+                TranslateMessage(&msg);
+                DispatchMessage(&msg);
+            }
+        }
+        GetExitCodeThread(*hThread, &dwExitCodeThread);
+        CloseHandle(*hThread);
+        *hThread = NULL;
+    }
+    return dwExitCodeThread;
+}
+
index 16eaad8..e0a8de8 100644 (file)
@@ -116,9 +116,9 @@ void TaskManager_OnEnterMenuLoop(HWND hWnd);
 void TaskManager_OnExitMenuLoop(HWND hWnd);
 void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
 void TaskManager_OnViewUpdateSpeed(DWORD);
-void TaskManager_OnViewRefresh(void);
 void TaskManager_OnTabWndSelChange(void);
 LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
+DWORD EndLocalThread(HANDLE *hThread, DWORD dwThread);
 
 #ifdef __cplusplus
 }
index f711cf3..3329848 100644 (file)
@@ -415,7 +415,7 @@ WinMain(
 
        /* Tell kernel that CurrentControlSet is good (needed
         * to support Last good known configuration boot) */
-       NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED);
+       NtInitializeRegistry(CM_BOOT_FLAG_ACCEPTED | 1);
 
        /* Message loop for the SAS window */
        while (GetMessageW(&Msg, WLSession->SASWindow, 0, 0))
index 7e22a3b..890972f 100644 (file)
@@ -209,7 +209,7 @@ DWORD WINAPI AdapterDiscoveryThread(LPVOID Context) {
     PDHCP_ADAPTER Adapter = NULL;
     HANDLE AdapterStateChangedEvent = (HANDLE)Context;
     struct interface_info *ifi = NULL;
-    int i, AdapterCount = 0;
+    int i, AdapterCount = 0, Broadcast;
 
     /* FIXME: Kill this thread when the service is stopped */
 
@@ -285,6 +285,15 @@ DWORD WINAPI AdapterDiscoveryThread(LPVOID Context) {
                         socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
 
                     if (DhcpSocket != INVALID_SOCKET) {
+                                               
+                                               /* Allow broadcast on this socket */
+                                               Broadcast = 1;
+                                               setsockopt(DhcpSocket,
+                                                                  SOL_SOCKET,
+                                                                  SO_BROADCAST,
+                                                                  (const char *)&Broadcast,
+                                                                  sizeof(Broadcast));
+                                               
                         Adapter->ListenAddr.sin_family = AF_INET;
                         Adapter->ListenAddr.sin_port = htons(LOCAL_PORT);
                         Adapter->BindStatus =
index 8508d2d..717fd2d 100644 (file)
@@ -2291,6 +2291,7 @@ PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap(VOID)
  */
 DWORD WINAPI GetAdaptersAddresses(ULONG Family,ULONG Flags,PVOID Reserved,PIP_ADAPTER_ADDRESSES pAdapterAddresses,PULONG pOutBufLen)
 {
+#if 0
     InterfaceIndexTable *indexTable;
     IFInfo ifInfo;
     int i;
@@ -2477,6 +2478,15 @@ DWORD WINAPI GetAdaptersAddresses(ULONG Family,ULONG Flags,PVOID Reserved,PIP_AD
     free(indexTable);
 
     return NO_ERROR;
+#else
+    if (!pOutBufLen) return ERROR_INVALID_PARAMETER;
+    if (!pAdapterAddresses || *pOutBufLen == 0)
+      return ERROR_BUFFER_OVERFLOW;
+    if (Reserved) return ERROR_INVALID_PARAMETER;
+
+    FIXME(":stub\n");
+    return ERROR_NO_DATA;
+#endif
 }
 
 /*
index fa6c1c1..2cb747f 100644 (file)
@@ -32,7 +32,7 @@
 #include "wine/debug.h"
 
 //#include "ntddndis.h"
-#include "ddk/tdiinfo.h"
+#include "tdiinfo.h"
 #include "tcpioctl.h"
 
 #include "tdilib.h"
index 0928e74..24c2a75 100644 (file)
@@ -11,9 +11,8 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
 
 /* FUNCTIONS ****************************************************************/
 
index 98d8f67..2722ba5 100644 (file)
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
+#define NDEBUG
+#include <debug.h>
 
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index 59f6165..c7aff9c 100644 (file)
@@ -10,9 +10,8 @@
  */
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
 
 /*
  * @implemented
index 760fda4..4055f87 100644 (file)
@@ -13,9 +13,9 @@
 /* INCLUDES ****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index d2fe40f..894970a 100644 (file)
@@ -15,9 +15,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 #define SYMLINK_FLAG_RELATIVE   1
 
index 5584899..ee6d855 100644 (file)
@@ -17,9 +17,9 @@
 /* INCLUDES ******************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* GLOBAL VARIABLES **********************************************************/
 
index 4ad6a80..3338516 100644 (file)
@@ -12,9 +12,9 @@
 /* INCLUDES ****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <reactos/debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index b4435a9..a3016ed 100644 (file)
@@ -9,7 +9,8 @@
 /* INCLUDES *******************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
+#define NDEBUG
+#include <debug.h>
 
 /* FUNCTIONS ******************************************************************/
 
index 913243a..5d352b1 100644 (file)
@@ -16,9 +16,9 @@
 /* INCLUDES ******************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 UNICODE_STRING DllDirectory = {0, 0, NULL};
 
index 006cc76..0ac0191 100644 (file)
@@ -12,9 +12,9 @@
 /* INCLUDES ******************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS *****************************************************************/
 
index cdbafd0..7210147 100644 (file)
@@ -13,9 +13,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* GLOBALS ******************************************************************/
 
index df24523..e2d476c 100644 (file)
@@ -12,9 +12,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* TYPES ********************************************************************/
 
index 8954ebe..5e8e91f 100644 (file)
@@ -12,9 +12,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index 2f33246..56eef2c 100644 (file)
  */
 
 #include <k32.h>
-#include <wine/debug.h>
+#define NDEBUG
+#include <debug.h>
 
 #define NANOS_TO_100NS(nanos) (((LONGLONG)(nanos)) / 100)
 #define MICROS_TO_100NS(micros) (((LONGLONG)(micros)) * NANOS_TO_100NS(1000))
 #define MILLIS_TO_100NS(milli) (((LONGLONG)(milli)) * MICROS_TO_100NS(1000))
 
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
-
 /*
  * @implemented
  */
index 7171c89..7c1a6b9 100644 (file)
@@ -10,9 +10,8 @@
  */
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
 
 /*
  * @implemented
index 60c7133..6cb3860 100644 (file)
@@ -14,9 +14,9 @@
 /* INCLUDES ****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index 629fef2..cbc7900 100644 (file)
@@ -11,9 +11,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index c46f006..cdf5352 100644 (file)
@@ -17,9 +17,9 @@
 
 #include <k32.h>
 #include <malloc.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* GLOBALS *****************************************************************/
 
index 55aeed9..3896e9b 100644 (file)
@@ -10,9 +10,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 //#define USING_PROPER_NPFS_WAIT_SEMANTICS
 
index 94bc1ae..a48150d 100644 (file)
@@ -11,9 +11,9 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* GLOBALS ******************************************************************/
 
index 400caf7..dc89e4d 100644 (file)
@@ -12,9 +12,9 @@
 /* INCLUDES ****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 /* FUNCTIONS ****************************************************************/
 
index fc6d4c4..32e274f 100644 (file)
@@ -12,9 +12,8 @@
 /* INCLUDES *****************************************************************/
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
 
 /* FUNCTIONS ****************************************************************/
 
index ee74d9f..2af3e8e 100644 (file)
@@ -20,9 +20,9 @@
  */
 
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32file);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32file;
 
 #define MAX_DOS_DRIVES 26
 
index 4d3f032..55b1338 100755 (executable)
@@ -1,5 +1,25 @@
 #pragma once
 
+//
+// Kernel32 Filter IDs
+//
+#define kernel32file            200
+#define kernel32ver             201
+#define actctx                  202
+#define resource                203
+#define kernel32session         204
+
+#define TRACE(fmt, ...)         TRACE__(gDebugChannel, fmt, ##__VA_ARGS__)
+#define WARN(fmt, ...)          WARN__(gDebugChannel, fmt, ##__VA_ARGS__)
+#define FIXME(fmt, ...)         WARN__(gDebugChannel, fmt,## __VA_ARGS__)
+#define ERR(fmt, ...)           ERR__(gDebugChannel, fmt, ##__VA_ARGS__)
+
+#define debugstr_a  
+#define debugstr_w
+#define wine_dbgstr_w  
+#define debugstr_guid
+
+#include "wine/unicode.h"
 #include "baseheap.h"
 
 #define BINARY_UNKNOWN (0)
@@ -40,8 +60,9 @@
 /* Undocumented CreateProcess flag */
 #define STARTF_SHELLPRIVATE         0x400
   
-#define SetLastErrorByStatus(__S__) \
- ((void)SetLastError(RtlNtStatusToDosError(__S__)))
+#define SetLastErrorByStatus(x) RtlSetLastWin32ErrorAndNtStatusFromNtStatus((x))
+#define GetLastError()          NtCurrentTeb()->LastErrorValue
+#define SetLastError(x)         NtCurrentTeb()->LastErrorValue = (x)
 
 typedef struct _CODEPAGE_ENTRY
 {
@@ -100,6 +121,7 @@ DWORD FilenameU2A_FitOrFail(LPSTR  DestA, INT destLen, PUNICODE_STRING SourceU);
 #define HeapAlloc RtlAllocateHeap
 #define HeapReAlloc RtlReAllocateHeap
 #define HeapFree RtlFreeHeap
+#define _lread  (_readfun)_hread
 
 POBJECT_ATTRIBUTES
 WINAPI
diff --git a/dll/win32/kernel32/kernel32.def b/dll/win32/kernel32/kernel32.def
new file mode 100644 (file)
index 0000000..f0130a9
--- /dev/null
@@ -0,0 +1,1459 @@
+#undef i386
+
+@ stdcall AcquireSRWLockExclusive(ptr) ntdll.RtlAcquireSRWLockExclusive
+@ stdcall AcquireSRWLockShared(ptr) ntdll.RtlAcquireSRWLockShared
+@ stdcall ActivateActCtx(ptr ptr)
+@ stdcall AddAtomA(str)
+@ stdcall AddAtomW(wstr)
+@ stdcall AddConsoleAliasA(str str str) ;check
+@ stdcall AddConsoleAliasW(wstr wstr wstr) ;check
+;@ stdcall -arch=x86_64 AddIntegrityLabelToBoundaryDescriptor ; Win 7
+@ stdcall AddLocalAlternateComputerNameA(str ptr)
+@ stdcall AddLocalAlternateComputerNameW(wstr ptr)
+@ stdcall AddRefActCtx(ptr)
+;@ stdcall AddSIDToBoundaryDescriptor ; Win 7
+;@ stdcall AddSecureMemoryCacheCallback ; Win 7
+@ stdcall AddVectoredContinueHandler(long ptr) ntdll.RtlAddVectoredContinueHandler
+@ stdcall AddVectoredExceptionHandler(long ptr) ntdll.RtlAddVectoredExceptionHandler
+;@ stdcall AdjustCalendarDate ; Win 7
+@ stdcall AllocConsole()
+@ stub AllocLSCallback ; missing in XP SP3 and 2003 R2 and Win 7
+@ stdcall AllocateUserPhysicalPages(long ptr ptr)
+;@ stdcall AllocateUserPhysicalPagesNuma ; Win 7
+;@ stdcall ApplicationRecoveryFinished ; Win 7
+;@ stdcall ApplicationRecoveryInProgress ; Win 7
+@ stdcall AreFileApisANSI()
+@ stdcall AssignProcessToJobObject(ptr ptr)
+@ stdcall AttachConsole(long)
+@ stdcall BackupRead(ptr ptr long ptr long long ptr)
+@ stdcall BackupSeek(ptr long long ptr ptr ptr)
+@ stdcall BackupWrite(ptr ptr long ptr long long ptr)
+@ stdcall BaseCheckAppcompatCache(long long long ptr) ;check
+;@ stdcall BaseCheckAppcompatCacheEx ; Win7
+@ stub BaseCheckRunApp
+@ stdcall BaseCleanupAppcompatCache() ; missing in Win 7
+@ stdcall BaseCleanupAppcompatCacheSupport(ptr)
+;@ stdcall BaseDllReadWriteIniFile ; Win 7
+@ stdcall BaseDumpAppcompatCache()
+@ stdcall BaseFlushAppcompatCache()
+;@ stdcall BaseFormatObjectAttributes ; Win 7
+;@ stdcall BaseFormatTimeOut ; Win 7
+;@ stdcall BaseGenerateAppCompatData ; Win 7
+;@ stdcall BaseGetNamedObjectDirectory ; Win 7
+@ stdcall BaseInitAppcompatCache() ; missing in Win 7
+@ stdcall BaseInitAppcompatCacheSupport()
+;@ stdcall BaseIsAppcompatInfrastructureDisabled ; Win 7
+@ stdcall BaseProcessInitPostImport() ; missing in Win 7
+@ stdcall BaseQueryModuleData(str str ptr ptr ptr) ;check
+;@ stdcall BaseThreadInitThunk ; Win 7
+;@ stdcall BaseSetLastNTError ; Win 7, not 64 bit
+@ stdcall BaseUpdateAppcompatCache(long long long)
+;@ stdcall BaseVerifyUnicodeString ; Win 7
+;@ stdcall Basep8BitStringToDynamicUnicodeString ; Win 7
+;@ stdcall BasepAllocateActivationContextActivationBlock ; Win 7
+;@ stdcall BasepAnsiStringToDynamicUnicodeString ; Win 7
+;@ stdcall BasepCheckAppCompat ; Win 7
+;@ stdcall BasepCheckBadapp ; Win 7
+@ stub BasepCheckWinSaferRestrictions
+@ stub BasepDebugDump ; missing in XP SP3 and Win 7
+;@ stdcall BasepFreeActivationContextActivationBlock ; Win 7
+;@ stdcall BasepFreeAppCompatData ; Win 7
+;@ stdcall BasepMapModuleHandle ; Win 7
+@ stdcall Beep(long long)
+@ stdcall BeginUpdateResourceA(str long)
+@ stdcall BeginUpdateResourceW(wstr long)
+@ stdcall BindIoCompletionCallback(long ptr long)
+@ stdcall BuildCommDCBA(str ptr)
+@ stdcall BuildCommDCBAndTimeoutsA(str ptr ptr)
+@ stdcall BuildCommDCBAndTimeoutsW(wstr ptr ptr)
+@ stdcall BuildCommDCBW(wstr ptr)
+@ stdcall CallNamedPipeA(str ptr long ptr long ptr long)
+@ stdcall CallNamedPipeW(wstr ptr long ptr long ptr long)
+;@ stdcall CallbackMayRunLong ; Win 7
+@ stdcall CancelDeviceWakeupRequest(long)
+@ stdcall CancelIo(long)
+@ stdcall CancelIoEx(long ptr)
+@ stdcall CancelSynchronousIo(long)
+;@ stdcall CancelThreadpoolIo(ptr) ntdll.TpCancelAsyncIoOperation; Win 7
+@ stdcall CancelTimerQueueTimer(long long)
+@ stdcall CancelWaitableTimer(long)
+@ stdcall ChangeTimerQueueTimer(ptr ptr long long)
+;@ stdcall CheckElevation ; Win 7
+;@ stdcall CheckElevationEnabled ; Win 7
+;@ stdcall CheckForReadOnlyResource ; Win 7
+@ stdcall CheckNameLegalDOS8Dot3A(str str long long long)
+@ stdcall CheckNameLegalDOS8Dot3W(wstr str long long long)
+@ stdcall CheckRemoteDebuggerPresent(long ptr)
+@ stdcall ClearCommBreak(long)
+@ stdcall ClearCommError(long ptr ptr)
+@ stdcall CloseConsoleHandle(long)
+@ stdcall CloseHandle(long)
+;@ stdcall ClosePrivateNamespace ; Win 7
+@ stdcall CloseProfileUserMapping()
+@ stub CloseSystemHandle ; missing in XP SP3 and Win 7
+;@ stdcall CloseThreadpool(ptr) ntdll.TpReleasePool ; Win 7
+;@ stdcall CloseThreadpoolCleanupGroup(ptr) ntdll.TpReleaseCleanupGroup ; Win 7
+;@ stdcall CloseThreadpoolCleanupGroupMembers(ptr long ptr) ntdll.TpReleaseCleanupGroupMembers ; Win 7
+;@ stdcall CloseThreadpoolIo ntdll.TpReleaseIoCompletion ; Win 7
+;@ stdcall CloseThreadpoolTimer ntdll.TpReleaseTimer ; Win 7
+;@ stdcall CloseThreadpoolWait ntdll.TpReleaseWait ; Win 7
+;@ stdcall CloseThreadpoolWork ntdll.TpReleaseWork ; Win 7
+@ stdcall CmdBatNotification(long)
+@ stdcall CommConfigDialogA(str long ptr)
+@ stdcall CommConfigDialogW(wstr long ptr)
+;@ stdcall CompareCalendarDates ; Win 7
+@ stdcall CompareFileTime(ptr ptr)
+@ stdcall CompareStringA(long long str long str long)
+;@ stdcall CompareStringEx ; Win 7
+;@ stdcall CompareStringOrdinal ; Win 7
+@ stdcall CompareStringW(long long wstr long wstr long)
+@ stdcall ConnectNamedPipe(long ptr)
+@ stdcall ConsoleMenuControl(long long long)
+@ stub ConsoleSubst ; missing in XP SP3 and Win 7
+@ stdcall ContinueDebugEvent(long long long)
+;@ stdcall ConvertCalDateTimeToSystemTime ; Win 7
+@ stdcall ConvertDefaultLocale (long)
+@ stdcall ConvertFiberToThread()
+;@ stdcall ConvertNLSDayOfWeekToWin32DayOfWeek ; Win 7
+;@ stdcall ConvertSystemTimeToCalDateTime ; Win 7
+@ stdcall ConvertThreadToFiber(ptr)
+@ stdcall ConvertThreadToFiberEx(ptr long)
+;@ stdcall CopyExtendedContext ; Win 7
+@ stdcall CopyFileA(str str long)
+@ stdcall CopyFileExA (str str ptr ptr ptr long)
+@ stdcall CopyFileExW (wstr wstr ptr ptr ptr long)
+;@ stdcall CopyFileTransactedA ; Win 7
+;@ stdcall CopyFileTransactedW ; Win 7
+@ stdcall CopyFileW(wstr wstr long)
+@ stdcall CopyLZFile(long long) LZCopy
+@ stdcall CreateActCtxA(ptr)
+@ stdcall CreateActCtxW(ptr)
+;@ stdcall CreateBoundaryDescriptorA ; Win 7
+;@ stdcall CreateBoundaryDescriptorW ; Win 7
+@ stdcall CreateConsoleScreenBuffer(long long ptr long ptr)
+@ stdcall CreateDirectoryA(str ptr)
+@ stdcall CreateDirectoryExA(str str ptr)
+@ stdcall CreateDirectoryExW(wstr wstr ptr)
+;@ stdcall CreateDirectoryTransactedA ; Win 7
+;@ stdcall CreateDirectoryTransactedW ; Win 7
+@ stdcall CreateDirectoryW(wstr ptr)
+@ stdcall CreateEventA(ptr long long str)
+@ stdcall CreateEventExA(ptr str long long)
+@ stdcall CreateEventExW(ptr wstr long long)
+@ stdcall CreateEventW(ptr long long wstr)
+@ stdcall CreateFiber(long ptr ptr)
+@ stdcall CreateFiberEx(long long long ptr ptr)
+@ stdcall CreateFileA(str long long ptr long long long)
+@ stdcall CreateFileMappingA(long ptr long long long str)
+;@ stdcall CreateFileMappingNumaA ; Win 7
+;@ stdcall CreateFileMappingNumaW ; Win 7
+@ stdcall CreateFileMappingW(long ptr long long long wstr)
+;@ stdcall CreateFileTransactedA ; Win 7
+;@ stdcall CreateFileTransactedW ; Win 7
+@ stdcall CreateFileW(wstr long long ptr long long long)
+@ stdcall CreateHardLinkA(str str ptr)
+;@ stdcall CreateHardLinkTransactedA ; Win 7
+;@ stdcall CreateHardLinkTransactedW ; Win 7
+@ stdcall CreateHardLinkW(wstr wstr ptr)
+@ stdcall CreateIoCompletionPort(long long long long)
+@ stdcall CreateJobObjectA(ptr str)
+@ stdcall CreateJobObjectW(ptr wstr)
+@ stdcall CreateJobSet(long ptr long)
+@ stub CreateKernelThread ; missing in XP SP3 and Win 7
+@ stdcall CreateMailslotA(ptr long long ptr)
+@ stdcall CreateMailslotW(ptr long long ptr)
+@ stdcall CreateMemoryResourceNotification(long)
+@ stdcall CreateMutexA(ptr long str)
+@ stdcall CreateMutexExA(ptr str long long)
+@ stdcall CreateMutexExW(ptr wstr long long)
+@ stdcall CreateMutexW(ptr long wstr)
+@ stdcall CreateNamedPipeA(str long long long long long long ptr)
+@ stdcall CreateNamedPipeW(wstr long long long long long long ptr)
+@ stdcall CreateNlsSecurityDescriptor(ptr long long) ; missing in Win 7
+@ stdcall CreatePipe(ptr ptr ptr long)
+;@ stdcall CreatePrivateNamespaceA ; Win 7
+;@ stdcall CreatePrivateNamespaceW ; Win 7
+@ stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr)
+;@ stdcall CreateProcessAsUserW ; Win 7
+@ stdcall CreateProcessInternalA(ptr str str ptr ptr long long ptr str ptr ptr long)
+@ stdcall CreateProcessInternalW(ptr wstr wstr ptr ptr long long ptr wstr ptr ptr long)
+@ stdcall CreateProcessInternalWSecure() ; missing in Win 7
+@ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr)
+@ stdcall CreateRemoteThread(long ptr long ptr long long ptr)
+;@ stdcall CreateRemoteThreadEx api-ms-win-core-processthreads-l1-1-0.CreateRemoteThreadEx ; Win 7
+@ stdcall CreateSemaphoreA(ptr long long str)
+@ stdcall CreateSemaphoreExA(ptr long long str long long)
+@ stdcall CreateSemaphoreExW(ptr long long wstr long long)
+@ stdcall CreateSemaphoreW(ptr long long wstr)
+@ stdcall CreateSocketHandle()
+@ stdcall CreateSymbolicLinkA(str str long)
+;@ stdcall CreateSymbolicLinkTransactedA ; Win 7
+;@ stdcall CreateSymbolicLinkTransactedW ; Win 7
+@ stdcall CreateSymbolicLinkW(wstr wstr long)
+@ stdcall CreateTapePartition(long long long long)
+@ stdcall CreateThread(ptr long ptr long long ptr)
+;@ stdcall CreateThreadpool ; Win 7
+;@ stdcall CreateThreadpoolCleanupGroup ; Win 7
+;@ stdcall CreateThreadpoolIo ; Win 7
+;@ stdcall CreateThreadpoolTimer ; Win 7
+;@ stdcall CreateThreadpoolWait ; Win 7
+;@ stdcall CreateThreadpoolWork ; Win 7
+@ stdcall CreateTimerQueue ()
+@ stdcall CreateTimerQueueTimer(ptr long ptr ptr long long long)
+@ stdcall CreateToolhelp32Snapshot(long long)
+;@ stdcall arch=x86_64 CreateUmsCompletionList
+;@ stdcall arch=x86_64 CreateUmsThreadContext
+@ stdcall CreateVirtualBuffer(long long long) ; missing in Win 7
+@ stdcall CreateWaitableTimerA(ptr long str)
+@ stdcall CreateWaitableTimerExA(ptr str long long)
+@ stdcall CreateWaitableTimerExW(ptr wstr long long)
+@ stdcall CreateWaitableTimerW(ptr long wstr)
+@ stdcall DeactivateActCtx(long ptr)
+@ stdcall DebugActiveProcess(long)
+@ stdcall DebugActiveProcessStop(long)
+@ stdcall DebugBreak() ntdll.DbgBreakPoint
+@ stdcall DebugBreakProcess(long)
+@ stdcall DebugSetProcessKillOnExit(long)
+@ stdcall DecodePointer(ptr) ntdll.RtlDecodePointer
+@ stdcall DecodeSystemPointer(ptr) ntdll.RtlDecodeSystemPointer
+@ stdcall DefineDosDeviceA(long str str)
+@ stdcall DefineDosDeviceW(long wstr wstr)
+@ stdcall DelayLoadFailureHook(str str)
+@ stdcall DeleteAtom(long)
+;@ stdcall DeleteBoundaryDescriptor ntdll.RtlDeleteBoundaryDescriptor ; Win 7
+@ stdcall DeleteCriticalSection(ptr) ntdll.RtlDeleteCriticalSection
+@ stdcall DeleteFiber(ptr)
+@ stdcall DeleteFileA(str)
+;@ stdcall DeleteFileTransactedA ; Win 7
+;@ stdcall DeleteFileTransactedW ; Win 7
+@ stdcall DeleteFileW(wstr)
+;@ stdcall DeleteProcThreadAttributeList api-ms-win-core-processthreads-l1-1-0.DeleteProcThreadAttributeList ; Win 7
+@ stdcall DeleteTimerQueue(long)
+@ stdcall DeleteTimerQueueEx (long long)
+@ stdcall DeleteTimerQueueTimer(long long long)
+;@ stdcall -arch=x86_64 DeleteUmsCompletionList
+;@ stdcall -arch=x86_64 DeleteUmsThreadContext
+@ stdcall DeleteVolumeMountPointA(str) ;check
+@ stdcall DeleteVolumeMountPointW(wstr) ;check
+;@ stdcall -arch=x86_64 DequeueUmsCompletionListItems
+@ stdcall DeviceIoControl(long long ptr long ptr long ptr ptr)
+@ stdcall DisableThreadLibraryCalls(long)
+;@ stdcall DisableThreadProfiling ; Win 7
+;@ stdcall DisassociateCurrentThreadFromCallback ntdll.TpDisassociateCallback ; Win 7
+@ stdcall DisconnectNamedPipe(long)
+@ stdcall DnsHostnameToComputerNameA (str ptr ptr)
+@ stdcall DnsHostnameToComputerNameW (wstr ptr ptr)
+@ stdcall DosDateTimeToFileTime(long long ptr)
+@ stdcall DosPathToSessionPathA(long str str)
+@ stdcall DosPathToSessionPathW(long wstr wstr)
+@ stdcall DuplicateConsoleHandle(long long long long)
+@ stdcall DuplicateHandle(long long long ptr long long long)
+;@ stdcall EnableThreadProfiling ; Win 7
+@ stdcall EncodePointer(ptr) ntdll.RtlEncodePointer
+@ stdcall EncodeSystemPointer(ptr) ntdll.RtlEncodeSystemPointer
+@ stdcall EndUpdateResourceA(long long)
+@ stdcall EndUpdateResourceW(long long)
+@ stdcall EnterCriticalSection(ptr) ntdll.RtlEnterCriticalSection
+;@ stdcall -arch=x86_64 EnterUmsSchedulingMode
+@ stdcall EnumCalendarInfoA(ptr long long long)
+@ stdcall EnumCalendarInfoExA(ptr long long long)
+;@ stdcall EnumCalendarInfoExEx ; Win 7
+@ stdcall EnumCalendarInfoExW(ptr long long long)
+@ stdcall EnumCalendarInfoW(ptr long long long)
+@ stdcall EnumDateFormatsA(ptr long long)
+@ stdcall EnumDateFormatsExA(ptr long long)
+;@ stdcall EnumDateFormatsExEx ; Win 7
+@ stdcall EnumDateFormatsExW(ptr long long)
+@ stdcall EnumDateFormatsW(ptr long long)
+@ stdcall EnumLanguageGroupLocalesA(ptr long long ptr)
+@ stdcall EnumLanguageGroupLocalesW(ptr long long ptr)
+@ stdcall EnumResourceLanguagesA(long str str ptr long)
+;@ stdcall EnumResourceLanguagesExA ; Win 7
+;@ stdcall EnumResourceLanguagesExW ; Win 7
+@ stdcall EnumResourceLanguagesW(long wstr wstr ptr long)
+@ stdcall EnumResourceNamesA(long str ptr long)
+;@ stdcall EnumResourceNamesExA ; Win 7
+;@ stdcall EnumResourceNamesExW ; Win 7
+@ stdcall EnumResourceNamesW(long wstr ptr long)
+@ stdcall EnumResourceTypesA(long ptr long)
+;@ stdcall EnumResourceTypesExA ; Win 7
+;@ stdcall EnumResourceTypesExW ; Win 7
+@ stdcall EnumResourceTypesW(long ptr long)
+@ stdcall EnumSystemCodePagesA(ptr long)
+@ stdcall EnumSystemCodePagesW(ptr long)
+;@ stdcall EnumSystemFirmwareTables ; Win 7
+@ stdcall EnumSystemGeoID(long long ptr)
+@ stdcall EnumSystemLanguageGroupsA(ptr long ptr)
+@ stdcall EnumSystemLanguageGroupsW(ptr long ptr)
+@ stdcall EnumSystemLocalesA(ptr long)
+;@ stdcall EnumSystemLocalesEx ; Win 7
+@ stdcall EnumSystemLocalesW(ptr long)
+@ stdcall EnumTimeFormatsA(ptr long long)
+;@ stdcall EnumTimeFormatsEx ; Win 7
+@ stdcall EnumTimeFormatsW(ptr long long)
+@ stdcall EnumUILanguagesA(ptr long long)
+@ stdcall EnumUILanguagesW(ptr long long)
+@ stdcall EnumerateLocalComputerNamesA(ptr long str ptr)
+@ stdcall EnumerateLocalComputerNamesW(ptr long wstr ptr)
+@ stdcall EraseTape(ptr long long)
+@ stdcall EscapeCommFunction(long long)
+@ stdcall ExitProcess(long) ; FIXME: ntdll.RtlExitUserProcess
+@ stdcall ExitThread(long) ; FIXME: ntdll.RtlExitUserThread
+@ stdcall ExitVDM(long long)
+@ stdcall ExpandEnvironmentStringsA(str ptr long)
+@ stdcall ExpandEnvironmentStringsW(wstr ptr long)
+@ stdcall ExpungeConsoleCommandHistoryA(long)
+@ stdcall ExpungeConsoleCommandHistoryW(long)
+@ stdcall ExtendVirtualBuffer(long long) ; missing in Win 7
+@ stdcall FatalAppExitA(long str)
+@ stdcall FatalAppExitW(long wstr)
+@ stdcall FatalExit(long)
+@ stdcall FileTimeToDosDateTime(ptr ptr ptr)
+@ stdcall FileTimeToLocalFileTime(ptr ptr)
+@ stdcall FileTimeToSystemTime(ptr ptr)
+@ stdcall FillConsoleOutputAttribute(long long long long ptr)
+@ stdcall FillConsoleOutputCharacterA(long long long long ptr)
+@ stdcall FillConsoleOutputCharacterW(long long long long ptr)
+@ stdcall FindActCtxSectionGuid(long ptr long ptr ptr)
+@ stdcall FindActCtxSectionStringA(long ptr long str ptr)
+@ stdcall FindActCtxSectionStringW(long ptr long wstr ptr)
+@ stdcall FindAtomA(str)
+@ stdcall FindAtomW(wstr)
+@ stdcall FindClose(long)
+@ stdcall FindCloseChangeNotification(long)
+@ stdcall FindFirstChangeNotificationA(str long long)
+@ stdcall FindFirstChangeNotificationW(wstr long long)
+@ stdcall FindFirstFileA(str ptr)
+@ stdcall FindFirstFileExA(str long ptr long ptr long)
+@ stdcall FindFirstFileExW(wstr long ptr long ptr long)
+;@ stdcall FindFirstFileNameTransactedW ; Win 7
+;@ stdcall FindFirstFileNameW ; Win 7
+;@ stdcall FindFirstFileTransactedA ; Win 7
+;@ stdcall FindFirstFileTransactedW ; Win 7
+@ stdcall FindFirstFileW(wstr ptr)
+;@ stdcall FindFirstStreamTransactedW ; Win 7
+@ stdcall FindFirstStreamW(wstr ptr ptr long)
+@ stdcall FindFirstVolumeA(ptr long)
+@ stdcall FindFirstVolumeMountPointA(str ptr long)
+@ stdcall FindFirstVolumeMountPointW(wstr ptr long)
+@ stdcall FindFirstVolumeW(ptr long)
+;@ stdcall FindNLSString ; Win 7
+;@ stdcall FindNLSStringEx ; Win 7
+@ stdcall FindNextChangeNotification(long)
+@ stdcall FindNextFileA(long ptr)
+;@ stdcall FindNextFileNameW ; Win 7
+@ stdcall FindNextFileW(long ptr)
+;@ stdcall FindNextStreamW ; Win 7
+@ stdcall FindNextVolumeA(long ptr long)
+@ stdcall FindNextVolumeMountPointA(long str long)
+@ stdcall FindNextVolumeMountPointW(long wstr long)
+@ stdcall FindNextVolumeW(long ptr long)
+@ stdcall FindResourceA(long str str)
+@ stdcall FindResourceExA(long str str long)
+@ stdcall FindResourceExW(long wstr wstr long)
+@ stdcall FindResourceW(long wstr wstr)
+;@ stdcall FindStringOrdinal ; Win 7
+@ stdcall FindVolumeClose(ptr)
+@ stdcall FindVolumeMountPointClose(ptr)
+;@ stdcall FlsAlloc(ptr) ; missing in XP SP3
+;@ stdcall FlsFree(long) ; missing in XP SP3
+;@ stdcall FlsGetValue(long) ; missing in XP SP3
+;@ stdcall FlsSetValue(long ptr) ; missing in XP SP3
+@ stdcall FlushConsoleInputBuffer(long)
+@ stdcall FlushFileBuffers(long)
+@ stdcall FlushInstructionCache(long long long)
+;@ stdcall FlushProcessWriteBuffers ntdll.NtFlushProcessWriteBuffers ; Win 7
+@ stdcall FlushViewOfFile(ptr long)
+@ stdcall FoldStringA(long str long ptr long)
+@ stdcall FoldStringW(long wstr long ptr long)
+@ stdcall FormatMessageA(long ptr long long ptr long ptr)
+@ stdcall FormatMessageW(long ptr long long ptr long ptr)
+@ stdcall FreeConsole()
+@ stdcall FreeEnvironmentStringsA(ptr)
+@ stdcall FreeEnvironmentStringsW(ptr)
+@ stdcall FreeLibrary(long)
+@ stdcall FreeLibraryAndExitThread(long long)
+;@ stdcall FreeLibraryWhenCallbackReturns ntdll.TpCallbackUnloadDllOnCompletion ; Win 7
+@ stdcall FreeResource(long)
+@ stdcall FreeUserPhysicalPages(long long long)
+@ stdcall FreeVirtualBuffer(ptr) ; missing in Win 7
+@ stdcall GenerateConsoleCtrlEvent(long long)
+@ stdcall GetACP()
+;@ stdcall GetActiveProcessorCount ; Win 7
+;@ stdcall GetActiveProcessorGroupCount ; Win 7
+;@ stdcall GetApplicationRecoveryCallback ; Win 7
+;@ stdcall GetApplicationRestartSettings ; Win 7
+@ stdcall GetAtomNameA(long ptr long)
+@ stdcall GetAtomNameW(long ptr long)
+@ stdcall GetBinaryType(str ptr) GetBinaryTypeA
+@ stdcall GetBinaryTypeA(str ptr)
+@ stdcall GetBinaryTypeW(wstr ptr)
+@ stdcall GetCPFileNameFromRegistry(long wstr long) ;check missing in Win 7
+@ stdcall GetCPInfo(long ptr)
+@ stdcall GetCPInfoExA(long long ptr)
+@ stdcall GetCPInfoExW(long long ptr)
+;@ stdcall GetCalendarDateFormat ; Win 7
+;@ stdcall GetCalendarDateFormatEx ; Win 7
+;@ stdcall GetCalendarDaysInMonth ; Win 7
+;@ stdcall GetCalendarDifferenceInDays ; Win 7
+@ stdcall GetCalendarInfoA(long long long ptr long ptr)
+;@ stdcall GetCalendarInfoEx ; Win 7
+@ stdcall GetCalendarInfoW(long long long ptr long ptr)
+;@ stdcall GetCalendarMonthsInYear ; Win 7
+;@ stdcall GetCalendarSupportedDateRange ; Win 7
+;@ stdcall GetCalendarWeekNumber ; Win 7
+@ stdcall GetComPlusPackageInstallStatus()
+@ stdcall GetCommConfig(long ptr long)
+@ stdcall GetCommMask(long ptr)
+@ stdcall GetCommModemStatus(long ptr)
+@ stdcall GetCommProperties(long ptr)
+@ stdcall GetCommState(long ptr)
+@ stdcall GetCommTimeouts(long ptr)
+@ stdcall GetCommandLineA()
+@ stdcall GetCommandLineW()
+@ stdcall GetCompressedFileSizeA(long ptr)
+;@ stdcall GetCompressedFileSizeTransactedA ; Win 7
+;@ stdcall GetCompressedFileSizeTransactedW ; Win 7
+@ stdcall GetCompressedFileSizeW(long ptr)
+@ stdcall GetComputerNameA(ptr ptr)
+@ stdcall GetComputerNameExA(long ptr ptr)
+@ stdcall GetComputerNameExW(long ptr ptr)
+@ stdcall GetComputerNameW(ptr ptr)
+@ stdcall GetConsoleAliasA(str str long str)
+@ stdcall GetConsoleAliasExesA(str long)
+@ stdcall GetConsoleAliasExesLengthA()
+@ stdcall GetConsoleAliasExesLengthW()
+@ stdcall GetConsoleAliasExesW(wstr long)
+@ stdcall GetConsoleAliasW(wstr ptr long wstr)
+@ stdcall GetConsoleAliasesA(str long str)
+@ stdcall GetConsoleAliasesLengthA(str)
+@ stdcall GetConsoleAliasesLengthW(wstr)
+@ stdcall GetConsoleAliasesW(wstr long wstr)
+@ stdcall GetConsoleCP()
+@ stdcall GetConsoleCharType(long long ptr)
+@ stdcall GetConsoleCommandHistoryA(long long long)
+@ stdcall GetConsoleCommandHistoryLengthA(long)
+@ stdcall GetConsoleCommandHistoryLengthW(long)
+@ stdcall GetConsoleCommandHistoryW(long long long)
+@ stdcall GetConsoleCursorInfo(long ptr)
+@ stdcall GetConsoleCursorMode(long ptr ptr)
+@ stdcall GetConsoleDisplayMode(ptr)
+@ stdcall GetConsoleFontInfo(long long long ptr)
+@ stdcall GetConsoleFontSize(long long)
+@ stdcall GetConsoleHardwareState(long long ptr)
+@ stdcall GetConsoleHistoryInfo(ptr)
+@ stdcall GetConsoleInputExeNameA(long ptr)
+@ stdcall GetConsoleInputExeNameW(long ptr)
+@ stdcall GetConsoleInputWaitHandle()
+@ stdcall GetConsoleKeyboardLayoutNameA(ptr)
+@ stdcall GetConsoleKeyboardLayoutNameW(ptr)
+@ stdcall GetConsoleMode(long ptr)
+@ stdcall GetConsoleNlsMode(long ptr)
+;@ stdcall GetConsoleOriginalTitleA ; Win 7
+;@ stdcall GetConsoleOriginalTitleW ; Win 7
+@ stdcall GetConsoleOutputCP()
+@ stdcall GetConsoleProcessList(ptr long) ; missing in XP SP3
+@ stdcall GetConsoleScreenBufferInfo(long ptr)
+;@ stdcall GetConsoleScreenBufferInfoEx ; Win 7
+@ stdcall GetConsoleSelectionInfo(ptr)
+@ stdcall GetConsoleTitleA(ptr long)
+@ stdcall GetConsoleTitleW(ptr long)
+@ stdcall GetConsoleWindow()
+@ stdcall GetCurrencyFormatA(long long str ptr str long)
+;@ stdcall GetCurrencyFormatEx ; Win 7
+@ stdcall GetCurrencyFormatW(long long str ptr str long)
+@ stdcall GetCurrentActCtx(ptr)
+@ stdcall GetCurrentConsoleFont(long long ptr)
+;@ stdcall GetCurrentConsoleFontEx ; Win 7
+@ stdcall GetCurrentDirectoryA(long ptr)
+@ stdcall GetCurrentDirectoryW(long ptr)
+@ stdcall GetCurrentProcess()
+@ stdcall GetCurrentProcessId()
+@ stdcall GetCurrentProcessorNumber() ntdll.RtlGetCurrentProcessorNumber
+;@ stdcall GetCurrentProcessorNumberEx ntdll.RtlGetCurrentProcessorNumberEx ; Win 7
+@ stdcall GetCurrentThread()
+@ stdcall GetCurrentThreadId()
+;@ stdcall GetCurrentUmsThread
+@ stdcall GetDateFormatA(long long ptr str ptr long)
+;@ stdcall GetDateFormatEx ; Win 7
+@ stdcall GetDateFormatW(long long ptr wstr ptr long)
+@ stub GetDaylightFlag ; missing in XP SP3 and Win 7
+@ stdcall GetDefaultCommConfigA(str ptr long)
+@ stdcall GetDefaultCommConfigW(wstr ptr long)
+@ stdcall GetDefaultSortkeySize(ptr) ; missing in Win 7
+@ stdcall GetDevicePowerState(long ptr)
+@ stdcall GetDiskFreeSpaceA(str ptr ptr ptr ptr)
+@ stdcall GetDiskFreeSpaceExA (str ptr ptr ptr)
+@ stdcall GetDiskFreeSpaceExW (wstr ptr ptr ptr)
+@ stdcall GetDiskFreeSpaceW(wstr ptr ptr ptr ptr)
+@ stdcall GetDllDirectoryA(long ptr)
+@ stdcall GetDllDirectoryW(long ptr)
+@ stdcall GetDriveTypeA(str)
+@ stdcall GetDriveTypeW(wstr)
+;@ stdcall GetDurationFormat ; Win 7
+;@ stdcall GetDurationFormatEx ; Win 7
+;@ stdcall GetDynamicTimeZoneInformation ; Win 7
+;@ stdcall GetEnabledExtendedFeatures api-ms-win-core-xstate-l1-1-0.RtlGetEnabledExtendedFeatures ; Win 7
+@ stdcall GetEnvironmentStrings()
+@ stdcall GetEnvironmentStringsA() GetEnvironmentStrings
+@ stdcall GetEnvironmentStringsW()
+@ stdcall GetEnvironmentVariableA(str ptr long)
+@ stdcall GetEnvironmentVariableW(wstr ptr long)
+;@ stdcall GetEraNameCountedString ; Win 7
+@ stdcall GetErrorMode()
+@ stdcall GetExitCodeProcess(long ptr)
+@ stdcall GetExitCodeThread(long ptr)
+@ stdcall GetExpandedNameA(str ptr)
+@ stdcall GetExpandedNameW(wstr ptr)
+;@ stdcall GetExtendedContextLength ; Win 7
+;@ stdcall GetExtendedFeaturesMask api-ms-win-core-xstate-l1-1-0.RtlGetExtendedFeaturesMask ; Win 7
+@ stdcall GetFileAttributesA(str)
+@ stdcall GetFileAttributesByHandle(long ptr long) ; missing in Win 7
+@ stdcall GetFileAttributesExA(str long ptr)
+@ stdcall GetFileAttributesExW(wstr long ptr)
+;@ stdcall GetFileAttributesTransactedA ; Win 7
+;@ stdcall GetFileAttributesTransactedW ; Win 7
+@ stdcall GetFileAttributesW(wstr)
+@ stdcall GetFileBandwidthReservation(long ptr ptr ptr ptr ptr)
+@ stdcall GetFileInformationByHandle(long ptr)
+;@ stdcall GetFileInformationByHandleEx ; Win 7
+;@ stdcall GetFileMUIInfo ; Win 7
+;@ stdcall GetFileMUIPath ; Win 7
+@ stdcall GetFileSize(long ptr)
+@ stdcall GetFileSizeEx(long ptr)
+@ stdcall GetFileTime(long ptr ptr ptr)
+@ stdcall GetFileType(long)
+@ stdcall GetFinalPathNameByHandleA(long str long long)
+@ stdcall GetFinalPathNameByHandleW(long wstr long long)
+@ stdcall GetFirmwareEnvironmentVariableA(str str ptr long)
+@ stdcall GetFirmwareEnvironmentVariableW(wstr wstr ptr long)
+@ stdcall GetFullPathNameA(str long ptr ptr)
+;@ stdcall GetFullPathNameTransactedA ; Win 7
+;@ stdcall GetFullPathNameTransactedW ; Win 7
+@ stdcall GetFullPathNameW(wstr long ptr ptr)
+@ stdcall GetGeoInfoA(long long ptr long long)
+@ stdcall GetGeoInfoW(long long ptr long long)
+@ stdcall GetHandleContext(long) ; missing on x64
+@ stdcall GetHandleInformation(long ptr)
+@ stub GetSCallbackTarget ; missing in XP SP3 and Win 7
+@ stub GetSCallbackTemplate ; missing in XP SP3 and Win 7
+@ stdcall GetLargePageMinimum()
+@ stdcall GetLargestConsoleWindowSize(long)
+@ stdcall GetLastError() ntdll.RtlGetLastWin32Error
+@ stdcall GetLinguistLangSize(ptr) ; missing in Win 7
+@ stdcall GetLocalTime(ptr)
+@ stdcall GetLocaleInfoA(long long ptr long)
+@ stdcall GetLocaleInfoEx(wstr long wstr long) ; Vista+
+@ stdcall GetLocaleInfoW(long long ptr long)
+@ stdcall GetLogicalDriveStringsA(long ptr)
+@ stdcall GetLogicalDriveStringsW(long ptr)
+@ stdcall GetLogicalDrives()
+@ stdcall GetLogicalProcessorInformation(ptr ptr)
+;@ stdcall GetLogicalProcessorInformationEx api-ms-win-core-sysinfo-l1-1-0.GetLogicalProcessorInformationEx ; Win 7
+@ stdcall GetLongPathNameA (str long long)
+;@ stdcall GetLongPathNameTransactedA ; Win 7
+;@ stdcall GetLongPathNameTransactedW ; Win 7
+@ stdcall GetLongPathNameW (wstr long long)
+@ stdcall GetMailslotInfo(long ptr ptr ptr ptr)
+;@ stdcall GetMaximumProcessorCount ; Win 7
+;@ stdcall GetMaximumProcessorGroupCount ; Win 7
+@ stdcall GetModuleFileNameA(long ptr long)
+@ stdcall GetModuleFileNameW(long ptr long)
+@ stdcall GetModuleHandleA(str)
+@ stdcall GetModuleHandleExA(long ptr ptr)
+@ stdcall GetModuleHandleExW(long ptr ptr)
+@ stdcall GetModuleHandleW(wstr)
+;@ stdcall GetNLSVersion ; Win 7
+;@ stdcall GetNLSVersionEx ; Win 7
+;@ stdcall GetNamedPipeAttribute ; Win 7
+;@ stdcall GetNamedPipeClientComputerNameA ; Win 7
+;@ stdcall GetNamedPipeClientComputerNameW ; Win 7
+;@ stdcall GetNamedPipeClientProcessId ; Win 7
+;@ stdcall GetNamedPipeClientSessionId ; Win 7
+@ stdcall GetNamedPipeHandleStateA(long ptr ptr ptr ptr str long)
+@ stdcall GetNamedPipeHandleStateW(long ptr ptr ptr ptr wstr long)
+@ stdcall GetNamedPipeInfo(long ptr ptr ptr ptr)
+;@ stdcall GetNamedPipeServerProcessId ; Win 7
+;@ stdcall GetNamedPipeServerSessionId ; Win 7
+@ stdcall GetNativeSystemInfo(ptr)
+;@ stdcall -arch=x86_64 GetNextUmsListItem
+@ stdcall GetNextVDMCommand(long)
+@ stdcall GetNlsSectionName(long long double str str double) ; missing in Win 7
+@ stdcall GetNumaAvailableMemory(ptr double ptr) ; missing in Win 7
+@ stdcall GetNumaAvailableMemoryNode(double ptr)
+;@ stdcall GetNumaAvailableMemoryNodeEx ; Win 7
+@ stdcall GetNumaHighestNodeNumber(ptr)
+;@ stdcall GetNumaNodeNumberFromHandle ; Win 7
+@ stdcall GetNumaNodeProcessorMask(double ptr)
+;@ stdcall GetNumaNodeProcessorMaskEx ; Win 7
+@ stdcall GetNumaProcessorMap(ptr double ptr) ; missing in Win 7
+@ stdcall GetNumaProcessorNode(double ptr)
+;@ stdcall GetNumaProcessorNodeEx ; Win 7
+;@ stdcall GetNumaProximityNode ; Win 7
+;@ stdcall GetNumaProximityNodeEx ; Win 7
+@ stdcall GetNumberFormatA(long long str ptr ptr long)
+;@ stdcall GetNumberFormatEx ; Win 7
+@ stdcall GetNumberFormatW(long long wstr ptr ptr long)
+@ stdcall GetNumberOfConsoleFonts()
+@ stdcall GetNumberOfConsoleInputEvents(long ptr)
+@ stdcall GetNumberOfConsoleMouseButtons(ptr)
+@ stdcall GetOEMCP()
+@ stdcall GetOverlappedResult(long ptr ptr long)
+;@ stdcall GetPhysicallyInstalledSystemMemory ; Win 7
+@ stdcall GetPriorityClass(long)
+@ stdcall GetPrivateProfileIntA(str str long str)
+@ stdcall GetPrivateProfileIntW(wstr wstr long wstr)
+@ stdcall GetPrivateProfileSectionA(str ptr long str)
+@ stdcall GetPrivateProfileSectionNamesA(ptr long str)
+@ stdcall GetPrivateProfileSectionNamesW(ptr long wstr)
+@ stdcall GetPrivateProfileSectionW(wstr ptr long wstr)
+@ stdcall GetPrivateProfileStringA(str str str ptr long str)
+@ stdcall GetPrivateProfileStringW(wstr wstr wstr ptr long wstr)
+@ stdcall GetPrivateProfileStructA (str str ptr long str)
+@ stdcall GetPrivateProfileStructW(wstr wstr ptr long wstr)
+@ stdcall GetProcAddress(long str)
+@ stdcall GetProcessAffinityMask(long ptr ptr)
+@ stdcall GetProcessFlags(long)
+;@ stdcall GetProcessDEPPolicy ; Win 7
+;@ stdcall GetProcessGroupAffinity ; Win 7
+@ stdcall GetProcessHandleCount(long ptr)
+@ stdcall GetProcessHeap()
+@ stdcall GetProcessHeaps(long ptr)
+@ stdcall GetProcessId(long)
+;@ stdcall GetProcessIdOfThread ; Win 7
+@ stdcall GetProcessIoCounters(long ptr)
+;@ stdcall GetProcessPreferredUILanguages ; Win 7
+@ stdcall GetProcessPriorityBoost(long ptr)
+@ stdcall GetProcessShutdownParameters(ptr ptr)
+@ stdcall GetProcessTimes(long ptr ptr ptr ptr)
+@ stdcall GetProcessVersion(long)
+@ stdcall GetProcessWorkingSetSize(long ptr ptr)
+;@ stdcall GetProcessWorkingSetSizeEx ; Win 7
+;@ stdcall GetProcessorSystemCycleTime ; Win 7
+@ stdcall GetProductInfo(long long long long ptr)
+@ stub GetProductName
+@ stdcall GetProfileIntA(str str long)
+@ stdcall GetProfileIntW(wstr wstr long)
+@ stdcall GetProfileSectionA(str ptr long)
+@ stdcall GetProfileSectionW(wstr ptr long)
+@ stdcall GetProfileStringA(str str str ptr long)
+@ stdcall GetProfileStringW(wstr wstr wstr ptr long)
+@ stdcall GetQueuedCompletionStatus(long ptr ptr ptr long)
+;@ stdcall GetQueuedCompletionStatusEx ; Win 7
+@ stub GetLSCallbackTarget ; missing in XP SP3 and Win 7
+@ stub GetLSCallbackTemplate ; missing in XP SP3 and Win 7
+@ stdcall GetShortPathNameA(str ptr long)
+@ stdcall GetShortPathNameW(wstr ptr long)
+@ stdcall GetStartupInfoA(ptr)
+@ stdcall GetStartupInfoW(ptr)
+@ stdcall GetStdHandle(long)
+;@ stdcall GetStringScripts ; Win 7
+@ stdcall GetStringTypeA(long long str long ptr)
+@ stdcall GetStringTypeExA(long long str long ptr)
+@ stdcall GetStringTypeExW(long long wstr long ptr)
+@ stdcall GetStringTypeW(long wstr long ptr)
+;@ stdcall GetSystemDEPPolicy ; Win 7
+@ stdcall GetSystemDefaultLCID()
+@ stdcall GetSystemDefaultLangID()
+;@ stdcall GetSystemDefaultLocaleName ; Win 7
+@ stdcall GetSystemDefaultUILanguage()
+@ stdcall GetSystemDirectoryA(ptr long)
+@ stdcall GetSystemDirectoryW(ptr long)
+;@ stdcall GetSystemFileCacheSize ; Win 7
+;@ stdcall GetSystemFirmwareTable ; Win 7
+@ stdcall GetSystemInfo(ptr)
+@ stdcall GetSystemPowerStatus(ptr)
+;@ stdcall GetSystemPreferredUILanguages ; Win 7
+@ stdcall GetSystemRegistryQuota(ptr ptr)
+@ stdcall GetSystemTime(ptr)
+@ stdcall GetSystemTimeAdjustment(ptr ptr ptr)
+@ stdcall GetSystemTimeAsFileTime(ptr)
+@ stdcall GetSystemTimes(ptr ptr ptr)
+@ stdcall GetSystemWindowsDirectoryA(ptr long)
+@ stdcall GetSystemWindowsDirectoryW(ptr long)
+@ stdcall GetSystemWow64DirectoryA(ptr long)
+@ stdcall GetSystemWow64DirectoryW(ptr long)
+@ stdcall GetTapeParameters(ptr long ptr ptr)
+@ stdcall GetTapePosition(ptr long ptr ptr ptr)
+@ stdcall GetTapeStatus(ptr)
+@ stdcall GetTempFileNameA(str str long ptr)
+@ stdcall GetTempFileNameW(wstr wstr long ptr)
+@ stdcall GetTempPathA(long ptr)
+@ stdcall GetTempPathW(long ptr)
+@ stdcall GetThreadContext(long ptr)
+@ stdcall GetThreadErrorMode()
+;@ stdcall GetThreadGroupAffinity ; Win 7
+@ stdcall GetThreadIOPendingFlag(long ptr)
+@ stdcall GetThreadId(ptr)
+;@ stdcall GetThreadIdealProcessorEx ; Win 7
+@ stdcall GetThreadLocale()
+;@ stdcall GetThreadPreferredUILanguages ; Win 7
+@ stdcall GetThreadPriority(long)
+@ stdcall GetThreadPriorityBoost(long ptr)
+@ stdcall GetThreadSelectorEntry(long long ptr)
+@ stdcall GetThreadTimes(long ptr ptr ptr ptr)
+;@ stdcall GetThreadUILanguage ; Win 7
+@ stdcall GetTickCount()
+@ stdcall -ret64 GetTickCount64()
+@ stdcall GetTimeFormatA(long long ptr str ptr long)
+;@ stdcall GetTimeFormatEx ; Win 7
+@ stdcall GetTimeFormatW(long long ptr wstr ptr long)
+@ stdcall GetTimeZoneInformation(ptr)
+;@ stdcall GetTimeZoneInformationForYear ; Win 7
+;@ stdcall GetUILanguageInfo ; Win 7
+;@ stdcall -arch=x86_64 GetUmsCompletionListEvent
+@ stdcall GetUserDefaultLCID()
+@ stdcall GetUserDefaultLangID()
+;@ stdcall GetUserDefaultLocaleName ; Win 7
+@ stdcall GetUserDefaultUILanguage()
+@ stdcall GetUserGeoID(long)
+;@ stdcall GetUserPreferredUILanguages ; Win 7
+@ stdcall GetVDMCurrentDirectories(long long)
+@ stdcall GetVersion()
+@ stdcall GetVersionExA(ptr)
+@ stdcall GetVersionExW(ptr)
+@ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long)
+;@ stdcall GetVolumeInformationByHandleW ; Win 7
+@ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long)
+@ stdcall GetVolumeNameForVolumeMountPointA(str ptr long)
+@ stdcall GetVolumeNameForVolumeMountPointW(wstr ptr long)
+@ stdcall GetVolumePathNameA(str ptr long)
+@ stdcall GetVolumePathNameW(wstr ptr long)
+@ stdcall GetVolumePathNamesForVolumeNameA(str str long ptr)
+@ stdcall GetVolumePathNamesForVolumeNameW(wstr wstr long ptr)
+@ stdcall GetWindowsDirectoryA(ptr long)
+@ stdcall GetWindowsDirectoryW(ptr long)
+@ stdcall GetWriteWatch(long ptr long ptr ptr ptr)
+@ stdcall GlobalAddAtomA(str)
+@ stdcall GlobalAddAtomW(wstr)
+@ stdcall GlobalAlloc(long long)
+@ stdcall GlobalCompact(long)
+@ stdcall GlobalDeleteAtom(long)
+@ stdcall GlobalFindAtomA(str)
+@ stdcall GlobalFindAtomW(wstr)
+@ stdcall GlobalFix(long)
+@ stdcall GlobalFlags(long)
+@ stdcall GlobalFree(long)
+@ stdcall GlobalGetAtomNameA(long ptr long)
+@ stdcall GlobalGetAtomNameW(long ptr long)
+@ stdcall GlobalHandle(ptr)
+@ stdcall GlobalLock(long)
+@ stdcall GlobalMemoryStatus(ptr)
+@ stdcall GlobalMemoryStatusEx(ptr)
+@ stdcall GlobalReAlloc(long long long)
+@ stdcall GlobalSize(long)
+@ stdcall GlobalUnWire(long)
+@ stdcall GlobalUnfix(long)
+@ stdcall GlobalUnlock(long)
+@ stdcall GlobalWire(long)
+@ stdcall Heap32First(ptr long long)
+@ stdcall Heap32ListFirst(long ptr)
+@ stdcall Heap32ListNext(long ptr)
+@ stdcall Heap32Next(ptr)
+@ stdcall HeapAlloc(long long long) ntdll.RtlAllocateHeap
+@ stdcall HeapCompact(long long)
+@ stdcall HeapCreate(long long long)
+@ stdcall HeapCreateTagsW(long long wstr wstr) ; missing in Win 7
+@ stdcall HeapDestroy(long)
+@ stdcall HeapExtend(long long ptr long) ; missing in Win 7
+@ stdcall HeapFree(long long long) ntdll.RtlFreeHeap
+@ stdcall HeapLock(long)
+@ stdcall HeapQueryInformation(long long ptr long ptr)
+@ stdcall HeapQueryTagW(long long long long ptr) ; missing in Win 7
+@ stdcall HeapReAlloc(long long ptr long) ntdll.RtlReAllocateHeap
+@ stub HeapSetFlags ; missing in XP SP3 and Win 7
+@ stdcall HeapSetInformation(ptr long ptr long)
+@ stdcall HeapSize(long long ptr) ntdll.RtlSizeHeap
+@ stdcall HeapSummary(long long ptr)
+@ stdcall HeapUnlock(long)
+@ stdcall HeapUsage(long long long long ptr) ; missing in Win 7
+@ stdcall HeapValidate(long long ptr)
+@ stdcall HeapWalk(long ptr)
+;@ stdcall IdnToAscii ; Win 7
+;@ stdcall IdnToNameprepUnicode ; Win 7
+;@ stdcall IdnToUnicode ; Win 7
+@ stdcall InitAtomTable(long)
+;@ stdcall InitOnceBeginInitialize ; Win 7
+;@ stdcall InitOnceComplete ; Win 7
+;@ stdcall InitOnceExecuteOnce ; Win 7
+;@ stdcall InitOnceInitialize ntdll.RtlRunOnceInitialize ; Win 7
+;@ stdcall InitializeConditionVariable ntdll.RtlInitializeConditionVariable ; Win 7
+@ stdcall InitializeCriticalSection(ptr) ; FIXME: ntdll.RtlInitializeCriticalSection
+@ stdcall InitializeCriticalSectionAndSpinCount(ptr long)
+@ stdcall InitializeCriticalSectionEx(ptr long long)
+;@ stdcall InitializeExtendedContext ; Win 7
+;@ stdcall InitializeProcThreadAttributeList api-ms-win-core-processthreads-l1-1-0.InitializeProcThreadAttributeList ; Win 7
+@ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
+@ stdcall InitializeSRWLock(ptr) ntdll.RtlInitializeSRWLock
+@ stdcall -arch=i386 InterlockedCompareExchange (ptr long long)
+@ stdcall -arch=i386 -ret64 InterlockedCompareExchange64(ptr double double) ntdll.RtlInterlockedCompareExchange64
+@ stdcall -arch=i386 InterlockedDecrement(ptr)
+@ stdcall -arch=i386 InterlockedExchange(ptr long)
+@ stdcall -arch=i386 InterlockedExchangeAdd (ptr long )
+@ stdcall InterlockedFlushSList(ptr) ntdll.RtlInterlockedFlushSList
+@ stdcall -arch=i386 InterlockedIncrement(ptr)
+@ stdcall InterlockedPopEntrySList(ptr) ntdll.RtlInterlockedPopEntrySList
+@ stdcall InterlockedPushEntrySList(ptr ptr) ntdll.RtlInterlockedPushEntrySList
+;@ stdcall InterlockedPushListSList ntdll.RtlInterlockedPushListSList ; Win 7
+@ stdcall InvalidateConsoleDIBits(long long)
+@ stub InvalidateNSCache ; missing in XP SP3 and Win 7
+@ stdcall IsBadCodePtr(ptr)
+@ stdcall IsBadHugeReadPtr(ptr long)
+@ stdcall IsBadHugeWritePtr(ptr long)
+@ stdcall IsBadReadPtr(ptr long)
+@ stdcall IsBadStringPtrA(ptr long)
+@ stdcall IsBadStringPtrW(ptr long)
+@ stdcall IsBadWritePtr(ptr long)
+;@ stdcall IsCalendarLeapDay ; Win 7
+;@ stdcall IsCalendarLeapMonth ; Win 7
+;@ stdcall IsCalendarLeapYear ; Win 7
+@ stdcall IsDBCSLeadByte(long)
+@ stdcall IsDBCSLeadByteEx(long long)
+@ stdcall IsDebuggerPresent()
+;@ stdcall IsNLSDefinedString ; Win 7
+;@ stdcall IsNormalizedString ; Win 7
+@ stdcall IsProcessInJob(long long ptr)
+@ stdcall IsProcessorFeaturePresent(long)
+@ stdcall IsSystemResumeAutomatic()
+@ stdcall IsThreadAFiber()
+;@ stdcall IsThreadAFiber ; Win 7
+;@ stdcall IsThreadpoolTimerSet ntdll.TpIsTimerSet ; Win 7
+;@ stdcall IsTimeZoneRedirectionEnabled ; Win 7
+;@ stdcall IsValidCalDateTime ; Win 7
+@ stdcall IsValidCodePage(long)
+@ stdcall IsValidLanguageGroup(long long)
+@ stdcall IsValidLocale(long long)
+;@ stdcall IsValidLocaleName ; Win 7
+@ stdcall IsValidUILanguage(long) ; missing in Win 7
+@ stdcall IsWow64Process(ptr ptr)
+;@ stdcall K32EmptyWorkingSet ; Win 7
+;@ stdcall K32EnumDeviceDrivers ; Win 7
+;@ stdcall K32EnumPageFilesA ; Win 7
+;@ stdcall K32EnumPageFilesW ; Win 7
+;@ stdcall K32EnumProcessModules ; Win 7
+;@ stdcall K32EnumProcessModulesEx ; Win 7
+;@ stdcall K32EnumProcesses ; Win 7
+;@ stdcall K32GetDeviceDriverBaseNameA ; Win 7
+;@ stdcall K32GetDeviceDriverBaseNameW ; Win 7
+;@ stdcall K32GetDeviceDriverFileNameA ; Win 7
+;@ stdcall K32GetDeviceDriverFileNameW ; Win 7
+;@ stdcall K32GetMappedFileNameA ; Win 7
+;@ stdcall K32GetMappedFileNameW ; Win 7
+;@ stdcall K32GetModuleBaseNameA ; Win 7
+;@ stdcall K32GetModuleBaseNameW ; Win 7
+;@ stdcall K32GetModuleFileNameExA ; Win 7
+;@ stdcall K32GetModuleFileNameExW ; Win 7
+;@ stdcall K32GetModuleInformation ; Win 7
+;@ stdcall K32GetPerformanceInfo ; Win 7
+;@ stdcall K32GetProcessImageFileNameA ; Win 7
+;@ stdcall K32GetProcessImageFileNameW ; Win 7
+;@ stdcall K32GetProcessMemoryInfo ; Win 7
+;@ stdcall K32GetWsChanges ; Win 7
+;@ stdcall K32GetWsChangesEx ; Win 7
+;@ stdcall K32InitializeProcessForWsWatch ; Win 7
+;@ stdcall K32QueryWorkingSet ; Win 7
+;@ stdcall K32QueryWorkingSetEx ; Win 7
+@ stdcall LCIDToLocaleName(long wstr long long) ; needed for wine gecko; missing in XP SP3
+@ stdcall LCMapStringA(long long str long ptr long)
+;@ stdcall LCMapStringEx ; Win 7
+@ stdcall LCMapStringW(long long wstr long ptr long)
+@ stdcall LZClose(long)
+;@ stdcall LZCloseFile ; Win 7
+@ stdcall LZCopy(long long)
+;@ stdcall LZCreateFileW ; Win 7
+@ stdcall LZDone()
+@ stdcall LZInit(long)
+@ stdcall LZOpenFileA(str ptr long)
+@ stdcall LZOpenFileW(wstr ptr long)
+@ stdcall LZRead(long str long)
+@ stdcall LZSeek(long long long)
+@ stdcall LZStart()
+@ stdcall LeaveCriticalSection(ptr) ntdll.RtlLeaveCriticalSection
+;@ stdcall LeaveCriticalSectionWhenCallbackReturns ntdll.TpCallbackLeaveCriticalSectionOnCompletion ; Win 7
+;@ stdcall LoadAppInitDlls ; Win 7
+@ stdcall LoadLibraryA(str)
+@ stdcall LoadLibraryExA( str long long)
+@ stdcall LoadLibraryExW(wstr long long)
+@ stdcall LoadLibraryW(wstr)
+@ stdcall LoadModule(str ptr)
+@ stdcall LoadResource(long long)
+;@ stdcall LoadStringBaseExW ; Win 7
+;@ stdcall LoadStringBaseW ; Win 7
+@ stdcall LocalAlloc(long long)
+@ stdcall LocalCompact(long)
+@ stdcall LocalFileTimeToFileTime(ptr ptr)
+@ stdcall LocalFlags(long)
+@ stdcall LocalFree(long)
+@ stdcall LocalHandle(ptr)
+@ stdcall LocalLock(long)
+@ stdcall LocalReAlloc(long long long)
+@ stdcall LocalShrink(long long)
+@ stdcall LocalSize(long)
+@ stdcall LocalUnlock(long)
+;@ stub LocaleNameToLCID ; missing in XP SP3
+;@ stdcall LocateExtendedFeature api-ms-win-core-xstate-l1-1-0.RtlLocateExtendedFeature ; Win 7
+;@ stdcall LocateLegacyContext api-ms-win-core-xstate-l1-1-0.RtlLocateLegacyContext ; Win 7
+@ stdcall LockFile(long long long long long)
+@ stdcall LockFileEx(long long long long long ptr)
+@ stdcall LockResource(long)
+@ stdcall MakeCriticalSectionGlobal(ptr)
+
+@ stdcall MapUserPhysicalPages(ptr long ptr)
+@ stdcall MapUserPhysicalPagesScatter(ptr long ptr)
+@ stdcall MapViewOfFile(long long long long long)
+@ stdcall MapViewOfFileEx(long long long long long ptr)
+;@ stdcall MapViewOfFileExNuma ; Win 7
+@ stdcall Module32First(long ptr)
+@ stdcall Module32FirstW(long ptr)
+@ stdcall Module32Next(long ptr)
+@ stdcall Module32NextW(long ptr)
+@ stdcall MoveFileA(str str)
+@ stdcall MoveFileExA(str str long)
+@ stdcall MoveFileExW(wstr wstr long)
+;@ stdcall MoveFileTransactedA ; Win 7
+;@ stdcall MoveFileTransactedW ; Win 7
+@ stdcall MoveFileW(wstr wstr)
+@ stdcall MoveFileWithProgressA(str str ptr ptr long)
+@ stdcall MoveFileWithProgressW(wstr wstr ptr ptr long)
+@ stdcall MulDiv(long long long)
+@ stdcall MultiByteToWideChar(long long str long ptr long)
+@ stdcall NeedCurrentDirectoryForExePathA(str)
+@ stdcall NeedCurrentDirectoryForExePathW(wstr)
+;@ stdcall NlsCheckPolicy ; Win 7
+@ stdcall NlsConvertIntegerToString(double double double wstr double) ; missing in Win 7
+;@ stdcall NlsEventDataDescCreate ; Win 7
+@ stdcall NlsGetCacheUpdateCount()
+@ stub NlsResetProcessLocale ; missing in XP SP3 and Win 7
+;@ stdcall NlsUpdateLocale ; Win 7
+;@ stdcall NlsUpdateSystemLocale ; Win 7
+;@ stdcall NlsWriteEtwEvent ; Win 7
+;@ stdcall NormalizeString ; Win 7
+;@ stdcall NotifyMountMgr ; Win 7
+@ stub NotifyNLSUserCache ; missing in XP SP3 and win 7
+;@ stdcall NotifyUILanguageChange ; Win 7
+@ stdcall NumaVirtualQueryNode(long long long long) ; missing in win 7
+@ stdcall OpenConsoleW(wstr long long long)
+@ stdcall OpenDataFile(long long) ; missing in Win 7
+@ stdcall OpenEventA(long long str)
+@ stdcall OpenEventW(long long wstr)
+@ stdcall OpenFile(str ptr long)
+;@ stdcall OpenFileById ; Win 7
+@ stdcall OpenFileMappingA(long long str)
+@ stdcall OpenFileMappingW(long long wstr)
+@ stdcall OpenJobObjectA(long long str)
+@ stdcall OpenJobObjectW(long long wstr)
+@ stdcall OpenMutexA(long long str)
+@ stdcall OpenMutexW(long long wstr)
+;@ stdcall OpenPrivateNamespaceA ; Win 7
+;@ stdcall OpenPrivateNamespaceW ; Win 7
+@ stdcall OpenProcess(long long long)
+;@ stdcall OpenProcessToken api-ms-win-core-processthreads-l1-1-0.OpenProcessToken ; Win 7
+@ stdcall OpenProfileUserMapping()
+@ stdcall OpenSemaphoreA(long long str)
+@ stdcall OpenSemaphoreW(long long wstr)
+@ stdcall OpenThread(long long long)
+;@ stdcall OpenThreadToken api-ms-win-core-processthreads-l1-1-0.OpenThreadToken ; win 7
+@ stdcall OpenWaitableTimerA(long long str)
+@ stdcall OpenWaitableTimerW(long long wstr)
+@ stdcall OutputDebugStringA(str)
+@ stdcall OutputDebugStringW(wstr)
+@ stdcall PeekConsoleInputA(ptr ptr long ptr)
+@ stdcall PeekConsoleInputW(ptr ptr long ptr)
+@ stdcall PeekNamedPipe(long ptr long ptr ptr ptr)
+@ stdcall PostQueuedCompletionStatus(long long ptr ptr)
+;@ stdcall PowerClearRequest ; Win 7
+;@ stdcall PowerCreateRequest ; Win 7
+;@ stdcall PowerSetRequest ; Win 7
+@ stdcall PrepareTape(ptr long long)
+@ stdcall PrivCopyFileExW(wstr wstr ptr ptr long long)
+@ stdcall PrivMoveFileIdentityW(long long long)
+@ stdcall Process32First (ptr ptr)
+@ stdcall Process32FirstW (ptr ptr)
+@ stdcall Process32Next (ptr ptr)
+@ stdcall Process32NextW (ptr ptr)
+@ stdcall ProcessIdToSessionId(long ptr)
+@ stdcall PulseEvent(long)
+@ stdcall PurgeComm(long long)
+;@ stdcall QueryActCtxSettingsW ; Win 7
+;@ stdcall QueryActCtxW(long ptr ptr long ptr long ptr)
+@ stdcall QueryActCtxW(long ptr ptr long ptr long ptr)
+@ stdcall QueryDepthSList(ptr) ntdll.RtlQueryDepthSList
+@ stdcall QueryDosDeviceA(str ptr long)
+@ stdcall QueryDosDeviceW(wstr ptr long)
+@ stdcall QueryFullProcessImageNameA(ptr long str ptr) ; Vista and later
+@ stdcall QueryFullProcessImageNameW(ptr long wstr ptr) ; Vista and later
+;@ stdcall QueryIdleProcessorCycleTime ; Win 7
+;@ stdcall QueryIdleProcessorCycleTimeEx ; Win 7
+@ stdcall QueryInformationJobObject(long long ptr long ptr)
+@ stdcall QueryMemoryResourceNotification(ptr ptr)
+@ stub QueryNumberOfEventLogRecords ; missing in XP SP3 and Win 7
+@ stub QueryOldestEventLogRecord ; missing in XP SP3 and Win 7
+@ stdcall QueryPerformanceCounter(ptr)
+@ stdcall QueryPerformanceFrequency(ptr)
+;@ stdcall QueryProcessAffinityUpdateMode ; Win 7
+;@ stdcall QueryProcessCycleTime ; Win 7
+;@ stdcall QueryThreadCycleTime ; Win 7
+;@ stdcall QueryThreadProfiling ; Win 7
+;@ stdcall QueryThreadpoolStackInformation ; Win 7
+;@ stdcall -arch=x86_64 QueryUmsThreadInformation
+;@ stdcall QueryUnbiasedInterruptTime ; Win 7
+@ stdcall QueryWin31IniFilesMappedToRegistry(long long long long) ; missing in Win 7
+@ stdcall QueueUserAPC(ptr long long)
+@ stdcall QueueUserWorkItem(ptr ptr long)
+@ stdcall RaiseException(long long long ptr)
+;@ stdcall RaiseFailFastException ; Win 7
+@ stub ReOpenFile ;@ stdcall ReOpenFile(ptr long long long)
+@ stdcall ReadConsoleA(long ptr long ptr ptr)
+@ stdcall ReadConsoleInputA(long ptr long ptr)
+@ stdcall ReadConsoleInputExA(long ptr long ptr long)
+@ stdcall ReadConsoleInputExW(long ptr long ptr long)
+@ stdcall ReadConsoleInputW(long ptr long ptr)
+@ stdcall ReadConsoleOutputA(long ptr long long ptr)
+@ stdcall ReadConsoleOutputAttribute(long ptr long long ptr)
+@ stdcall ReadConsoleOutputCharacterA(long ptr long long ptr)
+@ stdcall ReadConsoleOutputCharacterW(long ptr long long ptr)
+@ stdcall ReadConsoleOutputW(long ptr long long ptr)
+@ stdcall ReadConsoleW(long ptr long ptr ptr)
+@ stdcall ReadDirectoryChangesW(long ptr long long long ptr ptr ptr)
+@ stdcall ReadFile(long ptr long ptr ptr)
+@ stdcall ReadFileEx(long ptr long ptr ptr)
+@ stdcall ReadFileScatter(long ptr long ptr ptr)
+@ stdcall ReadProcessMemory(long ptr ptr long ptr)
+;@ stdcall ReadThreadProfilingData ; Win 7
+;@ stdcall RegCloseKey ; Win 7
+;@ stdcall RegCreateKeyExA ; Win 7
+;@ stdcall RegCreateKeyExW ; Win 7
+;@ stdcall RegDeleteKeyExA ; Win 7
+;@ stdcall RegDeleteKeyExW ; Win 7
+;@ stdcall RegDeleteTreeA ; Win 7
+;@ stdcall RegDeleteTreeW ; Win 7
+;@ stdcall RegDeleteValueA ; Win 7
+;@ stdcall RegDeleteValueW ; Win 7
+;@ stdcall RegDisablePredefinedCacheEx ; Win 7
+;@ stdcall RegEnumKeyExA ; Win 7
+;@ stdcall RegEnumKeyExW ; Win 7
+;@ stdcall RegEnumValueA ; Win 7
+;@ stdcall RegEnumValueW ; Win 7
+;@ stdcall RegFlushKey ; Win 7
+;@ stdcall RegGetKeySecurity ; Win 7
+;@ stdcall RegGetValueA ; Win 7
+;@ stdcall RegGetValueW ; Win 7
+;@ stdcall RegKrnGetGlobalState ; Win 7
+;@ stdcall RegKrnInitialize ; Win 7
+;@ stdcall RegLoadKeyA ; Win 7
+;@ stdcall RegLoadKeyW ; Win 7
+;@ stdcall RegLoadMUIStringA ; Win 7
+;@ stdcall RegLoadMUIStringW ; Win 7
+;@ stdcall RegNotifyChangeKeyValue ; Win 7
+;@ stdcall RegOpenCurrentUser ; Win 7
+;@ stdcall RegOpenKeyExA ; Win 7
+;@ stdcall RegOpenKeyExW ; Win 7
+;@ stdcall RegOpenUserClassesRoot ; Win 7
+;@ stdcall RegQueryInfoKeyA ; Win 7
+;@ stdcall RegQueryInfoKeyW ; Win 7
+;@ stdcall RegQueryValueExA ; Win 7
+;@ stdcall RegQueryValueExW ; Win 7
+;@ stdcall RegRestoreKeyA ; Win 7
+;@ stdcall RegRestoreKeyW ; Win 7
+;@ stdcall RegSaveKeyExA ; Win 7
+;@ stdcall RegSaveKeyExW ; Win 7
+;@ stdcall RegSetKeySecurity ; Win 7
+;@ stdcall RegSetValueExA ; Win 7
+;@ stdcall RegSetValueExW ; Win 7
+;@ stdcall RegUnLoadKeyA ; Win 7
+;@ stdcall RegUnLoadKeyW ; Win 7
+;@ stdcall RegisterApplicationRecoveryCallback ; Win 7
+@ stdcall RegisterApplicationRestart(wstr long)
+@ stdcall RegisterConsoleIME(ptr ptr)
+@ stdcall RegisterConsoleOS2(long)
+@ stdcall RegisterConsoleVDM(long long long long long long long long long long long)
+;@ stub RegisterServiceProcess ; missing in XP SP3 and Win 7
+@ stub RegisterSysMsgHandler ; missing in XP SP3 and win 7
+@ stdcall RegisterWaitForInputIdle(ptr)
+@ stdcall RegisterWaitForSingleObject(ptr long ptr ptr long long)
+@ stdcall RegisterWaitForSingleObjectEx(long ptr ptr long long)
+@ stdcall RegisterWowBaseHandlers(long)
+@ stdcall RegisterWowExec(long)
+@ stdcall ReinitializeCriticalSection(ptr)
+@ stdcall ReleaseActCtx(ptr)
+@ stdcall ReleaseMutex(long)
+;@ stdcall ReleaseMutexWhenCallbackReturns ntdll.TpCallbackReleaseMutexOnCompletion ; Win 7
+@ stdcall ReleaseSRWLockExclusive(ptr) ntdll.RtlReleaseSRWLockExclusive
+@ stdcall ReleaseSRWLockShared(ptr) ntdll.RtlReleaseSRWLockShared
+@ stdcall ReleaseSemaphore(long long ptr)
+;@ stdcall ReleaseSemaphoreWhenCallbackReturns ntdll.TpCallbackReleaseSemaphoreOnCompletion ; Win 7
+@ stdcall RemoveDirectoryA(str)
+;@ stdcall RemoveDirectoryTransactedA ; Win 7
+;@ stdcall RemoveDirectoryTransactedW ; Win 7
+@ stdcall RemoveDirectoryW(wstr)
+@ stdcall RemoveLocalAlternateComputerNameA(str long)
+@ stdcall RemoveLocalAlternateComputerNameW(wstr long)
+;@ stdcall RemoveSecureMemoryCacheCallback ; Win 7
+@ stdcall RemoveVectoredContinueHandler(ptr) ntdll.RtlRemoveVectoredContinueHandler
+@ stdcall RemoveVectoredExceptionHandler(ptr) ntdll.RtlRemoveVectoredExceptionHandler
+@ stdcall ReplaceFile(wstr wstr wstr long ptr ptr) ReplaceFileW
+@ stdcall ReplaceFileA(str str str long ptr ptr)
+@ stdcall ReplaceFileW(wstr wstr wstr long ptr ptr)
+;@ stdcall ReplacePartitionUnit ; Win 7
+@ stdcall RequestDeviceWakeup(long)
+@ stdcall RequestWakeupLatency(long)
+@ stdcall ResetEvent(long)
+@ stdcall ResetWriteWatch(ptr long)
+;@ stdcall ResolveLocaleName ; Win 7
+@ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error
+@ stdcall ResumeThread(long)
+@ cdecl -arch=x86_64 RtlAddFunctionTable(ptr long long) ntdll.RtlAddFunctionTable
+@ stdcall -register RtlCaptureContext(ptr) ntdll.RtlCaptureContext
+@ stdcall RtlCaptureStackBackTrace(long long ptr ptr) ntdll.RtlCaptureStackBackTrace
+@ stdcall -arch=x86_64 RtlCompareMemory(ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlCopyMemory(ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlDeleteFunctionTable(ptr)
+@ stdcall RtlFillMemory(ptr long long) ntdll.RtlFillMemory
+@ stdcall -arch=x86_64 RtlInstallFunctionTableCallback(double double long ptr ptr ptr)
+@ stdcall -arch=x86_64 RtlLookupFunctionEntry(ptr ptr ptr) ntdll.RtlLookupFunctionEntry
+@ stdcall RtlMoveMemory(ptr ptr long) ntdll.RtlMoveMemory
+@ stdcall -arch=x86_64 RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader
+@ stdcall -arch=x86_64 RtlRaiseException(ptr) ntdll.RtlRaiseException
+@ stdcall -arch=x86_64 RtlRestoreContext(ptr ptr) ntdll.RtlRestoreContext
+@ stdcall RtlUnwind(ptr ptr ptr long) ntdll.RtlUnwind
+@ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr) ntdll.RtlUnwindEx
+@ stdcall -arch=x86_64 RtlVirtualUnwind(ptr ptr ptr long) ntdll.RtlVirtualUnwind
+@ stdcall RtlZeroMemory(ptr long) ntdll.RtlZeroMemory
+@ stdcall ScrollConsoleScreenBufferA(long ptr ptr ptr ptr)
+@ stdcall ScrollConsoleScreenBufferW(long ptr ptr ptr ptr)
+@ stdcall SearchPathA(str str str long ptr ptr)
+@ stdcall SearchPathW(wstr wstr wstr long ptr ptr)
+@ stdcall SetCPGlobal(long) ; missing in Win 7
+@ stdcall SetCalendarInfoA(long long long str)
+@ stdcall SetCalendarInfoW(long long long wstr)
+@ stdcall SetClientTimeZoneInformation(ptr)
+@ stdcall SetComPlusPackageInstallStatus(ptr)
+@ stdcall SetCommBreak(long)
+@ stdcall SetCommConfig(long ptr long)
+@ stdcall SetCommMask(long ptr)
+@ stdcall SetCommState(long ptr)
+@ stdcall SetCommTimeouts(long ptr)
+@ stdcall SetComputerNameA(str)
+@ stdcall SetComputerNameExA(long str)
+@ stdcall SetComputerNameExW(long wstr)
+@ stdcall SetComputerNameW(wstr)
+@ stdcall SetConsoleActiveScreenBuffer(long)
+@ stdcall SetConsoleCP(long)
+@ stdcall SetConsoleCommandHistoryMode(long) ; missing in win 7
+@ stdcall SetConsoleCtrlHandler(ptr long)
+@ stdcall SetConsoleCursor(long long)
+@ stdcall SetConsoleCursorInfo(long ptr)
+@ stdcall SetConsoleCursorMode(long long long)
+@ stdcall SetConsoleCursorPosition(long long)
+@ stdcall SetConsoleDisplayMode(long long ptr)
+@ stdcall SetConsoleFont(long long)
+@ stdcall SetConsoleHardwareState(long long long)
+@ stdcall SetConsoleHistoryInfo(ptr)
+@ stdcall SetConsoleIcon(ptr)
+@ stdcall SetConsoleInputExeNameA(ptr)
+@ stdcall SetConsoleInputExeNameW(ptr)
+@ stdcall SetConsoleKeyShortcuts(long long long long)
+@ stdcall SetConsoleLocalEUDC(long long long long)
+@ stdcall SetConsoleMaximumWindowSize(long long)
+@ stdcall SetConsoleMenuClose(long)
+@ stdcall SetConsoleMode(long long)
+@ stdcall SetConsoleNlsMode(long long)
+@ stdcall SetConsoleNumberOfCommandsA(long long)
+@ stdcall SetConsoleNumberOfCommandsW(long long)
+@ stdcall SetConsoleOS2OemFormat(long)
+@ stdcall SetConsoleOutputCP(long)
+@ stdcall SetConsolePalette(long long long)
+;@ stdcall SetConsoleScreenBufferInfoEx ; Win 7
+@ stdcall SetConsoleScreenBufferSize(long long)
+@ stdcall SetConsoleTextAttribute(long long)
+@ stdcall SetConsoleTitleA(str)
+@ stdcall SetConsoleTitleW(wstr)
+@ stdcall SetConsoleWindowInfo(long long ptr)
+@ stdcall SetCriticalSectionSpinCount(ptr long) ntdll.RtlSetCriticalSectionSpinCount
+;@ stdcall SetCurrentConsoleFontEx ; Win 7
+@ stdcall SetCurrentDirectoryA(str)
+@ stdcall SetCurrentDirectoryW(wstr)
+@ stub SetDaylightFlag ; missing in XP SP3 and Win 7
+@ stdcall SetDefaultCommConfigA(str ptr long)
+@ stdcall SetDefaultCommConfigW(wstr ptr long)
+@ stdcall SetDllDirectoryA(str)
+@ stdcall SetDllDirectoryW(wstr)
+;@ stdcall SetDynamicTimeZoneInformation ; Win 7
+@ stdcall SetEndOfFile(long)
+;@ stdcall SetEnvironmentStringsA ; Win 7
+;@ stdcall SetEnvironmentStringsW ; Win 7
+@ stdcall SetEnvironmentVariableA(str str)
+@ stdcall SetEnvironmentVariableW(wstr wstr)
+@ stdcall SetErrorMode(long)
+@ stdcall SetEvent(long)
+;@ stdcall SetEventWhenCallbackReturns ntdll.TpCallbackSetEventOnCompletion ; Win 7
+;@ stdcall SetExtendedFeaturesMask api-ms-win-core-xstate-l1-1-0.RtlSetExtendedFeaturesMask ; Win 7
+@ stdcall SetFileApisToANSI()
+@ stdcall SetFileApisToOEM()
+@ stdcall SetFileAttributesA(str long)
+;@ stdcall SetFileAttributesTransactedA ; Win 7
+;@ stdcall SetFileAttributesTransactedW ; Win 7
+@ stdcall SetFileAttributesW(wstr long)
+;@ stdcall SetFileBandwidthReservation ; Win 7
+;@ stdcall SetFileCompletionNotificationModes ; Win 7
+;@ stdcall SetFileInformationByHandle ; Win 7
+;@ stdcall SetFileIoOverlappedRange ; Win 7
+@ stdcall SetFilePointer(long long ptr long)
+@ stdcall SetFilePointerEx(long double ptr long)
+@ stdcall SetFileShortNameA(long str)
+@ stdcall SetFileShortNameW(long wstr)
+@ stdcall SetFileTime(long ptr ptr ptr)
+@ stdcall SetFileValidData(long double)
+@ stdcall SetFirmwareEnvironmentVariableA(str str ptr long)
+@ stdcall SetFirmwareEnvironmentVariableW(wstr wstr ptr long)
+@ stdcall SetHandleContext(long long) ; missing in Win 7 x64
+@ stdcall SetHandleCount(long)
+@ stdcall SetHandleInformation(long long long)
+@ stdcall SetInformationJobObject(long long ptr long)
+@ stub SetLastConsoleEventActive ; missing in XP SP3
+@ stdcall SetLastError(long) ntdll.RtlSetLastWin32Error
+@ stub SetLocalPrimaryComputerNameA ; missing in XP SP3
+@ stub SetLocalPrimaryComputerNameW ; missing in XP SP3
+@ stdcall SetLocalTime(ptr)
+@ stdcall SetLocaleInfoA(long long str)
+@ stdcall SetLocaleInfoW(long long wstr)
+@ stdcall SetMailslotInfo(long long)
+@ stdcall SetMessageWaitingIndicator(long double)
+;@ stdcall SetNamedPipeAttribute ; Win 7
+@ stdcall SetNamedPipeHandleState(long ptr ptr ptr)
+@ stdcall SetPriorityClass(long long)
+@ stdcall SetProcessAffinityMask(long long)
+;@ stdcall SetProcessAffinityUpdateMode ; Win 7
+;@ stdcall SetProcessDEPPolicy ; Win 7
+;@ stdcall SetProcessPreferredUILanguages ; Win 7
+@ stdcall SetProcessPriorityBoost(long long)
+@ stdcall SetProcessShutdownParameters(long long)
+@ stdcall SetProcessWorkingSetSize(long long long)
+;@ stdcall SetProcessWorkingSetSizeEx ; Win 7
+;@ stdcall SetSearchPathMode ; Win 7
+@ stdcall SetStdHandle(long long)
+;@ stdcall SetStdHandleEx ; Win 7
+;@ stdcall SetSystemFileCacheSize ; Win 7
+@ stdcall SetSystemPowerState(long long)
+@ stdcall SetSystemTime(ptr)
+@ stdcall SetSystemTimeAdjustment(long long)
+@ stdcall SetTapeParameters(ptr long ptr)
+@ stdcall SetTapePosition(ptr long long long long long)
+@ stdcall SetTermsrvAppInstallMode(long)
+@ stdcall SetThreadAffinityMask(long long)
+@ stdcall SetThreadContext(long ptr)
+@ stdcall SetThreadErrorMode(long ptr)
+@ stdcall SetThreadExecutionState(long)
+;@ stdcall SetThreadGroupAffinity ; Win 7
+@ stdcall SetThreadIdealProcessor(long long)
+;@ stdcall SetThreadIdealProcessorEx ; Win 7
+@ stdcall SetThreadLocale(long)
+;@ stdcall SetThreadPreferredUILanguages ; Win 7
+@ stdcall SetThreadPriority(long long)
+@ stdcall SetThreadPriorityBoost(long long)
+;@ stdcall SetThreadStackGuarantee ; Win 7
+;@ stdcall SetThreadToken api-ms-win-core-processthreads-l1-1-0.SetThreadToken ; Win 7
+@ stdcall SetThreadUILanguage(long)
+;@ stdcall SetThreadpoolStackInformation ; Win 7
+;@ stdcall SetThreadpoolThreadMaximum ntdll.TpSetPoolMaxThreads ; Win 7
+;@ stdcall SetThreadpoolThreadMinimum ; Win 7
+;@ stdcall SetThreadpoolTimer ntdll.TpSetTimer ; Win 7
+;@ stdcall SetThreadpoolWait ntdll.TpSetWait ; Win 7
+@ stdcall SetTimeZoneInformation(ptr)
+@ stdcall SetTimerQueueTimer(long ptr ptr long long long)
+;@ stdcall -arch?x86_64 SetUmsThreadInformation
+@ stdcall SetUnhandledExceptionFilter(ptr)
+@ stdcall SetUserGeoID(long)
+@ stdcall SetVDMCurrentDirectories(long long)
+@ stdcall SetVolumeLabelA(str str)
+@ stdcall SetVolumeLabelW(wstr wstr)
+@ stdcall SetVolumeMountPointA(str str)
+@ stdcall SetVolumeMountPointW(wstr wstr)
+@ stdcall SetWaitableTimer(long ptr long ptr ptr long)
+;@ stdcall SetWaitableTimerEx api-ms-win-core-threadpool-l1-1-0.SetWaitableTimerEx ; Win 7
+@ stdcall SetupComm(long long long)
+@ stdcall ShowConsoleCursor(long long)
+@ stdcall SignalObjectAndWait(long long long long)
+@ stdcall SizeofResource(long long)
+@ stdcall Sleep(long)
+;@ stdcall SleepConditionVariableCS ; Win 7
+;@ stdcall SleepConditionVariableSRW ; Win 7
+@ stdcall SleepEx(long long)
+;@ stdcall SortCloseHandle ; Win 7
+;@ stdcall SortGetHandle ; Win 7
+;@ stdcall StartThreadpoolIo ntdll.TpStartAsyncIoOperation ; Win 7
+;@ stdcall SubmitThreadpoolWork ntdll.TpPostWork ; Win 7
+@ stdcall SuspendThread(long)
+@ stdcall SwitchToFiber(ptr)
+@ stdcall SwitchToThread()
+@ stdcall SystemTimeToFileTime(ptr ptr)
+@ stdcall SystemTimeToTzSpecificLocalTime (ptr ptr ptr)
+@ stdcall TerminateJobObject(long long)
+@ stdcall TerminateProcess(long long)
+@ stdcall TerminateThread(long long)
+@ stdcall TermsrvAppInstallMode()
+@ stdcall Thread32First(long ptr)
+@ stdcall Thread32Next(long ptr)
+@ stdcall TlsAlloc()
+@ stub TlsAllocInternal ; missing in XP SP3 and Win 7
+@ stdcall TlsFree(long)
+@ stub TlsFreeInternal ; missing in XP SP3 and Win 7
+@ stdcall TlsGetValue(long)
+@ stdcall TlsSetValue(long ptr)
+@ stdcall Toolhelp32ReadProcessMemory(long ptr ptr long ptr)
+@ stdcall TransactNamedPipe(long ptr long ptr long ptr ptr)
+@ stdcall TransmitCommChar(long long)
+@ stdcall TrimVirtualBuffer(ptr) ; missing in Win 7
+;@ stdcall TryAcquireSRWLockExclusive ntdll.RtlTryAcquireSRWLockExclusive ; Win 7
+;@ stdcall TryAcquireSRWLockShared ntdll.RtlTryAcquireSRWLockShared ; Win 7
+@ stdcall TryEnterCriticalSection(ptr) ntdll.RtlTryEnterCriticalSection
+;@ stdcall TrySubmitThreadpoolCallback ; Win 7
+@ stdcall TzSpecificLocalTimeToSystemTime(ptr ptr ptr)
+@ stdcall UTRegister(long str str str ptr ptr ptr)
+@ stdcall UTUnRegister(long)
+;@ stdcall -arch=x86_64 UmsThreadYield
+@ stdcall UnhandledExceptionFilter(ptr)
+@ stdcall UninitializeCriticalSection(ptr)
+@ stdcall UnlockFile(long long long long long)
+@ stdcall UnlockFileEx(long long long long ptr)
+@ stdcall UnmapViewOfFile(ptr)
+;@ stdcall UnregisterApplicationRecoveryCallback ; Win 7
+;@ stdcall UnregisterApplicationRestart ; Win 7
+@ stdcall UnregisterConsoleIME()
+@ stdcall UnregisterWait(long)
+@ stdcall UnregisterWaitEx(long long)
+;@ stdcall UpdateCalendarDayOfWeek ; Win 7
+;@ stdcall UpdateProcThreadAttribute api-ms-win-core-processthreads-l1-1-0.UpdateProcThreadAttribute ; Win 7
+@ stdcall UpdateResourceA(long str str long ptr long)
+@ stdcall UpdateResourceW(long wstr wstr long ptr long)
+@ stdcall VDMConsoleOperation(long long)
+@ stdcall VDMOperationStarted(long)
+@ stub ValidateCType ; missing in XP SP3 and Win 7
+@ stub ValidateLocale ; missing in XP SP3 and Win 7
+@ stdcall VerLanguageNameA(long str long)
+@ stdcall VerLanguageNameW(long wstr long)
+@ stdcall -ret64 VerSetConditionMask(long long long long) ntdll.VerSetConditionMask
+@ stdcall VerifyConsoleIoHandle(long)
+;@ stdcall VerifyScripts ; Win 7
+@ stdcall VerifyVersionInfoA(long long double)
+@ stdcall VerifyVersionInfoW(long long double)
+@ stdcall VirtualAlloc(ptr long long long)
+@ stdcall VirtualAllocEx(long ptr long long long)
+;@ stdcall VirtualAllocExNuma ; Win 7
+@ stdcall VirtualBufferExceptionHandler(long long long) ; missing in Win 7
+@ stdcall VirtualFree(ptr long long)
+@ stdcall VirtualFreeEx(long ptr long long)
+@ stdcall VirtualLock(ptr long)
+@ stdcall VirtualProtect(ptr long long ptr)
+@ stdcall VirtualProtectEx(long ptr long long ptr)
+@ stdcall VirtualQuery(ptr ptr long)
+@ stdcall VirtualQueryEx(long ptr ptr long)
+@ stdcall VirtualUnlock(ptr long)
+;@ stdcall WTSGetActiveConsoleSessionId ; Win 7
+@ stdcall WaitCommEvent(long ptr ptr)
+@ stdcall WaitForDebugEvent(ptr long)
+@ stdcall WaitForMultipleObjects(long ptr long long)
+@ stdcall WaitForMultipleObjectsEx(long ptr long long long)
+@ stdcall WaitForSingleObject(long long)
+@ stdcall WaitForSingleObjectEx(long long long)
+;@ stdcall WaitForThreadpoolIoCallbacks ntdll.TpWaitForIoCompletion ; Win 7
+;@ stdcall WaitForThreadpoolTimerCallbacks ntdll.TpWaitForTimer ; Win 7
+;@ stdcall WaitForThreadpoolWaitCallbacks ntdll.TpWaitForWait ; Win 7
+;@ stdcall WaitForThreadpoolWorkCallbacks ntdll.TpWaitForWork ; Win 7
+@ stdcall WaitNamedPipeA (str long)
+@ stdcall WaitNamedPipeW (wstr long)
+@ stdcall WakeAllConditionVariable(ptr) ntdll.RtlWakeAllConditionVariable
+@ stdcall WakeConditionVariable(ptr) ntdll.RtlWakeConditionVariable
+;@ stdcall WerGetFlags ; Win 7
+;@ stdcall WerRegisterFile ; Win 7
+;@ stdcall WerRegisterMemoryBlock ; Win 7
+;@ stdcall WerRegisterRuntimeExceptionModule ; Win 7
+;@ stdcall WerSetFlags ; Win 7
+;@ stdcall WerUnregisterFile ; Win 7
+;@ stdcall WerUnregisterMemoryBlock ; Win 7
+;@ stdcall WerUnregisterRuntimeExceptionModule ; Win 7
+;@ stdcall WerpCleanupMessageMapping ; Win 7
+;@ stdcall WerpInitiateRemoteRecovery ; Win 7
+;@ stdcall WerpNotifyLoadStringResource ; Win 7
+;@ stdcall WerpNotifyLoadStringResourceEx ; Win 7
+;@ stdcall WerpNotifyUseStringResource ; Win 7
+;@ stdcall WerpStringLookup ; Win 7
+@ stdcall WideCharToMultiByte(long long wstr long ptr long ptr ptr)
+@ stdcall WinExec(str long)
+@ stdcall Wow64DisableWow64FsRedirection(ptr)
+@ stdcall Wow64EnableWow64FsRedirection(long)
+;@ stdcall Wow64GetThreadContext ; Win 7
+;@ stdcall Wow64GetThreadSelectorEntry ; Win 7
+@ stdcall Wow64RevertWow64FsRedirection(ptr)
+;@ stdcall Wow64SetThreadContext ; Win 7
+;@ stdcall Wow64SuspendThread ; Win 7
+@ stdcall WriteConsoleA(long ptr long ptr ptr)
+@ stdcall WriteConsoleInputA(long ptr long ptr)
+@ stdcall WriteConsoleInputVDMA(long long long long)
+@ stdcall WriteConsoleInputVDMW(long long long long)
+@ stdcall WriteConsoleInputW(long ptr long ptr)
+@ stdcall WriteConsoleOutputA(long ptr long long ptr)
+@ stdcall WriteConsoleOutputAttribute(long ptr long long ptr)
+@ stdcall WriteConsoleOutputCharacterA(long ptr long long ptr)
+@ stdcall WriteConsoleOutputCharacterW(long ptr long long ptr)
+@ stdcall WriteConsoleOutputW(long ptr long long ptr)
+@ stdcall WriteConsoleW(long ptr long ptr ptr)
+@ stdcall WriteFile(long ptr long ptr ptr)
+@ stdcall WriteFileEx(long ptr long ptr ptr)
+@ stdcall WriteFileGather(long ptr long ptr ptr)
+@ stdcall WritePrivateProfileSectionA(str str str)
+@ stdcall WritePrivateProfileSectionW(wstr wstr wstr)
+@ stdcall WritePrivateProfileStringA(str str str str)
+@ stdcall WritePrivateProfileStringW(wstr wstr wstr wstr)
+@ stdcall WritePrivateProfileStructA (str str ptr long str)
+@ stdcall WritePrivateProfileStructW(wstr wstr ptr long wstr)
+@ stdcall WriteProcessMemory(long ptr ptr long ptr)
+@ stdcall WriteProfileSectionA(str str)
+@ stdcall WriteProfileSectionW(str str)
+@ stdcall WriteProfileStringA(str str str)
+@ stdcall WriteProfileStringW(wstr wstr wstr)
+@ stdcall WriteTapemark(ptr long long long)
+@ stdcall WTSGetActiveConsoleSessionId() ; missing in win 7
+@ stdcall ZombifyActCtx(ptr)
+;@ stdcall -arch=x86_64 __C_specific_handler ntdll.__C_specific_handler
+;@ stdcall -arch=x86_64 __chkstk ntdll.__chkstk
+;@ stdcall -arch=x86_64 __misaligned_access ntdll.__misaligned_access
+@ stub _DebugOut ; missing in XP SP3 and Win 7
+@ stub _DebugPrintf ; missing in XP SP3 and Win 7
+@ stdcall _hread(long ptr long)
+@ stdcall _hwrite(long ptr long)
+@ stdcall _lclose(long)
+@ stdcall _lcreat(str long)
+@ stdcall _llseek(long long long)
+;@ stdcall -arch=x86_64 _local_unwind ntdll._local_unwind; Win 7
+@ stdcall _lopen(str long)
+@ stdcall _lread(long ptr long) _hread
+@ stdcall _lwrite(long ptr long) _hwrite
+@ stub dprintf ; missing in XP SP3 and Win 7
+@ stdcall lstrcat(str str) lstrcatA
+@ stdcall lstrcatA(str str)
+@ stdcall lstrcatW(wstr wstr)
+@ stdcall lstrcmp(str str) lstrcmpA
+@ stdcall lstrcmpA(str str)
+@ stdcall lstrcmpW(wstr wstr)
+@ stdcall lstrcmpi(str str) lstrcmpiA
+@ stdcall lstrcmpiA(str str)
+@ stdcall lstrcmpiW(wstr wstr)
+@ stdcall lstrcpy(ptr str) lstrcpyA
+@ stdcall lstrcpyA(ptr str)
+@ stdcall lstrcpyW(ptr wstr)
+@ stdcall lstrcpyn(ptr str long) lstrcpynA
+@ stdcall lstrcpynA(ptr str long)
+@ stdcall lstrcpynW(ptr wstr long)
+@ stdcall lstrlen(str) lstrlenA
+@ stdcall lstrlenA(str)
+@ stdcall lstrlenW(wstr)
+;@ stdcall -arch=x86_64 uaw_lstrcmpW ; Win 7
+;@ stdcall -arch=x86_64 uaw_lstrcmpiW ; Win 7
+;@ stdcall -arch=x86_64 uaw_lstrlenW ; Win 7
+;@ stdcall -arch=x86_64 uaw_wcschr ; Win 7
+;@ stdcall -arch=x86_64 uaw_wcscpy ; Win 7
+;@ stdcall -arch=x86_64 uaw_wcsicmp ; Win 7
+;@ stdcall -arch=x86_64 uaw_wcslen ; Win 7
+;@ stdcall -arch=x86_64 uaw_wcsrchr ; Win 7
+
index f0130a9..dad314b 100644 (file)
 @ stdcall GetNativeSystemInfo(ptr)
 ;@ stdcall -arch=x86_64 GetNextUmsListItem
 @ stdcall GetNextVDMCommand(long)
-@ stdcall GetNlsSectionName(long long double str str double) ; missing in Win 7
-@ stdcall GetNumaAvailableMemory(ptr double ptr) ; missing in Win 7
-@ stdcall GetNumaAvailableMemoryNode(double ptr)
+@ stdcall GetNlsSectionName(long long long str str long) ; missing in Win 7
+@ stdcall GetNumaAvailableMemory(ptr long ptr) ; missing in Win 7
+@ stdcall GetNumaAvailableMemoryNode(long ptr)
 ;@ stdcall GetNumaAvailableMemoryNodeEx ; Win 7
 @ stdcall GetNumaHighestNodeNumber(ptr)
 ;@ stdcall GetNumaNodeNumberFromHandle ; Win 7
-@ stdcall GetNumaNodeProcessorMask(double ptr)
+@ stdcall GetNumaNodeProcessorMask(long ptr)
 ;@ stdcall GetNumaNodeProcessorMaskEx ; Win 7
-@ stdcall GetNumaProcessorMap(ptr double ptr) ; missing in Win 7
-@ stdcall GetNumaProcessorNode(double ptr)
+@ stdcall GetNumaProcessorMap(ptr long ptr) ; missing in Win 7
+@ stdcall GetNumaProcessorNode(long ptr)
 ;@ stdcall GetNumaProcessorNodeEx ; Win 7
 ;@ stdcall GetNumaProximityNode ; Win 7
 ;@ stdcall GetNumaProximityNodeEx ; Win 7
 @ stdcall GetPrivateProfileStructW(wstr wstr ptr long wstr)
 @ stdcall GetProcAddress(long str)
 @ stdcall GetProcessAffinityMask(long ptr ptr)
-@ stdcall GetProcessFlags(long)
+//@ stdcall GetProcessFlags(long)
 ;@ stdcall GetProcessDEPPolicy ; Win 7
 ;@ stdcall GetProcessGroupAffinity ; Win 7
 @ stdcall GetProcessHandleCount(long ptr)
 @ stdcall GetProcessWorkingSetSize(long ptr ptr)
 ;@ stdcall GetProcessWorkingSetSizeEx ; Win 7
 ;@ stdcall GetProcessorSystemCycleTime ; Win 7
-@ stdcall GetProductInfo(long long long long ptr)
+;@ stdcall GetProductInfo(long long long long ptr) ; Win 7
 @ stub GetProductName
 @ stdcall GetProfileIntA(str str long)
 @ stdcall GetProfileIntW(wstr wstr long)
 @ stdcall GetTempPathA(long ptr)
 @ stdcall GetTempPathW(long ptr)
 @ stdcall GetThreadContext(long ptr)
-@ stdcall GetThreadErrorMode()
+;@ stdcall GetThreadErrorMode() ; Win 7
 ;@ stdcall GetThreadGroupAffinity ; Win 7
 @ stdcall GetThreadIOPendingFlag(long ptr)
 @ stdcall GetThreadId(ptr)
 @ stdcall LockFile(long long long long long)
 @ stdcall LockFileEx(long long long long long ptr)
 @ stdcall LockResource(long)
-@ stdcall MakeCriticalSectionGlobal(ptr)
-
+;@ stdcall MakeCriticalSectionGlobal(ptr) // ???
 @ stdcall MapUserPhysicalPages(ptr long ptr)
 @ stdcall MapUserPhysicalPagesScatter(ptr long ptr)
 @ stdcall MapViewOfFile(long long long long long)
 @ stdcall NeedCurrentDirectoryForExePathA(str)
 @ stdcall NeedCurrentDirectoryForExePathW(wstr)
 ;@ stdcall NlsCheckPolicy ; Win 7
-@ stdcall NlsConvertIntegerToString(double double double wstr double) ; missing in Win 7
+@ stdcall NlsConvertIntegerToString(long long long wstr long) ; missing in Win 7
 ;@ stdcall NlsEventDataDescCreate ; Win 7
 @ stdcall NlsGetCacheUpdateCount()
 @ stub NlsResetProcessLocale ; missing in XP SP3 and Win 7
 @ stdcall RegisterWaitForSingleObjectEx(long ptr ptr long long)
 @ stdcall RegisterWowBaseHandlers(long)
 @ stdcall RegisterWowExec(long)
-@ stdcall ReinitializeCriticalSection(ptr)
+;@ stdcall ReinitializeCriticalSection(ptr) ; ???
 @ stdcall ReleaseActCtx(ptr)
 @ stdcall ReleaseMutex(long)
 ;@ stdcall ReleaseMutexWhenCallbackReturns ntdll.TpCallbackReleaseMutexOnCompletion ; Win 7
 @ stdcall SetLocaleInfoA(long long str)
 @ stdcall SetLocaleInfoW(long long wstr)
 @ stdcall SetMailslotInfo(long long)
-@ stdcall SetMessageWaitingIndicator(long double)
+@ stdcall SetMessageWaitingIndicator(ptr long)
 ;@ stdcall SetNamedPipeAttribute ; Win 7
 @ stdcall SetNamedPipeHandleState(long ptr ptr ptr)
 @ stdcall SetPriorityClass(long long)
 @ stdcall SetTermsrvAppInstallMode(long)
 @ stdcall SetThreadAffinityMask(long long)
 @ stdcall SetThreadContext(long ptr)
-@ stdcall SetThreadErrorMode(long ptr)
+;@ stdcall SetThreadErrorMode(long ptr) ; Win 7
 @ stdcall SetThreadExecutionState(long)
 ;@ stdcall SetThreadGroupAffinity ; Win 7
 @ stdcall SetThreadIdealProcessor(long long)
 @ stdcall UTUnRegister(long)
 ;@ stdcall -arch=x86_64 UmsThreadYield
 @ stdcall UnhandledExceptionFilter(ptr)
-@ stdcall UninitializeCriticalSection(ptr)
+;@ stdcall UninitializeCriticalSection(ptr) ; ???
 @ stdcall UnlockFile(long long long long long)
 @ stdcall UnlockFileEx(long long long long ptr)
 @ stdcall UnmapViewOfFile(ptr)
index d72472e..47a79fc 100644 (file)
@@ -6,7 +6,6 @@
        <include base="kernel32" root="intermediate">.</include>
        <include base="kernel32">include</include>
        <include base="ReactOS">include/reactos/subsys</include>
-       <library>wine</library>
        <library>pseh</library>
        <library>normalize</library>
        <library>ntdll</library>
index 5710a8f..2cf99fe 100644 (file)
 /* synched with wine 1.1.26 */
 
 #include <k32.h>
-
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(actctx);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = actctx;
 
 #define ACTCTX_FAKE_HANDLE ((HANDLE) 0xf00baa)
 
index d1e8a97..b608367 100644 (file)
@@ -1371,20 +1371,6 @@ SetConsolePalette(DWORD Unknown0,
     return FALSE;
 }
 
-
-/*
- * @unimplemented (Undocumented)
- */
-BOOL
-WINAPI
-SetLastConsoleEventActive(VOID)
-{
-    DPRINT1("SetLastConsoleEventActive() UNIMPLEMENTED!\n");
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
-}
-
-
 /*
  * @unimplemented (Undocumented)
  */
index 228ba4d..122cac5 100644 (file)
  */
 
 #include <k32.h>
-
-
-#include "wine/unicode.h"
-#include "wine/debug.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(resource);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = resource;
 
 struct format_args
 {
index 1813a5c..132452b 100644 (file)
  */
 
 #include <k32.h>
-
-#include "wine/config.h"
-#include "wine/unicode.h"
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(nls);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = resource;
 
 #define DATE_DATEVARSONLY 0x0100  /* only date stuff: yMdg */
 #define TIME_TIMEVARSONLY 0x0200  /* only time stuff: hHmst */
@@ -1047,8 +1044,10 @@ INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags,
   TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
         lpFormat, lpNumberStr, cchOut);
 
+  lcid = ConvertDefaultLocale(lcid);
+
   if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
-      !IsValidLocale(lcid, 0) ||
+      !IsValidLocale(lcid, LCID_INSTALLED) ||
       (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
   {
     goto error;
@@ -1418,8 +1417,10 @@ INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags,
   TRACE("(0x%04x,0x%08x,%s,%p,%p,%d)\n", lcid, dwFlags, debugstr_w(lpszValue),
         lpFormat, lpCurrencyStr, cchOut);
 
+  lcid = ConvertDefaultLocale(lcid);
+
   if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
-      !IsValidLocale(lcid, 0) ||
+      !IsValidLocale(lcid, LCID_INSTALLED) ||
       (lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
       !lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
       lpFormat->PositiveOrder > 3)))
index e327029..57805aa 100644 (file)
@@ -84,25 +84,6 @@ static RTL_CRITICAL_SECTION PROFILE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0
 static const char hex[16] = "0123456789ABCDEF";
 
 
-static __inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
-{
-    const WCHAR *end;
-    for (end = ptr + n; ptr < end; ptr++)
-        if (*ptr == ch)
-            return (WCHAR *)(ULONG_PTR)ptr;
-    return NULL;
-}
-
-static __inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
-{
-    const WCHAR *end;
-    WCHAR *ret = NULL;
-    for (end = ptr + n; ptr < end; ptr++)
-        if (*ptr == ch)
-            ret = (WCHAR *)(ULONG_PTR)ptr;
-    return ret;
-}
-
 /***********************************************************************
  *           PROFILE_CopyEntry
  *
index c852f34..030f07c 100644 (file)
@@ -958,17 +958,6 @@ SetThreadStackGuarantee(IN OUT PULONG StackSizeInBytes)
     return FALSE;
 }
 
-HANDLE
-WINAPI
-ReOpenFile(IN HANDLE hOriginalFile,
-           IN DWORD dwDesiredAccess,
-           IN DWORD dwShareMode,
-           IN DWORD dwFlags)
-{
-    STUB;
-    return INVALID_HANDLE_VALUE;
-}
-
 BOOL
 WINAPI
 SetProcessWorkingSetSizeEx(IN HANDLE hProcess,
@@ -1259,3 +1248,134 @@ UnregisterConsoleIME(VOID)
     STUB;
     return FALSE;
 }
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+BaseCheckRunApp(IN DWORD Unknown1,
+                IN DWORD Unknown2,
+                IN DWORD Unknown3,
+                IN DWORD Unknown4,
+                IN DWORD Unknown5,
+                IN DWORD Unknown6,
+                IN DWORD Unknown7,
+                IN DWORD Unknown8,
+                IN DWORD Unknown9,
+                IN DWORD Unknown10)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+BasepCheckWinSaferRestrictions(IN DWORD Unknown1,
+                               IN DWORD Unknown2,
+                               IN DWORD Unknown3,
+                               IN DWORD Unknown4,
+                               IN DWORD Unknown5,
+                               IN DWORD Unknown6)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+NumaVirtualQueryNode(IN DWORD Unknown1,
+                     IN DWORD Unknown2,
+                     IN DWORD Unknown3,
+                     IN DWORD Unknown4)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+HANDLE
+WINAPI
+ReOpenFile(IN HANDLE hOriginalFile,
+           IN DWORD dwDesiredAccess,
+           IN DWORD dwShareMode,
+           IN DWORD dwFlags)
+{
+   STUB;
+   return INVALID_HANDLE_VALUE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+SetLastConsoleEventActive(VOID)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+SetConsoleCommandHistoryMode(IN DWORD dwMode)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+SetLocalPrimaryComputerNameA(IN DWORD Unknown1,
+                             IN DWORD Unknown2)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+SetLocalPrimaryComputerNameW(IN DWORD Unknown1,
+                             IN DWORD Unknown2)
+{
+    STUB;
+    return FALSE;
+}
+
+/*
+ * @unimplemented
+ */
+VOID
+WINAPI
+SetTermsrvAppInstallMode(IN BOOL bInstallMode)
+{
+    STUB;
+}
+
+/*
+ * @unimplemented
+ */
+BOOL
+WINAPI
+TermsrvAppInstallMode(VOID)
+{
+    STUB;
+    return FALSE;
+}
index cba61e3..bb9288e 100644 (file)
@@ -9,10 +9,9 @@
 
 #include <k32.h>
 #include <reactos/buildno.h>
-
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32Ver);
+#define NDEBUG
+#include <debug.h>
+static ULONG gDebugChannel = kernel32ver;
 
 #define UNICODIZE1(x) L##x
 #define UNICODIZE(x) UNICODIZE1(x)
index 5df4c98..3c61ebe 100644 (file)
@@ -9,9 +9,9 @@
  *     2001-12-07 created
  */
 #include <k32.h>
-#include <wine/debug.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(kernel32session);
+#define NDEBUG
+#include <debug.h>
+//static ULONG gDebugChannel = kernel32session; not actually used
 
 DWORD ActiveConsoleSessionId = 0;
 
index a5e33ae..5714213 100644 (file)
@@ -1910,6 +1910,7 @@ WSPIoctl(IN  SOCKET Handle,
          OUT LPINT lpErrno)
 {
     PSOCKET_INFORMATION Socket = NULL;
+       BOOLEAN NeedsCompletion;
 
     /* Get the Socket Structure associate to this Socket*/
     Socket = GetSocketStructure(Handle);
@@ -1918,6 +1919,8 @@ WSPIoctl(IN  SOCKET Handle,
        *lpErrno = WSAENOTSOCK;
        return SOCKET_ERROR;
     }
+       
+       *lpcbBytesReturned = 0;
 
     switch( dwIoControlCode )
     {
@@ -1928,17 +1931,44 @@ WSPIoctl(IN  SOCKET Handle,
                 return SOCKET_ERROR;
             }
             Socket->SharedData.NonBlocking = *((PULONG)lpvInBuffer) ? 1 : 0;
-            return SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, (PULONG)lpvInBuffer, NULL);
+            *lpErrno = SetSocketInformation(Socket, AFD_INFO_BLOCKING_MODE, (PULONG)lpvInBuffer, NULL);
+                       if (*lpErrno != NO_ERROR)
+                               return SOCKET_ERROR;
+                       else
+                               return NO_ERROR;
         case FIONREAD:
             if( cbOutBuffer < sizeof(INT) || IS_INTRESOURCE(lpvOutBuffer) )
             {
                 *lpErrno = WSAEFAULT;
                 return SOCKET_ERROR;
             }
-            return GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, (PULONG)lpvOutBuffer, NULL);
+            *lpErrno = GetSocketInformation(Socket, AFD_INFO_RECEIVE_CONTENT_SIZE, (PULONG)lpvOutBuffer, NULL);
+                       if (*lpErrno != NO_ERROR)
+                               return SOCKET_ERROR;
+                       else
+                       {
+                               *lpcbBytesReturned = sizeof(ULONG);
+                               return NO_ERROR;
+                       }
         default:
-            *lpErrno = WSAEINVAL;
-            return SOCKET_ERROR;
+                       *lpErrno = Socket->HelperData->WSHIoctl(Socket->HelperContext,
+                                                                                                       Handle,
+                                                                                                       Socket->TdiAddressHandle,
+                                                                                                       Socket->TdiConnectionHandle,
+                                                                                                       dwIoControlCode,
+                                                                                                       lpvInBuffer,
+                                                                                                       cbInBuffer,
+                                                                                                       lpvOutBuffer,
+                                                                                                       cbOutBuffer,
+                                                                                                       lpcbBytesReturned,
+                                                                                                       lpOverlapped,
+                                                                                                       lpCompletionRoutine,
+                                                                                                       (LPBOOL)&NeedsCompletion);
+                       
+                       if (*lpErrno != NO_ERROR)
+                               return SOCKET_ERROR;
+                       else
+                               return NO_ERROR;
     }
 }
 
index 2c7ed3f..14f7169 100644 (file)
 @ cdecl __RTDynamicCast(ptr long ptr ptr long) MSVCRT___RTDynamicCast
 @ cdecl __RTtypeid(ptr) MSVCRT___RTtypeid
 @ cdecl __STRINGTOLD(ptr ptr str long)
-@ cdecl ___lc_codepage_func()
+@ cdecl ___lc_codepage_func()
 # @ cdecl ___lc_collate_cp_func()
-@ cdecl ___lc_handle_func()
+@ cdecl ___lc_handle_func()
 # @ cdecl ___mb_cur_max_func() MSVCRT___mb_cur_max_func
 @ cdecl ___setlc_active_func() 
 @ cdecl ___unguarded_readlc_active_add_func()
 @ cdecl __isascii(long) __isascii
 @ cdecl __iscsym(long) __iscsym
 @ cdecl __iscsymf(long) __iscsymf
-@ extern __lc_codepage __lc_codepage
+@ extern __lc_codepage MSVCRT___lc_codepage
 @ stub __lc_collate
-@ extern __lc_collate_cp __lc_collate_cp
-@ extern __lc_handle __lc_handle
+@ extern __lc_collate_cp MSVCRT___lc_collate_cp
+@ extern __lc_handle MSVCRT___lc_handle
 @ cdecl __lconv_init()
 # stub __libm_sse2_acos
 # stub __libm_sse2_acosf
index 41883ac..a57c33e 100644 (file)
@@ -175,37 +175,16 @@ static HICON SIC_OverlayShortcutImage(HICON SourceIcon, BOOL large)
        if (! BitBlt(TargetDC, 0, 0, SourceBitmapInfo.bmWidth, SourceBitmapInfo.bmHeight,
                     SourceDC, 0, 0, SRCCOPY)) goto fail;
 
-       /* Check if we can use alpha blending */
-       if (ShortcutBitmapInfo.bmBitsPixel == 32)
-       {
-               /* Use alpha blending to make sure the target alpha channel stays valid */
-               if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
-               if (!GdiAlphaBlend(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
-                               ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                               ShortcutDC, 0, 0, ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                               (BLENDFUNCTION){AC_SRC_OVER, 0, 255, AC_SRC_ALPHA})) goto fail;
-       }
-       else
-       {
-               /* Copy the source xor bitmap to the target and clear out part of it by using
-                  the shortcut mask */
-               if (! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
-                            ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                        ShortcutDC, 0, 0, SRCAND))
-               {
-                       goto fail;
-               }
-
-               if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
-
-               /* Now put in the shortcut xor mask */
-               if (! BitBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
-                            ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
-                        ShortcutDC, 0, 0, SRCINVERT))
-               {
-                       goto fail;
-               }
-       }
+    /* Copy the source xor bitmap to the target and clear out part of it by using
+       the shortcut mask */
+    if (NULL == SelectObject(ShortcutDC, ShortcutIconInfo.hbmColor)) goto fail;
+    if (!MaskBlt(TargetDC, 0, SourceBitmapInfo.bmHeight - ShortcutBitmapInfo.bmHeight,
+                 ShortcutBitmapInfo.bmWidth, ShortcutBitmapInfo.bmHeight,
+                 ShortcutDC, 0, 0, ShortcutIconInfo.hbmMask, 0, 0, 
+                 MAKEROP4(SRCCOPY, 0xAA0000)))
+    {
+        goto fail;
+    }
 
        /* Clean up, we're not goto'ing to 'fail' after this so we can be lazy and not set
           handles to NULL */
index 6102f3c..1609c38 100644 (file)
@@ -91,7 +91,7 @@ static void FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decimal_bu
  * Format an integer according to the current locale
  *
  * RETURNS
- *  The number of bytes written on success or 0 on failure
+ *  The number of characters written on success or 0 on failure
  */
 static int FormatInt(LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
 {
@@ -124,7 +124,7 @@ static int FormatInt(LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
  * after the decimal point
  *
  * RETURNS
- *  The number of bytes written on success or 0 on failure
+ *  The number of characters written on success or 0 on failure
  */
 static int FormatDouble(double value, int decimals, LPWSTR pszBuf, int cchBuf)
 {
index b71f80e..6eeb37e 100644 (file)
@@ -459,7 +459,7 @@ select(IN      INT nfds,
 
         DereferenceProviderByPointer(Provider);
 
-        if (Errno != NO_ERROR)
+        if (Count == SOCKET_ERROR)
         {
             WSASetLastError(Errno);
             return SOCKET_ERROR;
@@ -586,13 +586,15 @@ ioctlsocket(IN     SOCKET s,
             IN     LONG cmd,
             IN OUT ULONG FAR* argp)
 {
+       ULONG tmp;
+       
     return WSAIoctl(s,
                     cmd,
                     argp,
                     sizeof(ULONG),
                     argp,
                     sizeof(ULONG),
-                    argp,
+                    &tmp,
                     0,
                     0);
 }
@@ -642,7 +644,7 @@ WSAAccept(IN     SOCKET s,
     if (Socket == INVALID_SOCKET)
         WSASetLastError(Errno);
 
-    if ( addr )
+    if ( addr && addrlen )
     {
 #if DBG
         LPSOCKADDR_IN sa = (LPSOCKADDR_IN)addr;
index 05d307d..4dbd16b 100644 (file)
@@ -20,32 +20,238 @@ VOID
 NTAPI
 Device_SaveCurrentSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
-    UNIMPLEMENTED;
-    while (TRUE);
+    PPCI_COMMON_HEADER PciData;
+    PIO_RESOURCE_DESCRIPTOR IoDescriptor;
+    PCM_PARTIAL_RESOURCE_DESCRIPTOR CmDescriptor;
+    PPCI_FUNCTION_RESOURCES Resources;
+    PULONG BarArray;
+    ULONG Bar, BarMask, i;
+
+    /* Get variables from context */
+    PciData = Context->Current;
+    Resources = Context->PdoExtension->Resources;
+
+    /* Loop all the PCI BARs */
+    BarArray = PciData->u.type0.BaseAddresses;
+    for (i = 0; i <= PCI_TYPE0_ADDRESSES; i++)
+    {
+        /* Get the resource descriptor and limit descriptor for this BAR */
+        CmDescriptor = &Resources->Current[i];
+        IoDescriptor = &Resources->Limit[i];
+
+        /* Build the resource descriptor based on the limit descriptor */
+        CmDescriptor->Type = IoDescriptor->Type;
+        if (CmDescriptor->Type == CmResourceTypeNull) continue;
+        CmDescriptor->Flags = IoDescriptor->Flags;
+        CmDescriptor->ShareDisposition = IoDescriptor->ShareDisposition;
+        CmDescriptor->u.Generic.Start.HighPart = 0;
+        CmDescriptor->u.Generic.Length = IoDescriptor->u.Generic.Length;
+
+        /* Read the actual BAR value */
+        Bar = BarArray[i];
+
+        /* Check which BAR is being processed now */
+        if (i != PCI_TYPE0_ADDRESSES)
+        {
+            /* Check if this is an I/O BAR */
+            if (Bar & PCI_ADDRESS_IO_SPACE)
+            {
+                /* Use the right mask to get the I/O port base address */
+                ASSERT(CmDescriptor->Type == CmResourceTypePort);
+                BarMask = PCI_ADDRESS_IO_ADDRESS_MASK;
+            }
+            else
+            {
+                /* It's a RAM BAR, use the right mask to get the base address */
+                ASSERT(CmDescriptor->Type == CmResourceTypeMemory);
+                BarMask = PCI_ADDRESS_MEMORY_ADDRESS_MASK;
+
+                /* Check if it's a 64-bit BAR */
+                if ((Bar & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_64BIT)
+                {
+                    /* The next BAR value is actually the high 32-bits */
+                    CmDescriptor->u.Memory.Start.HighPart = BarArray[i + 1];
+                }
+                else if ((Bar & PCI_ADDRESS_MEMORY_TYPE_MASK) == PCI_TYPE_20BIT)
+                {
+                    /* Legacy BAR, don't read more than 20 bits of the address */
+                    BarMask = 0xFFFF0;
+                }
+            }
+        }
+        else
+        {
+            /* Actually a ROM BAR, so read the correct register */
+            Bar = PciData->u.type0.ROMBaseAddress;
+
+            /* Apply the correct mask for ROM BARs */
+            BarMask = PCI_ADDRESS_ROM_ADDRESS_MASK;
+
+            /* Make sure it's enabled */
+            if (!(Bar & PCI_ROMADDRESS_ENABLED))
+            {
+                /* If it isn't, then a descriptor won't be built for it */
+                CmDescriptor->Type = CmResourceTypeNull;
+                continue;
+            }
+        }
+
+        /* Now we have the right mask, read the actual address from the BAR */
+        Bar &= BarMask;
+        CmDescriptor->u.Memory.Start.LowPart = Bar;
+
+        /* And check for invalid BAR addresses */
+        if (!(CmDescriptor->u.Memory.Start.HighPart | Bar))
+        {
+            /* Skip these descriptors */
+            CmDescriptor->Type = CmResourceTypeNull;
+            DPRINT1("Invalid BAR\n");
+        }
+    }
+
+    /* Also save the sub-IDs that came directly from the PCI header */
+    Context->PdoExtension->SubsystemVendorId = PciData->u.type0.SubVendorID;
+    Context->PdoExtension->SubsystemId = PciData->u.type0.SubSystemID;
 }
 
 VOID
 NTAPI
 Device_SaveLimits(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
-    UNIMPLEMENTED;
-    while (TRUE);
+    PPCI_COMMON_HEADER Current, PciData;
+    PPCI_PDO_EXTENSION PdoExtension;
+    PULONG BarArray;
+    PIO_RESOURCE_DESCRIPTOR Limit;
+    ULONG i;
+
+    /* Get pointers from the context */
+    PdoExtension = Context->PdoExtension;
+    Current = Context->Current;
+    PciData = Context->PciData;
+
+    /* And get the array of bARs */
+    BarArray = PciData->u.type0.BaseAddresses;
+
+    /* First, check for IDE controllers that are not in native mode */
+    if ((PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
+        (PdoExtension->SubClass == PCI_SUBCLASS_MSC_IDE_CTLR) &&
+        (PdoExtension->ProgIf & 5) != 5)
+    {
+        /* They should not be using any non-legacy resources */
+        BarArray[0] = 0;
+        BarArray[1] = 0;
+        BarArray[2] = 0;
+        BarArray[3] = 0;
+    }
+    else if ((PdoExtension->VendorId == 0x5333) &&
+             ((PdoExtension->DeviceId == 0x88F0) ||
+              (PdoExtension->DeviceId == 0x8880)))
+    {
+        /*
+         * The problem is caused by the S3 Vision 968/868 video controller which
+         * is used on the Diamond Stealth 64 Video 3000 series, Number Nine 9FX
+         * motion 771, and other popular video cards, all containing a memory bug.
+         * The 968/868 claims to require 32 MB of memory, but it actually decodes
+         * 64 MB of memory.
+         */
+        for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        {
+            /* Find its 32MB RAM BAR */
+            if (BarArray[i] == 0xFE000000)
+            {
+                /* Increase it to 64MB to make sure nobody touches the buffer */
+                BarArray[i] = 0xFC000000;
+                DPRINT1("PCI - Adjusted broken S3 requirement from 32MB to 64MB\n");
+            }
+        }
+    }
+
+    /* Check for Cirrus Logic GD5430/5440 cards */
+    if ((PdoExtension->VendorId == 0x1013) && (PdoExtension->DeviceId == 0xA0))
+    {
+        /* Check for the I/O port requirement */
+        if (BarArray[1] == 0xFC01)
+        {
+            /* Check for completely bogus BAR */
+            if (Current->u.type0.BaseAddresses[1] == 1)
+            {
+                /* Ignore it */
+                BarArray[1] = 0;
+                DPRINT1("PCI - Ignored Cirrus GD54xx broken IO requirement (400 ports)\n");
+            }
+            else
+            {
+                /* Otherwise, this BAR seems okay */
+                DPRINT1("PCI - Cirrus GD54xx 400 port IO requirement has a valid setting (%08x)\n",
+                        Current->u.type0.BaseAddresses[1]);
+            }
+        }
+        else if (BarArray[1])
+        {
+            /* Strange, the I/O BAR was not found as expected (or at all) */
+            DPRINT1("PCI - Warning Cirrus Adapter 101300a0 has unexpected resource requirement (%08x)\n",
+                    BarArray[1]);
+        }
+    }
+
+    /* Finally, process all the limit descriptors */
+    Limit = PdoExtension->Resources->Limit;
+    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+    {
+        /* And build them based on the BARs */
+        if (PciCreateIoDescriptorFromBarLimit(&Limit[i], &BarArray[i], FALSE))
+        {
+            /* This function returns TRUE if the BAR was 64-bit, handle this */
+            ASSERT((i + 1) < PCI_TYPE0_ADDRESSES);
+            i++;
+            (&Limit[i])->Type == CmResourceTypeNull;
+        }
+    }
+
+    /* Create the last descriptor based on the ROM address */
+    PciCreateIoDescriptorFromBarLimit(&Limit[i],
+                                      &PciData->u.type0.ROMBaseAddress,
+                                      TRUE);
 }
 
 VOID
 NTAPI
 Device_MassageHeaderForLimitsDetermination(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
-    UNIMPLEMENTED;
-    while (TRUE);
+    PPCI_COMMON_HEADER PciData;
+    PPCI_PDO_EXTENSION PdoExtension;
+    PULONG BarArray;
+    ULONG i = 0;
+
+    /* Get pointers from context data */
+    PdoExtension = Context->PdoExtension;
+    PciData = Context->PciData;
+
+    /* Get the array of BARs */
+    BarArray = PciData->u.type0.BaseAddresses;
+
+    /* Check for IDE controllers that are not in native mode */
+    if ((PdoExtension->BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
+        (PdoExtension->SubClass == PCI_SUBCLASS_MSC_IDE_CTLR) &&
+        (PdoExtension->ProgIf & 5) != 5)
+    {
+        /* These controllers only use legacy resources */
+        i = 4;
+    }
+
+    /* Set all the bits on, which will allow us to recover the limit data */
+    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++) BarArray[i] = 0xFFFFFFFF;
+
+    /* Do the same for the PCI ROM BAR */
+    PciData->u.type0.ROMBaseAddress = PCI_ADDRESS_ROM_ADDRESS_MASK;
 }
 
 VOID
 NTAPI
 Device_RestoreCurrent(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
-    UNIMPLEMENTED;
-    while (TRUE);
+    /* Nothing to do for devices */
+    return;
 }
 
 VOID
@@ -54,6 +260,7 @@ Device_GetAdditionalResourceDescriptors(IN PPCI_CONFIGURATOR_CONTEXT Context,
                                         IN PPCI_COMMON_HEADER PciData,
                                         IN PIO_RESOURCE_DESCRIPTOR IoDescriptor)
 {
+    /* Not yet implemented */
     UNIMPLEMENTED;
     while (TRUE);
 }
@@ -62,6 +269,7 @@ VOID
 NTAPI
 Device_ResetDevice(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
+    /* Not yet implemented */
     UNIMPLEMENTED;
     while (TRUE);
 }
@@ -70,6 +278,7 @@ VOID
 NTAPI
 Device_ChangeResourceSettings(IN PPCI_CONFIGURATOR_CONTEXT Context)
 {
+    /* Not yet implemented */
     UNIMPLEMENTED;
     while (TRUE);
 }
index dc771f2..a4d53dd 100644 (file)
@@ -32,7 +32,7 @@ PCI_CONFIGURATOR PciConfigurators[] =
         PPBridge_SaveCurrentSettings,
         PPBridge_ChangeResourceSettings,
         PPBridge_GetAdditionalResourceDescriptors,
-        PPBridge_ResetDevice  
+        PPBridge_ResetDevice
     },
     {
         Cardbus_MassageHeaderForLimitsDetermination,
@@ -44,7 +44,7 @@ PCI_CONFIGURATOR PciConfigurators[] =
         Cardbus_ResetDevice
     }
 };
+
 /* FUNCTIONS ******************************************************************/
 
 /*
@@ -715,10 +715,10 @@ PciWriteLimitsAndRestoreCurrent(IN PVOID Reserved,
 
     /* Write the limit discovery header */
     PciWriteDeviceConfig(PdoExtension, PciData, 0, PCI_COMMON_HDR_LENGTH);
-    
+
     /* Now read what the device indicated the limits are */
     PciReadDeviceConfig(PdoExtension, PciData, 0, PCI_COMMON_HDR_LENGTH);
-    
+
     /* Then write back the original configuration header */
     PciWriteDeviceConfig(PdoExtension, Current, 0, PCI_COMMON_HDR_LENGTH);
 
@@ -735,7 +735,7 @@ PciWriteLimitsAndRestoreCurrent(IN PVOID Reserved,
 
     /* Copy back the original status that was saved as well */
     Current->Status = Context->Status;
-    
+
     /* Call the configurator to restore any other data that might've changed */
     Context->Configurator->RestoreCurrent(Context);
 }
@@ -917,6 +917,62 @@ PciGetFunctionLimits(IN PPCI_PDO_EXTENSION PdoExtension,
     return Status;
 }
 
+VOID
+NTAPI
+PciProcessBus(IN PPCI_FDO_EXTENSION DeviceExtension)
+{
+    PPCI_PDO_EXTENSION PdoExtension;
+    PDEVICE_OBJECT PhysicalDeviceObject;
+    PAGED_CODE();
+
+    /* Get the PDO Extension */
+    PhysicalDeviceObject = DeviceExtension->PhysicalDeviceObject;
+    PdoExtension = (PPCI_PDO_EXTENSION)PhysicalDeviceObject->DeviceExtension;
+
+    /* Cheeck if this is the root bus */
+    if (!PCI_IS_ROOT_FDO(DeviceExtension))
+    {
+        /* Not really handling this year */
+        UNIMPLEMENTED;
+        while (TRUE);
+
+        /* Check for PCI bridges with the ISA bit set, or required */
+        if ((PdoExtension) &&
+            (PciClassifyDeviceType(PdoExtension) == PciTypePciBridge) &&
+            ((PdoExtension->Dependent.type1.IsaBitRequired) ||
+             (PdoExtension->Dependent.type1.IsaBitSet)))
+        {
+            /* We'll need to do some legacy support */
+            UNIMPLEMENTED;
+            while (TRUE);
+        }
+    }
+    else
+    {
+        /* Scan all of the root bus' children bridges */
+        for (PdoExtension = DeviceExtension->ChildBridgePdoList;
+             PdoExtension;
+             PdoExtension = PdoExtension->NextBridge)
+        {
+            /* Find any that have the VGA decode bit on */
+            if (PdoExtension->Dependent.type1.VgaBitSet)
+            {
+                /* Again, some more legacy support we'll have to do */
+                UNIMPLEMENTED;
+                while (TRUE);
+            }
+        }
+    }
+
+    /* Check for ACPI systems where the OS assigns bus numbers */
+    if (PciAssignBusNumbers)
+    {
+        /* Not yet supported */
+        UNIMPLEMENTED;
+        while (TRUE);
+    }
+}
+
 NTSTATUS
 NTAPI
 PciScanBus(IN PPCI_FDO_EXTENSION DeviceExtension)
@@ -1363,7 +1419,8 @@ PciScanBus(IN PPCI_FDO_EXTENSION DeviceExtension)
         }
     }
 
-    /* Enumeration is completed */
+    /* Enumeration completed, do a final pass now that all devices are found */
+    if (ProcessFlag) PciProcessBus(DeviceExtension);
     return STATUS_SUCCESS;
 }
 
index 306265f..93a5f14 100644 (file)
@@ -102,6 +102,18 @@ typedef enum _PCI_SIGNATURE
     PciInterface_Location  = 'icP?'
 } PCI_SIGNATURE, *PPCI_SIGNATURE;
 
+//
+// Driver-handled PCI Device Types
+//
+typedef enum _PCI_DEVICE_TYPES
+{
+    PciTypeInvalid,
+    PciTypeHostBridge,
+    PciTypePciBridge,
+    PciTypeCardbusBridge,
+    PciTypeDevice
+} PCI_DEVICE_TYPES;
+
 //
 // Device Extension Logic States
 //
@@ -1064,6 +1076,12 @@ PciCanDisableDecodes(
     IN BOOLEAN ForPowerDown
 );
 
+PCI_DEVICE_TYPES
+NTAPI
+PciClassifyDeviceType(
+    IN PPCI_PDO_EXTENSION PdoExtension
+);
+
 ULONG_PTR
 NTAPI
 PciExecuteCriticalSystemRoutine(
@@ -1607,6 +1625,7 @@ extern PCI_INTERFACE TranslatorInterfaceInterrupt;
 extern PDRIVER_OBJECT PciDriverObject;
 extern PWATCHDOG_TABLE WdTable;
 extern PPCI_HACK_ENTRY PciHackTable;
+extern BOOLEAN PciAssignBusNumbers;
 extern BOOLEAN PciEnableNativeModeATA;
 
 /* Exported by NTOS, should this go in the NDK? */
index 94f411b..f450a26 100644 (file)
@@ -1041,6 +1041,24 @@ PciCanDisableDecodes(IN PPCI_PDO_EXTENSION DeviceExtension,
     return !(HackFlags & PCI_HACK_NO_PM_CAPS);
 }
 
+PCI_DEVICE_TYPES
+NTAPI
+PciClassifyDeviceType(IN PPCI_PDO_EXTENSION PdoExtension)
+{
+    ASSERT(PdoExtension->ExtensionType == PciPdoExtensionType);
+
+    /* Differenriate between devices and bridges */
+    if (PdoExtension->BaseClass != PCI_CLASS_BRIDGE_DEV) return PciTypeDevice;
+
+    /* The PCI Bus driver handles only CardBus and PCI bridges (plus host) */
+    if (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST) return PciTypeHostBridge;
+    if (PdoExtension->SubClass == PCI_SUBCLASS_BR_PCI_TO_PCI) return PciTypePciBridge;
+    if (PdoExtension->SubClass == PCI_SUBCLASS_BR_CARDBUS) return PciTypeCardbusBridge;
+
+    /* Any other kind of bridge is treated like a device */
+    return PciTypeDevice;
+}
+
 ULONG_PTR
 NTAPI
 PciExecuteCriticalSystemRoutine(IN ULONG_PTR IpiContext)
index 95db2ea..dd0e065 100644 (file)
@@ -73,7 +73,7 @@ CdfsGetPVDData(PUCHAR Buffer,
     /* Extract the volume label */
     pc = Pvd->VolumeId;
     pw = CdInfo->VolumeLabel;
-    for (i = 0; i < MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR); i++)
+    for (i = 0; i < (MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)) - 1; i++)
     {
         *pw++ = (WCHAR)*pc++;
     }
index 4e7128b..d1f618a 100644 (file)
@@ -95,6 +95,46 @@ CdfsFileFlagsToAttributes(PFCB Fcb,
         ((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
 }
 
+BOOLEAN
+CdfsIsNameLegalDOS8Dot3(IN UNICODE_STRING FileName
+    )
+{
+    ULONG i;
+    STRING DbcsName;
+    CHAR DbcsNameBuffer[12];
+
+    /* 8dot3 filename is max 12 length */
+    if (FileName.Length / sizeof(WCHAR) > 12)
+    {
+        return FALSE;
+    }
+
+    for (i = 0; i < FileName.Length / sizeof(WCHAR) ; i++)
+    {
+        /* Don't allow spaces in FileName */
+        if (FileName.Buffer[i] == L' ')
+            return FALSE;
+    }
+
+    /* If FileName is finishing with a dot, remove it */
+    if (FileName.Buffer[FileName.Length / sizeof(WCHAR) - 1] == '.')
+    {
+        FileName.Length -= sizeof(WCHAR);
+    }
+
+    /* Finally, convert the string to call the FsRtl function */
+    DbcsName.MaximumLength = 12;
+    DbcsName.Buffer = DbcsNameBuffer;
+    if (!NT_SUCCESS(RtlUnicodeStringToCountedOemString(&DbcsName,
+                                                       &FileName,
+                                                       FALSE )))
+    {
+
+        return FALSE;
+    }
+    return FsRtlIsFatDbcsLegal(DbcsName, FALSE, FALSE, FALSE);
+}
+
 VOID
 CdfsShortNameCacheGet
 (PFCB DirectoryFcb, 
@@ -102,7 +142,6 @@ CdfsShortNameCacheGet
  PUNICODE_STRING LongName, 
  PUNICODE_STRING ShortName)
 {
-    BOOLEAN HasSpaces;
     PLIST_ENTRY Entry;
     PCDFS_SHORT_NAME ShortNameEntry;
     GENERATE_NAME_CONTEXT Context = { 0 };
@@ -132,8 +171,7 @@ CdfsShortNameCacheGet
     }
 
     /* Cache miss */
-    if ((RtlIsNameLegalDOS8Dot3(LongName, NULL, &HasSpaces) == FALSE) ||
-        (HasSpaces == TRUE))
+    if (!CdfsIsNameLegalDOS8Dot3(*LongName))
     {
         RtlGenerate8dot3Name(LongName, FALSE, &Context, ShortName);
     }
index 07b6dc0..f643104 100644 (file)
@@ -466,7 +466,7 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
 
        /* This a open operation for the volume itself */
        if (FileObject->FileName.Length == 0 &&
-               FileObject->RelatedFileObject == NULL)
+               (FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL))
        {
                if (RequestedDisposition == FILE_CREATE ||
                        RequestedDisposition == FILE_OVERWRITE_IF ||
@@ -474,10 +474,13 @@ VfatCreateFile ( PDEVICE_OBJECT DeviceObject, PIRP Irp )
                {
                        return(STATUS_ACCESS_DENIED);
                }
+#if 0
+        /* In spite of what is shown in WDK, it seems that Windows FAT driver doesn't perform that test */
                if (RequestedOptions & FILE_DIRECTORY_FILE)
                {
                        return(STATUS_NOT_A_DIRECTORY);
                }
+#endif
                pFcb = DeviceExt->VolumeFcb;
                pCcb = ExAllocateFromNPagedLookasideList(&VfatGlobalData->CcbLookasideList);
                if (pCcb == NULL)
index dac825f..dbc1f1b 100644 (file)
 
 /* FUNCTIONS ****************************************************************/
 
+/* Last handle to a file object is closed */
+NTSTATUS
+NTAPI
+FatiCleanup(PFAT_IRP_CONTEXT IrpContext, PIRP Irp)
+{
+    PIO_STACK_LOCATION IrpSp;
+    PFILE_OBJECT FileObject;
+    TYPE_OF_OPEN TypeOfOpen;
+    PSHARE_ACCESS ShareAccess;
+    BOOLEAN SendUnlockNotification = FALSE;
+    PLARGE_INTEGER TruncateSize = NULL;
+    //LARGE_INTEGER LocalTruncateSize;
+    BOOLEAN AcquiredVcb = FALSE, AcquiredFcb = FALSE;
+    NTSTATUS Status;
+    PVCB Vcb;
+    PFCB Fcb;
+    PCCB Ccb;
+
+    IrpSp = IoGetCurrentIrpStackLocation( Irp );
+
+    DPRINT("FatiCleanup\n");
+    DPRINT("\tIrp           = %p\n", Irp);
+    DPRINT("\t->FileObject  = %p\n", IrpSp->FileObject);
+
+    FileObject = IrpSp->FileObject;
+    TypeOfOpen = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
+
+    if (TypeOfOpen == UnopenedFileObject)
+    {
+        DPRINT1("Unopened File Object\n");
+
+        FatCompleteRequest(IrpContext, Irp, STATUS_SUCCESS);
+        return STATUS_SUCCESS;
+    }
+
+    if (FlagOn( FileObject->Flags, FO_CLEANUP_COMPLETE ))
+    {
+        /* Just flush the file */
+
+        if (FlagOn(Vcb->State, VCB_STATE_FLAG_DEFERRED_FLUSH) &&
+            FlagOn(FileObject->Flags, FO_FILE_MODIFIED) &&
+            !FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED) &&
+            (TypeOfOpen == UserFileOpen))
+        {
+            //Status = FatFlushFile(IrpContext, Fcb, Flush);
+            //if (!NT_SUCCESS(Status)) FatNormalizeAndRaiseStatus(IrpContext, Status);
+            UNIMPLEMENTED;
+        }
+
+        FatCompleteRequest(IrpContext, Irp, STATUS_SUCCESS);
+        return STATUS_SUCCESS;
+    }
+
+    if (TypeOfOpen == UserFileOpen ||
+        TypeOfOpen == UserDirectoryOpen)
+    {
+        ASSERT(Fcb != NULL);
+
+        (VOID)FatAcquireExclusiveFcb(IrpContext, Fcb);
+
+        AcquiredFcb = TRUE;
+
+        /* Set FCB flags according to DELETE_ON_CLOSE */
+        if (FlagOn(Ccb->Flags, CCB_DELETE_ON_CLOSE))
+        {
+            ASSERT(FatNodeType(Fcb) != FAT_NTC_ROOT_DCB);
+
+            SetFlag(Fcb->State, FCB_STATE_DELETE_ON_CLOSE);
+
+            /* Issue a notification */
+            if (TypeOfOpen == UserDirectoryOpen)
+            {
+                FsRtlNotifyFullChangeDirectory(Vcb->NotifySync,
+                                               &Vcb->NotifyList,
+                                               FileObject->FsContext,
+                                               NULL,
+                                               FALSE,
+                                               FALSE,
+                                               0,
+                                               NULL,
+                                               NULL,
+                                               NULL);
+            }
+        }
+
+        /* If file should be deleted, acquire locks */
+        if ((Fcb->UncleanCount == 1) &&
+            FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE) &&
+            (Fcb->Condition != FcbBad) &&
+            !FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED))
+        {
+            FatReleaseFcb(IrpContext, Fcb);
+            AcquiredFcb = FALSE;
+
+            (VOID)FatAcquireExclusiveVcb(IrpContext, Vcb);
+            AcquiredVcb = TRUE;
+
+            (VOID)FatAcquireExclusiveFcb(IrpContext, Fcb);
+            AcquiredFcb = TRUE;
+        }
+    }
+
+    /* Acquire VCB lock if it was a volume open */
+    if (TypeOfOpen == UserVolumeOpen)
+    {
+        (VOID)FatAcquireExclusiveVcb(IrpContext, Vcb);
+        AcquiredVcb = TRUE;
+    }
+
+    /* Cleanup all notifications */
+    if (TypeOfOpen == UserDirectoryOpen)
+    {
+        FsRtlNotifyCleanup(Vcb->NotifySync,
+                           &Vcb->NotifyList,
+                           Ccb);
+    }
+
+    if (Fcb)
+    {
+        //TODO: FatVerifyFcb
+    }
+
+    switch (TypeOfOpen)
+    {
+    case DirectoryFile:
+    case VirtualVolumeFile:
+        DPRINT1("Cleanup VirtualVolumeFile/DirectoryFile\n");
+        ShareAccess = NULL;
+        break;
+
+    case UserVolumeOpen:
+        DPRINT("Cleanup UserVolumeOpen\n");
+
+        if (FlagOn(Ccb->Flags, CCB_COMPLETE_DISMOUNT))
+        {
+            FatCheckForDismount( IrpContext, Vcb, TRUE );
+        } else if (FileObject->WriteAccess &&
+            FlagOn(FileObject->Flags, FO_FILE_MODIFIED))
+        {
+            UNIMPLEMENTED;
+        }
+
+        /* Release the volume and send notification */
+        if (FlagOn(Vcb->State, VCB_STATE_FLAG_LOCKED) &&
+            (Vcb->FileObjectWithVcbLocked == FileObject))
+        {
+            UNIMPLEMENTED;
+            SendUnlockNotification = TRUE;
+        }
+
+        ShareAccess = &Vcb->ShareAccess;
+        break;
+
+    case EaFile:
+        DPRINT1("Cleanup EaFileObject\n");
+        ShareAccess = NULL;
+        break;
+
+    case UserDirectoryOpen:
+        DPRINT("Cleanup UserDirectoryOpen\n");
+
+        ShareAccess = &Fcb->ShareAccess;
+
+        /* Should it be a delayed close? */
+        if ((Fcb->UncleanCount == 1) &&
+            (Fcb->OpenCount == 1) &&
+            (Fcb->Dcb.DirectoryFileOpenCount == 0) &&
+            !FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE) &&
+            Fcb->Condition == FcbGood)
+        {
+            /* Yes, a delayed one */
+            SetFlag(Fcb->State, FCB_STATE_DELAY_CLOSE);
+        }
+
+        if (VcbGood == Vcb->Condition)
+        {
+            //FatUpdateDirentFromFcb( IrpContext, FileObject, Fcb, Ccb );
+            //TODO: Actually update dirent
+        }
+
+        if ((Fcb->UncleanCount == 1) &&
+            (FatNodeType(Fcb) == FAT_NTC_DCB) &&
+            (FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE)) &&
+            (Fcb->Condition != FcbBad) &&
+            !FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED))
+        {
+            UNIMPLEMENTED;
+        }
+
+        /*  Decrement unclean counter */
+        ASSERT(Fcb->UncleanCount != 0);
+        Fcb->UncleanCount--;
+        break;
+
+    case UserFileOpen:
+        DPRINT("Cleanup UserFileOpen\n");
+
+        ShareAccess = &Fcb->ShareAccess;
+
+        /* Should it be a delayed close? */
+        if ((FileObject->SectionObjectPointer->DataSectionObject == NULL) &&
+            (FileObject->SectionObjectPointer->ImageSectionObject == NULL) &&
+            (Fcb->UncleanCount == 1) &&
+            (Fcb->OpenCount == 1) &&
+            !FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE) &&
+            Fcb->Condition == FcbGood)
+        {
+            /* Yes, a delayed one */
+            SetFlag(Fcb->State, FCB_STATE_DELAY_CLOSE);
+        }
+
+        /* Unlock all file locks */
+        FsRtlFastUnlockAll(&Fcb->Fcb.Lock,
+                           FileObject,
+                           IoGetRequestorProcess(Irp),
+                           NULL);
+
+        if (Vcb->Condition == VcbGood)
+        {
+            if (Fcb->Condition != FcbBad)
+            {
+                //FatUpdateDirentFromFcb( IrpContext, FileObject, Fcb, Ccb );
+                // TODO: Update on-disk structures
+            }
+
+            if (Fcb->UncleanCount == 1 &&
+                Fcb->Condition != FcbBad)
+            {
+                //DELETE_CONTEXT DeleteContext;
+
+                /* Should this file be deleted on close? */
+                if (FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE) &&
+                    !FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED))
+                {
+                    UNIMPLEMENTED;
+                }
+                else
+                {
+                    if (!FlagOn(Fcb->State, FCB_STATE_PAGEFILE) &&
+                        (Fcb->Header.ValidDataLength.LowPart < Fcb->Header.FileSize.LowPart))
+                    {
+#if 0
+                        ULONG ValidDataLength;
+
+                        ValidDataLength = Fcb->Header.ValidDataLength.LowPart;
+
+                        if (ValidDataLength < Fcb->ValidDataToDisk) {
+                            ValidDataLength = Fcb->ValidDataToDisk;
+                        }
+
+                        if (ValidDataLength < Fcb->Header.FileSize.LowPart)
+                        {
+                            FatZeroData( IrpContext,
+                                Vcb,
+                                FileObject,
+                                ValidDataLength,
+                                Fcb->Header.FileSize.LowPart -
+                                ValidDataLength );
+
+                            Fcb->ValidDataToDisk =
+                                Fcb->Header.ValidDataLength.LowPart =
+                                Fcb->Header.FileSize.LowPart;
+
+                            if (CcIsFileCached(FileObject))
+                            {
+                                CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
+                            }
+                        }
+#endif
+                        DPRINT1("Zeroing out data is not implemented\n");
+                    }
+                }
+
+                /* Should the file be truncated on close? */
+                if (FlagOn(Fcb->State, FCB_STATE_TRUNCATE_ON_CLOSE))
+                {
+                    if (Vcb->Condition == VcbGood)
+                    {
+                        // TODO: Actually truncate the file allocation
+                        UNIMPLEMENTED;
+                    }
+
+                    /* Remove truncation flag */
+                    Fcb->State &= ~FCB_STATE_TRUNCATE_ON_CLOSE;
+                }
+
+                /* Check again if it should be deleted */
+                if (FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE) &&
+                    Fcb->Header.AllocationSize.LowPart == 0)
+                {
+                    FatNotifyReportChange(IrpContext,
+                                          Vcb,
+                                          Fcb,
+                                          FILE_NOTIFY_CHANGE_FILE_NAME,
+                                          FILE_ACTION_REMOVED);
+                }
+
+                /* Remove the entry from the splay table if the file was deleted */
+                if (FlagOn(Fcb->State, FCB_STATE_DELETE_ON_CLOSE))
+                {
+                    FatRemoveNames(IrpContext, Fcb);
+                }
+            }
+        }
+
+        ASSERT(Fcb->UncleanCount != 0);
+        Fcb->UncleanCount--;
+        if (!FlagOn(FileObject->Flags, FO_CACHE_SUPPORTED))
+        {
+            ASSERT(Fcb->NonCachedUncleanCount != 0);
+            Fcb->NonCachedUncleanCount--;
+        }
+
+        if (FlagOn(FileObject->Flags, FO_CACHE_SUPPORTED) &&
+            (Fcb->NonCachedUncleanCount != 0) &&
+            (Fcb->NonCachedUncleanCount == Fcb->UncleanCount) &&
+            (Fcb->SectionObjectPointers.DataSectionObject != NULL))
+        {
+            CcFlushCache(&Fcb->SectionObjectPointers, NULL, 0, NULL);
+
+            /* Acquire and release PagingIo to get in sync with lazy writer */
+            ExAcquireResourceExclusiveLite(Fcb->Header.PagingIoResource, TRUE);
+            ExReleaseResourceLite(Fcb->Header.PagingIoResource);
+
+            CcPurgeCacheSection(&Fcb->SectionObjectPointers,
+                                NULL,
+                                0,
+                                FALSE);
+        }
+
+        if (Fcb->Condition == FcbBad)
+        {
+            //TruncateSize = &FatLargeZero;
+            UNIMPLEMENTED;
+        }
+
+        /*  Cleanup the cache map */
+        CcUninitializeCacheMap(FileObject, TruncateSize, NULL);
+        break;
+
+    default:
+        KeBugCheckEx(FAT_FILE_SYSTEM, __LINE__, (ULONG_PTR)TypeOfOpen, 0, 0);
+    }
+
+    /* Cleanup the share access */
+
+    if (ShareAccess)
+    {
+        DPRINT("Cleaning up the share access\n");
+        IoRemoveShareAccess(FileObject, ShareAccess);
+    }
+
+    if (TypeOfOpen == UserFileOpen)
+    {
+        /* Update oplocks */
+        FsRtlCheckOplock(&Fcb->Fcb.Oplock,
+                         Irp,
+                         IrpContext,
+                         NULL,
+                         NULL);
+
+        Fcb->Header.IsFastIoPossible = FatIsFastIoPossible(Fcb);
+    }
+
+    /* Set the FO_CLEANUP_COMPLETE flag */
+    SetFlag(FileObject->Flags, FO_CLEANUP_COMPLETE);
+
+    Status = STATUS_SUCCESS;
+
+    // TODO: Unpin repinned BCBs
+    //FatUnpinRepinnedBcbs(IrpContext);
+
+    /* Flush the volume if necessary */
+    if (FlagOn(Vcb->State, VCB_STATE_FLAG_DEFERRED_FLUSH) &&
+        !FlagOn(Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED))
+    {
+        UNIMPLEMENTED;
+    }
+
+    /* Cleanup */
+    if (AcquiredFcb) FatReleaseFcb(IrpContext, Fcb);
+    if (AcquiredVcb) FatReleaseVcb(IrpContext, Vcb);
+
+    /* Send volume notification */
+    if (SendUnlockNotification)
+        FsRtlNotifyVolumeEvent(FileObject, FSRTL_VOLUME_UNLOCK);
+
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 FatCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
-    DPRINT1("FatCleanup(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
+    PFAT_IRP_CONTEXT IrpContext;
+    NTSTATUS Status;
+
+    DPRINT("FatCleanup(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
+
+    /* FatCleanup works only with a volume device object */
+    if (DeviceObject == FatGlobalData.DiskDeviceObject)
+    {
+        /* Complete the request and return success */
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = FILE_OPENED;
+
+        IoCompleteRequest(Irp, IO_DISK_INCREMENT);
+
+        return STATUS_SUCCESS;
+    }
+
+    /* Enter FsRtl critical region */
+    FsRtlEnterFileSystem();
+
+    /* Build an irp context */
+    IrpContext = FatBuildIrpContext(Irp, TRUE);
+
+    /* Call internal function */
+    Status = FatiCleanup(IrpContext, Irp);
+
+    /* Leave FsRtl critical region */
+    FsRtlExitFileSystem();
 
-    return STATUS_NOT_IMPLEMENTED;
+    return Status;
 }
 
 /* EOF */
index 6934698..69ccf3c 100644 (file)
 #define NDEBUG
 #include "fastfat.h"
 
+VOID NTAPI
+FatQueueClose(IN PCLOSE_CONTEXT CloseContext,
+              IN BOOLEAN DelayClose);
+
+PCLOSE_CONTEXT NTAPI
+FatRemoveClose(PVCB Vcb OPTIONAL,
+               PVCB LastVcbHint OPTIONAL);
+
+const ULONG FatMaxDelayedCloseCount = 16;
+
 /* FUNCTIONS ****************************************************************/
 
+NTSTATUS
+NTAPI
+FatiCommonClose(IN PVCB Vcb,
+                IN PFCB Fcb,
+                IN PCCB Ccb,
+                IN TYPE_OF_OPEN TypeOfOpen,
+                IN BOOLEAN Wait,
+                OUT PBOOLEAN VcbDeleted)
+{
+    NTSTATUS Status;
+    PFCB ParentDcb;
+    BOOLEAN RecursiveClose, VcbDeletedLv = FALSE;
+    FAT_IRP_CONTEXT IrpContext;
+
+    if (VcbDeleted) *VcbDeleted = FALSE;
+
+    if (TypeOfOpen == UnopenedFileObject)
+    {
+        DPRINT1("Closing unopened file object\n");
+        Status = STATUS_SUCCESS;
+        return Status;
+    }
+
+    RtlZeroMemory(&IrpContext, sizeof(FAT_IRP_CONTEXT));
+
+    IrpContext.NodeTypeCode = FAT_NTC_IRP_CONTEXT;
+    IrpContext.NodeByteSize = sizeof(IrpContext);
+    IrpContext.MajorFunction = IRP_MJ_CLOSE;
+
+    if (Wait) SetFlag(IrpContext.Flags, IRPCONTEXT_CANWAIT);
+
+    if (!ExAcquireResourceExclusiveLite(&Vcb->Resource, Wait)) return STATUS_PENDING;
+
+    if (Vcb->State & VCB_STATE_FLAG_CLOSE_IN_PROGRESS)
+    {
+        RecursiveClose = TRUE;
+    }
+    else
+    {
+        SetFlag(Vcb->State, VCB_STATE_FLAG_CLOSE_IN_PROGRESS);
+        RecursiveClose = FALSE;
+
+        Vcb->OpenFileCount++;
+    }
+
+    /* Update on-disk structures */
+    switch (TypeOfOpen)
+    {
+    case VirtualVolumeFile:
+        DPRINT1("Close VirtualVolumeFile\n");
+
+        InterlockedDecrement((PLONG)&(Vcb->InternalOpenCount));
+        InterlockedDecrement((PLONG)&(Vcb->ResidualOpenCount));
+
+        Status = STATUS_SUCCESS;
+        goto close_done;
+        break;
+
+    case UserVolumeOpen:
+        DPRINT1("Close UserVolumeOpen\n");
+
+        Vcb->DirectAccessOpenCount--;
+        Vcb->OpenFileCount--;
+        if (FlagOn(Ccb->Flags, CCB_READ_ONLY)) Vcb->ReadOnlyCount--;
+
+        FatDeleteCcb(&IrpContext, Ccb);
+
+        Status = STATUS_SUCCESS;
+        goto close_done;
+        break;
+
+    case EaFile:
+        UNIMPLEMENTED;
+        break;
+
+    case DirectoryFile:
+        DPRINT1("Close DirectoryFile\n");
+
+        InterlockedDecrement((PLONG)&(Fcb->Dcb.DirectoryFileOpenCount));
+        InterlockedDecrement((PLONG)&(Vcb->InternalOpenCount));
+
+        if (FatNodeType(Fcb) == FAT_NTC_ROOT_DCB)
+        {
+            InterlockedDecrement((PLONG)&(Vcb->ResidualOpenCount));
+        }
+
+        if (RecursiveClose)
+        {
+            Status = STATUS_SUCCESS;
+            goto close_done;
+        }
+        else
+        {
+            break;
+        }
+
+    case UserDirectoryOpen:
+    case UserFileOpen:
+        DPRINT("Close UserFileOpen/UserDirectoryOpen\n");
+
+        if ((FatNodeType(Fcb) == FAT_NTC_DCB) &&
+            IsListEmpty(&Fcb->Dcb.ParentDcbList) &&
+            (Fcb->OpenCount == 1) &&
+            (Fcb->Dcb.DirectoryFile != NULL))
+        {
+                PFILE_OBJECT DirectoryFileObject = Fcb->Dcb.DirectoryFile;
+
+                DPRINT1("Uninitialize the stream file object\n");
+
+                CcUninitializeCacheMap(DirectoryFileObject, NULL, NULL);
+
+                Fcb->Dcb.DirectoryFile = NULL;
+                ObDereferenceObject(DirectoryFileObject);
+        }
+
+        Fcb->OpenCount--;
+        Vcb->OpenFileCount--;
+        if (FlagOn(Ccb->Flags, CCB_READ_ONLY)) Vcb->ReadOnlyCount --;
+
+        FatDeleteCcb(&IrpContext, Ccb);
+        break;
+
+    default:
+        KeBugCheckEx(FAT_FILE_SYSTEM, __LINE__, (ULONG_PTR)TypeOfOpen, 0, 0);
+    }
+
+    /* Update in-memory structures */
+    if (((FatNodeType(Fcb) == FAT_NTC_FCB) &&
+        (Fcb->OpenCount == 0))
+        ||
+        ((FatNodeType(Fcb) == FAT_NTC_DCB) &&
+        (IsListEmpty(&Fcb->Dcb.ParentDcbList)) &&
+        (Fcb->OpenCount == 0) &&
+        (Fcb->Dcb.DirectoryFileOpenCount == 0)))
+    {
+        ParentDcb = Fcb->ParentFcb;
+
+        SetFlag(Vcb->State, VCB_STATE_FLAG_DELETED_FCB);
+
+        FatDeleteFcb(&IrpContext, Fcb);
+
+        while ((FatNodeType(ParentDcb) == FAT_NTC_DCB) &&
+            IsListEmpty(&ParentDcb->Dcb.ParentDcbList) &&
+            (ParentDcb->OpenCount == 0) &&
+            (ParentDcb->Dcb.DirectoryFile != NULL))
+        {
+                PFILE_OBJECT DirectoryFileObject;
+
+                DirectoryFileObject = ParentDcb->Dcb.DirectoryFile;
+
+                DPRINT1("Uninitialize parent Stream Cache Map\n");
+
+                CcUninitializeCacheMap(DirectoryFileObject, NULL, NULL);
+
+                ParentDcb->Dcb.DirectoryFile = NULL;
+
+                ObDereferenceObject(DirectoryFileObject);
+
+                if (ParentDcb->Dcb.DirectoryFileOpenCount == 0)
+                {
+                    PFCB CurrentDcb;
+
+                    CurrentDcb = ParentDcb;
+                    ParentDcb = CurrentDcb->ParentFcb;
+
+                    SetFlag(Vcb->State, VCB_STATE_FLAG_DELETED_FCB);
+
+                    FatDeleteFcb(&IrpContext, CurrentDcb);
+                }
+                else
+                {
+                    break;
+                }
+        }
+    }
+
+    Status = STATUS_SUCCESS;
+
+close_done:
+    /* Closing is done, check if VCB could be closed too */
+    if (!RecursiveClose)
+    {
+        /* One open left - yes, VCB can go away */
+        if (Vcb->OpenFileCount == 1 &&
+            !FlagOn(Vcb->State, VCB_STATE_FLAG_DISMOUNT_IN_PROGRESS)
+            && VcbDeleted)
+        {
+            FatReleaseVcb(&IrpContext, Vcb );
+
+            SetFlag(IrpContext.Flags, IRPCONTEXT_CANWAIT);
+
+            FatAcquireExclusiveGlobal(&IrpContext);
+
+            FatAcquireExclusiveVcb(&IrpContext, Vcb);
+
+            Vcb->OpenFileCount--;
+
+            VcbDeletedLv = FatCheckForDismount(&IrpContext, Vcb, FALSE);
+
+            FatReleaseGlobal(&IrpContext);
+
+            if (VcbDeleted) *VcbDeleted = VcbDeletedLv;
+        }
+        else
+        {
+            /* Remove extra referenec */
+            Vcb->OpenFileCount --;
+        }
+
+        /* Clear recursion flag if necessary */
+        if (!VcbDeletedLv)
+        {
+            ClearFlag(Vcb->State, VCB_STATE_FLAG_CLOSE_IN_PROGRESS);
+        }
+    }
+
+    /* Release VCB if it wasn't deleted */
+    if (!VcbDeletedLv)
+        FatReleaseVcb(&IrpContext, Vcb);
+
+    return Status;
+}
+
+NTSTATUS
+NTAPI
+FatiClose(IN PFAT_IRP_CONTEXT IrpContext,
+          IN PIRP Irp)
+{
+    PIO_STACK_LOCATION IrpSp;
+    TYPE_OF_OPEN TypeOfOpen;
+    PVCB Vcb;
+    PFCB Fcb;
+    PCCB Ccb;
+    BOOLEAN TopLevel, Wait, VcbDeleted = FALSE, DelayedClose = FALSE;
+    NTSTATUS Status = STATUS_SUCCESS;
+    PCLOSE_CONTEXT CloseContext = NULL;
+
+    TopLevel = FatIsTopLevelIrp(Irp);
+
+    /* Get current IRP stack location */
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+    /* Decode incoming file object */
+    TypeOfOpen = FatDecodeFileObject(IrpSp->FileObject, &Vcb, &Fcb, &Ccb);
+
+    /* Set CCB read only flag */
+    if (Ccb && IsFileObjectReadOnly(IrpSp->FileObject))
+        SetFlag(Ccb->Flags, CCB_READ_ONLY);
+
+    /* It's possible to wait only if we are top level or not a system process */
+    Wait = TopLevel && (PsGetCurrentProcess() != FatGlobalData.SystemProcess);
+
+    /* Determine if it's a delayed close, by flags first */
+    if ((TypeOfOpen == UserFileOpen || TypeOfOpen == UserDirectoryOpen) &&
+        (Fcb->State & FCB_STATE_DELAY_CLOSE) &&
+        !FatGlobalData.ShutdownStarted)
+    {
+        DelayedClose = TRUE;
+    }
+
+    /* If close is not delayed, try to perform the close operation */
+    if (!DelayedClose)
+        Status = FatiCommonClose(Vcb, Fcb, Ccb, TypeOfOpen, Wait, &VcbDeleted);
+
+    /* We have to delay close if either it's defined by a flag or it was not possible
+       to perform it synchronously */
+    if (DelayedClose || Status == STATUS_PENDING)
+    {
+        DPRINT1("Queuing a pending close, Vcb %p, Fcb %p, Ccb %p\n", Vcb, Fcb, Ccb);
+
+        /* Check if a close context should be allocated */
+        if (TypeOfOpen == VirtualVolumeFile)
+        {
+            ASSERT(Vcb->CloseContext != NULL);
+            CloseContext = Vcb->CloseContext;
+            Vcb->CloseContext = NULL;
+            CloseContext->Free = TRUE;
+        }
+        else if (TypeOfOpen == DirectoryFile ||
+                 TypeOfOpen == EaFile)
+        {
+            UNIMPLEMENTED;
+            //CloseContext = FatAllocateCloseContext(Vcb);
+            //ASSERT(CloseContext != NULL);
+            CloseContext->Free = TRUE;
+        }
+        else
+        {
+            //TODO: FatDeallocateCcbStrings( Ccb );
+
+            /* Set CloseContext to a buffer inside Ccb */
+            CloseContext = &Ccb->CloseContext;
+            CloseContext->Free = FALSE;
+            SetFlag(Ccb->Flags, CCB_CLOSE_CONTEXT);
+        }
+
+        /* Save all info in the close context */
+        CloseContext->Vcb = Vcb;
+        CloseContext->Fcb = Fcb;
+        CloseContext->TypeOfOpen = TypeOfOpen;
+
+        /* Queue the close */
+        FatQueueClose(CloseContext, (BOOLEAN)(Fcb && FlagOn(Fcb->State, FCB_STATE_DELAY_CLOSE)));
+    }
+    else
+    {
+        /* Close finished right away */
+        if (TypeOfOpen == VirtualVolumeFile ||
+            TypeOfOpen == DirectoryFile ||
+            TypeOfOpen == EaFile)
+        {
+                if (TypeOfOpen == VirtualVolumeFile)
+                {
+                    /* Free close context for the not deleted VCB */
+                    if (!VcbDeleted)
+                    {
+                        CloseContext = Vcb->CloseContext;
+                        Vcb->CloseContext = NULL;
+
+                        ASSERT(CloseContext != NULL);
+                    }
+                }
+                else
+                {
+                    //CloseContext = FatAllocateCloseContext(Vcb);
+                    DPRINT1("TODO: Allocate close context!\n");
+                    ASSERT(CloseContext != NULL);
+                }
+
+                /* Free close context */
+                if (CloseContext) ExFreePool(CloseContext);
+        }
+    }
+
+    /* Complete the request */
+    FatCompleteRequest(NULL, Irp, Status);
+
+    /* Reset the top level IRP if necessary */
+    if (TopLevel) IoSetTopLevelIrp(NULL);
+
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 FatClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
-    DPRINT1("FatClose(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
+    PFAT_IRP_CONTEXT IrpContext;
+    NTSTATUS Status;
+
+    DPRINT("FatClose(DeviceObject %p, Irp %p)\n", DeviceObject, Irp);
+
+    /* FatClose works only with a volume device object */
+    if (DeviceObject == FatGlobalData.DiskDeviceObject)
+    {
+        /* Complete the request and return success */
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = FILE_OPENED;
+
+        IoCompleteRequest(Irp, IO_DISK_INCREMENT);
+
+        return STATUS_SUCCESS;
+    }
+
+    /* Enter FsRtl critical region */
+    FsRtlEnterFileSystem();
+
+    /* Build an irp context */
+    IrpContext = FatBuildIrpContext(Irp, TRUE);
+
+    /* Call internal function */
+    Status = FatiClose(IrpContext, Irp);
+
+    /* Leave FsRtl critical region */
+    FsRtlExitFileSystem();
+
+    return Status;
+}
+
+VOID
+NTAPI
+FatPendingClose(IN PVCB Vcb OPTIONAL)
+{
+    PCLOSE_CONTEXT CloseContext;
+    PVCB CurrentVcb = NULL;
+    PVCB LastVcb = NULL;
+    BOOLEAN FreeContext;
+    ULONG Loops = 0;
+
+    /* Do the top-level IRP trick */
+    if (!Vcb) IoSetTopLevelIrp((PIRP)FSRTL_FSP_TOP_LEVEL_IRP);
+
+    while ((CloseContext = FatRemoveClose(Vcb, LastVcb)))
+    {
+        if (!Vcb)
+        {
+            if (!FatGlobalData.ShutdownStarted)
+            {
+                if (CloseContext->Vcb != CurrentVcb)
+                {
+                    Loops = 0;
+
+                    /* Release previous VCB */
+                    if (CurrentVcb)
+                        ExReleaseResourceLite(&CurrentVcb->Resource);
+
+                    /* Lock the new VCB */
+                    CurrentVcb = CloseContext->Vcb;
+                    (VOID)ExAcquireResourceExclusiveLite(&CurrentVcb->Resource, TRUE);
+                }
+                else
+                {
+                    /* Try to lock */
+                    if (++Loops >= 20)
+                    {
+                        if (ExGetSharedWaiterCount(&CurrentVcb->Resource) +
+                            ExGetExclusiveWaiterCount(&CurrentVcb->Resource))
+                        {
+                            ExReleaseResourceLite(&CurrentVcb->Resource);
+                            (VOID)ExAcquireResourceExclusiveLite(&CurrentVcb->Resource, TRUE);
+                        }
+
+                        Loops = 0;
+                    }
+                }
+
+                /* Check open count */
+                if (CurrentVcb->OpenFileCount <= 1)
+                {
+                    ExReleaseResourceLite(&CurrentVcb->Resource);
+                    CurrentVcb = NULL;
+                }
+            }
+            else if (CurrentVcb)
+            {
+                ExReleaseResourceLite(&CurrentVcb->Resource);
+                CurrentVcb = NULL;
+            }
+        }
+
+        LastVcb = CurrentVcb;
+
+        /* Remember if we should free the context */
+        FreeContext = CloseContext->Free;
+
+        FatiCommonClose(CloseContext->Vcb,
+                        CloseContext->Fcb,
+                        (FreeContext ? NULL : CONTAINING_RECORD(CloseContext, CCB, CloseContext)),
+                        CloseContext->TypeOfOpen,
+                        TRUE,
+                        NULL);
+
+        /* Free context if necessary */
+        if (FreeContext) ExFreePool(CloseContext);
+    }
+
+    /* Release VCB if necessary */
+    if (CurrentVcb) ExReleaseResourceLite(&CurrentVcb->Resource);
+
+    /* Reset top level IRP */
+    if (!Vcb) IoSetTopLevelIrp( NULL );
+}
+
+VOID
+NTAPI
+FatCloseWorker(IN PDEVICE_OBJECT DeviceObject,
+               IN PVOID Context)
+{
+    FsRtlEnterFileSystem();
+
+    FatPendingClose((PVCB)Context);
+
+    FsRtlExitFileSystem();
+}
+
+VOID
+NTAPI
+FatQueueClose(IN PCLOSE_CONTEXT CloseContext,
+              IN BOOLEAN DelayClose)
+{
+    BOOLEAN RunWorker = FALSE;
+
+    /* Acquire the close lists mutex */
+    ExAcquireFastMutexUnsafe(&FatCloseQueueMutex);
+
+    /* Add it to the desired list */
+    if (DelayClose)
+    {
+        InsertTailList(&FatGlobalData.DelayedCloseList,
+                       &CloseContext->GlobalLinks);
+        InsertTailList(&CloseContext->Vcb->DelayedCloseList,
+                       &CloseContext->VcbLinks);
+
+        FatGlobalData.DelayedCloseCount++;
+
+        if (FatGlobalData.DelayedCloseCount > FatMaxDelayedCloseCount &&
+            !FatGlobalData.AsyncCloseActive)
+        {
+            FatGlobalData.AsyncCloseActive = TRUE;
+            RunWorker = TRUE;
+        }
+    }
+    else
+    {
+        InsertTailList(&FatGlobalData.AsyncCloseList,
+                       &CloseContext->GlobalLinks);
+        InsertTailList(&CloseContext->Vcb->AsyncCloseList,
+                       &CloseContext->VcbLinks);
+
+        FatGlobalData.AsyncCloseCount++;
+
+        if (!FatGlobalData.AsyncCloseActive)
+        {
+            FatGlobalData.AsyncCloseActive = TRUE;
+            RunWorker = TRUE;
+        }
+    }
+
+    /* Release the close lists mutex */
+    ExReleaseFastMutexUnsafe(&FatCloseQueueMutex);
+
+    if (RunWorker)
+        IoQueueWorkItem(FatGlobalData.FatCloseItem, FatCloseWorker, CriticalWorkQueue, NULL);
+}
+
+PCLOSE_CONTEXT
+NTAPI
+FatRemoveClose(PVCB Vcb OPTIONAL,
+               PVCB LastVcbHint OPTIONAL)
+{
+    PLIST_ENTRY Entry;
+    PCLOSE_CONTEXT CloseContext;
+    BOOLEAN IsWorker = FALSE;
+
+    /* Acquire the close lists mutex */
+    ExAcquireFastMutexUnsafe(&FatCloseQueueMutex);
+
+    if (!Vcb) IsWorker = TRUE;
+
+    if (Vcb == NULL && LastVcbHint != NULL)
+    {
+        // TODO: A very special case of overflowing the queue
+        UNIMPLEMENTED;
+    }
+
+    /* Usual processing from a worker thread */
+    if (!Vcb)
+    {
+TryToCloseAgain:
+
+        /* Is there anything in the async close list */
+        if (!IsListEmpty(&FatGlobalData.AsyncCloseList))
+        {
+            Entry = RemoveHeadList(&FatGlobalData.AsyncCloseList);
+            FatGlobalData.AsyncCloseCount--;
+
+            CloseContext = CONTAINING_RECORD(Entry,
+                                             CLOSE_CONTEXT,
+                                             GlobalLinks);
+
+            RemoveEntryList(&CloseContext->VcbLinks);
+        } else if (!IsListEmpty(&FatGlobalData.DelayedCloseList) &&
+                   (FatGlobalData.DelayedCloseCount > FatMaxDelayedCloseCount/2 ||
+                   FatGlobalData.ShutdownStarted))
+        {
+            /* In case of a shutdown or when delayed queue is filled at half - perform closing */
+            Entry = RemoveHeadList(&FatGlobalData.DelayedCloseList);
+            FatGlobalData.DelayedCloseCount--;
+
+            CloseContext = CONTAINING_RECORD(Entry,
+                                             CLOSE_CONTEXT,
+                                             GlobalLinks);
+            RemoveEntryList(&CloseContext->VcbLinks);
+        }
+        else
+        {
+            /* Nothing to close */
+            CloseContext = NULL;
+            if (IsWorker) FatGlobalData.AsyncCloseActive = FALSE;
+        }
+    }
+    else
+    {
+        if (!IsListEmpty(&Vcb->AsyncCloseList))
+        {
+            /* Is there anything in the async close list */
+            Entry = RemoveHeadList(&Vcb->AsyncCloseList);
+            FatGlobalData.AsyncCloseCount--;
+
+            CloseContext = CONTAINING_RECORD(Entry,
+                                             CLOSE_CONTEXT,
+                                             VcbLinks);
+
+            RemoveEntryList(&CloseContext->GlobalLinks);
+        }
+        else if (!IsListEmpty(&Vcb->DelayedCloseList))
+        {
+            /* Process delayed close list */
+            Entry = RemoveHeadList(&Vcb->DelayedCloseList);
+            FatGlobalData.DelayedCloseCount--;
+
+            CloseContext = CONTAINING_RECORD(Entry,
+                                             CLOSE_CONTEXT,
+                                             VcbLinks);
+
+            RemoveEntryList(&CloseContext->GlobalLinks);
+        }
+        else if (LastVcbHint)
+        {
+            /* Try again */
+            goto TryToCloseAgain;
+        }
+        else
+        {
+            /* Nothing to close */
+            CloseContext = NULL;
+        }
+    }
+
+    /* Release the close lists mutex */
+    ExReleaseFastMutexUnsafe(&FatCloseQueueMutex);
 
-    return STATUS_NOT_IMPLEMENTED;
+    return CloseContext;
 }
 
 /* EOF */
index db9a794..ce8cc90 100644 (file)
@@ -72,7 +72,9 @@ FatiOpenRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
 
         /* Increment counters */
         Dcb->OpenCount++;
+        Dcb->UncleanCount++;
         Vcb->OpenFileCount++;
+        if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
 
         /* Set success statuses */
         Iosb.Status = STATUS_SUCCESS;
@@ -186,7 +188,7 @@ FatiOverwriteFile(PFAT_IRP_CONTEXT IrpContext,
         CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
 
         // TODO: Actually truncate the file
-        DPRINT1("TODO: Actually truncate the file with a fullfat handle %x\n", Fcb->FatHandle);
+        DPRINT1("TODO: Actually truncate file '%wZ' with a fullfat handle %x\n", &Fcb->FullFileName, Fcb->FatHandle);
 
         /* Release the paging resource */
         ExReleaseResourceLite(Fcb->Header.PagingIoResource);
@@ -288,6 +290,12 @@ FatiOpenExistingDir(IN PFAT_IRP_CONTEXT IrpContext,
                      Fcb,
                      FatCreateCcb());
 
+    /* Increase counters */
+    Fcb->UncleanCount++;
+    Fcb->OpenCount++;
+    Vcb->OpenFileCount++;
+    if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
+
     Iosb.Status = STATUS_SUCCESS;
     Iosb.Information = FILE_OPENED;
 
@@ -319,6 +327,7 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext,
     PFCB Fcb;
     NTSTATUS Status;
     FF_FILE *FileHandle;
+    FF_ERROR FfError;
 
     /* Check for create file option and fail */
     if (CreateDisposition == FILE_CREATE)
@@ -341,20 +350,22 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext,
     }
 
     /* Open the file with FullFAT */
-    FileHandle = FF_Open(Vcb->Ioman, AnsiName.Buffer, FF_MODE_READ, NULL);
+    FileHandle = FF_Open(Vcb->Ioman, AnsiName.Buffer, FF_MODE_READ, &FfError);
 
     if (!FileHandle)
     {
+        DPRINT1("Failed to open file '%s', error %ld\n", AnsiName.Buffer, FfError);
         Iosb.Status = STATUS_OBJECT_NAME_NOT_FOUND; // FIXME: A shortcut for now
         return Iosb;
     }
+    DPRINT1("Succeeded opening file '%s'\n", AnsiName.Buffer);
 
     /* Create a new FCB for this file */
     Fcb = FatCreateFcb(IrpContext, Vcb, ParentDcb, FileHandle);
 
     // TODO: Check if overwrite is needed
 
-    // This is usual file open branch, without overwriting!
+    // TODO: This is usual file open branch, without overwriting!
     /* Set context and section object pointers */
     FatSetFileObject(FileObject,
                      UserFileOpen,
@@ -365,6 +376,13 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext,
     Iosb.Status = STATUS_SUCCESS;
     Iosb.Information = FILE_OPENED;
 
+
+    /* Increase counters */
+    Fcb->UncleanCount++;
+    Fcb->OpenCount++;
+    if (FlagOn(FileObject->Flags, FO_NO_INTERMEDIATE_BUFFERING)) Fcb->NonCachedUncleanCount++;
+    if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
+
     return Iosb;
 }
 
@@ -397,7 +415,7 @@ FatiOpenVolume(IN PFAT_IRP_CONTEXT IrpContext,
         // and opened handles count is not 0
         //if (!FlagOn(ShareAccess, FILE_SHARE_READ)
 
-        DPRINT1("Exclusive voume open\n");
+        DPRINT1("Exclusive volume open\n");
 
         // TODO: Flush the volume
         VolumeFlushed = TRUE;
@@ -450,6 +468,7 @@ FatiOpenVolume(IN PFAT_IRP_CONTEXT IrpContext,
     /* Increase direct open count */
     Vcb->DirectOpenCount++;
     Vcb->OpenFileCount++;
+    if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
 
     /* Set no buffering flag */
     FileObject->Flags |= FO_NO_INTERMEDIATE_BUFFERING;
@@ -720,7 +739,7 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext,
         /* Set parent DCB */
         ParentDcb = RelatedDcb;
 
-        DPRINT1("Opening file '%wZ' relatively to '%wZ'\n", &FileName, &ParentDcb->FullFileName);
+        DPRINT("Opening file '%wZ' relatively to '%wZ'\n", &FileName, &ParentDcb->FullFileName);
     }
     else
     {
@@ -1137,6 +1156,12 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext,
                                 DeleteOnClose,
                                 OpenedAsDos);
 
+    /* In case of success set cache supported flag */
+    if (NT_SUCCESS(Iosb.Status) && !NoIntermediateBuffering)
+    {
+        SetFlag(FileObject->Flags, FO_CACHE_SUPPORTED);
+    }
+
     Irp->IoStatus.Information = Iosb.Information;
 
     /* Unlock VCB */
index ca04e84..9919715 100644 (file)
@@ -82,9 +82,6 @@ FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
     ExInitializeFastMutex(&Dcb->HeaderMutex);
     FsRtlSetupAdvancedHeader(&Dcb->Header, &Dcb->HeaderMutex);
 
-    /* Initialize MCB */
-    FsRtlInitializeLargeMcb(&Dcb->Mcb, NonPagedPool);
-
     /* Set up first cluster field depending on FAT type */
     if (TRUE/*FatIsFat32(Vcb)*/)
     {
@@ -114,13 +111,6 @@ FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
 #endif
         UNIMPLEMENTED;
     }
-
-    /* Initialize free dirent bitmap */
-    RtlInitializeBitMap(&Dcb->Dcb.FreeBitmap, NULL, 0);
-
-    /* Fill the dirent bitmap */
-    DPRINT1("Filling the free dirent bitmap is missing\n");
-    //FatCheckFreeDirentBitmap( IrpContext, Dcb );
 }
 
 PFCB
@@ -191,9 +181,98 @@ FatiOpenExistingDcb(IN PFAT_IRP_CONTEXT IrpContext,
                     IN BOOLEAN DeleteOnClose)
 {
     IO_STATUS_BLOCK Iosb = {{0}};
+    PCCB Ccb;
+
+    /* Exclusively lock this FCB */
+    FatAcquireExclusiveFcb(IrpContext, Dcb);
+
+    /* Check if it's a delete-on-close of a root DCB */
+    if (FatNodeType(Dcb) == FAT_NTC_ROOT_DCB && DeleteOnClose)
+    {
+        Iosb.Status = STATUS_CANNOT_DELETE;
+
+        /* Release the lock and return */
+        FatReleaseFcb(IrpContext, Dcb);
+        return Iosb;
+    }
+
+    /*if (NoEaKnowledge && NodeType(Dcb) != FAT_NTC_ROOT_DCB &&
+        !FatIsFat32(Vcb))
+    {
+        UNIMPLEMENTED;
+    }*/
+
+    /* Check the create disposition and desired access */
+    if ((CreateDisposition != FILE_OPEN) &&
+        (CreateDisposition != FILE_OPEN_IF))
+    {
+        Iosb.Status = STATUS_OBJECT_NAME_COLLISION;
+
+        /* Release the lock and return */
+        FatReleaseFcb(IrpContext, Dcb);
+        return Iosb;
+    }
+
+#if 0
+    if (!FatCheckFileAccess(IrpContext,
+                            Dcb->DirentFatFlags,
+                            DesiredAccess))
+    {
+        Iosb.Status = STATUS_ACCESS_DENIED;
+        try_return( Iosb );
+    }
+#endif
+
+    /* If it's already opened - check share access */
+    if (Dcb->OpenCount > 0)
+    {
+        Iosb.Status = IoCheckShareAccess(*DesiredAccess,
+                                         ShareAccess,
+                                         FileObject,
+                                         &Dcb->ShareAccess,
+                                         TRUE);
+
+        if (!NT_SUCCESS(Iosb.Status))
+        {
+            /* Release the lock and return */
+            FatReleaseFcb(IrpContext, Dcb);
+            return Iosb;
+        }
+    }
+    else
+    {
+        IoSetShareAccess(*DesiredAccess,
+                         ShareAccess,
+                         FileObject,
+                         &Dcb->ShareAccess);
+    }
+
+    /* Set the file object */
+    Ccb = FatCreateCcb(IrpContext);
+    FatSetFileObject(FileObject,
+                     UserDirectoryOpen,
+                     Dcb,
+                     Ccb);
+
+    /* Increase counters */
+    Dcb->UncleanCount++;
+    Dcb->OpenCount++;
+    Vcb->OpenFileCount++;
+    if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
+
+    /* Set delete on close */
+    if (DeleteOnClose)
+        SetFlag(Ccb->Flags, CCB_DELETE_ON_CLOSE);
+
+    /* Clear delay close flag */
+    ClearFlag(Dcb->State, FCB_STATE_DELAY_CLOSE);
+
+    /* That's it */
+    Iosb.Status = STATUS_SUCCESS;
+    Iosb.Information = FILE_OPENED;
 
-    Iosb.Status = STATUS_NOT_IMPLEMENTED;
-    UNIMPLEMENTED;
+    /* Release the lock */
+    FatReleaseFcb(IrpContext, Dcb);
 
     return Iosb;
 }
index 64736af..c469437 100644 (file)
@@ -14,6 +14,7 @@
 /* GLOBALS ******************************************************************/
 
 FAT_GLOBAL_DATA FatGlobalData;
+FAST_MUTEX FatCloseQueueMutex;
 
 /* FUNCTIONS ****************************************************************/
 
@@ -42,6 +43,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     RtlZeroMemory(&FatGlobalData, sizeof(FAT_GLOBAL_DATA));
     FatGlobalData.DriverObject = DriverObject;
     FatGlobalData.DiskDeviceObject = DeviceObject;
+    FatGlobalData.SystemProcess = PsGetCurrentProcess();
 
     /* Fill major function handlers */
     DriverObject->MajorFunction[IRP_MJ_CLOSE] = FatClose;
@@ -108,6 +110,12 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     /* Initialize synchronization resource for the global data */
     ExInitializeResourceLite(&FatGlobalData.Resource);
 
+    /* Initialize queued close stuff */
+    InitializeListHead(&FatGlobalData.AsyncCloseList);
+    InitializeListHead(&FatGlobalData.DelayedCloseList);
+    FatGlobalData.FatCloseItem = IoAllocateWorkItem(DeviceObject);
+    ExInitializeFastMutex(&FatCloseQueueMutex);
+
     /* Initialize global VCB list */
     InitializeListHead(&FatGlobalData.VcbListHead);
 
@@ -317,7 +325,7 @@ FatDecodeFileObject(IN PFILE_OBJECT FileObject,
 
             TypeOfOpen = (*Ccb == NULL ? DirectoryFile : UserDirectoryOpen);
 
-            DPRINT1("Referencing a directory: %wZ\n", &(*FcbOrDcb)->FullFileName);
+            DPRINT("Referencing a directory: %wZ\n", &(*FcbOrDcb)->FullFileName);
             break;
 
         /* File */
@@ -510,4 +518,45 @@ FatMapUserBuffer(PIRP Irp)
         return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);
 }
 
+BOOLEAN
+NTAPI
+FatIsTopLevelIrp(IN PIRP Irp)
+{
+    if (!IoGetTopLevelIrp())
+    {
+        IoSetTopLevelIrp(Irp);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+VOID
+NTAPI
+FatNotifyReportChange(IN PFAT_IRP_CONTEXT IrpContext,
+                      IN PVCB Vcb,
+                      IN PFCB Fcb,
+                      IN ULONG Filter,
+                      IN ULONG Action)
+{
+    if (Fcb->FullFileName.Buffer == NULL)
+        FatSetFullFileNameInFcb(IrpContext, Fcb);
+
+    ASSERT(Fcb->FullFileName.Length != 0 );
+    ASSERT(Fcb->FileNameLength != 0 );
+    ASSERT(Fcb->FullFileName.Length > Fcb->FileNameLength );
+    ASSERT(Fcb->FullFileName.Buffer[(Fcb->FullFileName.Length - Fcb->FileNameLength)/sizeof(WCHAR) - 1] == L'\\' );
+
+    FsRtlNotifyFullReportChange(Vcb->NotifySync,
+                                &Vcb->NotifyList,
+                                (PSTRING)&Fcb->FullFileName,
+                                (USHORT)(Fcb->FullFileName.Length -
+                                         Fcb->FileNameLength),
+                                NULL,
+                                NULL,
+                                Filter,
+                                Action,
+                                NULL);
+}
+
 /* EOF */
index a227a91..fbbf272 100644 (file)
@@ -16,6 +16,7 @@
 #define TAG_FCB  'BCFV'
 #define TAG_IRP  'PRIV'
 #define TAG_VFAT 'TAFV'
+#define TAG_FSD_CLOSE_CONTEXT 'CLCV'
 
 
 /* Global resource acquire/release */
     ExReleaseResourceLite(&(FatGlobalData.Resource)); \
 }
 
+#define FatIsFastIoPossible(FCB) ((BOOLEAN)                                                \
+    (((FCB)->Condition != FcbGood || !FsRtlOplockIsFastIoPossible(&(FCB)->Fcb.Oplock)) ?   \
+        FastIoIsNotPossible                                                                \
+    :                                                                                      \
+        (!FsRtlAreThereCurrentFileLocks(&(FCB)->Fcb.Lock) &&                               \
+         ((FCB)->OutstandingAsyncWrites == 0) &&                                           \
+         !FlagOn((FCB)->Vcb->State, VCB_STATE_FLAG_WRITE_PROTECTED) ?                      \
+            FastIoIsPossible                                                               \
+        :                                                                                  \
+            FastIoIsQuestionable                                                           \
+        )                                                                                  \
+    )                                                                                      \
+)
+
+#define IsFileObjectReadOnly(FO) (!((FO)->WriteAccess | (FO)->DeleteAccess))
+#define IsFileDeleted(FCB) (FlagOn((FCB)->State, FCB_STATE_DELETE_ON_CLOSE) && ((FCB)->UncleanCount == 0))
+
+BOOLEAN
+FORCEINLINE
+FatIsIoRangeValid(IN LARGE_INTEGER Start, IN ULONG Length)
+{
+    /* Check if it's more than 32bits, or if the length causes 32bit overflow.
+       FAT-specific! */
+
+    return !(Start.HighPart || Start.LowPart + Length < Start.LowPart);
+}
+
+
 NTSYSAPI
 NTSTATUS
 NTAPI
@@ -67,6 +96,12 @@ FatReadStreamFile(PVCB Vcb,
                   PBCB *Bcb,
                   PVOID *Buffer);
 
+BOOLEAN
+NTAPI
+FatCheckForDismount(IN PFAT_IRP_CONTEXT IrpContext,
+                    PVCB Vcb,
+                    IN BOOLEAN Force);
+
 /*  -----------------------------------------------------------  dir.c  */
 
 NTSTATUS NTAPI
@@ -149,6 +184,8 @@ FatNoopRelease(IN PVOID Context);
 
 /* ---------------------------------------------------------  fastfat.c */
 
+extern FAST_MUTEX FatCloseQueueMutex;
+
 PFAT_IRP_CONTEXT NTAPI
 FatBuildIrpContext(PIRP Irp, BOOLEAN CanWait);
 
@@ -205,6 +242,16 @@ FatSetFileObject(PFILE_OBJECT FileObject,
 PVOID FASTCALL
 FatMapUserBuffer(PIRP Irp);
 
+BOOLEAN NTAPI
+FatIsTopLevelIrp(IN PIRP Irp);
+
+VOID NTAPI
+FatNotifyReportChange(IN PFAT_IRP_CONTEXT IrpContext,
+                      IN PVCB Vcb,
+                      IN PFCB Fcb,
+                      IN ULONG Filter,
+                      IN ULONG Action);
+
 /* --------------------------------------------------------- fullfat.c */
 
 FF_T_SINT32
@@ -284,6 +331,10 @@ FatCreateFcb(
     IN PFCB ParentDcb,
     IN FF_FILE *FileHandle);
 
+VOID NTAPI
+FatDeleteFcb(IN PFAT_IRP_CONTEXT IrpContext,
+             IN PFCB Fcb);
+
 IO_STATUS_BLOCK NTAPI
 FatiOpenExistingFcb(IN PFAT_IRP_CONTEXT IrpContext,
                     IN PFILE_OBJECT FileObject,
@@ -319,6 +370,10 @@ FatRemoveNames(IN PFAT_IRP_CONTEXT IrpContext,
 PCCB NTAPI
 FatCreateCcb();
 
+VOID NTAPI
+FatDeleteCcb(IN PFAT_IRP_CONTEXT IrpContext,
+             IN PCCB Ccb);
+
 VOID NTAPI
 FatSetFullNameInFcb(PFCB Fcb,
                     PUNICODE_STRING Name);
index 06b601c..a6ac9fa 100644 (file)
@@ -163,6 +163,10 @@ FatInitializeVcb(IN PFAT_IRP_CONTEXT IrpContext,
     /* Initialize VCB's resource */
     ExInitializeResourceLite(&Vcb->Resource);
 
+    /* Initialize close queue lists */
+    InitializeListHead(&Vcb->AsyncCloseList);
+    InitializeListHead(&Vcb->DelayedCloseList);
+
     /* Initialize CC */
     CcInitializeCacheMap(Vcb->StreamFileObject,
                          (PCC_FILE_SIZES)&Vcb->Header.AllocationSize,
@@ -201,6 +205,10 @@ FatInitializeVcb(IN PFAT_IRP_CONTEXT IrpContext,
         goto FatInitializeVcbCleanup;
     }
 
+    /* Increase internal / residual open counter */
+    InterlockedIncrement((PLONG)&(Vcb->InternalOpenCount));
+    InterlockedIncrement((PLONG)&(Vcb->ResidualOpenCount));
+
     /* Set up notifications */
     FsRtlNotifyInitializeSync(&Vcb->NotifySync);
     InitializeListHead(&Vcb->NotifyList);
@@ -239,6 +247,9 @@ FatUninitializeVcb(IN PVCB Vcb)
         Vcb->StreamFileObject = NULL;
     }
 
+    /* Free ContextClose if it's not freed up already */
+    if (Vcb->CloseContext) ExFreePool(Vcb->CloseContext);
+
     /* Free notifications stuff */
     FsRtlNotifyUninitializeSync(&Vcb->NotifySync);
 
index dff04c5..2ca2f54 100644 (file)
@@ -14,15 +14,17 @@ typedef FAT_NODE_TYPE *PFAT_NODE_TYPE;
 #define FatNodeType(Ptr) (*((PFAT_NODE_TYPE)(Ptr)))
 
 /* Node type codes */
-#define FAT_NTC_VCB      (CSHORT) '00VF'
-#define FAT_NTC_FCB      (CSHORT)   'CF'
-#define FAT_NTC_DCB      (CSHORT)   'DF'
-#define FAT_NTC_ROOT_DCB (CSHORT)  'RFD'
-#define FAT_NTC_CCB      (CSHORT)  'BCC'
+#define FAT_NTC_VCB         (CSHORT) '00VF'
+#define FAT_NTC_FCB         (CSHORT)   'CF'
+#define FAT_NTC_DCB         (CSHORT)   'DF'
+#define FAT_NTC_ROOT_DCB    (CSHORT)  'RFD'
+#define FAT_NTC_CCB         (CSHORT)  'BCC'
+#define FAT_NTC_IRP_CONTEXT (CSHORT)  'PRI'
 
 typedef struct _FAT_GLOBAL_DATA
 {
     ERESOURCE Resource;
+    PEPROCESS SystemProcess;
     PDRIVER_OBJECT DriverObject;
     PDEVICE_OBJECT DiskDeviceObject;
     LIST_ENTRY VcbListHead;
@@ -33,9 +35,20 @@ typedef struct _FAT_GLOBAL_DATA
     CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
     CACHE_MANAGER_CALLBACKS CacheMgrNoopCallbacks;
     BOOLEAN Win31FileSystem;
+    BOOLEAN ShutdownStarted;
     /* Jan 1, 1980 System Time */
     LARGE_INTEGER DefaultFileTime;
 
+    /* Queued close */
+    ULONG AsyncCloseCount;
+    ULONG DelayedCloseCount;
+    LIST_ENTRY AsyncCloseList;
+    LIST_ENTRY DelayedCloseList;
+    PIO_WORKITEM FatCloseItem;
+
+    /* Various flags */
+    BOOLEAN AsyncCloseActive;
+
     /* FullFAT integration */
     FF_IOMAN *Ioman;
     FF_ERROR FF_Error;
@@ -82,6 +95,10 @@ typedef struct _FAT_PAGE_CONTEXT
 
 typedef struct _FAT_IRP_CONTEXT
 {
+    /*  Type and size of this record (must be FAT_NTC_IRP_CONTEXT) */
+    FAT_NODE_TYPE NodeTypeCode;
+    CSHORT NodeByteSize;
+
     PIRP Irp;
     PDEVICE_OBJECT DeviceObject;
     UCHAR MajorFunction;
@@ -132,10 +149,15 @@ typedef struct _FAT_METHODS {
     PFAT_SETFAT_VALUE_RUN_ROUTINE SetValueRun;
 } FAT_METHODS, *PFAT_METHODS;
 
-#define VCB_STATE_FLAG_LOCKED        0x01
-#define VCB_STATE_FLAG_DIRTY         0x02
-#define VCB_STATE_MOUNTED_DIRTY      0x04
-#define VCB_STATE_CREATE_IN_PROGRESS 0x08
+#define VCB_STATE_FLAG_LOCKED               0x001
+#define VCB_STATE_FLAG_DIRTY                0x002
+#define VCB_STATE_MOUNTED_DIRTY             0x004
+#define VCB_STATE_CREATE_IN_PROGRESS        0x008
+#define VCB_STATE_FLAG_CLOSE_IN_PROGRESS    0x010
+#define VCB_STATE_FLAG_DELETED_FCB          0x020
+#define VCB_STATE_FLAG_DISMOUNT_IN_PROGRESS 0x040
+#define VCB_STATE_FLAG_DEFERRED_FLUSH       0x080
+#define VCB_STATE_FLAG_WRITE_PROTECTED      0x100
 
 typedef enum _VCB_CONDITION
 {
@@ -158,10 +180,13 @@ typedef struct _VCB
     ULONG State;
     VCB_CONDITION Condition;
     ERESOURCE Resource;
+    struct _CLOSE_CONTEXT *CloseContext;
+    LIST_ENTRY AsyncCloseList;
+    LIST_ENTRY DelayedCloseList;
 
     /* Direct volume access */
-    ULONG DirectOpenCount;
     SHARE_ACCESS ShareAccess;
+    PFILE_OBJECT FileObjectWithVcbLocked;
 
     /* Notifications support */
     PNOTIFY_SYNC NotifySync;
@@ -186,8 +211,13 @@ typedef struct _VCB
     struct _FCB *RootDcb;
 
     /* Counters */
-    ULONG MediaChangeCount;
+    ULONG DirectOpenCount;
     ULONG OpenFileCount;
+    ULONG ReadOnlyCount;
+    ULONG InternalOpenCount;
+    ULONG ResidualOpenCount;
+    ULONG DirectAccessOpenCount;
+    ULONG MediaChangeCount;
 
     /* FullFAT integration */
     FF_IOMAN *Ioman;
@@ -221,6 +251,18 @@ typedef struct _VOLUME_DEVICE_OBJECT
         VCB Vcb; /* Must be the last entry! */
     };
 } VOLUME_DEVICE_OBJECT, *PVOLUME_DEVICE_OBJECT;
+
+typedef enum _TYPE_OF_OPEN
+{
+    UnopenedFileObject,
+    UserFileOpen,
+    UserDirectoryOpen,
+    UserVolumeOpen,
+    VirtualVolumeFile,
+    DirectoryFile,
+    EaFile
+} TYPE_OF_OPEN;
+
 //
 //  Short name always exists in FAT
 //
@@ -252,6 +294,7 @@ typedef enum _FCB_CONDITION
 #define FCB_STATE_PAGEFILE          0x04
 #define FCB_STATE_DELAY_CLOSE       0x08
 #define FCB_STATE_TRUNCATE_ON_CLOSE 0x10
+#define FCB_STATE_DELETE_ON_CLOSE   0x20
 
 typedef struct _FCB
 {
@@ -281,8 +324,6 @@ typedef struct _FCB
     FCB_CONDITION Condition;
     /* Share access */
     SHARE_ACCESS ShareAccess;
-    /* Mcb mapping Vbo->Lbo */
-    LARGE_MCB Mcb;
     ULONG FirstCluster;
     /* Links into FCB Tree */
     FCB_NAME_LINK ShortName;
@@ -307,6 +348,8 @@ typedef struct _FCB
     PKEVENT OutstandingAsyncEvent;
     /* Counters */
     ULONG OpenCount;
+    ULONG UncleanCount;
+    ULONG NonCachedUncleanCount;
     union
     {
         struct
@@ -318,12 +361,11 @@ typedef struct _FCB
 
         struct
         {
-            /* A list of all FCBs/DCBs opened under this DCB */
-            LIST_ENTRY ParentDcbList;
+            LIST_ENTRY ParentDcbList; /* A list of all FCBs/DCBs opened under this DCB */
+            ULONG DirectoryFileOpenCount; /* Sector-based access to the dir */
+            PFILE_OBJECT DirectoryFile;
             /* Directory data stream (just handy to have it). */
-            PFILE_OBJECT StreamFileObject;
-            /* Bitmap to search for free dirents. */
-            RTL_BITMAP FreeBitmap;
+            //PFILE_OBJECT StreamFileObject;
             /* Names */
             PRTL_SPLAY_LINKS SplayLinksAnsi;
             PRTL_SPLAY_LINKS SplayLinksUnicode;
@@ -368,6 +410,17 @@ typedef struct _FAT_FIND_DIRENT_CONTEXT
     BOOLEAN Valid8dot3Name;
 } FAT_FIND_DIRENT_CONTEXT, *PFAT_FIND_DIRENT_CONTEXT;
 
+typedef struct _CLOSE_CONTEXT
+{
+    LIST_ENTRY GlobalLinks;
+    LIST_ENTRY VcbLinks;
+
+    PVCB Vcb;
+    PFCB Fcb;
+    TYPE_OF_OPEN TypeOfOpen;
+    BOOLEAN Free;
+} CLOSE_CONTEXT, *PCLOSE_CONTEXT;
+
 typedef struct _CCB
 {
     CSHORT NodeTypeCode;
@@ -377,19 +430,9 @@ typedef struct _CCB
     ULONG Entry;
     UNICODE_STRING SearchPattern;
     UCHAR Flags;
+    CLOSE_CONTEXT CloseContext;
 } CCB, *PCCB;
 
-typedef enum _TYPE_OF_OPEN
-{
-    UnopenedFileObject,
-    UserFileOpen,
-    UserDirectoryOpen,
-    UserVolumeOpen,
-    VirtualVolumeFile,
-    DirectoryFile,
-    EaFile
-} TYPE_OF_OPEN;
-
 typedef enum _FILE_TIME_INDEX
 {
     FileCreationTime = 0,
@@ -401,5 +444,10 @@ typedef enum _FILE_TIME_INDEX
 #define CCB_SEARCH_RETURN_SINGLE_ENTRY      0x01
 #define CCB_SEARCH_PATTERN_LEGAL_8DOT3      0x02
 #define CCB_SEARCH_PATTERN_HAS_WILD_CARD    0x04
-#define CCB_DASD_IO                         0x10
+#define CCB_DASD_IO                         0x08
+#define CCB_READ_ONLY                       0x10
+#define CCB_DELETE_ON_CLOSE                 0x20
+#define CCB_COMPLETE_DISMOUNT               0x40
+#define CCB_CLOSE_CONTEXT                   0x80
+
 extern FAT_GLOBAL_DATA FatGlobalData;
index cb02d53..eeb12dd 100644 (file)
@@ -149,12 +149,74 @@ FatCreateFcb(IN PFAT_IRP_CONTEXT IrpContext,
     Fcb->Header.ValidDataLength.LowPart = FileHandle->Filesize;
     Fcb->FatHandle = FileHandle;
 
+    /* Initialize locks */
+    FsRtlInitializeFileLock(&Fcb->Fcb.Lock, NULL, NULL);
+    FsRtlInitializeOplock(&Fcb->Fcb.Oplock);
+
     /* Set names */
     FatSetFcbNames(IrpContext, Fcb);
 
     return Fcb;
 }
 
+VOID
+NTAPI
+FatDeleteFcb(IN PFAT_IRP_CONTEXT IrpContext,
+             IN PFCB Fcb)
+{
+    DPRINT("FatDeleteFcb %p\n", Fcb);
+
+    if (Fcb->OpenCount != 0)
+    {
+        DPRINT1("Trying to delete FCB with OpenCount %d\n", Fcb->OpenCount);
+        ASSERT(FALSE);
+    }
+
+    if ((Fcb->Header.NodeTypeCode == FAT_NTC_DCB) ||
+        (Fcb->Header.NodeTypeCode == FAT_NTC_ROOT_DCB))
+    {
+        /* Make sure it's a valid deletion */
+        ASSERT(Fcb->Dcb.DirectoryFileOpenCount == 0);
+        ASSERT(IsListEmpty(&Fcb->Dcb.ParentDcbList));
+        ASSERT(Fcb->Dcb.DirectoryFile == NULL);
+    }
+    else
+    {
+        /* Free locks */
+        FsRtlUninitializeFileLock(&Fcb->Fcb.Lock);
+        FsRtlUninitializeOplock(&Fcb->Fcb.Oplock);
+    }
+
+    /* Release any possible filter contexts */
+    FsRtlTeardownPerStreamContexts(&Fcb->Header);
+
+    /* Remove from parents queue */
+    if (Fcb->Header.NodeTypeCode != FAT_NTC_ROOT_DCB)
+    {
+        RemoveEntryList(&(Fcb->ParentDcbLinks));
+    }
+
+    /* Free FullFAT handle */
+    if (Fcb->FatHandle) FF_Close(Fcb->FatHandle);
+
+    /* Remove from the splay table */
+    if (FlagOn(Fcb->State, FCB_STATE_HAS_NAMES))
+        FatRemoveNames(IrpContext, Fcb);
+
+    /* Free file name buffers */
+    if (Fcb->Header.NodeTypeCode != FAT_NTC_ROOT_DCB)
+    {
+        if (Fcb->FullFileName.Buffer)
+            ExFreePool(Fcb->FullFileName.Buffer);
+    }
+
+    if (Fcb->ExactCaseLongName.Buffer)
+        ExFreePool(Fcb->ExactCaseLongName.Buffer);
+
+    /* Free this FCB, finally */
+    ExFreePool(Fcb);
+}
+
 PCCB
 NTAPI
 FatCreateCcb()
@@ -172,6 +234,17 @@ FatCreateCcb()
     return Ccb;
 }
 
+VOID
+NTAPI
+FatDeleteCcb(IN PFAT_IRP_CONTEXT IrpContext,
+             IN PCCB Ccb)
+{
+    // TODO: Deallocate CCB strings, if any
+
+    /* Free the CCB */
+    ExFreePool(Ccb);
+}
+
 IO_STATUS_BLOCK
 NTAPI
 FatiOpenExistingFcb(IN PFAT_IRP_CONTEXT IrpContext,
@@ -443,8 +516,11 @@ SuccComplete:
         ClearFlag(Fcb->State, FCB_STATE_DELAY_CLOSE);
 
         /* Increase counters */
+        Fcb->UncleanCount++;
         Fcb->OpenCount++;
         Vcb->OpenFileCount++;
+        if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++;
+        if (FlagOn(FileObject->Flags, FO_NO_INTERMEDIATE_BUFFERING)) Fcb->NonCachedUncleanCount++;
 
         // TODO: Handle DeleteOnClose and OpenedAsDos by storing those flags in CCB
     }
index d162aba..7e95834 100644 (file)
@@ -263,11 +263,7 @@ FatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     FsRtlEnterFileSystem();
 
     /* Set Top Level IRP if not set */
-    if (IoGetTopLevelIrp() == NULL)
-    {
-        IoSetTopLevelIrp(Irp);
-        TopLevel = TRUE;
-    }
+    TopLevel = FatIsTopLevelIrp(Irp);
 
     /* Build an irp context */
     IrpContext = FatBuildIrpContext(Irp, CanWait);
@@ -284,12 +280,394 @@ FatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     return Status;
 }
 
+NTSTATUS
+NTAPI
+FatSetEndOfFileInfo(IN PFAT_IRP_CONTEXT IrpContext,
+                    IN PIRP Irp,
+                    IN PFILE_OBJECT FileObject,
+                    IN PVCB Vcb,
+                    IN PFCB Fcb)
+{
+    PFILE_END_OF_FILE_INFORMATION Buffer;
+    ULONG NewFileSize;
+    ULONG InitialFileSize;
+    ULONG InitialValidDataLength;
+    //ULONG InitialValidDataToDisk;
+    BOOLEAN CacheMapInitialized = FALSE;
+    BOOLEAN ResourceAcquired = FALSE;
+    NTSTATUS Status;
+
+    Buffer = Irp->AssociatedIrp.SystemBuffer;
+
+    if (FatNodeType(Fcb) != FAT_NTC_FCB)
+    {
+        /* Trying to change size of a dir */
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        return Status;
+    }
+
+    /* Validate new size */
+    if (!FatIsIoRangeValid(Buffer->EndOfFile, 0))
+    {
+        Status = STATUS_DISK_FULL;
+        return Status;
+    }
+
+    NewFileSize = Buffer->EndOfFile.LowPart;
+
+    /* Lookup allocation size if needed */
+    if (Fcb->Header.AllocationSize.QuadPart == (LONGLONG)-1)
+        UNIMPLEMENTED;//FatLookupFileAllocationSize(IrpContext, Fcb);
+
+    /* Cache the file if there is a data section */
+    if (FileObject->SectionObjectPointer->DataSectionObject &&
+        (FileObject->SectionObjectPointer->SharedCacheMap == NULL) &&
+        !FlagOn(Irp->Flags, IRP_PAGING_IO))
+    {
+        if (FlagOn(FileObject->Flags, FO_CLEANUP_COMPLETE))
+        {
+            /* This is a really weird condition */
+            UNIMPLEMENTED;
+            //Raise(STATUS_FILE_CLOSED);
+        }
+
+        /*  Initialize the cache map */
+        CcInitializeCacheMap(FileObject,
+                             (PCC_FILE_SIZES)&Fcb->Header.AllocationSize,
+                             FALSE,
+                             &FatGlobalData.CacheMgrCallbacks,
+                             Fcb);
+
+        CacheMapInitialized = TRUE;
+    }
+
+    /* Lazy write case */
+    if (IoGetCurrentIrpStackLocation(Irp)->Parameters.SetFile.AdvanceOnly)
+    {
+        if (!IsFileDeleted(Fcb) &&
+            (Fcb->Condition == FcbGood))
+        {
+            /* Clamp the new file size */
+            if (NewFileSize >= Fcb->Header.FileSize.LowPart)
+                NewFileSize = Fcb->Header.FileSize.LowPart;
+
+            ASSERT(NewFileSize <= Fcb->Header.AllocationSize.LowPart);
+
+            /* Never reduce the file size here! */
+
+            // TODO: Actually change file size
+            DPRINT1("Actually changing file size is missing\n");
+
+            /* Notify about file size change */
+            FatNotifyReportChange(IrpContext,
+                                  Vcb,
+                                  Fcb,
+                                  FILE_NOTIFY_CHANGE_SIZE,
+                                  FILE_ACTION_MODIFIED);
+        }
+        else
+        {
+            DPRINT1("Cannot set size on deleted file\n");
+        }
+
+        Status = STATUS_SUCCESS;
+        return Status;
+    }
+
+    if ( NewFileSize > Fcb->Header.AllocationSize.LowPart )
+    {
+        // TODO: Increase file size
+        DPRINT1("Actually changing file size is missing\n");
+    }
+
+    if (Fcb->Header.FileSize.LowPart != NewFileSize)
+    {
+        if (NewFileSize < Fcb->Header.FileSize.LowPart)
+        {
+            if (!MmCanFileBeTruncated(FileObject->SectionObjectPointer,
+                                      &Buffer->EndOfFile))
+            {
+                Status = STATUS_USER_MAPPED_FILE;
+
+                /* Free up resources if necessary */
+                if (CacheMapInitialized)
+                    CcUninitializeCacheMap(FileObject, NULL, NULL);
+
+                return Status;
+            }
+
+            ResourceAcquired = ExAcquireResourceExclusiveLite(Fcb->Header.PagingIoResource, TRUE);
+        }
+
+        /* Set new file sizes */
+        InitialFileSize = Fcb->Header.FileSize.LowPart;
+        InitialValidDataLength = Fcb->Header.ValidDataLength.LowPart;
+        //InitialValidDataToDisk = Fcb->ValidDataToDisk;
+
+        Fcb->Header.FileSize.LowPart = NewFileSize;
+
+        /* Adjust valid data length if new size is less than that */
+        if (Fcb->Header.ValidDataLength.LowPart > NewFileSize)
+            Fcb->Header.ValidDataLength.LowPart = NewFileSize;
+
+        //if (Fcb->ValidDataToDisk > NewFileSize)
+        //    Fcb->ValidDataToDisk = NewFileSize;
+
+        DPRINT1("New file size is 0x%08lx\n", NewFileSize);
+
+        /* Update cache mapping */
+        CcSetFileSizes(FileObject,
+                       (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
+
+        /* Notify about size change */
+        FatNotifyReportChange(IrpContext,
+                              Vcb,
+                              Fcb,
+                              FILE_NOTIFY_CHANGE_SIZE,
+                              FILE_ACTION_MODIFIED);
+
+        /* Set truncate on close flag */
+        SetFlag(Fcb->State, FCB_STATE_TRUNCATE_ON_CLOSE);
+    }
+
+    /* Set modified flag */
+    FileObject->Flags |= FO_FILE_MODIFIED;
+
+    /* Free up resources if necessary */
+    if (CacheMapInitialized)
+        CcUninitializeCacheMap(FileObject, NULL, NULL);
+
+    if (ResourceAcquired)
+        ExReleaseResourceLite(Fcb->Header.PagingIoResource);
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+FatiSetInformation(IN PFAT_IRP_CONTEXT IrpContext,
+                   IN PIRP Irp)
+{
+    PFILE_OBJECT FileObject;
+    PIO_STACK_LOCATION IrpSp;
+    FILE_INFORMATION_CLASS InfoClass;
+    TYPE_OF_OPEN TypeOfOpen;
+    PVCB Vcb;
+    PFCB Fcb;
+    PCCB Ccb;
+    LONG Length;
+    PVOID Buffer;
+    NTSTATUS Status = STATUS_SUCCESS;
+    BOOLEAN VcbAcquired = FALSE, FcbAcquired = FALSE;
+
+    /* Get IRP stack location */
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+    /* Get the file object */
+    FileObject = IrpSp->FileObject;
+
+    /* Copy variables to something with shorter names */
+    InfoClass = IrpSp->Parameters.SetFile.FileInformationClass;
+    Length = IrpSp->Parameters.SetFile.Length;
+    Buffer = Irp->AssociatedIrp.SystemBuffer;
+
+    DPRINT("FatiSetInformation\n", 0);
+    DPRINT("\tIrp                  = %08lx\n", Irp);
+    DPRINT("\tLength               = %08lx\n", Length);
+    DPRINT("\tFileInformationClass = %08lx\n", InfoClass);
+    DPRINT("\tFileObject           = %08lx\n", IrpSp->Parameters.SetFile.FileObject);
+    DPRINT("\tBuffer               = %08lx\n", Buffer);
+
+    TypeOfOpen = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
+
+    DPRINT("Vcb %p, Fcb %p, Ccb %p, open type %d\n", Vcb, Fcb, Ccb, TypeOfOpen);
+
+    switch (TypeOfOpen)
+    {
+    case UserVolumeOpen:
+        Status = STATUS_INVALID_PARAMETER;
+        /* Complete request and return status */
+        FatCompleteRequest(IrpContext, Irp, Status);
+        return Status;
+    case UserFileOpen:
+        /* Check oplocks */
+        if (!FlagOn(Fcb->State, FCB_STATE_PAGEFILE) &&
+            ((InfoClass == FileEndOfFileInformation) ||
+            (InfoClass == FileAllocationInformation)))
+        {
+            Status = FsRtlCheckOplock(&Fcb->Fcb.Oplock,
+                                      Irp,
+                                      IrpContext,
+                                      NULL,
+                                      NULL);
+
+            if (Status != STATUS_SUCCESS)
+            {
+                /* Complete request and return status */
+                FatCompleteRequest(IrpContext, Irp, Status);
+                return Status;
+            }
+
+            /* Update Fast IO flag */
+            Fcb->Header.IsFastIoPossible = FatIsFastIoPossible(Fcb);
+        }
+        break;
+
+    case UserDirectoryOpen:
+        break;
+
+    default:
+        Status = STATUS_INVALID_PARAMETER;
+        /* Complete request and return status */
+        FatCompleteRequest(IrpContext, Irp, Status);
+        return Status;
+    }
+
+    /* If it's a root DCB - fail */
+    if (FatNodeType(Fcb) == FAT_NTC_ROOT_DCB)
+    {
+        if (InfoClass == FileDispositionInformation)
+            Status = STATUS_CANNOT_DELETE;
+        else
+            Status = STATUS_INVALID_PARAMETER;
+
+        /* Complete request and return status */
+        FatCompleteRequest(IrpContext, Irp, Status);
+        return Status;
+    }
+
+    /* Acquire the volume lock if needed */
+    if (InfoClass == FileDispositionInformation ||
+        InfoClass == FileRenameInformation)
+    {
+        if (!FatAcquireExclusiveVcb(IrpContext, Vcb))
+        {
+            UNIMPLEMENTED;
+        }
+
+        VcbAcquired = TRUE;
+    }
+
+    /* Acquire FCB lock */
+    if (!FlagOn(Fcb->State, FCB_STATE_PAGEFILE))
+    {
+        if (!FatAcquireExclusiveFcb(IrpContext, Fcb))
+        {
+            UNIMPLEMENTED;
+        }
+
+        FcbAcquired = TRUE;
+    }
+
+    // TODO: VerifyFcb
+
+    switch (InfoClass)
+    {
+    case FileBasicInformation:
+        //Status = FatSetBasicInfo(IrpContext, Irp, Fcb, Ccb);
+        DPRINT1("FileBasicInformation\n");
+        break;
+
+    case FileDispositionInformation:
+        if (FlagOn(Vcb->State, VCB_STATE_FLAG_DEFERRED_FLUSH) &&
+            !FlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))
+        {
+            UNIMPLEMENTED;
+        }
+        else
+        {
+            //Status = FatSetDispositionInfo(IrpContext, Irp, FileObject, Fcb);
+            DPRINT1("FileDispositionInformation\n");
+        }
+
+        break;
+
+    case FileRenameInformation:
+        if (!FlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT))
+        {
+            UNIMPLEMENTED;
+        }
+        else
+        {
+            //Status = FatSetRenameInfo(IrpContext, Irp, Vcb, Fcb, Ccb);
+            DPRINT1("FileRenameInformation\n");
+
+            /* NOTE: Request must not be completed here!
+            That's why Irp/IrpContext are set to NULL */
+            if (Status == STATUS_PENDING)
+            {
+                Irp = NULL;
+                IrpContext = NULL;
+            }
+        }
+        break;
+
+    case FilePositionInformation:
+        //Status = FatSetPositionInfo(IrpContext, Irp, FileObject);
+        DPRINT1("FilePositionInformation\n");
+        break;
+
+    case FileLinkInformation:
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        break;
+
+    case FileAllocationInformation:
+        //Status = FatSetAllocationInfo(IrpContext, Irp, Fcb, FileObject);
+        DPRINT1("FileAllocationInformation\n");
+        break;
+
+    case FileEndOfFileInformation:
+        Status = FatSetEndOfFileInfo(IrpContext, Irp, FileObject, Vcb, Fcb);
+        break;
+
+    default:
+        Status = STATUS_INVALID_PARAMETER;
+    }
+
+    /* Release locks */
+    if (FcbAcquired) FatReleaseFcb(IrpContext, Fcb);
+    if (VcbAcquired) FatReleaseVcb(IrpContext, Vcb);
+
+    /* Complete request and return status */
+    FatCompleteRequest(IrpContext, Irp, Status);
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 FatSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
-    DPRINT1("FatSetInformation()\n");
-    return STATUS_NOT_IMPLEMENTED;
+    NTSTATUS Status;
+    BOOLEAN TopLevel, CanWait;
+    PFAT_IRP_CONTEXT IrpContext;
+
+    CanWait = TRUE;
+    TopLevel = FALSE;
+    Status = STATUS_INVALID_DEVICE_REQUEST;
+
+    /* Get CanWait flag */
+    if (IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL)
+        CanWait = IoIsOperationSynchronous(Irp);
+
+    /* Enter FsRtl critical region */
+    FsRtlEnterFileSystem();
+
+    /* Set Top Level IRP if not set */
+    TopLevel = FatIsTopLevelIrp(Irp);
+
+    /* Build an irp context */
+    IrpContext = FatBuildIrpContext(Irp, CanWait);
+
+    /* Perform the actual read */
+    Status = FatiSetInformation(IrpContext, Irp);
+
+    /* Restore top level Irp */
+    if (TopLevel) IoSetTopLevelIrp(NULL);
+
+    /* Leave FsRtl critical region */
+    FsRtlExitFileSystem();
+
+    return Status;
 }
 
 /* EOF */
index 2953836..540b417 100644 (file)
 
 /* FUNCTIONS ****************************************************************/
 
+NTSTATUS
+NTAPI
+FatOplockRequest(IN PFAT_IRP_CONTEXT IrpContext,
+                 IN PIRP Irp)
+{
+    NTSTATUS Status;
+    DPRINT1("Oplock request!\n");
+
+    Status = STATUS_INVALID_DEVICE_REQUEST;
+    FatCompleteRequest(IrpContext, Irp, Status);
+
+    return Status;
+}
+
+NTSTATUS
+NTAPI
+FatMarkVolumeDirty(IN PFAT_IRP_CONTEXT IrpContext,
+                   IN PIRP Irp)
+{
+    NTSTATUS Status;
+    DPRINT1("Marking volume as dirty\n");
+
+    Status = STATUS_SUCCESS;
+    FatCompleteRequest(IrpContext, Irp, Status);
+
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 FatUserFsCtrl(PFAT_IRP_CONTEXT IrpContext, PIRP Irp)
 {
-    DPRINT1("FatUserFsCtrl()\n");
-    FatCompleteRequest(IrpContext, Irp, STATUS_INVALID_DEVICE_REQUEST);
-    return STATUS_INVALID_DEVICE_REQUEST;
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status;
+    ULONG Code;
+
+    /* Get current IRP stack location */
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+    Code = IrpSp->Parameters.FileSystemControl.FsControlCode;
+
+    /* Set the wait flag */
+    if (Irp->RequestorMode != KernelMode &&
+        (Code & 3) == METHOD_NEITHER)
+    {
+        SetFlag(IrpContext->Flags, IRPCONTEXT_CANWAIT);
+    }
+
+    /* Branch according to the code */
+    switch (Code)
+    {
+    case FSCTL_REQUEST_OPLOCK_LEVEL_1:
+    case FSCTL_REQUEST_OPLOCK_LEVEL_2:
+    case FSCTL_REQUEST_BATCH_OPLOCK:
+    case FSCTL_OPLOCK_BREAK_ACKNOWLEDGE:
+    case FSCTL_OPBATCH_ACK_CLOSE_PENDING:
+    case FSCTL_OPLOCK_BREAK_NOTIFY:
+    case FSCTL_OPLOCK_BREAK_ACK_NO_2:
+    case FSCTL_REQUEST_FILTER_OPLOCK :
+        Status = FatOplockRequest(IrpContext, Irp);
+        break;
+
+    case FSCTL_LOCK_VOLUME:
+        //Status = FatLockVolume( IrpContext, Irp );
+        DPRINT1("FSCTL_LOCK_VOLUME\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_UNLOCK_VOLUME:
+        //Status = FatUnlockVolume( IrpContext, Irp );
+        DPRINT1("FSCTL_UNLOCK_VOLUME\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_DISMOUNT_VOLUME:
+        //Status = FatDismountVolume( IrpContext, Irp );
+        DPRINT1("FSCTL_DISMOUNT_VOLUME\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_MARK_VOLUME_DIRTY:
+        Status = FatMarkVolumeDirty(IrpContext, Irp);
+        break;
+
+    case FSCTL_IS_VOLUME_DIRTY:
+        //Status = FatIsVolumeDirty( IrpContext, Irp );
+        DPRINT1("FSCTL_IS_VOLUME_DIRTY\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_IS_VOLUME_MOUNTED:
+        //Status = FatIsVolumeMounted( IrpContext, Irp );
+        DPRINT1("FSCTL_IS_VOLUME_MOUNTED\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_IS_PATHNAME_VALID:
+        //Status = FatIsPathnameValid( IrpContext, Irp );
+        DPRINT1("FSCTL_IS_PATHNAME_VALID\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_QUERY_RETRIEVAL_POINTERS:
+        //Status = FatQueryRetrievalPointers( IrpContext, Irp );
+        DPRINT1("FSCTL_QUERY_RETRIEVAL_POINTERS\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_QUERY_FAT_BPB:
+        //Status = FatQueryBpb( IrpContext, Irp );
+        DPRINT1("FSCTL_QUERY_FAT_BPB\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_FILESYSTEM_GET_STATISTICS:
+        //Status = FatGetStatistics( IrpContext, Irp );
+        DPRINT1("FSCTL_FILESYSTEM_GET_STATISTICS\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_GET_VOLUME_BITMAP:
+        //Status = FatGetVolumeBitmap( IrpContext, Irp );
+        DPRINT1("FSCTL_GET_VOLUME_BITMAP\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_GET_RETRIEVAL_POINTERS:
+        //Status = FatGetRetrievalPointers( IrpContext, Irp );
+        DPRINT1("FSCTL_GET_RETRIEVAL_POINTERS\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_MOVE_FILE:
+        //Status = FatMoveFile( IrpContext, Irp );
+        DPRINT1("FSCTL_MOVE_FILE\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    case FSCTL_ALLOW_EXTENDED_DASD_IO:
+        //Status = FatAllowExtendedDasdIo( IrpContext, Irp );
+        DPRINT1("FSCTL_ALLOW_EXTENDED_DASD_IO\n");
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+        break;
+
+    default:
+        DPRINT("FatUserFsCtrl(), unhandled fs control code 0x%x\n", Code);
+        Status = STATUS_INVALID_DEVICE_REQUEST;
+        FatCompleteRequest(IrpContext, Irp, Status);
+    }
+
+    //(((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
+
+    // 9c040
+    //    1 1     0   0   0
+    //    6 4     8   4   0
+    // 10011100000001000000
+    // DT = 1001 = 9
+    // Access = 11 = 3
+    // Function = 10000 = 16
+    // Method = 0
+
+    return Status;
 }
 
 NTSTATUS
index a081c4b..509aa50 100644 (file)
 
 /* FUNCTIONS ****************************************************************/
 
+NTSTATUS
+NTAPI
+FatiLockControl(PFAT_IRP_CONTEXT IrpContext, PIRP Irp)
+{
+    PIO_STACK_LOCATION IrpSp;
+    TYPE_OF_OPEN TypeOfOpen;
+    PVCB Vcb;
+    PFCB Fcb;
+    PCCB Ccb;
+    NTSTATUS Status;
+
+    /* Get IRP stack location */
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+
+    /* Determine type of open */
+    TypeOfOpen = FatDecodeFileObject(IrpSp->FileObject, &Vcb, &Fcb, &Ccb);
+
+    /* Only user file open is allowed */
+    if (TypeOfOpen != UserFileOpen)
+    {
+        FatCompleteRequest(IrpContext, Irp, STATUS_INVALID_PARAMETER);
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    /* Acquire shared FCB lock */
+    if (!FatAcquireSharedFcb(IrpContext, Fcb))
+    {
+        UNIMPLEMENTED;
+        //Status = FatFsdPostRequest(IrpContext, Irp);
+        Status = STATUS_NOT_IMPLEMENTED;
+        return Status;
+    }
+
+    /* Check oplock state */
+    Status = FsRtlCheckOplock(&Fcb->Fcb.Oplock,
+                              Irp,
+                              IrpContext,
+                              FatOplockComplete,
+                              NULL);
+
+    if (Status != STATUS_SUCCESS)
+    {
+        /* Release FCB lock */
+        FatReleaseFcb(IrpContext, Fcb);
+
+        return Status;
+    }
+
+    /* Process the lock */
+    Status = FsRtlProcessFileLock(&Fcb->Fcb.Lock, Irp, NULL);
+
+    /* Update Fast I/O state */
+    Fcb->Header.IsFastIoPossible = FatIsFastIoPossible(Fcb);
+
+    /* Complete the request */
+    FatCompleteRequest(IrpContext, NULL, 0);
+
+    /* Release FCB lock */
+    FatReleaseFcb(IrpContext, Fcb);
+
+    return Status;
+}
+
 NTSTATUS
 NTAPI
 FatLockControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
+    PFAT_IRP_CONTEXT IrpContext;
+    NTSTATUS Status;
+    BOOLEAN TopLevel;
+
     DPRINT1("FatLockControl()\n");
-    return STATUS_NOT_IMPLEMENTED;
+
+    /* Enter FsRtl critical region */
+    FsRtlEnterFileSystem();
+
+    /* Set Top Level IRP if not set */
+    TopLevel = FatIsTopLevelIrp(Irp);
+
+    /* Build an irp context */
+    IrpContext = FatBuildIrpContext(Irp, IoIsOperationSynchronous(Irp));
+
+    /* Call internal function */
+    Status = FatiLockControl(IrpContext, Irp);
+
+    /* Reset Top Level IRP */
+    if (TopLevel) IoSetTopLevelIrp(NULL);
+
+    /* Leave FsRtl critical region */
+    FsRtlExitFileSystem();
+
+    return Status;
 }
 
 VOID
index a4b887b..cdaea2b 100644 (file)
@@ -91,11 +91,7 @@ FatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     if (DeviceObject != FatGlobalData.DiskDeviceObject)
     {
         /* Set Top Level IRP if not set */
-        if (IoGetTopLevelIrp() == NULL)
-        {
-            IoSetTopLevelIrp(Irp);
-            TopLevel = TRUE;
-        }
+        TopLevel = FatIsTopLevelIrp(Irp);
 
         /* Build an irp context */
         IrpContext = FatBuildIrpContext(Irp, CanWait);
index 49a67b0..a6a30ab 100644 (file)
@@ -8,7 +8,7 @@
 
 /* INCLUDES *****************************************************************/
 
-//#define NDEBUG
+#define NDEBUG
 #include "fastfat.h"
 
 /* FUNCTIONS ****************************************************************/
@@ -77,12 +77,31 @@ FatiQueryFsSizeInfo(PVCB Vcb,
     Buffer->SectorsPerAllocationUnit = Vcb->Bpb.SectorsPerCluster;
     Buffer->BytesPerSector = Vcb->Bpb.BytesPerSector;
 
-    DPRINT1("Total %d, free %d, SPC %d, BPS %d\n", Partition->FreeClusterCount,
-        Partition->NumClusters, Vcb->Bpb.SectorsPerCluster, Vcb->Bpb.BytesPerSector);
+    DPRINT1("Total %d, free %d, SPC %d, BPS %d\n", Partition->NumClusters,
+        Partition->FreeClusterCount, Vcb->Bpb.SectorsPerCluster, Vcb->Bpb.BytesPerSector);
 
     return Status;
 }
 
+NTSTATUS
+NTAPI
+FatiQueryFsDeviceInfo(PVCB Vcb,
+                      PFILE_FS_DEVICE_INFORMATION Buffer,
+                      PLONG Length)
+{
+    /* Deduct the minimum written length */
+    *Length -= sizeof(FILE_FS_DEVICE_INFORMATION);
+
+    /* Zero it */
+    RtlZeroMemory(Buffer, sizeof(FILE_FS_DEVICE_INFORMATION));
+
+    /* Set values */
+    Buffer->DeviceType = FILE_DEVICE_DISK;
+    Buffer->Characteristics = Vcb->TargetDeviceObject->Characteristics;
+
+    return STATUS_SUCCESS;
+}
+
 NTSTATUS
 NTAPI
 FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext, PIRP Irp)
@@ -135,13 +154,28 @@ FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext, PIRP Irp)
         /* Call FsVolumeInfo handler */
         Status = FatiQueryFsVolumeInfo(Vcb, Buffer, &Length);
         break;
+
     case FileFsSizeInformation:
         /* Call FsVolumeInfo handler */
         Status = FatiQueryFsSizeInfo(Vcb, Buffer, &Length);
         break;
-    default:
-        DPRINT1("Volume information class %d is not supported!\n", InfoClass);
+
+    case FileFsDeviceInformation:
+        Status = FatiQueryFsDeviceInfo(Vcb, Buffer, &Length);
+        break;
+
+    case FileFsAttributeInformation:
         UNIMPLEMENTED;
+        //Status = FatiQueryFsAttributeInfo(IrpContext, Vcb, Buffer, &Length);
+        break;
+
+    case FileFsFullSizeInformation:
+        UNIMPLEMENTED;
+        //Status = FatiQueryFsFullSizeInfo(IrpContext, Vcb, Buffer, &Length);
+        break;
+
+    default:
+        Status = STATUS_INVALID_PARAMETER;
     }
 
     /* Set IoStatus.Information to amount of filled bytes */
@@ -175,11 +209,7 @@ FatQueryVolumeInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp)
     FsRtlEnterFileSystem();
 
     /* Set Top Level IRP if not set */
-    if (IoGetTopLevelIrp() == NULL)
-    {
-        IoSetTopLevelIrp(Irp);
-        TopLevel = TRUE;
-    }
+    TopLevel = FatIsTopLevelIrp(Irp);
 
     /* Build an irp context */
     IrpContext = FatBuildIrpContext(Irp, CanWait);
@@ -228,4 +258,14 @@ FatReadStreamFile(PVCB Vcb,
     }
 }
 
+BOOLEAN
+NTAPI
+FatCheckForDismount(IN PFAT_IRP_CONTEXT IrpContext,
+                    PVCB Vcb,
+                    IN BOOLEAN Force)
+{
+    /* We never allow deletion of a volume for now */
+    return FALSE;
+}
+
 /* EOF */
index 7dd615d..ad4de2a 100644 (file)
@@ -27,7 +27,7 @@ typedef struct _NDIS_M_DRIVER_BLOCK {
     PDRIVER_OBJECT                  DriverObject;             /* Driver object of miniport */
     LIST_ENTRY                      DeviceList;               /* Adapters created by miniport */
     PUNICODE_STRING                 RegistryPath;             /* SCM Registry key */
-#if !defined(_MSC_VER) && defined(__NDIS_H)
+#if !defined(_MSC_VER) && defined(_NDIS_)
 } NDIS_M_DRIVER_BLOCK_COMPATIBILITY_HACK_DONT_USE;
 #else
 } NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
index d4d550f..eeeb6e8 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
 
 typedef struct _ACPI_EVAL_INPUT_BUFFER {
   ULONG Signature;
-  union {
+  _ANONYMOUS_UNION union {
     UCHAR MethodName[4];
     ULONG MethodNameAsUlong;
   } DUMMYUNIONNAME;
@@ -43,7 +43,7 @@ typedef struct _ACPI_EVAL_INPUT_BUFFER {
 
 typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER {
   ULONG Signature;
-  union {
+  _ANONYMOUS_UNION union {
     UCHAR MethodName[4];
     ULONG MethodNameAsUlong;
   } DUMMYUNIONNAME;
@@ -52,7 +52,7 @@ typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_INTEGER {
 
 typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING {
   ULONG Signature;
-  union {
+  _ANONYMOUS_UNION union {
     UCHAR MethodName[4];
     ULONG MethodNameAsUlong;
   } DUMMYUNIONNAME;
@@ -63,7 +63,7 @@ typedef struct _ACPI_EVAL_INPUT_BUFFER_SIMPLE_STRING {
 typedef struct _ACPI_METHOD_ARGUMENT {
   USHORT Type;
   USHORT DataLength;
-  union {
+  _ANONYMOUS_UNION union {
     ULONG Argument;
     UCHAR Data[ANYSIZE_ARRAY];
   } DUMMYUNIONNAME;
@@ -72,7 +72,7 @@ typedef ACPI_METHOD_ARGUMENT UNALIGNED *PACPI_METHOD_ARGUMENT;
 
 typedef struct _ACPI_EVAL_INPUT_BUFFER_COMPLEX {
   ULONG Signature;
-  union {
+  _ANONYMOUS_UNION union {
     UCHAR MethodName[4];
     ULONG MethodNameAsUlong;
   } DUMMYUNIONNAME;
@@ -142,47 +142,47 @@ typedef struct _ACPI_ENUM_CHILDREN_OUTPUT_BUFFER {
 typedef ACPI_ENUM_CHILDREN_OUTPUT_BUFFER UNALIGNED *PACPI_ENUM_CHILDREN_OUTPUT_BUFFER;
 
 #define ACPI_METHOD_ARGUMENT_LENGTH( DataLength )                           \
-    (FIELD_OFFSET(ACPI_METHOD_ARGUMENT, Data) + max(sizeof(ULONG), DataLength))
+  (FIELD_OFFSET(ACPI_METHOD_ARGUMENT, Data) + max(sizeof(ULONG), DataLength))
 
 #define ACPI_METHOD_ARGUMENT_LENGTH_FROM_ARGUMENT( Argument )               \
-    (ACPI_METHOD_ARGUMENT_LENGTH(((PACPI_METHOD_ARGUMENT)Argument)->DataLength))
+  (ACPI_METHOD_ARGUMENT_LENGTH(((PACPI_METHOD_ARGUMENT)Argument)->DataLength))
 
 #define ACPI_METHOD_NEXT_ARGUMENT( Argument )                               \
-    (PACPI_METHOD_ARGUMENT) ( (PUCHAR) Argument +                           \
-    ACPI_METHOD_ARGUMENT_LENGTH_FROM_ARGUMENT( Argument ) )
+  (PACPI_METHOD_ARGUMENT) ( (PUCHAR) Argument +                             \
+  ACPI_METHOD_ARGUMENT_LENGTH_FROM_ARGUMENT( Argument ) )
 
 
 #define ACPI_METHOD_SET_ARGUMENT_INTEGER( MethodArgument, IntData )         \
-    { MethodArgument->Type = ACPI_METHOD_ARGUMENT_INTEGER;                  \
-      MethodArgument->DataLength = sizeof(ULONG);                           \
-      MethodArgument->Argument = IntData; }
+  { MethodArgument->Type = ACPI_METHOD_ARGUMENT_INTEGER;                    \
+    MethodArgument->DataLength = sizeof(ULONG);                             \
+    MethodArgument->Argument = IntData; }
 
 #define ACPI_METHOD_SET_ARGUMENT_STRING( Argument, StrData )                \
-    { Argument->Type = ACPI_METHOD_ARGUMENT_STRING;                         \
-      Argument->DataLength = strlen((PCHAR)StrData) + sizeof(UCHAR);       \
-      RtlCopyMemory(&Argument->Data[0],(PUCHAR)StrData,Argument->DataLength); }
+  { Argument->Type = ACPI_METHOD_ARGUMENT_STRING;                           \
+    Argument->DataLength = strlen((PCHAR)StrData) + sizeof(UCHAR);          \
+    RtlCopyMemory(&Argument->Data[0],(PUCHAR)StrData,Argument->DataLength); }
 
 #define ACPI_METHOD_SET_ARGUMENT_BUFFER( Argument, BuffData, BuffLength )   \
-    { Argument->Type = ACPI_METHOD_ARGUMENT_BUFFER;                         \
-      Argument->DataLength = BuffLength;                                    \
-      RtlCopyMemory(&Argument->Data[0],(PUCHAR)BuffData,Argument->DataLength); }
+  { Argument->Type = ACPI_METHOD_ARGUMENT_BUFFER;                           \
+    Argument->DataLength = BuffLength;                                      \
+    RtlCopyMemory(&Argument->Data[0],(PUCHAR)BuffData,Argument->DataLength); }
 
-#define ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child )              \
-    ( (2* sizeof (ULONG)) + Child->NameLength )
+#define ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child ) \
+  ( (2* sizeof (ULONG)) + Child->NameLength )
 
-#define ACPI_ENUM_CHILD_NEXT( Child )                           \
-    (PACPI_ENUM_CHILD) ( (PUCHAR) Child +                       \
-    ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child ) )
+#define ACPI_ENUM_CHILD_NEXT( Child )           \
+  (PACPI_ENUM_CHILD) ( (PUCHAR) Child +         \
+  ACPI_ENUM_CHILD_LENGTH_FROM_CHILD( Child ) )
 
-#define IOCTL_ACPI_ASYNC_EVAL_METHOD             CTL_CODE(FILE_DEVICE_ACPI, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_ACPI_EVAL_METHOD                   CTL_CODE(FILE_DEVICE_ACPI, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK           CTL_CODE(FILE_DEVICE_ACPI, 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_ACPI_RELEASE_GLOBAL_LOCK           CTL_CODE(FILE_DEVICE_ACPI, 5, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_ASYNC_EVAL_METHOD    CTL_CODE(FILE_DEVICE_ACPI, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_EVAL_METHOD          CTL_CODE(FILE_DEVICE_ACPI, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK  CTL_CODE(FILE_DEVICE_ACPI, 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_RELEASE_GLOBAL_LOCK  CTL_CODE(FILE_DEVICE_ACPI, 5, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
 
 #if (NTDDI_VERSION >= NTDDI_VISTA)
-#define IOCTL_ACPI_EVAL_METHOD_EX                CTL_CODE(FILE_DEVICE_ACPI, 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_ACPI_ASYNC_EVAL_METHOD_EX          CTL_CODE(FILE_DEVICE_ACPI, 7, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
-#define IOCTL_ACPI_ENUM_CHILDREN                 CTL_CODE(FILE_DEVICE_ACPI, 8, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_EVAL_METHOD_EX       CTL_CODE(FILE_DEVICE_ACPI, 6, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_ASYNC_EVAL_METHOD_EX CTL_CODE(FILE_DEVICE_ACPI, 7, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
+#define IOCTL_ACPI_ENUM_CHILDREN        CTL_CODE(FILE_DEVICE_ACPI, 8, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
 #endif
 
 #ifdef __cplusplus
index 373ccdb..5196411 100644 (file)
@@ -6,15 +6,6 @@
 extern "C" {
 #endif
 
-/* Helper macro to enable gcc's extension. */
-#ifndef __GNU_EXTENSION
-#ifdef __GNUC__
-#define __GNU_EXTENSION __extension__
-#else
-#define __GNU_EXTENSION
-#endif
-#endif
-
 #define STDMETHODCALLTYPE __stdcall
 
 #ifndef _WDMDDK_
index d4ecc2c..81f8d11 100644 (file)
 #ifndef _D3DHAL_H_
 #define _D3DHAL_H_
 
-/* Helper macro to enable gcc's extension.  */
-#ifndef __GNU_EXTENSION
-#ifdef __GNUC__
-#define __GNU_EXTENSION __extension__
-#else
-#define __GNU_EXTENSION
-#endif
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -61,31 +52,31 @@ typedef struct _DDRAWI_DDRAWSURFACE_LCL FAR *LPDDRAWI_DDRAWSURFACE_LCL;
  * device info structures
  */
 typedef struct _D3DDeviceDesc_V1 {
-  DWORD                        dwSize;
-  DWORD                        dwFlags;
-  D3DCOLORMODEL                dcmColorModel;
-  DWORD                        dwDevCaps;
-  D3DTRANSFORMCAPS     dtcTransformCaps;
-  BOOL                 bClipping;
-  D3DLIGHTINGCAPS      dlcLightingCaps;
-  D3DPRIMCAPS          dpcLineCaps;
-  D3DPRIMCAPS          dpcTriCaps;
-  DWORD                        dwDeviceRenderBitDepth;
-  DWORD                        dwDeviceZBufferBitDepth;
-  DWORD                        dwMaxBufferSize;
-  DWORD                        dwMaxVertexCount;
-} D3DDEVICEDESC_V1,*LPD3DDEVICEDESC_V1;
+  DWORD dwSize;
+  DWORD dwFlags;
+  D3DCOLORMODEL dcmColorModel;
+  DWORD dwDevCaps;
+  D3DTRANSFORMCAPS dtcTransformCaps;
+  BOOL bClipping;
+  D3DLIGHTINGCAPS dlcLightingCaps;
+  D3DPRIMCAPS dpcLineCaps;
+  D3DPRIMCAPS dpcTriCaps;
+  DWORD dwDeviceRenderBitDepth;
+  DWORD dwDeviceZBufferBitDepth;
+  DWORD dwMaxBufferSize;
+  DWORD dwMaxVertexCount;
+} D3DDEVICEDESC_V1, *LPD3DDEVICEDESC_V1;
 
 /* this is to allow keeping the bulk of our OpenGL code out of x11drv */
 #define D3DDD_WINE_OPENGL_DEVICE 0x00008000
 
 typedef struct _D3DHAL_GLOBALDRIVERDATA {
-  DWORD                        dwSize;
-  D3DDEVICEDESC_V1     hwCaps;
-  DWORD                        dwNumVertices;
-  DWORD                        dwNumClipVertices;
-  DWORD                        dwNumTextureFormats;
-  LPDDSURFACEDESC      lpTextureFormats;
+  DWORD dwSize;
+  D3DDEVICEDESC_V1 hwCaps;
+  DWORD dwNumVertices;
+  DWORD dwNumClipVertices;
+  DWORD dwNumTextureFormats;
+  LPDDSURFACEDESC lpTextureFormats;
 } D3DHAL_GLOBALDRIVERDATA;
 
 #ifndef D3DHAL_GLOBALDRIVERDATA_DEFINED
@@ -94,103 +85,103 @@ typedef D3DHAL_GLOBALDRIVERDATA *LPD3DHAL_GLOBALDRIVERDATA;
 #endif
 
 typedef struct _D3DHAL_D3DEXTENDEDCAPS {
-  DWORD                        dwSize;
+  DWORD dwSize;
   /* DirectX 5 */
-  DWORD                        dwMinTextureWidth, dwMaxTextureWidth;
-  DWORD                        dwMinTextureHeight, dwMaxTextureHeight;
-  DWORD                        dwMinStippleWidth, dwMaxStippleWidth;
-  DWORD                        dwMinStippleHeight, dwMaxStippleHeight;
+  DWORD dwMinTextureWidth, dwMaxTextureWidth;
+  DWORD dwMinTextureHeight, dwMaxTextureHeight;
+  DWORD dwMinStippleWidth, dwMaxStippleWidth;
+  DWORD dwMinStippleHeight, dwMaxStippleHeight;
   /* DirectX 6 */
-  DWORD                        dwMaxTextureRepeat;
-  DWORD                        dwMaxTextureAspectRatio;
-  DWORD                        dwMaxAnisotropy;
-  D3DVALUE             dvGuardBandLeft;
-  D3DVALUE             dvGuardBandTop;
-  D3DVALUE             dvGuardBandRight;
-  D3DVALUE             dvGuardBandBottom;
-  D3DVALUE             dvExtentsAdjust;
-  DWORD                        dwStencilCaps;
-  DWORD                        dwFVFCaps;
-  DWORD                        dwTextureOpCaps;
-  WORD                 wMaxTextureBlendStages;
-  WORD                 wMaxSimultaneousTextures;
+  DWORD dwMaxTextureRepeat;
+  DWORD dwMaxTextureAspectRatio;
+  DWORD dwMaxAnisotropy;
+  D3DVALUE dvGuardBandLeft;
+  D3DVALUE dvGuardBandTop;
+  D3DVALUE dvGuardBandRight;
+  D3DVALUE dvGuardBandBottom;
+  D3DVALUE dvExtentsAdjust;
+  DWORD dwStencilCaps;
+  DWORD dwFVFCaps;
+  DWORD dwTextureOpCaps;
+  WORD wMaxTextureBlendStages;
+  WORD wMaxSimultaneousTextures;
   /* DirectX 7 */
-  DWORD                        dwMaxActiveLights;
-  D3DVALUE             dvMaxVertexW;
-  WORD                 wMaxUserClipPlanes;
-  WORD                 wMaxVertexBlendMatrices;
-  DWORD                        dwVertexProcessingCaps;
-  DWORD                        dwReserved1;
-  DWORD                        dwReserved2;
-  DWORD                        dwReserved3;
-  DWORD                        dwReserved4;
-} D3DHAL_D3DEXTENDEDCAPS,*LPD3DHAL_D3DEXTENDEDCAPS;
+  DWORD dwMaxActiveLights;
+  D3DVALUE dvMaxVertexW;
+  WORD wMaxUserClipPlanes;
+  WORD wMaxVertexBlendMatrices;
+  DWORD dwVertexProcessingCaps;
+  DWORD dwReserved1;
+  DWORD dwReserved2;
+  DWORD dwReserved3;
+  DWORD dwReserved4;
+} D3DHAL_D3DEXTENDEDCAPS, *LPD3DHAL_D3DEXTENDEDCAPS;
 
 /*****************************************************************************
  * d3d->driver callbacks
  */
-typedef struct _D3DHAL_CONTEXTCREATEDATA       *LPD3DHAL_CONTEXTCREATEDATA;
-typedef struct _D3DHAL_CONTEXTDESTROYDATA      *LPD3DHAL_CONTEXTDESTROYDATA;
-typedef struct _D3DHAL_CONTEXTDESTROYALLDATA   *LPD3DHAL_CONTEXTDESTROYALLDATA;
-typedef struct _D3DHAL_SCENECAPTUREDATA                *LPD3DHAL_SCENECAPTUREDATA;
-typedef struct _D3DHAL_RENDERSTATEDATA         *LPD3DHAL_RENDERSTATEDATA;
-typedef struct _D3DHAL_RENDERPRIMITIVEDATA     *LPD3DHAL_RENDERPRIMITIVEDATA;
-typedef struct _D3DHAL_TEXTURECREATEDATA       *LPD3DHAL_TEXTURECREATEDATA;
-typedef struct _D3DHAL_TEXTUREDESTROYDATA      *LPD3DHAL_TEXTUREDESTROYDATA;
-typedef struct _D3DHAL_TEXTURESWAPDATA         *LPD3DHAL_TEXTURESWAPDATA;
-typedef struct _D3DHAL_TEXTUREGETSURFDATA      *LPD3DHAL_TEXTUREGETSURFDATA;
-typedef struct _D3DHAL_GETSTATEDATA            *LPD3DHAL_GETSTATEDATA;
+typedef struct _D3DHAL_CONTEXTCREATEDATA *LPD3DHAL_CONTEXTCREATEDATA;
+typedef struct _D3DHAL_CONTEXTDESTROYDATA *LPD3DHAL_CONTEXTDESTROYDATA;
+typedef struct _D3DHAL_CONTEXTDESTROYALLDATA *LPD3DHAL_CONTEXTDESTROYALLDATA;
+typedef struct _D3DHAL_SCENECAPTUREDATA *LPD3DHAL_SCENECAPTUREDATA;
+typedef struct _D3DHAL_RENDERSTATEDATA *LPD3DHAL_RENDERSTATEDATA;
+typedef struct _D3DHAL_RENDERPRIMITIVEDATA *LPD3DHAL_RENDERPRIMITIVEDATA;
+typedef struct _D3DHAL_TEXTURECREATEDATA *LPD3DHAL_TEXTURECREATEDATA;
+typedef struct _D3DHAL_TEXTUREDESTROYDATA *LPD3DHAL_TEXTUREDESTROYDATA;
+typedef struct _D3DHAL_TEXTURESWAPDATA *LPD3DHAL_TEXTURESWAPDATA;
+typedef struct _D3DHAL_TEXTUREGETSURFDATA *LPD3DHAL_TEXTUREGETSURFDATA;
+typedef struct _D3DHAL_GETSTATEDATA *LPD3DHAL_GETSTATEDATA;
 
 typedef DWORD (PASCAL *LPD3DHAL_CONTEXTCREATECB)    (LPD3DHAL_CONTEXTCREATEDATA);
 typedef DWORD (PASCAL *LPD3DHAL_CONTEXTDESTROYCB)   (LPD3DHAL_CONTEXTDESTROYDATA);
 typedef DWORD (PASCAL *LPD3DHAL_CONTEXTDESTROYALLCB)(LPD3DHAL_CONTEXTDESTROYALLDATA);
-typedef DWORD (PASCAL *LPD3DHAL_SCENECAPTURECB)            (LPD3DHAL_SCENECAPTUREDATA);
-typedef DWORD (PASCAL *LPD3DHAL_RENDERSTATECB)     (LPD3DHAL_RENDERSTATEDATA);
+typedef DWORD (PASCAL *LPD3DHAL_SCENECAPTURECB)     (LPD3DHAL_SCENECAPTUREDATA);
+typedef DWORD (PASCAL *LPD3DHAL_RENDERSTATECB)      (LPD3DHAL_RENDERSTATEDATA);
 typedef DWORD (PASCAL *LPD3DHAL_RENDERPRIMITIVECB)  (LPD3DHAL_RENDERPRIMITIVEDATA);
 typedef DWORD (PASCAL *LPD3DHAL_TEXTURECREATECB)    (LPD3DHAL_TEXTURECREATEDATA);
 typedef DWORD (PASCAL *LPD3DHAL_TEXTUREDESTROYCB)   (LPD3DHAL_TEXTUREDESTROYDATA);
-typedef DWORD (PASCAL *LPD3DHAL_TEXTURESWAPCB)     (LPD3DHAL_TEXTURESWAPDATA);
+typedef DWORD (PASCAL *LPD3DHAL_TEXTURESWAPCB)      (LPD3DHAL_TEXTURESWAPDATA);
 typedef DWORD (PASCAL *LPD3DHAL_TEXTUREGETSURFCB)   (LPD3DHAL_TEXTUREGETSURFDATA);
-typedef DWORD (PASCAL *LPD3DHAL_GETSTATECB)        (LPD3DHAL_GETSTATEDATA);
+typedef DWORD (PASCAL *LPD3DHAL_GETSTATECB)         (LPD3DHAL_GETSTATEDATA);
 
 typedef struct _D3DHAL_CALLBACKS {
-  DWORD                                dwSize;
-  LPD3DHAL_CONTEXTCREATECB     ContextCreate;
-  LPD3DHAL_CONTEXTDESTROYCB    ContextDestroy;
-  LPD3DHAL_CONTEXTDESTROYALLCB ContextDestroyAll;
-  LPD3DHAL_SCENECAPTURECB      SceneCapture;
-  LPVOID                       lpReserved10;
-  LPVOID                       lpReserved11;
-  LPD3DHAL_RENDERSTATECB       RenderState;
-  LPD3DHAL_RENDERPRIMITIVECB   RenderPrimitive;
-  DWORD                                dwReserved;
-  LPD3DHAL_TEXTURECREATECB     TextureCreate;
-  LPD3DHAL_TEXTUREDESTROYCB    TextureDestroy;
-  LPD3DHAL_TEXTURESWAPCB       TextureSwap;
-  LPD3DHAL_TEXTUREGETSURFCB    TextureGetSurf;
+  DWORD dwSize;
+  LPD3DHAL_CONTEXTCREATECB ContextCreate;
+  LPD3DHAL_CONTEXTDESTROYCB ContextDestroy;
+  LPD3DHAL_CONTEXTDESTROYALLCB ContextDestroyAll;
+  LPD3DHAL_SCENECAPTURECB SceneCapture;
+  LPVOID lpReserved10;
+  LPVOID lpReserved11;
+  LPD3DHAL_RENDERSTATECB RenderState;
+  LPD3DHAL_RENDERPRIMITIVECB RenderPrimitive;
+  DWORD dwReserved;
+  LPD3DHAL_TEXTURECREATECB TextureCreate;
+  LPD3DHAL_TEXTUREDESTROYCB TextureDestroy;
+  LPD3DHAL_TEXTURESWAPCB TextureSwap;
+  LPD3DHAL_TEXTUREGETSURFCB TextureGetSurf;
   /* now why did MS create CALLBACKS2 and CALLBACKS3 structures if
    * all these reserved fields were available? we may never know */
-  LPVOID                       lpReserved12;
-  LPVOID                       lpReserved13;
-  LPVOID                       lpReserved14;
-  LPVOID                       lpReserved15;
-  LPVOID                       lpReserved16;
-  LPVOID                       lpReserved17;
-  LPVOID                       lpReserved18;
-  LPVOID                       lpReserved19;
-  LPVOID                       lpReserved20;
-  LPVOID                       lpReserved21;
-  LPD3DHAL_GETSTATECB          GetState;
-  DWORD                                dwReserved0;
-  DWORD                                dwReserved1;
-  DWORD                                dwReserved2;
-  DWORD                                dwReserved3;
-  DWORD                                dwReserved4;
-  DWORD                                dwReserved5;
-  DWORD                                dwReserved6;
-  DWORD                                dwReserved7;
-  DWORD                                dwReserved8;
-  DWORD                                dwReserved9;
+  LPVOID lpReserved12;
+  LPVOID lpReserved13;
+  LPVOID lpReserved14;
+  LPVOID lpReserved15;
+  LPVOID lpReserved16;
+  LPVOID lpReserved17;
+  LPVOID lpReserved18;
+  LPVOID lpReserved19;
+  LPVOID lpReserved20;
+  LPVOID lpReserved21;
+  LPD3DHAL_GETSTATECB GetState;
+  DWORD dwReserved0;
+  DWORD dwReserved1;
+  DWORD dwReserved2;
+  DWORD dwReserved3;
+  DWORD dwReserved4;
+  DWORD dwReserved5;
+  DWORD dwReserved6;
+  DWORD dwReserved7;
+  DWORD dwReserved8;
+  DWORD dwReserved9;
 } D3DHAL_CALLBACKS;
 
 #ifndef D3DHAL_CALLBACKS_DEFINED
@@ -198,132 +189,132 @@ typedef D3DHAL_CALLBACKS *LPD3DHAL_CALLBACKS;
 #define D3DHAL_CALLBACKS_DEFINED
 #endif
 
-typedef struct _D3DHAL_SETRENDERTARGETDATA             *LPD3DHAL_SETRENDERTARGETDATA;
-typedef struct _D3DHAL_CLEARDATA                       *LPD3DHAL_CLEARDATA;
-typedef struct _D3DHAL_DRAWONEPRIMITIVEDATA            *LPD3DHAL_DRAWONEPRIMITIVEDATA;
-typedef struct _D3DHAL_DRAWONEINDEXEDPRIMITIVEDATA     *LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA;
-typedef struct _D3DHAL_DRAWPRIMITIVESDATA              *LPD3DHAL_DRAWPRIMITIVESDATA;
+typedef struct _D3DHAL_SETRENDERTARGETDATA *LPD3DHAL_SETRENDERTARGETDATA;
+typedef struct _D3DHAL_CLEARDATA *LPD3DHAL_CLEARDATA;
+typedef struct _D3DHAL_DRAWONEPRIMITIVEDATA *LPD3DHAL_DRAWONEPRIMITIVEDATA;
+typedef struct _D3DHAL_DRAWONEINDEXEDPRIMITIVEDATA *LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA;
+typedef struct _D3DHAL_DRAWPRIMITIVESDATA *LPD3DHAL_DRAWPRIMITIVESDATA;
 
-typedef DWORD (PASCAL *LPD3DHAL_SETRENDERTARGETCB)       (LPD3DHAL_SETRENDERTARGETDATA);
-typedef DWORD (PASCAL *LPD3DHAL_CLEARCB)                 (LPD3DHAL_CLEARDATA);
-typedef DWORD (PASCAL *LPD3DHAL_DRAWONEPRIMITIVECB)      (LPD3DHAL_DRAWONEPRIMITIVEDATA);
+typedef DWORD (PASCAL *LPD3DHAL_SETRENDERTARGETCB)        (LPD3DHAL_SETRENDERTARGETDATA);
+typedef DWORD (PASCAL *LPD3DHAL_CLEARCB)                  (LPD3DHAL_CLEARDATA);
+typedef DWORD (PASCAL *LPD3DHAL_DRAWONEPRIMITIVECB)       (LPD3DHAL_DRAWONEPRIMITIVEDATA);
 typedef DWORD (PASCAL *LPD3DHAL_DRAWONEINDEXEDPRIMITIVECB)(LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA);
-typedef DWORD (PASCAL *LPD3DHAL_DRAWPRIMITIVESCB)        (LPD3DHAL_DRAWPRIMITIVESDATA);
+typedef DWORD (PASCAL *LPD3DHAL_DRAWPRIMITIVESCB)         (LPD3DHAL_DRAWPRIMITIVESDATA);
 
 typedef struct _D3DHAL_CALLBACKS2 {
-  DWORD                                        dwSize;
-  DWORD                                        dwFlags;
-  LPD3DHAL_SETRENDERTARGETCB           SetRenderTarget;
-  LPD3DHAL_CLEARCB                     Clear;
-  LPD3DHAL_DRAWONEPRIMITIVECB          DrawOnePrimitive;
-  LPD3DHAL_DRAWONEINDEXEDPRIMITIVECB   DrawOneIndexedPrimitive;
-  LPD3DHAL_DRAWPRIMITIVESCB            DrawPrimitives;
-} D3DHAL_CALLBACKS2,*LPD3DHAL_CALLBACKS2;
-
-typedef struct _D3DHAL_CLEAR2DATA                      *LPD3DHAL_CLEAR2DATA;
-typedef struct _D3DHAL_VALIDATETEXTURESTAGESTATEDATA   *LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA;
-typedef struct _D3DHAL_DRAWPRIMITIVES2DATA             *LPD3DHAL_DRAWPRIMITIVES2DATA;
-
-typedef DWORD (PASCAL *LPD3DHAL_CLEAR2CB)                (LPD3DHAL_CLEAR2DATA);
-typedef DWORD (PASCAL *LPD3DHAL_VALIDATETEXTURESTAGESTATECB)(LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA);
-typedef DWORD (PASCAL *LPD3DHAL_DRAWPRIMITIVES2CB)       (LPD3DHAL_DRAWPRIMITIVES2DATA);
+  DWORD dwSize;
+  DWORD dwFlags;
+  LPD3DHAL_SETRENDERTARGETCB SetRenderTarget;
+  LPD3DHAL_CLEARCB Clear;
+  LPD3DHAL_DRAWONEPRIMITIVECB DrawOnePrimitive;
+  LPD3DHAL_DRAWONEINDEXEDPRIMITIVECB DrawOneIndexedPrimitive;
+  LPD3DHAL_DRAWPRIMITIVESCB DrawPrimitives;
+} D3DHAL_CALLBACKS2, *LPD3DHAL_CALLBACKS2;
+
+typedef struct _D3DHAL_CLEAR2DATA *LPD3DHAL_CLEAR2DATA;
+typedef struct _D3DHAL_VALIDATETEXTURESTAGESTATEDATA *LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA;
+typedef struct _D3DHAL_DRAWPRIMITIVES2DATA *LPD3DHAL_DRAWPRIMITIVES2DATA;
+
+typedef DWORD (PASCAL *LPD3DHAL_CLEAR2CB) (LPD3DHAL_CLEAR2DATA);
+typedef DWORD (PASCAL *LPD3DHAL_VALIDATETEXTURESTAGESTATECB) (LPD3DHAL_VALIDATETEXTURESTAGESTATEDATA);
+typedef DWORD (PASCAL *LPD3DHAL_DRAWPRIMITIVES2CB) (LPD3DHAL_DRAWPRIMITIVES2DATA);
 
 typedef struct _D3DHAL_CALLBACKS3 {
-  DWORD                                        dwSize;
-  DWORD                                        dwFlags;
-  LPD3DHAL_CLEAR2CB                    Clear2;
-  LPVOID                               lpvReserved;
-  LPD3DHAL_VALIDATETEXTURESTAGESTATECB ValidateTextureStageState;
-  LPD3DHAL_DRAWPRIMITIVES2CB           DrawPrimitives2;
-} D3DHAL_CALLBACKS3,*LPD3DHAL_CALLBACKS3;
+  DWORD dwSize;
+  DWORD dwFlags;
+  LPD3DHAL_CLEAR2CB Clear2;
+  LPVOID lpvReserved;
+  LPD3DHAL_VALIDATETEXTURESTAGESTATECB ValidateTextureStageState;
+  LPD3DHAL_DRAWPRIMITIVES2CB DrawPrimitives2;
+} D3DHAL_CALLBACKS3, *LPD3DHAL_CALLBACKS3;
 
 /*****************************************************************************
  * parameter structures
  */
 typedef struct _D3DHAL_CONTEXTCREATEDATA {
-  union {
-    LPDDRAWI_DIRECTDRAW_GBL    lpDDGbl; /* pre-DirectX 7 */
-    LPDDRAWI_DIRECTDRAW_LCL    lpDDLcl; /* DirectX 7 */
+  _ANONYMOUS_UNION union {
+    LPDDRAWI_DIRECTDRAW_GBL lpDDGbl; /* pre-DirectX 7 */
+    LPDDRAWI_DIRECTDRAW_LCL lpDDLcl; /* DirectX 7 */
   } DUMMYUNIONNAME1;
-  union {
-    LPDIRECTDRAWSURFACE                lpDDS;
-    LPDDRAWI_DDRAWSURFACE_LCL  lpDDSLcl; /* DirectX 7 */
+  _ANONYMOUS_UNION union {
+    LPDIRECTDRAWSURFACE lpDDS;
+    LPDDRAWI_DDRAWSURFACE_LCL lpDDSLcl; /* DirectX 7 */
   } DUMMYUNIONNAME2;
-  union {
-    LPDIRECTDRAWSURFACE                lpDDSZ;
-    LPDDRAWI_DDRAWSURFACE_LCL  lpDDSZLcl; /* DirectX 7 */
+  _ANONYMOUS_UNION union {
+    LPDIRECTDRAWSURFACE lpDDSZ;
+    LPDDRAWI_DDRAWSURFACE_LCL lpDDSZLcl; /* DirectX 7 */
   } DUMMYUNIONNAME3;
-  union {
-    DWORD                      dwPID;
-    ULONG_PTR                  dwrstates;
+  _ANONYMOUS_UNION union {
+    DWORD dwPID;
+    ULONG_PTR dwrstates;
   } DUMMYUNIONNAME4;
-  ULONG_PTR                    dwhContext;
-  HRESULT                      ddrval;
+  ULONG_PTR dwhContext;
+  HRESULT ddrval;
 } D3DHAL_CONTEXTCREATEDATA;
 
 typedef struct _D3DHAL_CONTEXTDESTROYDATA {
-  ULONG_PTR                    dwhContext;
-  HRESULT                      ddrval;
+  ULONG_PTR dwhContext;
+  HRESULT ddrval;
 } D3DHAL_CONTEXTDESTROYDATA;
 
 typedef struct _D3DHAL_CONTEXTDESTROYALLDATA {
-  DWORD                                dwPID;
-  HRESULT                      ddrval;
+  DWORD dwPID;
+  HRESULT ddrval;
 } D3DHAL_CONTEXTDESTROYALLDATA;
 
 typedef struct _D3DHAL_SCENECAPTUREDATA {
-  ULONG_PTR                    dwhContext;
-  DWORD                                dwFlag;
-  HRESULT                      ddrval;
+  ULONG_PTR dwhContext;
+  DWORD dwFlag;
+  HRESULT ddrval;
 } D3DHAL_SCENECAPTUREDATA;
 
-#define D3DHAL_SCENE_CAPTURE_START     0x00000000
-#define D3DHAL_SCENE_CAPTURE_END       0x00000001
+#define D3DHAL_SCENE_CAPTURE_START 0x00000000
+#define D3DHAL_SCENE_CAPTURE_END   0x00000001
 
 typedef struct _D3DHAL_SETRENDERTARGETDATA {
-  ULONG_PTR                    dwhContext;
-  union {
-    LPDIRECTDRAWSURFACE                lpDDS;
-    LPDDRAWI_DDRAWSURFACE_LCL  lpDDSLcl;
+  ULONG_PTR dwhContext;
+  _ANONYMOUS_UNION union {
+    LPDIRECTDRAWSURFACE lpDDS;
+    LPDDRAWI_DDRAWSURFACE_LCL lpDDSLcl;
   } DUMMYUNIONNAME1;
-  union {
-    LPDIRECTDRAWSURFACE                lpDDSZ;
-    LPDDRAWI_DDRAWSURFACE_LCL  lpDDSZLcl;
+  _ANONYMOUS_UNION union {
+    LPDIRECTDRAWSURFACE lpDDSZ;
+    LPDDRAWI_DDRAWSURFACE_LCL lpDDSZLcl;
   } DUMMYUNIONNAME2;
-  HRESULT                      ddrval;
+  HRESULT ddrval;
 } D3DHAL_SETRENDERTARGETDATA;
 
 typedef struct _D3DHAL_DRAWPRIMITIVES2DATA {
-  ULONG_PTR                    dwhContext;
-  DWORD                                dwFlags;
-  DWORD                                dwVertexType;
-  LPDDRAWI_DDRAWSURFACE_LCL    lpDDCommands;
-  DWORD                                dwCommandOffset;
-  DWORD                                dwCommandLength;
-  union {
-    LPDDRAWI_DDRAWSURFACE_LCL  lpDDVertex;
-    LPVOID                     lpVertices;
+  ULONG_PTR dwhContext;
+  DWORD dwFlags;
+  DWORD dwVertexType;
+  LPDDRAWI_DDRAWSURFACE_LCL lpDDCommands;
+  DWORD dwCommandOffset;
+  DWORD dwCommandLength;
+  _ANONYMOUS_UNION union {
+    LPDDRAWI_DDRAWSURFACE_LCL lpDDVertex;
+    LPVOID lpVertices;
   } DUMMYUNIONNAME1;
-  DWORD                                dwVertexOffset;
-  DWORD                                dwVertexLength;
-  DWORD                                dwReqVertexBufSize;
-  DWORD                                dwReqCommandBufSize;
-  LPDWORD                      lpdwRStates;
-  union {
-    DWORD                      dwVertexSize;
-    HRESULT                    ddrval;
+  DWORD dwVertexOffset;
+  DWORD dwVertexLength;
+  DWORD dwReqVertexBufSize;
+  DWORD dwReqCommandBufSize;
+  LPDWORD lpdwRStates;
+  _ANONYMOUS_UNION union {
+    DWORD dwVertexSize;
+    HRESULT ddrval;
   } DUMMYUNIONNAME2;
-  DWORD                                dwErrorOffset;
+  DWORD dwErrorOffset;
 } D3DHAL_DRAWPRIMITIVES2DATA;
 
-#define D3DHALDP2_USERMEMVERTICES      0x00000001
-#define D3DHALDP2_EXECUTEBUFFER                0x00000002
-#define D3DHALDP2_SWAPVERTEXBUFFER     0x00000004
-#define D3DHALDP2_SWAPCOMMANDBUFFER    0x00000008
-#define D3DHALDP2_REQVERTEXBUFSIZE     0x00000010
-#define D3DHALDP2_REQCOMMANDBUFSIZE    0x00000020
-#define D3DHALDP2_VIDMEMVERTEXBUF      0x00000040
-#define D3DHALDP2_VIDMEMCOMMANDBUF     0x00000080
+#define D3DHALDP2_USERMEMVERTICES   0x00000001
+#define D3DHALDP2_EXECUTEBUFFER     0x00000002
+#define D3DHALDP2_SWAPVERTEXBUFFER  0x00000004
+#define D3DHALDP2_SWAPCOMMANDBUFFER 0x00000008
+#define D3DHALDP2_REQVERTEXBUFSIZE  0x00000010
+#define D3DHALDP2_REQCOMMANDBUFSIZE 0x00000020
+#define D3DHALDP2_VIDMEMVERTEXBUF   0x00000040
+#define D3DHALDP2_VIDMEMCOMMANDBUF  0x00000080
 
 /*****************************************************************************
  * DrawPrimitives2 command structures
@@ -331,50 +322,50 @@ typedef struct _D3DHAL_DRAWPRIMITIVES2DATA {
 typedef struct _D3DHAL_DP2COMMAND {
   BYTE bCommand;
   BYTE bReserved;
-  union {
+  _ANONYMOUS_UNION union {
     WORD wPrimitiveCount;
     WORD wStateCount;
   } DUMMYUNIONNAME;
-} D3DHAL_DP2COMMAND,*LPD3DHAL_DP2COMMAND;
+} D3DHAL_DP2COMMAND, *LPD3DHAL_DP2COMMAND;
 
 typedef enum _D3DHAL_DP2OPERATION {
-  D3DDP2OP_POINTS              = 1,
-  D3DDP2OP_INDEXEDLINELIST     = 2,
-  D3DDP2OP_INDEXEDTRIANGLELIST = 3,
-  D3DDP2OP_RENDERSTATE         = 8,
-  D3DDP2OP_LINELIST            = 15,
-  D3DDP2OP_LINESTRIP           = 16,
-  D3DDP2OP_INDEXEDLINESTRIP    = 17,
-  D3DDP2OP_TRIANGLELIST                = 18,
-  D3DDP2OP_TRIANGLESTRIP       = 19,
-  D3DDP2OP_INDEXEDTRIANGLESTRIP        = 20,
-  D3DDP2OP_TRIANGLEFAN         = 21,
-  D3DDP2OP_INDEXEDTRIANGLEFAN  = 22,
-  D3DDP2OP_TRIANGLEFAN_IMM     = 23,
-  D3DDP2OP_LINELIST_IMM                = 24,
-  D3DDP2OP_TEXTURESTAGESTATE   = 25,
-  D3DDP2OP_INDEXEDTRIANGLELIST2        = 26,
-  D3DDP2OP_INDEXEDLINELIST2    = 27,
-  D3DDP2OP_VIEWPORTINFO                = 28,
-  D3DDP2OP_WINFO               = 29,
+  D3DDP2OP_POINTS = 1,
+  D3DDP2OP_INDEXEDLINELIST = 2,
+  D3DDP2OP_INDEXEDTRIANGLELIST = 3,
+  D3DDP2OP_RENDERSTATE = 8,
+  D3DDP2OP_LINELIST = 15,
+  D3DDP2OP_LINESTRIP = 16,
+  D3DDP2OP_INDEXEDLINESTRIP = 17,
+  D3DDP2OP_TRIANGLELIST = 18,
+  D3DDP2OP_TRIANGLESTRIP = 19,
+  D3DDP2OP_INDEXEDTRIANGLESTRIP = 20,
+  D3DDP2OP_TRIANGLEFAN = 21,
+  D3DDP2OP_INDEXEDTRIANGLEFAN = 22,
+  D3DDP2OP_TRIANGLEFAN_IMM = 23,
+  D3DDP2OP_LINELIST_IMM = 24,
+  D3DDP2OP_TEXTURESTAGESTATE = 25,
+  D3DDP2OP_INDEXEDTRIANGLELIST2 = 26,
+  D3DDP2OP_INDEXEDLINELIST2 = 27,
+  D3DDP2OP_VIEWPORTINFO = 28,
+  D3DDP2OP_WINFO = 29,
   /* pre-DirectX 7 interfaces */
-  D3DDP2OP_SETPALETTE          = 30,
-  D3DDP2OP_UPDATEPALETTE       = 31,
+  D3DDP2OP_SETPALETTE = 30,
+  D3DDP2OP_UPDATEPALETTE = 31,
   /* DirectX 7 interfaces */
-  D3DDP2OP_ZRANGE              = 32,
-  D3DDP2OP_SETMATERIAL         = 33,
-  D3DDP2OP_SETLIGHT            = 34,
-  D3DDP2OP_CREATELIGHT         = 35,
-  D3DDP2OP_SETTRANSFORM                = 36,
-  D3DDP2OP_TEXBLT              = 38,
-  D3DDP2OP_STATESET            = 39,
-  D3DDP2OP_SETPRIORITY         = 40,
+  D3DDP2OP_ZRANGE = 32,
+  D3DDP2OP_SETMATERIAL = 33,
+  D3DDP2OP_SETLIGHT = 34,
+  D3DDP2OP_CREATELIGHT = 35,
+  D3DDP2OP_SETTRANSFORM = 36,
+  D3DDP2OP_TEXBLT = 38,
+  D3DDP2OP_STATESET = 39,
+  D3DDP2OP_SETPRIORITY = 40,
   /* all interfaces */
-  D3DDP2OP_SETRENDERTARGET     = 41,
-  D3DDP2OP_CLEAR               = 42,
+  D3DDP2OP_SETRENDERTARGET = 41,
+  D3DDP2OP_CLEAR = 42,
   /* DirectX 7 interfaces */
-  D3DDP2OP_SETTEXLOD           = 43,
-  D3DPP2OP_SETCLIPPLANE                = 44,
+  D3DDP2OP_SETTEXLOD = 43,
+  D3DPP2OP_SETCLIPPLANE = 44,
 #if(DIRECT3D_VERSION >= 0x0800)
   D3DDP2OP_CREATEVERTEXSHADER   = 45,
   D3DDP2OP_DELETEVERTEXSHADER   = 46,
@@ -433,84 +424,84 @@ typedef enum _D3DHAL_DP2OPERATION {
 typedef struct _D3DHAL_POINTS {
   WORD wCount;
   WORD wVStart;
-} D3DHAL_DP2POINTS,*LPD3DHAL_DP2POINTS;
+} D3DHAL_DP2POINTS, *LPD3DHAL_DP2POINTS;
 
 /* line primitives */
 
 typedef struct _D3DHAL_DP2STARTVERTEX {
   WORD wVStart;
-} D3DHAL_DP2STARTVERTEX,*LPD3DHAL_DP2STARTVERTEX;
+} D3DHAL_DP2STARTVERTEX, *LPD3DHAL_DP2STARTVERTEX;
 
 typedef struct _D3DHAL_DP2LINELIST {
   WORD wVStart;
-} D3DHAL_DP2LINELIST,*LPD3DHAL_DP2LINELIST;
+} D3DHAL_DP2LINELIST, *LPD3DHAL_DP2LINELIST;
 
 typedef struct _D3DHAL_DP2INDEXEDLINELIST {
   WORD wV1;
   WORD wV2;
-} D3DHAL_DP2INDEXEDLINELIST,*LPD3DHAL_DP2INDEXEDLINELIST;
+} D3DHAL_DP2INDEXEDLINELIST, *LPD3DHAL_DP2INDEXEDLINELIST;
 
 typedef struct _D3DHAL_DP2LINESTRIP {
   WORD wVStart;
-} D3DHAL_DP2LINESTRIP,*LPD3DHAL_DP2LINESTRIP;
+} D3DHAL_DP2LINESTRIP, *LPD3DHAL_DP2LINESTRIP;
 
 typedef struct _D3DHAL_DP2INDEXEDLINESTRIP {
   WORD wV[2];
-} D3DHAL_DP2INDEXEDLINESTRIP,*LPD3DHAL_DP2INDEXEDLINESTRIP;
+} D3DHAL_DP2INDEXEDLINESTRIP, *LPD3DHAL_DP2INDEXEDLINESTRIP;
 
 /* triangle primitives */
 
 typedef struct _D3DHAL_DP2TRIANGLELIST {
   WORD wVStart;
-} D3DHAL_DP2TRIANGLELIST,*LPD3DHAL_DP2TRIANGLELIST;
+} D3DHAL_DP2TRIANGLELIST, *LPD3DHAL_DP2TRIANGLELIST;
 
 typedef struct _D3DHAL_DP2INDEXEDTRIANGLELIST {
   WORD wV1;
   WORD wV2;
   WORD wV3;
   WORD wFlags;
-} D3DHAL_DP2INDEXEDTRIANGLELIST,*LPD3DHAL_DP2INDEXEDTRIANGLELIST;
+} D3DHAL_DP2INDEXEDTRIANGLELIST, *LPD3DHAL_DP2INDEXEDTRIANGLELIST;
 
 typedef struct _D3DHAL_DP2INDEXEDTRIANGLELIST2 {
   WORD wV1;
   WORD wV2;
   WORD wV3;
-} D3DHAL_DP2INDEXEDTRIANGLELIST2,*LPD3DHAL_DP2INDEXEDTRIANGLELIST2;
+} D3DHAL_DP2INDEXEDTRIANGLELIST2, *LPD3DHAL_DP2INDEXEDTRIANGLELIST2;
 
 typedef struct _D3DHAL_DP2TRIANGLESTRIP {
   WORD wVStart;
-} D3DHAL_DP2TRIANGLESTRIP,*LPD3DHAL_DP2TRIANGLESTRIP;
+} D3DHAL_DP2TRIANGLESTRIP, *LPD3DHAL_DP2TRIANGLESTRIP;
 
 typedef struct _D3DHAL_DP2INDEXEDTRIANGLESTRIP {
   WORD wV[3];
-} D3DHAL_DP2INDEXEDTRIANGLESTRIP,*LPD3DHAL_DP2INDEXEDTRIANGLESTRIP;
+} D3DHAL_DP2INDEXEDTRIANGLESTRIP, *LPD3DHAL_DP2INDEXEDTRIANGLESTRIP;
 
 typedef struct _D3DHAL_DP2TRIANGLEFAN {
   WORD wVStart;
-} D3DHAL_DP2TRIANGLEFAN,*LPD3DHAL_DP2TRIANGLEFAN;
+} D3DHAL_DP2TRIANGLEFAN, *LPD3DHAL_DP2TRIANGLEFAN;
 
 typedef struct _D3DHAL_DP2INDEXEDTRIANGLEFAN {
   WORD wV[3];
-} D3DHAL_DP2INDEXEDTRIANGLEFAN,*LPD3DHAL_DP2INDEXEDTRIANGLEFAN;
+} D3DHAL_DP2INDEXEDTRIANGLEFAN, *LPD3DHAL_DP2INDEXEDTRIANGLEFAN;
 
 typedef struct _D3DHAL_DP2TRIANGLEFAN_IMM {
   DWORD dwEdgeFlags;
-} D3DHAL_DP2TRIANGLEFAN_IMM,*LPD3DHAL_DP2TRIANGLEFAN_IMM;
+} D3DHAL_DP2TRIANGLEFAN_IMM, *LPD3DHAL_DP2TRIANGLEFAN_IMM;
 
 /* render states */
 typedef struct _D3DHAL_DP2RENDERSTATE {
-  D3DRENDERSTATETYPE   RenderState;
-  union {
+  D3DRENDERSTATETYPE RenderState;
+  _ANONYMOUS_UNION union {
     D3DVALUE dvState;