Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: util/win/handle.h

Issue 1422503015: win: Add HandleToInt() and IntToHandle() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
16 #define CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
17
18 #include <windows.h>
19
20 namespace crashpad {
21
22 //! \brief Converts a `HANDLE` to an `int`.
23 //!
24 //! `HANDLE` is a `typedef` for `void *`, but `HANDLE` values aren’t necessarily
25 //! pointers to anything. Only 32 bits of shareable `HANDLE`s are significant,
26 //! even in 64-bit processes on 64-bit operating systems. See <a
27 //! href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203">Int erprocess
28 //! Communication Between 32-bit and 64-bit Applications</a>.
29 //!
30 //! This function safely converts a shareable `HANDLE` to an `int` similarly to
31 //! a cast operation. It checks that the operation can be performed safely, and
32 //! aborts execution if it cannot.
33 //!
34 //! \param[in] handle The shareable `HANDLE` to convert.
35 //!
36 //! \return An equivalent `int`, truncated (if necessary) from \a handle. If
37 //! truncation would have resulted in an `int` that could not be converted
38 //! back to \a handle, aborts execution.
39 //!
40 //! \sa IntToHandle()
41 int HandleToInt(HANDLE handle);
42
43 //! \brief Converts an `int` to an `HANDLE`.
44 //!
45 //! `HANDLE` is a `typedef` for `void *`, but `HANDLE` values aren’t necessarily
46 //! pointers to anything. Only 32 bits of shareable `HANDLE`s are significant,
47 //! even in 64-bit processes on 64-bit operating systems. See <a
48 //! href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203">Int erprocess
49 //! Communication Between 32-bit and 64-bit Applications</a>.
50 //!
51 //! This function safely convert an `int` to a shareable `HANDLE` similarly to a
52 //! cast operation.
53 //!
54 //! \param[in] handle_int The `int` to convert. This must have been produced by
55 //! HandleToInt(), possibly in a different process.
56 //!
57 //! \return An equivalent shareable `HANDLE`, sign-extended (if necessary) from
58 //! \a handle_int.
59 //!
60 //! \sa HandleToInt()
61 HANDLE IntToHandle(int handle_int);
62
63 } // namespace crashpad
64
65 #endif // CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
OLDNEW
« no previous file with comments | « util/win/exception_handler_server.cc ('k') | util/win/handle.cc » ('j') | util/win/handle.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698