DWORD WINAPI redirect_WaitForSingleObject( __in HANDLE hHandle, __in DWORD dwMilliseconds ) { NTSTATUS res; LARGE_INTEGER li; LARGE_INTEGER *timeout; if (dwMilliseconds == INFINITE) timeout = NULL; else { li.QuadPart = -((int)dwMilliseconds * TIMER_UNITS_PER_MILLISECOND); timeout = &li; } /* XXX: are there special handles we need to convert to real handles? */ res = NtWaitForSingleObject(hHandle, FALSE/*!alertable*/, timeout); if (!NT_SUCCESS(res)) { set_last_error(ntstatus_to_last_error(res)); return WAIT_FAILED; } if (res == STATUS_TIMEOUT) return WAIT_TIMEOUT; else if (res == STATUS_WAIT_0) return WAIT_OBJECT_0; else if (res == STATUS_ABANDONED_WAIT_0) return WAIT_ABANDONED; else return res; /* WAIT_ success codes tend to match STATUS_ values */ }
LSTATUS WINAPI redirect_RegCloseKey( __in HKEY hKey ) { NTSTATUS res = nt_raw_close(hKey); return ntstatus_to_last_error(res); }
static NTSTATUS open_key_common(HKEY parent_key, LPCWSTR subkey, DWORD access, PHKEY key OUT) { OBJECT_ATTRIBUTES oa; UNICODE_STRING us; NTSTATUS res = wchar_to_unicode(&us, subkey); if (!NT_SUCCESS(res)) return res; InitializeObjectAttributes(&oa, &us, OBJ_CASE_INSENSITIVE, parent_key, NULL); res = nt_raw_OpenKey(key, access, &oa); return ntstatus_to_last_error(res); }
VOID WINAPI redirect_InitializeCriticalSection( __out LPCRITICAL_SECTION lpCriticalSection ) { NTSTATUS res = redirect_RtlInitializeCriticalSection(lpCriticalSection); /* The man page for RtlInitializeCriticalSection implies it doesn't set * any error codes, but it seems reasonable to do so, esp on NULL being * passed in or sthg. */ if (!NT_SUCCESS(res)) set_last_error(ntstatus_to_last_error(res)); }
BOOL WINAPI redirect_InitializeCriticalSectionAndSpinCount( __out LPCRITICAL_SECTION lpCriticalSection, __in DWORD dwSpinCount ) { NTSTATUS res = redirect_RtlInitializeCriticalSectionAndSpinCount (lpCriticalSection, dwSpinCount); if (!NT_SUCCESS(res)) { set_last_error(ntstatus_to_last_error(res)); return FALSE; } return TRUE; }