diff options
author | avi <avi@chromium.org> | 2015-12-21 18:10:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-22 02:10:50 +0000 |
commit | 74a1875fca20f0985e43dac23fbf2329c1bbfe30 (patch) | |
tree | 7233f1a7b166a11fe74962bde7fe31f8ee8c21f9 /sandbox/win | |
parent | b5fedf206b645760d3f88a9055c5aee9eb76415d (diff) | |
download | chromium_src-74a1875fca20f0985e43dac23fbf2329c1bbfe30.zip chromium_src-74a1875fca20f0985e43dac23fbf2329c1bbfe30.tar.gz chromium_src-74a1875fca20f0985e43dac23fbf2329c1bbfe30.tar.bz2 |
Switch to standard integer types in sandbox/.
BUG=138542
TBR=cpu@chromium.org
Committed: https://crrev.com/b5032dd2fd694a9bd7a9e96ad8fefcaf29c24c9e
Cr-Commit-Position: refs/heads/master@{#366413}
Review URL: https://codereview.chromium.org/1538283002
Cr-Commit-Position: refs/heads/master@{#366520}
Diffstat (limited to 'sandbox/win')
118 files changed, 654 insertions, 455 deletions
diff --git a/sandbox/win/sandbox_poc/main_ui_window.cc b/sandbox/win/sandbox_poc/main_ui_window.cc index 8d67cec..c000ce1 100644 --- a/sandbox/win/sandbox_poc/main_ui_window.cc +++ b/sandbox/win/sandbox_poc/main_ui_window.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "sandbox/win/sandbox_poc/main_ui_window.h" + #include <windows.h> #include <CommCtrl.h> #include <commdlg.h> #include <stdarg.h> +#include <stddef.h> #include <time.h> #include <windowsx.h> #include <atlbase.h> @@ -13,7 +16,6 @@ #include <algorithm> #include <sstream> -#include "sandbox/win/sandbox_poc/main_ui_window.h" #include "base/logging.h" #include "sandbox/win/sandbox_poc/resource.h" #include "sandbox/win/src/acl.h" diff --git a/sandbox/win/sandbox_poc/main_ui_window.h b/sandbox/win/sandbox_poc/main_ui_window.h index de1ae216..d8bf720 100644 --- a/sandbox/win/sandbox_poc/main_ui_window.h +++ b/sandbox/win/sandbox_poc/main_ui_window.h @@ -9,7 +9,7 @@ #include <string> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" namespace sandbox { diff --git a/sandbox/win/sandbox_poc/pocdll/utils.h b/sandbox/win/sandbox_poc/pocdll/utils.h index 7588962..0a6ad37 100644 --- a/sandbox/win/sandbox_poc/pocdll/utils.h +++ b/sandbox/win/sandbox_poc/pocdll/utils.h @@ -7,7 +7,6 @@ #include <stdio.h> #include <io.h> -#include "base/basictypes.h" #include "base/macros.h" diff --git a/sandbox/win/src/Wow64.cc b/sandbox/win/src/Wow64.cc index 24facfc..306b9c1 100644 --- a/sandbox/win/src/Wow64.cc +++ b/sandbox/win/src/Wow64.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/wow64.h" +#include <stddef.h> + #include <sstream> #include "base/logging.h" diff --git a/sandbox/win/src/Wow64.h b/sandbox/win/src/Wow64.h index 5858ed8..acabc35 100644 --- a/sandbox/win/src/Wow64.h +++ b/sandbox/win/src/Wow64.h @@ -7,7 +7,7 @@ #include <windows.h> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/app_container.cc b/sandbox/win/src/app_container.cc index f8d7541..a51f092 100644 --- a/sandbox/win/src/app_container.cc +++ b/sandbox/win/src/app_container.cc @@ -5,6 +5,7 @@ #include "sandbox/win/src/app_container.h" #include <Sddl.h> +#include <stddef.h> #include <vector> #include "base/logging.h" diff --git a/sandbox/win/src/app_container.h b/sandbox/win/src/app_container.h index a08c01b..fe2b189 100644 --- a/sandbox/win/src/app_container.h +++ b/sandbox/win/src/app_container.h @@ -9,6 +9,7 @@ #include <vector> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/broker_services.cc b/sandbox/win/src/broker_services.cc index 5e6494f..c3df2ef 100644 --- a/sandbox/win/src/broker_services.cc +++ b/sandbox/win/src/broker_services.cc @@ -5,6 +5,7 @@ #include "sandbox/win/src/broker_services.h" #include <AclAPI.h> +#include <stddef.h> #include "base/logging.h" #include "base/macros.h" @@ -17,8 +18,8 @@ #include "base/win/windows_version.h" #include "sandbox/win/src/app_container.h" #include "sandbox/win/src/process_mitigations.h" -#include "sandbox/win/src/sandbox_policy_base.h" #include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_policy_base.h" #include "sandbox/win/src/target_process.h" #include "sandbox/win/src/win2k_threadpool.h" #include "sandbox/win/src/win_utils.h" diff --git a/sandbox/win/src/broker_services.h b/sandbox/win/src/broker_services.h index b16d5fc..6c8f523 100644 --- a/sandbox/win/src/broker_services.h +++ b/sandbox/win/src/broker_services.h @@ -9,8 +9,8 @@ #include <map> #include <set> #include <utility> -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/job.h" diff --git a/sandbox/win/src/crosscall_client.h b/sandbox/win/src/crosscall_client.h index 777bab7..60ff243 100644 --- a/sandbox/win/src/crosscall_client.h +++ b/sandbox/win/src/crosscall_client.h @@ -5,6 +5,9 @@ #ifndef SANDBOX_SRC_CROSSCALL_CLIENT_H_ #define SANDBOX_SRC_CROSSCALL_CLIENT_H_ +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/crosscall_params.h" #include "sandbox/win/src/sandbox.h" diff --git a/sandbox/win/src/crosscall_params.h b/sandbox/win/src/crosscall_params.h index c060c60..eb59c44 100644 --- a/sandbox/win/src/crosscall_params.h +++ b/sandbox/win/src/crosscall_params.h @@ -7,11 +7,12 @@ #include <windows.h> #include <lmaccess.h> +#include <stddef.h> #include <stdint.h> #include <memory> -#include "base/basictypes.h" +#include "base/macros.h" #include "sandbox/win/src/internal_types.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/crosscall_server.cc b/sandbox/win/src/crosscall_server.cc index f0e1183..9f71f33 100644 --- a/sandbox/win/src/crosscall_server.cc +++ b/sandbox/win/src/crosscall_server.cc @@ -4,12 +4,15 @@ #include "sandbox/win/src/crosscall_server.h" +#include <stddef.h> +#include <stdint.h> + #include <string> #include <vector> -#include "sandbox/win/src/crosscall_params.h" -#include "sandbox/win/src/crosscall_client.h" #include "base/logging.h" +#include "sandbox/win/src/crosscall_client.h" +#include "sandbox/win/src/crosscall_params.h" // This code performs the ipc message validation. Potential security flaws // on the ipc are likelier to be found in this code than in the rest of diff --git a/sandbox/win/src/crosscall_server.h b/sandbox/win/src/crosscall_server.h index 9779c11..0820ac4 100644 --- a/sandbox/win/src/crosscall_server.h +++ b/sandbox/win/src/crosscall_server.h @@ -5,6 +5,8 @@ #ifndef SANDBOX_SRC_CROSSCALL_SERVER_H_ #define SANDBOX_SRC_CROSSCALL_SERVER_H_ +#include <stdint.h> + #include <string> #include <vector> diff --git a/sandbox/win/src/eat_resolver.cc b/sandbox/win/src/eat_resolver.cc index 1675ce8..48681e8 100644 --- a/sandbox/win/src/eat_resolver.cc +++ b/sandbox/win/src/eat_resolver.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/eat_resolver.h" +#include <stddef.h> + #include "base/win/pe_image.h" #include "sandbox/win/src/sandbox_nt_util.h" diff --git a/sandbox/win/src/eat_resolver.h b/sandbox/win/src/eat_resolver.h index 1d9d430..a45d006 100644 --- a/sandbox/win/src/eat_resolver.h +++ b/sandbox/win/src/eat_resolver.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_EAT_RESOLVER_H__ #define SANDBOX_SRC_EAT_RESOLVER_H__ -#include "base/basictypes.h" +#include <stddef.h> + +#include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/resolver.h" diff --git a/sandbox/win/src/filesystem_dispatcher.cc b/sandbox/win/src/filesystem_dispatcher.cc index d4ef796..6f96be2 100644 --- a/sandbox/win/src/filesystem_dispatcher.cc +++ b/sandbox/win/src/filesystem_dispatcher.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/filesystem_dispatcher.h" +#include <stdint.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/filesystem_interception.h" #include "sandbox/win/src/filesystem_policy.h" @@ -86,12 +88,12 @@ bool FilesystemDispatcher::SetupService(InterceptionManager* manager, bool FilesystemDispatcher::NtCreateFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, - uint32 desired_access, - uint32 file_attributes, - uint32 share_access, - uint32 create_disposition, - uint32 create_options) { + uint32_t attributes, + uint32_t desired_access, + uint32_t file_attributes, + uint32_t share_access, + uint32_t create_disposition, + uint32_t create_options) { if (!PreProcessName(name)) { // The path requested might contain a reparse point. ipc->return_info.nt_status = STATUS_ACCESS_DENIED; @@ -100,7 +102,7 @@ bool FilesystemDispatcher::NtCreateFile(IPCInfo* ipc, const wchar_t* filename = name->c_str(); - uint32 broker = TRUE; + uint32_t broker = TRUE; CountedParameterSet<OpenFile> params; params[OpenFile::NAME] = ParamPickerMake(filename); params[OpenFile::ACCESS] = ParamPickerMake(desired_access); @@ -134,10 +136,10 @@ bool FilesystemDispatcher::NtCreateFile(IPCInfo* ipc, bool FilesystemDispatcher::NtOpenFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, - uint32 desired_access, - uint32 share_access, - uint32 open_options) { + uint32_t attributes, + uint32_t desired_access, + uint32_t share_access, + uint32_t open_options) { if (!PreProcessName(name)) { // The path requested might contain a reparse point. ipc->return_info.nt_status = STATUS_ACCESS_DENIED; @@ -146,8 +148,8 @@ bool FilesystemDispatcher::NtOpenFile(IPCInfo* ipc, const wchar_t* filename = name->c_str(); - uint32 broker = TRUE; - uint32 create_disposition = FILE_OPEN; + uint32_t broker = TRUE; + uint32_t create_disposition = FILE_OPEN; CountedParameterSet<OpenFile> params; params[OpenFile::NAME] = ParamPickerMake(filename); params[OpenFile::ACCESS] = ParamPickerMake(desired_access); @@ -179,7 +181,7 @@ bool FilesystemDispatcher::NtOpenFile(IPCInfo* ipc, bool FilesystemDispatcher::NtQueryAttributesFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, CountedBuffer* info) { if (sizeof(FILE_BASIC_INFORMATION) != info->Size()) return false; @@ -190,7 +192,7 @@ bool FilesystemDispatcher::NtQueryAttributesFile(IPCInfo* ipc, return true; } - uint32 broker = TRUE; + uint32_t broker = TRUE; const wchar_t* filename = name->c_str(); CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(filename); @@ -219,7 +221,7 @@ bool FilesystemDispatcher::NtQueryAttributesFile(IPCInfo* ipc, bool FilesystemDispatcher::NtQueryFullAttributesFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, CountedBuffer* info) { if (sizeof(FILE_NETWORK_OPEN_INFORMATION) != info->Size()) return false; @@ -230,7 +232,7 @@ bool FilesystemDispatcher::NtQueryFullAttributesFile(IPCInfo* ipc, return true; } - uint32 broker = TRUE; + uint32_t broker = TRUE; const wchar_t* filename = name->c_str(); CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(filename); @@ -263,8 +265,8 @@ bool FilesystemDispatcher::NtSetInformationFile(IPCInfo* ipc, HANDLE handle, CountedBuffer* status, CountedBuffer* info, - uint32 length, - uint32 info_class) { + uint32_t length, + uint32_t info_class) { if (sizeof(IO_STATUS_BLOCK) != status->Size()) return false; if (length != info->Size()) @@ -285,7 +287,7 @@ bool FilesystemDispatcher::NtSetInformationFile(IPCInfo* ipc, return true; } - uint32 broker = TRUE; + uint32_t broker = TRUE; const wchar_t* filename = name.c_str(); CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(filename); diff --git a/sandbox/win/src/filesystem_dispatcher.h b/sandbox/win/src/filesystem_dispatcher.h index 192d36c..61d918e 100644 --- a/sandbox/win/src/filesystem_dispatcher.h +++ b/sandbox/win/src/filesystem_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_FILESYSTEM_DISPATCHER_H__ #define SANDBOX_SRC_FILESYSTEM_DISPATCHER_H__ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -25,33 +27,33 @@ class FilesystemDispatcher : public Dispatcher { // Processes IPC requests coming from calls to NtCreateFile in the target. bool NtCreateFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, - uint32 desired_access, - uint32 file_attributes, - uint32 share_access, - uint32 create_disposition, - uint32 create_options); + uint32_t attributes, + uint32_t desired_access, + uint32_t file_attributes, + uint32_t share_access, + uint32_t create_disposition, + uint32_t create_options); // Processes IPC requests coming from calls to NtOpenFile in the target. bool NtOpenFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, - uint32 desired_access, - uint32 share_access, - uint32 create_options); + uint32_t attributes, + uint32_t desired_access, + uint32_t share_access, + uint32_t create_options); // Processes IPC requests coming from calls to NtQueryAttributesFile in the // target. bool NtQueryAttributesFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, CountedBuffer* info); // Processes IPC requests coming from calls to NtQueryFullAttributesFile in // the target. bool NtQueryFullAttributesFile(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, CountedBuffer* info); // Processes IPC requests coming from calls to NtSetInformationFile with the @@ -60,8 +62,8 @@ class FilesystemDispatcher : public Dispatcher { HANDLE handle, CountedBuffer* status, CountedBuffer* info, - uint32 length, - uint32 info_class); + uint32_t length, + uint32_t info_class); PolicyBase* policy_base_; DISALLOW_COPY_AND_ASSIGN(FilesystemDispatcher); diff --git a/sandbox/win/src/filesystem_interception.cc b/sandbox/win/src/filesystem_interception.cc index 459f7ac..26d790c 100644 --- a/sandbox/win/src/filesystem_interception.cc +++ b/sandbox/win/src/filesystem_interception.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/filesystem_interception.h" +#include <stdint.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_params.h" @@ -46,16 +48,16 @@ NTSTATUS WINAPI TargetNtCreateFile(NtCreateFileFunction orig_CreateFile, if (NULL == memory) break; - uint32 attributes = 0; + uint32_t attributes = 0; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || NULL == name) break; - uint32 desired_access_uint32 = desired_access; - uint32 options_uint32 = options; - uint32 disposition_uint32 = disposition; - uint32 broker = FALSE; + uint32_t desired_access_uint32 = desired_access; + uint32_t options_uint32 = options; + uint32_t disposition_uint32 = disposition; + uint32_t broker = FALSE; CountedParameterSet<OpenFile> params; params[OpenFile::NAME] = ParamPickerMake(name); params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); @@ -122,16 +124,16 @@ NTSTATUS WINAPI TargetNtOpenFile(NtOpenFileFunction orig_OpenFile, PHANDLE file, if (NULL == memory) break; - uint32 attributes; + uint32_t attributes; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || NULL == name) break; - uint32 desired_access_uint32 = desired_access; - uint32 options_uint32 = options; - uint32 disposition_uint32 = FILE_OPEN; - uint32 broker = FALSE; + uint32_t desired_access_uint32 = desired_access; + uint32_t options_uint32 = options; + uint32_t disposition_uint32 = FILE_OPEN; + uint32_t broker = FALSE; CountedParameterSet<OpenFile> params; params[OpenFile::NAME] = ParamPickerMake(name); params[OpenFile::ACCESS] = ParamPickerMake(desired_access_uint32); @@ -192,7 +194,7 @@ NTSTATUS WINAPI TargetNtQueryAttributesFile( if (NULL == memory) break; - uint32 attributes = 0; + uint32_t attributes = 0; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || NULL == name) @@ -201,7 +203,7 @@ NTSTATUS WINAPI TargetNtQueryAttributesFile( InOutCountedBuffer file_info(file_attributes, sizeof(FILE_BASIC_INFORMATION)); - uint32 broker = FALSE; + uint32_t broker = FALSE; CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(name); params[FileName::BROKER] = ParamPickerMake(broker); @@ -251,7 +253,7 @@ NTSTATUS WINAPI TargetNtQueryFullAttributesFile( if (NULL == memory) break; - uint32 attributes = 0; + uint32_t attributes = 0; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || NULL == name) @@ -260,7 +262,7 @@ NTSTATUS WINAPI TargetNtQueryFullAttributesFile( InOutCountedBuffer file_info(file_attributes, sizeof(FILE_NETWORK_OPEN_INFORMATION)); - uint32 broker = FALSE; + uint32_t broker = FALSE; CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(name); params[FileName::BROKER] = ParamPickerMake(broker); @@ -333,7 +335,7 @@ NTSTATUS WINAPI TargetNtSetInformationFile( if (!NT_SUCCESS(ret) || !name) break; - uint32 broker = FALSE; + uint32_t broker = FALSE; CountedParameterSet<FileName> params; params[FileName::NAME] = ParamPickerMake(name); params[FileName::BROKER] = ParamPickerMake(broker); diff --git a/sandbox/win/src/filesystem_policy.cc b/sandbox/win/src/filesystem_policy.cc index eb6b197..fe7f62f 100644 --- a/sandbox/win/src/filesystem_policy.cc +++ b/sandbox/win/src/filesystem_policy.cc @@ -2,18 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <string> #include "sandbox/win/src/filesystem_policy.h" #include "base/logging.h" +#include "base/macros.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_engine_opcodes.h" #include "sandbox/win/src/policy_params.h" -#include "sandbox/win/src/sandbox_utils.h" #include "sandbox/win/src/sandbox_types.h" +#include "sandbox/win/src/sandbox_utils.h" #include "sandbox/win/src/win_utils.h" namespace { @@ -239,16 +242,16 @@ bool FileSystemPolicy::SetInitialRules(LowLevelPolicy* policy) { bool FileSystemPolicy::CreateFileAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, - uint32 desired_access, - uint32 file_attributes, - uint32 share_access, - uint32 create_disposition, - uint32 create_options, - HANDLE *handle, + const base::string16& file, + uint32_t attributes, + uint32_t desired_access, + uint32_t file_attributes, + uint32_t share_access, + uint32_t create_disposition, + uint32_t create_options, + HANDLE* handle, NTSTATUS* nt_status, - ULONG_PTR *io_information) { + ULONG_PTR* io_information) { // The only action supported is ASK_BROKER which means create the requested // file as specified. if (ASK_BROKER != eval_result) { @@ -273,14 +276,14 @@ bool FileSystemPolicy::CreateFileAction(EvalResult eval_result, bool FileSystemPolicy::OpenFileAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, - uint32 desired_access, - uint32 share_access, - uint32 open_options, - HANDLE *handle, + const base::string16& file, + uint32_t attributes, + uint32_t desired_access, + uint32_t share_access, + uint32_t open_options, + HANDLE* handle, NTSTATUS* nt_status, - ULONG_PTR *io_information) { + ULONG_PTR* io_information) { // The only action supported is ASK_BROKER which means open the requested // file as specified. if (ASK_BROKER != eval_result) { @@ -308,8 +311,8 @@ bool FileSystemPolicy::OpenFileAction(EvalResult eval_result, bool FileSystemPolicy::QueryAttributesFileAction( EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, + const base::string16& file, + uint32_t attributes, FILE_BASIC_INFORMATION* file_info, NTSTATUS* nt_status) { // The only action supported is ASK_BROKER which means query the requested @@ -336,8 +339,8 @@ bool FileSystemPolicy::QueryAttributesFileAction( bool FileSystemPolicy::QueryFullAttributesFileAction( EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, + const base::string16& file, + uint32_t attributes, FILE_NETWORK_OPEN_INFORMATION* file_info, NTSTATUS* nt_status) { // The only action supported is ASK_BROKER which means query the requested @@ -361,11 +364,14 @@ bool FileSystemPolicy::QueryFullAttributesFileAction( return true; } -bool FileSystemPolicy::SetInformationFileAction( - EvalResult eval_result, const ClientInfo& client_info, - HANDLE target_file_handle, void* file_info, uint32 length, - uint32 info_class, IO_STATUS_BLOCK* io_block, - NTSTATUS* nt_status) { +bool FileSystemPolicy::SetInformationFileAction(EvalResult eval_result, + const ClientInfo& client_info, + HANDLE target_file_handle, + void* file_info, + uint32_t length, + uint32_t info_class, + IO_STATUS_BLOCK* io_block, + NTSTATUS* nt_status) { // The only action supported is ASK_BROKER which means open the requested // file as specified. if (ASK_BROKER != eval_result) { diff --git a/sandbox/win/src/filesystem_policy.h b/sandbox/win/src/filesystem_policy.h index 4103ad6..c2ee160 100644 --- a/sandbox/win/src/filesystem_policy.h +++ b/sandbox/win/src/filesystem_policy.h @@ -5,9 +5,10 @@ #ifndef SANDBOX_SRC_FILESYSTEM_POLICY_H__ #define SANDBOX_SRC_FILESYSTEM_POLICY_H__ +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/nt_internals.h" @@ -40,13 +41,13 @@ class FileSystemPolicy { // 'file' : The target file or directory. static bool CreateFileAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, - uint32 desired_access, - uint32 file_attributes, - uint32 share_access, - uint32 create_disposition, - uint32 create_options, + const base::string16& file, + uint32_t attributes, + uint32_t desired_access, + uint32_t file_attributes, + uint32_t share_access, + uint32_t create_disposition, + uint32_t create_options, HANDLE* handle, NTSTATUS* nt_status, ULONG_PTR* io_information); @@ -58,11 +59,11 @@ class FileSystemPolicy { // 'file' : The target file or directory. static bool OpenFileAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, - uint32 desired_access, - uint32 share_access, - uint32 open_options, + const base::string16& file, + uint32_t attributes, + uint32_t desired_access, + uint32_t share_access, + uint32_t open_options, HANDLE* handle, NTSTATUS* nt_status, ULONG_PTR* io_information); @@ -71,8 +72,8 @@ class FileSystemPolicy { // API that is compatible with the IPC-received parameters. static bool QueryAttributesFileAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, + const base::string16& file, + uint32_t attributes, FILE_BASIC_INFORMATION* file_info, NTSTATUS* nt_status); @@ -81,8 +82,8 @@ class FileSystemPolicy { static bool QueryFullAttributesFileAction( EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &file, - uint32 attributes, + const base::string16& file, + uint32_t attributes, FILE_NETWORK_OPEN_INFORMATION* file_info, NTSTATUS* nt_status); @@ -92,8 +93,8 @@ class FileSystemPolicy { const ClientInfo& client_info, HANDLE target_file_handle, void* file_info, - uint32 length, - uint32 info_class, + uint32_t length, + uint32_t info_class, IO_STATUS_BLOCK* io_block, NTSTATUS* nt_status); }; diff --git a/sandbox/win/src/handle_closer.cc b/sandbox/win/src/handle_closer.cc index 2e3a782..f2012b7 100644 --- a/sandbox/win/src/handle_closer.cc +++ b/sandbox/win/src/handle_closer.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/handle_closer.h" +#include <stddef.h> + #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/win/windows_version.h" diff --git a/sandbox/win/src/handle_closer.h b/sandbox/win/src/handle_closer.h index 2b43a6e..9592230 100644 --- a/sandbox/win/src/handle_closer.h +++ b/sandbox/win/src/handle_closer.h @@ -5,10 +5,12 @@ #ifndef SANDBOX_SRC_HANDLE_CLOSER_H_ #define SANDBOX_SRC_HANDLE_CLOSER_H_ +#include <stddef.h> + #include <map> #include <set> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/interception.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/handle_closer_agent.cc b/sandbox/win/src/handle_closer_agent.cc index b26fb15..5face9b 100644 --- a/sandbox/win/src/handle_closer_agent.cc +++ b/sandbox/win/src/handle_closer_agent.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/handle_closer_agent.h" +#include <stddef.h> + #include "base/logging.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/win_utils.h" diff --git a/sandbox/win/src/handle_closer_agent.h b/sandbox/win/src/handle_closer_agent.h index ca0a6cf..042c98e 100644 --- a/sandbox/win/src/handle_closer_agent.h +++ b/sandbox/win/src/handle_closer_agent.h @@ -5,7 +5,7 @@ #ifndef SANDBOX_SRC_HANDLE_CLOSER_AGENT_H_ #define SANDBOX_SRC_HANDLE_CLOSER_AGENT_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/handle_closer.h" diff --git a/sandbox/win/src/handle_closer_test.cc b/sandbox/win/src/handle_closer_test.cc index 10ebe3b..c144ac3 100644 --- a/sandbox/win/src/handle_closer_test.cc +++ b/sandbox/win/src/handle_closer_test.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> + #include "base/strings/stringprintf.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/handle_closer_agent.h" diff --git a/sandbox/win/src/handle_dispatcher.cc b/sandbox/win/src/handle_dispatcher.cc index fb640ba..4b98acd 100644 --- a/sandbox/win/src/handle_dispatcher.cc +++ b/sandbox/win/src/handle_dispatcher.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/handle_dispatcher.h" +#include <stdint.h> + #include "base/win/scoped_handle.h" #include "sandbox/win/src/handle_interception.h" #include "sandbox/win/src/handle_policy.h" @@ -41,9 +43,9 @@ bool HandleDispatcher::SetupService(InterceptionManager* manager, bool HandleDispatcher::DuplicateHandleProxy(IPCInfo* ipc, HANDLE source_handle, - uint32 target_process_id, - uint32 desired_access, - uint32 options) { + uint32_t target_process_id, + uint32_t desired_access, + uint32_t options) { static NtQueryObject QueryObject = NULL; if (!QueryObject) ResolveNTFunctionPtr("NtQueryObject", &QueryObject); diff --git a/sandbox/win/src/handle_dispatcher.h b/sandbox/win/src/handle_dispatcher.h index 84a22e1..24dcdac 100644 --- a/sandbox/win/src/handle_dispatcher.h +++ b/sandbox/win/src/handle_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_HANDLE_DISPATCHER_H_ #define SANDBOX_SRC_HANDLE_DISPATCHER_H_ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -25,9 +27,9 @@ class HandleDispatcher : public Dispatcher { // TargetServices::DuplicateHandle() in the target. bool DuplicateHandleProxy(IPCInfo* ipc, HANDLE source_handle, - uint32 target_process_id, - uint32 desired_access, - uint32 options); + uint32_t target_process_id, + uint32_t desired_access, + uint32_t options); PolicyBase* policy_base_; DISALLOW_COPY_AND_ASSIGN(HandleDispatcher); diff --git a/sandbox/win/src/handle_policy.h b/sandbox/win/src/handle_policy.h index ffe54b8..29ce5ab 100644 --- a/sandbox/win/src/handle_policy.h +++ b/sandbox/win/src/handle_policy.h @@ -7,7 +7,6 @@ #include <string> -#include "base/basictypes.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/policy_low_level.h" #include "sandbox/win/src/sandbox_policy.h" diff --git a/sandbox/win/src/interception.cc b/sandbox/win/src/interception.cc index 1d858be..f0a2a61 100644 --- a/sandbox/win/src/interception.cc +++ b/sandbox/win/src/interception.cc @@ -5,6 +5,8 @@ // For information about interceptions as a whole see // http://dev.chromium.org/developers/design-documents/sandbox . +#include <stddef.h> + #include <set> #include "sandbox/win/src/interception.h" diff --git a/sandbox/win/src/interception.h b/sandbox/win/src/interception.h index 728dc74..4d1ee82 100644 --- a/sandbox/win/src/interception.h +++ b/sandbox/win/src/interception.h @@ -9,11 +9,13 @@ #ifndef SANDBOX_SRC_INTERCEPTION_H_ #define SANDBOX_SRC_INTERCEPTION_H_ +#include <stddef.h> + #include <list> #include <string> -#include "base/basictypes.h" #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/interception_agent.cc b/sandbox/win/src/interception_agent.cc index b2a66c4..1ef6886 100644 --- a/sandbox/win/src/interception_agent.cc +++ b/sandbox/win/src/interception_agent.cc @@ -7,11 +7,13 @@ #include "sandbox/win/src/interception_agent.h" +#include <stddef.h> + +#include "sandbox/win/src/eat_resolver.h" #include "sandbox/win/src/interception_internal.h" #include "sandbox/win/src/interceptors.h" -#include "sandbox/win/src/eat_resolver.h" -#include "sandbox/win/src/sidestep_resolver.h" #include "sandbox/win/src/sandbox_nt_util.h" +#include "sandbox/win/src/sidestep_resolver.h" namespace { diff --git a/sandbox/win/src/interception_agent.h b/sandbox/win/src/interception_agent.h index 2762c61..b2bce08 100644 --- a/sandbox/win/src/interception_agent.h +++ b/sandbox/win/src/interception_agent.h @@ -9,7 +9,7 @@ #ifndef SANDBOX_SRC_INTERCEPTION_AGENT_H__ #define SANDBOX_SRC_INTERCEPTION_AGENT_H__ -#include "base/basictypes.h" +#include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/interception_internal.h b/sandbox/win/src/interception_internal.h index 810478a..45a0557 100644 --- a/sandbox/win/src/interception_internal.h +++ b/sandbox/win/src/interception_internal.h @@ -9,6 +9,8 @@ #ifndef SANDBOX_SRC_INTERCEPTION_INTERNAL_H_ #define SANDBOX_SRC_INTERCEPTION_INTERNAL_H_ +#include <stddef.h> + #include "sandbox/win/src/sandbox_types.h" namespace sandbox { diff --git a/sandbox/win/src/interception_unittest.cc b/sandbox/win/src/interception_unittest.cc index 9b282df..7b7932af 100644 --- a/sandbox/win/src/interception_unittest.cc +++ b/sandbox/win/src/interception_unittest.cc @@ -6,16 +6,17 @@ // The tests require private information so the whole interception.cc file is // included from this file. +#include <windows.h> +#include <stddef.h> + #include <algorithm> #include <set> -#include <windows.h> - #include "base/bits.h" #include "base/memory/scoped_ptr.h" #include "sandbox/win/src/interception.h" -#include "sandbox/win/src/interceptors.h" #include "sandbox/win/src/interception_internal.h" +#include "sandbox/win/src/interceptors.h" #include "sandbox/win/src/target_process.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/sandbox/win/src/internal_types.h b/sandbox/win/src/internal_types.h index 026bedb..e102818 100644 --- a/sandbox/win/src/internal_types.h +++ b/sandbox/win/src/internal_types.h @@ -5,6 +5,8 @@ #ifndef SANDBOX_WIN_SRC_INTERNAL_TYPES_H_ #define SANDBOX_WIN_SRC_INTERNAL_TYPES_H_ +#include <stdint.h> + namespace sandbox { const wchar_t kNtdllName[] = L"ntdll.dll"; @@ -28,18 +30,16 @@ enum ArgType { // Encapsulates a pointer to a buffer and the size of the buffer. class CountedBuffer { public: - CountedBuffer(void* buffer, uint32 size) : size_(size), buffer_(buffer) {} + CountedBuffer(void* buffer, uint32_t size) : size_(size), buffer_(buffer) {} - uint32 Size() const { - return size_; - } + uint32_t Size() const { return size_; } void* Buffer() const { return buffer_; } private: - uint32 size_; + uint32_t size_; void* buffer_; }; diff --git a/sandbox/win/src/ipc_unittest.cc b/sandbox/win/src/ipc_unittest.cc index 9b61a43..c41720d 100644 --- a/sandbox/win/src/ipc_unittest.cc +++ b/sandbox/win/src/ipc_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> #include <stdint.h> #include "sandbox/win/src/crosscall_client.h" diff --git a/sandbox/win/src/job.cc b/sandbox/win/src/job.cc index 9c854e5..adf392d 100644 --- a/sandbox/win/src/job.cc +++ b/sandbox/win/src/job.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/job.h" +#include <stddef.h> + #include "base/win/windows_version.h" #include "sandbox/win/src/restricted_token.h" diff --git a/sandbox/win/src/job.h b/sandbox/win/src/job.h index 4b7cb72..ad3dd41 100644 --- a/sandbox/win/src/job.h +++ b/sandbox/win/src/job.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_JOB_H_ #define SANDBOX_SRC_JOB_H_ -#include "base/basictypes.h" +#include <stddef.h> + +#include "base/macros.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/restricted_token_utils.h" diff --git a/sandbox/win/src/named_pipe_dispatcher.cc b/sandbox/win/src/named_pipe_dispatcher.cc index 53bb7c4..ea8d380 100644 --- a/sandbox/win/src/named_pipe_dispatcher.cc +++ b/sandbox/win/src/named_pipe_dispatcher.cc @@ -4,7 +4,8 @@ #include "sandbox/win/src/named_pipe_dispatcher.h" -#include "base/basictypes.h" +#include <stdint.h> + #include "base/strings/string_split.h" #include "sandbox/win/src/crosscall_client.h" @@ -47,12 +48,12 @@ bool NamedPipeDispatcher::SetupService(InterceptionManager* manager, bool NamedPipeDispatcher::CreateNamedPipe(IPCInfo* ipc, base::string16* name, - uint32 open_mode, - uint32 pipe_mode, - uint32 max_instances, - uint32 out_buffer_size, - uint32 in_buffer_size, - uint32 default_timeout) { + uint32_t open_mode, + uint32_t pipe_mode, + uint32_t max_instances, + uint32_t out_buffer_size, + uint32_t in_buffer_size, + uint32_t default_timeout) { ipc->return_info.win32_result = ERROR_ACCESS_DENIED; ipc->return_info.handle = INVALID_HANDLE_VALUE; diff --git a/sandbox/win/src/named_pipe_dispatcher.h b/sandbox/win/src/named_pipe_dispatcher.h index 1c02199..83f45e0 100644 --- a/sandbox/win/src/named_pipe_dispatcher.h +++ b/sandbox/win/src/named_pipe_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_NAMED_PIPE_DISPATCHER_H__ #define SANDBOX_SRC_NAMED_PIPE_DISPATCHER_H__ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -26,12 +28,12 @@ class NamedPipeDispatcher : public Dispatcher { // target. bool CreateNamedPipe(IPCInfo* ipc, base::string16* name, - uint32 open_mode, - uint32 pipe_mode, - uint32 max_instances, - uint32 out_buffer_size, - uint32 in_buffer_size, - uint32 default_timeout); + uint32_t open_mode, + uint32_t pipe_mode, + uint32_t max_instances, + uint32_t out_buffer_size, + uint32_t in_buffer_size, + uint32_t default_timeout); PolicyBase* policy_base_; DISALLOW_COPY_AND_ASSIGN(NamedPipeDispatcher); diff --git a/sandbox/win/src/named_pipe_policy.h b/sandbox/win/src/named_pipe_policy.h index c904aa3..02aa26c 100644 --- a/sandbox/win/src/named_pipe_policy.h +++ b/sandbox/win/src/named_pipe_policy.h @@ -7,7 +7,6 @@ #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/policy_low_level.h" diff --git a/sandbox/win/src/nt_internals.h b/sandbox/win/src/nt_internals.h index 010f7cb..2a39d5b 100644 --- a/sandbox/win/src/nt_internals.h +++ b/sandbox/win/src/nt_internals.h @@ -8,6 +8,7 @@ #define SANDBOX_WIN_SRC_NT_INTERNALS_H__ #include <windows.h> +#include <stddef.h> typedef LONG NTSTATUS; #define NT_SUCCESS(st) (st >= 0) diff --git a/sandbox/win/src/policy_broker.cc b/sandbox/win/src/policy_broker.cc index c2d25bd..a946ebc 100644 --- a/sandbox/win/src/policy_broker.cc +++ b/sandbox/win/src/policy_broker.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> + #include <map> #include "sandbox/win/src/policy_broker.h" diff --git a/sandbox/win/src/policy_engine_opcodes.cc b/sandbox/win/src/policy_engine_opcodes.cc index dfe42c0..8dca0d9 100644 --- a/sandbox/win/src/policy_engine_opcodes.cc +++ b/sandbox/win/src/policy_engine_opcodes.cc @@ -4,7 +4,9 @@ #include "sandbox/win/src/policy_engine_opcodes.h" -#include "base/basictypes.h" +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/sandbox_nt_types.h" #include "sandbox/win/src/sandbox_types.h" @@ -48,7 +50,7 @@ EvalResult OpcodeEval(PolicyOpcode* opcode, const ParameterSet* pp, // Opcode OpAlwaysFalse: // Does not require input parameter. -PolicyOpcode* OpcodeFactory::MakeOpAlwaysFalse(uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpAlwaysFalse(uint32_t options) { return MakeBase(OP_ALWAYS_FALSE, options, -1); } @@ -63,7 +65,7 @@ EvalResult OpcodeEval<OP_ALWAYS_FALSE>(PolicyOpcode* opcode, // Opcode OpAlwaysTrue: // Does not require input parameter. -PolicyOpcode* OpcodeFactory::MakeOpAlwaysTrue(uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpAlwaysTrue(uint32_t options) { return MakeBase(OP_ALWAYS_TRUE, options, -1); } @@ -79,8 +81,7 @@ EvalResult OpcodeEval<OP_ALWAYS_TRUE>(PolicyOpcode* opcode, // Does not require input parameter. // Argument 0 contains the actual action to return. -PolicyOpcode* OpcodeFactory::MakeOpAction(EvalResult action, - uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpAction(EvalResult action, uint32_t options) { PolicyOpcode* opcode = MakeBase(OP_ACTION, options, 0); if (NULL == opcode) return NULL; opcode->SetArgument(0, action); @@ -98,13 +99,13 @@ EvalResult OpcodeEval<OP_ACTION>(PolicyOpcode* opcode, ////////////////////////////////////////////////////////////////////////////// // Opcode OpNumberMatch: -// Requires a uint32 or void* in selected_param +// Requires a uint32_t or void* in selected_param // Argument 0 is the stored number to match. // Argument 1 is the C++ type of the 0th argument. -PolicyOpcode* OpcodeFactory::MakeOpNumberMatch(int16 selected_param, - uint32 match, - uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpNumberMatch(int16_t selected_param, + uint32_t match, + uint32_t options) { PolicyOpcode* opcode = MakeBase(OP_NUMBER_MATCH, options, selected_param); if (NULL == opcode) return NULL; opcode->SetArgument(0, match); @@ -112,9 +113,9 @@ PolicyOpcode* OpcodeFactory::MakeOpNumberMatch(int16 selected_param, return opcode; } -PolicyOpcode* OpcodeFactory::MakeOpVoidPtrMatch(int16 selected_param, +PolicyOpcode* OpcodeFactory::MakeOpVoidPtrMatch(int16_t selected_param, const void* match, - uint32 options) { + uint32_t options) { PolicyOpcode* opcode = MakeBase(OP_NUMBER_MATCH, options, selected_param); if (NULL == opcode) return NULL; opcode->SetArgument(0, match); @@ -126,9 +127,9 @@ template <> EvalResult OpcodeEval<OP_NUMBER_MATCH>(PolicyOpcode* opcode, const ParameterSet* param, MatchContext* context) { - uint32 value_uint32 = 0; + uint32_t value_uint32 = 0; if (param->Get(&value_uint32)) { - uint32 match_uint32 = 0; + uint32_t match_uint32 = 0; opcode->GetArgument(0, &match_uint32); return (match_uint32 != value_uint32)? EVAL_FALSE : EVAL_TRUE; } else { @@ -144,14 +145,14 @@ EvalResult OpcodeEval<OP_NUMBER_MATCH>(PolicyOpcode* opcode, ////////////////////////////////////////////////////////////////////////////// // Opcode OpNumberMatchRange -// Requires a uint32 in selected_param. +// Requires a uint32_t in selected_param. // Argument 0 is the stored lower bound to match. // Argument 1 is the stored upper bound to match. -PolicyOpcode* OpcodeFactory::MakeOpNumberMatchRange(int16 selected_param, - uint32 lower_bound, - uint32 upper_bound, - uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpNumberMatchRange(int16_t selected_param, + uint32_t lower_bound, + uint32_t upper_bound, + uint32_t options) { if (lower_bound > upper_bound) { return NULL; } @@ -167,11 +168,11 @@ template <> EvalResult OpcodeEval<OP_NUMBER_MATCH_RANGE>(PolicyOpcode* opcode, const ParameterSet* param, MatchContext* context) { - uint32 value = 0; + uint32_t value = 0; if (!param->Get(&value)) return EVAL_ERROR; - uint32 lower_bound = 0; - uint32 upper_bound = 0; + uint32_t lower_bound = 0; + uint32_t upper_bound = 0; opcode->GetArgument(0, &lower_bound); opcode->GetArgument(1, &upper_bound); return((lower_bound <= value) && (upper_bound >= value))? @@ -180,12 +181,12 @@ EvalResult OpcodeEval<OP_NUMBER_MATCH_RANGE>(PolicyOpcode* opcode, ////////////////////////////////////////////////////////////////////////////// // Opcode OpNumberAndMatch: -// Requires a uint32 in selected_param. +// Requires a uint32_t in selected_param. // Argument 0 is the stored number to match. -PolicyOpcode* OpcodeFactory::MakeOpNumberAndMatch(int16 selected_param, - uint32 match, - uint32 options) { +PolicyOpcode* OpcodeFactory::MakeOpNumberAndMatch(int16_t selected_param, + uint32_t match, + uint32_t options) { PolicyOpcode* opcode = MakeBase(OP_NUMBER_AND_MATCH, options, selected_param); if (NULL == opcode) return NULL; opcode->SetArgument(0, match); @@ -196,10 +197,10 @@ template <> EvalResult OpcodeEval<OP_NUMBER_AND_MATCH>(PolicyOpcode* opcode, const ParameterSet* param, MatchContext* context) { - uint32 value = 0; + uint32_t value = 0; if (!param->Get(&value)) return EVAL_ERROR; - uint32 number = 0; + uint32_t number = 0; opcode->GetArgument(0, &number); return (number & value)? EVAL_TRUE : EVAL_FALSE; } @@ -213,11 +214,11 @@ EvalResult OpcodeEval<OP_NUMBER_AND_MATCH>(PolicyOpcode* opcode, // as noted in the header file. // Argument 3 is the string matching options. -PolicyOpcode* OpcodeFactory::MakeOpWStringMatch(int16 selected_param, +PolicyOpcode* OpcodeFactory::MakeOpWStringMatch(int16_t selected_param, const wchar_t* match_str, int start_position, StringMatchOptions match_opts, - uint32 options) { + uint32_t options) { if (NULL == match_str) { return NULL; } @@ -341,8 +342,8 @@ EvalResult OpcodeEval<OP_WSTRING_MATCH>(PolicyOpcode* opcode, // OpcodeMaker (other member functions). PolicyOpcode* OpcodeFactory::MakeBase(OpcodeID opcode_id, - uint32 options, - int16 selected_param) { + uint32_t options, + int16_t selected_param) { if (memory_size() < sizeof(PolicyOpcode)) { return NULL; } diff --git a/sandbox/win/src/policy_engine_opcodes.h b/sandbox/win/src/policy_engine_opcodes.h index 17d1764..11a9c81 100644 --- a/sandbox/win/src/policy_engine_opcodes.h +++ b/sandbox/win/src/policy_engine_opcodes.h @@ -5,7 +5,10 @@ #ifndef SANDBOX_WIN_SRC_POLICY_ENGINE_OPCODES_H_ #define SANDBOX_WIN_SRC_POLICY_ENGINE_OPCODES_H_ -#include "base/basictypes.h" +#include <stddef.h> +#include <stdint.h> + +#include "base/macros.h" #include "base/numerics/safe_conversions.h" #include "sandbox/win/src/policy_engine_params.h" @@ -84,22 +87,22 @@ enum OpcodeID { // Options that apply to every opcode. They are specified when creating // each opcode using OpcodeFactory::MakeOpXXXXX() family of functions // Do nothing special. -const uint32 kPolNone = 0; +const uint32_t kPolNone = 0; // Convert EVAL_TRUE into EVAL_FALSE and vice-versa. This allows to express // negated conditions such as if ( a && !b). -const uint32 kPolNegateEval = 1; +const uint32_t kPolNegateEval = 1; // Zero the MatchContext context structure. This happens after the opcode // is evaluated. -const uint32 kPolClearContext = 2; +const uint32_t kPolClearContext = 2; // Use OR when evaluating this set of opcodes. The policy evaluator by default // uses AND when evaluating. Very helpful when // used with kPolNegateEval. For example if you have a condition best expressed // as if(! (a && b && c)), the use of this flags allows it to be expressed as // if ((!a) || (!b) || (!c)). -const uint32 kPolUseOREval = 4; +const uint32_t kPolUseOREval = 4; // Keeps the evaluation state between opcode evaluations. This is used // for string matching where the next opcode needs to continue matching @@ -108,7 +111,7 @@ const uint32 kPolUseOREval = 4; // as an option kPolClearContext. struct MatchContext { size_t position; - uint32 options; + uint32_t options; MatchContext() { Clear(); @@ -190,13 +193,11 @@ class PolicyOpcode { } // Returns the stored options such as kPolNegateEval and others. - uint32 GetOptions() const { - return options_; - } + uint32_t GetOptions() const { return options_; } // Sets the stored options such as kPolNegateEval. - void SetOptions(uint32 options) { - options_ = base::checked_cast<uint16>(options); + void SetOptions(uint32_t options) { + options_ = base::checked_cast<uint16_t>(options); } private: @@ -218,11 +219,11 @@ class PolicyOpcode { EvalResult EvaluateHelper(const ParameterSet* parameters, MatchContext* match); OpcodeID opcode_id_; - int16 parameter_; - // TODO(cpu): Making |options_| a uint32 would avoid casting, but causes test - // failures. Somewhere code is relying on the size of this struct. + int16_t parameter_; + // TODO(cpu): Making |options_| a uint32_t would avoid casting, but causes + // test failures. Somewhere code is relying on the size of this struct. // http://crbug.com/420296 - uint16 options_; + uint16_t options_; OpcodeArgument arguments_[PolicyOpcode::kArgumentCount]; }; @@ -297,39 +298,39 @@ class OpcodeFactory { } // Creates an OpAlwaysFalse opcode. - PolicyOpcode* MakeOpAlwaysFalse(uint32 options); + PolicyOpcode* MakeOpAlwaysFalse(uint32_t options); // Creates an OpAlwaysFalse opcode. - PolicyOpcode* MakeOpAlwaysTrue(uint32 options); + PolicyOpcode* MakeOpAlwaysTrue(uint32_t options); // Creates an OpAction opcode. // action: The action to return when Evaluate() is called. - PolicyOpcode* MakeOpAction(EvalResult action, uint32 options); + PolicyOpcode* MakeOpAction(EvalResult action, uint32_t options); // Creates an OpNumberMatch opcode. - // selected_param: index of the input argument. It must be a uint32 or the + // selected_param: index of the input argument. It must be a uint32_t or the // evaluation result will generate a EVAL_ERROR. // match: the number to compare against the selected_param. - PolicyOpcode* MakeOpNumberMatch(int16 selected_param, - uint32 match, - uint32 options); + PolicyOpcode* MakeOpNumberMatch(int16_t selected_param, + uint32_t match, + uint32_t options); // Creates an OpNumberMatch opcode (void pointers are cast to numbers). // selected_param: index of the input argument. It must be an void* or the // evaluation result will generate a EVAL_ERROR. // match: the pointer numeric value to compare against selected_param. - PolicyOpcode* MakeOpVoidPtrMatch(int16 selected_param, + PolicyOpcode* MakeOpVoidPtrMatch(int16_t selected_param, const void* match, - uint32 options); + uint32_t options); // Creates an OpNumberMatchRange opcode using the memory passed in the ctor. - // selected_param: index of the input argument. It must be a uint32 or the + // selected_param: index of the input argument. It must be a uint32_t or the // evaluation result will generate a EVAL_ERROR. // lower_bound, upper_bound: the range to compare against selected_param. - PolicyOpcode* MakeOpNumberMatchRange(int16 selected_param, - uint32 lower_bound, - uint32 upper_bound, - uint32 options); + PolicyOpcode* MakeOpNumberMatchRange(int16_t selected_param, + uint32_t lower_bound, + uint32_t upper_bound, + uint32_t options); // Creates an OpWStringMatch opcode using the raw memory passed in the ctor. // selected_param: index of the input argument. It must be a wide string @@ -344,26 +345,27 @@ class OpcodeFactory { // current implementation. // match_opts: Indicates additional matching flags. Currently CaseInsensitive // is supported. - PolicyOpcode* MakeOpWStringMatch(int16 selected_param, + PolicyOpcode* MakeOpWStringMatch(int16_t selected_param, const wchar_t* match_str, int start_position, StringMatchOptions match_opts, - uint32 options); + uint32_t options); // Creates an OpNumberAndMatch opcode using the raw memory passed in the ctor. - // selected_param: index of the input argument. It must be uint32 or the + // selected_param: index of the input argument. It must be uint32_t or the // evaluation result will generate a EVAL_ERROR. // match: the value to bitwise AND against selected_param. - PolicyOpcode* MakeOpNumberAndMatch(int16 selected_param, - uint32 match, - uint32 options); + PolicyOpcode* MakeOpNumberAndMatch(int16_t selected_param, + uint32_t match, + uint32_t options); private: // Constructs the common part of every opcode. selected_param is the index // of the input param to use when evaluating the opcode. Pass -1 in // selected_param to indicate that no input parameter is required. - PolicyOpcode* MakeBase(OpcodeID opcode_id, uint32 options, - int16 selected_param); + PolicyOpcode* MakeBase(OpcodeID opcode_id, + uint32_t options, + int16_t selected_param); // Allocates (and copies) a string (of size length) inside the buffer and // returns the displacement with respect to start. diff --git a/sandbox/win/src/policy_engine_params.h b/sandbox/win/src/policy_engine_params.h index 5b3c5ef..fb4c00e 100644 --- a/sandbox/win/src/policy_engine_params.h +++ b/sandbox/win/src/policy_engine_params.h @@ -5,7 +5,8 @@ #ifndef SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ #define SANDBOX_SRC_POLICY_ENGINE_PARAMS_H__ -#include "base/basictypes.h" +#include <stdint.h> + #include "sandbox/win/src/internal_types.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/sandbox_nt_util.h" @@ -61,11 +62,11 @@ class ParameterSet { ParameterSet() : real_type_(INVALID_TYPE), address_(NULL) {} // Retrieve the stored parameter. If the type does not match ulong fail. - bool Get(uint32* destination) const { + bool Get(uint32_t* destination) const { if (real_type_ != UINT32_TYPE) { return false; } - *destination = Void2TypePointerCopy<uint32>(); + *destination = Void2TypePointerCopy<uint32_t>(); return true; } @@ -152,9 +153,8 @@ class ParameterSetEx<wchar_t const*> : public ParameterSet { : ParameterSet(WCHAR_TYPE, address) {} }; - -template<> -class ParameterSetEx<uint32> : public ParameterSet { +template <> +class ParameterSetEx<uint32_t> : public ParameterSet { public: ParameterSetEx(const void* address) : ParameterSet(UINT32_TYPE, address) {} diff --git a/sandbox/win/src/policy_engine_processor.cc b/sandbox/win/src/policy_engine_processor.cc index 7ca25b2..960db08 100644 --- a/sandbox/win/src/policy_engine_processor.cc +++ b/sandbox/win/src/policy_engine_processor.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/policy_engine_processor.h" namespace sandbox { @@ -23,7 +26,7 @@ EvalResult PolicyProcessor::GetAction() const { bool SkipOpcode(const PolicyOpcode& opcode, MatchContext* context, bool* keep_skipping) { if (opcode.IsAction()) { - uint32 options = context->options; + uint32_t options = context->options; context->Clear(); *keep_skipping = false; return (kPolUseOREval != options); @@ -32,7 +35,7 @@ bool SkipOpcode(const PolicyOpcode& opcode, MatchContext* context, return true; } -PolicyResult PolicyProcessor::Evaluate(uint32 options, +PolicyResult PolicyProcessor::Evaluate(uint32_t options, ParameterSet* parameters, size_t param_count) { if (NULL == policy_) { diff --git a/sandbox/win/src/policy_engine_processor.h b/sandbox/win/src/policy_engine_processor.h index 9e416bd..0d56896 100644 --- a/sandbox/win/src/policy_engine_processor.h +++ b/sandbox/win/src/policy_engine_processor.h @@ -5,9 +5,12 @@ #ifndef SANDBOX_SRC_POLICY_ENGINE_PROCESSOR_H__ #define SANDBOX_SRC_POLICY_ENGINE_PROCESSOR_H__ -#include "base/basictypes.h" -#include "sandbox/win/src/policy_engine_params.h" +#include <stddef.h> +#include <stdint.h> + +#include "base/macros.h" #include "sandbox/win/src/policy_engine_opcodes.h" +#include "sandbox/win/src/policy_engine_params.h" namespace sandbox { @@ -66,15 +69,15 @@ enum PolicyResult { // TODO(cpu): implement the options kStopOnErrors & kRankedEval. // // Stop evaluating as soon as an error is encountered. -const uint32 kStopOnErrors = 1; +const uint32_t kStopOnErrors = 1; // Ignore all non fatal opcode evaluation errors. -const uint32 kIgnoreErrors = 2; +const uint32_t kIgnoreErrors = 2; // Short-circuit evaluation: Only evaluate until opcode group that // evaluated to true has been found. -const uint32 kShortEval = 4; +const uint32_t kShortEval = 4; // Discussed briefly at the policy design meeting. It will evaluate // all rules and then return the 'best' rule that evaluated true. -const uint32 kRankedEval = 8; +const uint32_t kRankedEval = 8; // This class evaluates a policy-opcode stream given the memory where the // opcodes are and an input 'parameter set'. @@ -119,7 +122,7 @@ class PolicyProcessor { // Evaluates a policy-opcode stream. See the comments at the top of this // class for more info. Returns POLICY_MATCH if a rule set was found that // matches an active policy. - PolicyResult Evaluate(uint32 options, + PolicyResult Evaluate(uint32_t options, ParameterSet* parameters, size_t parameter_count); diff --git a/sandbox/win/src/policy_engine_unittest.cc b/sandbox/win/src/policy_engine_unittest.cc index 325a101..5572bdc 100644 --- a/sandbox/win/src/policy_engine_unittest.cc +++ b/sandbox/win/src/policy_engine_unittest.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/policy_engine_params.h" #include "sandbox/win/src/policy_engine_processor.h" #include "testing/gtest/include/gtest/gtest.h" @@ -61,8 +64,8 @@ TEST(PolicyEngineTest, Rules1) { policy->opcode_count = 7; const wchar_t* filename = L"c:\\Documents and Settings\\Microsoft\\BLAH.txt"; - uint32 creation_mode = OPEN_EXISTING; - uint32 flags = FILE_ATTRIBUTE_NORMAL; + uint32_t creation_mode = OPEN_EXISTING; + uint32_t flags = FILE_ATTRIBUTE_NORMAL; void* security_descriptor = NULL; POLPARAMS_BEGIN(eval_params) diff --git a/sandbox/win/src/policy_low_level.cc b/sandbox/win/src/policy_low_level.cc index 739321c..526b23d 100644 --- a/sandbox/win/src/policy_low_level.cc +++ b/sandbox/win/src/policy_low_level.cc @@ -4,10 +4,11 @@ #include "sandbox/win/src/policy_low_level.h" -#include <string> -#include <map> +#include <stddef.h> +#include <stdint.h> -#include "base/basictypes.h" +#include <map> +#include <string> namespace { @@ -23,11 +24,11 @@ namespace { // The category of the last character seen by the string matching opcode // generator. - const uint32 kLastCharIsNone = 0; - const uint32 kLastCharIsAlpha = 1; - const uint32 kLastCharIsWild = 2; - const uint32 kLastCharIsAsterisk = kLastCharIsWild + 4; - const uint32 kLastCharIsQuestionM = kLastCharIsWild + 8; + const uint32_t kLastCharIsNone = 0; + const uint32_t kLastCharIsAlpha = 1; + const uint32_t kLastCharIsWild = 2; + const uint32_t kLastCharIsAsterisk = kLastCharIsWild + 4; + const uint32_t kLastCharIsQuestionM = kLastCharIsWild + 8; } namespace sandbox { @@ -68,7 +69,7 @@ LowLevelPolicy::~LowLevelPolicy() { bool LowLevelPolicy::Done() { typedef std::list<RuleNode> RuleNodes; typedef std::list<const PolicyRule*> RuleList; - typedef std::map<uint32, RuleList> Mmap; + typedef std::map<uint32_t, RuleList> Mmap; Mmap mmap; for (RuleNodes::iterator it = rules_.begin(); it != rules_.end(); ++it) { @@ -81,7 +82,7 @@ bool LowLevelPolicy::Done() { size_t avail_size = policy_store_->data_size; for (Mmap::iterator it = mmap.begin(); it != mmap.end(); ++it) { - uint32 service = (*it).first; + uint32_t service = (*it).first; if (service >= kMaxServiceCount) { return false; } @@ -155,14 +156,16 @@ PolicyRule::PolicyRule(const PolicyRule& other) { // to zero. bool PolicyRule::GenStringOpcode(RuleType rule_type, StringMatchOptions match_opts, - uint16 parameter, int state, bool last_call, - int* skip_count, base::string16* fragment) { - + uint16_t parameter, + int state, + bool last_call, + int* skip_count, + base::string16* fragment) { // The last opcode must: // 1) Always clear the context. // 2) Preserve the negation. // 3) Remove the 'OR' mode flag. - uint32 options = kPolNone; + uint32_t options = kPolNone; if (last_call) { if (IF_NOT == rule_type) { options = kPolClearContext | kPolNegateEval; @@ -219,7 +222,8 @@ bool PolicyRule::GenStringOpcode(RuleType rule_type, return true; } -bool PolicyRule::AddStringMatch(RuleType rule_type, int16 parameter, +bool PolicyRule::AddStringMatch(RuleType rule_type, + int16_t parameter, const wchar_t* string, StringMatchOptions match_opts) { if (done_) { @@ -228,7 +232,7 @@ bool PolicyRule::AddStringMatch(RuleType rule_type, int16 parameter, } const wchar_t* current_char = string; - uint32 last_char = kLastCharIsNone; + uint32_t last_char = kLastCharIsNone; int state = PENDING_NONE; int skip_count = 0; // counts how many '?' we have seen in a row. base::string16 fragment; // accumulates the non-wildcard part. @@ -280,14 +284,14 @@ bool PolicyRule::AddStringMatch(RuleType rule_type, int16 parameter, } bool PolicyRule::AddNumberMatch(RuleType rule_type, - int16 parameter, - uint32 number, + int16_t parameter, + uint32_t number, RuleOp comparison_op) { if (done_) { // Do not allow to add more rules after generating the action opcode. return false; } - uint32 opts = (rule_type == IF_NOT)? kPolNegateEval : kPolNone; + uint32_t opts = (rule_type == IF_NOT) ? kPolNegateEval : kPolNone; if (EQUAL == comparison_op) { if (NULL == opcode_factory_->MakeOpNumberMatch(parameter, number, opts)) { diff --git a/sandbox/win/src/policy_low_level.h b/sandbox/win/src/policy_low_level.h index 6a62631..f77787c 100644 --- a/sandbox/win/src/policy_low_level.h +++ b/sandbox/win/src/policy_low_level.h @@ -5,13 +5,16 @@ #ifndef SANDBOX_SRC_POLICY_LOW_LEVEL_H__ #define SANDBOX_SRC_POLICY_LOW_LEVEL_H__ +#include <stddef.h> +#include <stdint.h> + #include <list> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/ipc_tags.h" -#include "sandbox/win/src/policy_engine_params.h" #include "sandbox/win/src/policy_engine_opcodes.h" +#include "sandbox/win/src/policy_engine_params.h" // Low level policy classes. // Built on top of the PolicyOpcode and OpcodeFatory, the low level policy @@ -136,8 +139,10 @@ class PolicyRule { // in a 'create file' service the file name argument can be at index 0. // string: is the desired matching pattern. // match_opts: if the pattern matching is case sensitive or not. - bool AddStringMatch(RuleType rule_type, int16 parameter, - const wchar_t* string, StringMatchOptions match_opts); + bool AddStringMatch(RuleType rule_type, + int16_t parameter, + const wchar_t* string, + StringMatchOptions match_opts); // Adds a number match comparison to the rule. // rule_type: possible values are IF and IF_NOT. @@ -145,8 +150,8 @@ class PolicyRule { // number: the value to compare the input to. // comparison_op: the comparison kind (equal, logical and, etc). bool AddNumberMatch(RuleType rule_type, - int16 parameter, - uint32 number, + int16_t parameter, + uint32_t number, RuleOp comparison_op); // Returns the number of opcodes generated so far. @@ -163,9 +168,13 @@ class PolicyRule { // Called in a loop from AddStringMatch to generate the required string // match opcodes. rule_type, match_opts and parameter are the same as // in AddStringMatch. - bool GenStringOpcode(RuleType rule_type, StringMatchOptions match_opts, - uint16 parameter, int state, bool last_call, - int* skip_count, base::string16* fragment); + bool GenStringOpcode(RuleType rule_type, + StringMatchOptions match_opts, + uint16_t parameter, + int state, + bool last_call, + int* skip_count, + base::string16* fragment); // Loop over all generated opcodes and copy them to increasing memory // addresses from opcode_start and copy the extra data (strings usually) into diff --git a/sandbox/win/src/policy_low_level_unittest.cc b/sandbox/win/src/policy_low_level_unittest.cc index 88b9c43..fd67469 100644 --- a/sandbox/win/src/policy_low_level_unittest.cc +++ b/sandbox/win/src/policy_low_level_unittest.cc @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/policy_engine_params.h" #include "sandbox/win/src/policy_engine_processor.h" #include "sandbox/win/src/policy_low_level.h" @@ -56,7 +59,7 @@ TEST(PolicyEngineTest, SimpleStrMatch) { CASE_INSENSITIVE)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 2; + const uint32_t kFakeService = 2; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); @@ -89,7 +92,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatch) { CASE_SENSITIVE)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 2; + const uint32_t kFakeService = 2; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); @@ -127,7 +130,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatchWild1) { CASE_SENSITIVE)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 3; + const uint32_t kFakeService = 3; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); @@ -160,7 +163,7 @@ TEST(PolicyEngineTest, SimpleIfNotStrMatchWild2) { CASE_SENSITIVE)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 3; + const uint32_t kFakeService = 3; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); @@ -199,14 +202,14 @@ TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild1) { EXPECT_TRUE(pr.AddNumberMatch(IF, 1, 24, EQUAL)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 3; + const uint32_t kFakeService = 3; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); EXPECT_TRUE(policyGen.Done()); const wchar_t* filename = NULL; - uint32 access = 0; + uint32_t access = 0; POLPARAMS_BEGIN(eval_params) POLPARAM(filename) // Argument 0 POLPARAM(access) // Argument 1 @@ -248,15 +251,15 @@ TEST(PolicyEngineTest, IfNotStrMatchTwoRulesWild2) { EXPECT_TRUE(pr.AddNumberMatch(IF, 2, 66, EQUAL)); PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kFakeService = 3; + const uint32_t kFakeService = 3; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kFakeService, &pr)); EXPECT_TRUE(policyGen.Done()); const wchar_t* filename = NULL; - uint32 access = 0; - uint32 sharing = 66; + uint32_t access = 0; + uint32_t sharing = 66; POLPARAMS_BEGIN(eval_params) POLPARAM(filename) // Argument 0 @@ -322,15 +325,15 @@ TEST(PolicyEngineTest, OneRuleTest) { PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kNtFakeCreateFile = 7; + const uint32_t kNtFakeCreateFile = 7; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kNtFakeCreateFile, &pr)); EXPECT_TRUE(policyGen.Done()); const wchar_t* filename = L"c:\\Documents and Settings\\Microsoft\\BLAH.txt"; - uint32 creation_mode = OPEN_EXISTING; - uint32 flags = FILE_ATTRIBUTE_NORMAL; + uint32_t creation_mode = OPEN_EXISTING; + uint32_t flags = FILE_ATTRIBUTE_NORMAL; void* security_descriptor = NULL; POLPARAMS_BEGIN(eval_params) @@ -428,9 +431,9 @@ TEST(PolicyEngineTest, ThreeRulesTest) { PolicyGlobal* policy = MakePolicyMemory(); - const uint32 kNtFakeNone = 4; - const uint32 kNtFakeCreateFile = 5; - const uint32 kNtFakeOpenFile = 6; + const uint32_t kNtFakeNone = 4; + const uint32_t kNtFakeCreateFile = 5; + const uint32_t kNtFakeOpenFile = 6; LowLevelPolicy policyGen(policy); EXPECT_TRUE(policyGen.AddRule(kNtFakeCreateFile, &pr_pipe)); @@ -486,8 +489,8 @@ TEST(PolicyEngineTest, ThreeRulesTest) { // Test the policy evaluation. const wchar_t* filename = L""; - uint32 creation_mode = OPEN_EXISTING; - uint32 flags = FILE_ATTRIBUTE_NORMAL; + uint32_t creation_mode = OPEN_EXISTING; + uint32_t flags = FILE_ATTRIBUTE_NORMAL; void* security_descriptor = NULL; POLPARAMS_BEGIN(params) diff --git a/sandbox/win/src/policy_opcodes_unittest.cc b/sandbox/win/src/policy_opcodes_unittest.cc index 954aa44..f8c210e 100644 --- a/sandbox/win/src/policy_opcodes_unittest.cc +++ b/sandbox/win/src/policy_opcodes_unittest.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "sandbox/win/src/sandbox_types.h" -#include "sandbox/win/src/sandbox_nt_types.h" -#include "sandbox/win/src/policy_engine_params.h" +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/policy_engine_opcodes.h" +#include "sandbox/win/src/policy_engine_params.h" +#include "sandbox/win/src/sandbox_nt_types.h" +#include "sandbox/win/src/sandbox_types.h" #include "testing/gtest/include/gtest/gtest.h" @@ -45,7 +48,7 @@ TEST(PolicyEngineTest, ParameterSetTest) { // Test that we can store and retrieve a void pointer: const void* result1 =0; - uint32 result2 = 0; + uint32_t result2 = 0; EXPECT_TRUE(pset1.Get(&result1)); EXPECT_TRUE(pv1 == result1); EXPECT_FALSE(pset1.Get(&result2)); @@ -53,8 +56,8 @@ TEST(PolicyEngineTest, ParameterSetTest) { EXPECT_TRUE(pv2 == result1); EXPECT_FALSE(pset2.Get(&result2)); - // Test that we can store and retrieve a uint32: - uint32 number = 12747; + // Test that we can store and retrieve a uint32_t: + uint32_t number = 12747; ParameterSet pset3 = ParamPickerMake(number); EXPECT_FALSE(pset3.Get(&result1)); EXPECT_TRUE(pset3.Get(&result2)); @@ -181,8 +184,8 @@ TEST(PolicyEngineTest, OpcodeMakerCase2) { TEST(PolicyEngineTest, IntegerOpcodes) { const wchar_t* txt = L"abcdef"; - uint32 num1 = 42; - uint32 num2 = 113377; + uint32_t num1 = 42; + uint32_t num2 = 113377; ParameterSet pp_wrong1 = ParamPickerMake(txt); ParameterSet pp_num1 = ParamPickerMake(num1); @@ -221,7 +224,7 @@ TEST(PolicyEngineTest, LogicalOpcodes) { char memory[kOpcodeMemory]; OpcodeFactory opcode_maker(memory, sizeof(memory)); - uint32 num1 = 0x10100702; + uint32_t num1 = 0x10100702; ParameterSet pp_num1 = ParamPickerMake(num1); PolicyOpcode* op_and1 = diff --git a/sandbox/win/src/policy_target.cc b/sandbox/win/src/policy_target.cc index fb464cc..568fe2f 100644 --- a/sandbox/win/src/policy_target.cc +++ b/sandbox/win/src/policy_target.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/policy_target.h" +#include <stddef.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_engine_processor.h" diff --git a/sandbox/win/src/process_mitigations.cc b/sandbox/win/src/process_mitigations.cc index 8072440..6ca8a8d 100644 --- a/sandbox/win/src/process_mitigations.cc +++ b/sandbox/win/src/process_mitigations.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/process_mitigations.h" +#include <stddef.h> + #include <algorithm> #include "base/win/windows_version.h" diff --git a/sandbox/win/src/process_mitigations.h b/sandbox/win/src/process_mitigations.h index 9039ad6..8bee024 100644 --- a/sandbox/win/src/process_mitigations.h +++ b/sandbox/win/src/process_mitigations.h @@ -6,8 +6,8 @@ #define SANDBOX_SRC_WIN_PROCESS_MITIGATIONS_H_ #include <windows.h> +#include <stddef.h> -#include "base/basictypes.h" #include "sandbox/win/src/security_level.h" namespace sandbox { diff --git a/sandbox/win/src/process_mitigations_win32k_dispatcher.h b/sandbox/win/src/process_mitigations_win32k_dispatcher.h index 2e1e1a8..55a84a7 100644 --- a/sandbox/win/src/process_mitigations_win32k_dispatcher.h +++ b/sandbox/win/src/process_mitigations_win32k_dispatcher.h @@ -5,7 +5,7 @@ #ifndef SANDBOX_SRC_PROCESS_MITIGATIONS_WIN32K_DISPATCHER_H_ #define SANDBOX_SRC_PROCESS_MITIGATIONS_WIN32K_DISPATCHER_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "sandbox/win/src/sandbox_policy_base.h" namespace sandbox { diff --git a/sandbox/win/src/process_mitigations_win32k_interception.h b/sandbox/win/src/process_mitigations_win32k_interception.h index bf7b551..0b295ea 100644 --- a/sandbox/win/src/process_mitigations_win32k_interception.h +++ b/sandbox/win/src/process_mitigations_win32k_interception.h @@ -6,7 +6,6 @@ #define SANDBOX_SRC_PROCESS_MITIGATIONS_WIN32K_INTERCEPTION_H_ #include <windows.h> -#include "base/basictypes.h" #include "sandbox/win/src/sandbox_types.h" namespace sandbox { diff --git a/sandbox/win/src/process_mitigations_win32k_policy.h b/sandbox/win/src/process_mitigations_win32k_policy.h index 078ed2b..32af168 100644 --- a/sandbox/win/src/process_mitigations_win32k_policy.h +++ b/sandbox/win/src/process_mitigations_win32k_policy.h @@ -5,7 +5,6 @@ #ifndef SANDBOX_SRC_PROCESS_MITIGATIONS_WIN32K_POLICY_H_ #define SANDBOX_SRC_PROCESS_MITIGATIONS_WIN32K_POLICY_H_ -#include "base/basictypes.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/policy_low_level.h" #include "sandbox/win/src/sandbox_policy.h" diff --git a/sandbox/win/src/process_thread_dispatcher.cc b/sandbox/win/src/process_thread_dispatcher.cc index 90cad63..8debd1e 100644 --- a/sandbox/win/src/process_thread_dispatcher.cc +++ b/sandbox/win/src/process_thread_dispatcher.cc @@ -4,7 +4,9 @@ #include "sandbox/win/src/process_thread_dispatcher.h" -#include "base/basictypes.h" +#include <stddef.h> +#include <stdint.h> + #include "base/logging.h" #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/interception.h" @@ -152,8 +154,8 @@ bool ThreadProcessDispatcher::SetupService(InterceptionManager* manager, } bool ThreadProcessDispatcher::NtOpenThread(IPCInfo* ipc, - uint32 desired_access, - uint32 thread_id) { + uint32_t desired_access, + uint32_t thread_id) { HANDLE handle; NTSTATUS ret = ProcessPolicy::OpenThreadAction(*ipc->client_info, desired_access, thread_id, @@ -164,8 +166,8 @@ bool ThreadProcessDispatcher::NtOpenThread(IPCInfo* ipc, } bool ThreadProcessDispatcher::NtOpenProcess(IPCInfo* ipc, - uint32 desired_access, - uint32 process_id) { + uint32_t desired_access, + uint32_t process_id) { HANDLE handle; NTSTATUS ret = ProcessPolicy::OpenProcessAction(*ipc->client_info, desired_access, process_id, @@ -177,7 +179,7 @@ bool ThreadProcessDispatcher::NtOpenProcess(IPCInfo* ipc, bool ThreadProcessDispatcher::NtOpenProcessToken(IPCInfo* ipc, HANDLE process, - uint32 desired_access) { + uint32_t desired_access) { HANDLE handle; NTSTATUS ret = ProcessPolicy::OpenProcessTokenAction(*ipc->client_info, process, desired_access, @@ -189,8 +191,8 @@ bool ThreadProcessDispatcher::NtOpenProcessToken(IPCInfo* ipc, bool ThreadProcessDispatcher::NtOpenProcessTokenEx(IPCInfo* ipc, HANDLE process, - uint32 desired_access, - uint32 attributes) { + uint32_t desired_access, + uint32_t attributes) { HANDLE handle; NTSTATUS ret = ProcessPolicy::OpenProcessTokenExAction(*ipc->client_info, process, diff --git a/sandbox/win/src/process_thread_dispatcher.h b/sandbox/win/src/process_thread_dispatcher.h index 2bb3b6e..008385f 100644 --- a/sandbox/win/src/process_thread_dispatcher.h +++ b/sandbox/win/src/process_thread_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_PROCESS_THREAD_DISPATCHER_H_ #define SANDBOX_SRC_PROCESS_THREAD_DISPATCHER_H_ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -23,19 +25,23 @@ class ThreadProcessDispatcher : public Dispatcher { private: // Processes IPC requests coming from calls to NtOpenThread() in the target. - bool NtOpenThread(IPCInfo* ipc, uint32 desired_access, uint32 thread_id); + bool NtOpenThread(IPCInfo* ipc, uint32_t desired_access, uint32_t thread_id); // Processes IPC requests coming from calls to NtOpenProcess() in the target. - bool NtOpenProcess(IPCInfo* ipc, uint32 desired_access, uint32 process_id); + bool NtOpenProcess(IPCInfo* ipc, + uint32_t desired_access, + uint32_t process_id); // Processes IPC requests from calls to NtOpenProcessToken() in the target. - bool NtOpenProcessToken(IPCInfo* ipc, HANDLE process, uint32 desired_access); + bool NtOpenProcessToken(IPCInfo* ipc, + HANDLE process, + uint32_t desired_access); // Processes IPC requests from calls to NtOpenProcessTokenEx() in the target. bool NtOpenProcessTokenEx(IPCInfo* ipc, HANDLE process, - uint32 desired_access, - uint32 attributes); + uint32_t desired_access, + uint32_t attributes); // Processes IPC requests coming from calls to CreateProcessW() in the target. bool CreateProcessW(IPCInfo* ipc, diff --git a/sandbox/win/src/process_thread_interception.cc b/sandbox/win/src/process_thread_interception.cc index 2d459b6..bbf753e 100644 --- a/sandbox/win/src/process_thread_interception.cc +++ b/sandbox/win/src/process_thread_interception.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/process_thread_interception.h" +#include <stdint.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_params.h" @@ -34,7 +36,7 @@ NTSTATUS WINAPI TargetNtOpenThread(NtOpenThreadFunction orig_OpenThread, if (!client_id) break; - uint32 thread_id = 0; + uint32_t thread_id = 0; bool should_break = false; __try { // We support only the calls for the current process @@ -52,8 +54,8 @@ NTSTATUS WINAPI TargetNtOpenThread(NtOpenThreadFunction orig_OpenThread, } } - thread_id = static_cast<uint32>( - reinterpret_cast<ULONG_PTR>(client_id->UniqueThread)); + thread_id = static_cast<uint32_t>( + reinterpret_cast<ULONG_PTR>(client_id->UniqueThread)); } __except(EXCEPTION_EXECUTE_HANDLER) { break; } @@ -116,7 +118,7 @@ NTSTATUS WINAPI TargetNtOpenProcess(NtOpenProcessFunction orig_OpenProcess, if (!client_id) break; - uint32 process_id = 0; + uint32_t process_id = 0; bool should_break = false; __try { // Object attributes should be NULL or empty. @@ -130,8 +132,8 @@ NTSTATUS WINAPI TargetNtOpenProcess(NtOpenProcessFunction orig_OpenProcess, } } - process_id = static_cast<uint32>( - reinterpret_cast<ULONG_PTR>(client_id->UniqueProcess)); + process_id = static_cast<uint32_t>( + reinterpret_cast<ULONG_PTR>(client_id->UniqueProcess)); } __except(EXCEPTION_EXECUTE_HANDLER) { break; } diff --git a/sandbox/win/src/process_thread_policy.cc b/sandbox/win/src/process_thread_policy.cc index b58a287..b4976c0b 100644 --- a/sandbox/win/src/process_thread_policy.cc +++ b/sandbox/win/src/process_thread_policy.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/process_thread_policy.h" +#include <stdint.h> + #include <string> #include "base/memory/scoped_ptr.h" @@ -101,8 +103,8 @@ bool ProcessPolicy::GenerateRules(const wchar_t* name, } NTSTATUS ProcessPolicy::OpenThreadAction(const ClientInfo& client_info, - uint32 desired_access, - uint32 thread_id, + uint32_t desired_access, + uint32_t thread_id, HANDLE* handle) { *handle = NULL; @@ -132,8 +134,8 @@ NTSTATUS ProcessPolicy::OpenThreadAction(const ClientInfo& client_info, } NTSTATUS ProcessPolicy::OpenProcessAction(const ClientInfo& client_info, - uint32 desired_access, - uint32 process_id, + uint32_t desired_access, + uint32_t process_id, HANDLE* handle) { *handle = NULL; @@ -164,7 +166,7 @@ NTSTATUS ProcessPolicy::OpenProcessAction(const ClientInfo& client_info, NTSTATUS ProcessPolicy::OpenProcessTokenAction(const ClientInfo& client_info, HANDLE process, - uint32 desired_access, + uint32_t desired_access, HANDLE* handle) { *handle = NULL; NtOpenProcessTokenFunction NtOpenProcessToken = NULL; @@ -188,8 +190,8 @@ NTSTATUS ProcessPolicy::OpenProcessTokenAction(const ClientInfo& client_info, NTSTATUS ProcessPolicy::OpenProcessTokenExAction(const ClientInfo& client_info, HANDLE process, - uint32 desired_access, - uint32 attributes, + uint32_t desired_access, + uint32_t attributes, HANDLE* handle) { *handle = NULL; NtOpenProcessTokenExFunction NtOpenProcessTokenEx = NULL; diff --git a/sandbox/win/src/process_thread_policy.h b/sandbox/win/src/process_thread_policy.h index 2871dca..a66b52e 100644 --- a/sandbox/win/src/process_thread_policy.h +++ b/sandbox/win/src/process_thread_policy.h @@ -5,11 +5,12 @@ #ifndef SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ #define SANDBOX_SRC_PROCESS_THREAD_POLICY_H_ +#include <stdint.h> + #include <string> #include "sandbox/win/src/policy_low_level.h" -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy.h" @@ -36,16 +37,16 @@ class ProcessPolicy { // is the thread_id to be opened. // The function returns the return value of NtOpenThread. static NTSTATUS OpenThreadAction(const ClientInfo& client_info, - uint32 desired_access, - uint32 thread_id, + uint32_t desired_access, + uint32_t thread_id, HANDLE* handle); // Opens the process id passed in and returns the duplicated handle to // the child. We only allow the child processes to open themselves. Any other // pid open is denied. static NTSTATUS OpenProcessAction(const ClientInfo& client_info, - uint32 desired_access, - uint32 process_id, + uint32_t desired_access, + uint32_t process_id, HANDLE* handle); // Opens the token associated with the process and returns the duplicated @@ -53,7 +54,7 @@ class ProcessPolicy { // token (using ::GetCurrentProcess()). static NTSTATUS OpenProcessTokenAction(const ClientInfo& client_info, HANDLE process, - uint32 desired_access, + uint32_t desired_access, HANDLE* handle); // Opens the token associated with the process and returns the duplicated @@ -61,8 +62,8 @@ class ProcessPolicy { // token (using ::GetCurrentProcess()). static NTSTATUS OpenProcessTokenExAction(const ClientInfo& client_info, HANDLE process, - uint32 desired_access, - uint32 attributes, + uint32_t desired_access, + uint32_t attributes, HANDLE* handle); // Processes a 'CreateProcessW()' request from the target. diff --git a/sandbox/win/src/registry_dispatcher.cc b/sandbox/win/src/registry_dispatcher.cc index 267a592..fef727d 100644 --- a/sandbox/win/src/registry_dispatcher.cc +++ b/sandbox/win/src/registry_dispatcher.cc @@ -4,18 +4,20 @@ #include "sandbox/win/src/registry_dispatcher.h" +#include <stdint.h> + #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/interception.h" #include "sandbox/win/src/interceptors.h" #include "sandbox/win/src/ipc_tags.h" -#include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/policy_broker.h" #include "sandbox/win/src/policy_params.h" -#include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/registry_interception.h" #include "sandbox/win/src/registry_policy.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_nt_util.h" namespace { @@ -79,11 +81,11 @@ bool RegistryDispatcher::SetupService(InterceptionManager* manager, bool RegistryDispatcher::NtCreateKey(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, HANDLE root, - uint32 desired_access, - uint32 title_index, - uint32 create_options) { + uint32_t desired_access, + uint32_t title_index, + uint32_t create_options) { base::win::ScopedHandle root_handle; base::string16 real_path = *name; @@ -129,9 +131,9 @@ bool RegistryDispatcher::NtCreateKey(IPCInfo* ipc, bool RegistryDispatcher::NtOpenKey(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, HANDLE root, - uint32 desired_access) { + uint32_t desired_access) { base::win::ScopedHandle root_handle; base::string16 real_path = *name; diff --git a/sandbox/win/src/registry_dispatcher.h b/sandbox/win/src/registry_dispatcher.h index 83811a9..cb5af0c 100644 --- a/sandbox/win/src/registry_dispatcher.h +++ b/sandbox/win/src/registry_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_REGISTRY_DISPATCHER_H_ #define SANDBOX_SRC_REGISTRY_DISPATCHER_H_ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -25,18 +27,18 @@ class RegistryDispatcher : public Dispatcher { // Processes IPC requests coming from calls to NtCreateKey in the target. bool NtCreateKey(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, HANDLE root, - uint32 desired_access, - uint32 title_index, - uint32 create_options); + uint32_t desired_access, + uint32_t title_index, + uint32_t create_options); // Processes IPC requests coming from calls to NtOpenKey in the target. bool NtOpenKey(IPCInfo* ipc, base::string16* name, - uint32 attributes, + uint32_t attributes, HANDLE root, - uint32 desired_access); + uint32_t desired_access); PolicyBase* policy_base_; DISALLOW_COPY_AND_ASSIGN(RegistryDispatcher); diff --git a/sandbox/win/src/registry_interception.cc b/sandbox/win/src/registry_interception.cc index 4a1a846..e44099c 100644 --- a/sandbox/win/src/registry_interception.cc +++ b/sandbox/win/src/registry_interception.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/registry_interception.h" +#include <stdint.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_params.h" @@ -51,14 +53,14 @@ NTSTATUS WINAPI TargetNtCreateKey(NtCreateKeyFunction orig_CreateKey, break; wchar_t* name; - uint32 attributes = 0; + uint32_t attributes = 0; HANDLE root_directory = 0; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, &root_directory); if (!NT_SUCCESS(ret) || NULL == name) break; - uint32 desired_access_uint32 = desired_access; + uint32_t desired_access_uint32 = desired_access; CountedParameterSet<OpenKey> params; params[OpenKey::ACCESS] = ParamPickerMake(desired_access_uint32); @@ -133,14 +135,14 @@ NTSTATUS WINAPI CommonNtOpenKey(NTSTATUS status, PHANDLE key, break; wchar_t* name; - uint32 attributes; + uint32_t attributes; HANDLE root_directory; NTSTATUS ret = AllocAndCopyName(object_attributes, &name, &attributes, &root_directory); if (!NT_SUCCESS(ret) || NULL == name) break; - uint32 desired_access_uint32 = desired_access; + uint32_t desired_access_uint32 = desired_access; CountedParameterSet<OpenKey> params; params[OpenKey::ACCESS] = ParamPickerMake(desired_access_uint32); diff --git a/sandbox/win/src/registry_policy.cc b/sandbox/win/src/registry_policy.cc index 58e4e20..ec66380 100644 --- a/sandbox/win/src/registry_policy.cc +++ b/sandbox/win/src/registry_policy.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <string> #include "sandbox/win/src/registry_policy.h" @@ -10,13 +12,13 @@ #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_engine_opcodes.h" #include "sandbox/win/src/policy_params.h" -#include "sandbox/win/src/sandbox_utils.h" #include "sandbox/win/src/sandbox_types.h" +#include "sandbox/win/src/sandbox_utils.h" #include "sandbox/win/src/win_utils.h" namespace { -static const uint32 kAllowedRegFlags = +static const uint32_t kAllowedRegFlags = KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_READ | GENERIC_READ | GENERIC_EXECUTE | READ_CONTROL; @@ -137,7 +139,7 @@ bool RegistryPolicy::GenerateRules(const wchar_t* name, // We consider all flags that are not known to be readonly as potentially // used for write. Here we also support MAXIMUM_ALLOWED, but we are going // to expand it to read-only before the call. - uint32 restricted_flags = ~(kAllowedRegFlags | MAXIMUM_ALLOWED); + uint32_t restricted_flags = ~(kAllowedRegFlags | MAXIMUM_ALLOWED); open.AddNumberMatch(IF_NOT, OpenKey::ACCESS, restricted_flags, AND); create.AddNumberMatch(IF_NOT, OpenKey::ACCESS, restricted_flags, AND); break; @@ -166,12 +168,12 @@ bool RegistryPolicy::GenerateRules(const wchar_t* name, bool RegistryPolicy::CreateKeyAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &key, - uint32 attributes, + const base::string16& key, + uint32_t attributes, HANDLE root_directory, - uint32 desired_access, - uint32 title_index, - uint32 create_options, + uint32_t desired_access, + uint32_t title_index, + uint32_t create_options, HANDLE* handle, NTSTATUS* nt_status, ULONG* disposition) { @@ -200,10 +202,10 @@ bool RegistryPolicy::CreateKeyAction(EvalResult eval_result, bool RegistryPolicy::OpenKeyAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &key, - uint32 attributes, + const base::string16& key, + uint32_t attributes, HANDLE root_directory, - uint32 desired_access, + uint32_t desired_access, HANDLE* handle, NTSTATUS* nt_status) { // The only action supported is ASK_BROKER which means open the requested diff --git a/sandbox/win/src/registry_policy.h b/sandbox/win/src/registry_policy.h index 69af841..ddea1bf 100644 --- a/sandbox/win/src/registry_policy.h +++ b/sandbox/win/src/registry_policy.h @@ -5,9 +5,10 @@ #ifndef SANDBOX_SRC_REGISTRY_POLICY_H__ #define SANDBOX_SRC_REGISTRY_POLICY_H__ +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/nt_internals.h" @@ -31,12 +32,12 @@ class RegistryPolicy { // API that is compatible with the IPC-received parameters. static bool CreateKeyAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &key, - uint32 attributes, + const base::string16& key, + uint32_t attributes, HANDLE root_directory, - uint32 desired_access, - uint32 title_index, - uint32 create_options, + uint32_t desired_access, + uint32_t title_index, + uint32_t create_options, HANDLE* handle, NTSTATUS* nt_status, ULONG* disposition); @@ -44,13 +45,13 @@ class RegistryPolicy { // Performs the desired policy action on an open request with an // API that is compatible with the IPC-received parameters. static bool OpenKeyAction(EvalResult eval_result, - const ClientInfo& client_info, - const base::string16 &key, - uint32 attributes, - HANDLE root_directory, - uint32 desired_access, - HANDLE* handle, - NTSTATUS* nt_status); + const ClientInfo& client_info, + const base::string16& key, + uint32_t attributes, + HANDLE root_directory, + uint32_t desired_access, + HANDLE* handle, + NTSTATUS* nt_status); }; } // namespace sandbox diff --git a/sandbox/win/src/resolver.cc b/sandbox/win/src/resolver.cc index 6616fa5..d1719da 100644 --- a/sandbox/win/src/resolver.cc +++ b/sandbox/win/src/resolver.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/resolver.h" +#include <stddef.h> + #include "base/win/pe_image.h" #include "sandbox/win/src/sandbox_nt_util.h" diff --git a/sandbox/win/src/resolver.h b/sandbox/win/src/resolver.h index 85f1e91..9424060 100644 --- a/sandbox/win/src/resolver.h +++ b/sandbox/win/src/resolver.h @@ -6,7 +6,9 @@ // For more details see // http://dev.chromium.org/developers/design-documents/sandbox . -#include "base/basictypes.h" +#include <stddef.h> + +#include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #ifndef SANDBOX_SRC_RESOLVER_H__ diff --git a/sandbox/win/src/resolver_32.cc b/sandbox/win/src/resolver_32.cc index a591a8b..25df11c 100644 --- a/sandbox/win/src/resolver_32.cc +++ b/sandbox/win/src/resolver_32.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/resolver.h" +#include <stddef.h> + // For placement new. This file must not depend on the CRT at runtime, but // placement operator new is inline. #include <new> diff --git a/sandbox/win/src/resolver_64.cc b/sandbox/win/src/resolver_64.cc index f1f135e..6a99735 100644 --- a/sandbox/win/src/resolver_64.cc +++ b/sandbox/win/src/resolver_64.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/resolver.h" +#include <stddef.h> + // For placement new. This file must not depend on the CRT at runtime, but // placement operator new is inline. #include <new> diff --git a/sandbox/win/src/restricted_token.cc b/sandbox/win/src/restricted_token.cc index f0fc4cb..1940ae3 100644 --- a/sandbox/win/src/restricted_token.cc +++ b/sandbox/win/src/restricted_token.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/restricted_token.h" +#include <stddef.h> + #include <vector> #include "base/logging.h" diff --git a/sandbox/win/src/restricted_token.h b/sandbox/win/src/restricted_token.h index b9a2d4b..d302f86 100644 --- a/sandbox/win/src/restricted_token.h +++ b/sandbox/win/src/restricted_token.h @@ -8,7 +8,7 @@ #include <windows.h> #include <vector> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/restricted_token_utils.h" diff --git a/sandbox/win/src/sandbox.h b/sandbox/win/src/sandbox.h index e326194..193605d 100644 --- a/sandbox/win/src/sandbox.h +++ b/sandbox/win/src/sandbox.h @@ -21,7 +21,6 @@ #include <windows.h> -#include "base/basictypes.h" #include "sandbox/win/src/sandbox_policy.h" #include "sandbox/win/src/sandbox_types.h" diff --git a/sandbox/win/src/sandbox_factory.h b/sandbox/win/src/sandbox_factory.h index 7a0280f..f5888ff 100644 --- a/sandbox/win/src/sandbox_factory.h +++ b/sandbox/win/src/sandbox_factory.h @@ -5,6 +5,7 @@ #ifndef SANDBOX_SRC_SANDBOX_FACTORY_H__ #define SANDBOX_SRC_SANDBOX_FACTORY_H__ +#include "base/macros.h" #include "sandbox/win/src/sandbox.h" // SandboxFactory is a set of static methods to get access to the broker diff --git a/sandbox/win/src/sandbox_nt_util.cc b/sandbox/win/src/sandbox_nt_util.cc index 35b9e73..62f2422 100644 --- a/sandbox/win/src/sandbox_nt_util.cc +++ b/sandbox/win/src/sandbox_nt_util.cc @@ -4,6 +4,9 @@ #include "sandbox/win/src/sandbox_nt_util.h" +#include <stddef.h> +#include <stdint.h> + #include <string> #include "base/win/pe_image.h" diff --git a/sandbox/win/src/sandbox_nt_util.h b/sandbox/win/src/sandbox_nt_util.h index 17e5027..3e02382 100644 --- a/sandbox/win/src/sandbox_nt_util.h +++ b/sandbox/win/src/sandbox_nt_util.h @@ -6,6 +6,7 @@ #define SANDBOX_SRC_SANDBOX_NT_UTIL_H_ #include <intrin.h> +#include <stddef.h> #include <stdint.h> #include "base/macros.h" diff --git a/sandbox/win/src/sandbox_policy.h b/sandbox/win/src/sandbox_policy.h index 0c3e847..cc39c62 100644 --- a/sandbox/win/src/sandbox_policy.h +++ b/sandbox/win/src/sandbox_policy.h @@ -5,9 +5,11 @@ #ifndef SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ #define SANDBOX_WIN_SRC_SANDBOX_POLICY_H_ +#include <stddef.h> +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/sandbox_types.h" #include "sandbox/win/src/security_level.h" @@ -130,7 +132,8 @@ class TargetPolicy { // http://msdn2.microsoft.com/en-us/library/ms684152.aspx // // Note: the recommended level is JOB_RESTRICTED or JOB_LOCKDOWN. - virtual ResultCode SetJobLevel(JobLevel job_level, uint32 ui_exceptions) = 0; + virtual ResultCode SetJobLevel(JobLevel job_level, + uint32_t ui_exceptions) = 0; // Sets a hard limit on the size of the commit set for the sandboxed process. // If the limit is reached, the process will be terminated with diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc index bcb7587..28662b4 100644 --- a/sandbox/win/src/sandbox_policy_base.cc +++ b/sandbox/win/src/sandbox_policy_base.cc @@ -5,8 +5,9 @@ #include "sandbox/win/src/sandbox_policy_base.h" #include <sddl.h> +#include <stddef.h> +#include <stdint.h> -#include "base/basictypes.h" #include "base/callback.h" #include "base/logging.h" #include "base/macros.h" @@ -182,7 +183,7 @@ TokenLevel PolicyBase::GetLockdownTokenLevel() const{ return lockdown_level_; } -ResultCode PolicyBase::SetJobLevel(JobLevel job_level, uint32 ui_exceptions) { +ResultCode PolicyBase::SetJobLevel(JobLevel job_level, uint32_t ui_exceptions) { if (memory_limit_ && job_level == JOB_NONE) { return SBOX_ERROR_BAD_PARAMS; } diff --git a/sandbox/win/src/sandbox_policy_base.h b/sandbox/win/src/sandbox_policy_base.h index 751b0d8..b2d1b7c 100644 --- a/sandbox/win/src/sandbox_policy_base.h +++ b/sandbox/win/src/sandbox_policy_base.h @@ -6,12 +6,14 @@ #define SANDBOX_WIN_SRC_SANDBOX_POLICY_BASE_H_ #include <windows.h> +#include <stddef.h> +#include <stdint.h> #include <list> #include <vector> -#include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "base/win/scoped_handle.h" @@ -42,7 +44,7 @@ class PolicyBase final : public TargetPolicy { ResultCode SetTokenLevel(TokenLevel initial, TokenLevel lockdown) override; TokenLevel GetInitialTokenLevel() const override; TokenLevel GetLockdownTokenLevel() const override; - ResultCode SetJobLevel(JobLevel job_level, uint32 ui_exceptions) override; + ResultCode SetJobLevel(JobLevel job_level, uint32_t ui_exceptions) override; ResultCode SetJobMemoryLimit(size_t memory_limit) override; ResultCode SetAlternateDesktop(bool alternate_winstation) override; base::string16 GetAlternateDesktop() const override; @@ -129,7 +131,7 @@ class PolicyBase final : public TargetPolicy { TokenLevel lockdown_level_; TokenLevel initial_level_; JobLevel job_level_; - uint32 ui_exceptions_; + uint32_t ui_exceptions_; size_t memory_limit_; bool use_alternate_desktop_; bool use_alternate_winstation_; diff --git a/sandbox/win/src/sandbox_rand.h b/sandbox/win/src/sandbox_rand.h index 7f48287..7c4febc 100644 --- a/sandbox/win/src/sandbox_rand.h +++ b/sandbox/win/src/sandbox_rand.h @@ -5,7 +5,6 @@ #ifndef SANDBOX_SRC_SANDBOX_RAND_H_ #define SANDBOX_SRC_SANDBOX_RAND_H_ -#include "base/basictypes.h" namespace sandbox { diff --git a/sandbox/win/src/sandbox_utils.h b/sandbox/win/src/sandbox_utils.h index fc3100d..b1c1f31 100644 --- a/sandbox/win/src/sandbox_utils.h +++ b/sandbox/win/src/sandbox_utils.h @@ -8,7 +8,6 @@ #include <windows.h> #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/nt_internals.h" diff --git a/sandbox/win/src/security_level.h b/sandbox/win/src/security_level.h index c89bbb4..26ec306 100644 --- a/sandbox/win/src/security_level.h +++ b/sandbox/win/src/security_level.h @@ -5,7 +5,7 @@ #ifndef SANDBOX_SRC_SECURITY_LEVEL_H_ #define SANDBOX_SRC_SECURITY_LEVEL_H_ -#include "base/basictypes.h" +#include <stdint.h> namespace sandbox { @@ -138,7 +138,7 @@ enum JobLevel { // Flags that are unsupported for the target OS will be silently ignored. // Flags that are invalid for their application (pre or post startup) will // return SBOX_ERROR_BAD_PARAMS. -typedef uint64 MitigationFlags; +typedef uint64_t MitigationFlags; // Permanently enables DEP for the target process. Corresponds to // PROCESS_CREATION_MITIGATION_POLICY_DEP_ENABLE. diff --git a/sandbox/win/src/service_resolver.h b/sandbox/win/src/service_resolver.h index 08a45ba..7ac5a24 100644 --- a/sandbox/win/src/service_resolver.h +++ b/sandbox/win/src/service_resolver.h @@ -5,6 +5,8 @@ #ifndef SANDBOX_SRC_SERVICE_RESOLVER_H__ #define SANDBOX_SRC_SERVICE_RESOLVER_H__ +#include <stddef.h> + #include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/resolver.h" diff --git a/sandbox/win/src/service_resolver_32.cc b/sandbox/win/src/service_resolver_32.cc index b0c6ca6..4fc96d3 100644 --- a/sandbox/win/src/service_resolver_32.cc +++ b/sandbox/win/src/service_resolver_32.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/service_resolver.h" +#include <stddef.h> + #include "base/memory/scoped_ptr.h" #include "sandbox/win/src/win_utils.h" diff --git a/sandbox/win/src/service_resolver_64.cc b/sandbox/win/src/service_resolver_64.cc index 8dcea7d..25ee9db 100644 --- a/sandbox/win/src/service_resolver_64.cc +++ b/sandbox/win/src/service_resolver_64.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/service_resolver.h" +#include <stddef.h> + #include "base/memory/scoped_ptr.h" #include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/win_utils.h" diff --git a/sandbox/win/src/service_resolver_unittest.cc b/sandbox/win/src/service_resolver_unittest.cc index 2ae3e47..421b814 100644 --- a/sandbox/win/src/service_resolver_unittest.cc +++ b/sandbox/win/src/service_resolver_unittest.cc @@ -4,7 +4,9 @@ // This file contains unit tests for ServiceResolverThunk. -#include "base/basictypes.h" +#include <stddef.h> + +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/win/windows_version.h" #include "sandbox/win/src/resolver.h" diff --git a/sandbox/win/src/sharedmem_ipc_client.cc b/sandbox/win/src/sharedmem_ipc_client.cc index 8f79109..eac1393 100644 --- a/sandbox/win/src/sharedmem_ipc_client.cc +++ b/sandbox/win/src/sharedmem_ipc_client.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> #include <string.h> -#include "sandbox/win/src/sharedmem_ipc_client.h" -#include "sandbox/win/src/sandbox.h" + +#include "base/logging.h" #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/crosscall_params.h" -#include "base/logging.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sharedmem_ipc_client.h" namespace sandbox { diff --git a/sandbox/win/src/sharedmem_ipc_client.h b/sandbox/win/src/sharedmem_ipc_client.h index 9eec74a..67fd063 100644 --- a/sandbox/win/src/sharedmem_ipc_client.h +++ b/sandbox/win/src/sharedmem_ipc_client.h @@ -5,6 +5,9 @@ #ifndef SANDBOX_SRC_SHAREDMEM_IPC_CLIENT_H__ #define SANDBOX_SRC_SHAREDMEM_IPC_CLIENT_H__ +#include <stddef.h> +#include <stdint.h> + #include "sandbox/win/src/crosscall_params.h" #include "sandbox/win/src/sandbox.h" @@ -81,7 +84,7 @@ struct ChannelControl { // the client waits on the pong event for the IPC answer back HANDLE pong_event; // the IPC unique identifier - uint32 ipc_tag; + uint32_t ipc_tag; }; struct IPCControl { diff --git a/sandbox/win/src/sharedmem_ipc_server.cc b/sandbox/win/src/sharedmem_ipc_server.cc index ea1793c..cf2d800 100644 --- a/sandbox/win/src/sharedmem_ipc_server.cc +++ b/sandbox/win/src/sharedmem_ipc_server.cc @@ -2,16 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "base/callback.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" -#include "sandbox/win/src/sharedmem_ipc_server.h" -#include "sandbox/win/src/sharedmem_ipc_client.h" -#include "sandbox/win/src/sandbox.h" -#include "sandbox/win/src/sandbox_types.h" #include "sandbox/win/src/crosscall_params.h" #include "sandbox/win/src/crosscall_server.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_types.h" +#include "sandbox/win/src/sharedmem_ipc_client.h" +#include "sandbox/win/src/sharedmem_ipc_server.h" namespace { // This handle must not be closed. @@ -62,8 +65,9 @@ SharedMemIPCServer::~SharedMemIPCServer() { ::UnmapViewOfFile(client_control_); } -bool SharedMemIPCServer::Init(void* shared_mem, uint32 shared_size, - uint32 channel_size) { +bool SharedMemIPCServer::Init(void* shared_mem, + uint32_t shared_size, + uint32_t channel_size) { // The shared memory needs to be at least as big as a channel. if (shared_size < channel_size) { return false; @@ -163,8 +167,8 @@ bool GetArgs(CrossCallParamsEx* params, IPCParams* ipc_params, if (kMaxIpcParams < params->GetParamsCount()) return false; - for (uint32 i = 0; i < params->GetParamsCount(); i++) { - uint32 size; + for (uint32_t i = 0; i < params->GetParamsCount(); i++) { + uint32_t size; ArgType type; args[i] = params->GetRawParameter(i, &size, &type); if (args[i]) { @@ -181,7 +185,7 @@ bool GetArgs(CrossCallParamsEx* params, IPCParams* ipc_params, break; } case UINT32_TYPE: { - uint32 data; + uint32_t data; if (!params->GetParameter32(i, &data)) { ReleaseArgs(ipc_params, args); return false; @@ -220,7 +224,7 @@ bool SharedMemIPCServer::InvokeCallback(const ServerControl* service_context, CrossCallReturn* call_result) { // Set the default error code; SetCallError(SBOX_ERROR_INVALID_IPC, call_result); - uint32 output_size = 0; + uint32_t output_size = 0; // Parse, verify and copy the message. The handler operates on a copy // of the message so the client cannot play dirty tricks by changing the // data in the channel while the IPC is being processed. @@ -231,7 +235,7 @@ bool SharedMemIPCServer::InvokeCallback(const ServerControl* service_context, if (!params.get()) return false; - uint32 tag = params->GetTag(); + uint32_t tag = params->GetTag(); static_assert(0 == INVALID_TYPE, "incorrect type enum"); IPCParams ipc_params = {0}; ipc_params.ipc_tag = tag; diff --git a/sandbox/win/src/sharedmem_ipc_server.h b/sandbox/win/src/sharedmem_ipc_server.h index cb40bca..5afca1d 100644 --- a/sandbox/win/src/sharedmem_ipc_server.h +++ b/sandbox/win/src/sharedmem_ipc_server.h @@ -5,10 +5,12 @@ #ifndef SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ #define SANDBOX_SRC_SHAREDMEM_IPC_SERVER_H_ +#include <stdint.h> + #include <list> -#include "base/basictypes.h" #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/win/scoped_handle.h" #include "sandbox/win/src/crosscall_params.h" #include "sandbox/win/src/crosscall_server.h" @@ -53,7 +55,7 @@ class SharedMemIPCServer { // Initializes the server structures, shared memory structures and // creates the kernels events used to signal the IPC. - bool Init(void* shared_mem, uint32 shared_size, uint32 channel_size); + bool Init(void* shared_mem, uint32_t shared_size, uint32_t channel_size); private: // Allow tests to be marked DISABLED_. Note that FLAKY_ and FAILS_ prefixes @@ -85,7 +87,7 @@ class SharedMemIPCServer { // This channel server pong event. base::win::ScopedHandle pong_event; // The size of this channel. - uint32 channel_size; + uint32_t channel_size; // The pointer to the actual channel data. char* channel_buffer; // The pointer to the base of the shared memory. diff --git a/sandbox/win/src/sidestep/preamble_patcher_with_stub.cpp b/sandbox/win/src/sidestep/preamble_patcher_with_stub.cpp index 999d76b..b501600 100644 --- a/sandbox/win/src/sidestep/preamble_patcher_with_stub.cpp +++ b/sandbox/win/src/sidestep/preamble_patcher_with_stub.cpp @@ -6,6 +6,8 @@ #include "sandbox/win/src/sidestep/preamble_patcher.h" +#include <stddef.h> + #include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/sidestep/mini_disassembler.h" diff --git a/sandbox/win/src/sidestep_resolver.cc b/sandbox/win/src/sidestep_resolver.cc index 828c000..d5da2fb 100644 --- a/sandbox/win/src/sidestep_resolver.cc +++ b/sandbox/win/src/sidestep_resolver.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/sidestep_resolver.h" +#include <stddef.h> + #include "base/win/pe_image.h" #include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/sidestep/preamble_patcher.h" diff --git a/sandbox/win/src/sidestep_resolver.h b/sandbox/win/src/sidestep_resolver.h index cf03d6e..8088272 100644 --- a/sandbox/win/src/sidestep_resolver.h +++ b/sandbox/win/src/sidestep_resolver.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_SIDESTEP_RESOLVER_H__ #define SANDBOX_SRC_SIDESTEP_RESOLVER_H__ -#include "base/basictypes.h" +#include <stddef.h> + +#include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/resolver.h" diff --git a/sandbox/win/src/sync_dispatcher.cc b/sandbox/win/src/sync_dispatcher.cc index a638d3d..2e5d1c5 100644 --- a/sandbox/win/src/sync_dispatcher.cc +++ b/sandbox/win/src/sync_dispatcher.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/sync_dispatcher.h" +#include <stdint.h> + #include "base/win/windows_version.h" #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/interception.h" @@ -42,8 +44,8 @@ bool SyncDispatcher::SetupService(InterceptionManager* manager, bool SyncDispatcher::CreateEvent(IPCInfo* ipc, base::string16* name, - uint32 event_type, - uint32 initial_state) { + uint32_t event_type, + uint32_t initial_state) { const wchar_t* event_name = name->c_str(); CountedParameterSet<NameBased> params; params[NameBased::NAME] = ParamPickerMake(event_name); @@ -60,7 +62,7 @@ bool SyncDispatcher::CreateEvent(IPCInfo* ipc, bool SyncDispatcher::OpenEvent(IPCInfo* ipc, base::string16* name, - uint32 desired_access) { + uint32_t desired_access) { const wchar_t* event_name = name->c_str(); CountedParameterSet<OpenEventParams> params; diff --git a/sandbox/win/src/sync_dispatcher.h b/sandbox/win/src/sync_dispatcher.h index 29c6c1e..8a2a0e5 100644 --- a/sandbox/win/src/sync_dispatcher.h +++ b/sandbox/win/src/sync_dispatcher.h @@ -5,7 +5,9 @@ #ifndef SANDBOX_SRC_SYNC_DISPATCHER_H_ #define SANDBOX_SRC_SYNC_DISPATCHER_H_ -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/sandbox_policy_base.h" @@ -23,13 +25,13 @@ class SyncDispatcher : public Dispatcher { private: // Processes IPC requests coming from calls to CreateEvent in the target. - bool CreateEvent(IPCInfo* ipc, - base::string16* name, - uint32 event_type, - uint32 initial_state); + bool CreateEvent(IPCInfo* ipc, + base::string16* name, + uint32_t event_type, + uint32_t initial_state); // Processes IPC requests coming from calls to OpenEvent in the target. - bool OpenEvent(IPCInfo* ipc, base::string16* name, uint32 desired_access); + bool OpenEvent(IPCInfo* ipc, base::string16* name, uint32_t desired_access); PolicyBase* policy_base_; DISALLOW_COPY_AND_ASSIGN(SyncDispatcher); diff --git a/sandbox/win/src/sync_interception.cc b/sandbox/win/src/sync_interception.cc index da612a5..420d185 100644 --- a/sandbox/win/src/sync_interception.cc +++ b/sandbox/win/src/sync_interception.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/sync_interception.h" +#include <stdint.h> + #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/ipc_tags.h" #include "sandbox/win/src/policy_params.h" @@ -16,7 +18,7 @@ namespace sandbox { ResultCode ProxyCreateEvent(LPCWSTR name, - uint32 initial_state, + uint32_t initial_state, EVENT_TYPE event_type, void* ipc_memory, CrossCallReturn* answer) { @@ -33,7 +35,7 @@ ResultCode ProxyCreateEvent(LPCWSTR name, } ResultCode ProxyOpenEvent(LPCWSTR name, - uint32 desired_access, + uint32_t desired_access, void* ipc_memory, CrossCallReturn* answer) { CountedParameterSet<OpenEventParams> params; @@ -79,7 +81,7 @@ NTSTATUS WINAPI TargetNtCreateEvent(NtCreateEventFunction orig_CreateEvent, object_attribs_copy.RootDirectory = NULL; wchar_t* name = NULL; - uint32 attributes = 0; + uint32_t attributes = 0; NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || name == NULL) @@ -132,7 +134,7 @@ NTSTATUS WINAPI TargetNtOpenEvent(NtOpenEventFunction orig_OpenEvent, object_attribs_copy.RootDirectory = NULL; wchar_t* name = NULL; - uint32 attributes = 0; + uint32_t attributes = 0; NTSTATUS ret = AllocAndCopyName(&object_attribs_copy, &name, &attributes, NULL); if (!NT_SUCCESS(ret) || name == NULL) diff --git a/sandbox/win/src/sync_policy.cc b/sandbox/win/src/sync_policy.cc index 379e8f4..7ef094f 100644 --- a/sandbox/win/src/sync_policy.cc +++ b/sandbox/win/src/sync_policy.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <string> #include "sandbox/win/src/sync_policy.h" @@ -145,8 +147,8 @@ bool SyncPolicy::GenerateRules(const wchar_t* name, if (TargetPolicy::EVENTS_ALLOW_READONLY == semantics) { // We consider all flags that are not known to be readonly as potentially // used for write. - uint32 allowed_flags = SYNCHRONIZE | GENERIC_READ | READ_CONTROL; - uint32 restricted_flags = ~allowed_flags; + uint32_t allowed_flags = SYNCHRONIZE | GENERIC_READ | READ_CONTROL; + uint32_t restricted_flags = ~allowed_flags; open.AddNumberMatch(IF_NOT, OpenEventParams::ACCESS, restricted_flags, AND); } @@ -168,10 +170,10 @@ bool SyncPolicy::GenerateRules(const wchar_t* name, NTSTATUS SyncPolicy::CreateEventAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &event_name, - uint32 event_type, - uint32 initial_state, - HANDLE *handle) { + const base::string16& event_name, + uint32_t event_type, + uint32_t initial_state, + HANDLE* handle) { NtCreateEventFunction NtCreateEvent = NULL; ResolveNTFunctionPtr("NtCreateEvent", &NtCreateEvent); @@ -207,9 +209,9 @@ NTSTATUS SyncPolicy::CreateEventAction(EvalResult eval_result, NTSTATUS SyncPolicy::OpenEventAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &event_name, - uint32 desired_access, - HANDLE *handle) { + const base::string16& event_name, + uint32_t desired_access, + HANDLE* handle) { NtOpenEventFunction NtOpenEvent = NULL; ResolveNTFunctionPtr("NtOpenEvent", &NtOpenEvent); diff --git a/sandbox/win/src/sync_policy.h b/sandbox/win/src/sync_policy.h index e370e4b..24e5c7d 100644 --- a/sandbox/win/src/sync_policy.h +++ b/sandbox/win/src/sync_policy.h @@ -5,9 +5,10 @@ #ifndef SANDBOX_SRC_SYNC_POLICY_H__ #define SANDBOX_SRC_SYNC_POLICY_H__ +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/strings/string16.h" #include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/nt_internals.h" @@ -35,15 +36,15 @@ class SyncPolicy { // eval_result is the desired policy action to accomplish. static NTSTATUS CreateEventAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &event_name, - uint32 event_type, - uint32 initial_state, - HANDLE *handle); + const base::string16& event_name, + uint32_t event_type, + uint32_t initial_state, + HANDLE* handle); static NTSTATUS OpenEventAction(EvalResult eval_result, const ClientInfo& client_info, - const base::string16 &event_name, - uint32 desired_access, - HANDLE *handle); + const base::string16& event_name, + uint32_t desired_access, + HANDLE* handle); }; } // namespace sandbox diff --git a/sandbox/win/src/target_process.cc b/sandbox/win/src/target_process.cc index 8645e75..e27655e 100644 --- a/sandbox/win/src/target_process.cc +++ b/sandbox/win/src/target_process.cc @@ -4,14 +4,16 @@ #include "sandbox/win/src/target_process.h" -#include "base/basictypes.h" +#include <stddef.h> +#include <stdint.h> + #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/win/pe_image.h" #include "base/win/startup_information.h" #include "base/win/windows_version.h" -#include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/crosscall_client.h" +#include "sandbox/win/src/crosscall_server.h" #include "sandbox/win/src/policy_low_level.h" #include "sandbox/win/src/sandbox_types.h" #include "sandbox/win/src/sharedmem_ipc_server.h" @@ -266,8 +268,10 @@ ResultCode TargetProcess::TransferVariable(const char* name, void* address, // Construct the IPC server and the IPC dispatcher. When the target does // an IPC it will eventually call the dispatcher. -DWORD TargetProcess::Init(Dispatcher* ipc_dispatcher, void* policy, - uint32 shared_IPC_size, uint32 shared_policy_size) { +DWORD TargetProcess::Init(Dispatcher* ipc_dispatcher, + void* policy, + uint32_t shared_IPC_size, + uint32_t shared_policy_size) { // We need to map the shared memory on the target. This is necessary for // any IPC that needs to take place, even if the target has not yet hit // the main( ) function or even has initialized the CRT. So here we set diff --git a/sandbox/win/src/target_process.h b/sandbox/win/src/target_process.h index 59e6aea..c00f2ce 100644 --- a/sandbox/win/src/target_process.h +++ b/sandbox/win/src/target_process.h @@ -6,8 +6,10 @@ #define SANDBOX_WIN_SRC_TARGET_PROCESS_H_ #include <windows.h> +#include <stddef.h> +#include <stdint.h> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/win/scoped_handle.h" #include "base/win/scoped_process_information.h" @@ -60,8 +62,10 @@ class TargetProcess { // Creates the IPC objects such as the BrokerDispatcher and the // IPC server. The IPC server uses the services of the thread_pool. - DWORD Init(Dispatcher* ipc_dispatcher, void* policy, - uint32 shared_IPC_size, uint32 shared_policy_size); + DWORD Init(Dispatcher* ipc_dispatcher, + void* policy, + uint32_t shared_IPC_size, + uint32_t shared_policy_size); // Returns the handle to the target process. HANDLE Process() const { diff --git a/sandbox/win/src/target_services.cc b/sandbox/win/src/target_services.cc index e10f7ca..7537245 100644 --- a/sandbox/win/src/target_services.cc +++ b/sandbox/win/src/target_services.cc @@ -7,8 +7,8 @@ #include <new> #include <process.h> +#include <stdint.h> -#include "base/basictypes.h" #include "base/win/windows_version.h" #include "sandbox/win/src/crosscall_client.h" #include "sandbox/win/src/handle_closer_agent.h" @@ -17,9 +17,9 @@ #include "sandbox/win/src/process_mitigations.h" #include "sandbox/win/src/restricted_token_utils.h" #include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_nt_util.h" #include "sandbox/win/src/sandbox_types.h" #include "sandbox/win/src/sharedmem_ipc_client.h" -#include "sandbox/win/src/sandbox_nt_util.h" namespace { @@ -168,8 +168,8 @@ bool TargetServicesBase::TestIPCPing(int version) { CrossCallReturn answer = {0}; if (1 == version) { - uint32 tick1 = ::GetTickCount(); - uint32 cookie = 717115; + uint32_t tick1 = ::GetTickCount(); + uint32_t cookie = 717115; ResultCode code = CrossCall(ipc, IPC_PING1_TAG, cookie, &answer); if (SBOX_ALL_OK != code) { @@ -182,7 +182,7 @@ bool TargetServicesBase::TestIPCPing(int version) { } // We test the first extended answer to be within the bounds of the tick // count only if there was no tick count wraparound. - uint32 tick2 = ::GetTickCount(); + uint32_t tick2 = ::GetTickCount(); if (tick2 >= tick1) { if ((answer.extended[0].unsigned_int < tick1) || (answer.extended[0].unsigned_int > tick2)) { @@ -194,7 +194,7 @@ bool TargetServicesBase::TestIPCPing(int version) { return false; } } else if (2 == version) { - uint32 cookie = 717111; + uint32_t cookie = 717111; InOutCountedBuffer counted_buffer(&cookie, sizeof(cookie)); ResultCode code = CrossCall(ipc, IPC_PING2_TAG, counted_buffer, &answer); diff --git a/sandbox/win/src/target_services.h b/sandbox/win/src/target_services.h index c80a90d..3716948 100644 --- a/sandbox/win/src/target_services.h +++ b/sandbox/win/src/target_services.h @@ -5,7 +5,7 @@ #ifndef SANDBOX_SRC_TARGET_SERVICES_H__ #define SANDBOX_SRC_TARGET_SERVICES_H__ -#include "base/basictypes.h" +#include "base/macros.h" #include "sandbox/win/src/sandbox.h" #include "sandbox/win/src/win_utils.h" diff --git a/sandbox/win/src/threadpool_unittest.cc b/sandbox/win/src/threadpool_unittest.cc index 4f3b0df..d32fdda 100644 --- a/sandbox/win/src/threadpool_unittest.cc +++ b/sandbox/win/src/threadpool_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include "sandbox/win/src/win2k_threadpool.h" #include "testing/gtest/include/gtest/gtest.h" @@ -24,7 +26,7 @@ TEST(IPCTest, ThreadPoolRegisterTest1) { HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL); HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL); - uint32 context = 0; + uint32_t context = 0; EXPECT_FALSE(thread_pool.RegisterWait(0, event1, EmptyCallBack, &context)); EXPECT_EQ(0u, thread_pool.OutstandingWaits()); @@ -47,9 +49,9 @@ TEST(IPCTest, ThreadPoolRegisterTest2) { HANDLE event1 = ::CreateEventW(NULL, FALSE, FALSE, NULL); HANDLE event2 = ::CreateEventW(NULL, FALSE, FALSE, NULL); - uint32 context = 0; - uint32 c1 = 0; - uint32 c2 = 0; + uint32_t context = 0; + uint32_t c1 = 0; + uint32_t c2 = 0; EXPECT_TRUE(thread_pool.RegisterWait(&c1, event1, EmptyCallBack, &context)); EXPECT_EQ(1u, thread_pool.OutstandingWaits()); diff --git a/sandbox/win/src/top_level_dispatcher.cc b/sandbox/win/src/top_level_dispatcher.cc index 19a5f05..e6e224b 100644 --- a/sandbox/win/src/top_level_dispatcher.cc +++ b/sandbox/win/src/top_level_dispatcher.cc @@ -4,9 +4,9 @@ #include "sandbox/win/src/top_level_dispatcher.h" +#include <stdint.h> #include <string.h> -#include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "sandbox/win/src/crosscall_server.h" @@ -116,7 +116,7 @@ bool TopLevelDispatcher::Ping(IPCInfo* ipc, void* arg1) { switch (ipc->ipc_tag) { case IPC_PING1_TAG: { IPCInt ipc_int(arg1); - uint32 cookie = ipc_int.As32Bit(); + uint32_t cookie = ipc_int.As32Bit(); ipc->return_info.extended_count = 2; ipc->return_info.extended[0].unsigned_int = ::GetTickCount(); ipc->return_info.extended[1].unsigned_int = 2 * cookie; @@ -124,10 +124,10 @@ bool TopLevelDispatcher::Ping(IPCInfo* ipc, void* arg1) { } case IPC_PING2_TAG: { CountedBuffer* io_buffer = reinterpret_cast<CountedBuffer*>(arg1); - if (sizeof(uint32) != io_buffer->Size()) + if (sizeof(uint32_t) != io_buffer->Size()) return false; - uint32* cookie = reinterpret_cast<uint32*>(io_buffer->Buffer()); + uint32_t* cookie = reinterpret_cast<uint32_t*>(io_buffer->Buffer()); *cookie = (*cookie) * 3; return true; } diff --git a/sandbox/win/src/win2k_threadpool.cc b/sandbox/win/src/win2k_threadpool.cc index 051cfc1..35de38a 100644 --- a/sandbox/win/src/win2k_threadpool.cc +++ b/sandbox/win/src/win2k_threadpool.cc @@ -4,6 +4,8 @@ #include "sandbox/win/src/win2k_threadpool.h" +#include <stddef.h> + #include "sandbox/win/src/win_utils.h" namespace sandbox { diff --git a/sandbox/win/src/win2k_threadpool.h b/sandbox/win/src/win2k_threadpool.h index be2791f..c4d539d 100644 --- a/sandbox/win/src/win2k_threadpool.h +++ b/sandbox/win/src/win2k_threadpool.h @@ -5,8 +5,11 @@ #ifndef SANDBOX_SRC_WIN2K_THREADPOOL_H_ #define SANDBOX_SRC_WIN2K_THREADPOOL_H_ -#include <list> +#include <stddef.h> + #include <algorithm> +#include <list> +#include "base/macros.h" #include "sandbox/win/src/crosscall_server.h" namespace sandbox { diff --git a/sandbox/win/src/win_utils.cc b/sandbox/win/src/win_utils.cc index e09c680..3717a97 100644 --- a/sandbox/win/src/win_utils.cc +++ b/sandbox/win/src/win_utils.cc @@ -4,8 +4,11 @@ #include "sandbox/win/src/win_utils.h" +#include <stddef.h> + #include <map> +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/win/pe_image.h" diff --git a/sandbox/win/src/win_utils.h b/sandbox/win/src/win_utils.h index bf3ed84..f7895c1 100644 --- a/sandbox/win/src/win_utils.h +++ b/sandbox/win/src/win_utils.h @@ -6,9 +6,10 @@ #define SANDBOX_SRC_WIN_UTILS_H_ #include <windows.h> +#include <stddef.h> #include <string> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/strings/string16.h" namespace sandbox { diff --git a/sandbox/win/tests/common/test_utils.cc b/sandbox/win/tests/common/test_utils.cc index cdd86de..4ec47bc 100644 --- a/sandbox/win/tests/common/test_utils.cc +++ b/sandbox/win/tests/common/test_utils.cc @@ -4,6 +4,7 @@ #include "sandbox/win/tests/common/test_utils.h" +#include <stddef.h> #include <winioctl.h> typedef struct _REPARSE_DATA_BUFFER { diff --git a/sandbox/win/tests/integration_tests/integration_tests_test.cc b/sandbox/win/tests/integration_tests/integration_tests_test.cc index 44055d3..4acadb9 100644 --- a/sandbox/win/tests/integration_tests/integration_tests_test.cc +++ b/sandbox/win/tests/integration_tests/integration_tests_test.cc @@ -4,11 +4,13 @@ // Some tests for the framework itself. -#include "testing/gtest/include/gtest/gtest.h" +#include <stddef.h> + #include "sandbox/win/src/sandbox.h" -#include "sandbox/win/src/target_services.h" #include "sandbox/win/src/sandbox_factory.h" +#include "sandbox/win/src/target_services.h" #include "sandbox/win/tests/common/controller.h" +#include "testing/gtest/include/gtest/gtest.h" namespace sandbox { diff --git a/sandbox/win/tests/validation_tests/commands.cc b/sandbox/win/tests/validation_tests/commands.cc index 10a4a13..f0c8828 100644 --- a/sandbox/win/tests/validation_tests/commands.cc +++ b/sandbox/win/tests/validation_tests/commands.cc @@ -4,6 +4,7 @@ #include <Aclapi.h> #include <windows.h> +#include <stddef.h> #include <string> #include "sandbox/win/tests/validation_tests/commands.h" diff --git a/sandbox/win/tests/validation_tests/suite.cc b/sandbox/win/tests/validation_tests/suite.cc index df2cb3e..9fe25ce 100644 --- a/sandbox/win/tests/validation_tests/suite.cc +++ b/sandbox/win/tests/validation_tests/suite.cc @@ -7,10 +7,11 @@ // sandbox. #include <shlwapi.h> +#include <stddef.h> #include "base/win/windows_version.h" -#include "testing/gtest/include/gtest/gtest.h" #include "sandbox/win/tests/common/controller.h" +#include "testing/gtest/include/gtest/gtest.h" #pragma comment(lib, "shlwapi.lib") diff --git a/sandbox/win/wow_helper/service64_resolver.cc b/sandbox/win/wow_helper/service64_resolver.cc index 033b9d7..32c9829 100644 --- a/sandbox/win/wow_helper/service64_resolver.cc +++ b/sandbox/win/wow_helper/service64_resolver.cc @@ -4,6 +4,8 @@ #include "sandbox/win/wow_helper/service64_resolver.h" +#include <stddef.h> + #include "base/memory/scoped_ptr.h" #include "sandbox/win/wow_helper/target_code.h" diff --git a/sandbox/win/wow_helper/service64_resolver.h b/sandbox/win/wow_helper/service64_resolver.h index abd7efd..32ee46f 100644 --- a/sandbox/win/wow_helper/service64_resolver.h +++ b/sandbox/win/wow_helper/service64_resolver.h @@ -5,6 +5,9 @@ #ifndef SANDBOX_WOW_HELPER_SERVICE64_RESOLVER_H__ #define SANDBOX_WOW_HELPER_SERVICE64_RESOLVER_H__ +#include <stddef.h> + +#include "base/macros.h" #include "sandbox/win/src/nt_internals.h" #include "sandbox/win/src/resolver.h" diff --git a/sandbox/win/wow_helper/wow_helper.cc b/sandbox/win/wow_helper/wow_helper.cc index e349337..af76cbc 100644 --- a/sandbox/win/wow_helper/wow_helper.cc +++ b/sandbox/win/wow_helper/wow_helper.cc @@ -9,6 +9,7 @@ // setup the interceptions (32-bit) properly on the target. #include <windows.h> +#include <stddef.h> #include <string> |