Added GetState, GetManagedProperties, CreateNetwork methods to WiFiService.
[chromium-blink-merge.git] / sandbox / win / src / resolver_64.cc
blobca58b202993dd69c21e2d70e4070b4b8447862b9
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sandbox/win/src/resolver.h"
7 #include "sandbox/win/src/sandbox_nt_util.h"
9 namespace {
11 const BYTE kPushRax = 0x50;
12 const USHORT kMovRax = 0xB848;
13 const ULONG kMovRspRax = 0x24048948;
14 const BYTE kRetNp = 0xC3;
16 #pragma pack(push, 1)
17 struct InternalThunk {
18 // This struct contains roughly the following code:
19 // 00 50 push rax
20 // 01 48b8f0debc9a78563412 mov rax,123456789ABCDEF0h
21 // 0b 48890424 mov qword ptr [rsp],rax
22 // 0f c3 ret
24 // The code modifies rax, but that should not be an issue for the common
25 // calling conventions.
27 InternalThunk() {
28 push_rax = kPushRax;
29 mov_rax = kMovRax;
30 interceptor_function = 0;
31 mov_rsp_rax = kMovRspRax;
32 ret = kRetNp;
34 BYTE push_rax; // = 50
35 USHORT mov_rax; // = 48 B8
36 ULONG_PTR interceptor_function;
37 ULONG mov_rsp_rax; // = 48 89 04 24
38 BYTE ret; // = C3
40 #pragma pack(pop)
42 } // namespace.
44 namespace sandbox {
46 size_t ResolverThunk::GetInternalThunkSize() const {
47 return sizeof(InternalThunk);
50 bool ResolverThunk::SetInternalThunk(void* storage, size_t storage_bytes,
51 const void* original_function,
52 const void* interceptor) {
53 if (storage_bytes < sizeof(InternalThunk))
54 return false;
56 InternalThunk* thunk = new(storage, NT_PLACE) InternalThunk;
57 thunk->interceptor_function = reinterpret_cast<ULONG_PTR>(interceptor);
59 return true;
62 NTSTATUS ResolverThunk::ResolveTarget(const void* module,
63 const char* function_name,
64 void** address) {
65 // We don't support sidestep & co.
66 return STATUS_NOT_IMPLEMENTED;
69 } // namespace sandbox