Changelog:
* Added basic working stubs of new Windows 2000 API functions.

This patch provides working stubs for some of the new Windows 2000 API calls
as follows:

Terminal Server functions:
* RegOpenCurrentUser has been implemented by opening HKEY_CURRENT_USER  Both
dlls/advapi32/registry.c and memory/registry.c have been changed.  I used ""
as the path to open under HKEY_CURRENT_USER, should that be "\\" or is ""
okay?
* GetSystemWindowsDirectory[AW] calls GetWindowsDirectory[AW].  I chose to
stub out the function rather than forward because it may be usefull when
packaging wine for this to be a different directory, see MSDN documentation
on this function for details.
* ProcessIdToSessionId returns 0 in all cases per MSDN docs.

CriticalSection:
* InitializeCriticalSectionAndSpinCount - Calls
RtlInitializeCriticalSectionAndSpinCount function like
InitializeCriticalSection.  Returns TRUE if no error occured, false if an
error occured.  Since no errors can possibly occur at this time it will
always return TRUE.
* SetCriticalSectionSpinCount - Sets crit->SpinCount
* RtlInitializeCriticalSectionAndSpinCount - Sets crit->SpinCount then calls
RtlInitializeCriticalSection.
The above functions are related to SMP.  On a uniprocessor windows sytem,
the spincount is always zero.  For now these functions will actually set the
spincount, but since it's not used by anything in the wine core, they
basically do nothing.  They print FIXME's when used with spincounts other
than 0.

User32:
* GetClipboardSequenceNumber - This is a stub returning 0 per MSDN docs.
This deserves a real implementation at some point, but is not a
high-priority thing.
* AllowSetForegroundWindow - This is a stub returning TRUE.  This function
relates to the changes in focus behavior for Win98/win2k.  The new focus
behavior requires certain conditions to be met for a process to grab the
foreground focus with SetForegroundWindow.  This function allows a program
that is running in the foreground to give another process the ability to set
the foreground window like would have been allowed in older versions of
windows.
* LockSetForegroundWindow - Ditto except this function disallows all other
programs to grab the foreground with SetForegroundWindow until the user
switches away from the window for the program that called this function.

Other
* _ultow - Added @ stub entry to ntdll.spec
* strtol - Added @ cdecl entry using libc's strtol to ntdll.spec

-Dave
Index: dlls/advapi32/advapi32.spec
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/advapi32.spec,v
retrieving revision 1.12
diff -u -r1.12 advapi32.spec
--- dlls/advapi32/advapi32.spec 2000/10/24 01:39:29     1.12
+++ dlls/advapi32/advapi32.spec 2000/10/27 10:13:55
@@ -191,6 +191,7 @@
 @ stdcall RegLoadKeyA(long str str) RegLoadKeyA
 @ stdcall RegLoadKeyW(long wstr wstr) RegLoadKeyW
 @ stdcall RegNotifyChangeKeyValue(long long long long long) RegNotifyChangeKeyValue
+@ stdcall RegOpenCurrentUser(long ptr) RegOpenCurrentUser
 @ stdcall RegOpenKeyA(long str ptr) RegOpenKeyA
 @ stdcall RegOpenKeyExA(long str long long ptr) RegOpenKeyExA
 @ stdcall RegOpenKeyExW(long wstr long long ptr) RegOpenKeyExW
Index: dlls/advapi32/registry.c
===================================================================
RCS file: /home/wine/wine/dlls/advapi32/registry.c,v
retrieving revision 1.15
diff -u -r1.15 registry.c
--- dlls/advapi32/registry.c    2000/10/15 00:40:25     1.15
+++ dlls/advapi32/registry.c    2000/10/27 10:13:58
@@ -248,6 +248,19 @@
 }
 
 
+/******************************************************************************
+ *           RegOpenCurrentUser   [ADVAPI32]
+ * FIXME: This function is supposed to retrieve a handle to the
+ * HKEY_CURRENT_USER for the user the current thread is impersonating.
+ * Since Wine does not currently allow threads to impersonate other users,
+ * this stub should work fine.
+ */
+DWORD WINAPI RegOpenCurrentUser( REGSAM access, PHKEY retkey )
+{
+    return RegOpenKeyExA( HKEY_CURRENT_USER, "", 0, access, retkey );
+}
+
+
 
 /******************************************************************************
  *           RegEnumKeyExW   [ADVAPI32.139]
Index: dlls/kernel/kernel32.spec
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel32.spec,v
retrieving revision 1.14
diff -u -r1.14 kernel32.spec
--- dlls/kernel/kernel32.spec   2000/10/23 21:39:39     1.14
+++ dlls/kernel/kernel32.spec   2000/10/27 10:14:02
@@ -928,3 +928,10 @@
 
 #1599 wrong ordinal (249 in Win32s's W32SCOMB.DLL) !
 1599 stdcall Get16DLLAddress(long str) Get16DLLAddress
+
+# Windows 2000, Terminal Server 4.0 SP4 functions
+@ stdcall GetSystemWindowsDirectoryA(ptr long) GetSystemWindowsDirectoryA
+@ stdcall GetSystemWindowsDirectoryW(ptr long) GetSystemWindowsDirectoryW
+@ stdcall InitializeCriticalSectionAndSpinCount(ptr long) 
+InitializeCriticalSectionAndSpinCount
+@ stdcall SetCriticalSectionSpinCount(ptr long) SetCriticalSectionSpinCount
+@ stdcall ProcessIdToSessionId(long ptr) ProcessIdToSessionId
Index: dlls/ntdll/critsection.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/critsection.c,v
retrieving revision 1.1
diff -u -r1.1 critsection.c
--- dlls/ntdll/critsection.c    2000/09/29 00:31:23     1.1
+++ dlls/ntdll/critsection.c    2000/10/27 10:14:03
@@ -148,6 +148,20 @@
     return STATUS_SUCCESS;
 }
 
+/***********************************************************************
+ *           RtlInitializeCriticalSectionAndSpinCount   (NTDLL.@)
+ * The InitializeCriticalSectionAndSpinCount (KERNEL32) function is
+ * available on NT4SP3 or later, and Win98 or later.
+ * I am assuming that this is the correct definition given the MSDN
+ * docs for the kernel32 functions.
+ */
+NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, 
+DWORD spincount )
+{
+    if(spincount) FIXME("critsection=%p: spincount=%ld not supported\n", crit, 
+spincount);
+    crit->SpinCount = spincount;
+    return RtlInitializeCriticalSection( crit );
+}
+
 
 /***********************************************************************
  *           RtlDeleteCriticalSection   (NTDLL.@)
Index: dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.26
diff -u -r1.26 ntdll.spec
--- dlls/ntdll/ntdll.spec       2000/10/13 20:26:03     1.26
+++ dlls/ntdll/ntdll.spec       2000/10/27 10:14:05
@@ -411,6 +411,7 @@
 @ stdcall RtlInitializeBitMap(long long long) RtlInitializeBitMap
 @ stub RtlInitializeContext
 @ stdcall RtlInitializeCriticalSection(ptr) RtlInitializeCriticalSection
+@ stdcall RtlInitializeCriticalSectionAndSpinCount(ptr long) 
+RtlInitializeCriticalSectionAndSpinCount
 @ stdcall RtlInitializeGenericTable() RtlInitializeGenericTable
 @ stub RtlInitializeRXact
 @ stdcall RtlInitializeResource(ptr) RtlInitializeResource
@@ -887,6 +888,7 @@
 @ cdecl _strnicmp(str str long) strncasecmp
 @ cdecl _strupr(str) _strupr
 @ cdecl _ultoa(long ptr long) _ultoa
+@ stub _ultow
 @ cdecl _vsnprintf(ptr long ptr ptr) vsnprintf
 @ cdecl _wcsicmp(wstr wstr) NTDLL__wcsicmp
 @ cdecl _wcslwr(wstr) NTDLL__wcslwr
@@ -936,6 +938,7 @@
 @ cdecl strrchr(str long) strrchr
 @ cdecl strspn(str str) strspn
 @ cdecl strstr(str str) strstr
+@ cdecl strtol(str ptr long) strtol
 @ varargs swprintf(wstr wstr) wsprintfW
 @ stub tan
 @ cdecl tolower(long) tolower
Index: dlls/user/user32.spec
===================================================================
RCS file: /home/wine/wine/dlls/user/user32.spec,v
retrieving revision 1.11
diff -u -r1.11 user32.spec
--- dlls/user/user32.spec       2000/10/23 21:39:39     1.11
+++ dlls/user/user32.spec       2000/10/27 10:14:08
@@ -642,3 +642,7 @@
 @ stdcall RegisterDeviceNotificationA(long ptr long) RegisterDeviceNotificationA
 @ stub    RegisterDeviceNotificationW
 @ stub    UnregisterDeviceNotification
+# win98/win2k
+@ stdcall GetClipboardSequenceNumber () GetClipboardSequenceNumber
+@ stdcall AllowSetForegroundWindow (long) AllowSetForegroundWindow
+@ stdcall LockSetForegroundWindow (long) LockSetForegroundWindow
Index: files/directory.c
===================================================================
RCS file: /home/wine/wine/files/directory.c,v
retrieving revision 1.26
diff -u -r1.26 directory.c
--- files/directory.c   2000/09/10 03:18:29     1.26
+++ files/directory.c   2000/10/27 10:14:11
@@ -283,6 +283,24 @@
 
 
 /***********************************************************************
+ *           GetSystemWindowsDirectoryA   (KERNEL32) W2K, TS4.0SP4
+ */
+UINT WINAPI GetSystemWindowsDirectoryA( LPSTR path, UINT count )
+{
+    return GetWindowsDirectoryA( path, count );
+}
+
+
+/***********************************************************************
+ *           GetSystemWindowsDirectoryW   (KERNEL32) W2K, TS4.0SP4
+ */
+UINT WINAPI GetSystemWindowsDirectoryW( LPWSTR path, UINT count )
+{
+    return GetWindowsDirectoryW( path, count );
+}
+
+
+/***********************************************************************
  *           GetSystemDirectory16   (KERNEL.135)
  */
 UINT16 WINAPI GetSystemDirectory16( LPSTR path, UINT16 count )
Index: include/ntddk.h
===================================================================
RCS file: /home/wine/wine/include/ntddk.h,v
retrieving revision 1.31
diff -u -r1.31 ntddk.h
--- include/ntddk.h     2000/10/15 00:39:11     1.31
+++ include/ntddk.h     2000/10/27 10:14:13
@@ -897,6 +897,7 @@
 NTSTATUS WINAPI NtSetEvent(HANDLE,PULONG);
 
 NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit );
+NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, 
+DWORD spincount );
 NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit );
 NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit );
 NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit );
Index: memory/registry.c
===================================================================
RCS file: /home/wine/wine/memory/registry.c,v
retrieving revision 1.8
diff -u -r1.8 registry.c
--- memory/registry.c   2000/10/15 00:40:29     1.8
+++ memory/registry.c   2000/10/27 10:14:17
@@ -248,6 +248,19 @@
 }
 
 
+/******************************************************************************
+ *           RegOpenCurrentUser   [ADVAPI32]
+ * FIXME: This function is supposed to retrieve a handle to the
+ * HKEY_CURRENT_USER for the user the current thread is impersonating.
+ * Since Wine does not currently allow threads to impersonate other users,
+ * this stub should work fine.
+ */
+DWORD WINAPI RegOpenCurrentUser( REGSAM access, PHKEY retkey )
+{
+    return RegOpenKeyExA( HKEY_CURRENT_USER, "", 0, access, retkey );
+}
+
+
 
 /******************************************************************************
  *           RegEnumKeyExW   [ADVAPI32.139]
Index: scheduler/critsection.c
===================================================================
RCS file: /home/wine/wine/scheduler/critsection.c,v
retrieving revision 1.23
diff -u -r1.23 critsection.c
--- scheduler/critsection.c     2000/09/29 20:48:05     1.23
+++ scheduler/critsection.c     2000/10/27 10:14:24
@@ -28,6 +28,29 @@
 }
 
 /***********************************************************************
+ *           InitializeCriticalSectionAndSpinCount   (KERNEL32)
+ */
+BOOL WINAPI InitializeCriticalSectionAndSpinCount( CRITICAL_SECTION *crit, DWORD 
+spincount )
+{
+    NTSTATUS ret = RtlInitializeCriticalSectionAndSpinCount( crit, spincount );
+    if (ret) RtlRaiseStatus( ret );
+    return !ret;
+}
+
+/***********************************************************************
+ *           SetCriticalSectionSpinCount   (KERNEL32)
+ * This function is available on NT4SP3 or later, but not Win98
+ * It is SMP related
+ */
+DWORD WINAPI SetCriticalSectionSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
+{
+    ULONG_PTR oldspincount = crit->SpinCount;
+    if(spincount) FIXME("critsection=%p: spincount=%ld not supported\n", crit, 
+spincount);
+    crit->SpinCount = spincount;
+    return oldspincount;
+}
+
+/***********************************************************************
  *           MakeCriticalSectionGlobal   (KERNEL32.515)
  */
 void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
Index: scheduler/thread.c
===================================================================
RCS file: /home/wine/wine/scheduler/thread.c,v
retrieving revision 1.77
diff -u -r1.77 thread.c
--- scheduler/thread.c  2000/08/31 01:59:52     1.77
+++ scheduler/thread.c  2000/10/27 10:14:26
@@ -844,6 +844,20 @@
 }
 
 
+/***********************************************************************
+ * ProcessIdToSessionId   (KERNEL32)
+ * This function is available on Terminal Server 4SP4 and Windows 2000
+ */
+BOOL WINAPI ProcessIdToSessionId( DWORD procid, DWORD *sessionid_ptr )
+{
+       /* According to MSDN, if the calling process is not in a terminal
+        * services environment, then the sessionid returned is zero.
+        */
+       *sessionid_ptr = 0;
+       return TRUE;
+}
+
+
 #ifdef __i386__
 
 /* void WINAPI SetLastError( DWORD error ); */
Index: windows/clipboard.c
===================================================================
RCS file: /home/wine/wine/windows/clipboard.c,v
retrieving revision 1.26
diff -u -r1.26 clipboard.c
--- windows/clipboard.c 2000/09/25 23:31:07     1.26
+++ windows/clipboard.c 2000/10/27 10:14:30
@@ -1297,3 +1297,19 @@
     return -1;
 }
 
+
+/**************************************************************************
+ *             GetClipboardSequenceNumber   (USER32)
+ * Supported on Win2k/Win98
+ * MSDN: Windows clipboard code keeps a serial number for the clipboard
+ * for each window station.  The number is incremented whenever the
+ * contents change or are emptied.
+ * If you do not have WINSTA_ACCESSCLIPBOARD then the function returns 0
+ */
+DWORD WINAPI GetClipboardSequenceNumber(VOID)
+{
+       FIXME("Returning 0, see windows/clipboard.c\n");
+       /* FIXME: Use serial numbers */
+       return 0;
+}
+
Index: windows/winpos.c
===================================================================
RCS file: /home/wine/wine/windows/winpos.c,v
retrieving revision 1.76
diff -u -r1.76 winpos.c
--- windows/winpos.c    2000/10/25 20:29:06     1.76
+++ windows/winpos.c    2000/10/27 10:14:36
@@ -986,6 +986,28 @@
 
 
 /*******************************************************************
+ *         AllowSetForegroundWindow    (USER32)
+ */
+BOOL WINAPI AllowSetForegroundWindow( DWORD procid )
+{
+    /* FIXME: If Win98/2000 style SetForegroundWindow behavoir is
+     * implemented, then fix this function. */
+    return TRUE;
+}
+
+
+/*******************************************************************
+ *         LockSetForegroundWindow    (USER32)
+ */
+BOOL WINAPI LockSetForegroundWindow( UINT lockcode )
+{
+    /* FIXME: If Win98/2000 style SetForegroundWindow behavoir is
+     * implemented, then fix this function. */
+    return TRUE;
+}
+
+
+/*******************************************************************
  *         GetShellWindow16    (USER.600)
  */
 HWND16 WINAPI GetShellWindow16(void)

Reply via email to