Skip to content

Remove the size limit for memory read and write (revamped) #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
60bcdfc
modify uc_priv.h to use 64 bit hwaddr type for length for uc_write_me…
rliebig Apr 5, 2025
947b719
propogate 64 bit address support to memory function inside unicorn.h
rliebig Apr 5, 2025
7a6c9ac
modify physical memory functions to ensure 64 bit support for size pa…
rliebig Apr 5, 2025
d238d01
apply uint64_t size handling inside the memory handling main functions
rliebig Apr 5, 2025
41ae157
remove INT_MAX size check as we now use a 64 bit address
rliebig Apr 5, 2025
a115e0d
add @secretnonempty unit test for large memory addresses to avoid reg…
rliebig Apr 5, 2025
b5d0767
replace size_t in python3 bindings with u64
rliebig Apr 5, 2025
1912341
adjust rust bindings
rliebig Apr 5, 2025
cfd6b7c
Merge branch 'dev' of github.com:unicorn-engine/unicorn into dev-remo…
rliebig Apr 5, 2025
4a92fd1
use format.sh script to improve formatting
rliebig Apr 5, 2025
d32b25d
small adjustments to java bindings, because jlong type is sometimes a…
rliebig Apr 5, 2025
37cb96b
adjust dotnet bindings to reflect new type sizes
rliebig Apr 5, 2025
731c08f
adjust pascal bindings
rliebig Apr 5, 2025
eddc322
adjust ruby bindings
rliebig Apr 5, 2025
caf81dc
adjust vb6 bindings
rliebig Apr 5, 2025
4d10b62
adjust zig bindings for 64 bit size support
rliebig Apr 5, 2025
a115d6f
fix build.zig.zon for newer zig versions
rliebig Apr 5, 2025
d8ed6c9
add haskell binding support for 64 bit sizes
rliebig Apr 5, 2025
500be15
use mlugg/setup-zig instead of goto-bus-stop/setup-zig github action …
rliebig Apr 6, 2025
7aec74a
use uint64_t instead of size_t for uc_mem_unmap
rliebig Apr 6, 2025
c2bc937
add whitespace between functions to preserver formatting
rliebig Apr 6, 2025
c0d67b2
add precompiler check for android and abort execution of testcase to …
rliebig Apr 6, 2025
47bd239
downgrade zig version to 0.14.0 again to ensure that pipeline can run…
rliebig Apr 6, 2025
8714b87
adjust rust mmio_unwrap type to use u64
rliebig Apr 6, 2025
8a5673d
change ffi size type of uc_mem_map_ptr into u64
rliebig Apr 6, 2025
448ea88
add warning to rust slicing
rliebig Apr 6, 2025
189ffb2
return read_mem_as_vec to earlier state, leave usize as argument beca…
rliebig Apr 6, 2025
aad8200
adjust regions inside MmioCallbackScope to use u64 for region sizes
rliebig Apr 6, 2025
7957422
adjust regions inside MmioCallbackScope to use u64 for region sizes i…
rliebig Apr 6, 2025
17535b4
finalize dotnet bindings inside IBinding.fs
rliebig Apr 6, 2025
5cdfb51
fix typo
rliebig Apr 6, 2025
aa87075
adjust types inside Unicorn.fs
rliebig Apr 6, 2025
769a49c
finalize type wrangling inside F# bindings, setting MemRead and MemWr…
rliebig Apr 6, 2025
3dc0a69
fix merge conflicts inside bindings/rust/src/lib.rs from 64bit unicor…
rliebig Apr 13, 2025
758135b
fix missing bracket inside bindings/rust/src/lib.rs
rliebig Apr 13, 2025
1f25e8f
replace ffi interface to hook interface inside rust lib
rliebig Apr 13, 2025
a353300
fix testcases to use u64 for longer references
rliebig Apr 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/zigbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- uses: goto-bus-stop/setup-zig@v2
- uses: mlugg/setup-zig@v1
with:
version: 0.13.0
version: 0.14.0
- uses: lukka/get-cmake@latest
with:
cmakeVersion: latest
Expand All @@ -50,9 +50,9 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- uses: goto-bus-stop/setup-zig@v2
- uses: mlugg/setup-zig@v1
with:
version: 0.13.0
version: 0.14.0
- uses: lukka/get-cmake@latest
with:
cmakeVersion: latest
Expand Down
12 changes: 6 additions & 6 deletions bindings/dotnet/UnicornEngine/Binding/IBinding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ type IBinding =
abstract Errono : UIntPtr -> Int32
abstract RegRead : UIntPtr * Int32 * Byte array -> Int32
abstract RegWrite : UIntPtr * Int32 * Byte array -> Int32
abstract MemRead : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
abstract MemWrite : UIntPtr * UInt64 * Byte array * UIntPtr -> Int32
abstract MemRead : UIntPtr * UInt64 * Byte array * UInt64 -> Int32
abstract MemWrite : UIntPtr * UInt64 * Byte array * UInt64 -> Int32
abstract EmuStart : UIntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32
abstract EmuStop : UIntPtr -> Int32
abstract HookDel : UIntPtr * UIntPtr -> Int32
abstract MemMap : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
abstract MemMapPtr : UIntPtr * UInt64 * UIntPtr * UInt32 * UIntPtr -> Int32
abstract MemUnmap : UIntPtr * UInt64 * UIntPtr -> Int32
abstract MemProtect : UIntPtr * UInt64 * UIntPtr * UInt32 -> Int32
abstract MemMap : UIntPtr * UInt64 * UInt64 * UInt32 -> Int32
abstract MemMapPtr : UIntPtr * UInt64 * UInt64 * UInt32 * UIntPtr -> Int32
abstract MemUnmap : UIntPtr * UInt64 * UInt64 -> Int32
abstract MemProtect : UIntPtr * UInt64 * UInt64 * UInt32 -> Int32
abstract HookAddNoarg : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 -> Int32
abstract HookAddArg0 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * Int32 -> Int32
abstract HookAddArg0Arg1 : UIntPtr * UIntPtr * Int32 * UIntPtr * IntPtr * UInt64 * UInt64 * UInt64 * UInt64 -> Int32
Expand Down
14 changes: 7 additions & 7 deletions bindings/dotnet/UnicornEngine/Binding/NativeBinding.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ module NativeBinding =
extern Int32 uc_close(UIntPtr eng)

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

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

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

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

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

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

[<DllImport("unicorn", CallingConvention = CallingConvention.Cdecl)>]
extern Int32 uc_reg_write(UIntPtr eng, Int32 regId, Byte[] value)
Expand Down Expand Up @@ -90,4 +90,4 @@ module NativeBinding =
member thi.HookAddNoarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd) = uc_hook_add_noarg(eng, hh, callbackType, callback, userData, hookBegin, hookEnd)
member thi.HookAddArg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0) = uc_hook_add_arg0(eng, hh, callbackType, callback, userData, hookBegin, hookEnd, arg0)
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)
}
}
16 changes: 6 additions & 10 deletions bindings/dotnet/UnicornEngine/Unicorn.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,30 @@ and Unicorn(arch: Int32, mode: Int32, binding: IBinding) =

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

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

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

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

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

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

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

member this.RegWrite(regId: Int32, value: Byte array) =
Expand Down
12 changes: 6 additions & 6 deletions bindings/go/unicorn/unicorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ func (u *uc) MemWrite(addr uint64, data []byte) error {
if len(data) == 0 {
return nil
}
return errReturn(C.uc_mem_write(u.handle, C.uint64_t(addr), unsafe.Pointer(&data[0]), C.size_t(len(data))))
return errReturn(C.uc_mem_write(u.handle, C.uint64_t(addr), unsafe.Pointer(&data[0]), C.uint64_t(len(data))))
}

func (u *uc) MemReadInto(dst []byte, addr uint64) error {
if len(dst) == 0 {
return nil
}
return errReturn(C.uc_mem_read(u.handle, C.uint64_t(addr), unsafe.Pointer(&dst[0]), C.size_t(len(dst))))
return errReturn(C.uc_mem_read(u.handle, C.uint64_t(addr), unsafe.Pointer(&dst[0]), C.uint64_t(len(dst))))
}

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

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

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

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

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

func (u *uc) MemUnmap(addr, size uint64) error {
return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.size_t(size)))
return errReturn(C.uc_mem_unmap(u.handle, C.uint64_t(addr), C.uint64_t(size)))
}

func (u *uc) Query(queryType int) (uint64, error) {
Expand Down
8 changes: 4 additions & 4 deletions bindings/haskell/src/Unicorn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ memWrite uc address bytes = do
memRead :: Engine -- ^ 'Unicorn' engine handle
-> Word64 -- ^ Starting memory address to read
-- from
-> Int -- ^ Size of memory to read (in bytes)
-> Word64 -- ^ Size of memory to read (in bytes)
-> Emulator ByteString -- ^ The memory contents on success, or
-- an 'Error' on failure
memRead uc address size = do
Expand All @@ -238,7 +238,7 @@ memMap :: Engine -- ^ 'Unicorn' engine handle
-- be mapped in. This address must be
-- aligned to 4KB, or this will return with
-- 'ErrArg' error
-> Int -- ^ Size of the new memory region to be mapped
-> Word64 -- ^ Size of the new memory region to be mapped
-- in. This size must be a multiple of 4KB, or
-- this will return with an 'ErrArg' error
-> [MemoryPermission] -- ^ Permissions for the newly mapped region
Expand All @@ -255,7 +255,7 @@ memUnmap :: Engine -- ^ 'Unicorn' engine handle
-> Word64 -- ^ Start addres of the memory region to be unmapped.
-- This address must be aligned to 4KB or this will
-- return with an 'ErrArg' error
-> Int -- ^ Size of the memory region to be modified. This
-> Word64 -- ^ Size of the memory region to be modified. This
-- must be a multiple of 4KB, or this will return with
-- an 'ErrArg' error
-> Emulator () -- ^ An 'Error' on failure
Expand All @@ -272,7 +272,7 @@ memProtect :: Engine -- ^ 'Unicorn' engine handle
-- modify. This address must be aligned to
-- 4KB, or this will return with an
-- 'ErrArg' error
-> Int -- ^ Size of the memory region to be
-> Word64 -- ^ Size of the memory region to be
-- modified. This size must be a multiple
-- of 4KB, or this will return with an
-- 'ErrArg' error
Expand Down
7 changes: 4 additions & 3 deletions bindings/java/unicorn_Unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,9 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn__1mem_1read(JNIEnv *env,
jlong address,
jbyteArray dest)
{
jsize size = (*env)->GetArrayLength(env, dest);
jlong size = (*env)->GetArrayLength(env, dest);
jbyte *arr = (*env)->GetByteArrayElements(env, dest, NULL);
uc_err err = uc_mem_read((uc_engine *)uc, address, arr, size);
uc_err err = uc_mem_read((uc_engine *)uc, address, arr, *size);
(*env)->ReleaseByteArrayElements(env, dest, arr, 0);
if (err != UC_ERR_OK) {
throwUnicornException(env, err);
Expand All @@ -780,7 +780,8 @@ JNIEXPORT void JNICALL Java_unicorn_Unicorn__1mem_1write(JNIEnv *env,
{
jsize size = (*env)->GetArrayLength(env, src);
jbyte *arr = (*env)->GetByteArrayElements(env, src, NULL);
uc_err err = uc_mem_write((uc_engine *)uc, address, arr, size);
// add type cast in case that type inflection does not work
uc_err err = uc_mem_write((uc_engine *)uc, address, arr, (uint64_t)size);
(*env)->ReleaseByteArrayElements(env, src, arr, JNI_ABORT);
if (err != UC_ERR_OK) {
throwUnicornException(env, err);
Expand Down
12 changes: 6 additions & 6 deletions bindings/pascal/unicorn/Unicorn_dyn.pas
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ uc_mem_region = record
for detailed error).
*)
uc_mem_write_ : function (uc : uc_engine; address : UInt64; const bytes : Pointer;
size : Cardinal) : uc_err; cdecl;
size : UInt64) : uc_err; cdecl;

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

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


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


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

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

(*
Retrieve all memory regions mapped by uc_mem_map() and uc_mem_map_ptr()
Expand Down
14 changes: 7 additions & 7 deletions bindings/python/unicorn/unicorn_py3/unicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ def __set_prototype(fname: str, restype: Type[ctypes._CData], *argtypes: Type[ct
__set_prototype('uc_free', uc_err, void_p)
__set_prototype('uc_hook_add', uc_err, uc_engine, PTR(uc_hook_h), s32, void_p, void_p, u64, u64)
__set_prototype('uc_hook_del', uc_err, uc_engine, uc_hook_h)
__set_prototype('uc_mem_map', uc_err, uc_engine, u64, size_t, u32)
__set_prototype('uc_mem_map_ptr', uc_err, uc_engine, u64, size_t, u32, void_p)
__set_prototype('uc_mem_protect', uc_err, uc_engine, u64, size_t, u32)
__set_prototype('uc_mem_read', uc_err, uc_engine, u64, PTR(char), size_t)
__set_prototype('uc_mem_map', uc_err, uc_engine, u64, u64, u32)
__set_prototype('uc_mem_map_ptr', uc_err, uc_engine, u64, u64, u32, void_p)
__set_prototype('uc_mem_protect', uc_err, uc_engine, u64, u64, u32)
__set_prototype('uc_mem_read', uc_err, uc_engine, u64, PTR(char), u64)
__set_prototype('uc_mem_regions', uc_err, uc_engine, PTR(PTR(uc_mem_region)), PTR(u32))
__set_prototype('uc_mem_unmap', uc_err, uc_engine, u64, size_t)
__set_prototype('uc_mem_write', uc_err, uc_engine, u64, PTR(char), size_t)
__set_prototype('uc_mmio_map', uc_err, uc_engine, u64, size_t, void_p, void_p, void_p, void_p)
__set_prototype('uc_mem_unmap', uc_err, uc_engine, u64, u64)
__set_prototype('uc_mem_write', uc_err, uc_engine, u64, PTR(char), u64)
__set_prototype('uc_mmio_map', uc_err, uc_engine, u64, u64, void_p, void_p, void_p, void_p)
__set_prototype('uc_open', uc_err, u32, u32, PTR(uc_engine))
__set_prototype('uc_query', uc_err, uc_engine, u32, PTR(size_t))
__set_prototype('uc_reg_read', uc_err, uc_engine, s32, void_p)
Expand Down
8 changes: 4 additions & 4 deletions bindings/ruby/unicorn_gem/ext/unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ VALUE m_uc_reg_write(VALUE self, VALUE reg_id, VALUE reg_value){
}

VALUE m_uc_mem_read(VALUE self, VALUE address, VALUE size){
size_t isize = NUM2UINT(size);
uint64_t isize = NUM2ULL(size);
uint8_t bytes[isize];
uc_err err;
uc_engine *_uc;
Expand Down Expand Up @@ -310,7 +310,7 @@ VALUE m_uc_mem_map(int argc, VALUE* argv, VALUE self){
if (NIL_P(perms))
perms = INT2NUM(UC_PROT_ALL);

err = uc_mem_map(_uc, NUM2ULL(address), NUM2UINT(size), NUM2UINT(perms));
err = uc_mem_map(_uc, NUM2ULL(address), NUM2ULL(size), NUM2UINT(perms));
if (err != UC_ERR_OK) {
rb_raise(UcError, "%s", uc_strerror(err));
}
Expand All @@ -321,7 +321,7 @@ VALUE m_uc_mem_unmap(VALUE self, VALUE address, VALUE size){
uc_err err;
uc_engine *_uc;
Data_Get_Struct(rb_iv_get(self, "@uch"), uc_engine, _uc);
err = uc_mem_unmap(_uc, NUM2ULL(address), NUM2UINT(size));
err = uc_mem_unmap(_uc, NUM2ULL(address), NUM2ULL(size));
if (err != UC_ERR_OK) {
rb_raise(UcError, "%s", uc_strerror(err));
}
Expand All @@ -332,7 +332,7 @@ VALUE m_uc_mem_protect(VALUE self, VALUE address, VALUE size, VALUE perms){
uc_err err;
uc_engine *_uc;
Data_Get_Struct(rb_iv_get(self,"@uch"), uc_engine, _uc);
err = uc_mem_protect(_uc, NUM2ULL(address), NUM2UINT(size), NUM2UINT(perms));
err = uc_mem_protect(_uc, NUM2ULL(address), NUM2UINT(size), NUM2ULL(perms));
if (err != UC_ERR_OK) {
rb_raise(UcError, "%s", uc_strerror(err));
}
Expand Down
Loading
Loading