ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2005
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
609 discussions
Start a n
N
ew thread
[navaraf] 14285: Merge from HEAD: r14230
by navaraf@svn.reactos.com
Merge from HEAD: r14230 Don't use uninitialized variable in _SHExpandEnvironmentStrings. Modified: branches/ros-branch-0_2_6/reactos/lib/shell32/shellpath.c _____ Modified: branches/ros-branch-0_2_6/reactos/lib/shell32/shellpath.c --- branches/ros-branch-0_2_6/reactos/lib/shell32/shellpath.c 2005-03-23 17:19:12 UTC (rev 14284) +++ branches/ros-branch-0_2_6/reactos/lib/shell32/shellpath.c 2005-03-23 17:19:36 UTC (rev 14285) @@ -1522,7 +1522,7 @@ */ static HRESULT _SHExpandEnvironmentStrings(LPCWSTR szSrc, LPWSTR szDest) { - HRESULT hr; + HRESULT hr = S_OK; WCHAR szTemp[MAX_PATH], szProfilesPrefix[MAX_PATH] = { 0 }; TRACE("%s, %p\n", debugstr_w(szSrc), szDest);
19 years, 9 months
1
0
0
0
[navaraf] 14284: Merge from HEAD: r14219, r14220
by navaraf@svn.reactos.com
Merge from HEAD: r14219, r14220 Allow the lpTemplateDirectory parameter to be NULL in CreateDirectoryExA. Modified: branches/ros-branch-0_2_6/reactos/lib/kernel32/file/dir.c _____ Modified: branches/ros-branch-0_2_6/reactos/lib/kernel32/file/dir.c --- branches/ros-branch-0_2_6/reactos/lib/kernel32/file/dir.c 2005-03-23 17:12:58 UTC (rev 14283) +++ branches/ros-branch-0_2_6/reactos/lib/kernel32/file/dir.c 2005-03-23 17:19:12 UTC (rev 14284) @@ -50,11 +50,12 @@ LPCSTR lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes) { - PWCHAR TemplateDirectoryW; - PWCHAR NewDirectoryW; + PWCHAR TemplateDirectoryW = NULL; + PWCHAR NewDirectoryW = NULL; BOOL ret; - if (!(TemplateDirectoryW = FilenameA2W(lpTemplateDirectory, FALSE))) + if (lpTemplateDirectory != NULL && + !(TemplateDirectoryW = FilenameA2W(lpTemplateDirectory, FALSE))) return FALSE; if (!(NewDirectoryW = FilenameA2W(lpNewDirectory, TRUE)))
19 years, 9 months
1
0
0
0
[navaraf] 14283: Merge from HEAD: r14209
by navaraf@svn.reactos.com
Merge from HEAD: r14209 Minor correction to NtAdjustPrivilegesToken to keep it from returning total junk. Modified: branches/ros-branch-0_2_6/reactos/ntoskrnl/mm/marea.c Modified: branches/ros-branch-0_2_6/reactos/ntoskrnl/se/token.c _____ Modified: branches/ros-branch-0_2_6/reactos/ntoskrnl/mm/marea.c --- branches/ros-branch-0_2_6/reactos/ntoskrnl/mm/marea.c 2005-03-23 17:12:03 UTC (rev 14282) +++ branches/ros-branch-0_2_6/reactos/ntoskrnl/mm/marea.c 2005-03-23 17:12:58 UTC (rev 14283) @@ -491,7 +491,8 @@ /* Check if there is enough space after the last memory area. */ AlignedAddress = MM_ROUND_UP(PreviousNode->EndingAddress, Granularity); - if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length) + if ((ULONG_PTR)HighestAddress > (ULONG_PTR)AlignedAddress && + (ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length) { DPRINT("MmFindGapBottomUp: %p\n", AlignedAddress); return AlignedAddress; _____ Modified: branches/ros-branch-0_2_6/reactos/ntoskrnl/se/token.c --- branches/ros-branch-0_2_6/reactos/ntoskrnl/se/token.c 2005-03-23 17:12:03 UTC (rev 14282) +++ branches/ros-branch-0_2_6/reactos/ntoskrnl/se/token.c 2005-03-23 17:12:58 UTC (rev 14283) @@ -1632,7 +1632,7 @@ { // PLUID_AND_ATTRIBUTES Privileges; KPROCESSOR_MODE PreviousMode; -// ULONG PrivilegeCount; + ULONG PrivilegeCount; PTOKEN Token; // ULONG Length; ULONG i; @@ -1690,6 +1690,12 @@ &c); #endif + PrivilegeCount = (BufferLength - FIELD_OFFSET(TOKEN_PRIVILEGES, Privileges)) / + sizeof(LUID_AND_ATTRIBUTES); + + if (PreviousState != NULL) + PreviousState->PrivilegeCount = 0; + k = 0; if (DisableAllPrivileges == TRUE) { @@ -1700,11 +1706,22 @@ DPRINT ("Attributes differ\n"); /* Save current privilege */ - if (PreviousState != NULL && k < PreviousState->PrivilegeCount) + if (PreviousState != NULL) { - PreviousState->Privileges[k].Luid = Token->Privileges[i].Luid; - PreviousState->Privileges[k].Attributes = Token->Privileges[i].Attributes; - k++; + if (k < PrivilegeCount) + { + PreviousState->PrivilegeCount++; + PreviousState->Privileges[k].Luid = Token->Privileges[i].Luid; + PreviousState->Privileges[k].Attributes = Token->Privileges[i].Attributes; + } + else + { + /* FIXME: Should revert all the changes, calculate how + * much space would be needed, set ResultLength + * accordingly and fail. + */ + } + k++; } /* Update current privlege */ @@ -1734,11 +1751,22 @@ NewState->Privileges[j].Attributes); /* Save current privilege */ - if (PreviousState != NULL && k < PreviousState->PrivilegeCount) + if (PreviousState != NULL) { - PreviousState->Privileges[k].Luid = Token->Privileges[i].Luid; - PreviousState->Privileges[k].Attributes = Token->Privileges[i].Attributes; - k++; + if (k < PrivilegeCount) + { + PreviousState->PrivilegeCount++; + PreviousState->Privileges[k].Luid = Token->Privileges[i].Luid; + PreviousState->Privileges[k].Attributes = Token->Privileges[i].Attributes; + } + else + { + /* FIXME: Should revert all the changes, calculate how + * much space would be needed, set ResultLength + * accordingly and fail. + */ + } + k++; } /* Update current privlege */
19 years, 9 months
1
0
0
0
[navaraf] 14282: Merge from HEAD: r14202
by navaraf@svn.reactos.com
Merge from HEAD: r14202 Specify correct buffer size in GetPrivateProfileStringW calls. Modified: branches/ros-branch-0_2_6/reactos/lib/winmm/driver.c Modified: branches/ros-branch-0_2_6/reactos/lib/winmm/mci.c _____ Modified: branches/ros-branch-0_2_6/reactos/lib/winmm/driver.c --- branches/ros-branch-0_2_6/reactos/lib/winmm/driver.c 2005-03-23 17:11:18 UTC (rev 14281) +++ branches/ros-branch-0_2_6/reactos/lib/winmm/driver.c 2005-03-23 17:12:03 UTC (rev 14282) @@ -1,572 +1,572 @@ -/* - * WINE Drivers functions - * - * Copyright 1994 Martin Ayotte - * Copyright 1998 Marcus Meissner - * Copyright 1999 Eric Pouech - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <string.h> -#include <stdarg.h> -#include "windef.h" -#include "winbase.h" -#include "wingdi.h" -#include "winuser.h" -#include "winnls.h" -#include "winreg.h" -#include "mmddk.h" -#include "winemm.h" -#include "wine/debug.h" -#include "wine/unicode.h" - -WINE_DEFAULT_DEBUG_CHANNEL(driver); - -static LPWINE_DRIVER lpDrvItemList /* = NULL */; -static const WCHAR HKLM_BASE[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t ','\\', - 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0 }; - -WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */; -LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM) /* = NULL */; -LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM) /* = NULL */; -LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM) /* = NULL */; - -/********************************************************************** **** - * DRIVER_GetNumberOfModuleRefs [internal] - * - * Returns the number of open drivers which share the same module. - */ -static unsigned DRIVER_GetNumberOfModuleRefs(HMODULE hModule, WINE_DRIVER** found) -{ - LPWINE_DRIVER lpDrv; - unsigned count = 0; - - if (found) *found = NULL; - for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) - { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT) && lpDrv->d.d32.hModule == hModule) - { - if (found && !*found) *found = lpDrv; - count++; - } - } - return count; -} - -/********************************************************************** **** - * DRIVER_FindFromHDrvr [internal] - * - * From a hDrvr being 32 bits, returns the WINE internal structure. - */ -LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr) -{ - LPWINE_DRIVER d = (LPWINE_DRIVER)hDrvr; - - if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) { - return d; - } - return NULL; -} - -/********************************************************************** **** - * DRIVER_SendMessage [internal] - */ -static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, - LPARAM lParam1, LPARAM lParam2) -{ - LRESULT ret = 0; - - if (lpDrv->dwFlags & WINE_GDF_16BIT) { - /* no need to check mmsystem presence: the driver must have been opened as a 16 bit one, - */ - if (pFnSendMessage16) - ret = pFnSendMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2); - } else { - TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n", - lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); - ret = lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); - TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n", - lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2, ret); - } - return ret; -} - -/********************************************************************** **** - * SendDriverMessage [WINMM.@] - * DrvSendMessage [WINMM.@] - */ -LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1, - LPARAM lParam2) -{ - LPWINE_DRIVER lpDrv; - LRESULT retval = 0; - - TRACE("(%p, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2); - - if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) { - retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2); - } else { - WARN("Bad driver handle %p\n", hDriver); - } - TRACE("retval = %ld\n", retval); - - return retval; -} - -/********************************************************************** **** - * DRIVER_RemoveFromList [internal] - * - * Generates all the logic to handle driver closure / deletion - * Removes a driver struct to the list of open drivers. - */ -static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv) -{ - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) { - /* last of this driver in list ? */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 1) { - DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L); - DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L); - } - } - - if (lpDrv->lpPrevItem) - lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem; - else - lpDrvItemList = lpDrv->lpNextItem; - if (lpDrv->lpNextItem) - lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem; - /* trash magic number */ - lpDrv->dwMagic ^= 0xa5a5a5a5; - - return TRUE; -} - -/********************************************************************** **** - * DRIVER_AddToList [internal] - * - * Adds a driver struct to the list of open drivers. - * Generates all the logic to handle driver creation / open. - */ -static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2) -{ - lpNewDrv->dwMagic = WINE_DI_MAGIC; - /* First driver to be loaded for this module, need to load correctly the module */ - if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { - /* first of this driver in list ? */ - if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->d.d32.hModule, NULL) == 0) { - if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { - TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv); - return FALSE; - } - /* returned value is not checked */ - DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L); - } - } - - lpNewDrv->lpNextItem = NULL; - if (lpDrvItemList == NULL) { - lpDrvItemList = lpNewDrv; - lpNewDrv->lpPrevItem = NULL; - } else { - LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */ - while (lpDrv->lpNextItem != NULL) - lpDrv = lpDrv->lpNextItem; - - lpDrv->lpNextItem = lpNewDrv; - lpNewDrv->lpPrevItem = lpDrv; - } - - if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { - /* Now just open a new instance of a driver on this module */ - lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2); - - if (lpNewDrv->d.d32.dwDriverID == 0) { - TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv); - DRIVER_RemoveFromList(lpNewDrv); - return FALSE; - } - } - return TRUE; -} - -/********************************************************************** **** - * DRIVER_GetLibName [internal] - * - */ -BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz) -{ - HKEY hKey, hSecKey; - DWORD bufLen, lRet; - static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0}; - WCHAR wsznull = '\0'; - - lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey); - if (lRet == ERROR_SUCCESS) { - lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey); - if (lRet == ERROR_SUCCESS) { - bufLen = sz; - lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen); - RegCloseKey( hSecKey ); - } - RegCloseKey( hKey ); - } - if (lRet == ERROR_SUCCESS) return TRUE; - /* default to system.ini if we can't find it in the registry, - * to support native installations where system.ini is still used */ - return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz, wszSystemIni); -} - -/********************************************************************** **** - * DRIVER_TryOpenDriver32 [internal] - * - * Tries to load a 32 bit driver whose DLL's (module) name is fn - */ -LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) -{ - LPWINE_DRIVER lpDrv = NULL; - HMODULE hModule = 0; - LPWSTR ptr; - LPCSTR cause = 0; - - TRACE("(%s, %08lX);\n", debugstr_w(fn), lParam2); - - if ((ptr = strchrW(fn, ' ')) != NULL) { - *ptr++ = '\0'; - while (*ptr == ' ') ptr++; - if (*ptr == '\0') ptr = NULL; - } - - lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER)); - if (lpDrv == NULL) {cause = "OOM"; goto exit;} - - if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;} - - lpDrv->d.d32.lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc"); - if (lpDrv->d.d32.lpDrvProc == NULL) {cause = "no DriverProc"; goto exit;} - - lpDrv->dwFlags = 0; - lpDrv->d.d32.hModule = hModule; - lpDrv->d.d32.dwDriverID = 0; - - /* Win32 installable drivers must support a two phase opening scheme: - * + first open with NULL as lParam2 (session instance), - * + then do a second open with the real non null lParam2) - */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 0 && lParam2) - { - LPWINE_DRIVER ret; - - if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, 0L)) - { - cause = "load0 failed"; - goto exit; - } - ret = DRIVER_TryOpenDriver32(fn, lParam2); - if (!ret) - { - CloseDriver((HDRVR)lpDrv, 0L, 0L); - cause = "load1 failed"; - goto exit; - } - return ret; - } - - if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2)) - {cause = "load failed"; goto exit;} - - TRACE("=> %p\n", lpDrv); - return lpDrv; - exit: - FreeLibrary(hModule); - HeapFree(GetProcessHeap(), 0, lpDrv); - TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause); - return NULL; -} - -/********************************************************************** **** - * OpenDriverA [WINMM.@] - * DrvOpenA [WINMM.@] - * (0,1,DRV_LOAD ,0 ,0) - * (0,1,DRV_ENABLE,0 ,0) - * (0,1,DRV_OPEN ,buf[256],0) - */ -HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam) -{ - INT len; - LPWSTR dn = NULL; - LPWSTR sn = NULL; - HDRVR ret; - - if (lpDriverName) - { - len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 ); - dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - if (!dn) return 0; - MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len ); - } - - if (lpSectionName) - { - len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 ); - sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - if (!sn) return 0; - MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len ); - } - - ret = OpenDriver(dn, sn, lParam); - - if (dn) HeapFree(GetProcessHeap(), 0, dn); - if (sn) HeapFree(GetProcessHeap(), 0, sn); - return ret; -} - -/********************************************************************** **** - * OpenDriver [WINMM.@] - * DrvOpen [WINMM.@] - */ -HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam) -{ - LPWINE_DRIVER lpDrv = NULL; - WCHAR libName[128]; - LPCWSTR lsn = lpSectionName; - - TRACE("(%s, %s, 0x%08lx);\n", - debugstr_w(lpDriverName), debugstr_w(lpSectionName), lParam); - - if (lsn == NULL) { - static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0}; - lstrcpynW(libName, lpDriverName, sizeof(libName) / sizeof(WCHAR)); - - if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam))) - goto the_end; - lsn = wszDrivers32; - } - if (DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) && - (lpDrv = DRIVER_TryOpenDriver32(libName, lParam))) - goto the_end; - - /* now we will try a 16 bit driver (and add all the glue to make it work... which - * is located in our mmsystem implementation) - * so ensure, we can load our mmsystem, otherwise just fail - */ - WINMM_CheckForMMSystem(); - if (pFnOpenDriver16 && - (lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam))) - { - if (DRIVER_AddToList(lpDrv, 0, lParam)) goto the_end; - HeapFree(GetProcessHeap(), 0, lpDrv); - } - TRACE("Failed to open driver %s from system.ini file, section %s\n", - debugstr_w(lpDriverName), debugstr_w(lpSectionName)); - return 0; - - the_end: - if (lpDrv) TRACE("=> %08lx\n", (DWORD)lpDrv); - return (HDRVR)lpDrv; -} - -/********************************************************************** **** - * CloseDriver [WINMM.@] - * DrvClose [WINMM.@] - */ -LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) -{ - LPWINE_DRIVER lpDrv; - - TRACE("(%p, %08lX, %08lX);\n", hDrvr, lParam1, lParam2); - - if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) - { - if (lpDrv->dwFlags & WINE_GDF_16BIT) - { - if (pFnCloseDriver16) - pFnCloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2); - } - else - { - DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2); - lpDrv->d.d32.dwDriverID = 0; - } - if (DRIVER_RemoveFromList(lpDrv)) { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) - { - LPWINE_DRIVER lpDrv0; - - /* if driver has an opened session instance, we have to close it too */ - if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1) - { - DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0L, 0L); - lpDrv0->d.d32.dwDriverID = 0; - DRIVER_RemoveFromList(lpDrv0); - FreeLibrary(lpDrv0->d.d32.hModule); - HeapFree(GetProcessHeap(), 0, lpDrv0); - } - FreeLibrary(lpDrv->d.d32.hModule); - } - HeapFree(GetProcessHeap(), 0, lpDrv); - return TRUE; - } - } - WARN("Failed to close driver\n"); - return FALSE; -} - -/********************************************************************** **** - * GetDriverFlags [WINMM.@] - * [in] hDrvr handle to the driver - * - * Returns: - * 0x00000000 if hDrvr is an invalid handle - * 0x80000000 if hDrvr is a valid 32 bit driver - * 0x90000000 if hDrvr is a valid 16 bit driver - * - * native WINMM doesn't return those flags - * 0x80000000 for a valid 32 bit driver and that's it - * (I may have mixed up the two flags :-( - */ -DWORD WINAPI GetDriverFlags(HDRVR hDrvr) -{ - LPWINE_DRIVER lpDrv; - DWORD ret = 0; - - TRACE("(%p)\n", hDrvr); - - if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { - ret = WINE_GDF_EXIST | lpDrv->dwFlags; - } - return ret; -} - -/********************************************************************** **** - * GetDriverModuleHandle [WINMM.@] - * DrvGetModuleHandle [WINMM.@] - */ -HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr) -{ - LPWINE_DRIVER lpDrv; - HMODULE hModule = 0; - - TRACE("(%p);\n", hDrvr); - - if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { - if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) - hModule = lpDrv->d.d32.hModule; - } - TRACE("=> %p\n", hModule); - return hModule; -} - -/********************************************************************** **** - * DefDriverProc [WINMM.@] - * DrvDefDriverProc [WINMM.@] - */ -LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv, - UINT Msg, LPARAM lParam1, LPARAM lParam2) -{ - switch (Msg) { - case DRV_LOAD: - case DRV_FREE: - case DRV_ENABLE: - case DRV_DISABLE: - return 1; - case DRV_INSTALL: - case DRV_REMOVE: - return DRV_SUCCESS; - default: - return 0; - } -} - -/********************************************************************** **** - * DriverCallback [WINMM.@] - */ -BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, - UINT wMsg, DWORD dwUser, DWORD dwParam1, - DWORD dwParam2) -{ - TRACE("(%08lX, %04X, %p, %04X, %08lX, %08lX, %08lX); !\n", - dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2); - - switch (uFlags & DCB_TYPEMASK) { - case DCB_NULL: - TRACE("Null !\n"); - if (dwCallBack) - WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack); - break; - case DCB_WINDOW: - TRACE("Window(%04lX) handle=%p!\n", dwCallBack, hDev); - PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1); - break; - case DCB_TASK: /* aka DCB_THREAD */ - TRACE("Task(%04lx) !\n", dwCallBack); - PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1); - break; - case DCB_FUNCTION: - TRACE("Function (32 bit) !\n"); - ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2); - break; - case DCB_EVENT: - TRACE("Event(%08lx) !\n", dwCallBack); - SetEvent((HANDLE)dwCallBack); - break; - case 6: /* I would dub it DCB_MMTHREADSIGNAL */ - /* this is an undocumented DCB_ value used for mmThreads - * loword of dwCallBack contains the handle of the lpMMThd block - * which dwSignalCount has to be incremented - */ - if (pFnGetMMThread16) - { - WINE_MMTHREAD* lpMMThd = pFnGetMMThread16(LOWORD(dwCallBack)); - - TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd); - /* same as mmThreadSignal16 */ - InterlockedIncrement(&lpMMThd->dwSignalCount); - SetEvent(lpMMThd->hEvent); - /* some other stuff on lpMMThd->hVxD */ - } - break; -#if 0 - case 4: - /* this is an undocumented DCB_ value for... I don't know */ - break; -#endif - default: - WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK); - return FALSE; - } - TRACE("Done\n"); - return TRUE; -} - -/****************************************************************** - * DRIVER_UnloadAll - * - * - */ -void DRIVER_UnloadAll(void) -{ - LPWINE_DRIVER lpDrv; - LPWINE_DRIVER lpNextDrv = NULL; - unsigned count = 0; - - for (lpDrv = lpDrvItemList; lpDrv != NULL; lpDrv = lpNextDrv) - { - lpNextDrv = lpDrv->lpNextItem; - CloseDriver((HDRVR)lpDrv, 0, 0); - count++; - } - TRACE("Unloaded %u drivers\n", count); -} +/* + * WINE Drivers functions + * + * Copyright 1994 Martin Ayotte + * Copyright 1998 Marcus Meissner + * Copyright 1999 Eric Pouech + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <string.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winnls.h" +#include "winreg.h" +#include "mmddk.h" +#include "winemm.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(driver); + +static LPWINE_DRIVER lpDrvItemList /* = NULL */; +static const WCHAR HKLM_BASE[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t ','\\', + 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',0 }; + +WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */; +LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM) /* = NULL */; +LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM) /* = NULL */; +LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM) /* = NULL */; + +/********************************************************************** **** + * DRIVER_GetNumberOfModuleRefs [internal] + * + * Returns the number of open drivers which share the same module. + */ +static unsigned DRIVER_GetNumberOfModuleRefs(HMODULE hModule, WINE_DRIVER** found) +{ + LPWINE_DRIVER lpDrv; + unsigned count = 0; + + if (found) *found = NULL; + for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) + { + if (!(lpDrv->dwFlags & WINE_GDF_16BIT) && lpDrv->d.d32.hModule == hModule) + { + if (found && !*found) *found = lpDrv; + count++; + } + } + return count; +} + +/********************************************************************** **** + * DRIVER_FindFromHDrvr [internal] + * + * From a hDrvr being 32 bits, returns the WINE internal structure. + */ +LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr) +{ + LPWINE_DRIVER d = (LPWINE_DRIVER)hDrvr; + + if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) { + return d; + } + return NULL; +} + +/********************************************************************** **** + * DRIVER_SendMessage [internal] + */ +static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, + LPARAM lParam1, LPARAM lParam2) +{ + LRESULT ret = 0; + + if (lpDrv->dwFlags & WINE_GDF_16BIT) { + /* no need to check mmsystem presence: the driver must have been opened as a 16 bit one, + */ + if (pFnSendMessage16) + ret = pFnSendMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2); + } else { + TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx\n", + lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); + ret = lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); + TRACE("After call32 proc=%p drvrID=%08lx hDrv=%p wMsg=%04x p1=%08lx p2=%08lx => %08lx\n", + lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2, ret); + } + return ret; +} + +/********************************************************************** **** + * SendDriverMessage [WINMM.@] + * DrvSendMessage [WINMM.@] + */ +LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1, + LPARAM lParam2) +{ + LPWINE_DRIVER lpDrv; + LRESULT retval = 0; + + TRACE("(%p, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2); + + if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) { + retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2); + } else { + WARN("Bad driver handle %p\n", hDriver); + } + TRACE("retval = %ld\n", retval); + + return retval; +} + +/********************************************************************** **** + * DRIVER_RemoveFromList [internal] + * + * Generates all the logic to handle driver closure / deletion + * Removes a driver struct to the list of open drivers. + */ +static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv) +{ + if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) { + /* last of this driver in list ? */ + if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 1) { + DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L); + DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L); + } + } + + if (lpDrv->lpPrevItem) + lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem; + else + lpDrvItemList = lpDrv->lpNextItem; + if (lpDrv->lpNextItem) + lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem; + /* trash magic number */ + lpDrv->dwMagic ^= 0xa5a5a5a5; + + return TRUE; +} + +/********************************************************************** **** + * DRIVER_AddToList [internal] + * + * Adds a driver struct to the list of open drivers. + * Generates all the logic to handle driver creation / open. + */ +static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2) +{ + lpNewDrv->dwMagic = WINE_DI_MAGIC; + /* First driver to be loaded for this module, need to load correctly the module */ + if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { + /* first of this driver in list ? */ + if (DRIVER_GetNumberOfModuleRefs(lpNewDrv->d.d32.hModule, NULL) == 0) { + if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { + TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv); + return FALSE; + } + /* returned value is not checked */ + DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L); + } + } + + lpNewDrv->lpNextItem = NULL; + if (lpDrvItemList == NULL) { + lpDrvItemList = lpNewDrv; + lpNewDrv->lpPrevItem = NULL; + } else { + LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */ + while (lpDrv->lpNextItem != NULL) + lpDrv = lpDrv->lpNextItem; + + lpDrv->lpNextItem = lpNewDrv; + lpNewDrv->lpPrevItem = lpDrv; + } + + if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { + /* Now just open a new instance of a driver on this module */ + lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2); + + if (lpNewDrv->d.d32.dwDriverID == 0) { + TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv); + DRIVER_RemoveFromList(lpNewDrv); + return FALSE; + } + } + return TRUE; +} + +/********************************************************************** **** + * DRIVER_GetLibName [internal] + * + */ +BOOL DRIVER_GetLibName(LPCWSTR keyName, LPCWSTR sectName, LPWSTR buf, int sz) +{ + HKEY hKey, hSecKey; + DWORD bufLen, lRet; + static const WCHAR wszSystemIni[] = {'S','Y','S','T','E','M','.','I','N','I',0}; + WCHAR wsznull = '\0'; + + lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey); + if (lRet == ERROR_SUCCESS) { + lRet = RegOpenKeyExW(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey); + if (lRet == ERROR_SUCCESS) { + bufLen = sz; + lRet = RegQueryValueExW(hSecKey, keyName, 0, 0, (void*)buf, &bufLen); + RegCloseKey( hSecKey ); + } + RegCloseKey( hKey ); + } + if (lRet == ERROR_SUCCESS) return TRUE; + /* default to system.ini if we can't find it in the registry, + * to support native installations where system.ini is still used */ + return GetPrivateProfileStringW(sectName, keyName, &wsznull, buf, sz / sizeof(WCHAR), wszSystemIni); +} + +/********************************************************************** **** + * DRIVER_TryOpenDriver32 [internal] + * + * Tries to load a 32 bit driver whose DLL's (module) name is fn + */ +LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCWSTR fn, LPARAM lParam2) +{ + LPWINE_DRIVER lpDrv = NULL; + HMODULE hModule = 0; + LPWSTR ptr; + LPCSTR cause = 0; + + TRACE("(%s, %08lX);\n", debugstr_w(fn), lParam2); + + if ((ptr = strchrW(fn, ' ')) != NULL) { + *ptr++ = '\0'; + while (*ptr == ' ') ptr++; + if (*ptr == '\0') ptr = NULL; + } + + lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER)); + if (lpDrv == NULL) {cause = "OOM"; goto exit;} + + if ((hModule = LoadLibraryW(fn)) == 0) {cause = "Not a 32 bit lib"; goto exit;} + + lpDrv->d.d32.lpDrvProc = (DRIVERPROC)GetProcAddress(hModule, "DriverProc"); + if (lpDrv->d.d32.lpDrvProc == NULL) {cause = "no DriverProc"; goto exit;} + + lpDrv->dwFlags = 0; + lpDrv->d.d32.hModule = hModule; + lpDrv->d.d32.dwDriverID = 0; + + /* Win32 installable drivers must support a two phase opening scheme: + * + first open with NULL as lParam2 (session instance), + * + then do a second open with the real non null lParam2) + */ + if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, NULL) == 0 && lParam2) + { + LPWINE_DRIVER ret; + + if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, 0L)) + { + cause = "load0 failed"; + goto exit; + } + ret = DRIVER_TryOpenDriver32(fn, lParam2); + if (!ret) + { + CloseDriver((HDRVR)lpDrv, 0L, 0L); + cause = "load1 failed"; + goto exit; + } + return ret; + } + + if (!DRIVER_AddToList(lpDrv, (LPARAM)ptr, lParam2)) + {cause = "load failed"; goto exit;} + + TRACE("=> %p\n", lpDrv); + return lpDrv; + exit: + FreeLibrary(hModule); + HeapFree(GetProcessHeap(), 0, lpDrv); + TRACE("Unable to load 32 bit module %s: %s\n", debugstr_w(fn), cause); + return NULL; +} + +/********************************************************************** **** + * OpenDriverA [WINMM.@] + * DrvOpenA [WINMM.@] + * (0,1,DRV_LOAD ,0 ,0) + * (0,1,DRV_ENABLE,0 ,0) + * (0,1,DRV_OPEN ,buf[256],0) + */ +HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam) +{ + INT len; + LPWSTR dn = NULL; + LPWSTR sn = NULL; + HDRVR ret; + + if (lpDriverName) + { + len = MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, NULL, 0 ); + dn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + if (!dn) return 0; + MultiByteToWideChar( CP_ACP, 0, lpDriverName, -1, dn, len ); + } + + if (lpSectionName) + { + len = MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, NULL, 0 ); + sn = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + if (!sn) return 0; + MultiByteToWideChar( CP_ACP, 0, lpSectionName, -1, sn, len ); + } + + ret = OpenDriver(dn, sn, lParam); + + if (dn) HeapFree(GetProcessHeap(), 0, dn); + if (sn) HeapFree(GetProcessHeap(), 0, sn); + return ret; +} + +/********************************************************************** **** + * OpenDriver [WINMM.@] + * DrvOpen [WINMM.@] + */ +HDRVR WINAPI OpenDriver(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam) +{ + LPWINE_DRIVER lpDrv = NULL; + WCHAR libName[128]; + LPCWSTR lsn = lpSectionName; + + TRACE("(%s, %s, 0x%08lx);\n", + debugstr_w(lpDriverName), debugstr_w(lpSectionName), lParam); + + if (lsn == NULL) { + static const WCHAR wszDrivers32[] = {'D','r','i','v','e','r','s','3','2',0}; + lstrcpynW(libName, lpDriverName, sizeof(libName) / sizeof(WCHAR)); + + if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam))) + goto the_end; + lsn = wszDrivers32; + } + if (DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) && + (lpDrv = DRIVER_TryOpenDriver32(libName, lParam))) + goto the_end; + + /* now we will try a 16 bit driver (and add all the glue to make it work... which + * is located in our mmsystem implementation) + * so ensure, we can load our mmsystem, otherwise just fail + */ + WINMM_CheckForMMSystem(); + if (pFnOpenDriver16 && + (lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam))) + { + if (DRIVER_AddToList(lpDrv, 0, lParam)) goto the_end; + HeapFree(GetProcessHeap(), 0, lpDrv); + } + TRACE("Failed to open driver %s from system.ini file, section %s\n", + debugstr_w(lpDriverName), debugstr_w(lpSectionName)); + return 0; + + the_end: + if (lpDrv) TRACE("=> %08lx\n", (DWORD)lpDrv); + return (HDRVR)lpDrv; +} + +/********************************************************************** **** + * CloseDriver [WINMM.@] + * DrvClose [WINMM.@] + */ +LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) +{ + LPWINE_DRIVER lpDrv; + + TRACE("(%p, %08lX, %08lX);\n", hDrvr, lParam1, lParam2); + + if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) + { + if (lpDrv->dwFlags & WINE_GDF_16BIT) + { + if (pFnCloseDriver16) + pFnCloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2); + } + else + { + DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2); + lpDrv->d.d32.dwDriverID = 0; + } + if (DRIVER_RemoveFromList(lpDrv)) { + if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) + { + LPWINE_DRIVER lpDrv0; + + /* if driver has an opened session instance, we have to close it too */ + if (DRIVER_GetNumberOfModuleRefs(lpDrv->d.d32.hModule, &lpDrv0) == 1) + { + DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0L, 0L); + lpDrv0->d.d32.dwDriverID = 0; + DRIVER_RemoveFromList(lpDrv0); + FreeLibrary(lpDrv0->d.d32.hModule); + HeapFree(GetProcessHeap(), 0, lpDrv0); + } + FreeLibrary(lpDrv->d.d32.hModule); + } + HeapFree(GetProcessHeap(), 0, lpDrv); + return TRUE; + } + } + WARN("Failed to close driver\n"); [truncated at 1000 lines; 4984 more skipped]
19 years, 9 months
1
0
0
0
[navaraf] 14281: Merge from HEAD: r14193
by navaraf@svn.reactos.com
Merge from HEAD: r14193 Export the HOST variable even on Windows. Modified: branches/ros-branch-0_2_6/reactos/rules.mak _____ Modified: branches/ros-branch-0_2_6/reactos/rules.mak --- branches/ros-branch-0_2_6/reactos/rules.mak 2005-03-23 17:10:54 UTC (rev 14280) +++ branches/ros-branch-0_2_6/reactos/rules.mak 2005-03-23 17:11:18 UTC (rev 14281) @@ -38,7 +38,7 @@ # detect Windows host environment ifeq ($(HOST),) ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32) -HOST=mingw32-windows +export HOST=mingw32-windows else export HOST=mingw32-linux endif
19 years, 9 months
1
0
0
0
[navaraf] 14280: Merge from HEAD: r14186
by navaraf@svn.reactos.com
Merge from HEAD: r14186 - Fix acpi_os_get_thread_id to return 1-based thread ids (instead of zero-based ones). - Zero the owner_id field while initializing acpi_gbl_acpi_mutex_info. Modified: branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/ospm/osl.c Modified: branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/utils/cmglobal.c _____ Modified: branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/ospm/osl.c --- branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/ospm/osl.c 2005-03-23 17:10:03 UTC (rev 14279) +++ branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/ospm/osl.c 2005-03-23 17:10:54 UTC (rev 14280) @@ -601,5 +601,5 @@ u32 acpi_os_get_thread_id (void) { - return (ULONG)PsGetCurrentThreadId(); + return (ULONG)PsGetCurrentThreadId() + 1; } _____ Modified: branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/utils/cmglobal.c --- branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/utils/cmglobal.c 2005-03-23 17:10:03 UTC (rev 14279) +++ branches/ros-branch-0_2_6/reactos/drivers/bus/acpi/utils/cmglobal.c 2005-03-23 17:10:54 UTC (rev 14280) @@ -389,6 +389,7 @@ acpi_gbl_acpi_mutex_info[i].mutex = NULL; acpi_gbl_acpi_mutex_info[i].locked = FALSE; acpi_gbl_acpi_mutex_info[i].use_count = 0; + acpi_gbl_acpi_mutex_info[i].owner_id = 0; } /* Global notify handlers */
19 years, 9 months
1
0
0
0
[navaraf] 14279: Merge from HEAD: r14171
by navaraf@svn.reactos.com
Merge from HEAD: r14171 - Correctly initialize the standard handles for console-less applications. - Simplify _isatty and fix it to not set the errno for "invalid" handles. Modified: branches/ros-branch-0_2_6/reactos/lib/crt/io/isatty.c Modified: branches/ros-branch-0_2_6/reactos/lib/crt/io/open.c _____ Modified: branches/ros-branch-0_2_6/reactos/lib/crt/io/isatty.c --- branches/ros-branch-0_2_6/reactos/lib/crt/io/isatty.c 2005-03-23 17:08:24 UTC (rev 14278) +++ branches/ros-branch-0_2_6/reactos/lib/crt/io/isatty.c 2005-03-23 17:10:03 UTC (rev 14279) @@ -1,5 +1,4 @@ -#include <io.h> -#include <sys/stat.h> +#include <internal/file.h> #define NDEBUG #include <internal/debug.h> @@ -7,13 +6,10 @@ /* * @implemented */ -int _isatty( int fd ) +int _isatty(int fd) { - struct _stat buf; - DPRINT("_isatty(fd %d)\n", fd); - if (_fstat (fd, &buf) < 0) + HANDLE hFile = fdinfo(fd)->hFile; + if (hFile == INVALID_HANDLE_VALUE) return 0; - if (S_ISCHR (buf.st_mode)) - return 1; - return 0; + return GetFileType(hFile) == FILE_TYPE_CHAR ? 1 : 0; } _____ Modified: branches/ros-branch-0_2_6/reactos/lib/crt/io/open.c --- branches/ros-branch-0_2_6/reactos/lib/crt/io/open.c 2005-03-23 17:08:24 UTC (rev 14278) +++ branches/ros-branch-0_2_6/reactos/lib/crt/io/open.c 2005-03-23 17:10:03 UTC (rev 14279) @@ -608,14 +608,20 @@ if (fdinfo(0)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(0)->fdflags & FOPEN)) { fdinfo(0)->hFile = GetStdHandle(STD_INPUT_HANDLE); + if (fdinfo(0)->hFile == NULL) + fdinfo(0)->hFile = INVALID_HANDLE_VALUE; fdinfo(0)->fdflags = FOPEN|FTEXT; } if (fdinfo(1)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(1)->fdflags & FOPEN)) { fdinfo(1)->hFile = GetStdHandle(STD_OUTPUT_HANDLE); + if (fdinfo(1)->hFile == NULL) + fdinfo(1)->hFile = INVALID_HANDLE_VALUE; fdinfo(1)->fdflags = FOPEN|FTEXT; } if (fdinfo(2)->hFile == INVALID_HANDLE_VALUE || !(fdinfo(2)->fdflags & FOPEN)) { fdinfo(2)->hFile = GetStdHandle(STD_ERROR_HANDLE); + if (fdinfo(2)->hFile == NULL) + fdinfo(2)->hFile = INVALID_HANDLE_VALUE; fdinfo(2)->fdflags = FOPEN|FTEXT; }
19 years, 9 months
1
0
0
0
[navaraf] 14278: Merge from HEAD: r14166
by navaraf@svn.reactos.com
Merge from HEAD: r14166 (GDIOBJ_SetOwnership): Don't try to decrease the GDI object counter for global handles since they're not associated with process. Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/objects/gdiobj.c _____ Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/objects/gdiobj.c --- branches/ros-branch-0_2_6/reactos/subsys/win32k/objects/gdiobj.c 2005-03-23 17:07:48 UTC (rev 14277) +++ branches/ros-branch-0_2_6/reactos/subsys/win32k/objects/gdiobj.c 2005-03-23 17:08:24 UTC (rev 14278) @@ -1216,15 +1216,18 @@ /* dereference the process' object counter */ /* FIXME */ - Status = PsLookupProcessByProcessId((HANDLE)((ULONG_PTR)PrevProcId & ~0x1), &OldProcess); - if(NT_SUCCESS(Status)) + if((ULONG_PTR)PrevProcId & ~0x1) { - W32Process = OldProcess->Win32Process; - if(W32Process != NULL) + Status = PsLookupProcessByProcessId((HANDLE)((ULONG_PTR)PrevProcId & ~0x1), &OldProcess); + if(NT_SUCCESS(Status)) { - InterlockedDecrement(&W32Process->GDIObjects); + W32Process = OldProcess->Win32Process; + if(W32Process != NULL) + { + InterlockedDecrement(&W32Process->GDIObjects); + } + ObDereferenceObject(OldProcess); } - ObDereferenceObject(OldProcess); } if(NewOwner != NULL)
19 years, 9 months
1
0
0
0
[navaraf] 14277: Merge from HEAD: r14160
by navaraf@svn.reactos.com
Merge from HEAD: r14160 - Don't try to kill non-existing timers. - Close dialog using EndDialog instead of DestroyWindow. Modified: branches/ros-branch-0_2_6/reactos/subsys/system/taskmgr/taskmgr.c _____ Modified: branches/ros-branch-0_2_6/reactos/subsys/system/taskmgr/taskmgr.c --- branches/ros-branch-0_2_6/reactos/subsys/system/taskmgr/taskmgr.c 2005-03-23 17:06:29 UTC (rev 14276) +++ branches/ros-branch-0_2_6/reactos/subsys/system/taskmgr/taskmgr.c 2005-03-23 17:07:48 UTC (rev 14277) @@ -257,7 +257,7 @@ OnAbout(); break; case ID_FILE_EXIT: - DestroyWindow(hDlg); + EndDialog(hDlg, IDOK); break; } break; @@ -590,23 +590,12 @@ TabCtrl_SetCurFocus/*Sel*/(hTabWnd, 2); TabCtrl_SetCurFocus/*Sel*/(hTabWnd, nActivePage); - if (TaskManagerSettings.UpdateSpeed == 0) - KillTimer(hWnd, 1); - else if (TaskManagerSettings.UpdateSpeed == 1) - { - KillTimer(hWnd, 1); + if (TaskManagerSettings.UpdateSpeed == 1) SetTimer(hWnd, 1, 1000, NULL); - } else if (TaskManagerSettings.UpdateSpeed == 2) - { - KillTimer(hWnd, 1); SetTimer(hWnd, 1, 2000, NULL); - } else if (TaskManagerSettings.UpdateSpeed == 4) - { - KillTimer(hWnd, 1); SetTimer(hWnd, 1, 4000, NULL); - } /* * Refresh the performance data
19 years, 9 months
1
0
0
0
[navaraf] 14276: Merge from HEAD: r14159
by navaraf@svn.reactos.com
Merge from HEAD: r14159 Now that CSRSS is getting unloaded we must unregister the primitive message queue when it's about to be destroyed. Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/include/input.h Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/misc.c Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/msgqueue.c _____ Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/include/input.h --- branches/ros-branch-0_2_6/reactos/subsys/win32k/include/input.h 2005-03-23 13:26:38 UTC (rev 14275) +++ branches/ros-branch-0_2_6/reactos/subsys/win32k/include/input.h 2005-03-23 17:06:29 UTC (rev 14276) @@ -8,6 +8,7 @@ NTSTATUS FASTCALL InitKeyboardImpl(VOID); PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue(VOID); +VOID W32kUnregisterPrimitiveMessageQueue(VOID); PKBDTABLES W32kGetDefaultKeyLayout(VOID); VOID FASTCALL W32kKeyProcessMessage(LPMSG Msg, PKBDTABLES KeyLayout); BOOL FASTCALL IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt); _____ Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/misc.c --- branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/misc.c 2005-03-23 13:26:38 UTC (rev 14275) +++ branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/misc.c 2005-03-23 17:06:29 UTC (rev 14276) @@ -17,13 +17,15 @@ /* registered Logon process */ PW32PROCESS LogonProcess = NULL; -void W32kRegisterPrimitiveMessageQueue() { +VOID W32kRegisterPrimitiveMessageQueue(VOID) +{ extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; if( !pmPrimitiveMessageQueue ) { PW32THREAD pThread; pThread = PsGetWin32Thread(); if( pThread && pThread->MessageQueue ) { pmPrimitiveMessageQueue = pThread->MessageQueue; + IntReferenceMessageQueue(pmPrimitiveMessageQueue); DPRINT( "Installed primitive input queue.\n" ); } } else { @@ -31,8 +33,16 @@ } } -PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() { +VOID W32kUnregisterPrimitiveMessageQueue(VOID) +{ extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; + IntDereferenceMessageQueue(pmPrimitiveMessageQueue); + pmPrimitiveMessageQueue = NULL; +} + +PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() +{ + extern PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue; return pmPrimitiveMessageQueue; } _____ Modified: branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/msgqueue.c --- branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/msgqueue.c 2005-03-23 13:26:38 UTC (rev 14275) +++ branches/ros-branch-0_2_6/reactos/subsys/win32k/ntuser/msgqueue.c 2005-03-23 17:06:29 UTC (rev 14276) @@ -1413,15 +1413,21 @@ MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue) { PDESKTOP_OBJECT desk; + /* remove the message queue from any desktops */ - if((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0))) - { - InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0); - IntDereferenceMessageQueue(MessageQueue); - } + if ((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0))) + { + InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0); + IntDereferenceMessageQueue(MessageQueue); + } + /* if this is the primitive message queue, deregister it */ + if (MessageQueue == W32kGetPrimitiveMessageQueue()) + W32kUnregisterPrimitiveMessageQueue(); + /* clean it up */ MsqCleanupMessageQueue(MessageQueue); + /* decrease the reference counter, if it hits zero, the queue will be freed */ IntDereferenceMessageQueue(MessageQueue); }
19 years, 9 months
1
0
0
0
← Newer
1
...
9
10
11
12
13
14
15
...
61
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Results per page:
10
25
50
100
200