[ros-diffs] [tkreuzer] 49767: [KERNEL32] Revert r49761 on Pierre's request

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed Nov 24 12:35:52 UTC 2010


Author: tkreuzer
Date: Wed Nov 24 12:35:51 2010
New Revision: 49767

URL: http://svn.reactos.org/svn/reactos?rev=49767&view=rev
Log:
[KERNEL32]
Revert r49761 on Pierre's request

Modified:
    trunk/reactos/dll/win32/kernel32/include/kernel32.h
    trunk/reactos/dll/win32/kernel32/kernel32.def
    trunk/reactos/dll/win32/kernel32/misc/env.c
    trunk/reactos/dll/win32/kernel32/misc/error.c
    trunk/reactos/dll/win32/kernel32/misc/ldr.c
    trunk/reactos/dll/win32/kernel32/misc/utils.c
    trunk/reactos/dll/win32/kernel32/process/procsup.c

Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include/kernel32.h?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -69,6 +69,7 @@
   
 #define SetLastErrorByStatus(x) RtlSetLastWin32ErrorAndNtStatusFromNtStatus((x))
 #define GetLastError()          NtCurrentTeb()->LastErrorValue
+#define SetLastError(x)         NtCurrentTeb()->LastErrorValue = (x)
 
 typedef struct _CODEPAGE_ENTRY
 {
@@ -191,7 +192,7 @@
                                    
 PUNICODE_STRING
 WINAPI
-Basep8BitStringToStaticUnicodeString(IN LPCSTR AnsiString);
+Basep8BitStringToCachedUnicodeString(IN LPCSTR String);
 
 NTSTATUS
 WINAPI
@@ -224,7 +225,3 @@
 VOID
 WINAPI
 InitCommandLines(VOID);
-
-VOID
-WINAPI
-BaseSetLastNTError(IN NTSTATUS Status);

Modified: trunk/reactos/dll/win32/kernel32/kernel32.def
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/kernel32.def?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/kernel32.def [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/kernel32.def [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -46,7 +46,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 (present on w2k3 but not exported)
+;@ stdcall BaseSetLastNTError ; Win 7, not 64 bit
 @ stdcall BaseUpdateAppcompatCache(long long long)
 ;@ stdcall BaseVerifyUnicodeString ; Win 7
 ;@ stdcall Basep8BitStringToDynamicUnicodeString ; Win 7
@@ -1211,7 +1211,7 @@
 @ stdcall SetHandleInformation(long long long)
 @ stdcall SetInformationJobObject(long long ptr long)
 @ stub SetLastConsoleEventActive ; missing in XP SP3
-@ stdcall SetLastError(long)
+@ stdcall SetLastError(long) ntdll.RtlSetLastWin32Error
 @ stub SetLocalPrimaryComputerNameA ; missing in XP SP3
 @ stub SetLocalPrimaryComputerNameW ; missing in XP SP3
 @ stdcall SetLocalTime(ptr)

Modified: trunk/reactos/dll/win32/kernel32/misc/env.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/env.c?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/env.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/env.c [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -5,8 +5,6 @@
  * FILE:            lib/kernel32/misc/env.c
  * PURPOSE:         Environment functions
  * PROGRAMMER:      Ariadne ( ariadne at xs4all.nl)
- *                  Emanuele Aliberti
- *                  Thomas Weidenmueller
  * UPDATE HISTORY:
  *                  Created 01/11/98
  */
@@ -18,85 +16,6 @@
 
 
 /* FUNCTIONS ******************************************************************/
-
-/*
- * @implemented
- */
-BOOL
-WINAPI
-Beep (DWORD dwFreq, DWORD dwDuration)
-{
-    HANDLE hBeep;
-    UNICODE_STRING BeepDevice;
-    OBJECT_ATTRIBUTES ObjectAttributes;
-    IO_STATUS_BLOCK IoStatusBlock;
-    BEEP_SET_PARAMETERS BeepSetParameters;
-    NTSTATUS Status;
-
-    /* check the parameters */
-    if ((dwFreq >= 0x25 && dwFreq <= 0x7FFF) ||
-        (dwFreq == 0x0 && dwDuration == 0x0))
-    {
-        /* open the device */
-        RtlInitUnicodeString(&BeepDevice,
-                             L"\\Device\\Beep");
-
-        InitializeObjectAttributes(&ObjectAttributes,
-                                   &BeepDevice,
-                                   0,
-                                   NULL,
-                                   NULL);
-
-        Status = NtCreateFile(&hBeep,
-                              FILE_READ_DATA | FILE_WRITE_DATA,
-                              &ObjectAttributes,
-                              &IoStatusBlock,
-                              NULL,
-                              0,
-                              FILE_SHARE_READ | FILE_SHARE_WRITE,
-                              FILE_OPEN_IF,
-                              0,
-                              NULL,
-                              0);
-        if (NT_SUCCESS(Status))
-        {
-            /* Set beep data */
-            BeepSetParameters.Frequency = dwFreq;
-            BeepSetParameters.Duration = dwDuration;
-
-            Status = NtDeviceIoControlFile(hBeep,
-                                           NULL,
-                                           NULL,
-                                           NULL,
-                                           &IoStatusBlock,
-                                           IOCTL_BEEP_SET,
-                                           &BeepSetParameters,
-                                           sizeof(BEEP_SET_PARAMETERS),
-                                           NULL,
-                                           0);
-
-            /* do an alertable wait if necessary */
-            if (NT_SUCCESS(Status) &&
-                (dwFreq != 0x0 || dwDuration != 0x0) && dwDuration != MAXDWORD)
-            {
-                SleepEx(dwDuration,
-                        TRUE);
-            }
-
-            NtClose(hBeep);
-        }
-    }
-    else
-        Status = STATUS_INVALID_PARAMETER;
-
-    if (!NT_SUCCESS(Status))
-    {
-        SetLastErrorByStatus (Status);
-        return FALSE;
-    }
-
-    return TRUE;
-}
 
 /*
  * @implemented

Modified: trunk/reactos/dll/win32/kernel32/misc/error.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/error.c?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/error.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/error.c [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -1,10 +1,15 @@
-/*
+/* $Id$
+ *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  * FILE:            dll/win32/kernel32/misc/error.c
- * PURPOSE:         Error functions
- * PROGRAMMER:      Pierre Schweitzer (pierre.schweitzer at reactos.org)
+ * PURPOSE:         Environment functions
+ * PROGRAMMER:      Emanuele Aliberti
+ *                  Thomas Weidenmueller
+ * UPDATE HISTORY:
+ *                  Created 05/10/98
  */
+
 
 #include <k32.h>
 
@@ -12,34 +17,83 @@
 #include <debug.h>
 
 
-DWORD g_dwLastErrorToBreakOn;
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+Beep (DWORD dwFreq, DWORD dwDuration)
+{
+    HANDLE hBeep;
+    UNICODE_STRING BeepDevice;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    IO_STATUS_BLOCK IoStatusBlock;
+    BEEP_SET_PARAMETERS BeepSetParameters;
+    NTSTATUS Status;
 
-/* FUNCTIONS ******************************************************************/
+    /* check the parameters */
+    if ((dwFreq >= 0x25 && dwFreq <= 0x7FFF) ||
+        (dwFreq == 0x0 && dwDuration == 0x0))
+    {
+        /* open the device */
+        RtlInitUnicodeString(&BeepDevice,
+                             L"\\Device\\Beep");
 
-VOID
-WINAPI
-SetLastError(
-    IN DWORD dwErrCode)
-{
-    if (g_dwLastErrorToBreakOn)
-    {
-        /* If we have error to break on and if current matches, break */
-        if (g_dwLastErrorToBreakOn == dwErrCode)
+        InitializeObjectAttributes(&ObjectAttributes,
+                                   &BeepDevice,
+                                   0,
+                                   NULL,
+                                   NULL);
+
+        Status = NtCreateFile(&hBeep,
+                              FILE_READ_DATA | FILE_WRITE_DATA,
+                              &ObjectAttributes,
+                              &IoStatusBlock,
+                              NULL,
+                              0,
+                              FILE_SHARE_READ | FILE_SHARE_WRITE,
+                              FILE_OPEN_IF,
+                              0,
+                              NULL,
+                              0);
+        if (NT_SUCCESS(Status))
         {
-            DbgBreakPoint();
+            /* Set beep data */
+            BeepSetParameters.Frequency = dwFreq;
+            BeepSetParameters.Duration = dwDuration;
+
+            Status = NtDeviceIoControlFile(hBeep,
+                                           NULL,
+                                           NULL,
+                                           NULL,
+                                           &IoStatusBlock,
+                                           IOCTL_BEEP_SET,
+                                           &BeepSetParameters,
+                                           sizeof(BEEP_SET_PARAMETERS),
+                                           NULL,
+                                           0);
+
+            /* do an alertable wait if necessary */
+            if (NT_SUCCESS(Status) &&
+                (dwFreq != 0x0 || dwDuration != 0x0) && dwDuration != MAXDWORD)
+            {
+                SleepEx(dwDuration,
+                        TRUE);
+            }
+
+            NtClose(hBeep);
         }
     }
+    else
+        Status = STATUS_INVALID_PARAMETER;
 
-    /* Set last error */
-    NtCurrentTeb()->LastErrorValue = dwErrCode;
-}
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus (Status);
+        return FALSE;
+    }
 
-VOID
-WINAPI
-BaseSetLastNTError(
-    IN NTSTATUS Status)
-{
-    SetLastError(RtlNtStatusToDosError(Status));
+    return TRUE;
 }
 
 /* EOF */

Modified: trunk/reactos/dll/win32/kernel32/misc/ldr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/ldr.c?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/ldr.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/ldr.c [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -102,18 +102,19 @@
  */
 BOOL
 WINAPI
-DisableThreadLibraryCalls(
-    IN HMODULE hLibModule)
-{
-    NTSTATUS Status;
-
-    Status = LdrDisableThreadCalloutsForDll((PVOID)hLibModule);
-    if (!NT_SUCCESS(Status))
-    {
-        BaseSetLastNTError(Status);
-        return FALSE;
-    }
-    return TRUE;
+DisableThreadLibraryCalls (
+	HMODULE	hLibModule
+	)
+{
+	NTSTATUS Status;
+
+	Status = LdrDisableThreadCalloutsForDll ((PVOID)hLibModule);
+	if (!NT_SUCCESS (Status))
+	{
+		SetLastErrorByStatus (Status);
+		return FALSE;
+	}
+	return TRUE;
 }
 
 
@@ -135,17 +136,18 @@
  */
 HINSTANCE
 WINAPI
-LoadLibraryExA(
-    LPCSTR lpLibFileName,
-    HANDLE hFile,
-    DWORD dwFlags)
-{
-   PUNICODE_STRING FileNameW;
-
-    if (!(FileNameW = Basep8BitStringToStaticUnicodeString(lpLibFileName)))
-        return NULL;
-
-    return LoadLibraryExW(FileNameW->Buffer, hFile, dwFlags);
+LoadLibraryExA (
+	LPCSTR	lpLibFileName,
+	HANDLE	hFile,
+	DWORD	dwFlags
+	)
+{
+   PWCHAR FileNameW;
+
+   if (!(FileNameW = FilenameA2W(lpLibFileName, FALSE)))
+      return FALSE;
+
+   return LoadLibraryExW(FileNameW, hFile, dwFlags);
 }
 
 

Modified: trunk/reactos/dll/win32/kernel32/misc/utils.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/utils.c?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/utils.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/utils.c [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -57,27 +57,28 @@
  */
 PUNICODE_STRING
 WINAPI
-Basep8BitStringToStaticUnicodeString(IN LPCSTR String)
-{
-    PUNICODE_STRING StaticString = &(NtCurrentTeb()->StaticUnicodeString);
+Basep8BitStringToCachedUnicodeString(IN LPCSTR String)
+{
+    PUNICODE_STRING StaticString = &NtCurrentTeb()->StaticUnicodeString;
     ANSI_STRING AnsiString;
     NTSTATUS Status;
-
+    
+    DPRINT("Basep8BitStringToCachedUnicodeString\n");
+    
     /* Initialize an ANSI String */
-    if (!NT_SUCCESS(RtlInitAnsiStringEx(&AnsiString, String)))
-    {
-        SetLastError(ERROR_FILENAME_EXCED_RANGE);
-        return NULL;
-    }
-
+    RtlInitAnsiString(&AnsiString, String);
+    
     /* Convert it */
     Status = Basep8BitStringToUnicodeString(StaticString, &AnsiString, FALSE);
-    if (!NT_SUCCESS(Status))
-    {
-        BaseSetLastNTError(Status);
+    
+    /* Handle failure */
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
         return NULL;
     }
-
+    
+    /* Return pointer to the string */
     return StaticString;
 }
 

Modified: trunk/reactos/dll/win32/kernel32/process/procsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process/procsup.c?rev=49767&r1=49766&r2=49767&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/process/procsup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/process/procsup.c [iso-8859-1] Wed Nov 24 12:35:51 2010
@@ -1558,7 +1558,7 @@
             NtCurrentTeb()->StaticUnicodeString.MaximumLength)
         {
             /* Cache it in the TEB */
-            CommandLine = Basep8BitStringToStaticUnicodeString(lpCommandLine);
+            CommandLine = Basep8BitStringToCachedUnicodeString(lpCommandLine);
         }
         else
         {




More information about the Ros-diffs mailing list