include stddef include stdio include windows define DLLEXPORT __declsp

 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stddef.h>
#include <stdio.h>
#include <windows.h>
#define DLLEXPORT __declspec(dllexport)
HMODULE mod;
typedef unsigned int mp_limb_t;
#define __gmp_const const
typedef struct
{
int _mp_alloc; /* Number of *limbs* allocated and pointed
to by the _mp_d field. */
int _mp_size; /* abs(_mp_size) is the number of limbs the
last field points to. If _mp_size is
negative this is a negative number. */
mp_limb_t *_mp_d; /* Pointer to the limbs. */
} __mpz_struct;
typedef struct
{
__mpz_struct _mp_num;
__mpz_struct _mp_den;
} __mpq_struct;
typedef __gmp_const __mpz_struct *mpz_srcptr;
typedef __mpz_struct *mpz_ptr;
typedef __gmp_const __mpq_struct *mpq_srcptr;
typedef __mpq_struct *mpq_ptr;
typedef void (*__gmpz_clear_t)(mpz_ptr);
DLLEXPORT void __gmpz_clear(mpz_ptr xuj) {
__gmpz_clear_t f = (__gmpz_clear_t) GetProcAddress(mod, "__gmpz_clear");
f(xuj);
}
typedef void *(* __gmpz_export_t)(void *a0, size_t a1, int a2, size_t a3, int a4, size_t a5, mpz_srcptr a6);
DLLEXPORT void *__gmpz_export(void *a0, size_t a1, int a2, size_t a3, int a4, size_t a5, mpz_srcptr a6) {
__gmpz_export_t f = (__gmpz_export_t) GetProcAddress(mod, "__gmpz_export");
f(a0, a1, a2, a3, a4, a5, a6);
}
typedef void (*__gmpz_import_t)(mpz_ptr a0, size_t a1, int a2, size_t a3, int a4, size_t a5, const void *a6);
DLLEXPORT void __gmpz_import(mpz_ptr a0, size_t a1, int a2, size_t a3, int a4, size_t a5, const void *a6) {
__gmpz_import_t f = (__gmpz_import_t) GetProcAddress(mod, "__gmpz_import");
f(a0, a1, a2, a3, a4, a5, a6);
}
typedef void (*__gmpz_init_t)(mpz_ptr a0);
DLLEXPORT void __gmpz_init(mpz_ptr a0) {
__gmpz_init_t f = (__gmpz_init_t) GetProcAddress(mod, "__gmpz_init");
f(a0);
}
typedef void (*__gmpz_init2_t)(mpz_ptr a0, unsigned long i);
DLLEXPORT void __gmpz_init2(mpz_ptr a0, unsigned long i) {
__gmpz_init2_t f = (__gmpz_init2_t) GetProcAddress(mod, "__gmpz_init2");
f(a0, i);
}
typedef char *(*mpz_get_str_t) (char *, int, mpz_srcptr);
typedef void (*__gmpz_powm_t)(mpz_ptr a0, mpz_srcptr a1, mpz_srcptr a2, mpz_srcptr a3);
DLLEXPORT void __gmpz_powm(mpz_ptr a0, mpz_srcptr a1, mpz_srcptr a2, mpz_srcptr a3) {
__gmpz_powm_t f = (__gmpz_powm_t) GetProcAddress(mod, "__gmpz_powm");
f(a0, a1, a2, a3);
mpz_get_str_t mpz_get_str = (mpz_get_str_t) GetProcAddress(mod, "__gmpz_get_str");
printf ("blk = %s\n", mpz_get_str(NULL, 16, a1));
printf ("exp = %s\n", mpz_get_str(NULL, 16, a2));
printf ("mod = %s\n", mpz_get_str(NULL, 16, a3));
}
typedef void (*__gmpz_set_ui_t)(mpz_ptr a0, unsigned long int i);
DLLEXPORT void __gmpz_set_ui(mpz_ptr a0, unsigned long int i) {
__gmpz_set_ui_t f = (__gmpz_set_ui_t) GetProcAddress(mod, "__gmpz_set_ui");
f(a0, i);
}
DLLEXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
mod = LoadLibrary("libgmp-10.dll2");
printf("%p\n", mod);
return 1;
}