fix: search for license file in multiple directories
This commit is contained in:
20
src/main.c
20
src/main.c
@@ -18,6 +18,8 @@
|
||||
#define MAX_STEPS 1024u
|
||||
|
||||
|
||||
static const char* emu_program_paths[] = EMU_PROGRAM_PATHS;
|
||||
|
||||
int main(){
|
||||
hw_info_t hwinfo = {0};
|
||||
if(get_hw_info(&hwinfo) != 0){
|
||||
@@ -42,7 +44,19 @@ int main(){
|
||||
struct AES_ctx ctx;
|
||||
uint8_t nonce[16] = {0};
|
||||
|
||||
FILE* license = fopen(EMU_PROGRAM_PATH, "rb");
|
||||
FILE* license;
|
||||
for(size_t i = 0; i < sizeof(emu_program_paths); i++) {
|
||||
license = fopen(emu_program_paths[i], "rb");
|
||||
if (license != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (license == NULL) {
|
||||
fprintf(stderr, "Could not find license file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fread(nonce, 16, 1, license);
|
||||
long data_start = ftell(license);
|
||||
fseek(license, 0, SEEK_END);
|
||||
@@ -107,8 +121,8 @@ int main(){
|
||||
int symbol_status = resolve_elf_symbol_memory_offset(
|
||||
decrypted_license, EMU_ENTRY_SYMBOL, cpu.mem_size, &entry_offset);
|
||||
if (symbol_status != LOAD_OK) {
|
||||
fprintf(stderr, "Entry symbol '%s' resolve failed with code %d for '%s'\n",
|
||||
EMU_ENTRY_SYMBOL, symbol_status, EMU_PROGRAM_PATH);
|
||||
fprintf(stderr, "Entry symbol '%s' resolve failed with code %d\n",
|
||||
EMU_ENTRY_SYMBOL, symbol_status);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user