/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SHELL_AS_SHELL_CODE_H_
#define SHELL_AS_SHELL_CODE_H_

#include <selinux/selinux.h>
#include <sys/types.h>

#include <memory>

#include "context.h"

namespace shell_as {

// Returns shell code that when executed will set the current process's SElinux
// context to the given value and then SIGSTOP itself.
std::unique_ptr<uint8_t[]> GetSELinuxShellCode(
    char* selinux_context, size_t* total_size);

// Returns shell code that when executed will halt the current process and raise
// a signal. The specific signal is returned in the expected_signal argument.
std::unique_ptr<uint8_t[]> GetTrapShellCode(int* expected_signal,
                                            size_t* total_size);
}  // namespace shell_as

#endif  // SHELL_AS_SHELL_CODE_H_
