LVText,
i,
k);
- if (_tcslen(LVText))
+ if (dwTextLength != 0)
{
WriteFile(hFile,
LVText,
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 */
@ stub WmiSetSingleItemA
@ stub WmiSetSingleItemW
@ stub Wow64Win32ApiEntry
-@ stub WriteEncryptedFileRaw
+@ stdcall WriteEncryptedFileRaw(ptr ptr ptr)
* 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;
* 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;
* 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;
* 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;
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");
* 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;
*
* 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;
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;
+}
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
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;
{
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)
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';
*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);
credential->LastWritten.dwHighDateTime = win_time.u.HighPart;
}
break;
+ default:
+ FIXME("unhandled attribute %lu\n", attr_list->attr[i].tag);
+ break;
}
}
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)
TRACE("UserName = %s\n", debugstr_w(credential->UserName));
}
}
- HeapFree(GetProcessHeap(), 0, user);
- HeapFree(GetProcessHeap(), 0, domain);
+ heap_free(user);
if (cred_blob)
{
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);
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;
}
{
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;
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)
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
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)
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);
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;
}
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;
}
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;
}
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]);
}
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;
{
OSStatus status;
SecKeychainSearchRef search;
- status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search);
+ status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search);
if (status == noErr)
{
SecKeychainItemRef item;
{
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]);
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);
}
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);
ret = CredDeleteW(TargetNameW, Type, Flags);
- HeapFree(GetProcessHeap(), 0, TargetNameW);
+ heap_free(TargetNameW);
return ret;
}
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)
{
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);
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);
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);
ret = ERROR_NOT_FOUND;
if (ret != ERROR_SUCCESS)
{
- HeapFree(GetProcessHeap(), 0, target_name);
+ heap_free(target_name);
RegCloseKey(hkeyMgr);
SetLastError(ret);
return FALSE;
if (ret == ERROR_SUCCESS)
{
- buffer = HeapAlloc(GetProcessHeap(), 0, len);
+ buffer = heap_alloc(len);
*Credentials = (PCREDENTIALW *)buffer;
if (buffer)
{
ret = ERROR_OUTOFMEMORY;
}
- HeapFree(GetProcessHeap(), 0, target_name);
+ heap_free(target_name);
RegCloseKey(hkeyMgr);
if (ret != ERROR_SUCCESS)
*/
VOID WINAPI CredFree(PVOID Buffer)
{
- HeapFree(GetProcessHeap(), 0, Buffer);
+ heap_free(Buffer);
}
/******************************************************************************
}
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);
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);
{
OSStatus status;
SecKeychainSearchRef search;
- status = SecKeychainSearchCreateFromAttributes(NULL, kSecInternetPasswordItemClass, NULL, &search);
+ status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, NULL, &search);
if (status == noErr)
{
SecKeychainItemRef item;
{
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]);
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);
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));
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);
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);
ret = CredReadDomainCredentialsW(TargetInformationW, Flags, Size, &CredentialsW);
- HeapFree(GetProcessHeap(), 0, TargetInformationW);
+ heap_free(TargetInformationW);
if (ret)
{
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);
}
len = convert_PCREDENTIALA_to_PCREDENTIALW(Credential, NULL, 0);
- CredentialW = HeapAlloc(GetProcessHeap(), 0, len);
+ CredentialW = heap_alloc(len);
if (!CredentialW)
{
SetLastError(ERROR_OUTOFMEMORY);
ret = CredWriteW(CredentialW, Flags);
- HeapFree(GetProcessHeap(), 0, CredentialW);
+ heap_free(CredentialW);
return ret;
}
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",
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)
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;
{
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;
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;
}
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;
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);
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;
}
'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
{
{ "KOI8U", 21866 },
{ "UTF8", CP_UTF8 }
};
-
+#endif
struct locale_name
{
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 )
{
}
if (n) *dst = 0;
}
-
+#endif
/***********************************************************************
* get_lcid_codepage
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;
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);
if (!dstlen) dst = NULL;
- lcid = ConvertDefaultLocale(lcid);
-
if (flags & LCMAP_SORTKEY)
{
INT ret;
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)
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 */
{
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.@)
*
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;
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);
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
{
{
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;
}
TRAP_EPILOG $SystemCall
fixme
MEND
+
+ #define CR 13
+ #define LF 10
+ #define NUL 0
+
+ #define ASCII dcb
+
+ MACRO
+ UNIMPLEMENTED $Name
+ MEND
#else
# 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) \
#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);
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);
(NTAPI *FAST486_IO_READ_PROC)
(
PFAST486_STATE State,
- ULONG Port,
+ USHORT Port,
PVOID Buffer,
ULONG DataCount,
UCHAR DataSize
(NTAPI *FAST486_IO_WRITE_PROC)
(
PFAST486_STATE State,
- ULONG Port,
+ USHORT Port,
PVOID Buffer,
ULONG DataCount,
UCHAR DataSize
# 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) \
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);
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);
/* Clear what's left */
NumberToClear &= (_BITCOUNT - 1);
- if (NumberToClear)
+ if (NumberToClear != 0)
{
Mask = MAXINDEX << NumberToClear;
*Buffer &= Mask;
/* Set what's left */
NumberToSet &= (_BITCOUNT - 1);
- if (NumberToSet)
+ if (NumberToSet != 0)
{
Mask = MAXINDEX << NumberToSet;
*Buffer |= ~Mask;
* 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 <asm.inc>
+#include <kxarm.h>
/* 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 */
-#include <asm.inc>
-
#ifdef _M_IX86
#define SYM(name) _##name
#define IMPSYM(name) __imp__##name
#define IMPSYM(name) __imp_##name
#endif
+#if (defined(_M_IX86) || defined(_M_AMD64))
+
+#include <asm.inc>
+
MACRO(CREATE_ALIAS1, alias, target)
#ifdef _USE_ML
EXTERN SYM(&target):PROC
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)
+
+#include <kxarm.h>
+
+ 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
+ END
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
}
}
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 -
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)
{
/* 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;
{
ExFreePool(PoolObjectNameInfo);
PoolObjectNameInfo = NULL;
+ ObjectNameInfo = (POBJECT_NAME_INFORMATION)&Buffer;
}
/* Go to the next string buffer position */
PLIST_ENTRY ListHead, NextEntry;
OBJECT_ATTRIBUTES ObjectAttributes;
WCHAR SourceString[54];
-
+
//
// Scan memory descriptors
//
MemoryDescriptor = CONTAINING_RECORD(NextEntry,
MEMORY_ALLOCATION_DESCRIPTOR,
ListEntry);
-
+
//
// Needs to be a ROM/RAM descriptor
//
//
NextEntry = NextEntry->Flink;
}
-
+
//
// Nothing found?
//
0,
0);
}
-
+
//
// Setup the input buffer
//
RamdiskCreate.DiskGuid = RAMDISK_BOOTDISK_GUID;
RamdiskCreate.DriveLetter = L'C';
RamdiskCreate.Options.Fixed = TRUE;
-
+
//
// Check for commandline parameters
//
// Make everything upper case
//
_strupr(CommandLine);
-
+
//
// Check for offset parameter
//
RamdiskCreate.DiskOffset = atol(OffsetValue + 1);
}
}
-
+
//
// Reduce the disk length
//
RamdiskCreate.DiskLength.QuadPart -= RamdiskCreate.DiskOffset;
-
+
//
// Check for length parameter
//
}
}
}
-
+
//
// Setup object attributes
//
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
NULL,
NULL);
-
+
//
// Open a handle to the driver
//
0,
0);
}
-
+
//
// Send create command
//
0,
0);
}
-
+
//
// Convert the GUID
//
0,
0);
}
-
+
//
// Build the symbolic link name and target
//
SymbolicLinkName.Length = 38;
SymbolicLinkName.MaximumLength = 38 + sizeof(UNICODE_NULL);
SymbolicLinkName.Buffer = L"\\ArcName\\ramdisk(0)";
-
+
//
// Create the symbolic link
//
0,
0);
}
-
+
//
// We made it
//
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
* 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)
{
UNICODE_STRING GroupString =
RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet"
L"\\Control\\ServiceGroupOrder");
-
+
/* ReactOS HACK for SETUPLDR */
if (KeLoaderBlock->SetupLdrBlock)
{
PiInitGroupOrderTable = (PVOID)0xBABEB00B;
return STATUS_SUCCESS;
}
-
+
/* Open the registry key */
Status = IopOpenRegistryKeyEx(&KeyHandle,
NULL,
/* Get the list */
Status = IopGetRegistryValue(KeyHandle, L"List", &KeyValueInformation);
ZwClose(KeyHandle);
-
+
/* Make sure we got it */
if (NT_SUCCESS(Status))
{
Status = PnpRegMultiSzToUnicodeStrings(KeyValueInformation,
&GroupTable,
&Count);
-
+
/* Cache it for later */
PiInitGroupOrderTable = GroupTable;
PiInitGroupOrderTableCount = (USHORT)Count;
/* Fail */
Status = STATUS_UNSUCCESSFUL;
}
-
+
/* Free the information */
ExFreePool(KeyValueInformation);
}
}
-
+
/* Return status */
return Status;
}
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;
/* 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;
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))
Tag = *(PULONG)((ULONG_PTR)KeyValueInformationTag +
KeyValueInformationTag->DataOffset);
}
-
+
/* We can get rid of this now */
ExFreePool(KeyValueInformationTag);
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))
/* 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++)
GroupOrder++;
}
}
-
+
/* Last buffer to free */
ExFreePool(KeyValueInformationGroupOrderList);
return i;
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,
DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
return Status;
}
-
+
/* Open instance subkey */
Status = IopOpenRegistryKeyEx(&SubKey,
EnumRootKey,
DPRINT1("IopOpenRegistryKeyEx() failed with Status %08X\n", Status);
return Status;
}
-
+
/* Get class GUID */
Status = IopGetRegistryValue(SubKey,
REGSTR_VAL_CLASSGUID,
PnpRegSzToString(Buffer, KeyValueInformation->DataLength, &ClassGuid.Length);
ClassGuid.MaximumLength = (USHORT)KeyValueInformation->DataLength;
ClassGuid.Buffer = Buffer;
-
+
/* Open the key */
Status = IopOpenRegistryKeyEx(&ControlKey,
NULL,
ClassKey = NULL;
}
}
-
+
/* Check if we made it till here */
if (ClassKey)
{
ZwClose(PropertiesKey);
}
}
-
+
/* Free the registry data */
ExFreePool(KeyValueInformation);
}
-
+
/* Do ReactOS-style setup */
Status = IopAttachFilterDrivers(DeviceNode, TRUE);
if (!NT_SUCCESS(Status))
IopRemoveDevice(DeviceNode);
return Status;
}
-
+
Status = IopStartDevice(DeviceNode);
}
-
+
/* Return status */
return Status;
}
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,
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);
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,
DPRINT1("IoCreateDriverObject() failed\n");
KeBugCheckEx(PHASE1_INITIALIZATION_FAILED, Status, 0, 0, 0);
}
-
+
/* Create the root PDO */
Status = IoCreateDevice(IopRootDriverObject,
sizeof(IOPNP_DEVICE_EXTENSION),
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);
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);
/* 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;
}
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)
ZwClose(InstanceKey);
return;
}
-
+
/* Copy CID next */
CidLength = PartialInfo->DataLength;
RtlCopyMemory(((PUCHAR)IdBuffer) + HidLength, PartialInfo->Data, CidLength);
/* Free our temp buffer */
ExFreePool(PartialInfo);
-
+
InitializeObjectAttributes(&ObjectAttributes,
&CriticalDeviceKeyU,
OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE,
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,
/* Advance to the next ID */
IdBuffer += StringLength;
}
-
+
ExFreePool(OriginalIdBuffer);
ZwClose(InstanceKey);
ZwClose(CriticalDeviceKey);
{
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
-
+
if (!DriverObject)
{
/* Special case for bus driven devices */
{
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);
}
{
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);
}
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;
&GUID_TARGET_DEVICE_QUERY_REMOVE,
NULL,
NULL);
-
+
if (!NT_SUCCESS(Status))
{
DPRINT1("Removal vetoed by %wZ\n", &DeviceNode->InstancePath);
{
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);
}
/* 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;
{
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,
{
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);
}
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 =
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);
/* 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;
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)
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))
/* Nothing to do */
Status = STATUS_SUCCESS;
}
-
+
/* Return */
return Status;
}
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)
{
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)
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;
&Stack->Parameters,
sizeof(Stack->Parameters));
}
-
+
/* Do the PnP call */
IoStatusBlock->Status = IopSynchronousCall(DeviceObject,
&IoStackLocation,
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,
/* 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,
Recursing = FALSE;
continue;
}
-
+
/* Now see if there's more parents to create */
p1 = p + 1;
if ((p == pp) || (p1 == pp))
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))
{
*Handle = HandleArray[i];
if (Disposition) *Disposition = KeyDisposition;
}
-
+
/* Return the success state */
return Status;
}
{
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;
InitializeListHead(&DeviceNode->TargetDeviceNotify);
InitializeListHead(&DeviceNode->DockInfo.ListEntry);
InitializeListHead(&DeviceNode->PendedSetInterfaceState);
-
+
/* Check if there is a PDO */
if (PhysicalDeviceObject)
{
((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode = DeviceNode;
PhysicalDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
}
-
+
/* Return the node */
return DeviceNode;
}
/* Acquire the lock */
ExAcquireFastMutex(&PnpBusTypeGuidList->Lock);
-
+
/* Validate size */
if (Index < PnpBusTypeGuidList->GuidCount)
{
/* Failure path */
Status = STATUS_OBJECT_NAME_NOT_FOUND;
}
-
+
/* Release lock and return status */
ExReleaseFastMutex(&PnpBusTypeGuidList->Lock);
return Status;
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))
/* Fail */
Status = STATUS_INVALID_DEVICE_REQUEST;
}
-
+
/* Close the handle and return status */
ZwClose(KeyHandle);
return Status;
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++)
/* 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;
}
/* 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);
/* This is the format of the returned data */
PIP_RETURN_DATA((ULONG)(EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR),
DeviceInstanceName);
-
+
case DevicePropertyAddress:
/* Query the device caps */
/* 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
*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,
/* 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);
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,
/* Terminate the string */
((PWCHAR)PropertyBuffer)[ReturnLength / sizeof(WCHAR)] = UNICODE_NULL;
}
-
+
/* This is the success path */
Status = STATUS_SUCCESS;
}
Status = STATUS_BUFFER_TOO_SMALL;
}
}
-
+
/* Free any allocation we may have made, and return the status code */
if (ObjectNameInfo) ExFreePool(ObjectNameInfo);
return Status;
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))
{
/* 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))
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,
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,
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)
{
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;
{
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;
}
{
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);
{
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);
{
/* 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);
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 */
DeviceRelations->Objects[i] = NULL;
}
ExFreePool(DeviceRelations);
-
+
return Status;
}
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);
}
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);
}
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,
{
DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information;
}
-
+
if (DeviceRelations)
IopCancelRemoveDeviceRelations(DeviceRelations);
}
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,
if (DeviceRelations)
IopSendRemoveDeviceRelations(DeviceRelations);
IopSendRemoveChildDevices(DeviceNode);
-
+
return STATUS_SUCCESS;
}
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,
{
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))
{
IopCancelRemoveDeviceRelations(DeviceRelations);
goto cleanup;
}
-
+
if (IopPrepareDeviceForRemoval(PhysicalDeviceObject, FALSE) != STATUS_SUCCESS)
{
if (DeviceRelations)
IopCancelRemoveChildDevices(DeviceNode);
goto cleanup;
}
-
+
if (DeviceRelations)
IopSendRemoveDeviceRelations(DeviceRelations);
IopSendRemoveChildDevices(DeviceNode);
{
DeviceNode->Flags |= DNF_DISABLED;
}
-
+
IopQueueTargetDeviceEvent(&GUID_DEVICE_EJECT,
&DeviceNode->InstancePath);
-
+
return;
-
+
cleanup:
IopQueueTargetDeviceEvent(&GUID_DEVICE_EJECT_VETOED,
&DeviceNode->InstancePath);
IN DEVICE_RELATION_TYPE Type)
{
PAGED_CODE();
-
+
switch (Type)
{
case BusRelations:
/* We're enumerated already */
IopDeviceNodeSetFlag(DeviceNode, DNF_ENUMERATED);
-
+
/* We don't call AddDevice for devices reported this way */
IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
ASSERT(IoDesc->Type == CmDesc->Type);
ASSERT(IoDesc->Type == CmResourceTypePort);
-
+
/* HACK */
if (IoDesc->u.Port.Alignment == 0) IoDesc->u.Port.Alignment = 1;
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))
{
FoundResource = FALSE;
}
break;
-
+
case CmResourceTypePort:
/* Find an available port range */
if (!IopFindPortResource(IoDesc, &NewDesc))
FoundResource = FALSE;
}
break;
-
+
case CmResourceTypeMemory:
/* Find an available memory range */
if (!IopFindMemoryResource(IoDesc, &NewDesc))
FoundResource = FALSE;
}
break;
-
+
case CmResourceTypeBusNumber:
/* Find an available bus address range */
if (!IopFindBusNumberResource(IoDesc, &NewDesc))
FoundResource = FALSE;
}
break;
-
+
case CmResourceTypeDma:
/* Find an available DMA channel */
if (!IopFindDmaResource(IoDesc, &NewDesc))
FoundResource = FALSE;
}
break;
-
+
default:
DPRINT1("Unsupported resource type: %x\n", IoDesc->Type);
FoundResource = FALSE;
ULONG OldLength = 0;
ASSERT(DeviceNode->ResourceListTranslated);
-
+
RtlInitUnicodeString(&TranslatedSuffix, L".Translated");
RtlInitUnicodeString(&RawSuffix, L".Raw");
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,
/* This should never happen */
ASSERT(FALSE);
}
-
+
NameU.Length = (USHORT)OldLength;
RtlAppendUnicodeStringToString(&NameU, &RawSuffix);
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;
DescriptorRaw->u.Interrupt.Vector,
(PKIRQL)&DescriptorTranslated->u.Interrupt.Level,
&DescriptorTranslated->u.Interrupt.Affinity);
-
+
if (!DescriptorTranslated->u.Interrupt.Vector)
{
Status = STATUS_UNSUCCESSFUL;
IN ULONG StringCount)
{
ULONG i;
-
+
/* Go through the list */
if (UnicodeStringList)
{
ExFreePool(UnicodeStringList[i].Buffer);
}
}
-
+
/* Free the whole list */
ExFreePool(UnicodeStringList);
}
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)
{
{
/* 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)
{
{
/* 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,
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 +
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;
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;
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;
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);
Pic->Initialization = FALSE;
}
-static BYTE WINAPI PicReadPort(ULONG Port)
+static BYTE WINAPI PicReadPort(USHORT Port)
{
switch (Port)
{
return 0;
}
-static VOID WINAPI PicWritePort(ULONG Port, BYTE Data)
+static VOID WINAPI PicWritePort(USHORT Port, BYTE Data)
{
switch (Port)
{
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)
{
return 0;
}
-static VOID WINAPI PS2WritePort(ULONG Port, BYTE Data)
+static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data)
{
if (Port == PS2_CONTROL_PORT)
{
}
}
-static BYTE WINAPI PitReadPort(ULONG Port)
+static BYTE WINAPI PitReadPort(USHORT Port)
{
switch (Port)
{
return 0;
}
-static VOID WINAPI PitWritePort(ULONG Port, BYTE Data)
+static VOID WINAPI PitWritePort(USHORT Port, BYTE Data)
{
switch (Port)
{
CursorMoved = FALSE;
}
-static BYTE WINAPI VgaReadPort(ULONG Port)
+static BYTE WINAPI VgaReadPort(USHORT Port)
{
DPRINT("VgaReadPort: Port 0x%X\n", 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);
/* PUBLIC FUNCTIONS ***********************************************************/
UCHAR
-IOReadB(ULONG Port)
+IOReadB(USHORT Port)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
IoPortProc[Port].IoHandlers.InB)
}
VOID
-IOReadStrB(ULONG Port,
+IOReadStrB(USHORT Port,
PUCHAR Buffer,
ULONG Count)
{
}
VOID
-IOWriteB(ULONG Port,
+IOWriteB(USHORT Port,
UCHAR Buffer)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
}
VOID
-IOWriteStrB(ULONG Port,
+IOWriteStrB(USHORT Port,
PUCHAR Buffer,
ULONG Count)
{
}
USHORT
-IOReadW(ULONG Port)
+IOReadW(USHORT Port)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
IoPortProc[Port].IoHandlers.InW)
}
VOID
-IOReadStrW(ULONG Port,
+IOReadStrW(USHORT Port,
PUSHORT Buffer,
ULONG Count)
{
}
VOID
-IOWriteW(ULONG Port,
+IOWriteW(USHORT Port,
USHORT Buffer)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
}
VOID
-IOWriteStrW(ULONG Port,
+IOWriteStrW(USHORT Port,
PUSHORT Buffer,
ULONG Count)
{
}
ULONG
-IOReadD(ULONG Port)
+IOReadD(USHORT Port)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
IoPortProc[Port].IoHandlers.InD)
}
VOID
-IOReadStrD(ULONG Port,
+IOReadStrD(USHORT Port,
PULONG Buffer,
ULONG Count)
{
}
VOID
-IOWriteD(ULONG Port,
+IOWriteD(USHORT Port,
ULONG Buffer)
{
if (IoPortProc[Port].hVdd == INVALID_HANDLE_VALUE &&
}
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)
{
IoPortProc[Port].hVdd = INVALID_HANDLE_VALUE;
}
-VOID UnregisterIoPort(ULONG Port)
+VOID UnregisterIoPort(USHORT Port)
{
/*
* Put automagically all the fields to zero:
VOID WINAPI
EmulatorReadIo(PFAST486_STATE State,
- ULONG Port,
+ USHORT Port,
PVOID Buffer,
ULONG DataCount,
UCHAR DataSize)
VOID WINAPI
EmulatorWriteIo(PFAST486_STATE State,
- ULONG Port,
+ USHORT Port,
PVOID Buffer,
ULONG DataCount,
UCHAR DataSize)
/* 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
VOID WINAPI EmulatorWriteIo
(
PFAST486_STATE State,
- ULONG Port,
+ USHORT Port,
PVOID Buffer,
ULONG DataCount,
UCHAR DataSize
set(USE_DIBLIB FALSE)
-set(USE_NEW_CURSORICON FALSE)
+set(USE_NEW_CURSORICON TRUE)
# Give WIN32 subsystem its own project.
PROJECT(WIN32SS)
#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);
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);
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;
}
}
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;
}
{
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);
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 */
_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 */
}
/* 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;
PCURICON_OBJECT pcurOld, pcurNew;
HCURSOR hOldCursor = NULL;
- TRACE("Enter NtUserSetCursor\n");
+ TRACE("Enter NtUserSetCursor: %p\n", hCursor);
UserEnterExclusive();
if (hCursor)
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);
}
while (pRet)
{
- Status = NtDeviceIoControlFile(hKeyboardDevice,
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
NTSTATUS APIENTRY
IntKeyboardUpdateLeds(HANDLE hKeyboardDevice,
WORD wVk,
- WORD wScanCode,
- BOOL bEnabled)
+ WORD wScanCode)
{
NTSTATUS Status;
UINT i;
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,
{
NTSTATUS Status;
IO_STATUS_BLOCK Block;
-/*
+
IntKeyboardGetIndicatorTrans(hKeyboardDevice, &gpKeyboardIndicatorTrans);
- Status = NtDeviceIoControlFile(hKeyboardDevice,
+ Status = ZwDeviceIoControlFile(hKeyboardDevice,
NULL,
NULL,
NULL,
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,
/* Update keyboard LEDs */
IntKeyboardUpdateLeds(ghKeyboardDevice,
wSimpleVk,
- wScanCode,
- IS_KEY_LOCKED(gafAsyncKeyState, wSimpleVk));
+ wScanCode);
}
/* Call WH_KEYBOARD_LL hook */
#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;
}
}
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:
#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:
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;
/*
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);
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))
DeleteObject(cursorData.hbmMask);
if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor);
if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha);
+ UnmapViewOfFile(bits);
return NULL;
}
{
HICON ret = NULL;
ICONINFO ii;
+ CURSORDATA CursorData;
- if(fuFlags & LR_COPYFROMRESOURCE)
+ if (fuFlags & LR_COPYFROMRESOURCE)
{
/* Get the icon module/resource names */
UNICODE_STRING ustrModule;
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);
{
ustrRsrc.MaximumLength *= 2;
pvBuf = HeapReAlloc(GetProcessHeap(), 0, ustrRsrc.Buffer, ustrRsrc.MaximumLength);
- if(!pvBuf)
+ if (!pvBuf)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto leave;
/* 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");
}
/* 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);
}
/* 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
/* 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];
BitCount = entry->wBitCount;
}
}
+ if (iIndex >= 0)
+ return dir->idEntries[iIndex].wResId;
- return dir->idEntries[iIndex].wResId;
+ return 0;
}
HICON WINAPI CreateIcon(