Spaces:
Runtime error
Runtime error
Download src/sign.c from ankeke2026/ankeke: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/ankeke2026/ankeke/resolve/main/src/sign.c
- Command line
-
hf download hf://spaces/ankeke2026/ankeke/src/sign.c
-
curl -L -o sign.c https://huggingface.co/spaces/ankeke2026/ankeke/resolve/main/src/sign.c
1.34 kB
| // SPDX-License-Identifier: AGPL-3.0-only | |
| // Copyright (C) 2025 Moew72 <Moew72@proton.me> | |
| typedef long long (*func)(char*, unsigned char*, int, int, unsigned char*); | |
| char* module_path; | |
| uintptr_t offset; | |
| func sign; | |
| static uintptr_t module_base; | |
| static void* module; | |
| int callback(struct dl_phdr_info* info, size_t, void*) { | |
| if (info->dlpi_name && strstr(info->dlpi_name, "wrapper.node")) { | |
| module_base = info->dlpi_addr; | |
| printf("Found wrapper.node at base: 0x%lx\n", module_base); | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| int load_module() { | |
| module = dlopen(module_path, RTLD_LAZY); | |
| if (!module) { | |
| fprintf(stderr, "dlopen failed: %s\n", dlerror()); | |
| return 1; | |
| } | |
| printf("Module handle: %p\n", module); | |
| dl_iterate_phdr(callback, NULL); | |
| if (module_base == 0) { | |
| fprintf(stderr, "Failed to find module base\n"); | |
| dlclose(module); | |
| return 1; | |
| } | |
| sign = (func)(module_base + offset); | |
| printf("Calculated function address: %p\n", (void*)sign); | |
| if ((uintptr_t)sign < 0x10000) { | |
| fprintf(stderr, "Invalid function pointer: %p\n", (void*)sign); | |
| dlclose(module); | |
| return 1; | |
| } | |
| return 0; | |
| } | |
| void unload_module() { | |
| dlclose(module); | |
| } | |