Synchronize up to trunk's revision r57689.

svn path=/branches/ros-csrss/; revision=57690
This commit is contained in:
Hermès Bélusca-Maïto 2012-11-07 23:07:18 +00:00
commit f77f05cd9d
37 changed files with 2298 additions and 773 deletions

View file

@ -196,7 +196,7 @@ ALIASES =
# For instance, some of the names that are used will be different. The list # For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc. # of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_FOR_C = NO
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for # sources only. Doxygen will then generate output that is more tailored for
@ -236,7 +236,7 @@ EXTENSION_MAPPING =
# func(std::string) {}). This also make the inheritance and collaboration # func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate. # diagrams that involve STL classes more complete and accurate.
BUILTIN_STL_SUPPORT = NO BUILTIN_STL_SUPPORT = YES
# If you use Microsoft's C++/CLI language, you should set this option to YES to # If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support. # enable parsing support.

View file

@ -479,6 +479,26 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
SendMessage(g_Globals._hwndShellView, nmsg, wparam, lparam); SendMessage(g_Globals._hwndShellView, nmsg, wparam, lparam);
break; break;
case PM_TRANSLATE_MSG:
{
/* TranslateAccelerator is called for all explorer windows that are open
so we have to decide if this is the correct recipient */
LPMSG lpmsg = (LPMSG)lparam;
HWND hwnd = lpmsg->hwnd;
while(hwnd)
{
if(hwnd == _hwnd)
break;
hwnd = GetParent(hwnd);
}
if (hwnd)
return _pShellView->TranslateAccelerator(lpmsg) == S_OK;
return false;
}
default: def: default: def:
return super::WndProc(nmsg, wparam, lparam); return super::WndProc(nmsg, wparam, lparam);
} }

View file

@ -48,9 +48,9 @@ protected:
/// Implementation of the Explorer desktop window /// Implementation of the Explorer desktop window
struct DesktopWindow : public Window, public IShellBrowserImpl struct DesktopWindow : public PreTranslateWindow, public IShellBrowserImpl
{ {
typedef Window super; typedef PreTranslateWindow super;
DesktopWindow(HWND hwnd); DesktopWindow(HWND hwnd);
~DesktopWindow(); ~DesktopWindow();

View file

@ -599,6 +599,27 @@ bool ShellBrowser::jump_to_pidl(LPCITEMIDLIST pidl)
return false; return false;
} }
bool ShellBrowser::TranslateAccelerator(LPMSG lpmsg)
{
HWND hwnd;
/* TranslateAccelerator is called for all explorer windows that are open
so we have to decide if this is the correct recipient */
hwnd = lpmsg->hwnd;
while(hwnd)
{
if(hwnd == _hwnd)
break;
hwnd = GetParent(hwnd);
}
if (hwnd)
return _pShellView->TranslateAccelerator(lpmsg) == S_OK;
return false;
}
bool ShellBrowser::select_folder(Entry* entry, bool expand) bool ShellBrowser::select_folder(Entry* entry, bool expand)
{ {
@ -707,6 +728,9 @@ LRESULT MDIShellBrowserChild::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
SendMessage(_right_hwnd, WM_SYSCOLORCHANGE, 0, 0); SendMessage(_right_hwnd, WM_SYSCOLORCHANGE, 0, 0);
break; break;
case PM_TRANSLATE_MSG:
return _shellBrowser->TranslateAccelerator((MSG*)lparam);
default: default:
return super::WndProc(nmsg, wparam, lparam); return super::WndProc(nmsg, wparam, lparam);
} }

View file

@ -141,6 +141,8 @@ struct ShellBrowser : public IShellBrowserImpl
void invalidate_cache(); void invalidate_cache();
bool TranslateAccelerator(LPMSG lpmsg);
protected: protected:
HWND _hwnd; HWND _hwnd;
HWND _hwndFrame; HWND _hwndFrame;

View file

@ -591,6 +591,14 @@ void Window::unregister_pretranslate(HWND hwnd)
BOOL Window::pretranslate_msg(LPMSG pmsg) BOOL Window::pretranslate_msg(LPMSG pmsg)
{ {
if ((pmsg->message != WM_KEYDOWN) &&
(pmsg->message != WM_SYSKEYDOWN) &&
(pmsg->message != WM_SYSCHAR) &&
(pmsg->message != WM_CHAR))
{
return FALSE;
}
for(WindowSet::const_iterator it=Window::s_pretranslate_windows.begin(); it!=s_pretranslate_windows.end(); ++it) for(WindowSet::const_iterator it=Window::s_pretranslate_windows.begin(); it!=s_pretranslate_windows.end(); ++it)
if (SendMessage(*it, PM_TRANSLATE_MSG, 0, (LPARAM)pmsg)) if (SendMessage(*it, PM_TRANSLATE_MSG, 0, (LPARAM)pmsg))
return TRUE; return TRUE;

View file

@ -282,13 +282,28 @@ struct MenuInfo
#define Frame_GetMenuInfo(hwnd) ((MenuInfo*)SNDMSG(hwnd, PM_FRM_GET_MENUINFO, 0, 0)) #define Frame_GetMenuInfo(hwnd) ((MenuInfo*)SNDMSG(hwnd, PM_FRM_GET_MENUINFO, 0, 0))
/**
PreTranslateWindow is used to register windows to be called by Window::pretranslate_msg().
This way you get PM_TRANSLATE_MSG messages before the message loop dispatches messages.
You can then for example use TranslateAccelerator() to implement key shortcuts.
*/
struct PreTranslateWindow : public Window
{
typedef Window super;
PreTranslateWindow(HWND);
~PreTranslateWindow();
};
/** /**
Class ChildWindow represents MDI child windows. Class ChildWindow represents MDI child windows.
It is used with class MainFrame. It is used with class MainFrame.
*/ */
struct ChildWindow : public Window struct ChildWindow : public PreTranslateWindow
{ {
typedef Window super; typedef PreTranslateWindow super;
ChildWindow(HWND hwnd, const ChildWndInfo& info); ChildWindow(HWND hwnd, const ChildWndInfo& info);
@ -325,20 +340,6 @@ protected:
#define PM_SETSTATUSTEXT (WM_APP+0x1E) #define PM_SETSTATUSTEXT (WM_APP+0x1E)
/**
PreTranslateWindow is used to register windows to be called by Window::pretranslate_msg().
This way you get PM_TRANSLATE_MSG messages before the message loop dispatches messages.
You can then for example use TranslateAccelerator() to implement key shortcuts.
*/
struct PreTranslateWindow : public Window
{
typedef Window super;
PreTranslateWindow(HWND);
~PreTranslateWindow();
};
/** /**
The class DialogWindow implements modeless dialogs, which are managed by The class DialogWindow implements modeless dialogs, which are managed by
Window::dispatch_dialog_msg() in Window::MessageLoop(). Window::dispatch_dialog_msg() in Window::MessageLoop().

View file

@ -1130,8 +1130,11 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors",,0x00000012
HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",2,"localspl.dll" HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",2,"localspl.dll"
HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers",,0x00000012 HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers",,0x00000012
HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType",2,"WinNT" HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType",2,"ServerNT"
HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002,"" HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002,"Terminal Server"
; ReactOS specific - by default we report ourselves as Server for the user,
; but we can also report as Workstation if some application needs it.
HKLM,"SYSTEM\CurrentControlSet\Control\ReactOS\Settings\Version","ReportAsWorkstation",0x00010001,0x00000000
; Some installers check for SP1 ; Some installers check for SP1
HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDVersion",0x00010001,0x00000100 HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDVersion",0x00010001,0x00000100

View file

@ -1130,8 +1130,11 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors",,0x00000012
HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",2,"localspl.dll" HKLM,"SYSTEM\CurrentControlSet\Control\Print\Monitors\Local Port","Driver",2,"localspl.dll"
HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers",,0x00000012 HKLM,"SYSTEM\CurrentControlSet\Control\Print\Printers",,0x00000012
HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType",2,"WinNT" HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType",2,"ServerNT"
HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002,"" HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002,"Terminal Server"
; ReactOS specific - by default we report ourselves as Server for the user,
; but we can also report as Workstation if some application needs it.
HKLM,"SYSTEM\CurrentControlSet\Control\ReactOS\Settings\Version","ReportAsWorkstation",0x00010001,0x00000000
; Some installers check for SP1 ; Some installers check for SP1
HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDVersion",0x00010001,0x00000100 HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDVersion",0x00010001,0x00000100

View file

@ -8,13 +8,64 @@
* Created 01/11/98 * Created 01/11/98
*/ */
/* INCLUDES ****************************************************************/ /* INCLUDES *******************************************************************/
#include <ntdll.h> #include <ntdll.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ******************************************************************/
/* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
static VOID NTAPI
SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
{
CHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
PKEY_VALUE_PARTIAL_INFORMATION kvpInfo = (PVOID)Buffer;
OBJECT_ATTRIBUTES ObjectAttributes;
ULONG ReportAsWorkstation = 0;
HANDLE hKey;
ULONG Length;
NTSTATUS Status;
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
UNICODE_STRING ValName = RTL_CONSTANT_STRING(L"ReportAsWorkstation");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
NULL,
NULL);
/* Don't change anything if the key doesn't exist */
Status = NtOpenKey(&hKey, KEY_READ, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Get the value from the registry and make sure it's a 32-bit value */
Status = NtQueryValueKey(hKey,
&ValName,
KeyValuePartialInformation,
kvpInfo,
sizeof(Buffer),
&Length);
if (NT_SUCCESS(Status) &&
(kvpInfo->Type == REG_DWORD) &&
(kvpInfo->DataLength == sizeof(ULONG)))
{
/* Is the value set? */
ReportAsWorkstation = *(PULONG)kvpInfo->Data;
if ((VersionInformation->wProductType == VER_NT_SERVER) &&
(ReportAsWorkstation != 0))
{
/* It is, modify the product type to report a workstation */
VersionInformation->wProductType = VER_NT_WORKSTATION;
DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
}
}
/* Close the handle */
NtClose(hKey);
}
}
/********************************************************************** /**********************************************************************
* NAME EXPORTED * NAME EXPORTED
@ -40,12 +91,11 @@
* *
* @implemented * @implemented
*/ */
BOOLEAN NTAPI BOOLEAN NTAPI
RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType) RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
{ {
*ProductType = SharedUserData->NtProductType; *ProductType = SharedUserData->NtProductType;
return(TRUE); return TRUE;
} }
/********************************************************************** /**********************************************************************
@ -71,7 +121,6 @@ RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
* *
* @implemented * @implemented
*/ */
VOID NTAPI VOID NTAPI
RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion, RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
OUT LPDWORD pdwMinorVersion, OUT LPDWORD pdwMinorVersion,
@ -102,42 +151,49 @@ RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
/* /*
* @implemented * @implemented
* @note User-mode version of RtlGetVersion in ntoskrnl/rtl/misc.c
*/ */
NTSTATUS NTAPI NTSTATUS NTAPI
RtlGetVersion(RTL_OSVERSIONINFOW *Info) RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
{ {
LONG i, MaxLength; LONG i, MaxLength;
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) || if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW)) lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{ {
PPEB Peb = NtCurrentPeb(); PPEB Peb = NtCurrentPeb();
Info->dwMajorVersion = Peb->OSMajorVersion; lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
Info->dwMinorVersion = Peb->OSMinorVersion; lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
Info->dwBuildNumber = Peb->OSBuildNumber; lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
Info->dwPlatformId = Peb->OSPlatformId; lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion)); RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0) if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
{ {
MaxLength = (sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1; MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
i = _snwprintf(Info->szCSDVersion, i = _snwprintf(lpVersionInformation->szCSDVersion,
MaxLength, MaxLength,
L"Service Pack %d", L"Service Pack %d",
((Peb->OSCSDVersion >> 8) & 0xFF)); ((Peb->OSCSDVersion >> 8) & 0xFF));
if (i < 0) if (i < 0)
{ {
/* null-terminate if it was overflowed */ /* Null-terminate if it was overflowed */
Info->szCSDVersion[MaxLength] = L'\0'; lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
} }
} }
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{ {
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info; PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF; InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF; InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF; InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
InfoEx->wProductType = SharedUserData->NtProductType; InfoEx->wProductType = SharedUserData->NtProductType;
InfoEx->wReserved = 0;
/* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
SetRosSpecificInfo(InfoEx);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;

View file

@ -57,10 +57,6 @@
#define FN_PROGRESSA FN_PROGRESS #define FN_PROGRESSA FN_PROGRESS
#endif #endif
/* sid.c */
BOOL ADVAPI_GetComputerSid(PSID sid);
/* rpc.c */ /* rpc.c */
RPC_STATUS EvtBindRpc(LPCWSTR pszMachine, RPC_STATUS EvtBindRpc(LPCWSTR pszMachine,

View file

@ -299,67 +299,6 @@ static __inline BOOL set_ntstatus( NTSTATUS status )
return !status; return !status;
} }
/************************************************************
* ADVAPI_GetComputerSid
*
* Reads the computer SID from the registry.
*/
BOOL ADVAPI_GetComputerSid(PSID sid)
{
HKEY key;
LONG ret;
BOOL retval = FALSE;
static const WCHAR Account[] = { 'S','E','C','U','R','I','T','Y','\\','S','A','M','\\','D','o','m','a','i','n','s','\\','A','c','c','o','u','n','t',0 };
static const WCHAR V[] = { 'V',0 };
if ((ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, Account, 0,
KEY_READ, &key)) == ERROR_SUCCESS)
{
DWORD size = 0;
ret = RegQueryValueExW(key, V, NULL, NULL, NULL, &size);
if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
{
BYTE * data = HeapAlloc(GetProcessHeap(), 0, size);
if (data)
{
if ((ret = RegQueryValueExW(key, V, NULL, NULL,
data, &size)) == ERROR_SUCCESS)
{
/* the SID is in the last 24 bytes of the binary data */
CopyMemory(sid, &data[size-24], 24);
retval = TRUE;
}
HeapFree(GetProcessHeap(), 0, data);
}
}
RegCloseKey(key);
}
if(retval == TRUE) return retval;
/* create a new random SID */
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, Account,
0, NULL, 0, KEY_ALL_ACCESS, NULL, &key, NULL) == ERROR_SUCCESS)
{
PSID new_sid;
SID_IDENTIFIER_AUTHORITY identifierAuthority = {SECURITY_NT_AUTHORITY};
DWORD id[3];
if (RtlGenRandom(id, sizeof(id)))
{
if (AllocateAndInitializeSid(&identifierAuthority, 4, SECURITY_NT_NON_UNIQUE, id[0], id[1], id[2], 0, 0, 0, 0, &new_sid))
{
if (RegSetValueExW(key, V, 0, REG_BINARY, new_sid, GetLengthSid(new_sid)) == ERROR_SUCCESS)
retval = CopySid(GetLengthSid(new_sid), sid, new_sid);
FreeSid(new_sid);
}
}
RegCloseKey(key);
}
return retval;
}
/* Exported functions */ /* Exported functions */
@ -794,6 +733,7 @@ ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCRIPTOR Securi
{ {
LPWSTR wstr; LPWSTR wstr;
ULONG len; ULONG len;
if (ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, SDRevision, Information, &wstr, &len)) if (ConvertSecurityDescriptorToStringSecurityDescriptorW(SecurityDescriptor, SDRevision, Information, &wstr, &len))
{ {
int lenA; int lenA;
@ -1123,8 +1063,11 @@ static DWORD ParseAceStringRights(LPCWSTR* StringAcl)
* *
* dacl_flags(string_ace1)(string_ace2)... (string_acen) * dacl_flags(string_ace1)(string_ace2)... (string_acen)
*/ */
static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags, static BOOL
PACL pAcl, LPDWORD cBytes) ParseStringAclToAcl(LPCWSTR StringAcl,
LPDWORD lpdwFlags,
PACL pAcl,
LPDWORD cBytes)
{ {
DWORD val; DWORD val;
DWORD sidlen; DWORD sidlen;
@ -1238,8 +1181,8 @@ lerr:
/****************************************************************************** /******************************************************************************
* ParseStringSecurityDescriptorToSecurityDescriptor * ParseStringSecurityDescriptorToSecurityDescriptor
*/ */
static BOOL ParseStringSecurityDescriptorToSecurityDescriptor( static BOOL
LPCWSTR StringSecurityDescriptor, ParseStringSecurityDescriptorToSecurityDescriptor(LPCWSTR StringSecurityDescriptor,
SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor, SECURITY_DESCRIPTOR_RELATIVE* SecurityDescriptor,
LPDWORD cBytes) LPDWORD cBytes)
{ {
@ -1378,8 +1321,8 @@ lend:
* ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@] * ConvertStringSecurityDescriptorToSecurityDescriptorW [ADVAPI32.@]
* @implemented * @implemented
*/ */
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW( BOOL WINAPI
LPCWSTR StringSecurityDescriptor, ConvertStringSecurityDescriptorToSecurityDescriptorW(LPCWSTR StringSecurityDescriptor,
DWORD StringSDRevision, DWORD StringSDRevision,
PSECURITY_DESCRIPTOR* SecurityDescriptor, PSECURITY_DESCRIPTOR* SecurityDescriptor,
PULONG SecurityDescriptorSize) PULONG SecurityDescriptorSize)
@ -1440,8 +1383,9 @@ lend:
* ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@] * ConvertStringSecurityDescriptorToSecurityDescriptorA [ADVAPI32.@]
* @implemented * @implemented
*/ */
BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA( BOOL
LPCSTR StringSecurityDescriptor, WINAPI
ConvertStringSecurityDescriptorToSecurityDescriptorA(LPCSTR StringSecurityDescriptor,
DWORD StringSDRevision, DWORD StringSDRevision,
PSECURITY_DESCRIPTOR* SecurityDescriptor, PSECURITY_DESCRIPTOR* SecurityDescriptor,
PULONG SecurityDescriptorSize) PULONG SecurityDescriptorSize)
@ -1469,7 +1413,8 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
EqualPrefixSid(PSID pSid1, EqualPrefixSid(PSID pSid1,
PSID pSid2) PSID pSid2)
{ {
@ -1480,7 +1425,8 @@ EqualPrefixSid(PSID pSid1,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
EqualSid(PSID pSid1, EqualSid(PSID pSid1,
PSID pSid2) PSID pSid2)
{ {
@ -1495,7 +1441,8 @@ EqualSid(PSID pSid1,
* Docs says this function does NOT return a value * Docs says this function does NOT return a value
* even thou it's defined to return a PVOID... * even thou it's defined to return a PVOID...
*/ */
PVOID WINAPI PVOID
WINAPI
FreeSid(PSID pSid) FreeSid(PSID pSid)
{ {
return RtlFreeSid(pSid); return RtlFreeSid(pSid);
@ -1505,7 +1452,8 @@ FreeSid(PSID pSid)
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WINAPI
GetLengthSid(PSID pSid) GetLengthSid(PSID pSid)
{ {
return (DWORD)RtlLengthSid(pSid); return (DWORD)RtlLengthSid(pSid);
@ -1515,7 +1463,8 @@ GetLengthSid(PSID pSid)
/* /*
* @implemented * @implemented
*/ */
PSID_IDENTIFIER_AUTHORITY WINAPI PSID_IDENTIFIER_AUTHORITY
WINAPI
GetSidIdentifierAuthority(PSID pSid) GetSidIdentifierAuthority(PSID pSid)
{ {
return RtlIdentifierAuthoritySid(pSid); return RtlIdentifierAuthoritySid(pSid);
@ -1525,7 +1474,8 @@ GetSidIdentifierAuthority(PSID pSid)
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WINAPI
GetSidLengthRequired(UCHAR nSubAuthorityCount) GetSidLengthRequired(UCHAR nSubAuthorityCount)
{ {
return (DWORD)RtlLengthRequiredSid(nSubAuthorityCount); return (DWORD)RtlLengthRequiredSid(nSubAuthorityCount);
@ -1535,7 +1485,8 @@ GetSidLengthRequired(UCHAR nSubAuthorityCount)
/* /*
* @implemented * @implemented
*/ */
PDWORD WINAPI PDWORD
WINAPI
GetSidSubAuthority(PSID pSid, GetSidSubAuthority(PSID pSid,
DWORD nSubAuthority) DWORD nSubAuthority)
{ {
@ -1546,7 +1497,8 @@ GetSidSubAuthority(PSID pSid,
/* /*
* @implemented * @implemented
*/ */
PUCHAR WINAPI PUCHAR
WINAPI
GetSidSubAuthorityCount(PSID pSid) GetSidSubAuthorityCount(PSID pSid)
{ {
return RtlSubAuthorityCountSid(pSid); return RtlSubAuthorityCountSid(pSid);
@ -1556,7 +1508,8 @@ GetSidSubAuthorityCount(PSID pSid)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
InitializeSid(PSID Sid, InitializeSid(PSID Sid,
PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
BYTE nSubAuthorityCount) BYTE nSubAuthorityCount)
@ -1579,7 +1532,8 @@ InitializeSid(PSID Sid,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
IsValidSid(PSID pSid) IsValidSid(PSID pSid)
{ {
return (BOOL)RtlValidSid(pSid); return (BOOL)RtlValidSid(pSid);
@ -1589,7 +1543,8 @@ IsValidSid(PSID pSid)
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
ConvertSidToStringSidW(PSID Sid, ConvertSidToStringSidW(PSID Sid,
LPWSTR *StringSid) LPWSTR *StringSid)
{ {
@ -1643,7 +1598,8 @@ ConvertSidToStringSidW(PSID Sid,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
ConvertSidToStringSidA(PSID Sid, ConvertSidToStringSidA(PSID Sid,
LPSTR *StringSid) LPSTR *StringSid)
{ {
@ -1687,7 +1643,8 @@ ConvertSidToStringSidA(PSID Sid,
/* /*
* @unimplemented * @unimplemented
*/ */
BOOL WINAPI BOOL
WINAPI
EqualDomainSid(IN PSID pSid1, EqualDomainSid(IN PSID pSid1,
IN PSID pSid2, IN PSID pSid2,
OUT BOOL* pfEqual) OUT BOOL* pfEqual)
@ -1700,7 +1657,8 @@ EqualDomainSid(IN PSID pSid1,
/* /*
* @unimplemented * @unimplemented
*/ */
BOOL WINAPI BOOL
WINAPI
GetWindowsAccountDomainSid(IN PSID pSid, GetWindowsAccountDomainSid(IN PSID pSid,
OUT PSID ppDomainSid, OUT PSID ppDomainSid,
IN OUT DWORD* cbSid) IN OUT DWORD* cbSid)
@ -1713,7 +1671,8 @@ GetWindowsAccountDomainSid(IN PSID pSid,
/* /*
* @unimplemented * @unimplemented
*/ */
BOOL WINAPI BOOL
WINAPI
CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType, CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType,
IN PSID DomainSid OPTIONAL, IN PSID DomainSid OPTIONAL,
OUT PSID pSid, OUT PSID pSid,
@ -1787,7 +1746,8 @@ CreateWellKnownSid(IN WELL_KNOWN_SID_TYPE WellKnownSidType,
/* /*
* @unimplemented * @unimplemented
*/ */
BOOL WINAPI BOOL
WINAPI
IsWellKnownSid(IN PSID pSid, IsWellKnownSid(IN PSID pSid,
IN WELL_KNOWN_SID_TYPE WellKnownSidType) IN WELL_KNOWN_SID_TYPE WellKnownSidType)
{ {
@ -1810,7 +1770,8 @@ IsWellKnownSid(IN PSID pSid,
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
ConvertStringSidToSidA(IN LPCSTR StringSid, ConvertStringSidToSidA(IN LPCSTR StringSid,
OUT PSID* sid) OUT PSID* sid)
{ {
@ -1879,7 +1840,8 @@ static const RECORD SidTable[] =
/* /*
* @implemented * @implemented
*/ */
BOOL WINAPI BOOL
WINAPI
ConvertStringSidToSidW(IN LPCWSTR StringSid, ConvertStringSidToSidW(IN LPCWSTR StringSid,
OUT PSID* sid) OUT PSID* sid)
{ {
@ -1895,6 +1857,7 @@ ConvertStringSidToSidW(IN LPCWSTR StringSid,
SetLastError(ERROR_INVALID_SID); SetLastError(ERROR_INVALID_SID);
return FALSE; return FALSE;
} }
for (i = 0; i < sizeof(SidTable) / sizeof(SidTable[0]) - 1; i++) for (i = 0; i < sizeof(SidTable) / sizeof(SidTable[0]) - 1; i++)
{ {
if (wcscmp(StringSid, SidTable[i].key) == 0) if (wcscmp(StringSid, SidTable[i].key) == 0)
@ -1907,8 +1870,7 @@ ConvertStringSidToSidW(IN LPCWSTR StringSid,
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
} }
ret = CreateWellKnownSid( ret = CreateWellKnownSid(knownSid,
knownSid,
NULL, NULL,
*sid, *sid,
&size); &size);
@ -2005,5 +1967,4 @@ lend:
return ret; return ret;
} }
/* EOF */ /* EOF */

View file

@ -14,57 +14,6 @@
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID
NTAPI
SetRosSpecificInfo(IN LPOSVERSIONINFOEXW VersionInformation)
{
CHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(DWORD)];
PKEY_VALUE_PARTIAL_INFORMATION kvpInfo = (PVOID)Buffer;
OBJECT_ATTRIBUTES ObjectAttributes;
DWORD ReportAsWorkstation = 0;
HANDLE hKey;
DWORD dwSize;
NTSTATUS Status;
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
UNICODE_STRING ValName = RTL_CONSTANT_STRING(L"ReportAsWorkstation");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
NULL,
NULL);
/* Don't change anything if the key doesn't exist */
Status = NtOpenKey(&hKey, KEY_READ, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Get the value from the registry and make sure it's a 32-bit value */
Status = NtQueryValueKey(hKey,
&ValName,
KeyValuePartialInformation,
kvpInfo,
sizeof(Buffer),
&dwSize);
if ((NT_SUCCESS(Status)) &&
(kvpInfo->Type == REG_DWORD) &&
(kvpInfo->DataLength == sizeof(DWORD)))
{
/* Is the value set? */
ReportAsWorkstation = *(PULONG)kvpInfo->Data;
if ((VersionInformation->wProductType == VER_NT_SERVER) &&
(ReportAsWorkstation))
{
/* It is, modify the product type to report a workstation */
VersionInformation->wProductType = VER_NT_WORKSTATION;
DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
}
}
/* Close the handle */
NtClose(hKey);
}
}
/* /*
* @implemented * @implemented
*/ */
@ -104,9 +53,6 @@ GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
{ {
lpVersionInformationEx = (PVOID)lpVersionInformation; lpVersionInformationEx = (PVOID)lpVersionInformation;
lpVersionInformationEx->wReserved = 0; lpVersionInformationEx->wReserved = 0;
/* ReactOS specific changes */
SetRosSpecificInfo(lpVersionInformationEx);
} }
return TRUE; return TRUE;

View file

@ -28,5 +28,7 @@ target_link_libraries(netapi32 wine)
add_importlibs(netapi32 iphlpapi ws2_32 advapi32 msvcrt kernel32 ntdll) add_importlibs(netapi32 iphlpapi ws2_32 advapi32 msvcrt kernel32 ntdll)
add_delay_importlibs(netapi32 samlib)
add_cd_file(TARGET netapi32 DESTINATION reactos/system32 FOR all) add_cd_file(TARGET netapi32 DESTINATION reactos/system32 FOR all)

View file

@ -34,8 +34,122 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#define NTOS_MODE_USER
#include <ndk/rtlfuncs.h>
#include "ntsam.h"
#include "netapi32.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32); WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
typedef struct _ENUM_CONTEXT
{
SAM_HANDLE ServerHandle;
SAM_HANDLE BuiltinDomainHandle;
SAM_HANDLE AccountDomainHandle;
SAM_ENUMERATE_HANDLE EnumerationContext;
PSAM_RID_ENUMERATION Buffer;
ULONG Returned;
ULONG Index;
BOOLEAN BuiltinDone;
} ENUM_CONTEXT, *PENUM_CONTEXT;
static SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
static
NTSTATUS
GetAccountDomainSid(PSID *AccountDomainSid)
{
PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo = NULL;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle = NULL;
ULONG Length = 0;
NTSTATUS Status;
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
Status = LsaOpenPolicy(NULL,
&ObjectAttributes,
POLICY_VIEW_LOCAL_INFORMATION,
&PolicyHandle);
if (!NT_SUCCESS(Status))
{
ERR("LsaOpenPolicy failed (Status %08lx)\n", Status);
return Status;
}
Status = LsaQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation,
(PVOID *)&AccountDomainInfo);
if (!NT_SUCCESS(Status))
{
ERR("LsaQueryInformationPolicy failed (Status %08lx)\n", Status);
goto done;
}
Length = RtlLengthSid(AccountDomainInfo->DomainSid);
*AccountDomainSid = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
if (*AccountDomainSid == NULL)
{
ERR("Failed to allocate SID\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
goto done;
}
memcpy(*AccountDomainSid, AccountDomainInfo->DomainSid, Length);
done:
if (AccountDomainInfo != NULL)
LsaFreeMemory(AccountDomainInfo);
LsaClose(PolicyHandle);
return Status;
}
static
NTSTATUS
GetBuiltinDomainSid(PSID *BuiltinDomainSid)
{
PSID Sid = NULL;
PULONG Ptr;
NTSTATUS Status = STATUS_SUCCESS;
*BuiltinDomainSid = NULL;
Sid = RtlAllocateHeap(RtlGetProcessHeap(),
0,
RtlLengthRequiredSid(1));
if (Sid == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
Status = RtlInitializeSid(Sid,
&NtAuthority,
1);
if (!NT_SUCCESS(Status))
goto done;
Ptr = RtlSubAuthoritySid(Sid, 0);
*Ptr = SECURITY_BUILTIN_DOMAIN_RID;
*BuiltinDomainSid = Sid;
done:
if (!NT_SUCCESS(Status))
{
if (Sid != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, Sid);
}
return Status;
}
/************************************************************ /************************************************************
* NetLocalGroupAdd (NETAPI32.@) * NetLocalGroupAdd (NETAPI32.@)
*/ */
@ -129,11 +243,236 @@ NET_API_STATUS WINAPI NetLocalGroupEnum(
LPDWORD totalentries, LPDWORD totalentries,
PDWORD_PTR resumehandle) PDWORD_PTR resumehandle)
{ {
PSAM_RID_ENUMERATION CurrentAlias;
PENUM_CONTEXT EnumContext = NULL;
PSID DomainSid = NULL;
ULONG i;
SAM_HANDLE AliasHandle = NULL;
PALIAS_GENERAL_INFORMATION AliasInfo = NULL;
NET_API_STATUS ApiStatus = NERR_Success;
NTSTATUS Status = STATUS_SUCCESS;
FIXME("(%s %d %p %d %p %p %p) stub!\n", debugstr_w(servername), FIXME("(%s %d %p %d %p %p %p) stub!\n", debugstr_w(servername),
level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle); level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
*entriesread = 0; *entriesread = 0;
*totalentries = 0; *totalentries = 0;
return NERR_Success; *bufptr = NULL;
if (resumehandle != NULL && *resumehandle != 0)
{
EnumContext = (PENUM_CONTEXT)resumehandle;
}
else
{
ApiStatus = NetApiBufferAllocate(sizeof(ENUM_CONTEXT), (PVOID*)&EnumContext);
if (ApiStatus != NERR_Success)
goto done;
EnumContext->EnumerationContext = 0;
EnumContext->Buffer = NULL;
EnumContext->Returned = 0;
EnumContext->Index = 0;
EnumContext->BuiltinDone = FALSE;
Status = SamConnect(NULL,
&EnumContext->ServerHandle,
SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
NULL);
if (!NT_SUCCESS(Status))
{
ERR("SamConnect failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = GetAccountDomainSid(&DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = SamOpenDomain(EnumContext->ServerHandle,
DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP,
DomainSid,
&EnumContext->AccountDomainHandle);
RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("SamOpenDomain failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = GetBuiltinDomainSid(&DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = SamOpenDomain(EnumContext->ServerHandle,
DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP,
DomainSid,
&EnumContext->BuiltinDomainHandle);
RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
if (!NT_SUCCESS(Status))
{
ERR("SamOpenDomain failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
}
while (TRUE)
{
if (EnumContext->Index >= EnumContext->Returned)
{
if (EnumContext->BuiltinDone == TRUE)
{
ApiStatus = NERR_Success;
goto done;
}
TRACE("Calling SamEnumerateAliasesInDomain\n");
Status = SamEnumerateAliasesInDomain(EnumContext->BuiltinDomainHandle,
&EnumContext->EnumerationContext,
(PVOID *)&EnumContext->Buffer,
prefmaxlen,
&EnumContext->Returned);
TRACE("SamEnumerateAliasesInDomain returned (Status %08lx)\n", Status);
if (!NT_SUCCESS(Status))
{
ERR("SamEnumerateAliasesInDomain failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
if (Status == STATUS_MORE_ENTRIES)
{
ApiStatus = NERR_BufTooSmall;
goto done;
}
else
{
EnumContext->BuiltinDone = TRUE;
}
}
TRACE("EnumContext: %lu\n", EnumContext);
TRACE("EnumContext->Returned: %lu\n", EnumContext->Returned);
TRACE("EnumContext->Buffer: %p\n", EnumContext->Buffer);
/* Get a pointer to the current alias */
CurrentAlias = &EnumContext->Buffer[EnumContext->Index];
TRACE("RID: %lu\n", CurrentAlias->RelativeId);
Status = SamOpenAlias(EnumContext->BuiltinDomainHandle,
ALIAS_READ_INFORMATION,
CurrentAlias->RelativeId,
&AliasHandle);
if (!NT_SUCCESS(Status))
{
ERR("SamOpenAlias failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
Status = SamQueryInformationAlias(AliasHandle,
AliasGeneralInformation,
(PVOID *)&AliasInfo);
if (!NT_SUCCESS(Status))
{
ERR("SamQueryInformationAlias failed (Status %08lx)\n", Status);
ApiStatus = NetpNtStatusToApiStatus(Status);
goto done;
}
SamCloseHandle(AliasHandle);
AliasHandle = NULL;
TRACE("Name: %S\n", AliasInfo->Name.Buffer);
TRACE("Comment: %S\n", AliasInfo->AdminComment.Buffer);
if (AliasInfo != NULL)
{
if (AliasInfo->Name.Buffer != NULL)
SamFreeMemory(AliasInfo->Name.Buffer);
if (AliasInfo->AdminComment.Buffer != NULL)
SamFreeMemory(AliasInfo->AdminComment.Buffer);
SamFreeMemory(AliasInfo);
AliasInfo = NULL;
}
EnumContext->Index++;
}
done:
if (resumehandle == NULL || ApiStatus != ERROR_MORE_DATA)
{
if (EnumContext != NULL)
{
if (EnumContext->BuiltinDomainHandle != NULL)
SamCloseHandle(EnumContext->BuiltinDomainHandle);
if (EnumContext->AccountDomainHandle != NULL)
SamCloseHandle(EnumContext->AccountDomainHandle);
if (EnumContext->ServerHandle != NULL)
SamCloseHandle(EnumContext->ServerHandle);
if (EnumContext->Buffer != NULL)
{
for (i = 0; i < EnumContext->Returned; i++)
{
SamFreeMemory(EnumContext->Buffer[i].Name.Buffer);
}
SamFreeMemory(EnumContext->Buffer);
}
NetApiBufferFree(EnumContext);
EnumContext = NULL;
}
}
if (AliasHandle != NULL)
SamCloseHandle(AliasHandle);
if (AliasInfo != NULL)
{
if (AliasInfo->Name.Buffer != NULL)
SamFreeMemory(AliasInfo->Name.Buffer);
if (AliasInfo->AdminComment.Buffer != NULL)
SamFreeMemory(AliasInfo->AdminComment.Buffer);
SamFreeMemory(AliasInfo);
}
if (resumehandle != NULL)
*resumehandle = (DWORD_PTR)EnumContext;
return ApiStatus;
} }
/************************************************************ /************************************************************

View file

@ -16,12 +16,17 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#define WIN32_NO_STATUS
#include "config.h" #include "config.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "lm.h" #include "lm.h"
#include "netbios.h" #include "netbios.h"
#define NTOS_MODE_USER
#include <ndk/rtlfuncs.h>
#include "netapi32.h"
WINE_DEFAULT_DEBUG_CHANNEL(netbios); WINE_DEFAULT_DEBUG_CHANNEL(netbios);
static HMODULE NETAPI32_hModule; static HMODULE NETAPI32_hModule;
@ -211,6 +216,13 @@ DWORD WINAPI NetpNetBiosStatusToApiStatus(DWORD nrc)
return ret; return ret;
} }
NET_API_STATUS
WINAPI
NetpNtStatusToApiStatus(NTSTATUS Status)
{
return RtlNtStatusToDosError(Status);
}
NET_API_STATUS WINAPI NetUseEnum(LMSTR server, DWORD level, LPBYTE* bufptr, DWORD prefmaxsize, NET_API_STATUS WINAPI NetUseEnum(LMSTR server, DWORD level, LPBYTE* bufptr, DWORD prefmaxsize,
LPDWORD entriesread, LPDWORD totalentries, LPDWORD resumehandle) LPDWORD entriesread, LPDWORD totalentries, LPDWORD resumehandle)
{ {

View file

@ -0,0 +1,10 @@
#ifndef __WINE_NETAPI32_H__
#define __WINE_NETAPI32_H__
NET_API_STATUS
WINAPI
NetpNtStatusToApiStatus(NTSTATUS Status);
#endif

View file

@ -261,7 +261,7 @@
@ stub NetpNetBiosReset @ stub NetpNetBiosReset
@ stub NetpNetBiosSend @ stub NetpNetBiosSend
@ stdcall NetpNetBiosStatusToApiStatus(long) @ stdcall NetpNetBiosStatusToApiStatus(long)
@ stub NetpNtStatusToApiStatus @ stdcall NetpNtStatusToApiStatus(long)
@ stub NetpOpenConfigData @ stub NetpOpenConfigData
@ stub NetpPackString @ stub NetpPackString
@ stub NetpReleasePrivilege @ stub NetpReleasePrivilege

View file

@ -155,6 +155,7 @@ SamrShutdownSamServer(IN SAMPR_HANDLE ServerHandle)
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
} }
/* Function 5 */ /* Function 5 */
NTSTATUS NTSTATUS
NTAPI NTAPI
@ -264,6 +265,7 @@ SamrLookupDomainInSamServer(IN SAMPR_HANDLE ServerHandle,
return Status; return Status;
} }
/* Function 6 */ /* Function 6 */
NTSTATUS NTSTATUS
NTAPI NTAPI
@ -3868,12 +3870,8 @@ SampQueryAliasGeneral(PSAM_DB_OBJECT AliasObject,
L"Members", L"Members",
KEY_READ, KEY_READ,
&MembersKeyHandle); &MembersKeyHandle);
if (!NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
TRACE("Status 0x%08lx\n", Status);
goto done;
}
/* Retrieve the number of members of the alias */ /* Retrieve the number of members of the alias */
Status = SampRegQueryKeyInfo(MembersKeyHandle, Status = SampRegQueryKeyInfo(MembersKeyHandle,
NULL, NULL,
@ -3883,6 +3881,17 @@ SampQueryAliasGeneral(PSAM_DB_OBJECT AliasObject,
TRACE("Status 0x%08lx\n", Status); TRACE("Status 0x%08lx\n", Status);
goto done; goto done;
} }
}
else if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
{
InfoBuffer->General.MemberCount = 0;
Status = STATUS_SUCCESS;
}
else
{
TRACE("Status 0x%08lx\n", Status);
goto done;
}
*Buffer = InfoBuffer; *Buffer = InfoBuffer;

View file

@ -4,7 +4,7 @@
* PURPOSE: Runtime code * PURPOSE: Runtime code
* FILE: lib/rtl/version.c * FILE: lib/rtl/version.c
* PROGRAMERS: Filip Navara * PROGRAMERS: Filip Navara
* Hermes BELUSCA - MAITO * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -18,9 +18,7 @@
NTSTATUS NTSTATUS
NTAPI NTAPI
RtlGetVersion( RtlGetVersion(OUT PRTL_OSVERSIONINFOW lpVersionInformation);
OUT PRTL_OSVERSIONINFOW lpVersionInformation
);
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
@ -54,11 +52,9 @@ RtlpVerCompare(ULONG left, ULONG right, UCHAR condition)
*/ */
NTSTATUS NTSTATUS
NTAPI NTAPI
RtlVerifyVersionInfo( RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
IN PRTL_OSVERSIONINFOEXW VersionInfo,
IN ULONG TypeMask, IN ULONG TypeMask,
IN ULONGLONG ConditionMask IN ULONGLONG ConditionMask)
)
{ {
RTL_OSVERSIONINFOEXW ver; RTL_OSVERSIONINFOEXW ver;
NTSTATUS status; NTSTATUS status;

View file

@ -678,7 +678,7 @@ MmCreatePeb(IN PEPROCESS Process,
Peb->OSMajorVersion = NtMajorVersion; Peb->OSMajorVersion = NtMajorVersion;
Peb->OSMinorVersion = NtMinorVersion; Peb->OSMinorVersion = NtMinorVersion;
Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF); Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF);
Peb->OSPlatformId = 2; /* VER_PLATFORM_WIN32_NT */ Peb->OSPlatformId = VER_PLATFORM_WIN32_NT;
Peb->OSCSDVersion = (USHORT)CmNtCSDVersion; Peb->OSCSDVersion = (USHORT)CmNtCSDVersion;
// //

View file

@ -29,10 +29,9 @@ ULONG
NTAPI NTAPI
RtlGetNtGlobalFlags(VOID) RtlGetNtGlobalFlags(VOID)
{ {
return(NtGlobalFlag); return NtGlobalFlag;
} }
/* /*
* @implemented * @implemented
*/ */
@ -41,6 +40,7 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
{ {
LONG i; LONG i;
ULONG MaxLength; ULONG MaxLength;
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) || if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW)) lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{ {
@ -49,6 +49,7 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
lpVersionInformation->dwBuildNumber = NtBuildNumber; lpVersionInformation->dwBuildNumber = NtBuildNumber;
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT; lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
if(((CmNtCSDVersion >> 8) & 0xFF) != 0) if(((CmNtCSDVersion >> 8) & 0xFF) != 0)
{ {
MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1; MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
@ -58,17 +59,19 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
((CmNtCSDVersion >> 8) & 0xFF)); ((CmNtCSDVersion >> 8) & 0xFF));
if (i < 0) if (i < 0)
{ {
/* null-terminate if it was overflowed */ /* Null-terminate if it was overflowed */
lpVersionInformation->szCSDVersion[MaxLength] = L'\0'; lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
} }
} }
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{ {
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation; PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF; InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF); InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF); InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
InfoEx->wProductType = SharedUserData->NtProductType; InfoEx->wProductType = SharedUserData->NtProductType;
InfoEx->wReserved = 0;
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -77,3 +80,4 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
/* EOF */

View file

@ -11,6 +11,10 @@ if(USE_DIBLIB)
add_subdirectory(gdi/diblib) add_subdirectory(gdi/diblib)
endif() endif()
if(USE_NEW_CURSORICON)
add_definitions(-DNEW_CURSORICON)
endif()
add_subdirectory(gdi/gdi32) add_subdirectory(gdi/gdi32)
add_subdirectory(reactx) add_subdirectory(reactx)
add_subdirectory(user/consrv) add_subdirectory(user/consrv)
@ -190,7 +194,6 @@ else()
endif() endif()
if(USE_NEW_CURSORICON) if(USE_NEW_CURSORICON)
add_definitions(-DNEW_CURSORICON)
list(APPEND SOURCE user/ntuser/cursoricon_new.c) list(APPEND SOURCE user/ntuser/cursoricon_new.c)
else() else()
list(APPEND SOURCE user/ntuser/cursoricon.c) list(APPEND SOURCE user/ntuser/cursoricon.c)

View file

@ -48,14 +48,17 @@ list(APPEND SOURCE
add_library(gdi32 SHARED ${SOURCE}) add_library(gdi32 SHARED ${SOURCE})
set_module_type(gdi32 win32dll UNICODE) set_module_type(gdi32
win32dll
ENTRYPOINT DllMain 12
UNICODE)
target_link_libraries(gdi32 target_link_libraries(gdi32
win32ksys win32ksys
dxguid dxguid
${PSEH_LIB}) ${PSEH_LIB})
add_importlibs(gdi32 user32 advapi32 msvcrt kernel32 ntdll) add_importlibs(gdi32 user32 advapi32 kernel32 ntdll)
add_pch(gdi32 include/precomp.h) add_pch(gdi32 include/precomp.h)
add_cd_file(TARGET gdi32 DESTINATION reactos/system32 FOR all) add_cd_file(TARGET gdi32 DESTINATION reactos/system32 FOR all)

View file

@ -1659,8 +1659,8 @@ NtUserDestroyAcceleratorTable(
BOOL BOOL
NTAPI NTAPI
NtUserDestroyCursor( NtUserDestroyCursor(
HANDLE Handle, _In_ HANDLE Handle,
DWORD Unknown); _In_ BOOL bForce);
DWORD DWORD
NTAPI NTAPI
@ -1818,14 +1818,6 @@ NtUserFillWindow(
HDC hDC, HDC hDC,
HBRUSH hBrush); HBRUSH hBrush);
HICON
NTAPI
NtUserFindExistingCursorIcon(
HMODULE hModule,
HRSRC hRsrc,
LONG cx,
LONG cy);
HWND HWND
NTAPI NTAPI
NtUserFindWindowEx( NtUserFindWindowEx(
@ -1998,12 +1990,12 @@ NtUserGetGUIThreadInfo(
BOOL BOOL
NTAPI NTAPI
NtUserGetIconInfo( NtUserGetIconInfo(
HANDLE hCurIcon, _In_ HANDLE hCurIcon,
PICONINFO IconInfo, _Out_opt_ PICONINFO IconInfo,
PUNICODE_STRING lpInstName, _Out_opt_ PUNICODE_STRING lpInstName,
PUNICODE_STRING lpResName, _Out_opt_ PUNICODE_STRING lpResName,
LPDWORD pbpp, _Out_opt_ LPDWORD pbpp,
BOOL bInternal); _In_ BOOL bInternal);
BOOL BOOL
NTAPI NTAPI
@ -2743,9 +2735,17 @@ BOOL
NTAPI NTAPI
NtUserSetCursorIconData( NtUserSetCursorIconData(
_In_ HCURSOR hCursor, _In_ HCURSOR hCursor,
_In_ HINSTANCE hinst, _In_ PUNICODE_STRING pustrModule,
_In_ HRSRC hrsrc, _In_ PUNICODE_STRING puSrcName,
_In_ PICONINFO pii); _In_ PICONINFO pii);
HICON
NTAPI
NtUserFindExistingCursorIcon(
_In_ PUNICODE_STRING pustrModule,
_In_ PUNICODE_STRING pustrRsrc,
_In_ LONG cxDesired,
_In_ LONG cyDesired);
#else #else
BOOL BOOL
NTAPI NTAPI
@ -2756,6 +2756,14 @@ NtUserSetCursorIconData(
HMODULE hModule, HMODULE hModule,
HRSRC hRsrc, HRSRC hRsrc,
HRSRC hGroupRsrc); HRSRC hGroupRsrc);
HICON
NTAPI
NtUserFindExistingCursorIcon(
HMODULE hModule,
HRSRC hRsrc,
LONG cx,
LONG cy);
#endif #endif
DWORD DWORD

View file

@ -88,7 +88,8 @@ typedef struct
typedef struct typedef struct
{ union { union
{ ICONRESDIR icon; {
ICONRESDIR icon;
CURSORDIR cursor; CURSORDIR cursor;
} ResInfo; } ResInfo;
WORD wPlanes; WORD wPlanes;

View file

@ -124,7 +124,7 @@ LookupFnIdToiCls(int FnId, int *iCls )
_Must_inspect_result_ _Must_inspect_result_
NTSTATUS NTSTATUS
NTAPI NTAPI
CaptureUnicodeStringOrAtom( ProbeAndCaptureUnicodeStringOrAtom(
_Out_ PUNICODE_STRING pustrOut, _Out_ PUNICODE_STRING pustrOut,
__in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe) __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe)
{ {
@ -2294,7 +2294,7 @@ NtUserUnregisterClass(
NTSTATUS Status; NTSTATUS Status;
BOOL Ret; BOOL Ret;
Status = CaptureUnicodeStringOrAtom(&SafeClassName, ClassNameOrAtom); Status = ProbeAndCaptureUnicodeStringOrAtom(&SafeClassName, ClassNameOrAtom);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR("Error capturing the class name\n"); ERR("Error capturing the class name\n");
@ -2346,7 +2346,7 @@ NtUserGetClassInfo(
} }
_SEH2_END; _SEH2_END;
Status = CaptureUnicodeStringOrAtom(&SafeClassName, ClassName); Status = ProbeAndCaptureUnicodeStringOrAtom(&SafeClassName, ClassName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR("Error capturing the class name\n"); ERR("Error capturing the class name\n");
@ -2480,7 +2480,7 @@ NtUserGetWOWClass(
RTL_ATOM ClassAtom = 0; RTL_ATOM ClassAtom = 0;
NTSTATUS Status; NTSTATUS Status;
Status = CaptureUnicodeStringOrAtom(&SafeClassName, ClassName); Status = ProbeAndCaptureUnicodeStringOrAtom(&SafeClassName, ClassName);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ERR("Error capturing the class name\n"); ERR("Error capturing the class name\n");

View file

@ -59,4 +59,11 @@ IntCheckProcessDesktopClasses(IN PDESKTOP Desktop,
ULONG_PTR FASTCALL UserGetCPD(PVOID,GETCPD,ULONG_PTR); ULONG_PTR FASTCALL UserGetCPD(PVOID,GETCPD,ULONG_PTR);
_Must_inspect_result_
NTSTATUS
NTAPI
ProbeAndCaptureUnicodeStringOrAtom(
_Out_ PUNICODE_STRING pustrOut,
__in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe);
/* EOF */ /* EOF */

View file

@ -204,7 +204,7 @@ IntFindExistingCurIconObject(HMODULE hModule,
} }
PCURICON_OBJECT PCURICON_OBJECT
IntCreateCurIconHandle() IntCreateCurIconHandle(DWORD dwNumber)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
HANDLE hCurIcon; HANDLE hCurIcon;
@ -613,8 +613,8 @@ NtUserClipCursor(
BOOL BOOL
APIENTRY APIENTRY
NtUserDestroyCursor( NtUserDestroyCursor(
HANDLE hCurIcon, _In_ HANDLE hCurIcon,
DWORD Unknown) _In_ BOOL bForce)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
BOOL ret; BOOL ret;

View file

@ -22,8 +22,8 @@ typedef struct _CURICON_OBJECT
LIST_ENTRY ListEntry; LIST_ENTRY ListEntry;
HANDLE Self; HANDLE Self;
LIST_ENTRY ProcessList; LIST_ENTRY ProcessList;
HMODULE hModule; UNICODE_STRING ustrModule;
HRSRC hRsrc; UNICODE_STRING ustrRsrc;
SIZE Size; SIZE Size;
BYTE Shadow; BYTE Shadow;
BOOL bIcon; BOOL bIcon;
@ -88,7 +88,7 @@ typedef struct _SYSTEM_CURSORINFO
} SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO; } SYSTEM_CURSORINFO, *PSYSTEM_CURSORINFO;
BOOL InitCursorImpl(VOID); BOOL InitCursorImpl(VOID);
PCURICON_OBJECT IntCreateCurIconHandle(VOID); PCURICON_OBJECT IntCreateCurIconHandle(DWORD dwNumber);
VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process); VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process);
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth,

View file

@ -169,25 +169,37 @@ ReferenceCurIconByProcess(PCURICON_OBJECT CurIcon)
return TRUE; return TRUE;
} }
PCURICON_OBJECT FASTCALL static
IntFindExistingCurIconObject(HMODULE hModule, PCURICON_OBJECT
HRSRC hRsrc, LONG cx, LONG cy) FASTCALL
IntFindExistingCurIconObject(
PUNICODE_STRING pustrModule,
PUNICODE_STRING pustrRsrc,
FINDEXISTINGCURICONPARAM* param)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
LIST_FOR_EACH(CurIcon, &gCurIconList, CURICON_OBJECT, ListEntry) LIST_FOR_EACH(CurIcon, &gCurIconList, CURICON_OBJECT, ListEntry)
{ {
/* See if we are looking for an icon or a cursor */
// if (NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon))) // <- huh???? if(CurIcon->bIcon != param->bIcon)
// UserReferenceObject( CurIcon); continue;
// { /* See if module names match */
if ((CurIcon->hModule == hModule) && (CurIcon->hRsrc == hRsrc)) if(RtlCompareUnicodeString(pustrModule, &CurIcon->ustrModule, TRUE) == 0)
{ {
if (cx && ((cx != CurIcon->Size.cx) || (cy != CurIcon->Size.cy))) /* They do. Now see if this is the same resource */
if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer) && IS_INTRESOURCE(pustrRsrc->Buffer))
{ {
// UserDereferenceObject(CurIcon); if(CurIcon->ustrRsrc.Buffer != pustrRsrc->Buffer)
continue; continue;
} }
else if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer) || IS_INTRESOURCE(pustrRsrc->Buffer))
continue;
else if(RtlCompareUnicodeString(pustrRsrc, &CurIcon->ustrRsrc, TRUE) != 0)
continue;
if ((param->cx == CurIcon->Size.cx) &&(param->cy == CurIcon->Size.cy))
{
if (! ReferenceCurIconByProcess(CurIcon)) if (! ReferenceCurIconByProcess(CurIcon))
{ {
return NULL; return NULL;
@ -195,21 +207,23 @@ IntFindExistingCurIconObject(HMODULE hModule,
return CurIcon; return CurIcon;
} }
// } }
// UserDereferenceObject(CurIcon);
} }
return NULL; return NULL;
} }
PCURICON_OBJECT PCURICON_OBJECT
IntCreateCurIconHandle() IntCreateCurIconHandle(DWORD dwNumber)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
BOOLEAN bIcon = dwNumber == 0;
HANDLE hCurIcon; HANDLE hCurIcon;
CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); if(dwNumber == 0)
dwNumber = 1;
CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, FIELD_OFFSET(CURICON_OBJECT, aFrame[dwNumber]));
if (!CurIcon) if (!CurIcon)
{ {
@ -218,6 +232,7 @@ IntCreateCurIconHandle()
} }
CurIcon->Self = hCurIcon; CurIcon->Self = hCurIcon;
CurIcon->bIcon = bIcon;
InitializeListHead(&CurIcon->ProcessList); InitializeListHead(&CurIcon->ProcessList);
if (! ReferenceCurIconByProcess(CurIcon)) if (! ReferenceCurIconByProcess(CurIcon))
@ -234,7 +249,7 @@ IntCreateCurIconHandle()
} }
BOOLEAN FASTCALL BOOLEAN FASTCALL
IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi) IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi, BOOLEAN bForce)
{ {
PSYSTEM_CURSORINFO CurInfo; PSYSTEM_CURSORINFO CurInfo;
HBITMAP bmpMask, bmpColor, bmpAlpha; HBITMAP bmpMask, bmpColor, bmpAlpha;
@ -261,9 +276,19 @@ IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi)
{ {
/* This object doesn't belong to this process */ /* This object doesn't belong to this process */
EngSetLastError(ERROR_INVALID_HANDLE); EngSetLastError(ERROR_INVALID_HANDLE);
/* Caller expects us to dereference! */
UserDereferenceObject(CurIcon);
return FALSE; return FALSE;
} }
/* We found our process, but we're told to not destroy it in case it is shared */
if((CurIcon->ustrModule.Buffer != NULL) && !bForce)
{
/* Tests show this is a valid call */
UserDereferenceObject(CurIcon);
return TRUE;
}
ExFreeToPagedLookasideList(pgProcessLookasideList, Current); ExFreeToPagedLookasideList(pgProcessLookasideList, Current);
/* If there are still processes referencing this object we can't destroy it yet */ /* If there are still processes referencing this object we can't destroy it yet */
@ -315,6 +340,11 @@ emptyList:
CurIcon->aFrame[0].hbmAlpha = NULL; CurIcon->aFrame[0].hbmAlpha = NULL;
} }
if(!IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer))
ExFreePoolWithTag(CurIcon->ustrRsrc.Buffer, TAG_STRING);
if(CurIcon->ustrModule.Buffer)
ReleaseCapturedUnicodeString(&CurIcon->ustrModule, UserMode);
/* We were given a pointer, no need to keep the reference anylonger! */ /* We were given a pointer, no need to keep the reference anylonger! */
UserDereferenceObject(CurIcon); UserDereferenceObject(CurIcon);
Ret = UserDeleteObject(CurIcon->Self, otCursorIcon); Ret = UserDeleteObject(CurIcon->Self, otCursorIcon);
@ -331,7 +361,7 @@ IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry) LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry)
{ {
UserReferenceObject(CurIcon); UserReferenceObject(CurIcon);
IntDestroyCurIconObject(CurIcon, Win32Process); IntDestroyCurIconObject(CurIcon, Win32Process, TRUE);
} }
} }
@ -342,12 +372,12 @@ IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process)
BOOL BOOL
APIENTRY APIENTRY
NtUserGetIconInfo( NtUserGetIconInfo(
HANDLE hCurIcon, _In_ HANDLE hCurIcon,
PICONINFO IconInfo, _Out_opt_ PICONINFO IconInfo,
PUNICODE_STRING lpInstName, // Optional _Out_opt_ PUNICODE_STRING lpModule, // Optional
PUNICODE_STRING lpResName, // Optional _Out_opt_ PUNICODE_STRING lpResName, // Optional
LPDWORD pbpp, // Optional _Out_opt_ LPDWORD pbpp, // Optional
BOOL bInternal) _In_ BOOL bInternal)
{ {
ICONINFO ii; ICONINFO ii;
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
@ -356,19 +386,27 @@ NtUserGetIconInfo(
DWORD colorBpp = 0; DWORD colorBpp = 0;
TRACE("Enter NtUserGetIconInfo\n"); TRACE("Enter NtUserGetIconInfo\n");
UserEnterExclusive();
if (!IconInfo) /* Check if something was actually asked */
if (!IconInfo && !lpModule && !lpResName)
{ {
WARN("Nothing to fill.\n");
EngSetLastError(ERROR_INVALID_PARAMETER); EngSetLastError(ERROR_INVALID_PARAMETER);
goto leave; return FALSE;
} }
UserEnterExclusive();
if (!(CurIcon = UserGetCurIconObject(hCurIcon))) if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
{ {
goto leave; WARN("UserGetIconObject(0x%08x) Failed.\n", hCurIcon);
UserLeave();
return FALSE;
} }
/* Give back the icon information */
if(IconInfo)
{
/* Fill data */ /* Fill data */
ii.fIcon = CurIcon->bIcon; ii.fIcon = CurIcon->bIcon;
ii.xHotspot = CurIcon->ptlHotspot.x; ii.xHotspot = CurIcon->ptlHotspot.x;
@ -376,7 +414,9 @@ NtUserGetIconInfo(
/* Copy bitmaps */ /* Copy bitmaps */
ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask); ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask);
GreSetObjectOwner(ii.hbmMask, GDI_OBJ_HMGR_POWNED);
ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor); ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor);
GreSetObjectOwner(ii.hbmColor, GDI_OBJ_HMGR_POWNED);
if (pbpp) if (pbpp)
{ {
@ -407,15 +447,84 @@ NtUserGetIconInfo(
Status = _SEH2_GetExceptionCode(); Status = _SEH2_GetExceptionCode();
} }
_SEH2_END _SEH2_END
}
if (NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
Ret = TRUE; {
else WARN("Status: 0x%08x.\n", Status);
SetLastNtError(Status); SetLastNtError(Status);
goto leave;
}
UserDereferenceObject(CurIcon); /* Give back the module name */
if(lpModule)
{
if(!CurIcon->ustrModule.Buffer)
{
EngSetLastError(ERROR_INVALID_HANDLE);
goto leave;
}
/* Copy what we can */
_SEH2_TRY
{
ProbeForWrite(lpModule, sizeof(UNICODE_STRING), 1);
ProbeForWrite(lpModule->Buffer, lpModule->MaximumLength, 1);
lpModule->Length = min(lpModule->MaximumLength, CurIcon->ustrModule.Length);
RtlCopyMemory(lpModule->Buffer, CurIcon->ustrModule.Buffer, lpModule->Length);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END
}
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
goto leave;
}
if(lpResName)
{
if(!CurIcon->ustrRsrc.Buffer)
{
EngSetLastError(ERROR_INVALID_HANDLE);
goto leave;
}
/* Copy it */
_SEH2_TRY
{
ProbeForWrite(lpResName, sizeof(UNICODE_STRING), 1);
if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer))
{
lpResName->Buffer = CurIcon->ustrRsrc.Buffer;
lpResName->Length = 0;
}
else
{
lpResName->Length = min(lpResName->MaximumLength, CurIcon->ustrRsrc.Length);
RtlCopyMemory(lpResName->Buffer, CurIcon->ustrRsrc.Buffer, lpResName->Length);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END
}
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
goto leave;
}
Ret = TRUE;
leave: leave:
UserDereferenceObject(CurIcon);
TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret); TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret);
UserLeave(); UserLeave();
@ -623,8 +732,8 @@ NtUserClipCursor(
BOOL BOOL
APIENTRY APIENTRY
NtUserDestroyCursor( NtUserDestroyCursor(
HANDLE hCurIcon, _In_ HANDLE hCurIcon,
DWORD Unknown) _In_ BOOL bForce)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
BOOL ret; BOOL ret;
@ -638,7 +747,7 @@ NtUserDestroyCursor(
RETURN(FALSE); RETURN(FALSE);
} }
ret = IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); ret = IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process(), bForce);
/* Note: IntDestroyCurIconObject will remove our reference for us! */ /* Note: IntDestroyCurIconObject will remove our reference for us! */
RETURN(ret); RETURN(ret);
@ -654,36 +763,51 @@ CLEANUP:
* @implemented * @implemented
*/ */
HICON HICON
APIENTRY NTAPI
NtUserFindExistingCursorIcon( NtUserFindExistingCursorIcon(
HMODULE hModule, _In_ PUNICODE_STRING pustrModule,
HRSRC hRsrc, _In_ PUNICODE_STRING pustrRsrc,
LONG cx, _In_ FINDEXISTINGCURICONPARAM* param)
LONG cy)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
HANDLE Ret = (HANDLE)0; HICON Ret = NULL;
DECLARE_RETURN(HICON); UNICODE_STRING ustrModuleSafe, ustrRsrcSafe;
FINDEXISTINGCURICONPARAM paramSafe;
NTSTATUS Status;
TRACE("Enter NtUserFindExistingCursorIcon\n"); TRACE("Enter NtUserFindExistingCursorIcon\n");
UserEnterExclusive();
CurIcon = IntFindExistingCurIconObject(hModule, hRsrc, cx, cy); /* Capture resource name (it can be an INTRESOURCE == ATOM) */
if (CurIcon) Status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrcSafe, pustrRsrc);
if(!NT_SUCCESS(Status))
return NULL;
Status = ProbeAndCaptureUnicodeString(&ustrModuleSafe, UserMode, pustrModule);
if(!NT_SUCCESS(Status))
goto done;
_SEH2_TRY
{ {
Ret = CurIcon->Self; ProbeForRead(param, sizeof(*param), 1);
paramSafe = *param;
// IntReleaseCurIconObject(CurIcon); // FIXME: Is this correct? Does IntFindExistingCurIconObject add a ref?
RETURN(Ret);
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END
EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); UserEnterExclusive();
RETURN((HANDLE)0); CurIcon = IntFindExistingCurIconObject(&ustrModuleSafe, &ustrRsrcSafe, &paramSafe);
if (CurIcon)
CLEANUP: Ret = CurIcon->Self;
TRACE("Leave NtUserFindExistingCursorIcon, ret=%p\n",_ret_);
UserLeave(); UserLeave();
END_CLEANUP;
done:
if(!IS_INTRESOURCE(ustrRsrcSafe.Buffer))
ExFreePoolWithTag(ustrRsrcSafe.Buffer, TAG_STRING);
ReleaseCapturedUnicodeString(&ustrModuleSafe, UserMode);
return Ret;
} }
@ -920,12 +1044,6 @@ NtUserSetCursorContents(
done: done:
if(!Ret)
{
IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process());
CurIcon = NULL;
}
if (CurIcon) if (CurIcon)
{ {
UserDereferenceObject(CurIcon); UserDereferenceObject(CurIcon);
@ -942,33 +1060,35 @@ CLEANUP:
/* /*
* @implemented * @implemented
*/ */
#ifdef NEW_CURSORICON
BOOL BOOL
APIENTRY APIENTRY
NtUserSetCursorIconData( NtUserSetCursorIconData(
_In_ HCURSOR Handle, _In_ HCURSOR Handle,
_In_ HINSTANCE hinst, _In_opt_ PUNICODE_STRING pustrModule,
_In_ HRSRC hrsrc, _In_opt_ PUNICODE_STRING pustrRsrc,
_In_ PICONINFO pIconInfo) _In_ PICONINFO pIconInfo)
{ {
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
PSURFACE psurfBmp; PSURFACE psurfBmp;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
BOOL Ret = FALSE; BOOL Ret = FALSE;
DECLARE_RETURN(BOOL);
ICONINFO ii; ICONINFO ii;
TRACE("Enter NtUserSetCursorIconData\n"); TRACE("Enter NtUserSetCursorIconData\n");
/* If a module name is provided, we need a resource name, and vice versa */
if((pustrModule && !pustrRsrc) || (!pustrModule && pustrRsrc))
return FALSE;
UserEnterExclusive(); UserEnterExclusive();
if (!(CurIcon = UserGetCurIconObject(Handle))) if (!(CurIcon = UserGetCurIconObject(Handle)))
{ {
RETURN(FALSE); UserLeave();
EngSetLastError(ERROR_INVALID_HANDLE);
return FALSE;
} }
CurIcon->hModule = hinst;
CurIcon->hRsrc =hrsrc;
_SEH2_TRY _SEH2_TRY
{ {
ProbeForRead(pIconInfo, sizeof(ICONINFO), 1); ProbeForRead(pIconInfo, sizeof(ICONINFO), 1);
@ -1014,28 +1134,37 @@ NtUserSetCursorIconData(
if (CurIcon->aFrame[0].hbmColor) if (CurIcon->aFrame[0].hbmColor)
{ {
if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor))) psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor);
{ if(!psurfBmp)
goto done;
CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx;
CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy;
SURFACE_ShareUnlockSurface(psurfBmp); SURFACE_ShareUnlockSurface(psurfBmp);
GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC);
} }
else else
{
psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask);
if(!psurfBmp)
goto done; goto done;
}
else
{
if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask)))
{
CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx;
CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2; CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2;
SURFACE_ShareUnlockSurface(psurfBmp); SURFACE_ShareUnlockSurface(psurfBmp);
} }
else GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC);
if(pustrModule)
{
/* We use this convenient function, because INTRESOURCEs and ATOMs are the same */
Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->ustrRsrc, pustrRsrc);
if(!NT_SUCCESS(Status))
goto done;
Status = ProbeAndCaptureUnicodeString(&CurIcon->ustrModule, UserMode, pustrModule);
if(!NT_SUCCESS(Status))
goto done; goto done;
} }
GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC);
Ret = TRUE; Ret = TRUE;
@ -1055,98 +1184,18 @@ done:
GreDeleteObject(CurIcon->aFrame[0].hbmColor); GreDeleteObject(CurIcon->aFrame[0].hbmColor);
CurIcon->aFrame[0].hbmColor = NULL; CurIcon->aFrame[0].hbmColor = NULL;
} }
if(!IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer))
ExFreePoolWithTag(CurIcon->ustrRsrc.Buffer, TAG_STRING);
if(CurIcon->ustrModule.Buffer)
ReleaseCapturedUnicodeString(&CurIcon->ustrModule, UserMode);
} }
RETURN(Ret);
CLEANUP: TRACE("Leave NtUserSetCursorIconData, ret=%i\n",Ret);
TRACE("Leave NtUserSetCursorIconData, ret=%i\n",_ret_);
UserLeave(); UserLeave();
END_CLEANUP;
}
#else
BOOL
APIENTRY
NtUserSetCursorIconData(
HANDLE hCurIcon,
PBOOL fIcon,
POINT *Hotspot,
HMODULE hModule,
HRSRC hRsrc,
HRSRC hGroupRsrc)
{
PCURICON_OBJECT CurIcon;
NTSTATUS Status;
BOOL Ret = FALSE;
DECLARE_RETURN(BOOL);
TRACE("Enter NtUserSetCursorIconData\n"); return Ret;
UserEnterExclusive();
if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
{
RETURN(FALSE);
} }
CurIcon->hModule = hModule;
CurIcon->hRsrc = hRsrc;
CurIcon->hGroupRsrc = hGroupRsrc;
/* Copy fields */
if (fIcon)
{
Status = MmCopyFromCaller(&CurIcon->bIcon, fIcon, sizeof(BOOL));
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
goto done;
}
}
else
{
if (!Hotspot)
Ret = TRUE;
}
if (Hotspot)
{
Status = MmCopyFromCaller(&CurIcon->ptlHotspot, Hotspot, sizeof(POINT));
if (!NT_SUCCESS(Status))
{
SetLastNtError(Status);
goto done;
}
}
if (!fIcon && !Hotspot)
{
Ret = TRUE;
}
done:
if(Ret)
{
/* This icon is shared now */
GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC);
if(CurIcon->aFrame[0].hbmColor)
{
GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC);
}
if(CurIcon->aFrame[0].hbmAlpha)
{
GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC);
}
}
UserDereferenceObject(CurIcon);
RETURN(Ret);
CLEANUP:
TRACE("Leave NtUserSetCursorIconData, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
#endif
/* Mostly inspired from wine code. /* Mostly inspired from wine code.
* We use low level functions because: * We use low level functions because:
* - at this point, the icon bitmap could have a different bit depth than the DC, * - at this point, the icon bitmap could have a different bit depth than the DC,
@ -1167,7 +1216,7 @@ UserDrawIconEx(
HBRUSH hbrFlickerFreeDraw, HBRUSH hbrFlickerFreeDraw,
UINT diFlags) UINT diFlags)
{ {
PSURFACE psurfDest, psurfMask, psurfColor, psurfOffScreen; PSURFACE psurfDest, psurfMask, psurfColor; //, psurfOffScreen = NULL;
PDC pdc = NULL; PDC pdc = NULL;
BOOL Ret = FALSE; BOOL Ret = FALSE;
HBITMAP hbmMask, hbmColor, hbmAlpha; HBITMAP hbmMask, hbmColor, hbmAlpha;
@ -1215,6 +1264,35 @@ UserDrawIconEx(
return FALSE; return FALSE;
} }
pdc = DC_LockDc(hDc);
if(!pdc)
{
ERR("Could not lock the destination DC.\n");
SURFACE_ShareUnlockSurface(psurfMask);
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
return FALSE;
}
/* Calculate destination rectangle */
RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
/* Prepare the underlying surface */
DC_vPrepareDCsForBlit(pdc, rcDest, NULL, rcDest);
/* We now have our destination surface and rectangle */
psurfDest = pdc->dclevel.pSurface;
if(psurfDest == NULL)
{
/* Empty DC */
DC_vFinishBlit(pdc, NULL);
DC_UnlockDc(pdc);
SURFACE_ShareUnlockSurface(psurfMask);
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
return FALSE;
}
/* Set source rect */ /* Set source rect */
RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy); RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy);
@ -1239,7 +1317,8 @@ UserDrawIconEx(
} }
/* Should we render off-screen? */ /* Should we render off-screen? */
bOffScreen = hbrFlickerFreeDraw && (GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH); bOffScreen = hbrFlickerFreeDraw &&
(GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH);
if (bOffScreen) if (bOffScreen)
{ {
@ -1252,21 +1331,18 @@ UserDrawIconEx(
if(!pbrush) if(!pbrush)
{ {
ERR("Failed to get brush object.\n"); ERR("Failed to get brush object.\n");
SURFACE_ShareUnlockSurface(psurfMask); goto Cleanup;
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
return FALSE;
} }
#if 0 //We lock the hdc surface during the whole function it makes no sense to use an offscreen surface for "flicker free" drawing
psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP, psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP,
cxWidth, cyHeight, psurfColor->SurfObj.iBitmapFormat, cxWidth, cyHeight, psurfDest->SurfObj.iBitmapFormat,
0, 0, NULL); 0, 0, NULL);
if(!psurfOffScreen) if(!psurfOffScreen)
{ {
ERR("Failed to allocate the off-screen surface.\n"); ERR("Failed to allocate the off-screen surface.\n");
SURFACE_ShareUnlockSurface(psurfMask);
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
BRUSH_ShareUnlockBrush(pbrush); BRUSH_ShareUnlockBrush(pbrush);
return FALSE; goto Cleanup;
} }
/* Paint the brush */ /* Paint the brush */
@ -1292,52 +1368,45 @@ UserDrawIconEx(
if(!Ret) if(!Ret)
{ {
ERR("Failed to paint the off-screen surface.\n"); ERR("Failed to paint the off-screen surface.\n");
SURFACE_ShareUnlockSurface(psurfMask); goto Cleanup;
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject);
return FALSE;
} }
/* We now have our destination surface */ /* We now have our destination surface */
psurfDest = psurfOffScreen; psurfDest = psurfOffScreen;
#else
pdcClipObj = pdc->rosdc.CombinedClip;
/* Paint the brush */
EBRUSHOBJ_vInit(&eboFill, pbrush, psurfDest, 0x00FFFFFF, 0, NULL);
Ret = IntEngBitBlt(&psurfDest->SurfObj,
NULL,
NULL,
pdcClipObj,
NULL,
&rcDest,
NULL,
NULL,
&eboFill.BrushObject,
&pbrush->ptOrigin,
ROP4_PATCOPY);
/* Clean up everything */
EBRUSHOBJ_vCleanup(&eboFill);
BRUSH_ShareUnlockBrush(pbrush);
if(!Ret)
{
ERR("Failed to paint the off-screen surface.\n");
goto Cleanup;
}
#endif
} }
else else
{ {
/* We directly draw to the DC */ /* We directly draw to the DC */
TRACE("Performing on screen rendering.\n"); TRACE("Performing on screen rendering.\n");
psurfOffScreen = NULL;
pdc = DC_LockDc(hDc);
if(!pdc)
{
ERR("Could not lock the destination DC.\n");
SURFACE_ShareUnlockSurface(psurfMask);
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
return FALSE;
}
/* Calculate destination rectangle */
RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
/* Prepare the underlying surface */
DC_vPrepareDCsForBlit(pdc, rcDest, NULL, rcDest);
/* Get the clip object */
pdcClipObj = pdc->rosdc.CombinedClip; pdcClipObj = pdc->rosdc.CombinedClip;
// psurfOffScreen = NULL;
/* We now have our destination surface and rectangle */
psurfDest = pdc->dclevel.pSurface;
if(psurfDest == NULL)
{
/* Empty DC */
DC_vFinishBlit(pdc, NULL);
DC_UnlockDc(pdc);
SURFACE_ShareUnlockSurface(psurfMask);
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
return FALSE;
}
} }
/* Now do the rendering */ /* Now do the rendering */
@ -1460,36 +1529,23 @@ NoAlpha:
} }
done: done:
#if 0
/* We're done. Was it a double buffered draw ? */ /* We're done. Was it a double buffered draw ? */
if(bOffScreen) if(bOffScreen)
{ {
/* Yes. Draw it back to our DC */ /* Yes. Draw it back to our DC */
POINTL ptSrc = {0, 0}; POINTL ptSrc = {0, 0};
pdc = DC_LockDc(hDc);
if(!pdc)
{
ERR("Could not lock the destination DC.\n");
return FALSE;
}
/* Calculate destination rectangle */ /* Calculate destination rectangle */
RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight); RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
IntLPtoDP(pdc, (LPPOINT)&rcDest, 2); IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y); RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
/* Prepare the underlying surface */
DC_vPrepareDCsForBlit(pdc, rcDest, NULL, rcDest);
/* Get the clip object */ /* Get the clip object */
pdcClipObj = pdc->rosdc.CombinedClip; pdcClipObj = pdc->rosdc.CombinedClip;
/* We now have our destination surface and rectangle */ /* We now have our destination surface and rectangle */
psurfDest = pdc->dclevel.pSurface; psurfDest = pdc->dclevel.pSurface;
if(!psurfDest)
{
/* So, you did all of this for an empty DC. */
DC_UnlockDc(pdc);
goto Cleanup2;
}
/* Color translation */ /* Color translation */
EXLATEOBJ_vInitialize(&exlo, psurfOffScreen->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0); EXLATEOBJ_vInitialize(&exlo, psurfOffScreen->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
@ -1509,6 +1565,7 @@ done:
EXLATEOBJ_vCleanup(&exlo); EXLATEOBJ_vCleanup(&exlo);
} }
#endif
Cleanup: Cleanup:
if(pdc) if(pdc)
{ {
@ -1516,10 +1573,11 @@ Cleanup:
DC_UnlockDc(pdc); DC_UnlockDc(pdc);
} }
Cleanup2: #if 0
/* Delete off screen rendering surface */ /* Delete off screen rendering surface */
if(psurfOffScreen) if(psurfOffScreen)
GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject); GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject);
#endif
/* Unlock other surfaces */ /* Unlock other surfaces */
SURFACE_ShareUnlockSurface(psurfMask); SURFACE_ShareUnlockSurface(psurfMask);
@ -1554,7 +1612,7 @@ NtUserDrawIconEx(
if (!(pIcon = UserGetCurIconObject(hIcon))) if (!(pIcon = UserGetCurIconObject(hIcon)))
{ {
ERR("UserGetCurIconObject() failed!\n"); ERR("UserGetCurIconObject(0x%08x) failed!\n", hIcon);
UserLeave(); UserLeave();
return FALSE; return FALSE;
} }

View file

@ -236,7 +236,7 @@ NtUserCallOneParam(
PCURICON_OBJECT CurIcon; PCURICON_OBJECT CurIcon;
DWORD_PTR Result ; DWORD_PTR Result ;
if (!(CurIcon = IntCreateCurIconHandle())) if (!(CurIcon = IntCreateCurIconHandle((DWORD)Param)))
{ {
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
RETURN(0); RETURN(0);

View file

@ -71,7 +71,10 @@ else()
endif() endif()
add_library(user32 SHARED ${SOURCE}) add_library(user32 SHARED ${SOURCE})
set_module_type(user32 win32dll UNICODE) set_module_type(user32
win32dll
ENTRYPOINT DllMain 12
UNICODE)
target_link_libraries(user32 target_link_libraries(user32
user32_wsprintf user32_wsprintf
@ -79,8 +82,13 @@ target_link_libraries(user32
win32ksys win32ksys
${PSEH_LIB}) ${PSEH_LIB})
if(MSVC)
# for __ftol2_sse, float to int cast helper
target_link_libraries(user32 msvcrtex)
endif()
add_delay_importlibs(user32 imm32 usp10) add_delay_importlibs(user32 imm32 usp10)
add_importlibs(user32 gdi32 advapi32 msvcrt kernel32 ntdll) add_importlibs(user32 gdi32 advapi32 kernel32 ntdll)
add_pch(user32 include/user32.h) add_pch(user32 include/user32.h)
add_cd_file(TARGET user32 DESTINATION reactos/system32 FOR all) add_cd_file(TARGET user32 DESTINATION reactos/system32 FOR all)

View file

@ -400,7 +400,7 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HD
tabdef.pTabStops = es->tabs; tabdef.pTabStops = es->tabs;
tabdef.iTabOrigin = 0; tabdef.iTabOrigin = 0;
ScriptStringAnalyse(udc, &es->text[index], line_def->net_length, (1.5*line_def->net_length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_TAB, -1, NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa); ScriptStringAnalyse(udc, &es->text[index], line_def->net_length, (3*line_def->net_length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_TAB, -1, NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa);
if (es->font) if (es->font)
SelectObject(udc, old_font); SelectObject(udc, old_font);
@ -435,9 +435,9 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, IN
old_font = SelectObject(udc, es->font); old_font = SelectObject(udc, es->font);
if (es->style & ES_PASSWORD) if (es->style & ES_PASSWORD)
ScriptStringAnalyse(udc, &es->password_char, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa); ScriptStringAnalyse(udc, &es->password_char, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
else else
ScriptStringAnalyse(udc, es->text, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa); ScriptStringAnalyse(udc, es->text, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
if (es->font) if (es->font)
SelectObject(udc, old_font); SelectObject(udc, old_font);

File diff suppressed because it is too large Load diff

View file

@ -2162,7 +2162,7 @@ GetDlgItemInt(
result = strtol( str, &endptr, 10 ); result = strtol( str, &endptr, 10 );
if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
return 0; return 0;
if (((result == LONG_MIN) || (result == LONG_MAX)) && (errno == ERANGE) ) if (((result == LONG_MIN) || (result == LONG_MAX)))
return 0; return 0;
} }
else else
@ -2170,7 +2170,7 @@ GetDlgItemInt(
result = strtoul( str, &endptr, 10 ); result = strtoul( str, &endptr, 10 );
if (!endptr || (endptr == str)) /* Conversion was unsuccessful */ if (!endptr || (endptr == str)) /* Conversion was unsuccessful */
return 0; return 0;
if ((result == ULONG_MAX) && (errno == ERANGE) ) return 0; if (result == ULONG_MAX) return 0;
} }
if (lpTranslated) *lpTranslated = TRUE; if (lpTranslated) *lpTranslated = TRUE;
return (UINT)result; return (UINT)result;

View file

@ -792,7 +792,7 @@ static LONG MDICascade( HWND client, MDICLIENTINFO *ci )
static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam )
{ {
HWND *win_array; HWND *win_array;
int i, total; int i, total, rows, columns;
BOOL has_icons = FALSE; BOOL has_icons = FALSE;
if (ci->hwndChildMaximized) if (ci->hwndChildMaximized)
@ -803,7 +803,7 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam )
if (!(win_array = WIN_ListChildren( client ))) return; if (!(win_array = WIN_ListChildren( client ))) return;
/* remove all the windows we don't want */ /* remove all the windows we don't want */
for (i = total = 0; win_array[i]; i++) for (i = total = rows = 0; win_array[i]; i++)
{ {
if (!IsWindowVisible( win_array[i] )) continue; if (!IsWindowVisible( win_array[i] )) continue;
if (GetWindow( win_array[i], GW_OWNER )) continue; /* skip owned windows (icon titles) */ if (GetWindow( win_array[i], GW_OWNER )) continue; /* skip owned windows (icon titles) */
@ -813,6 +813,7 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam )
continue; continue;
} }
if ((wParam & MDITILE_SKIPDISABLED) && !IsWindowEnabled( win_array[i] )) continue; if ((wParam & MDITILE_SKIPDISABLED) && !IsWindowEnabled( win_array[i] )) continue;
if(total == (rows * (rows + 2))) rows++; /* total+1 == (rows+1)*(rows+1) */
win_array[total++] = win_array[i]; win_array[total++] = win_array[i];
} }
win_array[total] = 0; win_array[total] = 0;
@ -824,11 +825,11 @@ static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam )
HWND *pWnd = win_array; HWND *pWnd = win_array;
RECT rect; RECT rect;
int x, y, xsize, ysize; int x, y, xsize, ysize;
int rows, columns, r, c, i; int r, c, i;
GetClientRect(client,&rect); GetClientRect(client,&rect);
rows = (int) sqrt((double)total);
columns = total/rows; columns = total/rows;
//while(total < rows*columns) rows++;
if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */ if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */
{ {
@ -1604,8 +1605,8 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
#ifndef __REACTOS__ #ifndef __REACTOS__
case WM_SETVISIBLE: case WM_SETVISIBLE:
#endif #endif
if (ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE; /*if (ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE;
else MDI_PostUpdate(client, ci, SB_BOTH+1); else*/ MDI_PostUpdate(client, ci, SB_BOTH+1);
break; break;
case WM_SIZE: case WM_SIZE:
@ -1843,7 +1844,6 @@ void WINAPI CalcChildScroll( HWND hwnd, INT scroll )
} }
HeapFree( GetProcessHeap(), 0, list ); HeapFree( GetProcessHeap(), 0, list );
} }
MapWindowPoints( 0, hwnd, (POINT *)&childRect, 2 );
UnionRect( &childRect, &clientRect, &childRect ); UnionRect( &childRect, &clientRect, &childRect );
/* set common info values */ /* set common info values */