2023-09-18 10:00:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "hook/iobuf.h"
|
|
|
|
|
|
|
|
struct sg_header {
|
|
|
|
uint8_t frame_len;
|
|
|
|
uint8_t addr;
|
|
|
|
uint8_t seq_no;
|
|
|
|
uint8_t cmd;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sg_req_header {
|
|
|
|
struct sg_header hdr;
|
|
|
|
uint8_t payload_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sg_res_header {
|
|
|
|
struct sg_header hdr;
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t payload_len;
|
|
|
|
};
|
|
|
|
|
2024-10-06 20:37:20 +02:00
|
|
|
/* struct to save the version string with its length
|
|
|
|
to fix NUL terminator issues */
|
|
|
|
struct version_info {
|
|
|
|
const char *version;
|
|
|
|
uint8_t length;
|
|
|
|
};
|
|
|
|
|
2023-09-18 10:00:09 +02:00
|
|
|
typedef HRESULT (*sg_dispatch_fn_t)(
|
|
|
|
void *ctx,
|
|
|
|
const void *req,
|
|
|
|
void *res);
|
|
|
|
|
|
|
|
void sg_req_transact(
|
|
|
|
struct iobuf *res_frame,
|
|
|
|
const uint8_t *req_bytes,
|
|
|
|
size_t req_nbytes,
|
|
|
|
sg_dispatch_fn_t dispatch,
|
|
|
|
void *ctx);
|
|
|
|
|
|
|
|
void sg_res_init(
|
|
|
|
struct sg_res_header *res,
|
|
|
|
const struct sg_req_header *req,
|
|
|
|
size_t payload_len);
|