leechcorepyc 2.20.0__tar.gz → 2.22.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. {leechcorepyc-2.20.0/leechcorepyc.egg-info → leechcorepyc-2.22.0}/PKG-INFO +1 -1
  2. leechcorepyc-2.22.0/includes/leechgrpc.h +354 -0
  3. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/Makefile +1 -1
  4. leechcorepyc-2.22.0/leechcore/Makefile.macos +50 -0
  5. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_fpga.c +23 -5
  6. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_pmem.c +1 -1
  7. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_vmware.c +216 -216
  8. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechcore.c +5 -0
  9. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechrpc.h +69 -23
  10. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechrpc_c.c +56 -31
  11. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechrpc_h.h +1 -1
  12. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechrpcclient.c +151 -21
  13. leechcorepyc-2.22.0/leechcore/leechrpcshared.c +231 -0
  14. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/oscompatibility.c +9 -1
  15. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/oscompatibility.h +4 -0
  16. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/util.c +1 -1
  17. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/version.h +3 -3
  18. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/version.h +24 -24
  19. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0/leechcorepyc.egg-info}/PKG-INFO +1 -1
  20. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc.egg-info/SOURCES.txt +1 -0
  21. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/setup.py +1 -1
  22. leechcorepyc-2.20.0/leechcore/Makefile.macos +0 -29
  23. leechcorepyc-2.20.0/leechcore/leechrpcshared.c +0 -151
  24. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/MANIFEST.in +0 -0
  25. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/Makefile +0 -0
  26. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/README +0 -0
  27. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/files/dummy +0 -0
  28. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/includes/leechcore.h +0 -0
  29. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/includes/leechcore_device.h +0 -0
  30. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/includes/libpdbcrust.h +0 -0
  31. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/includes/vmmdll.h +0 -0
  32. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/includes/vmmyara.h +0 -0
  33. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_file.c +0 -0
  34. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_hibr.c +0 -0
  35. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_tmd.c +0 -0
  36. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_usb3380.c +0 -0
  37. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/device_vmm.c +0 -0
  38. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechcore.h +0 -0
  39. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechcore.rc +0 -0
  40. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechcore_device.h +0 -0
  41. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechcore_internal.h +0 -0
  42. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/leechrpc.idl +0 -0
  43. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/memmap.c +0 -0
  44. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/ob/ob.h +0 -0
  45. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/ob/ob_bytequeue.c +0 -0
  46. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/ob/ob_core.c +0 -0
  47. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/ob/ob_map.c +0 -0
  48. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/ob/ob_set.c +0 -0
  49. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore/util.h +0 -0
  50. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_qemu/Makefile +0 -0
  51. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_qemu/leechcore_device_qemu.c +0 -0
  52. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/Makefile +0 -0
  53. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/leechcore_device_rawtcp.c +0 -0
  54. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/oscompatibility.c +0 -0
  55. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/oscompatibility.h +0 -0
  56. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/plugin.rc +0 -0
  57. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_device_rawtcp/resource.h +0 -0
  58. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_ft601_driver_linux/Makefile +0 -0
  59. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_ft601_driver_linux/fpga_libusb.c +0 -0
  60. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_ft601_driver_linux/fpga_libusb.h +0 -0
  61. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_ft601_driver_linux/leechcore_ft601_driver_linux.c +0 -0
  62. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcore_ft601_driver_linux/leechcore_ft601_driver_linux.h +0 -0
  63. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc/__init__.py +0 -0
  64. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc.c +0 -0
  65. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc.egg-info/dependency_links.txt +0 -0
  66. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc.egg-info/top_level.txt +0 -0
  67. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc.h +0 -0
  68. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/leechcorepyc_barrequest.c +0 -0
  69. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/Makefile +0 -0
  70. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/lznt1.h +0 -0
  71. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/Array.h +0 -0
  72. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/Bitstream.h +0 -0
  73. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/CircularBuffer.h +0 -0
  74. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/HuffmanDecoder.h +0 -0
  75. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/HuffmanEncoder.h +0 -0
  76. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/LZNT1Dictionary.h +0 -0
  77. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/LZNT1Dictionary_SA.h +0 -0
  78. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/XpressDictionary.h +0 -0
  79. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/config.h +0 -0
  80. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/general.h +0 -0
  81. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/internal.h +0 -0
  82. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp/sorting.h +0 -0
  83. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/mscomp.h +0 -0
  84. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/xpress.h +0 -0
  85. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/include/xpress_huff.h +0 -0
  86. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/lznt1_compress.cpp +0 -0
  87. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/lznt1_decompress.cpp +0 -0
  88. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/mscomp.cpp +0 -0
  89. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/xpress_compress.cpp +0 -0
  90. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/xpress_decompress.cpp +0 -0
  91. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/xpress_huff_compress.cpp +0 -0
  92. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/ms-compress/src/xpress_huff_decompress.cpp +0 -0
  93. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/oscompatibility.c +0 -0
  94. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/oscompatibility.h +0 -0
  95. {leechcorepyc-2.20.0 → leechcorepyc-2.22.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: leechcorepyc
3
- Version: 2.20.0
3
+ Version: 2.22.0
4
4
  Summary: LeechCore for Python
5
5
  Home-page: https://github.com/ufrisk/LeechCore
6
6
  Author: Ulf Frisk
@@ -0,0 +1,354 @@
1
+ // leechgrpc.h : external header of the libleechgrpc library.
2
+ //
3
+ // libleechgrpc is a library used by LeechCore to communicate with a LeechAgent
4
+ // gRPC server. The library provides functions to create a gRPC client and
5
+ // server, submit commands to the server, and handle incoming commands.
6
+ //
7
+ // libleechgrpc offers a platform-independent way to communicate with remote
8
+ // LeechAgent instances, using gRPC as the underlying communication protocol.
9
+ // The library supports both insecure and secure connections, with secure
10
+ // connections using mTLS.
11
+ //
12
+ // For more information visit the project page at:
13
+ // https://github.com/ufrisk/libleechgrpc
14
+ //
15
+ // (c) Ulf Frisk, 2025
16
+ // Author: Ulf Frisk, pcileech@frizk.net
17
+ //
18
+
19
+ #ifndef __LEECHGRPC_H__
20
+ #define __LEECHGRPC_H__
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif /* __cplusplus */
24
+
25
+ #define LEECHGRPC_MESSAGE_SIZE_MAX (64*1024*1024)
26
+ #define LEECHGRPC_CLIENT_TIMEOUT_MS (5000)
27
+
28
+ #ifdef _WIN32
29
+
30
+ #include <Windows.h>
31
+ #define LEECHGRPC_EXPORTED_FUNCTION __declspec(dllexport)
32
+
33
+ #endif /* _WIN32 */
34
+ #if defined(LINUX) || defined(MACOS)
35
+
36
+ #include <inttypes.h>
37
+ #include <stdlib.h>
38
+ #define LEECHGRPC_EXPORTED_FUNCTION __attribute__((visibility("default")))
39
+ typedef void VOID, *PVOID, *HANDLE;
40
+ typedef size_t SIZE_T;
41
+ typedef uint32_t DWORD, BOOL;
42
+ typedef uint8_t BYTE, *PBYTE;
43
+ typedef char CHAR, *LPSTR;
44
+ typedef const char *LPCSTR;
45
+ #define _Success_(x)
46
+ #define _In_
47
+ #define _Out_
48
+ #define _In_opt_
49
+
50
+ #endif /* LINUX || MACOS */
51
+
52
+ typedef void *LEECHGRPC_CLIENT_HANDLE, *LEECHGRPC_SERVER_HANDLE;
53
+
54
+
55
+
56
+ //-----------------------------------------------------------------------------
57
+ // LeechgRPC Client API:
58
+ //-----------------------------------------------------------------------------
59
+
60
+ /*
61
+ * Submit a command to the gRPC server.
62
+ * -- hGRPC: Handle to the gRPC client.
63
+ * -- pbIn: Pointer to the input buffer.
64
+ * -- cbIn: Size of the input buffer.
65
+ * -- ppbOut: Pointer to receive the output buffer. The caller is responsible for freeing this buffer with LocalFree/free.
66
+ * -- pcbOut: Pointer to receive the size of the output buffer.
67
+ * -- return: TRUE if the command was successfully submitted; otherwise, FALSE.
68
+ */
69
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return)
70
+ BOOL leechgrpc_client_submit_command(
71
+ _In_ LEECHGRPC_CLIENT_HANDLE hGRPC,
72
+ _In_ PBYTE pbIn,
73
+ _In_ SIZE_T cbIn,
74
+ _Out_ PBYTE *ppbOut,
75
+ _Out_ SIZE_T *pcbOut
76
+ );
77
+
78
+ typedef BOOL(*pfn_leechgrpc_client_submit_command)(
79
+ _In_ LEECHGRPC_CLIENT_HANDLE hGRPC,
80
+ _In_ PBYTE pbIn,
81
+ _In_ SIZE_T cbIn,
82
+ _Out_ PBYTE *ppbOut,
83
+ _Out_ SIZE_T *pcbOut
84
+ );
85
+
86
+ /*
87
+ * Free the gRPC client connection.
88
+ * -- hGRPC: Handle to the gRPC client.
89
+ */
90
+ LEECHGRPC_EXPORTED_FUNCTION
91
+ VOID leechgrpc_client_free(
92
+ _In_ LEECHGRPC_CLIENT_HANDLE hGRPC
93
+ );
94
+
95
+ typedef VOID(*pfn_leechgrpc_client_free)(
96
+ _In_ LEECHGRPC_CLIENT_HANDLE hGRPC
97
+ );
98
+
99
+ /*
100
+ * Create an insecure unauthenticated unencrypted gRPC client connection to the gRPC server.
101
+ * -- pszAddress: Address of the gRPC server.
102
+ * -- dwPort: Port of the gRPC server.
103
+ * -- return: Handle to the gRPC client connection, or NULL on failure.
104
+ */
105
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
106
+ LEECHGRPC_CLIENT_HANDLE leechgrpc_client_create_insecure(
107
+ _In_ LPCSTR szAddress,
108
+ _In_ DWORD dwPort
109
+ );
110
+
111
+ typedef LEECHGRPC_CLIENT_HANDLE(*pfn_leechgrpc_client_create_insecure)(
112
+ _In_ LPCSTR szAddress,
113
+ _In_ DWORD dwPort
114
+ );
115
+
116
+ /*
117
+ * Create a gRPC client connection to the gRPC server with mTLS.
118
+ * -- pszAddress: Address of the gRPC server.
119
+ * -- dwPort: Port of the gRPC server.
120
+ * -- szTlsServerHostnameOverride: Optional hostname to verify against the server certificate (if different from address).
121
+ * -- szTlsServerCertPath: Server CA certificate to trust for mTLS connections.
122
+ * -- szTlsClientP12Path: Path to the client's TLS certificate (incl. chain) & private key (.p12 / .pfx).
123
+ * -- szTlsClientP12Password: Password for the client's TLS certificate & private key (.p12 / .pfx).
124
+ */
125
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
126
+ LEECHGRPC_CLIENT_HANDLE leechgrpc_client_create_secure_p12(
127
+ _In_ LPCSTR szAddress,
128
+ _In_ DWORD dwPort,
129
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
130
+ _In_opt_ LPCSTR szTlsServerCertPath,
131
+ _In_ LPCSTR szTlsClientP12Path,
132
+ _In_ LPCSTR szTlsClientP12Password
133
+ );
134
+
135
+ typedef LEECHGRPC_CLIENT_HANDLE(*pfn_leechgrpc_client_create_secure_p12)(
136
+ _In_ LPCSTR szAddress,
137
+ _In_ DWORD dwPort,
138
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
139
+ _In_opt_ LPCSTR szTlsServerCertPath,
140
+ _In_ LPCSTR szTlsClientP12Path,
141
+ _In_ LPCSTR szTlsClientP12Password
142
+ );
143
+
144
+ /*
145
+ * Create a gRPC client connection to the gRPC server with mTLS.
146
+ * -- pszAddress: Address of the gRPC server.
147
+ * -- dwPort: Port of the gRPC server.
148
+ * -- szTlsServerHostnameOverride: Optional hostname to verify against the server certificate (if different from address).
149
+ * -- szTlsServerCert: Server CA certificate to trust for mTLS connections.
150
+ * -- szTlsClientCert: Cerver TLS certificate.
151
+ * -- szTlsClientCertPrivateKey: Client TLS certificate private key.
152
+ */
153
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
154
+ LEECHGRPC_CLIENT_HANDLE leechgrpc_client_create_secure_pemraw(
155
+ _In_ LPCSTR szAddress,
156
+ _In_ DWORD dwPort,
157
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
158
+ _In_opt_ LPCSTR szTlsServerCert,
159
+ _In_ LPCSTR szTlsClientCert,
160
+ _In_ LPCSTR szTlsClientCertPrivateKey
161
+ );
162
+
163
+ typedef LEECHGRPC_CLIENT_HANDLE(*pfn_leechgrpc_client_create_secure_pemraw)(
164
+ _In_ LPCSTR szAddress,
165
+ _In_ DWORD dwPort,
166
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
167
+ _In_opt_ LPCSTR szTlsServerCert,
168
+ _In_ LPCSTR szTlsClientCert,
169
+ _In_ LPCSTR szTlsClientCertPrivateKey
170
+ );
171
+
172
+ /*
173
+ * Create a gRPC client connection to the gRPC server with mTLS.
174
+ * -- pszAddress: Address of the gRPC server.
175
+ * -- dwPort: Port of the gRPC server.
176
+ * -- szTlsServerHostnameOverride: Optional hostname to verify against the server certificate (if different from address).
177
+ * -- szTlsServerCertPath: Server CA certificate to trust for mTLS connections.
178
+ * -- szTlsClientCertPath: Cerver TLS certificate.
179
+ * -- szTlsClientCertPrivateKeyPath: Client TLS certificate private key.
180
+ */
181
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
182
+ LEECHGRPC_CLIENT_HANDLE leechgrpc_client_create_secure_pemfile(
183
+ _In_ LPCSTR szAddress,
184
+ _In_ DWORD dwPort,
185
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
186
+ _In_opt_ LPCSTR szTlsServerCertPath,
187
+ _In_ LPCSTR szTlsClientCertPath,
188
+ _In_ LPCSTR szTlsClientCertPrivateKeyPath
189
+ );
190
+
191
+ typedef LEECHGRPC_CLIENT_HANDLE(*pfn_leechgrpc_client_create_secure_pemfile)(
192
+ _In_ LPCSTR szAddress,
193
+ _In_ DWORD dwPort,
194
+ _In_opt_ LPCSTR szTlsServerHostnameOverride,
195
+ _In_opt_ LPCSTR szTlsServerCertPath,
196
+ _In_ LPCSTR szTlsClientCertPath,
197
+ _In_ LPCSTR szTlsClientCertPrivateKeyPath
198
+ );
199
+
200
+
201
+
202
+ //-----------------------------------------------------------------------------
203
+ // LeechgRPC Server API:
204
+ //-----------------------------------------------------------------------------
205
+
206
+ /*
207
+ * Callback function used to pass on a command received by the gRPC server.
208
+ * -- pbIn: Pointer to the input buffer.
209
+ * -- cbIn: Size of the input buffer.
210
+ * -- ppbOut: Pointer to receive the output buffer allocated by the callback function, freed by the caller.
211
+ * -- pcbOut: Pointer to receive the size of the output buffer.
212
+ */
213
+ typedef VOID(*PFN_RESERVED_SUBMIT_COMMAND_CB)(_In_opt_ PVOID ctx, _In_ PBYTE pbIn, _In_ SIZE_T cbIn, _Out_ PBYTE *ppbOut, _Out_ SIZE_T *pcbOut);
214
+
215
+ /*
216
+ * Wait for the gRPC server to shutdown.
217
+ * -- hGRPC: Handle to the gRPC server.
218
+ */
219
+ LEECHGRPC_EXPORTED_FUNCTION
220
+ VOID leechgrpc_server_wait(_In_ LEECHGRPC_SERVER_HANDLE hGRPC);
221
+
222
+ typedef VOID(*pfn_leechgrpc_server_wait)(_In_ LEECHGRPC_SERVER_HANDLE hGRPC);
223
+
224
+ /*
225
+ * Shut down the gRPC server.
226
+ * -- hGRPC: Handle to the gRPC server.
227
+ */
228
+ LEECHGRPC_EXPORTED_FUNCTION
229
+ VOID leechgrpc_server_shutdown(_In_ LEECHGRPC_SERVER_HANDLE hGRPC);
230
+
231
+ typedef VOID(*pfn_leechgrpc_server_shutdown)(_In_ LEECHGRPC_SERVER_HANDLE hGRPC);
232
+
233
+ /*
234
+ * Create an insecure gRPC server without any authentication / encryption.
235
+ * -- szAddress: Address to listen on, e.g., "localhost" or "0.0.0.0".
236
+ * -- dwPort: Port to listen on.
237
+ * -- pfnReservedSubmitCommandCB: Callback function to handle incoming commands.
238
+ * -- return: Handle to the gRPC server, or NULL on failure.
239
+ */
240
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
241
+ LEECHGRPC_SERVER_HANDLE leechgrpc_server_create_insecure(
242
+ _In_ LPCSTR szAddress,
243
+ _In_ DWORD dwPort,
244
+ _In_opt_ PVOID ctx,
245
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB
246
+ );
247
+
248
+ typedef LEECHGRPC_SERVER_HANDLE(*pfn_leechgrpc_server_create_insecure)(
249
+ _In_ LPCSTR szAddress,
250
+ _In_ DWORD dwPort,
251
+ _In_opt_ PVOID ctx,
252
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB
253
+ );
254
+
255
+ /*
256
+ * Create a gRPC server with mTLS.
257
+ * -- szAddress: Address to listen on, e.g., "localhost" or "
258
+ * -- dwPort: Port to listen on.
259
+ * -- ctx: Optional context to pass to the callback function.
260
+ * -- pfnReservedSubmitCommandCB: Callback function to handle incoming commands.
261
+ * -- szTlsClientCertPath: Client CA certificate to trust for mTLS connections.
262
+ * -- szTlsServerP12Path: Path to the server's TLS certificate (incl. chain) & private key (.p12 / .pfx).
263
+ * -- szTlsServerP12Password: Password for the server's TLS certificate & private key (.p12 / .pfx).
264
+ * -- return: Handle to the gRPC server, or NULL on failure.
265
+ */
266
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
267
+ LEECHGRPC_SERVER_HANDLE leechgrpc_server_create_secure_p12(
268
+ _In_ LPCSTR szAddress,
269
+ _In_ DWORD dwPort,
270
+ _In_opt_ PVOID ctx,
271
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
272
+ _In_ LPCSTR szTlsClientCertPath,
273
+ _In_ LPCSTR szTlsServerP12Path,
274
+ _In_ LPCSTR szTlsServerP12Password
275
+ );
276
+
277
+ typedef LEECHGRPC_SERVER_HANDLE(*pfn_leechgrpc_server_create_secure_p12)(
278
+ _In_ LPCSTR szAddress,
279
+ _In_ DWORD dwPort,
280
+ _In_opt_ PVOID ctx,
281
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
282
+ _In_ LPCSTR szTlsClientCertPath,
283
+ _In_ LPCSTR szTlsServerP12Path,
284
+ _In_ LPCSTR szTlsServerP12Password
285
+ );
286
+
287
+ /*
288
+ * Create a gRPC server with mTLS.
289
+ * -- szAddress: Address to listen on, e.g., "localhost" or "
290
+ * -- dwPort: Port to listen on.
291
+ * -- ctx: Optional context to pass to the callback function.
292
+ * -- pfnReservedSubmitCommandCB: Callback function to handle incoming commands.
293
+ * -- szTlsClientCert: Client CA certificate to trust for mTLS connections.
294
+ * -- szTlsServerCert: Server TLS certificate (incl. chain).
295
+ * -- szTlsServerCertPrivateKey: Server TLS certificate private key.
296
+ * -- return: Handle to the gRPC server, or NULL on failure.
297
+ */
298
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
299
+ LEECHGRPC_SERVER_HANDLE leechgrpc_server_create_secure_pemraw(
300
+ _In_ LPCSTR szAddress,
301
+ _In_ DWORD dwPort,
302
+ _In_opt_ PVOID ctx,
303
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
304
+ _In_ LPCSTR szTlsClientCert,
305
+ _In_ LPCSTR szTlsServerCert,
306
+ _In_ LPCSTR szTlsServerCertPrivateKey
307
+ );
308
+
309
+ typedef LEECHGRPC_SERVER_HANDLE(*pfn_leechgrpc_server_create_secure_pemraw)(
310
+ _In_ LPCSTR szAddress,
311
+ _In_ DWORD dwPort,
312
+ _In_opt_ PVOID ctx,
313
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
314
+ _In_ LPCSTR szTlsClientCert,
315
+ _In_ LPCSTR szTlsServerCert,
316
+ _In_ LPCSTR szTlsServerCertPrivateKey
317
+ );
318
+
319
+ /*
320
+ * Create a gRPC server with mTLS.
321
+ * -- szAddress: Address to listen on, e.g., "localhost" or "
322
+ * -- dwPort: Port to listen on.
323
+ * -- ctx: Optional context to pass to the callback function.
324
+ * -- pfnReservedSubmitCommandCB: Callback function to handle incoming commands.
325
+ * -- szTlsClientCertPath: Client CA certificate to trust for mTLS connections.
326
+ * -- szTlsServerCertPath: Server TLS certificate (incl. chain).
327
+ * -- szTlsServerCertPrivateKeyPath: Server TLS certificate private key.
328
+ * -- return: Handle to the gRPC server, or NULL on failure.
329
+ */
330
+ LEECHGRPC_EXPORTED_FUNCTION _Success_(return != NULL)
331
+ LEECHGRPC_SERVER_HANDLE leechgrpc_server_create_secure_pemfile(
332
+ _In_ LPCSTR szAddress,
333
+ _In_ DWORD dwPort,
334
+ _In_opt_ PVOID ctx,
335
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
336
+ _In_ LPCSTR szTlsClientCertPath,
337
+ _In_ LPCSTR szTlsServerCertPath,
338
+ _In_ LPCSTR szTlsServerCertPrivateKeyPath
339
+ );
340
+
341
+ typedef LEECHGRPC_SERVER_HANDLE(*pfn_leechgrpc_server_create_secure_pemfile)(
342
+ _In_ LPCSTR szAddress,
343
+ _In_ DWORD dwPort,
344
+ _In_opt_ PVOID ctx,
345
+ _In_ PFN_RESERVED_SUBMIT_COMMAND_CB pfnReservedSubmitCommandCB,
346
+ _In_ LPCSTR szTlsClientCertPath,
347
+ _In_ LPCSTR szTlsServerCertPath,
348
+ _In_ LPCSTR szTlsServerCertPrivateKeyPath
349
+ );
350
+
351
+ #ifdef __cplusplus
352
+ }
353
+ #endif /* __cplusplus */
354
+ #endif /* __LEECHGRPC_H__ */
@@ -1,5 +1,5 @@
1
1
  CC=gcc
2
- CFLAGS += -I. -D LINUX -D _GNU_SOURCE -shared -fPIC -fvisibility=hidden -pthread `pkg-config libusb-1.0 --libs --cflags`
2
+ CFLAGS += -I. -I../includes/ -D LINUX -D _GNU_SOURCE -shared -fPIC -fvisibility=hidden -pthread `pkg-config libusb-1.0 --libs --cflags`
3
3
  # DEBUG FLAGS BELOW
4
4
  # export ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_invalid_pointer_pairs=2
5
5
  # CFLAGS += -g -O0 -Wextra -Wno-unused-parameter -Wno-cast-function-type
@@ -0,0 +1,50 @@
1
+ CC=clang
2
+ CFLAGS += -I. -D MACOS -D _GNU_SOURCE -fPIC -fvisibility=hidden -pthread
3
+ CFLAGS += -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O1
4
+ CFLAGS += -Wall -Wno-multichar -Wno-unused-result -Wno-unused-variable -Wno-unused-value
5
+ CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
6
+ CFLAGS += -mmacosx-version-min=11.0
7
+ # DEBUG FLAGS BELOW
8
+ #CFLAGS += -O0
9
+ #CFLAGS += -fsanitize=address
10
+ # DEBUG FLAGS ABOVE
11
+ LDFLAGS += -g -dynamiclib -mmacosx-version-min=11.0
12
+
13
+ DEPS = leechcore.h
14
+ OBJ = oscompatibility.o leechcore.o util.o memmap.o device_file.o device_fpga.o device_hibr.o device_pmem.o device_tmd.o device_usb3380.o device_vmm.o device_vmware.o leechrpcclient.o ob/ob_core.o ob/ob_map.o ob/ob_set.o ob/ob_bytequeue.o
15
+
16
+ # ARCH SPECIFIC FLAGS:
17
+ CFLAGS_X86_64 = $(CFLAGS) -arch x86_64
18
+ CFLAGS_ARM64 = $(CFLAGS) -arch arm64
19
+ LDFLAGS_X86_64 = $(LDFLAGS) -arch x86_64
20
+ LDFLAGS_ARM64 = $(LDFLAGS) -arch arm64
21
+ OBJ_X86_64 = $(OBJ:.o=.o.x86_64)
22
+ OBJ_ARM64 = $(OBJ:.o=.o.arm64)
23
+
24
+ all: leechcore.dylib
25
+
26
+ %.o.x86_64: %.c $(DEPS)
27
+ $(CC) $(CFLAGS_X86_64) -c -o $@ $<
28
+
29
+ %.o.arm64: %.c $(DEPS)
30
+ $(CC) $(CFLAGS_ARM64) -c -o $@ $<
31
+
32
+ leechcore_x86_64.dylib: $(OBJ_X86_64)
33
+ $(CC) $(LDFLAGS_X86_64) -o $@ $^
34
+
35
+ leechcore_arm64.dylib: $(OBJ_ARM64)
36
+ $(CC) $(LDFLAGS_ARM64) -o $@ $^
37
+
38
+ leechcore.dylib: leechcore_x86_64.dylib leechcore_arm64.dylib
39
+ lipo -create -output leechcore.dylib leechcore_x86_64.dylib leechcore_arm64.dylib
40
+ install_name_tool -id @rpath/leechcore.dylib leechcore.dylib
41
+ mv leechcore.dylib ../files/
42
+ rm -f *.o *.o.x86_64 *.o.arm64 || true
43
+ rm -f */*.o */*.o.x86_64 */*.o.arm64 || true
44
+ rm -f *.dylib || true
45
+ true
46
+
47
+ clean:
48
+ rm -f *.o *.o.x86_64 *.o.arm64 || true
49
+ rm -f */*.o */*.o.x86_64 */*.o.arm64 || true
50
+ rm -f *.dylib || true
@@ -32,17 +32,20 @@
32
32
  #define FPGA_REG_SHADOWCFGSPACE 0xC000
33
33
 
34
34
  #ifdef _WIN32
35
- #define DEVICE_FPGA_FT601_LIBRARY "FTD3XX.dll"
35
+ #define DEVICE_FPGA_FT601_LIBRARY "FTD3XXWU.dll"
36
+ #define DEVICE_FPGA_FT601_OLD_LIBRARY "FTD3XX.dll"
36
37
  #define DEVICE_FPGA_FT2XX_LIBRARY "FTD2XX.dll"
37
38
  #define DEVICE_FPGA_DRIVER_LIBRARY "leechcore_driver.dll"
38
39
  #endif /* _WIN32 */
39
40
  #ifdef LINUX
40
41
  #define DEVICE_FPGA_FT601_LIBRARY "leechcore_ft601_driver_linux.so"
42
+ #define DEVICE_FPGA_FT601_OLD_LIBRARY ""
41
43
  #define DEVICE_FPGA_FT2XX_LIBRARY "libftd2xx.so"
42
44
  #define DEVICE_FPGA_DRIVER_LIBRARY "leechcore_driver.so"
43
45
  #endif /* LINUX */
44
46
  #ifdef MACOS
45
47
  #define DEVICE_FPGA_FT601_LIBRARY "leechcore_ft601_driver_macos.dylib"
48
+ #define DEVICE_FPGA_FT601_OLD_LIBRARY ""
46
49
  #define DEVICE_FPGA_FT2XX_LIBRARY "libftd2xx.dylib"
47
50
  #define DEVICE_FPGA_DRIVER_LIBRARY "leechcore_driver.dylib"
48
51
  #endif /* MACOS */
@@ -804,13 +807,15 @@ VOID DeviceFPGA_Initialize_LinuxMultiHandle_LockRelease(_In_ QWORD qwDeviceIndex
804
807
 
805
808
  LPSTR DeviceFPGA_InitializeFT601(_In_ PDEVICE_CONTEXT_FPGA ctx, _In_ BOOL fFT601, _In_ BOOL fCustomDriver)
806
809
  {
807
- LPSTR szErrorReason;
810
+ LPSTR szErrorReason = NULL;
808
811
  CHAR c, szModuleFTDI[MAX_PATH + 1] = { 0 };
809
812
  DWORD status;
813
+ BOOL fUseFTD3XXWU = TRUE, fFailFTD3XXWU = FALSE;
810
814
  ULONG(WINAPI *pfnFT_GetChipConfiguration)(HANDLE ftHandle, PVOID pvConfiguration);
811
815
  ULONG(WINAPI *pfnFT_SetChipConfiguration)(HANDLE ftHandle, PVOID pvConfiguration);
812
816
  ULONG(WINAPI *pfnFT_SetSuspendTimeout)(HANDLE ftHandle, ULONG Timeout);
813
817
  FT_60XCONFIGURATION oCfgNew, oCfgOld;
818
+ ftdi_retry_old:
814
819
  if(DeviceFPGA_Initialize_LinuxMultiHandle_LockCheck(ctx->qwDeviceIndex)) {
815
820
  szErrorReason = "FPGA linux handle already open";
816
821
  goto fail;
@@ -839,15 +844,18 @@ LPSTR DeviceFPGA_InitializeFT601(_In_ PDEVICE_CONTEXT_FPGA ctx, _In_ BOOL fFT601
839
844
  }
840
845
  // Load FTDI Library:
841
846
  if(fFT601) {
842
- if(!ctx->dev.hModule) { ctx->dev.hModule = LoadLibraryA(DEVICE_FPGA_FT601_LIBRARY); }
847
+ if(!ctx->dev.hModule) { ctx->dev.hModule = LoadLibraryA((fUseFTD3XXWU ? DEVICE_FPGA_FT601_LIBRARY : DEVICE_FPGA_FT601_OLD_LIBRARY)); }
843
848
  if(!ctx->dev.hModule) {
844
849
  Util_GetPathLib(szModuleFTDI);
845
- strcat_s(szModuleFTDI, sizeof(szModuleFTDI) - 1, DEVICE_FPGA_FT601_LIBRARY);
850
+ strcat_s(szModuleFTDI, sizeof(szModuleFTDI) - 1, (fUseFTD3XXWU ? DEVICE_FPGA_FT601_LIBRARY : DEVICE_FPGA_FT601_OLD_LIBRARY));
846
851
  ctx->dev.hModule = LoadLibraryA(szModuleFTDI);
847
852
  }
848
853
  ctx->fFT601 = ctx->dev.hModule ? TRUE : FALSE;
849
854
  }
850
855
  if(!ctx->dev.hModule) {
856
+ #ifdef _WIN32
857
+ fFailFTD3XXWU = fUseFTD3XXWU;
858
+ #endif /* _WIN32 */
851
859
  szErrorReason = "Unable to load '"DEVICE_FPGA_FT601_LIBRARY"' or '"DEVICE_FPGA_DRIVER_LIBRARY"'";
852
860
  goto fail;
853
861
  }
@@ -878,7 +886,12 @@ LPSTR DeviceFPGA_InitializeFT601(_In_ PDEVICE_CONTEXT_FPGA ctx, _In_ BOOL fFT601
878
886
  if(fFT601) {
879
887
  status = ctx->dev.pfnFT_Create((PVOID)ctx->qwDeviceIndex, 0x10 /*FT_OPEN_BY_INDEX*/, &ctx->dev.hFTDI);
880
888
  if(status || !ctx->dev.hFTDI) {
881
- szErrorReason = "Unable to connect to FPGA device";
889
+ #ifdef _WIN32
890
+ fFailFTD3XXWU = fUseFTD3XXWU;
891
+ #endif /* _WIN32 */
892
+ if(!szErrorReason) {
893
+ szErrorReason = "Unable to connect to FPGA device";
894
+ }
882
895
  goto fail;
883
896
  }
884
897
  ctx->dev.pfnFT_AbortPipe(ctx->dev.hFTDI, 0x02);
@@ -934,6 +947,11 @@ fail:
934
947
  if(ctx->dev.hModule) { FreeLibrary(ctx->dev.hModule); }
935
948
  ctx->dev.hModule = NULL;
936
949
  ctx->dev.hFTDI = NULL;
950
+ // retry with older FTD3XX driver if FTD3XXWU fails.
951
+ if(fFailFTD3XXWU) {
952
+ fUseFTD3XXWU = FALSE;
953
+ goto ftdi_retry_old;
954
+ }
937
955
  return szErrorReason;
938
956
  }
939
957
 
@@ -183,7 +183,7 @@ BOOL DevicePMEM_SvcStart(_In_ PLC_CONTEXT ctxLC)
183
183
  pDriverFile = NULL;
184
184
  break;
185
185
  }
186
- ZeroMemory(szDriverFile, _countof(szDriverFile));
186
+ strcpy_s(szDriverFile, _countof(szDriverFile), ctxLC->Config.szDevice);
187
187
  }
188
188
  }
189
189
  if(fopen_s(&pDriverFile, szDriverFile, "rb") || !pDriverFile) {