| 95 | HRESULT hr = SetThreadDescription(hThread, lpThreadName); |
| 96 | SetLastError(WIN32_FROM_HRESULT(hr)); |
| 97 | return SUCCEEDED(hr); |
| 98 | } |
| 99 | |
| 100 | EXTERN_C BOOL __stdcall GetThreadName(HANDLE hThread, PWSTR lpThreadName, SIZE_T dwBufferLength, |
| 101 | PSIZE_T pdwReturnLength) |
| 102 | { |
| 103 | PWSTR pszThreadDescription; |
| 104 | int nThreadDescriptionLength; |
| 105 | |
| 106 | if (!pdwReturnLength) |
| 107 | { |
| 108 | SetLastError(ERROR_INVALID_PARAMETER); |
| 109 | return FALSE; |
| 110 | } |
| 111 | |
| 112 | if (HRESULT hr; FAILED(hr = GetThreadDescription(hThread, &pszThreadDescription))) |
| 113 | { |
| 114 | *pdwReturnLength = 0; |
| 115 | SetLastError(WIN32_FROM_HRESULT(hr)); |
| 116 | return FALSE; |
| 117 | } |
| 118 | |
| 119 | nThreadDescriptionLength = lstrlenW(pszThreadDescription); |
| 120 | *pdwReturnLength = nThreadDescriptionLength; |
| 121 | |
| 122 | if (!lpThreadName || nThreadDescriptionLength >= dwBufferLength) |
| 123 | { |
| 124 | LocalFree((HLOCAL)pszThreadDescription); |
| 125 | SetLastError(ERROR_INSUFFICIENT_BUFFER); |
| 126 | return FALSE; |
| 127 | } |
| 128 | |
| 129 | CopyMemory(lpThreadName, pszThreadDescription, sizeof(WCHAR) * nThreadDescriptionLength); |
| 130 | lpThreadName[nThreadDescriptionLength] = L'\0'; |
| 131 | LocalFree((HLOCAL)pszThreadDescription); |
| 132 | SetLastError(ERROR_SUCCESS); |
| 133 | return TRUE; |
| 134 | } |
nothing calls this directly
no test coverage detected