2018-11-21 02:21:52 +01: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;
|
|
|
|
};
|
|
|
|
|
2019-10-27 00:25:04 +02:00
|
|
|
struct sg_res_header {
|
2018-11-21 02:21:52 +01:00
|
|
|
struct sg_header hdr;
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t payload_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef HRESULT (*sg_dispatch_fn_t)(
|
|
|
|
void *ctx,
|
|
|
|
const void *req,
|
2019-10-27 00:25:04 +02:00
|
|
|
void *res);
|
2018-11-21 02:21:52 +01:00
|
|
|
|
|
|
|
void sg_req_transact(
|
2019-10-27 00:25:04 +02:00
|
|
|
struct iobuf *res_frame,
|
2018-11-21 02:21:52 +01:00
|
|
|
const uint8_t *req_bytes,
|
|
|
|
size_t req_nbytes,
|
|
|
|
sg_dispatch_fn_t dispatch,
|
|
|
|
void *ctx);
|
|
|
|
|
2019-10-27 00:25:04 +02:00
|
|
|
void sg_res_init(
|
|
|
|
struct sg_res_header *res,
|
2018-11-21 02:21:52 +01:00
|
|
|
const struct sg_req_header *req,
|
|
|
|
size_t payload_len);
|