When using native binding lib, linking failed on overloaded method

Steve_ParkSteve_Park Member
edited November 2018 in Xamarin.iOS

Hi, I have a trouble using iOS native binding library.

I have to use**** a native library, so I created Xamarin.iOS binding library and referenced it.
(Native binding library build, no error)
When I use overloaded method(ix_integrityCheck) in TestApp, 'Native linking failed, undefined symbol occurred on build process.
Except that method, build succeeded and other methods works fine.
I think 'attribute((overloadable))' methods should be coded differently but hard to find about that.

Please help me anyone knows about this.
Thanks.

This is the library header.

[library header]

   #include <stdio.h>
    struct ix_init_info
    {
        char init_data[256];
        IX_INTEGRITY_TYPE integrity_type;
        char userId[24];
        char subId[256];
    };

struct ix_verify_info
{
    char verify_result[12];
    char verify_data[2048];
};

struct ix_detected_pattern
{
    char pattern_type_id[12];
    char pattern_obj[128];
    char pattern_desc[128];
};

// System Check
extern int ix_sysCheckStart(struct ix_detected_pattern ** p_info);

// System + GameHack Check
extern int ix_sysCheck_gamehack(struct ix_detected_pattern ** p_info, struct ix_detected_pattern_list_gamehack ** p_list_gamehack);

// get ix Version
extern const char* ix_getVersion();

// Check Debugger
extern int ix_runAntiDebugger(void);

// integrity Check
extern int ix_integrityCheck(struct ix_verify_info * v_info) __attribute__((overloadable));
extern int ix_integrityCheck(struct ix_init_info * info, struct ix_verify_info * v_info) __attribute__((overloadable));

Here's my code.
[Struct.cs]

        public static class IxShieldCFunctions
        {            
            [DllImport("__Internal")]
            public static extern unsafe int ix_sysCheckStart(ref ix_detected_pattern p_info);

            [DllImport("__Internal")]
            public static extern unsafe int ix_sysCheck_gamehack(ref ix_detected_pattern p_info, ref ix_detected_pattern_list_gamehack p_list_gamehack);

            [DllImport("__Internal")]
            public static extern unsafe sbyte* ix_getVersion();

            [DllImport("__Internal")]
            public static extern int ix_runAntiDebugger();

            [DllImport("__Internal")]
        public static extern unsafe int ix_integrityCheck(ix_verify_info v_info);

        [DllImport("__Internal")]
        public static extern unsafe int ix_integrityCheck(ix_init_info info, ix_verify_info v_info);  
    }
    [StructLayout(LayoutKind.Sequential)]
    public class ix_init_info
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
        public sbyte[] init_data;

        public IxIntegrityType integrity_type;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
        public sbyte[] userId;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
        public sbyte[] subId;
    }

    [StructLayout(LayoutKind.Sequential)]
    public class ix_verify_info
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
        public sbyte[] verify_result;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2048)]
        public sbyte[] verify_data;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class ix_detected_pattern
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
        public sbyte[] pattern_type_id;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public sbyte[] pattern_obj;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
        public sbyte[] pattern_desc;
    }

Answers

  • ColeXColeX Member, Xamarin Team Xamurai
    edited November 2018

    If you can modify the code in source code , i suggest you remove __attribute__((overloadable)); and change the name of one of the ix_integrityCheck , than re-create binding library.

  • Sadly, I just received native library and manual(for Objective-C and Swift) from security team, so I cannot modify that.
    And the library vendor doesn't know about Xamarin.

    I attach build log and real code.
    (The methods are obfuscated and I transformed and wrote that before to read easily)

    Does Xamarin.iOS binding library not support overloaded methods?

    [iX.h]

    #define ix_integrityCheck           a106c4e13097eb3613110ee85730fc9f9
    
    // integrity Check
    extern int ix_integrityCheck(struct ix_verify_info *v_info) __attribute__((overloadable));
    extern int ix_integrityCheck(struct ix_init_info *info, struct ix_verify_info *v_info) __attribute__((overloadable));
    

    [Struct.cs]

    [DllImport("__Internal")]
    public static extern unsafe int a106c4e13097eb3613110ee85730fc9f9( ix_verify_info v_info);
    
    [DllImport("__Internal")]
    public static extern unsafe int a106c4e13097eb3613110ee85730fc9f9( ix_init_info info,  ix_verify_info v_info);
    
Sign In or Register to comment.