diff --git a/base/applications/mscutils/servman/export.c b/base/applications/mscutils/servman/export.c index 3df3c4424fb..4abb2796019 100644 --- a/base/applications/mscutils/servman/export.c +++ b/base/applications/mscutils/servman/export.c @@ -68,7 +68,7 @@ SaveServicesToFile(PMAIN_WND_INFO Info, LVText, i, k); - if (_tcslen(LVText)) + if (dwTextLength != 0) { WriteFile(hFile, LVText, diff --git a/dll/win32/advapi32/advapi32.h b/dll/win32/advapi32/advapi32.h index 39492bdae2d..41e40f7c255 100644 --- a/dll/win32/advapi32/advapi32.h +++ b/dll/win32/advapi32/advapi32.h @@ -178,4 +178,16 @@ extern NTMARTA NtMartaStatic; DWORD CheckNtMartaPresent(VOID); +/* heap allocation helpers */ +static void *heap_alloc( size_t len ) __WINE_ALLOC_SIZE(1); +static inline void *heap_alloc( size_t len ) +{ + return HeapAlloc( GetProcessHeap(), 0, len ); +} + +static inline BOOL heap_free( void *mem ) +{ + return HeapFree( GetProcessHeap(), 0, mem ); +} + #endif /* __ADVAPI32_H */ diff --git a/dll/win32/advapi32/advapi32.spec b/dll/win32/advapi32/advapi32.spec index 9e62df6b6fb..713ffa58074 100644 --- a/dll/win32/advapi32/advapi32.spec +++ b/dll/win32/advapi32/advapi32.spec @@ -681,4 +681,4 @@ @ stub WmiSetSingleItemA @ stub WmiSetSingleItemW @ stub Wow64Win32ApiEntry -@ stub WriteEncryptedFileRaw +@ stdcall WriteEncryptedFileRaw(ptr ptr ptr) diff --git a/dll/win32/advapi32/crypt/crypt.c b/dll/win32/advapi32/crypt/crypt.c index 5d6266b3003..264356154d3 100644 --- a/dll/win32/advapi32/crypt/crypt.c +++ b/dll/win32/advapi32/crypt/crypt.c @@ -1802,7 +1802,7 @@ BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags * Success: TRUE * Failure: FALSE */ -BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDataLen, +BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey) { PCRYPTPROV prov = (PCRYPTPROV)hProv; @@ -1922,7 +1922,7 @@ BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescripti * Success: TRUE * Failure: FALSE */ -BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags) +BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags) { PCRYPTPROV prov; PCRYPTHASH hash = (PCRYPTHASH)hHash; @@ -1956,7 +1956,7 @@ BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, CONST BYTE *pbDa * Success: TRUE * Failure: FALSE */ -BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags) +BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags) { PCRYPTPROV prov; PCRYPTKEY key = (PCRYPTKEY)hKey; @@ -2131,7 +2131,7 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd * Success: TRUE * Failure: FALSE */ -BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags) +BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags) { PCRYPTPROV prov = (PCRYPTPROV)hProv; @@ -2147,7 +2147,7 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, CONST BYTE *pbDa SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - if (dwFlags & PP_USE_HARDWARE_RNG) + if (dwParam == PP_USE_HARDWARE_RNG) { FIXME("PP_USE_HARDWARE_RNG: What do I do with this?\n"); FIXME("\tLetting the CSP decide.\n"); @@ -2190,7 +2190,7 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, CONST BYTE *pbDa * NULL. It is supported only for compatibility with Microsoft's Cryptographic * Providers. */ -BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, CONST BYTE *pbSignature, DWORD dwSigLen, +BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags) { PCRYPTHASH hash = (PCRYPTHASH)hHash; @@ -2218,7 +2218,7 @@ BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, CONST BYTE *pbSignature, DW * * See CryptVerifySignatureW. */ -BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, CONST BYTE *pbSignature, DWORD dwSigLen, +BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCSTR sDescription, DWORD dwFlags) { LPWSTR wsDescription; @@ -2362,3 +2362,22 @@ NTSTATUS WINAPI SystemFunction041(PVOID memory, ULONG length, ULONG flags) return STATUS_SUCCESS; } #endif /* !__REACTOS __ */ + +/****************************************************************************** + * WriteEncryptedFileRaw (ADVAPI32.@) + * + * Import encrypted files + * + * PARAMS + * import [I] pointer to the import callback function + * callback [I] pointer to the application defined context + * context [I] pointer to the system context + * RETURNS + * Success: ERROR_SUCCESS + * Failure: NTSTATUS error code + */ +DWORD WINAPI WriteEncryptedFileRaw(PFE_IMPORT_FUNC import, PVOID callback, PVOID context) +{ + FIXME("(%p, %p, %p): stub\n", import, callback, context); + return ERROR_CALL_NOT_IMPLEMENTED; +} diff --git a/dll/win32/advapi32/crypt/crypt.h b/dll/win32/advapi32/crypt/crypt.h index 937e30b6e69..75cf937fda2 100644 --- a/dll/win32/advapi32/crypt/crypt.h +++ b/dll/win32/advapi32/crypt/crypt.h @@ -45,15 +45,15 @@ typedef struct tagPROVFUNCS BOOL (WINAPI *pCPGetKeyParam)(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags); BOOL (WINAPI *pCPGetProvParam)(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags); BOOL (WINAPI *pCPGetUserKey)(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey); - BOOL (WINAPI *pCPHashData)(HCRYPTPROV hProv, HCRYPTHASH hHash, CONST BYTE *pbData, DWORD dwDataLen, DWORD dwFlags); + BOOL (WINAPI *pCPHashData)(HCRYPTPROV hProv, HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags); BOOL (WINAPI *pCPHashSessionKey)(HCRYPTPROV hProv, HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags); - BOOL (WINAPI *pCPImportKey)(HCRYPTPROV hProv, CONST BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey); + BOOL (WINAPI *pCPImportKey)(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey); BOOL (WINAPI *pCPReleaseContext)(HCRYPTPROV hProv, DWORD dwFlags); - BOOL (WINAPI *pCPSetHashParam)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags); - BOOL (WINAPI *pCPSetKeyParam)(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags); - BOOL (WINAPI *pCPSetProvParam)(HCRYPTPROV hProv, DWORD dwParam, CONST BYTE *pbData, DWORD dwFlags); + BOOL (WINAPI *pCPSetHashParam)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags); + BOOL (WINAPI *pCPSetKeyParam)(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags); + BOOL (WINAPI *pCPSetProvParam)(HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags); BOOL (WINAPI *pCPSignHash)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen); - BOOL (WINAPI *pCPVerifySignature)(HCRYPTPROV hProv, HCRYPTHASH hHash, CONST BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags); + BOOL (WINAPI *pCPVerifySignature)(HCRYPTPROV hProv, HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags); } PROVFUNCS, *PPROVFUNCS; #define MAGIC_CRYPTPROV 0xA39E741F diff --git a/dll/win32/advapi32/sec/cred.c b/dll/win32/advapi32/sec/cred.c index a8d64933332..69639a4ffb1 100644 --- a/dll/win32/advapi32/sec/cred.c +++ b/dll/win32/advapi32/sec/cred.c @@ -236,15 +236,13 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require DWORD *len) { OSStatus status; - UInt32 i; - UInt32 cred_blob_len; + UInt32 i, cred_blob_len; void *cred_blob; - LPWSTR domain = NULL; - LPWSTR user = NULL; + WCHAR *user = NULL; BOOL user_name_present = FALSE; SecKeychainAttributeInfo info; SecKeychainAttributeList *attr_list; - UInt32 info_tags[] = { kSecServerItemAttr, kSecSecurityDomainItemAttr, kSecAccountItemAttr, + UInt32 info_tags[] = { kSecServiceItemAttr, kSecAccountItemAttr, kSecCommentItemAttr, kSecCreationDateItemAttr }; info.count = sizeof(info_tags)/sizeof(info_tags[0]); info.tag = info_tags; @@ -294,8 +292,8 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require { switch (attr_list->attr[i].tag) { - case kSecServerItemAttr: - TRACE("kSecServerItemAttr: %.*s\n", (int)attr_list->attr[i].length, + case kSecServiceItemAttr: + TRACE("kSecServiceItemAttr: %.*s\n", (int)attr_list->attr[i].length, (char *)attr_list->attr[i].data); if (!attr_list->attr[i].data) continue; if (buffer) @@ -324,7 +322,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require if (!attr_list->attr[i].data) continue; str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, attr_list->attr[i].length, NULL, 0); - user = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + user = heap_alloc((str_len + 1) * sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, attr_list->attr[i].length, user, str_len); user[str_len] = '\0'; @@ -352,20 +350,6 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require *len += (str_len + 1) * sizeof(WCHAR); } break; - case kSecSecurityDomainItemAttr: - { - INT str_len; - TRACE("kSecSecurityDomainItemAttr: %.*s\n", (int)attr_list->attr[i].length, - (char *)attr_list->attr[i].data); - if (!attr_list->attr[i].data) continue; - str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, - attr_list->attr[i].length, NULL, 0); - domain = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[i].data, - attr_list->attr[i].length, domain, str_len); - domain[str_len] = '\0'; - break; - } case kSecCreationDateItemAttr: TRACE("kSecCreationDateItemAttr: %.*s\n", (int)attr_list->attr[i].length, (char *)attr_list->attr[i].data); @@ -382,6 +366,9 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require credential->LastWritten.dwHighDateTime = win_time.u.HighPart; } break; + default: + FIXME("unhandled attribute %lu\n", attr_list->attr[i].tag); + break; } } @@ -390,18 +377,6 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require INT str_len; if (buffer) credential->UserName = (LPWSTR)buffer; - if (domain) - { - str_len = strlenW(domain); - *len += (str_len + 1) * sizeof(WCHAR); - if (buffer) - { - memcpy(credential->UserName, domain, str_len * sizeof(WCHAR)); - /* FIXME: figure out when to use an '@' */ - credential->UserName[str_len] = '\\'; - buffer += (str_len + 1) * sizeof(WCHAR); - } - } str_len = strlenW(user); *len += (str_len + 1) * sizeof(WCHAR); if (buffer) @@ -411,8 +386,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item, BOOL require TRACE("UserName = %s\n", debugstr_w(credential->UserName)); } } - HeapFree(GetProcessHeap(), 0, user); - HeapFree(GetProcessHeap(), 0, domain); + heap_free(user); if (cred_blob) { @@ -450,7 +424,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type, key.Length = key.MaximumLength = KEY_SIZE; key.Buffer = (unsigned char *)key_data; - encrypted_credential_blob = HeapAlloc(GetProcessHeap(), 0, credential_blob_size); + encrypted_credential_blob = heap_alloc(credential_blob_size); if (!encrypted_credential_blob) return ERROR_OUTOFMEMORY; memcpy(encrypted_credential_blob, credential_blob, credential_blob_size); @@ -459,7 +433,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type, SystemFunction032(&data, &key); ret = RegSetValueExW(hkey, wszPasswordValue, 0, REG_BINARY, encrypted_credential_blob, credential_blob_size); - HeapFree(GetProcessHeap(), 0, encrypted_credential_blob); + heap_free(encrypted_credential_blob); return ret; } @@ -520,15 +494,8 @@ static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_b { OSStatus status; SecKeychainItemRef keychain_item; - char *username; - char *domain = NULL; - char *password; - char *servername; - UInt32 userlen; - UInt32 domainlen = 0; - UInt32 pwlen; - UInt32 serverlen; - LPCWSTR p; + char *username, *password, *servername; + UInt32 userlen, pwlen, serverlen; SecKeychainAttribute attrs[1]; SecKeychainAttributeList attr_list; @@ -541,61 +508,36 @@ static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_b if (credential->AttributeCount) FIXME("custom attributes not supported\n"); - p = strchrW(credential->UserName, '\\'); - if (p) - { - domainlen = WideCharToMultiByte(CP_UTF8, 0, credential->UserName, - p - credential->UserName, NULL, 0, NULL, NULL); - domain = HeapAlloc(GetProcessHeap(), 0, (domainlen + 1) * sizeof(*domain)); - WideCharToMultiByte(CP_UTF8, 0, credential->UserName, p - credential->UserName, - domain, domainlen, NULL, NULL); - domain[domainlen] = '\0'; - p++; - } - else - p = credential->UserName; - userlen = WideCharToMultiByte(CP_UTF8, 0, p, -1, NULL, 0, NULL, NULL); - username = HeapAlloc(GetProcessHeap(), 0, userlen * sizeof(*username)); - WideCharToMultiByte(CP_UTF8, 0, p, -1, username, userlen, NULL, NULL); + userlen = WideCharToMultiByte(CP_UTF8, 0, credential->UserName, -1, NULL, 0, NULL, NULL); + username = heap_alloc(userlen * sizeof(*username)); + WideCharToMultiByte(CP_UTF8, 0, credential->UserName, -1, username, userlen, NULL, NULL); serverlen = WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, NULL, 0, NULL, NULL); - servername = HeapAlloc(GetProcessHeap(), 0, serverlen * sizeof(*servername)); + servername = heap_alloc(serverlen * sizeof(*servername)); WideCharToMultiByte(CP_UTF8, 0, credential->TargetName, -1, servername, serverlen, NULL, NULL); pwlen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, credential->CredentialBlobSize / sizeof(WCHAR), NULL, 0, NULL, NULL); - password = HeapAlloc(GetProcessHeap(), 0, pwlen * sizeof(*domain)); + password = heap_alloc(pwlen * sizeof(*password)); WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)credential->CredentialBlob, credential->CredentialBlobSize / sizeof(WCHAR), password, pwlen, NULL, NULL); - TRACE("adding server %s, domain %s, username %s using Keychain\n", servername, domain, username); - status = SecKeychainAddInternetPassword(NULL, strlen(servername), servername, - strlen(domain), domain, strlen(username), - username, 0, NULL, 0, - 0 /* no protocol */, - kSecAuthenticationTypeDefault, - strlen(password), password, &keychain_item); + TRACE("adding server %s, username %s using Keychain\n", servername, username); + status = SecKeychainAddGenericPassword(NULL, strlen(servername), servername, strlen(username), + username, strlen(password), password, &keychain_item); if (status != noErr) - ERR("SecKeychainAddInternetPassword returned %ld\n", status); + ERR("SecKeychainAddGenericPassword returned %ld\n", status); if (status == errSecDuplicateItem) { - SecKeychainItemRef keychain_item; - - status = SecKeychainFindInternetPassword(NULL, strlen(servername), servername, - strlen(domain), domain, - strlen(username), username, - 0, NULL /* any path */, 0, - 0 /* any protocol */, - 0 /* any authentication type */, - 0, NULL, &keychain_item); + status = SecKeychainFindGenericPassword(NULL, strlen(servername), servername, strlen(username), + username, NULL, NULL, &keychain_item); if (status != noErr) - ERR("SecKeychainFindInternetPassword returned %ld\n", status); + ERR("SecKeychainFindGenericPassword returned %ld\n", status); } - HeapFree(GetProcessHeap(), 0, domain); - HeapFree(GetProcessHeap(), 0, username); - HeapFree(GetProcessHeap(), 0, servername); + heap_free(username); + heap_free(servername); if (status != noErr) { - HeapFree(GetProcessHeap(), 0, password); + heap_free(password); return ERROR_GEN_FAILURE; } if (credential->Comment) @@ -605,7 +547,7 @@ static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_b attrs[0].tag = kSecCommentItemAttr; attrs[0].length = WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, NULL, 0, NULL, NULL); if (attrs[0].length) attrs[0].length--; - attrs[0].data = HeapAlloc(GetProcessHeap(), 0, attrs[0].length); + attrs[0].data = heap_alloc(attrs[0].length); WideCharToMultiByte(CP_UTF8, 0, credential->Comment, -1, attrs[0].data, attrs[0].length, NULL, NULL); } else @@ -617,8 +559,8 @@ static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_b preserve_blob ? 0 : strlen(password), preserve_blob ? NULL : password); if (credential->Comment) - HeapFree(GetProcessHeap(), 0, attrs[0].data); - HeapFree(GetProcessHeap(), 0, password); + heap_free(attrs[0].data); + heap_free(password); /* FIXME: set TargetAlias attribute */ CFRelease(keychain_item); if (status != noErr) @@ -702,7 +644,7 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type) len += sizeof(wszDomPasswdPrefix)/sizeof(wszDomPasswdPrefix[0]); } - key_name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + key_name = heap_alloc(len * sizeof(WCHAR)); if (!key_name) return NULL; strcpyW(key_name, prefix); @@ -730,13 +672,13 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter) else if (type != REG_SZ) return FALSE; - target_name = HeapAlloc(GetProcessHeap(), 0, count); + target_name = heap_alloc(count); if (!target_name) return FALSE; ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, (LPVOID)target_name, &count); if (ret != ERROR_SUCCESS || type != REG_SZ) { - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); return FALSE; } @@ -744,11 +686,11 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter) debugstr_w(target_name)); p = strchrW(filter, '*'); - ret = CompareStringW(GetThreadLocale(), 0, filter, + ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, filter, (p && !p[1] ? p - filter : -1), target_name, (p && !p[1] ? p - filter : -1)) == CSTR_EQUAL; - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); return ret; } @@ -809,17 +751,17 @@ static BOOL mac_credential_matches_filter(void *data, UInt32 data_len, const WCH if (!filter) return TRUE; len = MultiByteToWideChar(CP_UTF8, 0, data, data_len, NULL, 0); - if (!(target_name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)))) return FALSE; + if (!(target_name = heap_alloc((len + 1) * sizeof(WCHAR)))) return FALSE; MultiByteToWideChar(CP_UTF8, 0, data, data_len, target_name, len); target_name[len] = 0; TRACE("comparing filter %s to target name %s\n", debugstr_w(filter), debugstr_w(target_name)); p = strchrW(filter, '*'); - ret = CompareStringW(GetThreadLocale(), 0, filter, + ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, filter, (p && !p[1] ? p - filter : -1), target_name, (p && !p[1] ? p - filter : -1)) == CSTR_EQUAL; - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); return ret; } @@ -835,14 +777,14 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW *credentials SecKeychainGetUserInteractionAllowed(&saved_user_interaction_allowed); SecKeychainSetUserInteractionAllowed(false); - status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search); if (status == noErr) { while (SecKeychainSearchCopyNext(search, &item) == noErr) { SecKeychainAttributeInfo info; SecKeychainAttributeList *attr_list; - UInt32 info_tags[] = { kSecServerItemAttr }; + UInt32 info_tags[] = { kSecServiceItemAttr }; BOOL match; info.count = sizeof(info_tags)/sizeof(info_tags[0]); @@ -861,12 +803,12 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW *credentials } else *len += sizeof(CREDENTIALW); - if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServiceItemAttr) { SecKeychainItemFreeAttributesAndData(attr_list, NULL); continue; } - TRACE("server item: %.*s\n", (int)attr_list->attr[0].length, (char *)attr_list->attr[0].data); + TRACE("service item: %.*s\n", (int)attr_list->attr[0].length, (char *)attr_list->attr[0].data); match = mac_credential_matches_filter(attr_list->attr[0].data, attr_list->attr[0].length, filter); SecKeychainItemFreeAttributesAndData(attr_list, NULL); if (!match) continue; @@ -893,7 +835,7 @@ static DWORD mac_delete_credential(LPCWSTR TargetName) { OSStatus status; SecKeychainSearchRef search; - status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search); if (status == noErr) { SecKeychainItemRef item; @@ -901,7 +843,7 @@ static DWORD mac_delete_credential(LPCWSTR TargetName) { SecKeychainAttributeInfo info; SecKeychainAttributeList *attr_list; - UInt32 info_tags[] = { kSecServerItemAttr }; + UInt32 info_tags[] = { kSecServiceItemAttr }; LPWSTR target_name; INT str_len; info.count = sizeof(info_tags)/sizeof(info_tags[0]); @@ -913,23 +855,23 @@ static DWORD mac_delete_credential(LPCWSTR TargetName) WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); continue; } - if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServiceItemAttr) { CFRelease(item); continue; } str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, NULL, 0); - target_name = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + target_name = heap_alloc((str_len + 1) * sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, target_name, str_len); /* nul terminate */ target_name[str_len] = '\0'; if (strcmpiW(TargetName, target_name)) { CFRelease(item); - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); continue; } - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); SecKeychainItemFreeAttributesAndData(attr_list, NULL); SecKeychainItemDelete(item); CFRelease(item); @@ -1142,7 +1084,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags) } len = MultiByteToWideChar(CP_ACP, 0, TargetName, -1, NULL, 0); - TargetNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + TargetNameW = heap_alloc(len * sizeof(WCHAR)); if (!TargetNameW) { SetLastError(ERROR_OUTOFMEMORY); @@ -1152,7 +1094,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags) ret = CredDeleteW(TargetNameW, Type, Flags); - HeapFree(GetProcessHeap(), 0, TargetNameW); + heap_free(TargetNameW); return ret; } @@ -1207,7 +1149,7 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags) key_name = get_key_name_for_target(TargetName, Type); ret = RegDeleteKeyW(hkeyMgr, key_name); - HeapFree(GetProcessHeap(), 0, key_name); + heap_free(key_name); RegCloseKey(hkeyMgr); if (ret != ERROR_SUCCESS) { @@ -1236,7 +1178,7 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count, if (Filter) { len = MultiByteToWideChar(CP_ACP, 0, Filter, -1, NULL, 0); - FilterW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + FilterW = heap_alloc(len * sizeof(WCHAR)); if (!FilterW) { SetLastError(ERROR_OUTOFMEMORY); @@ -1249,16 +1191,16 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count, if (!CredEnumerateW(FilterW, Flags, Count, &CredentialsW)) { - HeapFree(GetProcessHeap(), 0, FilterW); + heap_free(FilterW); return FALSE; } - HeapFree(GetProcessHeap(), 0, FilterW); + heap_free(FilterW); len = *Count * sizeof(PCREDENTIALA); for (i = 0; i < *Count; i++) len += convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], NULL, 0); - *Credentials = HeapAlloc(GetProcessHeap(), 0, len); + *Credentials = heap_alloc(len); if (!*Credentials) { CredFree(CredentialsW); @@ -1327,7 +1269,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, return FALSE; } - target_name = HeapAlloc(GetProcessHeap(), 0, (target_name_len+1)*sizeof(WCHAR)); + target_name = heap_alloc((target_name_len+1)*sizeof(WCHAR)); if (!target_name) { RegCloseKey(hkeyMgr); @@ -1347,7 +1289,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, ret = ERROR_NOT_FOUND; if (ret != ERROR_SUCCESS) { - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); RegCloseKey(hkeyMgr); SetLastError(ret); return FALSE; @@ -1356,7 +1298,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, if (ret == ERROR_SUCCESS) { - buffer = HeapAlloc(GetProcessHeap(), 0, len); + buffer = heap_alloc(len); *Credentials = (PCREDENTIALW *)buffer; if (buffer) { @@ -1376,7 +1318,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, ret = ERROR_OUTOFMEMORY; } - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); RegCloseKey(hkeyMgr); if (ret != ERROR_SUCCESS) @@ -1392,7 +1334,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, */ VOID WINAPI CredFree(PVOID Buffer) { - HeapFree(GetProcessHeap(), 0, Buffer); + heap_free(Buffer); } /****************************************************************************** @@ -1413,7 +1355,7 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA * } len = MultiByteToWideChar(CP_ACP, 0, TargetName, -1, NULL, 0); - TargetNameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + TargetNameW = heap_alloc(len * sizeof(WCHAR)); if (!TargetNameW) { SetLastError(ERROR_OUTOFMEMORY); @@ -1423,13 +1365,13 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA * if (!CredReadW(TargetNameW, Type, Flags, &CredentialW)) { - HeapFree(GetProcessHeap(), 0, TargetNameW); + heap_free(TargetNameW); return FALSE; } - HeapFree(GetProcessHeap(), 0, TargetNameW); + heap_free(TargetNameW); len = convert_PCREDENTIALW_to_PCREDENTIALA(CredentialW, NULL, 0); - *Credential = HeapAlloc(GetProcessHeap(), 0, len); + *Credential = heap_alloc(len); if (!*Credential) { SetLastError(ERROR_OUTOFMEMORY); @@ -1481,7 +1423,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW { OSStatus status; SecKeychainSearchRef search; - status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search); + status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search); if (status == noErr) { SecKeychainItemRef item; @@ -1489,7 +1431,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW { SecKeychainAttributeInfo info; SecKeychainAttributeList *attr_list; - UInt32 info_tags[] = { kSecServerItemAttr }; + UInt32 info_tags[] = { kSecServiceItemAttr }; LPWSTR target_name; INT str_len; info.count = sizeof(info_tags)/sizeof(info_tags[0]); @@ -1502,28 +1444,28 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n", status); continue; } - if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServerItemAttr) + if (attr_list->count != 1 || attr_list->attr[0].tag != kSecServiceItemAttr) { CFRelease(item); continue; } str_len = MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, NULL, 0); - target_name = HeapAlloc(GetProcessHeap(), 0, (str_len + 1) * sizeof(WCHAR)); + target_name = heap_alloc((str_len + 1) * sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, attr_list->attr[0].data, attr_list->attr[0].length, target_name, str_len); /* nul terminate */ target_name[str_len] = '\0'; if (strcmpiW(TargetName, target_name)) { CFRelease(item); - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); continue; } - HeapFree(GetProcessHeap(), 0, target_name); + heap_free(target_name); SecKeychainItemFreeAttributesAndData(attr_list, NULL); ret = mac_read_credential_from_item(item, TRUE, NULL, NULL, &len); if (ret == ERROR_SUCCESS) { - *Credential = HeapAlloc(GetProcessHeap(), 0, len); + *Credential = heap_alloc(len); if (*Credential) { len = sizeof(**Credential); @@ -1566,7 +1508,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW key_name = get_key_name_for_target(TargetName, Type); ret = RegOpenKeyExW(hkeyMgr, key_name, 0, KEY_QUERY_VALUE, &hkeyCred); - HeapFree(GetProcessHeap(), 0, key_name); + heap_free(key_name); if (ret != ERROR_SUCCESS) { TRACE("credentials for target name %s not found\n", debugstr_w(TargetName)); @@ -1578,7 +1520,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW ret = registry_read_credential(hkeyCred, NULL, key_data, NULL, &len); if (ret == ERROR_SUCCESS) { - *Credential = HeapAlloc(GetProcessHeap(), 0, len); + *Credential = heap_alloc(len); if (*Credential) { len = sizeof(**Credential); @@ -1641,7 +1583,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf if (TargetInformation->PackageName) len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->PackageName, -1, NULL, 0) * sizeof(WCHAR); - TargetInformationW = HeapAlloc(GetProcessHeap(), 0, len); + TargetInformationW = heap_alloc(len); if (!TargetInformationW) { SetLastError(ERROR_OUTOFMEMORY); @@ -1712,7 +1654,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf ret = CredReadDomainCredentialsW(TargetInformationW, Flags, Size, &CredentialsW); - HeapFree(GetProcessHeap(), 0, TargetInformationW); + heap_free(TargetInformationW); if (ret) { @@ -1723,7 +1665,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf for (i = 0; i < *Size; i++) len += convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], NULL, 0); - *Credentials = HeapAlloc(GetProcessHeap(), 0, len); + *Credentials = heap_alloc(len); if (!*Credentials) { CredFree(CredentialsW); @@ -1785,7 +1727,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags) } len = convert_PCREDENTIALA_to_PCREDENTIALW(Credential, NULL, 0); - CredentialW = HeapAlloc(GetProcessHeap(), 0, len); + CredentialW = heap_alloc(len); if (!CredentialW) { SetLastError(ERROR_OUTOFMEMORY); @@ -1796,7 +1738,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags) ret = CredWriteW(CredentialW, Flags); - HeapFree(GetProcessHeap(), 0, CredentialW); + heap_free(CredentialW); return ret; } @@ -1889,7 +1831,7 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags) ret = RegCreateKeyExW(hkeyMgr, key_name, 0, NULL, Credential->Persist == CRED_PERSIST_SESSION ? REG_OPTION_VOLATILE : REG_OPTION_NON_VOLATILE, KEY_READ|KEY_WRITE, NULL, &hkeyCred, NULL); - HeapFree(GetProcessHeap(), 0, key_name); + heap_free(key_name); if (ret != ERROR_SUCCESS) { TRACE("credentials for target name %s not found\n", @@ -1945,20 +1887,20 @@ BOOL WINAPI CredMarshalCredentialA( CRED_MARSHAL_TYPE type, PVOID cred, LPSTR *o if ((ret = CredMarshalCredentialW( type, cred, &outW ))) { int len = WideCharToMultiByte( CP_ACP, 0, outW, -1, NULL, 0, NULL, NULL ); - if (!(*out = HeapAlloc( GetProcessHeap(), 0, len ))) + if (!(*out = heap_alloc( len ))) { - HeapFree( GetProcessHeap(), 0, outW ); + heap_free( outW ); return FALSE; } WideCharToMultiByte( CP_ACP, 0, outW, -1, *out, len, NULL, NULL ); - HeapFree( GetProcessHeap(), 0, outW ); + heap_free( outW ); } return ret; } static UINT cred_encode( const char *bin, unsigned int len, WCHAR *cred ) { - static char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#-"; + static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#-"; UINT n = 0, x; while (len > 0) @@ -2009,7 +1951,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR * case CertCredential: { size = (sizeof(cert->rgbHashOfCert) + 2) * 4 / 3; - if (!(p = HeapAlloc( GetProcessHeap(), 0, (size + 4) * sizeof(WCHAR) ))) return FALSE; + if (!(p = heap_alloc( (size + 4) * sizeof(WCHAR) ))) return FALSE; p[0] = '@'; p[1] = '@'; p[2] = 'A' + type; @@ -2021,7 +1963,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR * { len = strlenW( target->UserName ); size = (sizeof(DWORD) + len * sizeof(WCHAR) + 2) * 4 / 3; - if (!(p = HeapAlloc( GetProcessHeap(), 0, (size + 4) * sizeof(WCHAR) ))) return FALSE; + if (!(p = heap_alloc( (size + 4) * sizeof(WCHAR) ))) return FALSE; p[0] = '@'; p[1] = '@'; p[2] = 'A' + type; @@ -2054,11 +1996,11 @@ BOOL WINAPI CredUnmarshalCredentialA( LPCSTR cred, PCRED_MARSHAL_TYPE type, PVOI if (cred) { int len = MultiByteToWideChar( CP_ACP, 0, cred, -1, NULL, 0 ); - if (!(credW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE; + if (!(credW = heap_alloc( len * sizeof(WCHAR) ))) return FALSE; MultiByteToWideChar( CP_ACP, 0, cred, -1, credW, len ); } ret = CredUnmarshalCredentialW( credW, type, out ); - HeapFree( GetProcessHeap(), 0, credW ); + heap_free( credW ); return ret; } @@ -2144,7 +2086,7 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO SetLastError( ERROR_INVALID_PARAMETER ); return FALSE; } - if (!(cert = HeapAlloc( GetProcessHeap(), 0, sizeof(*cert) ))) return FALSE; + if (!(cert = heap_alloc( sizeof(*cert) ))) return FALSE; memcpy( cert->rgbHashOfCert, hash, sizeof(cert->rgbHashOfCert) ); cert->cbSize = sizeof(*cert); *out = cert; @@ -2162,10 +2104,10 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO return FALSE; } buflen = sizeof(*target) + size + sizeof(WCHAR); - if (!(target = HeapAlloc( GetProcessHeap(), 0, buflen ))) return FALSE; + if (!(target = heap_alloc( buflen ))) return FALSE; if (!cred_decode( cred + 9, len - 6, (char *)(target + 1) )) { - HeapFree( GetProcessHeap(), 0, target ); + heap_free( target ); return FALSE; } target->UserName = (WCHAR *)(target + 1); @@ -2241,11 +2183,11 @@ BOOL WINAPI CredIsMarshaledCredentialA(LPCSTR name) if (name) { len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0); - nameW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + nameW = heap_alloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, len); } res = CredIsMarshaledCredentialW(nameW); - HeapFree(GetProcessHeap(), 0, nameW); + heap_free(nameW); return res; } diff --git a/dll/win32/kernel32/winnls/string/lang.c b/dll/win32/kernel32/winnls/string/lang.c index 825c90ecaf9..f9cb3d356c5 100644 --- a/dll/win32/kernel32/winnls/string/lang.c +++ b/dll/win32/kernel32/winnls/string/lang.c @@ -54,6 +54,7 @@ static const WCHAR szLangGroupsKeyName[] = { 'L','a','n','g','u','a','g','e',' ','G','r','o','u','p','s',0 }; +#ifndef __REACTOS__ /* Charset to codepage map, sorted by name. */ static const struct charset_entry { @@ -114,7 +115,7 @@ static const struct charset_entry { "KOI8U", 21866 }, { "UTF8", CP_UTF8 } }; - +#endif struct locale_name { @@ -139,6 +140,7 @@ static LCID lcid_LC_PAPER; static LCID lcid_LC_MEASUREMENT; static LCID lcid_LC_TELEPHONE; +#ifndef __REACTOS__ /* Copy Ascii string to Unicode without using codepages */ static inline void strcpynAtoW( WCHAR *dst, const char *src, size_t n ) { @@ -149,7 +151,7 @@ static inline void strcpynAtoW( WCHAR *dst, const char *src, size_t n ) } if (n) *dst = 0; } - +#endif /*********************************************************************** * get_lcid_codepage @@ -1278,6 +1280,9 @@ BOOL WINAPI GetStringTypeW( DWORD type, LPCWSTR src, INT count, LPWORD chartype if ((c>=0x0600)&&(c<=0x06FF)) type3 |= C3_KASHIDA; if ((c>=0x3000)&&(c<=0x303F)) type3 |= C3_SYMBOL; + if ((c>=0xD800)&&(c<=0xDBFF)) type3 |= C3_HIGHSURROGATE; + if ((c>=0xDC00)&&(c<=0xDFFF)) type3 |= C3_LOWSURROGATE; + if ((c>=0xFF00)&&(c<=0xFF60)) type3 |= C3_FULLWIDTH; if ((c>=0xFF00)&&(c<=0xFF20)) type3 |= C3_SYMBOL; if ((c>=0xFF3B)&&(c<=0xFF40)) type3 |= C3_SYMBOL; @@ -1386,17 +1391,35 @@ BOOL WINAPI GetStringTypeExA( LCID locale, DWORD type, LPCSTR src, INT count, LP return GetStringTypeA(locale, type, src, count, chartype); } - /************************************************************************* - * LCMapStringW (KERNEL32.@) + * LCMapStringEx (KERNEL32.@) * - * See LCMapStringA. + * Map characters in a locale sensitive string. + * + * PARAMS + * name [I] Locale name for the conversion. + * flags [I] Flags controlling the mapping (LCMAP_ constants from "winnls.h") + * src [I] String to map + * srclen [I] Length of src in chars, or -1 if src is NUL terminated + * dst [O] Destination for mapped string + * dstlen [I] Length of dst in characters + * version [I] reserved, must be NULL + * reserved [I] reserved, must be NULL + * lparam [I] reserved, must be 0 + * + * RETURNS + * Success: The length of the mapped string in dst, including the NUL terminator. + * Failure: 0. Use GetLastError() to determine the cause. */ -INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, - LPWSTR dst, INT dstlen) +INT WINAPI LCMapStringEx(LPCWSTR name, DWORD flags, LPCWSTR src, INT srclen, LPWSTR dst, INT dstlen, + LPNLSVERSIONINFO version, LPVOID reserved, LPARAM lparam) { LPWSTR dst_ptr; + if (version) FIXME("unsupported version structure %p\n", version); + if (reserved) FIXME("unsupported reserved pointer %p\n", reserved); + if (lparam) FIXME("unsupported lparam %lx\n", lparam); + if (!src || !srclen || dstlen < 0) { SetLastError(ERROR_INVALID_PARAMETER); @@ -1415,8 +1438,6 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, if (!dstlen) dst = NULL; - lcid = ConvertDefaultLocale(lcid); - if (flags & LCMAP_SORTKEY) { INT ret; @@ -1428,8 +1449,8 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, if (srclen < 0) srclen = strlenW(src); - TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n", - lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen); + TRACE("(%s,0x%08x,%s,%d,%p,%d)\n", + debugstr_w(name), flags, debugstr_wn(src, srclen), srclen, dst, dstlen); ret = wine_get_sortkey(flags, src, srclen, (char *)dst, dstlen); if (ret == 0) @@ -1448,8 +1469,8 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, if (srclen < 0) srclen = strlenW(src) + 1; - TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n", - lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen); + TRACE("(%s,0x%08x,%s,%d,%p,%d)\n", + debugstr_w(name), flags, debugstr_wn(src, srclen), srclen, dst, dstlen); if (!dst) /* return required string length */ { @@ -1517,6 +1538,20 @@ INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, return dst_ptr - dst; } +/************************************************************************* + * LCMapStringW (KERNEL32.@) + * + * See LCMapStringA. + */ +INT WINAPI LCMapStringW(LCID lcid, DWORD flags, LPCWSTR src, INT srclen, + LPWSTR dst, INT dstlen) +{ + TRACE("(0x%04x,0x%08x,%s,%d,%p,%d)\n", + lcid, flags, debugstr_wn(src, srclen), srclen, dst, dstlen); + + return LCMapStringEx(NULL, flags, src, srclen, dst, dstlen, NULL, NULL, 0); +} + /************************************************************************* * LCMapStringA (KERNEL32.@) * @@ -1586,7 +1621,7 @@ INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, goto map_string_exit; } - dstlenW = LCMapStringW(lcid, flags, srcW, srclenW, NULL, 0); + dstlenW = LCMapStringEx(NULL, flags, srcW, srclenW, NULL, 0, NULL, NULL, 0); if (!dstlenW) goto map_string_exit; @@ -1597,7 +1632,7 @@ INT WINAPI LCMapStringA(LCID lcid, DWORD flags, LPCSTR src, INT srclen, goto map_string_exit; } - LCMapStringW(lcid, flags, srcW, srclenW, dstW, dstlenW); + LCMapStringEx(NULL, flags, srcW, srclenW, dstW, dstlenW, NULL, NULL, 0); ret = WideCharToMultiByte(locale_cp, 0, dstW, dstlenW, dst, dstlen, NULL, NULL); HeapFree(GetProcessHeap(), 0, dstW); @@ -1944,18 +1979,6 @@ static BOOL NLS_GetLanguageGroupName(LGRPID lgrpid, LPWSTR szName, ULONG nameSiz return bRet; } -/* Registry keys for NLS related information */ - -static const WCHAR szCountryListName[] = { - '\\','R','e','g','i','s','t','r','y','\\', - 'M','a','c','h','i','n','e','\\','S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'T','e','l','e','p','h','o','n','y','\\', - 'C','o','u','n','t','r','y',' ','L','i','s','t','\0' -}; - - /* Callback function ptrs for EnumSystemLanguageGroupsA/W */ typedef struct { diff --git a/drivers/input/i8042prt/keyboard.c b/drivers/input/i8042prt/keyboard.c index 0827a2f5b56..275aeb643ee 100644 --- a/drivers/input/i8042prt/keyboard.c +++ b/drivers/input/i8042prt/keyboard.c @@ -694,7 +694,7 @@ cleanup: { TRACE_(I8042PRT, "IRP_MJ_INTERNAL_DEVICE_CONTROL / IOCTL_KEYBOARD_QUERY_INDICATORS\n"); - if (Stack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS)) + if (Stack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS)) { Status = STATUS_BUFFER_TOO_SMALL; } diff --git a/include/asm/kxarm.h b/include/asm/kxarm.h index 50928e75815..770df4b5050 100644 --- a/include/asm/kxarm.h +++ b/include/asm/kxarm.h @@ -67,6 +67,16 @@ $FuncEndName TRAP_EPILOG $SystemCall fixme MEND + + #define CR 13 + #define LF 10 + #define NUL 0 + + #define ASCII dcb + + MACRO + UNIMPLEMENTED $Name + MEND #else diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index 92366bb4394..6dce8251736 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -11061,9 +11061,9 @@ RtlCheckBit( # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg) #else # define __assert_annotationA(msg) \ - DbgPrint("Assertion %s(%d): %s", __FILE__, __LINE__, msg) + DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg) # define __assert_annotationW(msg) \ - DbgPrint("Assertion %s(%d): %S", __FILE__, __LINE__, msg) + DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg) #endif #define NT_VERIFY(exp) \ diff --git a/include/psdk/winbase.h b/include/psdk/winbase.h index e4540dea9ed..9e4fe90a168 100644 --- a/include/psdk/winbase.h +++ b/include/psdk/winbase.h @@ -1277,6 +1277,12 @@ typedef DWORD (WINAPI *APPLICATION_RECOVERY_CALLBACK)(PVOID); #define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i))) #endif +typedef DWORD +(WINAPI *PFE_IMPORT_FUNC)( + _Out_writes_bytes_to_(*ulLength, *ulLength) PBYTE pbData, + _In_opt_ PVOID pvCallbackContext, + _Inout_ PULONG ulLength); + /* Functions */ #ifndef UNDER_CE int APIENTRY WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int); @@ -3142,6 +3148,7 @@ BOOL WINAPI WinLoadTrustProvider(GUID*); BOOL WINAPI Wow64DisableWow64FsRedirection(PVOID*); BOOLEAN WINAPI Wow64EnableWow64FsRedirection(_In_ BOOLEAN); BOOL WINAPI Wow64RevertWow64FsRedirection(PVOID); +DWORD WINAPI WriteEncryptedFileRaw(_In_ PFE_IMPORT_FUNC, _In_opt_ PVOID, _In_ PVOID); BOOL WINAPI WriteFile(HANDLE,LPCVOID,DWORD,LPDWORD,LPOVERLAPPED); BOOL WINAPI WriteFileEx(HANDLE,LPCVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE); BOOL WINAPI WriteFileGather(HANDLE,FILE_SEGMENT_ELEMENT*,DWORD,LPDWORD,LPOVERLAPPED); diff --git a/include/reactos/libs/fast486/fast486.h b/include/reactos/libs/fast486/fast486.h index 2606a35ad0b..efc87fefc73 100644 --- a/include/reactos/libs/fast486/fast486.h +++ b/include/reactos/libs/fast486/fast486.h @@ -190,7 +190,7 @@ VOID (NTAPI *FAST486_IO_READ_PROC) ( PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize @@ -201,7 +201,7 @@ VOID (NTAPI *FAST486_IO_WRITE_PROC) ( PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize diff --git a/include/xdk/rtlfuncs.h b/include/xdk/rtlfuncs.h index 516bcce4075..6854515341f 100644 --- a/include/xdk/rtlfuncs.h +++ b/include/xdk/rtlfuncs.h @@ -3113,9 +3113,9 @@ RtlCheckBit( # define __assert_annotationW(msg) __annotation(L"Debug", L"AssertFail", msg) #else # define __assert_annotationA(msg) \ - DbgPrint("Assertion %s(%d): %s", __FILE__, __LINE__, msg) + DbgPrint("Assertion failed at %s(%d): %s\n", __FILE__, __LINE__, msg) # define __assert_annotationW(msg) \ - DbgPrint("Assertion %s(%d): %S", __FILE__, __LINE__, msg) + DbgPrint("Assertion failed at %s(%d): %S\n", __FILE__, __LINE__, msg) #endif #define NT_VERIFY(exp) \ diff --git a/lib/fast486/fast486.c b/lib/fast486/fast486.c index 6bfd382017e..12a37685869 100644 --- a/lib/fast486/fast486.c +++ b/lib/fast486/fast486.c @@ -149,7 +149,7 @@ Fast486MemWriteCallback(PFAST486_STATE State, ULONG Address, PVOID Buffer, ULONG static VOID NTAPI -Fast486IoReadCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) +Fast486IoReadCallback(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) { UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(Port); @@ -160,7 +160,7 @@ Fast486IoReadCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG Data static VOID NTAPI -Fast486IoWriteCallback(PFAST486_STATE State, ULONG Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) +Fast486IoWriteCallback(PFAST486_STATE State, USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) { UNREFERENCED_PARAMETER(State); UNREFERENCED_PARAMETER(Port); diff --git a/lib/rtl/bitmap.c b/lib/rtl/bitmap.c index ddb6b156042..378c94c407b 100644 --- a/lib/rtl/bitmap.c +++ b/lib/rtl/bitmap.c @@ -362,7 +362,7 @@ RtlClearBits( /* Clear what's left */ NumberToClear &= (_BITCOUNT - 1); - if (NumberToClear) + if (NumberToClear != 0) { Mask = MAXINDEX << NumberToClear; *Buffer &= Mask; @@ -422,7 +422,7 @@ RtlSetBits( /* Set what's left */ NumberToSet &= (_BITCOUNT - 1); - if (NumberToSet) + if (NumberToSet != 0) { Mask = MAXINDEX << NumberToSet; *Buffer |= ~Mask; diff --git a/lib/sdk/crt/except/arm/chkstk_asm.s b/lib/sdk/crt/except/arm/chkstk_asm.s index f94d76461bc..94fb754b65e 100644 --- a/lib/sdk/crt/except/arm/chkstk_asm.s +++ b/lib/sdk/crt/except/arm/chkstk_asm.s @@ -2,31 +2,29 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * PURPOSE: Implementation of _chkstk and _alloca_probe - * FILE: lib/sdk/crt/math/amd64/chkstk_asm.s + * FILE: lib/sdk/crt/except/arm/chkstk_asm.s * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + * Yuntian Zhang (yuntian.zh@gmail.com) */ /* INCLUDES ******************************************************************/ -#include +#include /* CODE **********************************************************************/ -.code64 + TEXTAREA -MsgUnimplemented: - .ascii "Unimplemented", CR, LF, NUL +MsgUnimplemented ASCII "Unimplemented", CR, LF, NUL -FUNC __chkstk - .endprolog + LEAF_ENTRY __chkstk UNIMPLEMENTED chkstk - ret -ENDFUNC + bx lr + LEAF_END __chkstk -FUNC __alloca_probe - .endprolog + LEAF_ENTRY __alloca_probe UNIMPLEMENTED alloca_probe - ret -ENDFUNC + bx lr + LEAF_END __alloca_probe -END + END /* EOF */ diff --git a/lib/sdk/crt/oldnames-msvcrt.S b/lib/sdk/crt/oldnames-msvcrt.S index 2ef81c96997..3e07d8231b8 100644 --- a/lib/sdk/crt/oldnames-msvcrt.S +++ b/lib/sdk/crt/oldnames-msvcrt.S @@ -1,6 +1,4 @@ -#include - #ifdef _M_IX86 #define SYM(name) _##name #define IMPSYM(name) __imp__##name @@ -9,6 +7,10 @@ #define IMPSYM(name) __imp_##name #endif +#if (defined(_M_IX86) || defined(_M_AMD64)) + +#include + MACRO(CREATE_ALIAS1, alias, target) #ifdef _USE_ML EXTERN SYM(&target):PROC @@ -32,124 +34,148 @@ MACRO(CREATE_ALIAS, alias, target) CREATE_ALIAS2 &alias, &target ENDM -CREATE_ALIAS access, _access -CREATE_ALIAS chdir, _chdir -CREATE_ALIAS chmod, _chmod -CREATE_ALIAS chsize, _chsize -CREATE_ALIAS close, _close -CREATE_ALIAS creat, _creat -CREATE_ALIAS cwait, _cwait -CREATE_ALIAS2 daylight, _daylight -CREATE_ALIAS dup, _dup -CREATE_ALIAS dup2, _dup2 -CREATE_ALIAS ecvt, _ecvt -CREATE_ALIAS eof, _eof -CREATE_ALIAS execl, _execl -CREATE_ALIAS execle, _execle -CREATE_ALIAS execlp, _execlp -CREATE_ALIAS execlpe, _execlpe -CREATE_ALIAS execv, _execv -CREATE_ALIAS execve, _execve -CREATE_ALIAS execvp, _execvp -CREATE_ALIAS execvpe, _execvpe -CREATE_ALIAS fcvt, _fcvt -CREATE_ALIAS fdopen, _fdopen -CREATE_ALIAS fgetchar, _fgetchar -CREATE_ALIAS fgetwchar, _fgetwchar -CREATE_ALIAS filelength, _filelength -CREATE_ALIAS fileno, _fileno -CREATE_ALIAS fpreset, _fpreset -CREATE_ALIAS fputchar, _fputchar -CREATE_ALIAS fputwchar, _fputwchar -CREATE_ALIAS fstat, _fstat -CREATE_ALIAS ftime, _ftime -CREATE_ALIAS gcvt, _gcvt -CREATE_ALIAS getch, _getch -CREATE_ALIAS getche, _getche -CREATE_ALIAS getcwd, _getcwd -CREATE_ALIAS getpid, _getpid -CREATE_ALIAS getw, _getw -CREATE_ALIAS heapwalk, _heapwalk -CREATE_ALIAS isatty, _isatty -CREATE_ALIAS itoa, _itoa -CREATE_ALIAS kbhit, _kbhit -CREATE_ALIAS lfind, _lfind -CREATE_ALIAS lsearch, _lsearch -CREATE_ALIAS lseek, _lseek -CREATE_ALIAS ltoa, _ltoa -CREATE_ALIAS memccpy, _memccpy -CREATE_ALIAS memicmp, _memicmp -CREATE_ALIAS mkdir, _mkdir -CREATE_ALIAS mktemp, _mktemp -CREATE_ALIAS open, _open -CREATE_ALIAS pclose, _pclose -CREATE_ALIAS popen, _popen -CREATE_ALIAS putch, _putch -CREATE_ALIAS putenv, _putenv -CREATE_ALIAS putw, _putw -CREATE_ALIAS read, _read -CREATE_ALIAS rmdir, _rmdir -CREATE_ALIAS rmtmp, _rmtmp -CREATE_ALIAS searchenv, _searchenv -CREATE_ALIAS setmode, _setmode -CREATE_ALIAS snprintf, _snprintf -CREATE_ALIAS sopen, _sopen -CREATE_ALIAS spawnl, _spawnl -CREATE_ALIAS spawnle, _spawnle -CREATE_ALIAS spawnlp, _spawnlp -CREATE_ALIAS spawnlpe, _spawnlpe -CREATE_ALIAS spawnv, _spawnv -CREATE_ALIAS spawnve, _spawnve -CREATE_ALIAS spawnvp, _spawnvp -CREATE_ALIAS spawnvpe, _spawnvpe -CREATE_ALIAS stat, _stat -CREATE_ALIAS strcmpi, _strcmpi -CREATE_ALIAS strdup, _strdup -CREATE_ALIAS stricmp, _stricmp -CREATE_ALIAS stricoll, _stricoll -CREATE_ALIAS strlwr, _strlwr -CREATE_ALIAS strnicmp, _strnicmp -CREATE_ALIAS strnset, _strnset -CREATE_ALIAS strrev, _strrev -CREATE_ALIAS strset, _strset -CREATE_ALIAS strupr, _strupr -CREATE_ALIAS swab, _swab -CREATE_ALIAS tell, _tell -CREATE_ALIAS tempnam, _tempnam -CREATE_ALIAS2 timezone, _timezone -CREATE_ALIAS2 tzname, _tzname -CREATE_ALIAS tzset, _tzset -CREATE_ALIAS umask, _umask -CREATE_ALIAS ungetch, _ungetch -CREATE_ALIAS unlink, _unlink -CREATE_ALIAS utime, _utime -CREATE_ALIAS wcsdup, _wcsdup -CREATE_ALIAS wcsicmp, _wcsicmp -CREATE_ALIAS wcsicoll, _wcsicoll -CREATE_ALIAS wcslwr, _wcslwr -CREATE_ALIAS wcsnicmp, _wcsnicmp -CREATE_ALIAS wcsnset, _wcsnset -CREATE_ALIAS wcsrev, _wcsrev -CREATE_ALIAS wcsset, _wcsset -CREATE_ALIAS wcsupr, _wcsupr -CREATE_ALIAS wpopen, _wpopen -CREATE_ALIAS write, _write -// non-ANSI functions declared in math.h -CREATE_ALIAS j0, _j0 -CREATE_ALIAS j1, _j1 -CREATE_ALIAS jn, _jn -CREATE_ALIAS y0, _y0 -CREATE_ALIAS y1, _y1 -CREATE_ALIAS yn, _yn -CREATE_ALIAS chgsign, _chgsign -CREATE_ALIAS scalb, _scalb -CREATE_ALIAS finite, _finite -CREATE_ALIAS fpclass, _fpclass -// C99 functions -CREATE_ALIAS cabs, _cabs -CREATE_ALIAS hypot, _hypot -CREATE_ALIAS logb, _logb -CREATE_ALIAS nextafter, _nextafter +#elif defined(_M_ARM) -END +#include + + MACRO + CREATE_ALIAS1 $alias, $target + IMPORT SYM($alias), WEAK SYM($target) + MEND + + MACRO + CREATE_ALIAS2 $alias, $target + IMPORT IMPSYM($alias), WEAK IMPSYM($target) + MEND + + MACRO + CREATE_ALIAS $alias, $target + CREATE_ALIAS1 $alias, $target + CREATE_ALIAS2 $alias, $target + MEND +#else +#error "Unsupported platform." +#endif + + /* Do not remove indentation, this would break ARM build! */ + CREATE_ALIAS access, _access + CREATE_ALIAS chdir, _chdir + CREATE_ALIAS chmod, _chmod + CREATE_ALIAS chsize, _chsize + CREATE_ALIAS close, _close + CREATE_ALIAS creat, _creat + CREATE_ALIAS cwait, _cwait + CREATE_ALIAS2 daylight, _daylight + CREATE_ALIAS dup, _dup + CREATE_ALIAS dup2, _dup2 + CREATE_ALIAS ecvt, _ecvt + CREATE_ALIAS eof, _eof + CREATE_ALIAS execl, _execl + CREATE_ALIAS execle, _execle + CREATE_ALIAS execlp, _execlp + CREATE_ALIAS execlpe, _execlpe + CREATE_ALIAS execv, _execv + CREATE_ALIAS execve, _execve + CREATE_ALIAS execvp, _execvp + CREATE_ALIAS execvpe, _execvpe + CREATE_ALIAS fcvt, _fcvt + CREATE_ALIAS fdopen, _fdopen + CREATE_ALIAS fgetchar, _fgetchar + CREATE_ALIAS fgetwchar, _fgetwchar + CREATE_ALIAS filelength, _filelength + CREATE_ALIAS fileno, _fileno + CREATE_ALIAS fpreset, _fpreset + CREATE_ALIAS fputchar, _fputchar + CREATE_ALIAS fputwchar, _fputwchar + CREATE_ALIAS fstat, _fstat + CREATE_ALIAS ftime, _ftime + CREATE_ALIAS gcvt, _gcvt + CREATE_ALIAS getch, _getch + CREATE_ALIAS getche, _getche + CREATE_ALIAS getcwd, _getcwd + CREATE_ALIAS getpid, _getpid + CREATE_ALIAS getw, _getw + CREATE_ALIAS heapwalk, _heapwalk + CREATE_ALIAS isatty, _isatty + CREATE_ALIAS itoa, _itoa + CREATE_ALIAS kbhit, _kbhit + CREATE_ALIAS lfind, _lfind + CREATE_ALIAS lsearch, _lsearch + CREATE_ALIAS lseek, _lseek + CREATE_ALIAS ltoa, _ltoa + CREATE_ALIAS memccpy, _memccpy + CREATE_ALIAS memicmp, _memicmp + CREATE_ALIAS mkdir, _mkdir + CREATE_ALIAS mktemp, _mktemp + CREATE_ALIAS open, _open + CREATE_ALIAS pclose, _pclose + CREATE_ALIAS popen, _popen + CREATE_ALIAS putch, _putch + CREATE_ALIAS putenv, _putenv + CREATE_ALIAS putw, _putw + CREATE_ALIAS read, _read + CREATE_ALIAS rmdir, _rmdir + CREATE_ALIAS rmtmp, _rmtmp + CREATE_ALIAS searchenv, _searchenv + CREATE_ALIAS setmode, _setmode + CREATE_ALIAS snprintf, _snprintf + CREATE_ALIAS sopen, _sopen + CREATE_ALIAS spawnl, _spawnl + CREATE_ALIAS spawnle, _spawnle + CREATE_ALIAS spawnlp, _spawnlp + CREATE_ALIAS spawnlpe, _spawnlpe + CREATE_ALIAS spawnv, _spawnv + CREATE_ALIAS spawnve, _spawnve + CREATE_ALIAS spawnvp, _spawnvp + CREATE_ALIAS spawnvpe, _spawnvpe + CREATE_ALIAS stat, _stat + CREATE_ALIAS strcmpi, _strcmpi + CREATE_ALIAS strdup, _strdup + CREATE_ALIAS stricmp, _stricmp + CREATE_ALIAS stricoll, _stricoll + CREATE_ALIAS strlwr, _strlwr + CREATE_ALIAS strnicmp, _strnicmp + CREATE_ALIAS strnset, _strnset + CREATE_ALIAS strrev, _strrev + CREATE_ALIAS strset, _strset + CREATE_ALIAS strupr, _strupr + CREATE_ALIAS swab, _swab + CREATE_ALIAS tell, _tell + CREATE_ALIAS tempnam, _tempnam + CREATE_ALIAS2 timezone, _timezone + CREATE_ALIAS2 tzname, _tzname + CREATE_ALIAS tzset, _tzset + CREATE_ALIAS umask, _umask + CREATE_ALIAS ungetch, _ungetch + CREATE_ALIAS unlink, _unlink + CREATE_ALIAS utime, _utime + CREATE_ALIAS wcsdup, _wcsdup + CREATE_ALIAS wcsicmp, _wcsicmp + CREATE_ALIAS wcsicoll, _wcsicoll + CREATE_ALIAS wcslwr, _wcslwr + CREATE_ALIAS wcsnicmp, _wcsnicmp + CREATE_ALIAS wcsnset, _wcsnset + CREATE_ALIAS wcsrev, _wcsrev + CREATE_ALIAS wcsset, _wcsset + CREATE_ALIAS wcsupr, _wcsupr + CREATE_ALIAS wpopen, _wpopen + CREATE_ALIAS write, _write + // non-ANSI functions declared in math.h + CREATE_ALIAS j0, _j0 + CREATE_ALIAS j1, _j1 + CREATE_ALIAS jn, _jn + CREATE_ALIAS y0, _y0 + CREATE_ALIAS y1, _y1 + CREATE_ALIAS yn, _yn + CREATE_ALIAS chgsign, _chgsign + CREATE_ALIAS scalb, _scalb + CREATE_ALIAS finite, _finite + CREATE_ALIAS fpclass, _fpclass + // C99 functions + CREATE_ALIAS cabs, _cabs + CREATE_ALIAS hypot, _hypot + CREATE_ALIAS logb, _logb + CREATE_ALIAS nextafter, _nextafter + + END diff --git a/lib/sdk/crt/stdlib/errno.c b/lib/sdk/crt/stdlib/errno.c index 049ad2c1fb8..f1b06e9b80f 100644 --- a/lib/sdk/crt/stdlib/errno.c +++ b/lib/sdk/crt/stdlib/errno.c @@ -141,7 +141,9 @@ void __cdecl _invalid_parameter(const wchar_t *expr, const wchar_t *func, else { ERR( "%s:%u %s: %s %lx\n", debugstr_w(file), line, debugstr_w(func), debugstr_w(expr), arg ); +#if _MSVCR_VER > 0 // FIXME: possible improvement: use a global variable in the DLL RaiseException( STATUS_INVALID_CRUNTIME_PARAMETER, EXCEPTION_NONCONTINUABLE, 0, NULL ); +#endif } } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index e034f3439a4..ac419a318bb 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -256,8 +256,8 @@ check Wine current souces first as it may already be fixed. reactos/lib/3rdparty/strmbase # Synced to Wine-1.7.27 advapi32 - - reactos/dll/win32/advapi32/crypt/*.c # Synced to Wine-1.7.1 - reactos/dll/win32/advapi32/sec/cred.c # Synced to Wine-1.7.1 + reactos/dll/win32/advapi32/crypt/*.c # Synced to Wine-1.7.27 + reactos/dll/win32/advapi32/sec/cred.c # Synced to Wine-1.7.27 reactos/dll/win32/advapi32/sec/sid.c # Out of Sync gdi32 - diff --git a/ntoskrnl/io/iomgr/driver.c b/ntoskrnl/io/iomgr/driver.c index e623d7b65e8..e0e3bb970f8 100644 --- a/ntoskrnl/io/iomgr/driver.c +++ b/ntoskrnl/io/iomgr/driver.c @@ -310,14 +310,8 @@ IopLoadServiceModule( HANDLE CCSKey, ServiceKey; PVOID BaseAddress; - DPRINT("IopLoadServiceModule(%wZ, 0x%p)\n", ServiceName, ModuleObject); - - /* FIXME: This check may be removed once the bug is fixed */ - if (ServiceName->Buffer == NULL) - { - DPRINT1("If you see this, please report to Fireball or hpoussin!\n"); - return STATUS_UNSUCCESSFUL; - } + ASSERT(ServiceName->Length); + DPRINT("IopLoadServiceModule(%wZ, 0x%p)\n", ServiceName, ModuleObject); if (ExpInTextModeSetup) { diff --git a/ntoskrnl/io/iomgr/error.c b/ntoskrnl/io/iomgr/error.c index 0c7c14ec926..91c1621d6ae 100644 --- a/ntoskrnl/io/iomgr/error.c +++ b/ntoskrnl/io/iomgr/error.c @@ -310,11 +310,9 @@ IopLogWorker(IN PVOID Parameter) /* We do, query its name */ Status = ObQueryNameString(LogEntry->DeviceObject, ObjectNameInfo, - sizeof(OBJECT_NAME_INFORMATION) + - 100 - - DriverNameLength, + sizeof(Buffer), &ReturnedLength); - if ((!NT_SUCCESS(Status)) || !(ObjectNameInfo->Name.Length)) + if (!NT_SUCCESS(Status) || (ObjectNameInfo->Name.Length == 0)) { /* Setup an empty name */ ObjectNameInfo->Name.Length = 0; @@ -371,6 +369,7 @@ IopLogWorker(IN PVOID Parameter) { ExFreePool(PoolObjectNameInfo); PoolObjectNameInfo = NULL; + ObjectNameInfo = (POBJECT_NAME_INFORMATION)&Buffer; } /* Go to the next string buffer position */ diff --git a/ntoskrnl/io/iomgr/ramdisk.c b/ntoskrnl/io/iomgr/ramdisk.c index d07cb353155..658b997df6e 100644 --- a/ntoskrnl/io/iomgr/ramdisk.c +++ b/ntoskrnl/io/iomgr/ramdisk.c @@ -37,7 +37,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) PLIST_ENTRY ListHead, NextEntry; OBJECT_ATTRIBUTES ObjectAttributes; WCHAR SourceString[54]; - + // // Scan memory descriptors // @@ -52,7 +52,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MemoryDescriptor = CONTAINING_RECORD(NextEntry, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry); - + // // Needs to be a ROM/RAM descriptor // @@ -63,7 +63,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // NextEntry = NextEntry->Flink; } - + // // Nothing found? // @@ -78,7 +78,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 0, 0); } - + // // Setup the input buffer // @@ -91,7 +91,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) RamdiskCreate.DiskGuid = RAMDISK_BOOTDISK_GUID; RamdiskCreate.DriveLetter = L'C'; RamdiskCreate.Options.Fixed = TRUE; - + // // Check for commandline parameters // @@ -102,7 +102,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) // Make everything upper case // _strupr(CommandLine); - + // // Check for offset parameter // @@ -121,12 +121,12 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) RamdiskCreate.DiskOffset = atol(OffsetValue + 1); } } - + // // Reduce the disk length // RamdiskCreate.DiskLength.QuadPart -= RamdiskCreate.DiskOffset; - + // // Check for length parameter // @@ -146,7 +146,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } } } - + // // Setup object attributes // @@ -156,7 +156,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL); - + // // Open a handle to the driver // @@ -177,7 +177,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 0, 0); } - + // // Send create command // @@ -203,7 +203,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 0, 0); } - + // // Convert the GUID // @@ -219,7 +219,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 0, 0); } - + // // Build the symbolic link name and target // @@ -230,7 +230,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) SymbolicLinkName.Length = 38; SymbolicLinkName.MaximumLength = 38 + sizeof(UNICODE_NULL); SymbolicLinkName.Buffer = L"\\ArcName\\ramdisk(0)"; - + // // Create the symbolic link // @@ -248,7 +248,7 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock) 0, 0); } - + // // We made it // diff --git a/ntoskrnl/io/iomgr/remlock.c b/ntoskrnl/io/iomgr/remlock.c index d353a00435b..ad098f3ae2d 100644 --- a/ntoskrnl/io/iomgr/remlock.c +++ b/ntoskrnl/io/iomgr/remlock.c @@ -100,7 +100,7 @@ IoAcquireRemoveLockEx(IN PIO_REMOVE_LOCK RemoveLock, TrackingBlock = ExAllocatePoolWithTag(NonPagedPool, sizeof(IO_REMOVE_LOCK_TRACKING_BLOCK), Lock->Dbg.AllocateTag); if (!TrackingBlock) { - /* Keep count of failures for lock release and missing tags */ + /* Keep count of failures for lock release and missing tags */ InterlockedIncrement(&(Lock->Dbg.LowMemoryCount)); } else diff --git a/ntoskrnl/io/iomgr/volume.c b/ntoskrnl/io/iomgr/volume.c index 114def8aeb4..82bf52f5f21 100644 --- a/ntoskrnl/io/iomgr/volume.c +++ b/ntoskrnl/io/iomgr/volume.c @@ -1365,7 +1365,7 @@ IoVolumeDeviceToDosName(IN PVOID VolumeDeviceObject, * name lengths than MAXUSHORT, we can't use * them, because we have to return this in an UNICODE_STRING * that stores length on USHORT. - */ + */ Length = VolumePath.MultiSzLength + sizeof(VolumePath); if (Length > MAXUSHORT) { diff --git a/ntoskrnl/io/pnpmgr/pnpinit.c b/ntoskrnl/io/pnpmgr/pnpinit.c index 30e20ca9e62..c51e326229a 100644 --- a/ntoskrnl/io/pnpmgr/pnpinit.c +++ b/ntoskrnl/io/pnpmgr/pnpinit.c @@ -55,7 +55,7 @@ PiInitCacheGroupInformation(VOID) UNICODE_STRING GroupString = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet" L"\\Control\\ServiceGroupOrder"); - + /* ReactOS HACK for SETUPLDR */ if (KeLoaderBlock->SetupLdrBlock) { @@ -64,7 +64,7 @@ PiInitCacheGroupInformation(VOID) PiInitGroupOrderTable = (PVOID)0xBABEB00B; return STATUS_SUCCESS; } - + /* Open the registry key */ Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, @@ -75,7 +75,7 @@ PiInitCacheGroupInformation(VOID) /* Get the list */ Status = IopGetRegistryValue(KeyHandle, L"List", &KeyValueInformation); ZwClose(KeyHandle); - + /* Make sure we got it */ if (NT_SUCCESS(Status)) { @@ -87,7 +87,7 @@ PiInitCacheGroupInformation(VOID) Status = PnpRegMultiSzToUnicodeStrings(KeyValueInformation, &GroupTable, &Count); - + /* Cache it for later */ PiInitGroupOrderTable = GroupTable; PiInitGroupOrderTableCount = (USHORT)Count; @@ -97,12 +97,12 @@ PiInitCacheGroupInformation(VOID) /* Fail */ Status = STATUS_UNSUCCESSFUL; } - + /* Free the information */ ExFreePool(KeyValueInformation); } } - + /* Return status */ return Status; } @@ -117,13 +117,13 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle) PVOID Buffer; UNICODE_STRING Group; PAGED_CODE(); - + /* Make sure we have a cache */ if (!PiInitGroupOrderTable) return -1; - + /* If we don't have a handle, the rest is easy -- return the count */ if (!ServiceHandle) return PiInitGroupOrderTableCount + 1; - + /* Otherwise, get the group value */ Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation); if (!NT_SUCCESS(Status)) return PiInitGroupOrderTableCount; @@ -131,20 +131,20 @@ PpInitGetGroupOrderIndex(IN HANDLE ServiceHandle) /* Make sure we have a valid string */ ASSERT(KeyValueInformation->Type == REG_SZ); ASSERT(KeyValueInformation->DataLength); - + /* Convert to unicode string */ Buffer = (PVOID)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &Group.Length); Group.MaximumLength = (USHORT)KeyValueInformation->DataLength; Group.Buffer = Buffer; - + /* Loop the groups */ for (i = 0; i < PiInitGroupOrderTableCount; i++) { /* Try to find a match */ if (RtlEqualUnicodeString(&Group, &PiInitGroupOrderTable[i], TRUE)) break; } - + /* We're done */ ExFreePool(KeyValueInformation); return i; @@ -167,15 +167,15 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle) UNICODE_STRING GroupString = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet" L"\\Control\\ServiceGroupOrder"); - + /* Open the key */ Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, &GroupString, KEY_READ); if (!NT_SUCCESS(Status)) goto Quickie; - + /* Read the group */ Status = IopGetRegistryValue(ServiceHandle, L"Group", &KeyValueInformation); if (!NT_SUCCESS(Status)) goto Quickie; - + /* Make sure we have a group */ if ((KeyValueInformation->Type == REG_SZ) && (KeyValueInformation->DataLength)) @@ -199,7 +199,7 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle) Tag = *(PULONG)((ULONG_PTR)KeyValueInformationTag + KeyValueInformationTag->DataOffset); } - + /* We can get rid of this now */ ExFreePool(KeyValueInformationTag); @@ -207,13 +207,13 @@ PipGetDriverTagPriority(IN HANDLE ServiceHandle) Status = IopGetRegistryValue(KeyHandle, Group.Buffer, &KeyValueInformationGroupOrderList); - + /* We can get rid of this now */ Quickie: if (KeyValueInformation) ExFreePool(KeyValueInformation); if (KeyHandle) NtClose(KeyHandle); if (!NT_SUCCESS(Status)) return -1; - + /* We're on the success path -- validate the tag order*/ if ((KeyValueInformationGroupOrderList->Type == REG_BINARY) && (KeyValueInformationGroupOrderList->DataLength)) @@ -221,12 +221,12 @@ Quickie: /* Get the order array */ GroupOrder = (PULONG)((ULONG_PTR)KeyValueInformationGroupOrderList + KeyValueInformationGroupOrderList->DataOffset); - + /* Get the count */ Count = *GroupOrder; ASSERT(((Count + 1) * sizeof(ULONG)) <= KeyValueInformationGroupOrderList->DataLength); - + /* Now loop each tag */ GroupOrder++; for (i = 1; i <= Count; i++) @@ -238,7 +238,7 @@ Quickie: GroupOrder++; } } - + /* Last buffer to free */ ExFreePool(KeyValueInformationGroupOrderList); return i; @@ -258,7 +258,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Class"); PKEY_VALUE_FULL_INFORMATION KeyValueInformation = NULL; PWCHAR Buffer; - + /* Open enumeration root key */ Status = IopOpenRegistryKeyEx(&EnumRootKey, NULL, @@ -269,7 +269,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status); return Status; } - + /* Open instance subkey */ Status = IopOpenRegistryKeyEx(&SubKey, EnumRootKey, @@ -281,7 +281,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status); return Status; } - + /* Get class GUID */ Status = IopGetRegistryValue(SubKey, REGSTR_VAL_CLASSGUID, @@ -293,7 +293,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length); ClassGuid.MaximumLength = (USHORT)KeyValueInformation->DataLength; ClassGuid.Buffer = Buffer; - + /* Open the key */ Status = IopOpenRegistryKeyEx(&ControlKey, NULL, @@ -320,7 +320,7 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, ClassKey = NULL; } } - + /* Check if we made it till here */ if (ClassKey) { @@ -342,11 +342,11 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, ZwClose(PropertiesKey); } } - + /* Free the registry data */ ExFreePool(KeyValueInformation); } - + /* Do ReactOS-style setup */ Status = IopAttachFilterDrivers(DeviceNode, TRUE); if (!NT_SUCCESS(Status)) @@ -363,10 +363,10 @@ PipCallDriverAddDevice(IN PDEVICE_NODE DeviceNode, IopRemoveDevice(DeviceNode); return Status; } - + Status = IopStartDevice(DeviceNode); } - + /* Return status */ return Status; } @@ -382,21 +382,21 @@ IopInitializePlugPlayServices(VOID) UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"); UNICODE_STRING PnpManagerDriverName = RTL_CONSTANT_STRING(DRIVER_ROOT_NAME L"PnpManager"); PDEVICE_OBJECT Pdo; - + /* Initialize locks and such */ KeInitializeSpinLock(&IopDeviceTreeLock); - + /* Get the default interface */ PnpDefaultInterfaceType = IopDetermineDefaultInterfaceType(); - + /* Initialize arbiters */ Status = IopInitializeArbiters(); if (!NT_SUCCESS(Status)) return Status; - + /* Setup the group cache */ Status = PiInitCacheGroupInformation(); if (!NT_SUCCESS(Status)) return Status; - + /* Open the current control set */ Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, @@ -443,14 +443,14 @@ IopInitializePlugPlayServices(VOID) REG_OPTION_NON_VOLATILE, &Disposition); if (!NT_SUCCESS(Status)) return Status; - + /* Check if it's a new key */ if (Disposition == REG_CREATED_NEW_KEY) { /* FIXME: DACLs */ DPRINT1("Need to build DACL\n"); } - + /* Create the root key */ ParentHandle = EnumHandle; RtlInitUnicodeString(&KeyName, REGSTR_KEY_ROOTENUM); @@ -463,7 +463,7 @@ IopInitializePlugPlayServices(VOID) NtClose(ParentHandle); if (!NT_SUCCESS(Status)) return Status; NtClose(EnumHandle); - + /* Open the root key now */ RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM"); Status = IopOpenRegistryKeyEx(&EnumHandle, @@ -491,7 +491,7 @@ IopInitializePlugPlayServices(VOID) DPRINT1("IoCreateDriverObject() failed\n"); KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0); } - + /* Create the root PDO */ Status = IoCreateDevice(IopRootDriverObject, sizeof(IOPNP_DEVICE_EXTENSION), @@ -505,10 +505,10 @@ IopInitializePlugPlayServices(VOID) DPRINT1("IoCreateDevice() failed\n"); KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0); } - + /* This is a bus enumerated device */ Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE; - + /* Create the root device node */ IopRootDeviceNode = PipAllocateDeviceNode(Pdo); @@ -516,11 +516,11 @@ IopInitializePlugPlayServices(VOID) IopRootDeviceNode->Flags |= DNF_STARTED + DNF_PROCESSED + DNF_ENUMERATED + DNF_MADEUP + DNF_NO_RESOURCE_REQUIRED + DNF_ADDED; - + /* Create instance path */ RtlCreateUnicodeString(&IopRootDeviceNode->InstancePath, REGSTR_VAL_ROOT_DEVNODE); - + /* Call the add device routine */ IopRootDriverObject->DriverExtension->AddDevice(IopRootDriverObject, IopRootDeviceNode->PhysicalDeviceObject); @@ -528,23 +528,23 @@ IopInitializePlugPlayServices(VOID) /* Initialize PnP-Event notification support */ Status = IopInitPlugPlayEvents(); if (!NT_SUCCESS(Status)) return Status; - + /* Report the device to the user-mode pnp manager */ IopQueueTargetDeviceEvent(&GUID_DEVICE_ARRIVAL, &IopRootDeviceNode->InstancePath); - + /* Initialize the Bus Type GUID List */ PnpBusTypeGuidList = ExAllocatePool(PagedPool, sizeof(IO_BUS_TYPE_GUID_LIST)); RtlZeroMemory(PnpBusTypeGuidList, sizeof(IO_BUS_TYPE_GUID_LIST)); ExInitializeFastMutex(&PnpBusTypeGuidList->Lock); - + /* Launch the firmware mapper */ Status = IopUpdateRootKey(); if (!NT_SUCCESS(Status)) return Status; - + /* Close the handle to the control set */ NtClose(KeyHandle); - + /* We made it */ return STATUS_SUCCESS; } diff --git a/ntoskrnl/io/pnpmgr/pnpmgr.c b/ntoskrnl/io/pnpmgr/pnpmgr.c index cf84e79e8a5..09284d62a44 100644 --- a/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -87,7 +87,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode) PKEY_VALUE_PARTIAL_INFORMATION PartialInfo; ULONG HidLength = 0, CidLength = 0, BufferLength; PWCHAR IdBuffer, OriginalIdBuffer; - + /* Open the device instance key */ Status = IopCreateDeviceKeyPath(&DeviceNode->InstancePath, 0, &InstanceKey); if (Status != STATUS_SUCCESS) @@ -174,7 +174,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode) ZwClose(InstanceKey); return; } - + /* Copy CID next */ CidLength = PartialInfo->DataLength; RtlCopyMemory(((PUCHAR)IdBuffer) + HidLength, PartialInfo->Data, CidLength); @@ -182,7 +182,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode) /* Free our temp buffer */ ExFreePool(PartialInfo); - + InitializeObjectAttributes(&ObjectAttributes, &CriticalDeviceKeyU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, @@ -203,15 +203,15 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode) while (*IdBuffer) { USHORT StringLength = (USHORT)wcslen(IdBuffer) + 1, Index; - + IopFixupDeviceId(IdBuffer); - + /* Look through all subkeys for a match */ for (Index = 0; TRUE; Index++) { ULONG NeededLength; PKEY_BASIC_INFORMATION BasicInfo; - + Status = ZwEnumerateKey(CriticalDeviceKey, Index, KeyBasicInformation, @@ -415,7 +415,7 @@ IopInstallCriticalDevice(PDEVICE_NODE DeviceNode) /* Advance to the next ID */ IdBuffer += StringLength; } - + ExFreePool(OriginalIdBuffer); ZwClose(InstanceKey); ZwClose(CriticalDeviceKey); @@ -428,7 +428,7 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode, { PDEVICE_OBJECT Fdo; NTSTATUS Status; - + if (!DriverObject) { /* Special case for bus driven devices */ @@ -497,11 +497,11 @@ IopSendEject(IN PDEVICE_OBJECT DeviceObject) { IO_STACK_LOCATION Stack; PVOID Dummy; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_EJECT; - + return IopSynchronousCall(DeviceObject, &Stack, &Dummy); } @@ -512,11 +512,11 @@ IopSendSurpriseRemoval(IN PDEVICE_OBJECT DeviceObject) { IO_STACK_LOCATION Stack; PVOID Dummy; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_SURPRISE_REMOVAL; - + /* Drivers should never fail a IRP_MN_SURPRISE_REMOVAL request */ IopSynchronousCall(DeviceObject, &Stack, &Dummy); } @@ -530,12 +530,12 @@ IopQueryRemoveDevice(IN PDEVICE_OBJECT DeviceObject) IO_STACK_LOCATION Stack; PVOID Dummy; NTSTATUS Status; - + ASSERT(DeviceNode); - + IopQueueTargetDeviceEvent(&GUID_DEVICE_REMOVE_PENDING, &DeviceNode->InstancePath); - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_QUERY_REMOVE_DEVICE; @@ -547,7 +547,7 @@ IopQueryRemoveDevice(IN PDEVICE_OBJECT DeviceObject) &GUID_TARGET_DEVICE_QUERY_REMOVE, NULL, NULL); - + if (!NT_SUCCESS(Status)) { DPRINT1("Removal vetoed by %wZ\n", &DeviceNode->InstancePath); @@ -565,11 +565,11 @@ IopQueryStopDevice(IN PDEVICE_OBJECT DeviceObject) { IO_STACK_LOCATION Stack; PVOID Dummy; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_QUERY_STOP_DEVICE; - + return IopSynchronousCall(DeviceObject, &Stack, &Dummy); } @@ -584,7 +584,7 @@ IopSendRemoveDevice(IN PDEVICE_OBJECT DeviceObject) /* Drop all our state for this device in case it isn't really going away */ DeviceNode->Flags &= DNF_ENUMERATED | DNF_PROCESSED; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_REMOVE_DEVICE; @@ -607,14 +607,14 @@ IopCancelRemoveDevice(IN PDEVICE_OBJECT DeviceObject) { IO_STACK_LOCATION Stack; PVOID Dummy; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_CANCEL_REMOVE_DEVICE; - + /* Drivers should never fail a IRP_MN_CANCEL_REMOVE_DEVICE request */ IopSynchronousCall(DeviceObject, &Stack, &Dummy); - + IopNotifyPlugPlayNotification(DeviceObject, EventCategoryTargetDeviceChange, &GUID_TARGET_DEVICE_REMOVE_CANCELLED, @@ -629,11 +629,11 @@ IopSendStopDevice(IN PDEVICE_OBJECT DeviceObject) { IO_STACK_LOCATION Stack; PVOID Dummy; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_STOP_DEVICE; - + /* Drivers should never fail a IRP_MN_STOP_DEVICE request */ IopSynchronousCall(DeviceObject, &Stack, &Dummy); } @@ -647,17 +647,17 @@ IopStartDevice2(IN PDEVICE_OBJECT DeviceObject) NTSTATUS Status; PVOID Dummy; DEVICE_CAPABILITIES DeviceCapabilities; - + /* Get the device node */ DeviceNode = IopGetDeviceNode(DeviceObject); - + ASSERT(!(DeviceNode->Flags & DNF_DISABLED)); /* Build the I/O stack location */ RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_START_DEVICE; - + Stack.Parameters.StartDevice.AllocatedResources = DeviceNode->ResourceList; Stack.Parameters.StartDevice.AllocatedResourcesTranslated = @@ -677,7 +677,7 @@ IopStartDevice2(IN PDEVICE_OBJECT DeviceObject) DPRINT1("Warning: PnP Start failed (%wZ) [Status: 0x%x]\n", &DeviceNode->InstancePath, Status); return; } - + DPRINT("Sending IRP_MN_QUERY_CAPABILITIES to device stack (after start)\n"); Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities); @@ -688,7 +688,7 @@ IopStartDevice2(IN PDEVICE_OBJECT DeviceObject) /* Invalidate device state so IRP_MN_QUERY_PNP_DEVICE_STATE is sent */ IoInvalidateDeviceState(DeviceObject); - + /* Otherwise, mark us as started */ DeviceNode->Flags |= DNF_STARTED; DeviceNode->Flags &= ~DNF_STOPPED; @@ -704,23 +704,23 @@ IopStartAndEnumerateDevice(IN PDEVICE_NODE DeviceNode) PDEVICE_OBJECT DeviceObject; NTSTATUS Status; PAGED_CODE(); - + /* Sanity check */ ASSERT((DeviceNode->Flags & DNF_ADDED)); ASSERT((DeviceNode->Flags & (DNF_RESOURCE_ASSIGNED | DNF_RESOURCE_REPORTED | DNF_NO_RESOURCE_REQUIRED))); - + /* Get the device object */ DeviceObject = DeviceNode->PhysicalDeviceObject; - + /* Check if we're not started yet */ if (!(DeviceNode->Flags & DNF_STARTED)) { /* Start us */ IopStartDevice2(DeviceObject); } - + /* Do we need to query IDs? This happens in the case of manual reporting */ #if 0 if (DeviceNode->Flags & DNF_NEED_QUERY_IDS) @@ -730,7 +730,7 @@ IopStartAndEnumerateDevice(IN PDEVICE_NODE DeviceNode) ASSERT(FALSE); } #endif - + /* Make sure we're started, and check if we need enumeration */ if ((DeviceNode->Flags & DNF_STARTED) && (DeviceNode->Flags & DNF_NEED_ENUMERATION_ONLY)) @@ -744,7 +744,7 @@ IopStartAndEnumerateDevice(IN PDEVICE_NODE DeviceNode) /* Nothing to do */ Status = STATUS_SUCCESS; } - + /* Return */ return Status; } @@ -1243,18 +1243,18 @@ IopSynchronousCall(IN PDEVICE_OBJECT DeviceObject, NTSTATUS Status; PDEVICE_OBJECT TopDeviceObject; PAGED_CODE(); - + /* Call the top of the device stack */ TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject); - + /* Allocate an IRP */ Irp = IoAllocateIrp(TopDeviceObject->StackSize, FALSE); if (!Irp) return STATUS_INSUFFICIENT_RESOURCES; - + /* Initialize to failure */ Irp->IoStatus.Status = IoStatusBlock.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Information = IoStatusBlock.Information = 0; - + /* Special case for IRP_MN_FILTER_RESOURCE_REQUIREMENTS */ if (IoStackLocation->MinorFunction == IRP_MN_FILTER_RESOURCE_REQUIREMENTS) { @@ -1262,22 +1262,22 @@ IopSynchronousCall(IN PDEVICE_OBJECT DeviceObject, Irp->IoStatus.Information = IoStatusBlock.Information = (ULONG_PTR)IoStackLocation->Parameters.FilterResourceRequirements.IoResourceRequirementList; } - + /* Initialize the event */ KeInitializeEvent(&Event, SynchronizationEvent, FALSE); - + /* Set them up */ Irp->UserIosb = &IoStatusBlock; Irp->UserEvent = &Event; - + /* Queue the IRP */ Irp->Tail.Overlay.Thread = PsGetCurrentThread(); IoQueueThreadIrp(Irp); - + /* Copy-in the stack */ IrpStack = IoGetNextIrpStackLocation(Irp); *IrpStack = *IoStackLocation; - + /* Call the driver */ Status = IoCallDriver(TopDeviceObject, Irp); if (Status == STATUS_PENDING) @@ -1307,7 +1307,7 @@ IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, IN PIO_STACK_LOCATION Stack OPTIONAL) { IO_STACK_LOCATION IoStackLocation; - + /* Fill out the stack information */ RtlZeroMemory(&IoStackLocation, sizeof(IO_STACK_LOCATION)); IoStackLocation.MajorFunction = IRP_MJ_PNP; @@ -1319,7 +1319,7 @@ IopInitiatePnpIrp(IN PDEVICE_OBJECT DeviceObject, &Stack->Parameters, sizeof(Stack->Parameters)); } - + /* Do the PnP call */ IoStatusBlock->Status = IopSynchronousCall(DeviceObject, &IoStackLocation, @@ -3295,11 +3295,11 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle, UNICODE_STRING KeyString; NTSTATUS Status = STATUS_SUCCESS; PAGED_CODE(); - + /* P1 is start, pp is end */ p1 = KeyName->Buffer; pp = (PVOID)((ULONG_PTR)p1 + KeyName->Length); - + /* Create the target key */ InitializeObjectAttributes(&ObjectAttributes, KeyName, @@ -3320,31 +3320,31 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle, /* Target key failed, so we'll need to create its parent. Setup array */ HandleArray[0] = NULL; HandleArray[1] = RootHandle; - + /* Keep recursing for each missing parent */ while (Recursing) { /* And if we're deep enough, close the last handle */ if (NestedCloseLevel > 1) ZwClose(HandleArray[RootHandleIndex]); - + /* We're setup to ping-pong between the two handle array entries */ RootHandleIndex = i; i = (i + 1) & 1; - + /* Clear the one we're attempting to open now */ HandleArray[i] = NULL; - + /* Process the parent key name */ for (p = p1; ((p < pp) && (*p != OBJ_NAME_PATH_SEPARATOR)); p++); Length = (USHORT)(p - p1) * sizeof(WCHAR); - + /* Is there a parent name? */ if (Length) { /* Build the unicode string for it */ KeyString.Buffer = p1; KeyString.Length = KeyString.MaximumLength = Length; - + /* Now try opening the parent */ InitializeObjectAttributes(&ObjectAttributes, &KeyString, @@ -3377,7 +3377,7 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle, Recursing = FALSE; continue; } - + /* Now see if there's more parents to create */ p1 = p + 1; if ((p == pp) || (p1 == pp)) @@ -3386,11 +3386,11 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle, Recursing = FALSE; } } - + /* Outer loop check for handle nesting that requires closing the top handle */ if (NestedCloseLevel > 1) ZwClose(HandleArray[RootHandleIndex]); } - + /* Check if we broke out of the loop due to success */ if (NT_SUCCESS(Status)) { @@ -3398,7 +3398,7 @@ IopCreateRegistryKeyEx(OUT PHANDLE Handle, *Handle = HandleArray[i]; if (Disposition) *Disposition = KeyDisposition; } - + /* Return the success state */ return Status; } @@ -3543,14 +3543,14 @@ PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject) { PDEVICE_NODE DeviceNode; PAGED_CODE(); - + /* Allocate it */ DeviceNode = ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVICE_NODE), 'donD'); if (!DeviceNode) return DeviceNode; - + /* Statistics */ InterlockedIncrement(&IopNumberDeviceNodes); - + /* Set it up */ RtlZeroMemory(DeviceNode, sizeof(DEVICE_NODE)); DeviceNode->InterfaceType = InterfaceTypeUndefined; @@ -3564,7 +3564,7 @@ PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject) InitializeListHead(&DeviceNode->TargetDeviceNotify); InitializeListHead(&DeviceNode->DockInfo.ListEntry); InitializeListHead(&DeviceNode->PendedSetInterfaceState); - + /* Check if there is a PDO */ if (PhysicalDeviceObject) { @@ -3573,7 +3573,7 @@ PipAllocateDeviceNode(IN PDEVICE_OBJECT PhysicalDeviceObject) ((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode = DeviceNode; PhysicalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; } - + /* Return the node */ return DeviceNode; } @@ -3589,7 +3589,7 @@ PnpBusTypeGuidGet(IN USHORT Index, /* Acquire the lock */ ExAcquireFastMutex(&PnpBusTypeGuidList->Lock); - + /* Validate size */ if (Index < PnpBusTypeGuidList->GuidCount) { @@ -3601,7 +3601,7 @@ PnpBusTypeGuidGet(IN USHORT Index, /* Failure path */ Status = STATUS_OBJECT_NAME_NOT_FOUND; } - + /* Release lock and return status */ ExReleaseFastMutex(&PnpBusTypeGuidList->Lock); return Status; @@ -3618,14 +3618,14 @@ PnpDeviceObjectToDeviceInstance(IN PDEVICE_OBJECT DeviceObject, PDEVICE_NODE DeviceNode; UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\ENUM"); PAGED_CODE(); - + /* Open the enum key */ Status = IopOpenRegistryKeyEx(&KeyHandle, NULL, &KeyName, KEY_READ); if (!NT_SUCCESS(Status)) return Status; - + /* Make sure we have an instance path */ DeviceNode = IopGetDeviceNode(DeviceObject); if ((DeviceNode) && (DeviceNode->InstancePath.Length)) @@ -3641,7 +3641,7 @@ PnpDeviceObjectToDeviceInstance(IN PDEVICE_OBJECT DeviceObject, /* Fail */ Status = STATUS_INVALID_DEVICE_REQUEST; } - + /* Close the handle and return status */ ZwClose(KeyHandle); return Status; @@ -3654,13 +3654,13 @@ PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList) ULONG FinalSize, PartialSize, EntrySize, i, j; PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor; PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor; - + /* If we don't have one, that's easy */ if (!ResourceList) return 0; - + /* Start with the minimum size possible */ FinalSize = FIELD_OFFSET(CM_RESOURCE_LIST, List); - + /* Loop each full descriptor */ FullDescriptor = ResourceList->List; for (i = 0; i < ResourceList->Count; i++) @@ -3668,35 +3668,35 @@ PnpDetermineResourceListSize(IN PCM_RESOURCE_LIST ResourceList) /* Start with the minimum size possible */ PartialSize = FIELD_OFFSET(CM_FULL_RESOURCE_DESCRIPTOR, PartialResourceList) + FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors); - + /* Loop each partial descriptor */ PartialDescriptor = FullDescriptor->PartialResourceList.PartialDescriptors; for (j = 0; j < FullDescriptor->PartialResourceList.Count; j++) { /* Start with the minimum size possible */ EntrySize = sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR); - + /* Check if there is extra data */ if (PartialDescriptor->Type == CmResourceTypeDeviceSpecific) { /* Add that data */ EntrySize += PartialDescriptor->u.DeviceSpecificData.DataSize; } - + /* The size of partial descriptors is bigger */ PartialSize += EntrySize; - + /* Go to the next partial descriptor */ PartialDescriptor = (PVOID)((ULONG_PTR)PartialDescriptor + EntrySize); } - + /* The size of full descriptors is bigger */ FinalSize += PartialSize; - + /* Go to the next full descriptor */ FullDescriptor = (PVOID)((ULONG_PTR)FullDescriptor + PartialSize); } - + /* Return the final size */ return FinalSize; } @@ -3829,34 +3829,34 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, /* This is the format of the returned data */ PIP_RETURN_DATA(sizeof(GUID), &BusTypeGuid); - + case DevicePropertyLegacyBusType: - + /* Validate correct interface type */ if (DeviceNode->ChildInterfaceType == InterfaceTypeUndefined) return STATUS_OBJECT_NAME_NOT_FOUND; /* This is the format of the returned data */ PIP_RETURN_DATA(sizeof(INTERFACE_TYPE), &DeviceNode->ChildInterfaceType); - + case DevicePropertyBusNumber: - + /* Validate correct bus number */ if ((DeviceNode->ChildBusNumber & 0x80000000) == 0x80000000) return STATUS_OBJECT_NAME_NOT_FOUND; - + /* This is the format of the returned data */ PIP_RETURN_DATA(sizeof(ULONG), &DeviceNode->ChildBusNumber); - + case DevicePropertyEnumeratorName: /* Get the instance path */ DeviceInstanceName = DeviceNode->InstancePath.Buffer; - + /* Sanity checks */ ASSERT((BufferLength & 1) == 0); ASSERT(DeviceInstanceName != NULL); - + /* Get the name from the path */ EnumeratorNameEnd = wcschr(DeviceInstanceName, OBJ_NAME_PATH_SEPARATOR); ASSERT(EnumeratorNameEnd); @@ -3867,7 +3867,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, /* This is the format of the returned data */ PIP_RETURN_DATA((ULONG)(EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR), DeviceInstanceName); - + case DevicePropertyAddress: /* Query the device caps */ @@ -3877,9 +3877,9 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, /* This is the format of the returned data */ PIP_RETURN_DATA(sizeof(ULONG), &DeviceCaps.Address); - + case DevicePropertyBootConfigurationTranslated: - + /* Validate we have resources */ if (!DeviceNode->BootResources) // if (!DeviceNode->BootResourcesTranslated) // FIXFIX: Need this field @@ -3888,21 +3888,21 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, *ResultLength = 0; return STATUS_SUCCESS; } - + /* This is the format of the returned data */ PIP_RETURN_DATA(PnpDetermineResourceListSize(DeviceNode->BootResources), // FIXFIX: Should use BootResourcesTranslated DeviceNode->BootResources); // FIXFIX: Should use BootResourcesTranslated case DevicePropertyPhysicalDeviceObjectName: - + /* Sanity check for Unicode-sized string */ ASSERT((BufferLength & 1) == 0); - + /* Allocate name buffer */ Length = BufferLength + sizeof(OBJECT_NAME_INFORMATION); ObjectNameInfo = ExAllocatePool(PagedPool, Length); if (!ObjectNameInfo) return STATUS_INSUFFICIENT_RESOURCES; - + /* Query the PDO name */ Status = ObQueryNameString(DeviceObject, ObjectNameInfo, @@ -3924,7 +3924,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, /* Let the caller know how big the name is */ *ResultLength -= sizeof(OBJECT_NAME_INFORMATION); break; - + /* Handle the registry-based properties */ case DevicePropertyUINumber: PIP_REGISTRY_DATA(REGSTR_VAL_UI_NUMBER, REG_DWORD); @@ -3962,13 +3962,13 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, default: return STATUS_INVALID_PARAMETER_2; } - + /* Having a registry value name implies registry data */ if (ValueName) { /* We know up-front how much data to expect */ *ResultLength = BufferLength; - + /* Go get the data, use the LogConf subkey if necessary */ Status = PiGetDeviceRegistryProperty(DeviceObject, ValueType, @@ -3994,7 +3994,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, /* Terminate the string */ ((PWCHAR)PropertyBuffer)[ReturnLength / sizeof(WCHAR)] = UNICODE_NULL; } - + /* This is the success path */ Status = STATUS_SUCCESS; } @@ -4004,7 +4004,7 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, Status = STATUS_BUFFER_TOO_SMALL; } } - + /* Free any allocation we may have made, and return the status code */ if (ObjectNameInfo) ExFreePool(ObjectNameInfo); return Status; @@ -4022,11 +4022,11 @@ IoInvalidateDeviceState(IN PDEVICE_OBJECT PhysicalDeviceObject) ULONG PnPFlags; NTSTATUS Status; IO_STATUS_BLOCK IoStatusBlock; - + RtlZeroMemory(&Stack, sizeof(IO_STACK_LOCATION)); Stack.MajorFunction = IRP_MJ_PNP; Stack.MinorFunction = IRP_MN_QUERY_PNP_DEVICE_STATE; - + Status = IopSynchronousCall(PhysicalDeviceObject, &Stack, (PVOID*)&PnPFlags); if (!NT_SUCCESS(Status)) { @@ -4055,11 +4055,11 @@ IoInvalidateDeviceState(IN PDEVICE_OBJECT PhysicalDeviceObject) /* Send surprise removal */ IopSendSurpriseRemoval(PhysicalDeviceObject); - + /* Tell the user-mode PnP manager that a device was removed */ IopQueueTargetDeviceEvent(&GUID_DEVICE_SURPRISE_REMOVAL, &DeviceNode->InstancePath); - + IopSendRemoveDevice(PhysicalDeviceObject); } else if ((PnPFlags & PNP_DEVICE_FAILED) && (PnPFlags & PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED)) @@ -4074,12 +4074,12 @@ IoInvalidateDeviceState(IN PDEVICE_OBJECT PhysicalDeviceObject) PnPFlags &= ~PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED; } } - + /* Resource rebalance */ if (PnPFlags & PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED) { DPRINT("Sending IRP_MN_QUERY_RESOURCES to device stack\n"); - + Status = IopInitiatePnpIrp(PhysicalDeviceObject, &IoStatusBlock, IRP_MN_QUERY_RESOURCES, @@ -4095,9 +4095,9 @@ IoInvalidateDeviceState(IN PDEVICE_OBJECT PhysicalDeviceObject) DPRINT("IopInitiatePnpIrp() failed (Status %x) or IoStatusBlock.Information=NULL\n", Status); DeviceNode->BootResources = NULL; } - + DPRINT("Sending IRP_MN_QUERY_RESOURCE_REQUIREMENTS to device stack\n"); - + Status = IopInitiatePnpIrp(PhysicalDeviceObject, &IoStatusBlock, IRP_MN_QUERY_RESOURCE_REQUIREMENTS, @@ -4112,7 +4112,7 @@ IoInvalidateDeviceState(IN PDEVICE_OBJECT PhysicalDeviceObject) DPRINT("IopInitiatePnpIrp() failed (Status %08lx)\n", Status); DeviceNode->ResourceRequirements = NULL; } - + /* IRP_MN_FILTER_RESOURCE_REQUIREMENTS is called indirectly by IopStartDevice */ if (IopStartDevice(DeviceNode) != STATUS_SUCCESS) { @@ -4288,28 +4288,28 @@ IopQueryRemoveChildDevices(PDEVICE_NODE ParentDeviceNode, BOOLEAN Force) PDEVICE_NODE ChildDeviceNode, NextDeviceNode, FailedRemoveDevice; NTSTATUS Status; KIRQL OldIrql; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); ChildDeviceNode = ParentDeviceNode->Child; while (ChildDeviceNode != NULL) { NextDeviceNode = ChildDeviceNode->Sibling; KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + Status = IopPrepareDeviceForRemoval(ChildDeviceNode->PhysicalDeviceObject, Force); if (!NT_SUCCESS(Status)) { FailedRemoveDevice = ChildDeviceNode; goto cleanup; } - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); ChildDeviceNode = NextDeviceNode; } KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + return STATUS_SUCCESS; - + cleanup: KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); ChildDeviceNode = ParentDeviceNode->Child; @@ -4317,20 +4317,20 @@ cleanup: { NextDeviceNode = ChildDeviceNode->Sibling; KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + IopCancelPrepareDeviceForRemoval(ChildDeviceNode->PhysicalDeviceObject); - + /* IRP_MN_CANCEL_REMOVE_DEVICE is also sent to the device * that failed the IRP_MN_QUERY_REMOVE_DEVICE request */ if (ChildDeviceNode == FailedRemoveDevice) return Status; - + ChildDeviceNode = NextDeviceNode; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); } KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + return Status; } @@ -4340,18 +4340,18 @@ IopSendRemoveChildDevices(PDEVICE_NODE ParentDeviceNode) { PDEVICE_NODE ChildDeviceNode, NextDeviceNode; KIRQL OldIrql; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); ChildDeviceNode = ParentDeviceNode->Child; while (ChildDeviceNode != NULL) { NextDeviceNode = ChildDeviceNode->Sibling; KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + IopSendRemoveDevice(ChildDeviceNode->PhysicalDeviceObject); - + ChildDeviceNode = NextDeviceNode; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); } KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); @@ -4363,18 +4363,18 @@ IopCancelRemoveChildDevices(PDEVICE_NODE ParentDeviceNode) { PDEVICE_NODE ChildDeviceNode, NextDeviceNode; KIRQL OldIrql; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); ChildDeviceNode = ParentDeviceNode->Child; while (ChildDeviceNode != NULL) { NextDeviceNode = ChildDeviceNode->Sibling; KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); - + IopCancelPrepareDeviceForRemoval(ChildDeviceNode->PhysicalDeviceObject); - + ChildDeviceNode = NextDeviceNode; - + KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql); } KeReleaseSpinLock(&IopDeviceTreeLock, OldIrql); @@ -4386,10 +4386,10 @@ IopQueryRemoveDeviceRelations(PDEVICE_RELATIONS DeviceRelations, BOOLEAN Force) { /* This function DOES NOT dereference the device objects on SUCCESS * but it DOES dereference device objects on FAILURE */ - + ULONG i, j; NTSTATUS Status; - + for (i = 0; i < DeviceRelations->Count; i++) { Status = IopPrepareDeviceForRemoval(DeviceRelations->Objects[i], Force); @@ -4399,9 +4399,9 @@ IopQueryRemoveDeviceRelations(PDEVICE_RELATIONS DeviceRelations, BOOLEAN Force) goto cleanup; } } - + return STATUS_SUCCESS; - + cleanup: /* IRP_MN_CANCEL_REMOVE_DEVICE is also sent to the device * that failed the IRP_MN_QUERY_REMOVE_DEVICE request */ @@ -4417,7 +4417,7 @@ cleanup: DeviceRelations->Objects[i] = NULL; } ExFreePool(DeviceRelations); - + return Status; } @@ -4426,15 +4426,15 @@ VOID IopSendRemoveDeviceRelations(PDEVICE_RELATIONS DeviceRelations) { /* This function DOES dereference the device objects in all cases */ - + ULONG i; - + for (i = 0; i < DeviceRelations->Count; i++) { IopSendRemoveDevice(DeviceRelations->Objects[i]); DeviceRelations->Objects[i] = NULL; } - + ExFreePool(DeviceRelations); } @@ -4443,16 +4443,16 @@ VOID IopCancelRemoveDeviceRelations(PDEVICE_RELATIONS DeviceRelations) { /* This function DOES dereference the device objects in all cases */ - + ULONG i; - + for (i = 0; i < DeviceRelations->Count; i++) { IopCancelPrepareDeviceForRemoval(DeviceRelations->Objects[i]); ObDereferenceObject(DeviceRelations->Objects[i]); DeviceRelations->Objects[i] = NULL; } - + ExFreePool(DeviceRelations); } @@ -4463,11 +4463,11 @@ IopCancelPrepareDeviceForRemoval(PDEVICE_OBJECT DeviceObject) IO_STATUS_BLOCK IoStatusBlock; PDEVICE_RELATIONS DeviceRelations; NTSTATUS Status; - + IopCancelRemoveDevice(DeviceObject); - + Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations; - + Status = IopInitiatePnpIrp(DeviceObject, &IoStatusBlock, IRP_MN_QUERY_DEVICE_RELATIONS, @@ -4481,7 +4481,7 @@ IopCancelPrepareDeviceForRemoval(PDEVICE_OBJECT DeviceObject) { DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information; } - + if (DeviceRelations) IopCancelRemoveDeviceRelations(DeviceRelations); } @@ -4500,16 +4500,16 @@ IopPrepareDeviceForRemoval(IN PDEVICE_OBJECT DeviceObject, BOOLEAN Force) DPRINT1("Removal not allowed for %wZ\n", &DeviceNode->InstancePath); return STATUS_UNSUCCESSFUL; } - + if (!Force && IopQueryRemoveDevice(DeviceObject) != STATUS_SUCCESS) { DPRINT1("Removal vetoed by failing the query remove request\n"); - + IopCancelRemoveDevice(DeviceObject); - + return STATUS_UNSUCCESSFUL; } - + Stack.Parameters.QueryDeviceRelations.Type = RemovalRelations; Status = IopInitiatePnpIrp(DeviceObject, @@ -4544,7 +4544,7 @@ IopPrepareDeviceForRemoval(IN PDEVICE_OBJECT DeviceObject, BOOLEAN Force) if (DeviceRelations) IopSendRemoveDeviceRelations(DeviceRelations); IopSendRemoveChildDevices(DeviceNode); - + return STATUS_SUCCESS; } @@ -4580,17 +4580,17 @@ IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject) IO_STACK_LOCATION Stack; DEVICE_CAPABILITIES Capabilities; NTSTATUS Status; - + IopQueueTargetDeviceEvent(&GUID_DEVICE_KERNEL_INITIATED_EJECT, &DeviceNode->InstancePath); - + if (IopQueryDeviceCapabilities(DeviceNode, &Capabilities) != STATUS_SUCCESS) { goto cleanup; } - + Stack.Parameters.QueryDeviceRelations.Type = EjectionRelations; - + Status = IopInitiatePnpIrp(PhysicalDeviceObject, &IoStatusBlock, IRP_MN_QUERY_DEVICE_RELATIONS, @@ -4604,14 +4604,14 @@ IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject) { DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information; } - + if (DeviceRelations) { Status = IopQueryRemoveDeviceRelations(DeviceRelations, FALSE); if (!NT_SUCCESS(Status)) goto cleanup; } - + Status = IopQueryRemoveChildDevices(DeviceNode, FALSE); if (!NT_SUCCESS(Status)) { @@ -4619,7 +4619,7 @@ IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject) IopCancelRemoveDeviceRelations(DeviceRelations); goto cleanup; } - + if (IopPrepareDeviceForRemoval(PhysicalDeviceObject, FALSE) != STATUS_SUCCESS) { if (DeviceRelations) @@ -4627,7 +4627,7 @@ IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject) IopCancelRemoveChildDevices(DeviceNode); goto cleanup; } - + if (DeviceRelations) IopSendRemoveDeviceRelations(DeviceRelations); IopSendRemoveChildDevices(DeviceNode); @@ -4644,12 +4644,12 @@ IoRequestDeviceEject(IN PDEVICE_OBJECT PhysicalDeviceObject) { DeviceNode->Flags |= DNF_DISABLED; } - + IopQueueTargetDeviceEvent(&GUID_DEVICE_EJECT, &DeviceNode->InstancePath); - + return; - + cleanup: IopQueueTargetDeviceEvent(&GUID_DEVICE_EJECT_VETOED, &DeviceNode->InstancePath); @@ -4699,7 +4699,7 @@ IoSynchronousInvalidateDeviceRelations( IN DEVICE_RELATION_TYPE Type) { PAGED_CODE(); - + switch (Type) { case BusRelations: diff --git a/ntoskrnl/io/pnpmgr/pnpreport.c b/ntoskrnl/io/pnpmgr/pnpreport.c index 8b919a124b7..206fccfa251 100644 --- a/ntoskrnl/io/pnpmgr/pnpreport.c +++ b/ntoskrnl/io/pnpmgr/pnpreport.c @@ -231,7 +231,7 @@ IoReportDetectedDevice(IN PDRIVER_OBJECT DriverObject, /* We're enumerated already */ IopDeviceNodeSetFlag(DeviceNode, DNF_ENUMERATED); - + /* We don't call AddDevice for devices reported this way */ IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED); diff --git a/ntoskrnl/io/pnpmgr/pnpres.c b/ntoskrnl/io/pnpmgr/pnpres.c index c272b0a4987..42e6cfede49 100644 --- a/ntoskrnl/io/pnpmgr/pnpres.c +++ b/ntoskrnl/io/pnpmgr/pnpres.c @@ -115,7 +115,7 @@ IopFindPortResource( ASSERT(IoDesc->Type == CmDesc->Type); ASSERT(IoDesc->Type == CmResourceTypePort); - + /* HACK */ if (IoDesc->u.Port.Alignment == 0) IoDesc->u.Port.Alignment = 1; @@ -251,7 +251,7 @@ IopFixupResourceListWithRequirements( PCM_PARTIAL_RESOURCE_LIST PartialList = (*ResourceList) ? &(*ResourceList)->List[0].PartialResourceList : NULL; PIO_RESOURCE_DESCRIPTOR IoDesc = &ResList->Descriptors[ii]; BOOLEAN Matched = FALSE; - + /* Skip alternates if we don't need one */ if (!AlternateRequired && (IoDesc->Option & IO_RESOURCE_ALTERNATIVE)) { @@ -386,7 +386,7 @@ IopFixupResourceListWithRequirements( FoundResource = FALSE; } break; - + case CmResourceTypePort: /* Find an available port range */ if (!IopFindPortResource(IoDesc, &NewDesc)) @@ -398,7 +398,7 @@ IopFixupResourceListWithRequirements( FoundResource = FALSE; } break; - + case CmResourceTypeMemory: /* Find an available memory range */ if (!IopFindMemoryResource(IoDesc, &NewDesc)) @@ -410,7 +410,7 @@ IopFixupResourceListWithRequirements( FoundResource = FALSE; } break; - + case CmResourceTypeBusNumber: /* Find an available bus address range */ if (!IopFindBusNumberResource(IoDesc, &NewDesc)) @@ -422,7 +422,7 @@ IopFixupResourceListWithRequirements( FoundResource = FALSE; } break; - + case CmResourceTypeDma: /* Find an available DMA channel */ if (!IopFindDmaResource(IoDesc, &NewDesc)) @@ -433,7 +433,7 @@ IopFixupResourceListWithRequirements( FoundResource = FALSE; } break; - + default: DPRINT1("Unsupported resource type: %x\n", IoDesc->Type); FoundResource = FALSE; @@ -825,7 +825,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2 ULONG OldLength = 0; ASSERT(DeviceNode->ResourceListTranslated); - + RtlInitUnicodeString(&TranslatedSuffix, L".Translated"); RtlInitUnicodeString(&RawSuffix, L".Raw"); @@ -837,17 +837,17 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2 if (Status == STATUS_BUFFER_OVERFLOW || Status == STATUS_BUFFER_TOO_SMALL) { ASSERT(OldLength); - + NameU.Buffer = ExAllocatePool(PagedPool, OldLength + TranslatedSuffix.Length); if (!NameU.Buffer) { ZwClose(PnpMgrLevel2); return STATUS_INSUFFICIENT_RESOURCES; } - + NameU.Length = 0; NameU.MaximumLength = (USHORT)OldLength + TranslatedSuffix.Length; - + Status = IoGetDeviceProperty(DeviceNode->PhysicalDeviceObject, DevicePropertyPhysicalDeviceObjectName, NameU.MaximumLength, @@ -871,7 +871,7 @@ IopUpdateResourceMap(IN PDEVICE_NODE DeviceNode, PWCHAR Level1Key, PWCHAR Level2 /* This should never happen */ ASSERT(FALSE); } - + NameU.Length = (USHORT)OldLength; RtlAppendUnicodeStringToString(&NameU, &RawSuffix); @@ -972,12 +972,12 @@ IopTranslateDeviceResources( DPRINT1("Failed to translate port resource (Start: 0x%I64x)\n", DescriptorRaw->u.Port.Start.QuadPart); goto cleanup; } - + if (AddressSpace == 0) { DPRINT1("Guessed incorrect address space: 1 -> 0\n"); - /* FIXME: I think all other CM_RESOURCE_PORT_XXX flags are + /* FIXME: I think all other CM_RESOURCE_PORT_XXX flags are * invalid for this state but I'm not 100% sure */ DescriptorRaw->Flags = DescriptorTranslated->Flags = CM_RESOURCE_PORT_MEMORY; @@ -993,7 +993,7 @@ IopTranslateDeviceResources( DescriptorRaw->u.Interrupt.Vector, (PKIRQL)&DescriptorTranslated->u.Interrupt.Level, &DescriptorTranslated->u.Interrupt.Affinity); - + if (!DescriptorTranslated->u.Interrupt.Vector) { Status = STATUS_UNSUCCESSFUL; diff --git a/ntoskrnl/io/pnpmgr/pnputil.c b/ntoskrnl/io/pnpmgr/pnputil.c index bdb24047b0c..3ed75b2c071 100644 --- a/ntoskrnl/io/pnpmgr/pnputil.c +++ b/ntoskrnl/io/pnpmgr/pnputil.c @@ -22,7 +22,7 @@ PnpFreeUnicodeStringList(IN PUNICODE_STRING UnicodeStringList, IN ULONG StringCount) { ULONG i; - + /* Go through the list */ if (UnicodeStringList) { @@ -36,7 +36,7 @@ PnpFreeUnicodeStringList(IN PUNICODE_STRING UnicodeStringList, ExFreePool(UnicodeStringList[i].Buffer); } } - + /* Free the whole list */ ExFreePool(UnicodeStringList); } @@ -52,15 +52,15 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation ULONG i = 0; SIZE_T n; ULONG Count = 0; - + /* Validate the key information */ if (KeyValueInformation->Type != REG_MULTI_SZ) return STATUS_INVALID_PARAMETER; - + /* Set the pointers */ p = (PWCHAR)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); pp = (PWCHAR)((ULONG_PTR)p + KeyValueInformation->DataLength); - + /* Loop the data */ while (p != pp) { @@ -69,28 +69,28 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation { /* Add to our string count */ Count++; - + /* Check for a double-NULL, which means we're done */ if (((p + 1) == pp) || !(*(p + 1))) break; } - + /* Go to the next character */ p++; } /* If we looped the whole list over, we missed increment a string, do it */ if (p == pp) Count++; - + /* Allocate the list now that we know how big it is */ *UnicodeStringList = ExAllocatePoolWithTag(PagedPool, sizeof(UNICODE_STRING) * Count, 'sUpP'); if (!(*UnicodeStringList)) return STATUS_INSUFFICIENT_RESOURCES; - + /* Set pointers for second loop */ ps = p = (PWCHAR)((ULONG_PTR)KeyValueInformation + KeyValueInformation->DataOffset); - + /* Loop again, to do the copy this time */ while (p != pp) { @@ -99,7 +99,7 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation { /* Check how long this string is */ n = (ULONG_PTR)p - (ULONG_PTR)ps + sizeof(UNICODE_NULL); - + /* Allocate the buffer */ (*UnicodeStringList)[i].Buffer = ExAllocatePoolWithTag(PagedPool, n, @@ -110,34 +110,34 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation PnpFreeUnicodeStringList(*UnicodeStringList, i); return STATUS_INSUFFICIENT_RESOURCES; } - + /* Copy the string into the buffer */ RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n); - + /* Set the lengths */ (*UnicodeStringList)[i].MaximumLength = (USHORT)n; (*UnicodeStringList)[i].Length = (USHORT)(n - sizeof(UNICODE_NULL)); - + /* One more entry done */ i++; - + /* Check for a double-NULL, which means we're done */ if (((p + 1) == pp) || !(*(p + 1))) break; /* New string */ ps = p + 1; } - + /* New string */ p++; } - + /* Check if we've reached the last string */ if (p == pp) { /* Calculate the string length */ n = (ULONG_PTR)p - (ULONG_PTR)ps; - + /* Allocate the buffer for it */ (*UnicodeStringList)[i].Buffer = ExAllocatePoolWithTag(PagedPool, n + @@ -149,18 +149,18 @@ PnpRegMultiSzToUnicodeStrings(IN PKEY_VALUE_FULL_INFORMATION KeyValueInformation PnpFreeUnicodeStringList(*UnicodeStringList, i); return STATUS_INSUFFICIENT_RESOURCES; } - + /* Make sure there's an actual string here */ if (n) RtlCopyMemory((*UnicodeStringList)[i].Buffer, ps, n); /* Null-terminate the string ourselves */ (*UnicodeStringList)[i].Buffer[n / sizeof(WCHAR)] = UNICODE_NULL; - + /* Set the lengths */ (*UnicodeStringList)[i].Length = (USHORT)n; (*UnicodeStringList)[i].MaximumLength = (USHORT)(n + sizeof(UNICODE_NULL)); } - + /* And we're done */ *UnicodeStringCount = Count; return STATUS_SUCCESS; @@ -173,11 +173,11 @@ PnpRegSzToString(IN PWCHAR RegSzData, OUT PUSHORT StringLength OPTIONAL) { PWCHAR p, pp; - + /* Find the end */ pp = RegSzData + RegSzLength; for (p = RegSzData; p < pp; p++) if (!*p) break; - + /* Return it */ if (StringLength) *StringLength = (USHORT)(p - RegSzData) * sizeof(WCHAR); return TRUE; diff --git a/subsystems/ntvdm/emulator.c b/subsystems/ntvdm/emulator.c index ffb881ec5ad..b8a43b6aeae 100644 --- a/subsystems/ntvdm/emulator.c +++ b/subsystems/ntvdm/emulator.c @@ -273,12 +273,12 @@ static VOID WINAPI EmulatorDebugBreakBop(LPWORD Stack) DebugBreak(); } -static BYTE WINAPI Port61hRead(ULONG Port) +static BYTE WINAPI Port61hRead(USHORT Port) { return Port61hState; } -static VOID WINAPI Port61hWrite(ULONG Port, BYTE Data) +static VOID WINAPI Port61hWrite(USHORT Port, BYTE Data) { // BOOLEAN SpeakerStateChange = FALSE; BYTE OldPort61hState = Port61hState; diff --git a/subsystems/ntvdm/hardware/cmos.c b/subsystems/ntvdm/hardware/cmos.c index 72393681ded..7ae7cf34e27 100644 --- a/subsystems/ntvdm/hardware/cmos.c +++ b/subsystems/ntvdm/hardware/cmos.c @@ -342,13 +342,13 @@ VOID CmosWriteData(BYTE Value) SelectedRegister = CMOS_REG_STATUS_D; } -BYTE WINAPI CmosReadPort(ULONG Port) +BYTE WINAPI CmosReadPort(USHORT Port) { ASSERT(Port == CMOS_DATA_PORT); return CmosReadData(); } -VOID WINAPI CmosWritePort(ULONG Port, BYTE Data) +VOID WINAPI CmosWritePort(USHORT Port, BYTE Data) { if (Port == CMOS_ADDRESS_PORT) CmosWriteAddress(Data); diff --git a/subsystems/ntvdm/hardware/pic.c b/subsystems/ntvdm/hardware/pic.c index 5c705ca5827..b5de2b407c2 100644 --- a/subsystems/ntvdm/hardware/pic.c +++ b/subsystems/ntvdm/hardware/pic.c @@ -154,7 +154,7 @@ static VOID PicWriteData(BYTE Port, BYTE Value) Pic->Initialization = FALSE; } -static BYTE WINAPI PicReadPort(ULONG Port) +static BYTE WINAPI PicReadPort(USHORT Port) { switch (Port) { @@ -174,7 +174,7 @@ static BYTE WINAPI PicReadPort(ULONG Port) return 0; } -static VOID WINAPI PicWritePort(ULONG Port, BYTE Data) +static VOID WINAPI PicWritePort(USHORT Port, BYTE Data) { switch (Port) { diff --git a/subsystems/ntvdm/hardware/ps2.c b/subsystems/ntvdm/hardware/ps2.c index d354c6081c9..bfede556a03 100644 --- a/subsystems/ntvdm/hardware/ps2.c +++ b/subsystems/ntvdm/hardware/ps2.c @@ -59,7 +59,7 @@ static VOID PS2SendCommand(PPS2_PORT Port, BYTE Command) if (Port->DeviceCommand) Port->DeviceCommand(Port->Param, Command); } -static BYTE WINAPI PS2ReadPort(ULONG Port) +static BYTE WINAPI PS2ReadPort(USHORT Port) { if (Port == PS2_CONTROL_PORT) { @@ -87,7 +87,7 @@ static BYTE WINAPI PS2ReadPort(ULONG Port) return 0; } -static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data) +static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data) { if (Port == PS2_CONTROL_PORT) { diff --git a/subsystems/ntvdm/hardware/timer.c b/subsystems/ntvdm/hardware/timer.c index dcf1f34030b..44c07943880 100644 --- a/subsystems/ntvdm/hardware/timer.c +++ b/subsystems/ntvdm/hardware/timer.c @@ -275,7 +275,7 @@ static VOID PitWriteData(BYTE Channel, BYTE Value) } } -static BYTE WINAPI PitReadPort(ULONG Port) +static BYTE WINAPI PitReadPort(USHORT Port) { switch (Port) { @@ -290,7 +290,7 @@ static BYTE WINAPI PitReadPort(ULONG Port) return 0; } -static VOID WINAPI PitWritePort(ULONG Port, BYTE Data) +static VOID WINAPI PitWritePort(USHORT Port, BYTE Data) { switch (Port) { diff --git a/subsystems/ntvdm/hardware/vga.c b/subsystems/ntvdm/hardware/vga.c index 1e33af5938a..f2d34639720 100644 --- a/subsystems/ntvdm/hardware/vga.c +++ b/subsystems/ntvdm/hardware/vga.c @@ -1462,7 +1462,7 @@ static VOID VgaUpdateTextCursor(VOID) CursorMoved = FALSE; } -static BYTE WINAPI VgaReadPort(ULONG Port) +static BYTE WINAPI VgaReadPort(USHORT Port) { DPRINT("VgaReadPort: Port 0x%X\n", Port); @@ -1554,7 +1554,7 @@ static BYTE WINAPI VgaReadPort(ULONG Port) return 0; } -static VOID WINAPI VgaWritePort(ULONG Port, BYTE Data) +static VOID WINAPI VgaWritePort(USHORT Port, BYTE Data) { DPRINT("VgaWritePort: Port 0x%X, Data 0x%02X\n", Port, Data); diff --git a/subsystems/ntvdm/io.c b/subsystems/ntvdm/io.c index 92e5e3c6ff5..53ff8dca14b 100644 --- a/subsystems/ntvdm/io.c +++ b/subsystems/ntvdm/io.c @@ -58,7 +58,7 @@ EMULATOR_IOPORT_HANDLERS IoPortProc[EMULATOR_MAX_IOPORTS_NUM] = {{NULL}}; /* PUBLIC FUNCTIONS ***********************************************************/ UCHAR -IOReadB(ULONG Port) +IOReadB(USHORT Port) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && IoPortProc[Port].IoHandlers.InB) @@ -82,7 +82,7 @@ IOReadB(ULONG Port) } VOID -IOReadStrB(ULONG Port, +IOReadStrB(USHORT Port, PUCHAR Buffer, ULONG Count) { @@ -105,7 +105,7 @@ IOReadStrB(ULONG Port, } VOID -IOWriteB(ULONG Port, +IOWriteB(USHORT Port, UCHAR Buffer) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && @@ -127,7 +127,7 @@ IOWriteB(ULONG Port, } VOID -IOWriteStrB(ULONG Port, +IOWriteStrB(USHORT Port, PUCHAR Buffer, ULONG Count) { @@ -150,7 +150,7 @@ IOWriteStrB(ULONG Port, } USHORT -IOReadW(ULONG Port) +IOReadW(USHORT Port) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && IoPortProc[Port].IoHandlers.InW) @@ -177,7 +177,7 @@ IOReadW(ULONG Port) } VOID -IOReadStrW(ULONG Port, +IOReadStrW(USHORT Port, PUSHORT Buffer, ULONG Count) { @@ -200,7 +200,7 @@ IOReadStrW(ULONG Port, } VOID -IOWriteW(ULONG Port, +IOWriteW(USHORT Port, USHORT Buffer) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && @@ -223,7 +223,7 @@ IOWriteW(ULONG Port, } VOID -IOWriteStrW(ULONG Port, +IOWriteStrW(USHORT Port, PUSHORT Buffer, ULONG Count) { @@ -246,7 +246,7 @@ IOWriteStrW(ULONG Port, } ULONG -IOReadD(ULONG Port) +IOReadD(USHORT Port) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && IoPortProc[Port].IoHandlers.InD) @@ -265,7 +265,7 @@ IOReadD(ULONG Port) } VOID -IOReadStrD(ULONG Port, +IOReadStrD(USHORT Port, PULONG Buffer, ULONG Count) { @@ -281,7 +281,7 @@ IOReadStrD(ULONG Port, } VOID -IOWriteD(ULONG Port, +IOWriteD(USHORT Port, ULONG Buffer) { if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE && @@ -298,7 +298,7 @@ IOWriteD(ULONG Port, } VOID -IOWriteStrD(ULONG Port, +IOWriteStrD(USHORT Port, PULONG Buffer, ULONG Count) { @@ -314,7 +314,7 @@ IOWriteStrD(ULONG Port, } -VOID RegisterIoPort(ULONG Port, +VOID RegisterIoPort(USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler) { @@ -332,7 +332,7 @@ VOID RegisterIoPort(ULONG Port, IoPortProc[Port].hVdd = INVALID_HANDLE_VALUE; } -VOID UnregisterIoPort(ULONG Port) +VOID UnregisterIoPort(USHORT Port) { /* * Put automagically all the fields to zero: @@ -344,7 +344,7 @@ VOID UnregisterIoPort(ULONG Port) VOID WINAPI EmulatorReadIo(PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) @@ -419,7 +419,7 @@ EmulatorReadIo(PFAST486_STATE State, VOID WINAPI EmulatorWriteIo(PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize) diff --git a/subsystems/ntvdm/io.h b/subsystems/ntvdm/io.h index 9ed80ec794b..d1bde389099 100644 --- a/subsystems/ntvdm/io.h +++ b/subsystems/ntvdm/io.h @@ -16,79 +16,79 @@ /* FUNCTIONS ******************************************************************/ -typedef UCHAR (WINAPI *EMULATOR_INB_PROC)(ULONG Port); -typedef USHORT (WINAPI *EMULATOR_INW_PROC)(ULONG Port); -typedef ULONG (WINAPI *EMULATOR_IND_PROC)(ULONG Port); +typedef UCHAR (WINAPI *EMULATOR_INB_PROC)(USHORT Port); +typedef USHORT (WINAPI *EMULATOR_INW_PROC)(USHORT Port); +typedef ULONG (WINAPI *EMULATOR_IND_PROC)(USHORT Port); -typedef VOID (WINAPI *EMULATOR_INSB_PROC)(ULONG Port, PUCHAR Buffer, ULONG Count); -typedef VOID (WINAPI *EMULATOR_INSW_PROC)(ULONG Port, PUSHORT Buffer, ULONG Count); -typedef VOID (WINAPI *EMULATOR_INSD_PROC)(ULONG Port, PULONG Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_INSB_PROC)(USHORT Port, PUCHAR Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_INSW_PROC)(USHORT Port, PUSHORT Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_INSD_PROC)(USHORT Port, PULONG Buffer, ULONG Count); -typedef VOID (WINAPI *EMULATOR_OUTB_PROC)(ULONG Port, UCHAR Data); -typedef VOID (WINAPI *EMULATOR_OUTW_PROC)(ULONG Port, USHORT Data); -typedef VOID (WINAPI *EMULATOR_OUTD_PROC)(ULONG Port, ULONG Data); +typedef VOID (WINAPI *EMULATOR_OUTB_PROC)(USHORT Port, UCHAR Data); +typedef VOID (WINAPI *EMULATOR_OUTW_PROC)(USHORT Port, USHORT Data); +typedef VOID (WINAPI *EMULATOR_OUTD_PROC)(USHORT Port, ULONG Data); -typedef VOID (WINAPI *EMULATOR_OUTSB_PROC)(ULONG Port, PUCHAR Buffer, ULONG Count); -typedef VOID (WINAPI *EMULATOR_OUTSW_PROC)(ULONG Port, PUSHORT Buffer, ULONG Count); -typedef VOID (WINAPI *EMULATOR_OUTSD_PROC)(ULONG Port, PULONG Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_OUTSB_PROC)(USHORT Port, PUCHAR Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_OUTSW_PROC)(USHORT Port, PUSHORT Buffer, ULONG Count); +typedef VOID (WINAPI *EMULATOR_OUTSD_PROC)(USHORT Port, PULONG Buffer, ULONG Count); UCHAR -IOReadB(ULONG Port); +IOReadB(USHORT Port); VOID -IOReadStrB(ULONG Port, +IOReadStrB(USHORT Port, PUCHAR Buffer, ULONG Count); VOID -IOWriteB(ULONG Port, +IOWriteB(USHORT Port, UCHAR Buffer); VOID -IOWriteStrB(ULONG Port, +IOWriteStrB(USHORT Port, PUCHAR Buffer, ULONG Count); USHORT -IOReadW(ULONG Port); +IOReadW(USHORT Port); VOID -IOReadStrW(ULONG Port, +IOReadStrW(USHORT Port, PUSHORT Buffer, ULONG Count); VOID -IOWriteW(ULONG Port, +IOWriteW(USHORT Port, USHORT Buffer); VOID -IOWriteStrW(ULONG Port, +IOWriteStrW(USHORT Port, PUSHORT Buffer, ULONG Count); ULONG -IOReadD(ULONG Port); +IOReadD(USHORT Port); VOID -IOReadStrD(ULONG Port, +IOReadStrD(USHORT Port, PULONG Buffer, ULONG Count); VOID -IOWriteD(ULONG Port, +IOWriteD(USHORT Port, ULONG Buffer); VOID -IOWriteStrD(ULONG Port, +IOWriteStrD(USHORT Port, PULONG Buffer, ULONG Count); -VOID RegisterIoPort(ULONG Port, +VOID RegisterIoPort(USHORT Port, EMULATOR_INB_PROC InHandler, EMULATOR_OUTB_PROC OutHandler); -VOID UnregisterIoPort(ULONG Port); +VOID UnregisterIoPort(USHORT Port); VOID WINAPI EmulatorReadIo ( PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize @@ -97,7 +97,7 @@ VOID WINAPI EmulatorReadIo VOID WINAPI EmulatorWriteIo ( PFAST486_STATE State, - ULONG Port, + USHORT Port, PVOID Buffer, ULONG DataCount, UCHAR DataSize diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt index 361e9db7633..e5bfa1d41eb 100644 --- a/win32ss/CMakeLists.txt +++ b/win32ss/CMakeLists.txt @@ -1,6 +1,6 @@ set(USE_DIBLIB FALSE) -set(USE_NEW_CURSORICON FALSE) +set(USE_NEW_CURSORICON TRUE) # Give WIN32 subsystem its own project. PROJECT(WIN32SS) diff --git a/win32ss/user/ntuser/class.c b/win32ss/user/ntuser/class.c index dd95752e04f..98e6b1a12d3 100644 --- a/win32ss/user/ntuser/class.c +++ b/win32ss/user/ntuser/class.c @@ -248,10 +248,10 @@ IntDestroyClass(IN OUT PCLS Class) #ifdef NEW_CURSORICON if (Class->spicn) UserDereferenceObject(Class->spicn); - if (Class->spicnSm) - UserDereferenceObject(Class->spicnSm); if (Class->spcur) UserDereferenceObject(Class->spcur); + if (Class->spicnSm) + UserDereferenceObject(Class->spicnSm); #else if (Class->hIconSmIntern) IntClassDestroyIcon(Class->hIconSmIntern); @@ -838,6 +838,16 @@ IntMoveClassToSharedHeap(IN OUT PCLS Class, NewClass->rpdeskParent = NULL; NewClass->pclsBase = NewClass; +#ifdef NEW_CURSORICON + if (NewClass->spcur) + UserReferenceObject(NewClass->spcur); + if (NewClass->spicn) + UserReferenceObject(NewClass->spicn); + if (NewClass->spicnSm) + UserReferenceObject(NewClass->spicnSm); +#endif + + /* Replace the class in the list */ (void)InterlockedExchangePointer((PVOID*)*ClassLinkPtr, NewClass); @@ -1966,18 +1976,31 @@ UserSetClassLongPtr(IN PCLS Class, if (NewLong && !Class->spicnSm) { /* Create the new small icon from the new large(?) one */ - HICON SmallIconHandle = co_IntCopyImage( - (HICON)NewLong, - IMAGE_ICON, - UserGetSystemMetrics( SM_CXSMICON ), - UserGetSystemMetrics( SM_CYSMICON ), - 0); + HICON SmallIconHandle = NULL; + if((NewIcon->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE)) + == (CURSORF_LRSHARED | CURSORF_FROMRESOURCE)) + { + SmallIconHandle = co_IntCopyImage( + (HICON)NewLong, + IMAGE_ICON, + UserGetSystemMetrics( SM_CXSMICON ), + UserGetSystemMetrics( SM_CYSMICON ), + LR_COPYFROMRESOURCE | LR_SHARED); + } + if (!SmallIconHandle) + { + /* Retry without copying from resource */ + SmallIconHandle = co_IntCopyImage( + (HICON)NewLong, + IMAGE_ICON, + UserGetSystemMetrics( SM_CXSMICON ), + UserGetSystemMetrics( SM_CYSMICON ), + LR_SHARED); + } if (SmallIconHandle) { /* So use it */ NewSmallIcon = Class->spicnSm = UserGetCurIconObject(SmallIconHandle); - /* Let the handle go, we have the reference on the object */ - NtUserDestroyCursor(SmallIconHandle, FALSE); Class->CSF_flags |= CSF_CACHEDSMICON; } } diff --git a/win32ss/user/ntuser/cursoricon_new.c b/win32ss/user/ntuser/cursoricon_new.c index 436021715a8..2fbfe99fb60 100644 --- a/win32ss/user/ntuser/cursoricon_new.c +++ b/win32ss/user/ntuser/cursoricon_new.c @@ -63,9 +63,9 @@ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon) return NULL; } - if(UserObjectInDestroy(hCurIcon)) + if (UserObjectInDestroy(hCurIcon)) { - ERR("Requesting destroyed cursor.\n"); + WARN("Requesting invalid/destroyed cursor.\n"); EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); return NULL; } @@ -155,6 +155,36 @@ IntDestroyCurIconObject( { PCURICON_OBJECT CurIcon = Object; + /* Try finding it in its process cache */ + if (CurIcon->CURSORF_flags & CURSORF_LRSHARED) + { + PPROCESSINFO ppi; + + ppi = CurIcon->head.ppi; + if (ppi->pCursorCache == CurIcon) + { + ppi->pCursorCache = CurIcon->pcurNext; + UserDereferenceObject(CurIcon); + } + else + { + PCURICON_OBJECT CacheCurIcon = ppi->pCursorCache; + while (CacheCurIcon) + { + if (CacheCurIcon->pcurNext == CurIcon) + { + CacheCurIcon->pcurNext = CurIcon->pcurNext; + break; + } + CacheCurIcon = CacheCurIcon->pcurNext; + } + + /* We must have found it! */ + ASSERT(CacheCurIcon != NULL); + UserDereferenceObject(CurIcon); + } + } + /* We just mark the handle as being destroyed. * Deleting all the stuff will be deferred to the actual struct free. */ return UserDeleteObject(CurIcon->head.h, TYPE_CURSOR); @@ -204,32 +234,12 @@ FreeCurIconObject( if (CurIcon->CURSORF_flags & CURSORF_LRSHARED) { - PPROCESSINFO ppi; - if (!IS_INTRESOURCE(CurIcon->strName.Buffer)) ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING); if (CurIcon->atomModName) RtlDeleteAtomFromAtomTable(gAtomTable, CurIcon->atomModName); CurIcon->strName.Buffer = NULL; CurIcon->atomModName = 0; - - /* Try finding it in its process cache */ - ppi = CurIcon->head.ppi; - if (ppi->pCursorCache == CurIcon) - ppi->pCursorCache = CurIcon->pcurNext; - else - { - PCURICON_OBJECT CacheCurIcon= ppi->pCursorCache; - while (CacheCurIcon) - { - if (CacheCurIcon->pcurNext == CurIcon) - { - CacheCurIcon->pcurNext = CurIcon->pcurNext; - break; - } - CacheCurIcon = CacheCurIcon->pcurNext; - } - } } /* Finally free the thing */ @@ -634,40 +644,36 @@ NtUserDestroyCursor( _In_ BOOL bForce) { BOOL ret; + PCURICON_OBJECT CurIcon = NULL; - TRACE("Enter NtUserDestroyCursorIcon\n"); + TRACE("Enter NtUserDestroyCursorIcon (%p, %u)\n", hCurIcon, bForce); UserEnterExclusive(); + CurIcon = UserGetCurIconObject(hCurIcon); + if (!CurIcon) + { + ret = FALSE; + goto leave; + } + if (!bForce) { /* Maybe we have good reasons not to destroy this object */ - PCURICON_OBJECT CurIcon = UserGetCurIconObject(hCurIcon); - ULONG Flags; - if (!CurIcon) - { - ret = FALSE; - goto leave; - } - if (CurIcon->head.ppi != PsGetCurrentProcessWin32Process()) { /* No way, you're not touching my cursor */ ret = FALSE; - UserDereferenceObject(CurIcon); goto leave; } - Flags = CurIcon->CURSORF_flags; - UserDereferenceObject(CurIcon); - - if (Flags & CURSORF_CURRENT) + if (CurIcon->CURSORF_flags & CURSORF_CURRENT) { WARN("Trying to delete current cursor!\n"); ret = FALSE; goto leave; } - if (Flags & CURSORF_LRSHARED) + if (CurIcon->CURSORF_flags & CURSORF_LRSHARED) { WARN("Trying to delete shared cursor.\n"); /* This one is not an error */ @@ -677,9 +683,11 @@ NtUserDestroyCursor( } /* Destroy the handle */ - ret = UserDeleteObject(hCurIcon, TYPE_CURSOR); + ret = IntDestroyCurIconObject(CurIcon); leave: + if (CurIcon) + UserDereferenceObject(CurIcon); TRACE("Leave NtUserDestroyCursorIcon, ret=%i\n", ret); UserLeave(); return ret; @@ -842,7 +850,7 @@ NtUserSetCursor( PCURICON_OBJECT pcurOld, pcurNew; HCURSOR hOldCursor = NULL; - TRACE("Enter NtUserSetCursor\n"); + TRACE("Enter NtUserSetCursor: %p\n", hCursor); UserEnterExclusive(); if (hCursor) @@ -863,6 +871,10 @@ NtUserSetCursor( pcurOld = UserSetCursor(pcurNew, FALSE); if (pcurOld) { + hOldCursor = pcurOld->head.h; + /* See if it was destroyed in the meantime */ + if (UserObjectInDestroy(hOldCursor)) + hOldCursor = NULL; pcurOld->CURSORF_flags &= ~CURSORF_CURRENT; UserDereferenceObject(pcurOld); } diff --git a/win32ss/user/ntuser/keyboard.c b/win32ss/user/ntuser/keyboard.c index 28ac361b63d..705f4ff6434 100644 --- a/win32ss/user/ntuser/keyboard.c +++ b/win32ss/user/ntuser/keyboard.c @@ -61,7 +61,7 @@ IntKeyboardGetIndicatorTrans(HANDLE hKeyboardDevice, while (pRet) { - Status = NtDeviceIoControlFile(hKeyboardDevice, + Status = ZwDeviceIoControlFile(hKeyboardDevice, NULL, NULL, NULL, @@ -104,8 +104,7 @@ static NTSTATUS APIENTRY IntKeyboardUpdateLeds(HANDLE hKeyboardDevice, WORD wVk, - WORD wScanCode, - BOOL bEnabled) + WORD wScanCode) { NTSTATUS Status; UINT i; @@ -133,13 +132,10 @@ IntKeyboardUpdateLeds(HANDLE hKeyboardDevice, if (LedFlag) { - if (bEnabled) - gIndicators.LedFlags |= LedFlag; - else - gIndicators.LedFlags = ~LedFlag; + gIndicators.LedFlags ^= LedFlag; /* Update the lights on the hardware */ - Status = NtDeviceIoControlFile(hKeyboardDevice, + Status = ZwDeviceIoControlFile(hKeyboardDevice, NULL, NULL, NULL, @@ -164,10 +160,10 @@ UserInitKeyboard(HANDLE hKeyboardDevice) { NTSTATUS Status; IO_STATUS_BLOCK Block; -/* + IntKeyboardGetIndicatorTrans(hKeyboardDevice, &gpKeyboardIndicatorTrans); - Status = NtDeviceIoControlFile(hKeyboardDevice, + Status = ZwDeviceIoControlFile(hKeyboardDevice, NULL, NULL, NULL, @@ -186,9 +182,9 @@ UserInitKeyboard(HANDLE hKeyboardDevice) gIndicators.LedFlags & KEYBOARD_NUM_LOCK_ON); SET_KEY_LOCKED(gafAsyncKeyState, VK_SCROLL, gIndicators.LedFlags & KEYBOARD_SCROLL_LOCK_ON); -*/ + // FIXME: Need device driver to work! HID support more than one!!!! - Status = NtDeviceIoControlFile(hKeyboardDevice, + Status = ZwDeviceIoControlFile(hKeyboardDevice, NULL, NULL, NULL, @@ -808,8 +804,7 @@ ProcessKeyEvent(WORD wVk, WORD wScanCode, DWORD dwFlags, BOOL bInjected, DWORD d /* Update keyboard LEDs */ IntKeyboardUpdateLeds(ghKeyboardDevice, wSimpleVk, - wScanCode, - IS_KEY_LOCKED(gafAsyncKeyState, wSimpleVk)); + wScanCode); } /* Call WH_KEYBOARD_LL hook */ diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c index 5c5363cf277..b04f6bad059 100644 --- a/win32ss/user/ntuser/window.c +++ b/win32ss/user/ntuser/window.c @@ -1677,17 +1677,31 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, #ifdef NEW_CURSORICON if (Class->spicn && !Class->spicnSm) { - HICON IconSmHandle = co_IntCopyImage( - UserHMGetHandle(Class->spicn), - IMAGE_ICON, - UserGetSystemMetrics( SM_CXSMICON ), - UserGetSystemMetrics( SM_CYSMICON ), - 0); + HICON IconSmHandle = NULL; + if((Class->spicn->CURSORF_flags & (CURSORF_LRSHARED | CURSORF_FROMRESOURCE)) + == (CURSORF_LRSHARED | CURSORF_FROMRESOURCE)) + { + IconSmHandle = co_IntCopyImage( + UserHMGetHandle(Class->spicn), + IMAGE_ICON, + UserGetSystemMetrics( SM_CXSMICON ), + UserGetSystemMetrics( SM_CYSMICON ), + LR_COPYFROMRESOURCE | LR_SHARED); + } + if (!IconSmHandle) + { + /* Retry without copying from resource */ + IconSmHandle = co_IntCopyImage( + UserHMGetHandle(Class->spicn), + IMAGE_ICON, + UserGetSystemMetrics( SM_CXSMICON ), + UserGetSystemMetrics( SM_CYSMICON ), + LR_SHARED); + } + if (IconSmHandle) { Class->spicnSm = UserGetCurIconObject(IconSmHandle); - /* We can delete the handle, only the pointer is of interest */ - NtUserDestroyCursor(IconSmHandle, FALSE); Class->CSF_flags |= CSF_CACHEDSMICON; } } diff --git a/win32ss/user/user32/windows/class.c b/win32ss/user/user32/windows/class.c index fbfa9a6382e..b46f3f7e1d7 100644 --- a/win32ss/user/user32/windows/class.c +++ b/win32ss/user/user32/windows/class.c @@ -714,15 +714,15 @@ IntGetClassLongA(PWND Wnd, PCLS Class, int nIndex) break; #ifdef NEW_CURSORICON case GCLP_HCURSOR: - Ret = Class->spcur ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spcur))->h : 0; + Ret = Class->spcur ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spcur))->h : 0; break; case GCLP_HICON: - Ret = Class->spicn ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spicn))->h : 0; + Ret = Class->spicn ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spicn))->h : 0; break; case GCLP_HICONSM: - Ret = Class->spicnSm ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spicnSm))->h : 0; + Ret = Class->spicnSm ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spicnSm))->h : 0; break; #else case GCLP_HCURSOR: @@ -805,15 +805,15 @@ IntGetClassLongW (PWND Wnd, PCLS Class, int nIndex) #ifdef NEW_CURSORICON case GCLP_HCURSOR: - Ret = Class->spcur ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spcur))->h : 0; + Ret = Class->spcur ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spcur))->h : 0; break; case GCLP_HICON: - Ret = Class->spicn ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spicn))->h : 0; + Ret = Class->spicn ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spicn))->h : 0; break; case GCLP_HICONSM: - Ret = Class->spicnSm ? (ULONG_PTR)((PPROCMARKHEAD)DesktopPtrToUser(Class->spicnSm))->h : 0; + Ret = Class->spicnSm ? (ULONG_PTR)((PPROCMARKHEAD)SharedPtrToUser(Class->spicnSm))->h : 0; break; #else case GCLP_HCURSOR: diff --git a/win32ss/user/user32/windows/cursoricon_new.c b/win32ss/user/user32/windows/cursoricon_new.c index 9b622e127b9..c6810ea914c 100644 --- a/win32ss/user/user32/windows/cursoricon_new.c +++ b/win32ss/user/user32/windows/cursoricon_new.c @@ -393,10 +393,11 @@ get_best_icon_file_entry( WORD i; const CURSORICONFILEDIRENTRY* entry; + /* Check our file is what it claims to be */ if ( dwFileSize < sizeof(*dir) ) return NULL; - if ( dwFileSize < (sizeof(*dir) + sizeof(dir->idEntries[0])*(dir->idCount-1)) ) + if (dwFileSize < (sizeof(*dir) + FIELD_OFFSET(CURSORICONFILEDIR, idEntries[dir->idCount]))) return NULL; /* @@ -418,7 +419,8 @@ get_best_icon_file_entry( fakeEntry = &fakeDir->idEntries[i]; entry = &dir->idEntries[i]; /* Take this as an occasion to perform a size check */ - if((entry->dwDIBOffset + entry->dwDIBSize) > dwFileSize) + if ((entry->dwDIBOffset > dwFileSize) + || ((entry->dwDIBOffset + entry->dwDIBSize) > dwFileSize)) { ERR("Corrupted icon file?.\n"); HeapFree(GetProcessHeap(), 0, fakeDir); @@ -1260,12 +1262,12 @@ CURSORICON_LoadFromFileW( cursorData.rt = (USHORT)((ULONG_PTR)(bIcon ? RT_ICON : RT_CURSOR)); /* Do the dance */ - if(!CURSORICON_GetCursorDataFromBMI(&cursorData, (BITMAPINFO*)&bits[entry->dwDIBOffset])) + if(!CURSORICON_GetCursorDataFromBMI(&cursorData, (BITMAPINFO*)(&bits[entry->dwDIBOffset]))) goto end; hCurIcon = NtUserxCreateEmptyCurObject(FALSE); if(!hCurIcon) - goto end_error; + goto end; /* Tell win32k */ if(!NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData)) @@ -1283,6 +1285,7 @@ end_error: DeleteObject(cursorData.hbmMask); if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); + UnmapViewOfFile(bits); return NULL; } @@ -1681,8 +1684,9 @@ CURSORICON_CopyImage( { HICON ret = NULL; ICONINFO ii; + CURSORDATA CursorData; - if(fuFlags & LR_COPYFROMRESOURCE) + if (fuFlags & LR_COPYFROMRESOURCE) { /* Get the icon module/resource names */ UNICODE_STRING ustrModule; @@ -1694,14 +1698,14 @@ CURSORICON_CopyImage( ustrRsrc.MaximumLength = 256; ustrModule.Buffer = HeapAlloc(GetProcessHeap(), 0, ustrModule.MaximumLength); - if(!ustrModule.Buffer) + if (!ustrModule.Buffer) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } /* Keep track of the buffer for the resource, NtUserGetIconInfo might overwrite it */ pvBuf = HeapAlloc(GetProcessHeap(), 0, ustrRsrc.MaximumLength); - if(!pvBuf) + if (!pvBuf) { HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1742,7 +1746,7 @@ CURSORICON_CopyImage( { ustrRsrc.MaximumLength *= 2; pvBuf = HeapReAlloc(GetProcessHeap(), 0, ustrRsrc.Buffer, ustrRsrc.MaximumLength); - if(!pvBuf) + if (!pvBuf) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto leave; @@ -1753,11 +1757,11 @@ CURSORICON_CopyImage( /* NULL-terminate our strings */ ustrModule.Buffer[ustrModule.Length/sizeof(WCHAR)] = 0; - if(!IS_INTRESOURCE(ustrRsrc.Buffer)) + if (!IS_INTRESOURCE(ustrRsrc.Buffer)) ustrRsrc.Buffer[ustrRsrc.Length/sizeof(WCHAR)] = 0; /* Get the module handle */ - if(!GetModuleHandleExW(0, ustrModule.Buffer, &hModule)) + if (!GetModuleHandleExW(0, ustrModule.Buffer, &hModule)) { /* This should never happen */ ERR("Invalid handle?.\n"); @@ -1766,7 +1770,13 @@ CURSORICON_CopyImage( } /* Call the relevant function */ - ret = CURSORICON_LoadImageW(hModule, ustrRsrc.Buffer, cxDesired, cyDesired, fuFlags & LR_DEFAULTSIZE, bIcon); + ret = CURSORICON_LoadImageW( + hModule, + ustrRsrc.Buffer, + cxDesired, + cyDesired, + fuFlags & (LR_DEFAULTSIZE | LR_SHARED), + bIcon); FreeLibrary(hModule); @@ -1781,24 +1791,40 @@ CURSORICON_CopyImage( } /* This is a regular copy */ - if(fuFlags & ~LR_COPYDELETEORG) + if (fuFlags & ~(LR_COPYDELETEORG | LR_SHARED)) FIXME("Unimplemented flags: 0x%08x\n", fuFlags); - if(!GetIconInfo(hicon, &ii)) + if (!GetIconInfo(hicon, &ii)) { ERR("GetIconInfo failed.\n"); return NULL; } + + /* This is CreateIconIndirect with the LR_SHARED coat added */ + if (!CURSORICON_GetCursorDataFromIconInfo(&CursorData, &ii)) + goto Leave; + + if (fuFlags & LR_SHARED) + CursorData.CURSORF_flags |= CURSORF_LRSHARED; + + ret = NtUserxCreateEmptyCurObject(FALSE); + if (!ret) + goto Leave; + + if (!NtUserSetCursorIconData(ret, NULL, NULL, &CursorData)) + { + NtUserDestroyCursor(ret, TRUE); + goto Leave; + } - ret = CreateIconIndirect(&ii); - +Leave: DeleteObject(ii.hbmMask); - if(ii.hbmColor) DeleteObject(ii.hbmColor); + if (ii.hbmColor) DeleteObject(ii.hbmColor); - if(ret && (fuFlags & LR_COPYDELETEORG)) + if (ret && (fuFlags & LR_COPYDELETEORG)) DestroyIcon(hicon); - return hicon; + return ret; } NTSTATUS WINAPI @@ -2196,7 +2222,7 @@ int WINAPI LookupIconIdFromDirectoryEx( /* No inferior or equal depth available. Get the smallest bigger one */ BitCount = 0xFFFF; - iIndex = 0; + iIndex = -1; for(i = 0; i < dir->idCount; i++) { entry = &dir->idEntries[i]; @@ -2222,8 +2248,10 @@ int WINAPI LookupIconIdFromDirectoryEx( BitCount = entry->wBitCount; } } + if (iIndex >= 0) + return dir->idEntries[iIndex].wResId; - return dir->idEntries[iIndex].wResId; + return 0; } HICON WINAPI CreateIcon(