| 1947 | } |
| 1948 | |
| 1949 | LONG WINAPI DetourUpdateThread(_In_ HANDLE hThread) |
| 1950 | { |
| 1951 | LONG error; |
| 1952 | |
| 1953 | // If any of the pending operations failed, then we don't need to do this. |
| 1954 | if (s_nPendingError != NO_ERROR) { |
| 1955 | return s_nPendingError; |
| 1956 | } |
| 1957 | |
| 1958 | // Silently (and safely) drop any attempt to suspend our own thread. |
| 1959 | if (hThread == GetCurrentThread()) { |
| 1960 | return NO_ERROR; |
| 1961 | } |
| 1962 | |
| 1963 | DetourThread *t = new NOTHROW DetourThread; |
| 1964 | if (t == NULL) { |
| 1965 | error = ERROR_NOT_ENOUGH_MEMORY; |
| 1966 | fail: |
| 1967 | if (t != NULL) { |
| 1968 | delete t; |
| 1969 | t = NULL; |
| 1970 | } |
| 1971 | s_nPendingError = error; |
| 1972 | s_ppPendingError = NULL; |
| 1973 | DETOUR_BREAK(); |
| 1974 | return error; |
| 1975 | } |
| 1976 | |
| 1977 | if (SuspendThread(hThread) == (DWORD)-1) { |
| 1978 | error = GetLastError(); |
| 1979 | DETOUR_BREAK(); |
| 1980 | goto fail; |
| 1981 | } |
| 1982 | |
| 1983 | t->hThread = hThread; |
| 1984 | t->pNext = s_pPendingThreads; |
| 1985 | s_pPendingThreads = t; |
| 1986 | |
| 1987 | return NO_ERROR; |
| 1988 | } |
| 1989 | |
| 1990 | ///////////////////////////////////////////////////////////// Transacted APIs. |
| 1991 | // |
no outgoing calls
no test coverage detected
searching dependent graphs…