1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SHELL_AS_SHELL_CODE_H_
18 #define SHELL_AS_SHELL_CODE_H_
19 
20 #include <selinux/selinux.h>
21 #include <sys/types.h>
22 
23 #include <memory>
24 
25 #include "context.h"
26 
27 namespace shell_as {
28 
29 // Returns shell code that when executed will set the current process's SElinux
30 // context to the given value and then SIGSTOP itself.
31 std::unique_ptr<uint8_t[]> GetSELinuxShellCode(
32     char* selinux_context, size_t* total_size);
33 
34 // Returns shell code that when executed will halt the current process and raise
35 // a signal. The specific signal is returned in the expected_signal argument.
36 std::unique_ptr<uint8_t[]> GetTrapShellCode(int* expected_signal,
37                                             size_t* total_size);
38 }  // namespace shell_as
39 
40 #endif  // SHELL_AS_SHELL_CODE_H_
41