Skip to content

Commit d65545a

Browse files
committed
fix: another attempt
1 parent 188b1a8 commit d65545a

4 files changed

Lines changed: 74 additions & 66 deletions

File tree

.github/workflows/build.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,15 @@ jobs:
5555
uses: msys2/setup-msys2@v2
5656
with:
5757
update: true
58-
install: mingw-w64-i686-gcc mingw-w64-x86_64-gcc
59-
60-
- name: Debug PATH
61-
run: |
62-
Get-ChildItem -Path "C:\msys64" -Recurse -Directory | Select-String "mingw"
58+
install: ${{ matrix.target == 'i686-pc-windows-gnu' && 'mingw-w64-i686-gcc' || 'mingw-w64-x86_64-gcc' }}
6359

6460
- name: Add MinGW to PATH
6561
run: |
66-
echo "C:\\msys64\\mingw32\\bin" >> $env:GITHUB_PATH
67-
echo "C:\\msys64\\mingw64\\bin" >> $env:GITHUB_PATH
62+
if ("${{ matrix.target }}" -eq "i686-pc-windows-gnu") {
63+
echo "C:\\msys64\\mingw32\\bin" >> $env:GITHUB_PATH
64+
} else {
65+
echo "C:\\msys64\\mingw64\\bin" >> $env:GITHUB_PATH
66+
}
6867
shell: pwsh
6968

7069
- name: Build for ${{ matrix.target }}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ lazy_static::lazy_static! {
3434

3535
// dll functions
3636
#[no_mangle]
37-
pub extern "C" fn Inject(path: *const c_char, pid: u32) -> bool {
37+
pub extern "system" fn Inject(path: *const c_char, pid: u32) -> bool {
3838
if path.is_null() {
3939
println!("[WaspInput]: Invalid string\n");
4040
return false;
@@ -72,7 +72,7 @@ pub extern "C" fn Inject(path: *const c_char, pid: u32) -> bool {
7272
}
7373

7474
#[no_mangle]
75-
pub extern "C" fn OpenConsole() {
75+
pub extern "system" fn OpenConsole() {
7676
let hwnd = WINDOW_HWND.lock().unwrap();
7777

7878
match *hwnd {
@@ -82,7 +82,7 @@ pub extern "C" fn OpenConsole() {
8282
}
8383

8484
#[no_mangle]
85-
pub extern "C" fn GetInputState() -> bool {
85+
pub extern "system" fn GetInputState() -> bool {
8686
let hwnd = WINDOW_HWND.lock().unwrap();
8787
match *hwnd {
8888
Some(h) => is_input_enabled(h),
@@ -91,7 +91,7 @@ pub extern "C" fn GetInputState() -> bool {
9191
}
9292

9393
#[no_mangle]
94-
pub extern "C" fn SetInputState(state: bool) -> bool {
94+
pub extern "system" fn SetInputState(state: bool) -> bool {
9595
let hwnd = WINDOW_HWND.lock().unwrap();
9696
match *hwnd {
9797
Some(h) => toggle_input(h, state),

src/simba/plugin.rs

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::shared::windows::get_proc_address;
77
use crate::{PASCAL_EXPORTS, PASCAL_TYPES}; // bring in the constants
88

99
#[no_mangle]
10-
pub extern "C" fn GetFunctionInfo(
10+
pub extern "system" fn GetFunctionInfo(
1111
index: c_int,
1212
address: *mut *mut c_void,
1313
definition: *mut *mut c_char,
@@ -27,12 +27,12 @@ pub extern "C" fn GetFunctionInfo(
2727
}
2828

2929
#[no_mangle]
30-
pub extern "C" fn GetFunctionCount() -> c_int {
30+
pub extern "system" fn GetFunctionCount() -> c_int {
3131
PASCAL_EXPORTS.len() as c_int
3232
}
3333

3434
#[no_mangle]
35-
pub extern "C" fn GetTypeInfo(
35+
pub extern "system" fn GetTypeInfo(
3636
index: c_int,
3737
typ: *mut *mut c_char,
3838
definition: *mut *mut c_char,
@@ -53,7 +53,7 @@ pub extern "C" fn GetTypeInfo(
5353
}
5454

5555
#[no_mangle]
56-
pub extern "C" fn GetTypeCount() -> c_int {
56+
pub extern "system" fn GetTypeCount() -> c_int {
5757
PASCAL_TYPES.len() as c_int
5858
}
5959

@@ -68,45 +68,50 @@ pub struct TSimbaInfomation {
6868

6969
#[repr(C, packed)]
7070
pub struct TSimbaMethods {
71-
pub run_on_main_thread:
72-
Option<unsafe extern "C" fn(method: extern "C" fn(*mut c_void), data: *mut c_void)>,
73-
pub get_mem: Option<unsafe extern "C" fn(size: usize) -> *mut c_void>,
74-
pub free_mem: Option<unsafe extern "C" fn(ptr: *mut c_void)>,
75-
pub alloc_mem: Option<unsafe extern "C" fn(size: usize) -> *mut c_void>,
71+
pub run_on_main_thread: Option<
72+
unsafe extern "system" fn(method: extern "system" fn(*mut c_void), data: *mut c_void),
73+
>,
74+
pub get_mem: Option<unsafe extern "system" fn(size: usize) -> *mut c_void>,
75+
pub free_mem: Option<unsafe extern "system" fn(ptr: *mut c_void)>,
76+
pub alloc_mem: Option<unsafe extern "system" fn(size: usize) -> *mut c_void>,
7677
pub realloc_mem:
77-
Option<unsafe extern "C" fn(ptr: *mut *mut c_void, size: usize) -> *mut c_void>,
78-
pub mem_size: Option<unsafe extern "C" fn(ptr: *mut c_void) -> usize>,
78+
Option<unsafe extern "system" fn(ptr: *mut *mut c_void, size: usize) -> *mut c_void>,
79+
pub mem_size: Option<unsafe extern "system" fn(ptr: *mut c_void) -> usize>,
7980

80-
pub raise_exception: Option<unsafe extern "C" fn(message: *const c_char)>,
81+
pub raise_exception: Option<unsafe extern "system" fn(message: *const c_char)>,
8182

8283
pub get_type_info:
83-
Option<unsafe extern "C" fn(compiler: *mut c_void, typ: *const c_char) -> *mut c_void>,
84-
pub get_type_info_size: Option<unsafe extern "C" fn(typeinfo: *mut c_void) -> isize>,
84+
Option<unsafe extern "system" fn(compiler: *mut c_void, typ: *const c_char) -> *mut c_void>,
85+
pub get_type_info_size: Option<unsafe extern "system" fn(typeinfo: *mut c_void) -> isize>,
8586
pub get_type_info_field_offset:
86-
Option<unsafe extern "C" fn(typeinfo: *mut c_void, field: *const c_char) -> isize>,
87+
Option<unsafe extern "system" fn(typeinfo: *mut c_void, field: *const c_char) -> isize>,
8788

8889
pub allocate_raw_array:
89-
Option<unsafe extern "C" fn(element_size: usize, len: usize) -> *mut c_void>,
90-
pub reallocate_raw_array:
91-
Option<unsafe extern "C" fn(array: *mut *mut c_void, element_size: usize, new_len: usize)>,
90+
Option<unsafe extern "system" fn(element_size: usize, len: usize) -> *mut c_void>,
91+
pub reallocate_raw_array: Option<
92+
unsafe extern "system" fn(array: *mut *mut c_void, element_size: usize, new_len: usize),
93+
>,
9294

9395
pub allocate_array:
94-
Option<unsafe extern "C" fn(type_info: *mut c_void, len: usize) -> *mut c_void>,
95-
pub allocate_string: Option<unsafe extern "C" fn(data: *const c_char) -> *mut c_void>,
96-
pub allocate_unicode_string: Option<unsafe extern "C" fn(data: *const u16) -> *mut c_void>,
97-
98-
pub set_array_length:
99-
Option<unsafe extern "C" fn(type_info: *mut c_void, var: *mut *mut c_void, new_len: usize)>,
100-
pub get_array_length: Option<unsafe extern "C" fn(var: *mut c_void) -> usize>,
101-
102-
pub external_image_create: Option<unsafe extern "C" fn(auto_resize: bool) -> *mut c_void>,
103-
pub external_image_set_memory:
104-
Option<unsafe extern "C" fn(img: *mut c_void, data: *mut c_void, width: i32, height: i32)>,
96+
Option<unsafe extern "system" fn(type_info: *mut c_void, len: usize) -> *mut c_void>,
97+
pub allocate_string: Option<unsafe extern "system" fn(data: *const c_char) -> *mut c_void>,
98+
pub allocate_unicode_string: Option<unsafe extern "system" fn(data: *const u16) -> *mut c_void>,
99+
100+
pub set_array_length: Option<
101+
unsafe extern "system" fn(type_info: *mut c_void, var: *mut *mut c_void, new_len: usize),
102+
>,
103+
pub get_array_length: Option<unsafe extern "system" fn(var: *mut c_void) -> usize>,
104+
105+
pub external_image_create: Option<unsafe extern "system" fn(auto_resize: bool) -> *mut c_void>,
106+
pub external_image_set_memory: Option<
107+
unsafe extern "system" fn(img: *mut c_void, data: *mut c_void, width: i32, height: i32),
108+
>,
105109
pub external_image_resize:
106-
Option<unsafe extern "C" fn(img: *mut c_void, new_width: i32, new_height: i32)>,
110+
Option<unsafe extern "system" fn(img: *mut c_void, new_width: i32, new_height: i32)>,
107111
pub external_image_set_user_data:
108-
Option<unsafe extern "C" fn(img: *mut c_void, user_data: *mut c_void)>,
109-
pub external_image_get_user_data: Option<unsafe extern "C" fn(img: *mut c_void) -> *mut c_void>,
112+
Option<unsafe extern "system" fn(img: *mut c_void, user_data: *mut c_void)>,
113+
pub external_image_get_user_data:
114+
Option<unsafe extern "system" fn(img: *mut c_void) -> *mut c_void>,
110115
}
111116

112117
#[no_mangle]
@@ -123,34 +128,34 @@ pub static mut PLUGIN_SIMBA_METHODS: TSimbaMethods = unsafe { zeroed() };
123128
// Optional memory management helpers
124129
#[repr(C)]
125130
pub struct TSimbaMemoryAllocators {
126-
pub get_mem: Option<extern "C" fn(size: usize) -> *mut c_void>,
127-
pub free_mem: Option<extern "C" fn(p: *mut c_void) -> usize>,
131+
pub get_mem: Option<extern "system" fn(size: usize) -> *mut c_void>,
132+
pub free_mem: Option<extern "system" fn(p: *mut c_void) -> usize>,
128133
}
129134

130135
#[repr(C)]
131136
pub struct TMemoryManager {
132-
pub get_mem: Option<extern "C" fn(size: usize) -> *mut c_void>,
133-
pub free_mem: Option<extern "C" fn(p: *mut c_void) -> usize>,
137+
pub get_mem: Option<extern "system" fn(size: usize) -> *mut c_void>,
138+
pub free_mem: Option<extern "system" fn(p: *mut c_void) -> usize>,
134139
}
135140

136141
#[no_mangle]
137-
pub unsafe extern "C" fn SetPluginMemManager(mem_mgr: TMemoryManager) {
142+
pub unsafe extern "system" fn SetPluginMemManager(mem_mgr: TMemoryManager) {
138143
let _ = mem_mgr;
139144
// Implement if needed
140145
}
141146

142147
#[no_mangle]
143-
pub unsafe extern "C" fn SetPluginSimbaMethods(methods: TSimbaMethods) {
148+
pub unsafe extern "system" fn SetPluginSimbaMethods(methods: TSimbaMethods) {
144149
PLUGIN_SIMBA_METHODS = methods;
145150
}
146151

147152
#[no_mangle]
148-
pub unsafe extern "C" fn SetPluginSimbaMemoryAllocators(_allocators: TSimbaMemoryAllocators) {
153+
pub unsafe extern "system" fn SetPluginSimbaMemoryAllocators(_allocators: TSimbaMemoryAllocators) {
149154
// Implement if needed
150155
}
151156

152157
#[no_mangle]
153-
pub unsafe extern "C" fn RegisterSimbaPlugin(
158+
pub unsafe extern "system" fn RegisterSimbaPlugin(
154159
info: *const TSimbaInfomation,
155160
methods: *const TSimbaMethods,
156161
) {

src/simba/target.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn get_mouse_pos(hwnd: u64) -> POINT {
5151
}
5252

5353
#[no_mangle]
54-
pub extern "C" fn SimbaPluginTarget_Request(args: *const c_char) -> *mut SimbaTarget {
54+
pub extern "system" fn SimbaPluginTarget_Request(args: *const c_char) -> *mut SimbaTarget {
5555
if args.is_null() {
5656
return null_mut();
5757
}
@@ -86,7 +86,7 @@ pub extern "C" fn SimbaPluginTarget_Request(args: *const c_char) -> *mut SimbaTa
8686
}
8787

8888
#[no_mangle]
89-
pub extern "C" fn SimbaPluginTarget_RequestWithDebugImage(
89+
pub extern "system" fn SimbaPluginTarget_RequestWithDebugImage(
9090
args: *const c_char,
9191
overlay: *mut *mut c_void,
9292
) -> *mut SimbaTarget {
@@ -124,7 +124,7 @@ pub extern "C" fn SimbaPluginTarget_RequestWithDebugImage(
124124
}
125125

126126
#[no_mangle]
127-
pub extern "C" fn SimbaPluginTarget_Release(target: *mut SimbaTarget) {
127+
pub extern "system" fn SimbaPluginTarget_Release(target: *mut SimbaTarget) {
128128
if target.is_null() {
129129
return;
130130
}
@@ -141,7 +141,7 @@ pub extern "C" fn SimbaPluginTarget_Release(target: *mut SimbaTarget) {
141141
}
142142

143143
#[no_mangle]
144-
pub extern "C" fn SimbaPluginTarget_GetDimensions(
144+
pub extern "system" fn SimbaPluginTarget_GetDimensions(
145145
target: *mut SimbaTarget,
146146
width: *mut c_int,
147147
height: *mut c_int,
@@ -164,7 +164,7 @@ pub extern "C" fn SimbaPluginTarget_GetDimensions(
164164
}
165165

166166
#[no_mangle]
167-
pub extern "C" fn SimbaPluginTarget_GetImageData(
167+
pub extern "system" fn SimbaPluginTarget_GetImageData(
168168
target: *mut SimbaTarget,
169169
x: c_int,
170170
y: c_int,
@@ -205,7 +205,7 @@ pub extern "C" fn SimbaPluginTarget_GetImageData(
205205
}
206206

207207
#[no_mangle]
208-
pub extern "C" fn SimbaPluginTarget_MousePressed(
208+
pub extern "system" fn SimbaPluginTarget_MousePressed(
209209
target: *mut SimbaTarget,
210210
mouse_button: c_int,
211211
) -> bool {
@@ -228,7 +228,7 @@ pub extern "C" fn SimbaPluginTarget_MousePressed(
228228
}
229229

230230
#[no_mangle]
231-
pub extern "C" fn SimbaPluginTarget_MousePosition(
231+
pub extern "system" fn SimbaPluginTarget_MousePosition(
232232
target: *mut SimbaTarget,
233233
x: *mut i32,
234234
y: *mut i32,
@@ -250,7 +250,11 @@ pub extern "C" fn SimbaPluginTarget_MousePosition(
250250
}
251251

252252
#[no_mangle]
253-
pub extern "C" fn SimbaPluginTarget_MouseTeleport(target: *mut SimbaTarget, x: c_int, y: c_int) {
253+
pub extern "system" fn SimbaPluginTarget_MouseTeleport(
254+
target: *mut SimbaTarget,
255+
x: c_int,
256+
y: c_int,
257+
) {
254258
if target.is_null() {
255259
println!("[WaspInput]: target is null!\r\n");
256260
return;
@@ -263,7 +267,7 @@ pub extern "C" fn SimbaPluginTarget_MouseTeleport(target: *mut SimbaTarget, x: c
263267
}
264268

265269
#[no_mangle]
266-
pub extern "C" fn SimbaPluginTarget_MouseUp(target: *mut SimbaTarget, mouse_button: c_int) {
270+
pub extern "system" fn SimbaPluginTarget_MouseUp(target: *mut SimbaTarget, mouse_button: c_int) {
267271
if target.is_null() {
268272
println!("[WaspInput]: target is null!\r\n");
269273
return;
@@ -294,7 +298,7 @@ pub extern "C" fn SimbaPluginTarget_MouseUp(target: *mut SimbaTarget, mouse_butt
294298
}
295299

296300
#[no_mangle]
297-
pub extern "C" fn SimbaPluginTarget_MouseDown(target: *mut SimbaTarget, mouse_button: c_int) {
301+
pub extern "system" fn SimbaPluginTarget_MouseDown(target: *mut SimbaTarget, mouse_button: c_int) {
298302
if target.is_null() {
299303
println!("[WaspInput]: target is null!\r\n");
300304
return;
@@ -326,7 +330,7 @@ pub extern "C" fn SimbaPluginTarget_MouseDown(target: *mut SimbaTarget, mouse_bu
326330
}
327331

328332
#[no_mangle]
329-
pub extern "C" fn SimbaPluginTarget_MouseScroll(target: *mut SimbaTarget, scrolls: c_int) {
333+
pub extern "system" fn SimbaPluginTarget_MouseScroll(target: *mut SimbaTarget, scrolls: c_int) {
330334
if target.is_null() {
331335
println!("[WaspInput]: target is null!\r\n");
332336
return;
@@ -341,7 +345,7 @@ pub extern "C" fn SimbaPluginTarget_MouseScroll(target: *mut SimbaTarget, scroll
341345
}
342346

343347
#[no_mangle]
344-
pub extern "C" fn SimbaPluginTarget_KeyDown(target: *mut SimbaTarget, key: c_int) {
348+
pub extern "system" fn SimbaPluginTarget_KeyDown(target: *mut SimbaTarget, key: c_int) {
345349
if target.is_null() {
346350
println!("[WaspInput]: target is null!\r\n");
347351
return;
@@ -355,7 +359,7 @@ pub extern "C" fn SimbaPluginTarget_KeyDown(target: *mut SimbaTarget, key: c_int
355359
}
356360

357361
#[no_mangle]
358-
pub extern "C" fn SimbaPluginTarget_KeyUp(target: *mut SimbaTarget, key: c_int) {
362+
pub extern "system" fn SimbaPluginTarget_KeyUp(target: *mut SimbaTarget, key: c_int) {
359363
if target.is_null() {
360364
println!("[WaspInput]: target is null!\r\n");
361365
return;
@@ -369,7 +373,7 @@ pub extern "C" fn SimbaPluginTarget_KeyUp(target: *mut SimbaTarget, key: c_int)
369373
}
370374

371375
#[no_mangle]
372-
pub extern "C" fn SimbaPluginTarget_KeySend(
376+
pub extern "system" fn SimbaPluginTarget_KeySend(
373377
target: *mut SimbaTarget,
374378
text: *mut c_char,
375379
len: c_int,
@@ -396,7 +400,7 @@ pub extern "C" fn SimbaPluginTarget_KeySend(
396400
}
397401

398402
#[no_mangle]
399-
pub extern "C" fn SimbaPluginTarget_KeyPressed(target: *mut SimbaTarget, key: c_int) -> bool {
403+
pub extern "system" fn SimbaPluginTarget_KeyPressed(target: *mut SimbaTarget, key: c_int) -> bool {
400404
let _lock = TARGETS.lock().unwrap();
401405
let target = unsafe { &*target };
402406

0 commit comments

Comments
 (0)