Skip to content

Commit 5e25388

Browse files
rliebigsecretnonempty
authored andcommitted
Remove the size limit for memory read and write (revamped) (unicorn-engine#2144)
* modify uc_priv.h to use 64 bit hwaddr type for length for uc_write_mem_t and uc_read_mem_t * propogate 64 bit address support to memory function inside unicorn.h * modify physical memory functions to ensure 64 bit support for size parameters * apply uint64_t size handling inside the memory handling main functions * remove INT_MAX size check as we now use a 64 bit address * add @secretnonempty unit test for large memory addresses to avoid regression * replace size_t in python3 bindings with u64 * adjust rust bindings * use format.sh script to improve formatting * small adjustments to java bindings, because jlong type is sometimes already used * adjust dotnet bindings to reflect new type sizes * adjust pascal bindings * adjust ruby bindings * adjust vb6 bindings * adjust zig bindings for 64 bit size support * fix build.zig.zon for newer zig versions * add haskell binding support for 64 bit sizes * use mlugg/setup-zig instead of goto-bus-stop/setup-zig github action to get access to current zig releases * use uint64_t instead of size_t for uc_mem_unmap * add whitespace between functions to preserver formatting * add precompiler check for android and abort execution of testcase to avoid infinite low memory killer loop * downgrade zig version to 0.14.0 again to ensure that pipeline can run through * adjust rust mmio_unwrap type to use u64 * change ffi size type of uc_mem_map_ptr into u64 * add warning to rust slicing * return read_mem_as_vec to earlier state, leave usize as argument because there cannot be larger vec![] anyway * adjust regions inside MmioCallbackScope to use u64 for region sizes * adjust regions inside MmioCallbackScope to use u64 for region sizes inside search vec * finalize dotnet bindings inside IBinding.fs * fix typo * adjust types inside Unicorn.fs * finalize type wrangling inside F# bindings, setting MemRead and MemWrite to correct types * fix missing bracket inside bindings/rust/src/lib.rs * replace ffi interface to hook interface inside rust lib * fix testcases to use u64 for longer references Co-authored-by: r0b0t <[email protected]>
1 parent 76b352c commit 5e25388

File tree

27 files changed

+541
-172
lines changed

27 files changed

+541
-172
lines changed

.github/workflows/zigbuild.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
with:
2727
submodules: recursive
2828
fetch-depth: 0
29-
- uses: goto-bus-stop/setup-zig@v2
29+
- uses: mlugg/setup-zig@v1
3030
with:
31-
version: 0.13.0
31+
version: 0.14.0
3232
- uses: lukka/get-cmake@latest
3333
with:
3434
cmakeVersion: latest
@@ -50,9 +50,9 @@ jobs:
5050
with:
5151
submodules: recursive
5252
fetch-depth: 0
53-
- uses: goto-bus-stop/setup-zig@v2
53+
- uses: mlugg/setup-zig@v1
5454
with:
55-
version: 0.13.0
55+
version: 0.14.0
5656
- uses: lukka/get-cmake@latest
5757
with:
5858
cmakeVersion: latest

bindings/dotnet/UnicornEngine/Binding/IBinding.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ type IBinding =
1212
abstract Errono : UIntPtr -> Int32
1313
abstract RegRead : UIntPtr * Int32 * Byte array -> Int32
1414
abstract RegWrite : UIntPtr * Int32 * Byte array -> Int32
15-
abstract MemRead : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
16-
abstract MemWrite : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
15+
abstract MemRead : UIntPtr * UInt64 * Byte array * UInt64 -> Int32
16+
abstract MemWrite : UIntPtr * UInt64 * Byte array * UInt64 -> Int32
1717
abstract EmuStart : UIntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32
1818
abstract EmuStop : UIntPtr -> Int32
1919
abstract HookDel : UIntPtr * UIntPtr -> Int32
20-
abstract MemMap : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
21-
abstract MemMapPtr : UIntPtr * UInt64 * UIntPtr * UInt32 * UIntPtr -> Int32
22-
abstract MemUnmap : UIntPtr * UInt64 * UIntPtr -> Int32
23-
abstract MemProtect : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
20+
abstract MemMap : UIntPtr * UInt64 * UInt64 * UInt32 -> Int32
21+
abstract MemMapPtr : UIntPtr * UInt64 * UInt64 * UInt32 * UIntPtr -> Int32
22+
abstract MemUnmap : UIntPtr * UInt64 * UInt64 -> Int32
23+
abstract MemProtect : UIntPtr * UInt64 * UInt64 * UInt32 -> Int32
2424
abstract HookAddNoarg : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 -> Int32
2525
abstract HookAddArg0 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * Int32 -> Int32
2626
abstract HookAddArg0Arg1 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32

bindings/dotnet/UnicornEngine/Binding/NativeBinding.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ module NativeBinding =
1818
extern Int32 uc_close(UIntPtr eng)
1919

2020
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
21-
extern Int32 uc_mem_map(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perm)
21+
extern Int32 uc_mem_map(UIntPtr eng, UInt64 address, UInt64 size, UInt32 perm)
2222

2323
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
24-
extern Int32 uc_mem_map_ptr(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perm, UIntPtr ptr)
24+
extern Int32 uc_mem_map_ptr(UIntPtr eng, UInt64 address, UInt64 size, UInt32 perm, UIntPtr ptr)
2525

2626
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
27-
extern Int32 uc_mem_unmap(UIntPtr eng, UInt64 address, UIntPtr size)
27+
extern Int32 uc_mem_unmap(UIntPtr eng, UInt64 address, UInt64 size)
2828

2929
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
30-
extern Int32 uc_mem_protect(UIntPtr eng, UInt64 address, UIntPtr size, UInt32 perms)
30+
extern Int32 uc_mem_protect(UIntPtr eng, UInt64 address, UInt64 size, UInt32 perms)
3131

3232
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
33-
extern Int32 uc_mem_write(UIntPtr eng, UInt64 address, Byte[] value, UIntPtr size)
33+
extern Int32 uc_mem_write(UIntPtr eng, UInt64 address, Byte[] value, UInt64 size)
3434

3535
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
36-
extern Int32 uc_mem_read(UIntPtr eng, UInt64 address, Byte[] value, UIntPtr size)
36+
extern Int32 uc_mem_read(UIntPtr eng, UInt64 address, Byte[] value, UInt64 size)
3737

3838
[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
3939
extern Int32 uc_reg_write(UIntPtr eng, Int32 regId, Byte[] value)
@@ -90,4 +90,4 @@ module NativeBinding =
9090
member thi.HookAddNoarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd) = uc_hook_add_noarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd)
9191
member thi.HookAddArg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0) = uc_hook_add_arg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0)
9292
member thi.HookAddArg0Arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1) = uc_hook_add_arg0_arg1(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0, arg1)
93-
}
93+
}

bindings/dotnet/UnicornEngine/Unicorn.fs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,30 @@ and Unicorn(arch: Int32, mode: Int32, binding: IBinding) =
8484

8585
new(arch, mode) = new Unicorn(arch, mode, BindingFactory.getDefault())
8686

87-
member this.MemMap(address: Int64, size: Int64, perm: Int32) =
88-
let size = new UIntPtr(uint64 size)
87+
member this.MemMap(address: Int64, size: UInt64, perm: Int32) =
8988
match binding.MemMap(_eng.[0], uint64 address, size, uint32 perm) |> checkResult with
9089
| Some e -> raise e | None -> ()
9190

92-
member this.MemMapPtr(address: Int64, size: Int64, perm: Int32, ptr: IntPtr) =
93-
let size = new UIntPtr(uint64 size)
91+
member this.MemMapPtr(address: Int64, size: UInt64, perm: Int32, ptr: IntPtr) =
9492
let ptr = new UIntPtr(ptr.ToPointer())
9593
match binding.MemMapPtr(_eng.[0], uint64 address, size, uint32 perm, ptr) |> checkResult with
9694
| Some e -> raise e | None -> ()
9795

98-
member this.MemUnmap(address: Int64, size: Int64) =
99-
let size = new UIntPtr(uint64 size)
96+
member this.MemUnmap(address: Int64, size: UInt64) =
10097
match binding.MemUnmap(_eng.[0], uint64 address, size) |> checkResult with
10198
| Some e -> raise e | None -> ()
10299

103-
member this.MemProtect(address: Int64, size: Int64, ?perm: Int32) =
104-
let size = new UIntPtr(uint64 size)
100+
member this.MemProtect(address: Int64, size: UInt64, ?perm: Int32) =
105101
let perm = defaultArg perm Common.UC_PROT_ALL
106102
match binding.MemProtect(_eng.[0], uint64 address, size, uint32 perm) |> checkResult with
107103
| Some e -> raise e | None -> ()
108104

109105
member this.MemWrite(address: Int64, value: Byte array) =
110-
match binding.MemWrite(_eng.[0], uint64 address, value, new UIntPtr(uint32 value.Length)) |> checkResult with
106+
match binding.MemWrite(_eng.[0], uint64 address, value, uint64 value.Length) |> checkResult with
111107
| Some e -> raise e | None -> ()
112108

113109
member this.MemRead(address: Int64, memValue: Byte array) =
114-
match binding.MemRead(_eng.[0], uint64 address, memValue, new UIntPtr(uint32 memValue.Length)) |> checkResult with
110+
match binding.MemRead(_eng.[0], uint64 address, memValue, uint64 memValue.Length) |> checkResult with
115111
| Some e -> raise e | None -> ()
116112

117113
member this.RegWrite(regId: Int32, value: Byte array) =

bindings/go/unicorn/unicorn.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ func (u *uc) MemWrite(addr uint64, data []byte) error {
187187
if len(data) == 0 {
188188
return nil
189189
}
190-
return errReturn(C.uc_mem_write(u.handle, C.uint64_t(addr), unsafe.Pointer(&data[0]), C.size_t(len(data))))
190+
return errReturn(C.uc_mem_write(u.handle, C.uint64_t(addr), unsafe.Pointer(&data[0]), C.uint64_t(len(data))))
191191
}
192192

193193
func (u *uc) MemReadInto(dst []byte, addr uint64) error {
194194
if len(dst) == 0 {
195195
return nil
196196
}
197-
return errReturn(C.uc_mem_read(u.handle, C.uint64_t(addr), unsafe.Pointer(&dst[0]), C.size_t(len(dst))))
197+
return errReturn(C.uc_mem_read(u.handle, C.uint64_t(addr), unsafe.Pointer(&dst[0]), C.uint64_t(len(dst))))
198198
}
199199

200200
func (u *uc) MemRead(addr, size uint64) ([]byte, error) {
@@ -203,23 +203,23 @@ func (u *uc) MemRead(addr, size uint64) ([]byte, error) {
203203
}
204204

205205
func (u *uc) MemMapProt(addr, size uint64, prot int) error {
206-
return errReturn(C.uc_mem_map(u.handle, C.uint64_t(addr), C.size_t(size), C.uint32_t(prot)))
206+
return errReturn(C.uc_mem_map(u.handle, C.uint64_t(addr), C.uint64_t(size), C.uint32_t(prot)))
207207
}
208208

209209
func (u *uc) MemMap(addr, size uint64) error {
210210
return u.MemMapProt(addr, size, PROT_ALL)
211211
}
212212

213213
func (u *uc) MemMapPtr(addr, size uint64, prot int, ptr unsafe.Pointer) error {
214-
return errReturn(C.uc_mem_map_ptr(u.handle, C.uint64_t(addr), C.size_t(size), C.uint32_t(prot), ptr))
214+
return errReturn(C.uc_mem_map_ptr(u.handle, C.uint64_t(addr), C.uint64_t(size), C.uint32_t(prot), ptr))
215215
}
216216

217217
func (u *uc) MemProtect(addr, size uint64, prot int) error {
218-
return errReturn(C.uc_mem_protect(u.handle, C.uint64_t(addr), C.size_t(size), C.uint32_t(prot)))
218+
return errReturn(C.uc_mem_protect(u.handle, C.uint64_t(addr), C.uint64_t(size), C.uint32_t(prot)))
219219
}
220220

221221
func (u *uc) MemUnmap(addr, size uint64) error {
222-
return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.size_t(size)))
222+
return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.uint64_t(size)))
223223
}
224224

225225
func (u *uc) Query(queryType int) (uint64, error) {

bindings/haskell/src/Unicorn.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ memWrite uc address bytes = do
217217
memRead :: Engine -- ^ 'Unicorn' engine handle
218218
-> Word64 -- ^ Starting memory address to read
219219
-- from
220-
-> Int -- ^ Size of memory to read (in bytes)
220+
-> Word64 -- ^ Size of memory to read (in bytes)
221221
-> Emulator ByteString -- ^ The memory contents on success, or
222222
-- an 'Error' on failure
223223
memRead uc address size = do
@@ -238,7 +238,7 @@ memMap :: Engine -- ^ 'Unicorn' engine handle
238238
-- be mapped in. This address must be
239239
-- aligned to 4KB, or this will return with
240240
-- 'ErrArg' error
241-
-> Int -- ^ Size of the new memory region to be mapped
241+
-> Word64 -- ^ Size of the new memory region to be mapped
242242
-- in. This size must be a multiple of 4KB, or
243243
-- this will return with an 'ErrArg' error
244244
-> [MemoryPermission] -- ^ Permissions for the newly mapped region
@@ -255,7 +255,7 @@ memUnmap :: Engine -- ^ 'Unicorn' engine handle
255255
-> Word64 -- ^ Start addres of the memory region to be unmapped.
256256
-- This address must be aligned to 4KB or this will
257257
-- return with an 'ErrArg' error
258-
-> Int -- ^ Size of the memory region to be modified. This
258+
-> Word64 -- ^ Size of the memory region to be modified. This
259259
-- must be a multiple of 4KB, or this will return with
260260
-- an 'ErrArg' error
261261
-> Emulator () -- ^ An 'Error' on failure
@@ -272,7 +272,7 @@ memProtect :: Engine -- ^ 'Unicorn' engine handle
272272
-- modify. This address must be aligned to
273273
-- 4KB, or this will return with an
274274
-- 'ErrArg' error
275-
-> Int -- ^ Size of the memory region to be
275+
-> Word64 -- ^ Size of the memory region to be
276276
-- modified. This size must be a multiple
277277
-- of 4KB, or this will return with an
278278
-- 'ErrArg' error

bindings/java/unicorn_Unicorn.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,9 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn__1mem_1read(JNIEnv *env,
758758
jlong address,
759759
jbyteArray dest)
760760
{
761-
jsize size = (*env)->GetArrayLength(env, dest);
761+
jlong size = (*env)->GetArrayLength(env, dest);
762762
jbyte *arr = (*env)->GetByteArrayElements(env, dest, NULL);
763-
uc_err err = uc_mem_read((uc_engine *)uc, address, arr, size);
763+
uc_err err = uc_mem_read((uc_engine *)uc, address, arr, *size);
764764
(*env)->ReleaseByteArrayElements(env, dest, arr, 0);
765765
if (err != UC_ERR_OK) {
766766
throwUnicornException(env, err);
@@ -780,7 +780,8 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn__1mem_1write(JNIEnv *env,
780780
{
781781
jsize size = (*env)->GetArrayLength(env, src);
782782
jbyte *arr = (*env)->GetByteArrayElements(env, src, NULL);
783-
uc_err err = uc_mem_write((uc_engine *)uc, address, arr, size);
783+
// add type cast in case that type inflection does not work
784+
uc_err err = uc_mem_write((uc_engine *)uc, address, arr, (uint64_t)size);
784785
(*env)->ReleaseByteArrayElements(env, src, arr, JNI_ABORT);
785786
if (err != UC_ERR_OK) {
786787
throwUnicornException(env, err);

bindings/pascal/unicorn/Unicorn_dyn.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ uc_mem_region = record
291291
for detailed error).
292292
*)
293293
uc_mem_write_ : function (uc : uc_engine; address : UInt64; const bytes : Pointer;
294-
size : Cardinal) : uc_err; cdecl;
294+
size : UInt64) : uc_err; cdecl;
295295

296296
(*
297297
Read a range of bytes in memory.
@@ -307,7 +307,7 @@ uc_mem_region = record
307307
for detailed error).
308308
*)
309309
uc_mem_read_ : function (uc : uc_engine; address : UInt64; bytes : Pointer;
310-
size : Cardinal) : uc_err; cdecl;
310+
size : UInt64) : uc_err; cdecl;
311311

312312
(*
313313
Emulate machine code in a specific duration of time.
@@ -400,7 +400,7 @@ function (uc : uc_engine; var hh : uc_hook; _type : integer;
400400
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
401401
for detailed error).
402402
*)
403-
uc_mem_map : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl;
403+
uc_mem_map : function (uc : uc_engine; address : UInt64; size : UInt64; perms : UInt32) : uc_err; cdecl;
404404

405405

406406
(*
@@ -422,7 +422,7 @@ function (uc : uc_engine; var hh : uc_hook; _type : integer;
422422
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
423423
for detailed error).
424424
*)
425-
uc_mem_map_ptr : function(uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32; ptr : Pointer) : uc_err; cdecl;
425+
uc_mem_map_ptr : function(uc : uc_engine; address : UInt64; size : UInt64; perms : UInt32; ptr : Pointer) : uc_err; cdecl;
426426

427427

428428
(*
@@ -438,7 +438,7 @@ function (uc : uc_engine; var hh : uc_hook; _type : integer;
438438
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
439439
for detailed error).
440440
*)
441-
uc_mem_unmap : function (uc : uc_engine; address : UInt64; size : Cardinal) : uc_err; cdecl ;
441+
uc_mem_unmap : function (uc : uc_engine; address : UInt64; size : UInt64) : uc_err; cdecl ;
442442

443443
(*
444444
Set memory permissions for emulation memory.
@@ -456,7 +456,7 @@ function (uc : uc_engine; var hh : uc_hook; _type : integer;
456456
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum \
457457
for detailed error).
458458
*)
459-
uc_mem_protect : function (uc : uc_engine; address : UInt64; size : Cardinal; perms : UInt32) : uc_err; cdecl ;
459+
uc_mem_protect : function (uc : uc_engine; address : UInt64; size : UInt64; perms : UInt32) : uc_err; cdecl ;
460460

461461
(*
462462
Retrieve all memory regions mapped by uc_mem_map() and uc_mem_map_ptr()

bindings/python/unicorn/unicorn_py3/unicorn.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ def __set_prototype(fname: str, restype: Type[ctypes._CData], *argtypes: Type[ct
202202
__set_prototype('uc_free', uc_err, void_p)
203203
__set_prototype('uc_hook_add', uc_err, uc_engine, PTR(uc_hook_h), s32, void_p, void_p, u64, u64)
204204
__set_prototype('uc_hook_del', uc_err, uc_engine, uc_hook_h)
205-
__set_prototype('uc_mem_map', uc_err, uc_engine, u64, size_t, u32)
206-
__set_prototype('uc_mem_map_ptr', uc_err, uc_engine, u64, size_t, u32, void_p)
207-
__set_prototype('uc_mem_protect', uc_err, uc_engine, u64, size_t, u32)
208-
__set_prototype('uc_mem_read', uc_err, uc_engine, u64, PTR(char), size_t)
205+
__set_prototype('uc_mem_map', uc_err, uc_engine, u64, u64, u32)
206+
__set_prototype('uc_mem_map_ptr', uc_err, uc_engine, u64, u64, u32, void_p)
207+
__set_prototype('uc_mem_protect', uc_err, uc_engine, u64, u64, u32)
208+
__set_prototype('uc_mem_read', uc_err, uc_engine, u64, PTR(char), u64)
209209
__set_prototype('uc_mem_regions', uc_err, uc_engine, PTR(PTR(uc_mem_region)), PTR(u32))
210-
__set_prototype('uc_mem_unmap', uc_err, uc_engine, u64, size_t)
211-
__set_prototype('uc_mem_write', uc_err, uc_engine, u64, PTR(char), size_t)
212-
__set_prototype('uc_mmio_map', uc_err, uc_engine, u64, size_t, void_p, void_p, void_p, void_p)
210+
__set_prototype('uc_mem_unmap', uc_err, uc_engine, u64, u64)
211+
__set_prototype('uc_mem_write', uc_err, uc_engine, u64, PTR(char), u64)
212+
__set_prototype('uc_mmio_map', uc_err, uc_engine, u64, u64, void_p, void_p, void_p, void_p)
213213
__set_prototype('uc_open', uc_err, u32, u32, PTR(uc_engine))
214214
__set_prototype('uc_query', uc_err, uc_engine, u32, PTR(size_t))
215215
__set_prototype('uc_reg_read', uc_err, uc_engine, s32, void_p)

bindings/ruby/unicorn_gem/ext/unicorn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ VALUE m_uc_reg_write(VALUE self, VALUE reg_id, VALUE reg_value){
275275
}
276276

277277
VALUE m_uc_mem_read(VALUE self, VALUE address, VALUE size){
278-
size_t isize = NUM2UINT(size);
278+
uint64_t isize = NUM2ULL(size);
279279
uint8_t bytes[isize];
280280
uc_err err;
281281
uc_engine *_uc;
@@ -310,7 +310,7 @@ VALUE m_uc_mem_map(int argc, VALUE* argv, VALUE self){
310310
if (NIL_P(perms))
311311
perms = INT2NUM(UC_PROT_ALL);
312312

313-
err = uc_mem_map(_uc, NUM2ULL(address), NUM2UINT(size), NUM2UINT(perms));
313+
err = uc_mem_map(_uc, NUM2ULL(address), NUM2ULL(size), NUM2UINT(perms));
314314
if (err != UC_ERR_OK) {
315315
rb_raise(UcError, "%s", uc_strerror(err));
316316
}
@@ -321,7 +321,7 @@ VALUE m_uc_mem_unmap(VALUE self, VALUE address, VALUE size){
321321
uc_err err;
322322
uc_engine *_uc;
323323
Data_Get_Struct(rb_iv_get(self, "@uch"), uc_engine, _uc);
324-
err = uc_mem_unmap(_uc, NUM2ULL(address), NUM2UINT(size));
324+
err = uc_mem_unmap(_uc, NUM2ULL(address), NUM2ULL(size));
325325
if (err != UC_ERR_OK) {
326326
rb_raise(UcError, "%s", uc_strerror(err));
327327
}
@@ -332,7 +332,7 @@ VALUE m_uc_mem_protect(VALUE self, VALUE address, VALUE size, VALUE perms){
332332
uc_err err;
333333
uc_engine *_uc;
334334
Data_Get_Struct(rb_iv_get(self,"@uch"), uc_engine, _uc);
335-
err = uc_mem_protect(_uc, NUM2ULL(address), NUM2UINT(size), NUM2UINT(perms));
335+
err = uc_mem_protect(_uc, NUM2ULL(address), NUM2UINT(size), NUM2ULL(perms));
336336
if (err != UC_ERR_OK) {
337337
rb_raise(UcError, "%s", uc_strerror(err));
338338
}

0 commit comments

Comments
 (0)