1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
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
16#ifndef APPSPAWN_MODULE_MGR_H
17#define APPSPAWN_MODULE_MGR_H
18#include <stdint.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <time.h>
22
23#include "hookmgr.h"
24#include "modulemgr.h"
25#include "appspawn_hook.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define HOOK_STOP_WHEN_ERROR 0x2
32#if defined(__aarch64__) || defined(__x86_64__)
33#define ASAN_MODULE_PATH "/system/lib64/appspawn/libappspawn_asan"
34#else
35#define ASAN_MODULE_PATH "/system/lib/appspawn/libappspawn_asan"
36#endif
37
38typedef enum {
39    MODULE_DEFAULT,
40    MODULE_APPSPAWN,
41    MODULE_NWEBSPAWN,
42    MODULE_COMMON,
43    MODULE_NATIVESPAWN,
44    MODULE_MAX
45} AppSpawnModuleType;
46
47typedef struct {
48    AppSpawnContent *content;
49    AppSpawnClient *client;
50    struct timespec tmStart;
51    struct timespec tmEnd;
52} AppSpawnHookArg;
53
54int AppSpawnModuleMgrInstall(const char *moduleName);
55int AppSpawnLoadAutoRunModules(int type);
56void AppSpawnModuleMgrUnInstall(int type);
57void DeleteAppSpawnHookMgr(void);
58int ServerStageHookExecute(AppSpawnHookStage stage, AppSpawnContent *content);
59int ProcessMgrHookExecute(AppSpawnHookStage stage,
60    const AppSpawnContent *content, const AppSpawnedProcessInfo *appInfo);
61int AppSpawnHookExecute(AppSpawnHookStage stage, uint32_t flags, AppSpawnContent *content, AppSpawnClient *client);
62
63#ifdef __cplusplus
64}
65#endif
66#endif  // APPSPAWN_MODULE_MGR_H
67