OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/win/src/service_resolver.h" | 5 #include "sandbox/win/src/service_resolver.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "sandbox/win/src/win_utils.h" | 8 #include "sandbox/win/src/win_utils.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 #pragma pack(push, 1) | 11 #pragma pack(push, 1) |
12 | 12 |
13 const BYTE kMovEax = 0xB8; | 13 const BYTE kMovEax = 0xB8; |
14 const BYTE kMovEdx = 0xBA; | 14 const BYTE kMovEdx = 0xBA; |
15 const USHORT kMovEdxEsp = 0xD48B; | 15 const USHORT kMovEdxEsp = 0xD48B; |
16 const USHORT kCallPtrEdx = 0x12FF; | 16 const USHORT kCallPtrEdx = 0x12FF; |
17 const USHORT kCallEdx = 0xD2FF; | 17 const USHORT kCallEdx = 0xD2FF; |
18 const BYTE kCallEip = 0xE8; | 18 const BYTE kCallEip = 0xE8; |
19 const BYTE kRet = 0xC2; | 19 const BYTE kRet = 0xC2; |
20 const BYTE kRet2 = 0xC3; | 20 const BYTE kRet2 = 0xC3; |
21 const BYTE kNop = 0x90; | |
22 const USHORT kJmpEdx = 0xE2FF; | 21 const USHORT kJmpEdx = 0xE2FF; |
23 const USHORT kXorEcx = 0xC933; | 22 const USHORT kXorEcx = 0xC933; |
24 const ULONG kLeaEdx = 0x0424548D; | 23 const ULONG kLeaEdx = 0x0424548D; |
25 const ULONG kCallFs1 = 0xC015FF64; | 24 const ULONG kCallFs1 = 0xC015FF64; |
26 const USHORT kCallFs2 = 0; | 25 const USHORT kCallFs2 = 0; |
27 const BYTE kCallFs3 = 0; | 26 const BYTE kCallFs3 = 0; |
28 const BYTE kAddEsp1 = 0x83; | 27 const BYTE kAddEsp1 = 0x83; |
29 const USHORT kAddEsp2 = 0x4C4; | 28 const USHORT kAddEsp2 = 0x4C4; |
30 const BYTE kJmp32 = 0xE9; | 29 const BYTE kJmp32 = 0xE9; |
31 const USHORT kSysenter = 0x340F; | 30 const USHORT kSysenter = 0x340F; |
32 | 31 |
33 const int kMaxService = 1000; | |
34 | |
35 // Service code for 32 bit systems. | 32 // Service code for 32 bit systems. |
36 // NOTE: on win2003 "call dword ptr [edx]" is "call edx". | 33 // NOTE: on win2003 "call dword ptr [edx]" is "call edx". |
37 struct ServiceEntry { | 34 struct ServiceEntry { |
38 // This struct contains roughly the following code: | 35 // This struct contains roughly the following code: |
39 // 00 mov eax,25h | 36 // 00 mov eax,25h |
40 // 05 mov edx,offset SharedUserData!SystemCallStub (7ffe0300) | 37 // 05 mov edx,offset SharedUserData!SystemCallStub (7ffe0300) |
41 // 0a call dword ptr [edx] | 38 // 0a call dword ptr [edx] |
42 // 0c ret 2Ch | 39 // 0c ret 2Ch |
43 // 0f nop | 40 // 0f nop |
44 BYTE mov_eax; // = B8 | 41 BYTE mov_eax; // = B8 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 return false; | 415 return false; |
419 } | 416 } |
420 | 417 |
421 // Save the verified code | 418 // Save the verified code |
422 memcpy(local_thunk, &function_code, sizeof(function_code)); | 419 memcpy(local_thunk, &function_code, sizeof(function_code)); |
423 | 420 |
424 return true; | 421 return true; |
425 } | 422 } |
426 | 423 |
427 } // namespace sandbox | 424 } // namespace sandbox |
OLD | NEW |