1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/refinery/analyzers/analyzer_util.h"
16 :
17 : #include "base/logging.h"
18 : #include "syzygy/refinery/process_state/refinery.pb.h"
19 :
20 : namespace refinery {
21 :
22 E : void ParseContext(const CONTEXT& ctx, RegisterInformation* register_info) {
23 E : DCHECK(register_info != nullptr);
24 E : if (ctx.ContextFlags & CONTEXT_SEGMENTS) {
25 E : register_info->set_seg_gs(ctx.SegGs);
26 E : register_info->set_seg_fs(ctx.SegFs);
27 E : register_info->set_seg_es(ctx.SegEs);
28 E : register_info->set_seg_ds(ctx.SegDs);
29 : }
30 E : if (ctx.ContextFlags & CONTEXT_INTEGER) {
31 E : register_info->set_edi(ctx.Edi);
32 E : register_info->set_esi(ctx.Esi);
33 E : register_info->set_ebx(ctx.Ebx);
34 E : register_info->set_edx(ctx.Edx);
35 E : register_info->set_ecx(ctx.Ecx);
36 E : register_info->set_eax(ctx.Eax);
37 : }
38 E : if (ctx.ContextFlags & CONTEXT_CONTROL) {
39 E : register_info->set_ebp(ctx.Ebp);
40 E : register_info->set_eip(ctx.Eip);
41 E : register_info->set_seg_cs(ctx.SegCs);
42 E : register_info->set_eflags(ctx.EFlags);
43 E : register_info->set_esp(ctx.Esp);
44 E : register_info->set_seg_ss(ctx.SegSs);
45 : }
46 E : }
47 :
48 : } // namespace refinery
|