-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathopenssl_1_1_0_offset.c
49 lines (43 loc) · 1.29 KB
/
openssl_1_1_0_offset.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <ctype.h>
#include <crypto/bio/bio_lcl.h>
#include <openssl/crypto.h>
#include <ssl/ssl_locl.h>
#include <stddef.h>
#include <stdio.h>
#define SSL_STRUCT_OFFSETS \
X(ssl_st, version) \
X(ssl_st, session) \
X(ssl_st, s3) \
X(ssl_st, rbio) \
X(ssl_st, wbio) \
X(ssl_st, server) \
X(ssl_session_st, master_key) \
X(ssl3_state_st, client_random) \
X(ssl_session_st, cipher) \
X(ssl_session_st, cipher_id) \
X(ssl_cipher_st, id) \
X(bio_st, num)
void toUpper(char *s) {
int i = 0;
while (s[i] != '\0') {
putchar(toupper(s[i]));
i++;
}
}
void format(char *struct_name, char *field_name, size_t offset) {
printf("// %s->%s\n", struct_name, field_name);
printf("#define ");
toUpper(struct_name);
printf("_");
toUpper(field_name);
printf(" 0x%lx\n\n", offset);
}
int main() {
printf("/* OPENSSL_VERSION_TEXT: %s */\n", OPENSSL_VERSION_TEXT);
printf("/* OPENSSL_VERSION_NUMBER: %d */\n\n", OPENSSL_VERSION_NUMBER);
#define X(struct_name, field_name) \
format(#struct_name, #field_name, offsetof(struct struct_name, field_name));
SSL_STRUCT_OFFSETS
#undef X
return 0;
}