1/*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
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 __OHOS_MALLOC_HOOK_CLIENT_H__
17#define __OHOS_MALLOC_HOOK_CLIENT_H__
18
19#include <cstdlib>
20#include "musl_malloc_dispatch.h"
21
22#define EXPORT_API __attribute__((visibility("default")))
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28EXPORT_API bool ohos_malloc_hook_initialize(const MallocDispatchType*, bool*, const char*);
29EXPORT_API bool ohos_malloc_hook_get_hook_flag(void);
30EXPORT_API bool ohos_malloc_hook_set_hook_flag(bool);
31EXPORT_API void ohos_malloc_hook_finalize(void);
32EXPORT_API bool ohos_malloc_hook_on_start(void (*disableHookCallback)());
33EXPORT_API bool ohos_malloc_hook_on_end(void);
34EXPORT_API void* ohos_malloc_hook_malloc(size_t);
35EXPORT_API void* ohos_malloc_hook_realloc(void*, size_t);
36EXPORT_API void* ohos_malloc_hook_calloc(size_t, size_t);
37EXPORT_API void* ohos_malloc_hook_valloc(size_t);
38EXPORT_API void ohos_malloc_hook_free(void*);
39EXPORT_API void* ohos_malloc_hook_aligned_alloc(size_t, size_t);
40EXPORT_API size_t ohos_malloc_hook_malloc_usable_size(void*);
41EXPORT_API void* ohos_malloc_hook_mmap(void*, size_t, int, int, int, off_t);
42EXPORT_API int ohos_malloc_hook_munmap(void*, size_t);
43EXPORT_API void ohos_malloc_hook_memtrace(void*, size_t, const char*, bool);
44EXPORT_API int ohos_malloc_hook_prctl(int option, unsigned long, unsigned long, unsigned long, unsigned long);
45EXPORT_API bool ohos_set_filter_size(size_t size, void* ret);
46EXPORT_API bool ohos_malloc_hook_send_hook_misc_data(uint64_t, const char*, size_t, uint32_t);
47EXPORT_API void* ohos_malloc_hook_get_hook_config();
48
49#ifdef __cplusplus
50}
51#endif
52
53
54#endif /* __OHOS_MALLOC_HOOK_CLIENT_H__ */