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

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

Issue 1422023010: win: Use signed int as the integer representation of HANDLEs (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
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_ 15 #ifndef CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
16 #define CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_ 16 #define CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
17 17
18 #include <windows.h> 18 #include <windows.h>
19 19
20 namespace crashpad { 20 namespace crashpad {
21 21
22 //! \brief Converts a `HANDLE` to an `int`. 22 //! \brief Converts a `HANDLE` to an `int`.
23 //! 23 //!
24 //! `HANDLE` is a `typedef` for `void *`, but `HANDLE` values aren’t necessarily 24 //! `HANDLE` is a `typedef` for `void *`, but kernel `HANDLE` values aren’t
25 //! pointers to anything. Only 32 bits of shareable `HANDLE`s are significant, 25 //! pointers to anything. Only 32 bits of kernel `HANDLE`s are significant, even
scottmg 2015/11/06 18:33:22 Ah, I meant to mention "shareable" in the last cha
Mark Mentovai 2015/11/06 18:36:27 scottmg wrote:
26 //! even in 64-bit processes on 64-bit operating systems. See <a 26 //! 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 27 //! href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203">Int erprocess
28 //! Communication Between 32-bit and 64-bit Applications</a>. 28 //! Communication Between 32-bit and 64-bit Applications</a>.
29 //! 29 //!
30 //! This function safely converts a shareable `HANDLE` to an `int` similarly to 30 //! This function safely converts a kernel `HANDLE` to an `int` similarly to a
31 //! a cast operation. It checks that the operation can be performed safely, and 31 //! cast operation. It checks that the operation can be performed safely, and
32 //! aborts execution if it cannot. 32 //! aborts execution if it cannot.
33 //! 33 //!
34 //! \param[in] handle The shareable `HANDLE` to convert. 34 //! \param[in] handle The kernel `HANDLE` to convert.
35 //! 35 //!
36 //! \return An equivalent `int`, truncated (if necessary) from \a handle. If 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 37 //! truncation would have resulted in an `int` that could not be converted
38 //! back to \a handle, aborts execution. 38 //! back to \a handle, aborts execution.
39 //! 39 //!
40 //! \sa IntToHandle() 40 //! \sa IntToHandle()
41 int HandleToInt(HANDLE handle); 41 int HandleToInt(HANDLE handle);
42 42
43 //! \brief Converts an `int` to an `HANDLE`. 43 //! \brief Converts an `int` to an `HANDLE`.
44 //! 44 //!
45 //! `HANDLE` is a `typedef` for `void *`, but `HANDLE` values aren’t necessarily 45 //! `HANDLE` is a `typedef` for `void *`, but kernel `HANDLE` values aren’t
46 //! pointers to anything. Only 32 bits of shareable `HANDLE`s are significant, 46 //! pointers to anything. Only 32 bits of kernel `HANDLE`s are significant, even
47 //! even in 64-bit processes on 64-bit operating systems. See <a 47 //! 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 48 //! href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203">Int erprocess
49 //! Communication Between 32-bit and 64-bit Applications</a>. 49 //! Communication Between 32-bit and 64-bit Applications</a>.
50 //! 50 //!
51 //! This function safely convert an `int` to a shareable `HANDLE` similarly to a 51 //! This function safely convert an `int` to a kernel `HANDLE` similarly to a
52 //! cast operation. 52 //! cast operation.
53 //! 53 //!
54 //! \param[in] handle_int The `int` to convert. This must have been produced by 54 //! \param[in] handle_int The `int` to convert. This must have been produced by
55 //! HandleToInt(), possibly in a different process. 55 //! HandleToInt(), possibly in a different process.
56 //! 56 //!
57 //! \return An equivalent shareable `HANDLE`, sign-extended (if necessary) from 57 //! \return An equivalent kernel `HANDLE`, sign-extended (if necessary) from \a
58 //! \a handle_int. 58 //! handle_int.
59 //! 59 //!
60 //! \sa HandleToInt() 60 //! \sa HandleToInt()
61 HANDLE IntToHandle(int handle_int); 61 HANDLE IntToHandle(int handle_int);
62 62
63 } // namespace crashpad 63 } // namespace crashpad
64 64
65 #endif // CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_ 65 #endif // CRASHPAD_UTIL_WIN_HANDLE_TO_INT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698