Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/hook/f2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ static void f2hook_patch_dongle_init()
patch_hasp_init(
(const uint8_t *) _binary_f2hook_hasp_key_start,
((uintptr_t) &_binary_f2hook_hasp_key_end -
(uintptr_t) &_binary_f2hook_hasp_key_start));
(uintptr_t) &_binary_f2hook_hasp_key_start),
0x80dbd50);
}

static void f2hook_patch_hdd_check_init()
Expand Down
12 changes: 11 additions & 1 deletion src/main/hook/patch/hasp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define LOG_MODULE "patch-hasp"

#include <inttypes.h>

#include "sec/hasp/old/hasp.h"

#include "util/log.h"
Expand All @@ -26,7 +28,10 @@ static const uint8_t patch_hasp_login_sig[] = {
static const uint8_t patch_hasp_id_sig[] = {
0x53, 0x83, 0xEC, 0x48, 0xC7, 0x44, 0x24, 0x10};

void patch_hasp_init(const uint8_t *key_data, size_t len)
void patch_hasp_init(
const uint8_t *key_data,
size_t len,
uintptr_t addr_get_sessioninfo)
{
void *func_api_login;
void *func_api_logout;
Expand Down Expand Up @@ -74,6 +79,11 @@ void patch_hasp_init(const uint8_t *key_data, size_t len)
util_patch_function((uintptr_t) func_api_decrypt, sec_hasp_api_decrypt);
util_patch_function((uintptr_t) func_api_getid, sec_hasp_api_getid);

if (addr_get_sessioninfo) {
log_debug("ApiGetSessionInfo at 0x%" PRIxPTR, addr_get_sessioninfo);
util_patch_function(addr_get_sessioninfo, sec_hasp_api_get_sessioninfo);
}

sec_hasp_init(key_data, len);

log_info("Initialized");
Expand Down
9 changes: 8 additions & 1 deletion src/main/hook/patch/hasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
#ifndef PATCH_HASP_H
#define PATCH_HASP_H

#include <stddef.h>
#include <stdint.h>

/**
* Initialize the patch module
*
* @param key_data Pointer to loaded key data (key table)
* @param len Length of the buffer
* @param addr_get_sessioninfo Address of hasp_get_sessioninfo function (0 if not used)
*/
void patch_hasp_init(const uint8_t *key_data, size_t len);
void patch_hasp_init(
const uint8_t *key_data,
size_t len,
uintptr_t addr_get_sessioninfo);

#endif
3 changes: 2 additions & 1 deletion src/main/hook/patch/piuio-exit.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <unistd.h>

#include "capnhook/hook/usbhook.h"

Expand Down Expand Up @@ -65,7 +66,7 @@ static enum cnh_result patch_piuio_exit_usbhook(struct cnh_usbhook_irp *irp)
if (((~irp->ctrl_buffer.bytes[1]) & (1 << 1)) &&
((~irp->ctrl_buffer.bytes[1]) & (1 << 6))) {
log_info("Exit on service + test enabled and hit, bye");
exit(0);
_exit(0);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/hook/pri/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static void prihook_patch_dongle_init()
patch_hasp_init(
(const uint8_t *) _binary_prihook_hasp_key_start,
((uintptr_t) &_binary_prihook_hasp_key_end -
(uintptr_t) &_binary_prihook_hasp_key_start));
(uintptr_t) &_binary_prihook_hasp_key_start),
0);
}

static void prihook_patch_hdd_check_init()
Expand Down
11 changes: 11 additions & 0 deletions src/main/sec/hasp/old/hasp.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,16 @@ int sec_hasp_api_decrypt(int handle, void *buffer, size_t length)
log_warn("Missing key for request %s", buf);
free(buf);

return 0;
}

int sec_hasp_api_get_sessioninfo(int handle, const char *format, const char **info)
{
static const char dummy_info[] = "p ";

if (info) {
*info = dummy_info;
}

return 0;
}
2 changes: 2 additions & 0 deletions src/main/sec/hasp/old/hasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ unsigned int sec_hasp_api_getid(void);

int sec_hasp_api_decrypt(int handle, void *buffer, size_t length);

int sec_hasp_api_get_sessioninfo(int handle, const char *format, const char **info);

#endif