169570cc8Sopenharmony_ci/* 269570cc8Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 369570cc8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 469570cc8Sopenharmony_ci * you may not use this file except in compliance with the License. 569570cc8Sopenharmony_ci * You may obtain a copy of the License at 669570cc8Sopenharmony_ci * 769570cc8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 869570cc8Sopenharmony_ci * 969570cc8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1069570cc8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1169570cc8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1269570cc8Sopenharmony_ci * See the License for the specific language governing permissions and 1369570cc8Sopenharmony_ci * limitations under the License. 1469570cc8Sopenharmony_ci */ 1569570cc8Sopenharmony_ci 1669570cc8Sopenharmony_ci#ifndef APPSPAWN_MODULE_MGR_H 1769570cc8Sopenharmony_ci#define APPSPAWN_MODULE_MGR_H 1869570cc8Sopenharmony_ci#include <stdint.h> 1969570cc8Sopenharmony_ci#include <stdio.h> 2069570cc8Sopenharmony_ci#include <stdlib.h> 2169570cc8Sopenharmony_ci#include <time.h> 2269570cc8Sopenharmony_ci 2369570cc8Sopenharmony_ci#include "hookmgr.h" 2469570cc8Sopenharmony_ci#include "modulemgr.h" 2569570cc8Sopenharmony_ci#include "appspawn_hook.h" 2669570cc8Sopenharmony_ci 2769570cc8Sopenharmony_ci#ifdef __cplusplus 2869570cc8Sopenharmony_ciextern "C" { 2969570cc8Sopenharmony_ci#endif 3069570cc8Sopenharmony_ci 3169570cc8Sopenharmony_ci#define HOOK_STOP_WHEN_ERROR 0x2 3269570cc8Sopenharmony_ci#if defined(__aarch64__) || defined(__x86_64__) 3369570cc8Sopenharmony_ci#define ASAN_MODULE_PATH "/system/lib64/appspawn/libappspawn_asan" 3469570cc8Sopenharmony_ci#else 3569570cc8Sopenharmony_ci#define ASAN_MODULE_PATH "/system/lib/appspawn/libappspawn_asan" 3669570cc8Sopenharmony_ci#endif 3769570cc8Sopenharmony_ci 3869570cc8Sopenharmony_citypedef enum { 3969570cc8Sopenharmony_ci MODULE_DEFAULT, 4069570cc8Sopenharmony_ci MODULE_APPSPAWN, 4169570cc8Sopenharmony_ci MODULE_NWEBSPAWN, 4269570cc8Sopenharmony_ci MODULE_COMMON, 4369570cc8Sopenharmony_ci MODULE_NATIVESPAWN, 4469570cc8Sopenharmony_ci MODULE_MAX 4569570cc8Sopenharmony_ci} AppSpawnModuleType; 4669570cc8Sopenharmony_ci 4769570cc8Sopenharmony_citypedef struct { 4869570cc8Sopenharmony_ci AppSpawnContent *content; 4969570cc8Sopenharmony_ci AppSpawnClient *client; 5069570cc8Sopenharmony_ci struct timespec tmStart; 5169570cc8Sopenharmony_ci struct timespec tmEnd; 5269570cc8Sopenharmony_ci} AppSpawnHookArg; 5369570cc8Sopenharmony_ci 5469570cc8Sopenharmony_ciint AppSpawnModuleMgrInstall(const char *moduleName); 5569570cc8Sopenharmony_ciint AppSpawnLoadAutoRunModules(int type); 5669570cc8Sopenharmony_civoid AppSpawnModuleMgrUnInstall(int type); 5769570cc8Sopenharmony_civoid DeleteAppSpawnHookMgr(void); 5869570cc8Sopenharmony_ciint ServerStageHookExecute(AppSpawnHookStage stage, AppSpawnContent *content); 5969570cc8Sopenharmony_ciint ProcessMgrHookExecute(AppSpawnHookStage stage, 6069570cc8Sopenharmony_ci const AppSpawnContent *content, const AppSpawnedProcessInfo *appInfo); 6169570cc8Sopenharmony_ciint AppSpawnHookExecute(AppSpawnHookStage stage, uint32_t flags, AppSpawnContent *content, AppSpawnClient *client); 6269570cc8Sopenharmony_ci 6369570cc8Sopenharmony_ci#ifdef __cplusplus 6469570cc8Sopenharmony_ci} 6569570cc8Sopenharmony_ci#endif 6669570cc8Sopenharmony_ci#endif // APPSPAWN_MODULE_MGR_H 67