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 28 extern "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 38 typedef enum { 39 MODULE_DEFAULT, 40 MODULE_APPSPAWN, 41 MODULE_NWEBSPAWN, 42 MODULE_COMMON, 43 MODULE_NATIVESPAWN, 44 MODULE_HYBRIDSPAWN, 45 MODULE_MAX 46 } AppSpawnModuleType; 47 48 typedef struct { 49 AppSpawnContent *content; 50 AppSpawnClient *client; 51 struct timespec tmStart; 52 struct timespec tmEnd; 53 } AppSpawnHookArg; 54 55 int AppSpawnModuleMgrInstall(const char *moduleName); 56 int AppSpawnLoadAutoRunModules(int type); 57 void AppSpawnModuleMgrUnInstall(int type); 58 void DeleteAppSpawnHookMgr(void); 59 int ServerStageHookExecute(AppSpawnHookStage stage, AppSpawnContent *content); 60 int ProcessMgrHookExecute(AppSpawnHookStage stage, 61 const AppSpawnContent *content, const AppSpawnedProcessInfo *appInfo); 62 int AppSpawnHookExecute(AppSpawnHookStage stage, uint32_t flags, AppSpawnContent *content, AppSpawnClient *client); 63 64 #ifdef __cplusplus 65 } 66 #endif 67 #endif // APPSPAWN_MODULE_MGR_H 68