/* This file was generated by the Hex-Rays decompiler version 9.2.0.250908. Copyright (c) 2007-2021 Hex-Rays Detected compiler: GNU C++ */ #include //------------------------------------------------------------------------- // Function declarations void init_proc(); int sub_11880(); // int pthread_detach(pthread_t th); // int printf(const char *format, ...); // int __fastcall json_tokener_parse(_DWORD); weak // void *realloc(void *ptr, size_t size); // int pthread_mutex_lock(pthread_mutex_t *mutex); // int __fastcall pthread_mutexattr_settype(_DWORD, _DWORD); weak // double atof(const char *nptr); // int pthread_sigmask(int how, const __sigset_t *newmask, __sigset_t *oldmask); // int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); // int __fastcall RSA_public_encrypt(_DWORD, _DWORD, _DWORD, _DWORD); weak // char *fgets(char *s, int n, FILE *stream); // int __fastcall json_object_array_length(_DWORD); weak // int close(int fd); // pthread_t pthread_self(void); // char *strchr(const char *s, int c); // int __fastcall json_object_get_type(_DWORD); weak // struct mallinfo *mallinfo(struct mallinfo *__return_ptr __struct_ptr retstr); // void *calloc(size_t nmemb, size_t size); // int strncmp(const char *s1, const char *s2, size_t n); // int __fastcall json_object_new_array(_DWORD); weak // int __fastcall json_object_new_string(_DWORD); weak // void free(void *ptr); // int RSA_size(void); weak // double __fastcall json_object_get_double(_DWORD); weak // int unlink(const char *name); // __int64 strtoll(const char *nptr, char **endptr, int base); // int __fastcall json_object_get_string(_DWORD); weak // void pthread_exit(void *retval); // int __fastcall json_object_array_get_idx(_DWORD, _DWORD); weak // int __fastcall uci_lookup_ptr(_DWORD, _DWORD, _DWORD, _DWORD); weak // int __fastcall json_object_array_add(_DWORD, _DWORD); weak // int __fastcall json_object_new_object(_DWORD); weak // int __fastcall json_object_object_length(_DWORD); weak // int __fastcall RSA_free(_DWORD); weak // void *pthread_getspecific(pthread_key_t key); // void *memcpy(void *dest, const void *src, size_t n); // void srand(unsigned int seed); // int rand(void); // int pthread_mutex_unlock(pthread_mutex_t *mutex); // int prctl(int option, ...); // void *memset(void *s, int c, size_t n); // int pthread_setcanceltype(int type, int *oldtype); // int __fastcall json_object_to_json_string_ext(_DWORD, _DWORD); weak // int __fastcall json_object_get_int(_DWORD); weak // int __fastcall uci_free_context(_DWORD); weak // int __fastcall json_object_new_int(_DWORD); weak // int pthread_key_create(pthread_key_t *key, void (*destr_function)(void *)); // void perror(const char *s); // char *strcpy(char *dest, const char *src); // int __fastcall json_object_get_boolean(_DWORD); weak // int __fastcall json_object_object_add(_DWORD, _DWORD, _DWORD); weak // int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen); // ssize_t sendto(int fd, const void *buf, size_t n, int flags, const struct sockaddr *addr, socklen_t addr_len); // int uci_alloc_context(void); weak // int atoi(const char *nptr); // int pthread_setspecific(pthread_key_t key, const void *pointer); // int puts(const char *s); // FILE *fopen(const char *filename, const char *modes); // int sigaddset(sigset_t *set, int signo); // int snprintf(char *s, size_t maxlen, const char *format, ...); // int pthread_attr_init(pthread_attr_t *attr); // __pid_t getpid(void); // int socket(int domain, int type, int protocol); // int __fastcall json_object_new_double(_DWORD, _DWORD); weak // int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); // int pthread_attr_destroy(pthread_attr_t *attr); // time_t time(time_t *timer); // char *strncpy(char *dest, const char *src, size_t n); // int fclose(FILE *stream); // int syscall(int sysno, ...); // double pow(double x, double y); // int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr); // ssize_t recvfrom(int fd, void *buf, size_t n, int flags, struct sockaddr *addr, socklen_t *addr_len); // int pthread_mutexattr_init(pthread_mutexattr_t *attr); // int sigemptyset(sigset_t *set); // int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); // int __fastcall json_object_object_get(_DWORD, _DWORD); weak // int sprintf(char *s, const char *format, ...); // int __fastcall PEM_read_RSA_PUBKEY(_DWORD, _DWORD, _DWORD, _DWORD); weak // unsigned int sleep(unsigned int seconds); // int sscanf(const char *s, const char *format, ...); // int bind(int fd, const struct sockaddr *addr, socklen_t len); // size_t strlen(const char *s); // int pthread_setcancelstate(int state, int *oldstate); // int __fastcall json_object_put(_DWORD); weak // double floor(double x); // int __fastcall json_object_new_boolean(_DWORD); weak // int *_errno_location(void); // void *malloc(size_t size); // int strcmp(const char *s1, const char *s2); int sub_11DF8(); int start(); void sub_11E94(); int *sub_11EB0(); int __fastcall sub_11EE0(int a1, int *a2); int __fastcall sub_11FD4(unsigned int a1, const char *a2, char *nptr, int a4); void __fastcall sub_120A4(int *a1); int __fastcall sub_125A8(const char *a1, int a2, int a3, int a4); int __fastcall sub_125C0(int a1, int a2, int a3); int __fastcall sub_12710(int a1, int a2); int __fastcall sub_13338(const char *a1); int sub_13874(); int sub_138A0(); int __fastcall sub_138CC(const char *a1, const char *a2); unsigned int __fastcall sub_13920(char *a1); unsigned int __fastcall sub_13978(char *a1); int __fastcall sub_139C0(const char *a1, unsigned int a2, int a3); int sub_13AE0(); int sub_13C04(); int sub_13D10(); int __fastcall sub_13D5C(const char *a1, int a2, int a3, int a4, int *a5, int a6); int __fastcall sub_14600(int a1, const char *a2); int __fastcall sub_146E0(const char *a1, const char *a2, int a3, int a4); bool sub_1502C(); int __fastcall sub_150E4(char *a1, int a2); int __fastcall sub_15210(char *a1, int a2); int __fastcall sub_1533C(char *a1, int a2); int __fastcall sub_15468(_DWORD *a1); int __fastcall sub_15D28(char *a1, unsigned int a2); int sub_15EC4(); int __fastcall sub_16058(char *a1, size_t a2); _DWORD *__fastcall sub_16FB0(int a1, int a2, int a3, int a4, signed int a5); _DWORD *__fastcall sub_17070(int a1, int a2, int a3, signed int a4); _DWORD *__fastcall sub_17084(int a1, int a2, int a3); void __fastcall sub_1709C(_DWORD *a1); int __fastcall sub_17108(int (__fastcall **a1)(int), int a2); int __fastcall sub_17204(int (__fastcall **a1)(int), int a2); int __fastcall sub_172E8(int a1, int a2); int __fastcall sub_173B8(int a1, int a2); int __fastcall sub_17438(int result, int (__fastcall *a2)(int, int), int a3); int __fastcall sub_174D8(int result, unsigned int a2, int a3, int (__fastcall *a4)(int, int), int a5); int __fastcall sub_175C8(int a1); unsigned int __fastcall sub_175D8(unsigned __int8 *a1, unsigned int a2, int a3); int __fastcall sub_17684(int a1, int a2, int (__fastcall *a3)(int, int), int a4); int __fastcall sub_17714(int a1, int a2); _DWORD *__fastcall sub_177E4(_DWORD *result); int __fastcall sub_1782C(int *a1); int __fastcall sub_1787C(int a1); int __fastcall sub_178CC(int *a1); int __fastcall sub_17920(int a1); int __fastcall sub_179D4(int result, int *a2); _DWORD *__fastcall sub_17B04(_DWORD *result); int __fastcall sub_17B70(int a1); int *__fastcall sub_17BB8(int *result, int *a2); int sub_17C24(); int sub_17C30(); void sub_17CE8(); void sub_17CFC(); int sub_17D10(); void sub_17D20(); int sub_17D34(); void *__fastcall sub_17D44(signed int a1); void __fastcall sub_17D98(void *ptr); void *__fastcall sub_17DE0(signed int a1, signed int a2); void *__fastcall sub_17E5C(void *a1, int a2); int __fastcall sub_17EAC(int a1); void __fastcall __noreturn start_routine(int *a1, int a2, int a3); _DWORD *__fastcall sub_17FB8(int a1, pthread_mutexattr_t a2, int a3); int __fastcall sub_18018(int a1, int a2, int a3, int a4); int __fastcall sub_18088(pthread_t *a1, const char *a2, int a3, int a4); _DWORD *__fastcall sub_181B4(int a1); int __fastcall sub_181E4(int result); int __fastcall sub_18238(void *a1); int __fastcall sub_18288(int a1, _DWORD *a2); int sub_18318(); int __fastcall sub_18324(unsigned __int8 *a1, unsigned __int8 *a2); int __fastcall sub_1838C(unsigned __int8 *a1); unsigned __int8 *__fastcall sub_18498(int a1, _BYTE *a2); unsigned __int8 *__fastcall sub_186F8(unsigned __int8 *a1); void *sub_1871C(); _DWORD *__fastcall sub_18750(_DWORD *result); void *__fastcall sub_18784(const char *a1); _DWORD *__fastcall sub_187C4(int *a1); char *__fastcall sub_18810(char **a1, int a2); char *__fastcall sub_188C0(int *a1, char **a2); char *__fastcall sub_18B08(const char *a1, char **a2); char *__fastcall sub_18D60(int *a1, int a2, int a3, char **a4); char *__fastcall sub_18EAC(int a1, int a2, int a3, int a4); char *__fastcall sub_194FC(int a1, int a2, int a3, int a4); unsigned __int8 *__fastcall sub_1985C(int a1, const char *a2); int sub_19D88(); int __fastcall sub_19D98(int result); int __fastcall sub_19DEC(int result); int __fastcall sub_19E7C(unsigned __int8 *a1, unsigned __int8 **a2, int a3); int __fastcall sub_19F14(unsigned __int8 *a1); char *__fastcall sub_19F20(int *a1); char *__fastcall sub_19F30(int *a1); char *__fastcall sub_19F40(int *a1, char *a2, int a3); _DWORD *__fastcall sub_19FA8(int a1, int a2); int **__fastcall sub_19FC8(int a1, unsigned __int8 *a2); int __fastcall sub_1A000(int result, int a2); int __fastcall sub_1A038(int result, const char *a2, int a3); int __fastcall sub_1A084(int result, int a2, int a3); int __fastcall sub_1A0E0(int a1, int *a2); int __fastcall sub_1A100(int a1, const char *a2, int *a3); _DWORD *__fastcall sub_1A128(int a1, int a2); int __fastcall sub_1A190(int a1, int a2); _DWORD *__fastcall sub_1A1A0(int a1, unsigned __int8 *a2); int __fastcall sub_1A1F4(int a1, unsigned __int8 *a2); int __fastcall sub_1A204(int result, int a2, _DWORD *a3); _DWORD *__fastcall sub_1A258(int a1, int a2, _DWORD *a3); _DWORD *__fastcall sub_1A2BC(_DWORD *result, unsigned __int8 *a2, _DWORD *a3); _DWORD *sub_1A31C(); _DWORD *sub_1A334(); _DWORD *sub_1A34C(); _DWORD *__fastcall sub_1A364(int a1); double *__fastcall sub_1A388(double a1); _DWORD *__fastcall sub_1A3C4(const char *a1); _DWORD *sub_1A3F4(); _DWORD *sub_1A40C(); _DWORD *__fastcall sub_1A424(int *a1, int a2); _DWORD *__fastcall sub_1A47C(float *a1, int a2); _DWORD *__fastcall sub_1A4D4(double *a1, int a2); _DWORD *__fastcall sub_1A528(const char **a1, int a2); _DWORD *__fastcall sub_1A57C(int a1, int a2); char *__fastcall sub_1A668(char *result); void term_proc(); //------------------------------------------------------------------------- // Data declarations // extern _UNKNOWN _uClibc_main; weak char a0123456789abcd[17] = "0123456789abcdef"; // weak const char asc_1C908[3] = "\"\\\b"; // idb const char byte_1C90F = '\0'; // idb int dword_2D008 = 0; // weak int (*off_2D15C)(void) = NULL; // weak int dword_2D33C = 1; // weak int dword_2D340 = 1; // weak int dword_2D344 = 3; // weak int dword_2D370 = 1; // weak void *(*off_2D374)(size_t size) = &malloc; // weak int (__fastcall *off_2D378)(_DWORD) = ; // weak int _ctype_tolower; // weak char byte_2D380; // weak int dword_2D38C; // weak int dword_2D390; // weak int dword_2D394; // weak int dword_2D398; // weak char byte_2D39C[64]; // weak int dword_2D3E8; // weak int dword_2D474; // weak char byte_2D478[132]; // weak int dword_2D4FC; // weak char byte_2D500[132]; // weak int dword_2D584; // weak char byte_2D588[132]; // weak int dword_2D60C; // weak int dword_2D610; // weak int dword_2D950; // weak char dest[132]; // idb int dword_2D9D8; // weak int dword_2D9DC; // weak pthread_mutex_t stru_2D9E0; // weak pthread_mutex_t mutex; // idb _DWORD dword_2DA10[3]; // weak int dword_2DA1C; // weak int dword_2DA20; // weak int dword_2DA24; // weak //----- (00011870) -------------------------------------------------------- // Alternative name is '_init' void init_proc() { ; } //----- (00011880) -------------------------------------------------------- int sub_11880() { return off_2D15C(); } // 2D15C: using guessed type int (*off_2D15C)(void); //----- (00011DF8) -------------------------------------------------------- int sub_11DF8() { int v0; // r4 char v2[100]; // [sp+0h] [bp-70h] BYREF char s[12]; // [sp+64h] [bp-Ch] BYREF memset(s, 0, 0xAu); memset(v2, 0, sizeof(v2)); v0 = sub_125C0((int)s, 6, (int)v2); if ( !v0 ) printf("%s%s\n", s, v2); return v0; } //----- (00011E58) -------------------------------------------------------- // positive sp value has been detected, the output may be wrong! int start() { return ((int (__fastcall *)(int (*)()))_uClibc_main)(sub_11DF8); } // 11E64: positive sp value 4 has been found //----- (00011E94) -------------------------------------------------------- void sub_11E94() { if ( !byte_2D380 ) byte_2D380 = 1; } // 2D380: using guessed type char byte_2D380; //----- (00011EB0) -------------------------------------------------------- int *sub_11EB0() { return &dword_2D008; } // 2D008: using guessed type int dword_2D008; //----- (00011EE0) -------------------------------------------------------- int __fastcall sub_11EE0(int a1, int *a2) { bool v2; // zf int v4; // r8 int v5; // r7 int *i; // r5 int v7; // r0 int v8; // r4 int v9; // r0 int v10; // r0 unsigned int v11; // r3 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; v4 = a1; v5 = v2; if ( v2 ) return -1; for ( i = a2; ; i += 8 ) { if ( v5 >= *a2 ) return 0; v8 = json_object_new_object(a1); v9 = json_object_new_string(&a2[8 * v5 + 1]); json_object_object_add(v8, "para_name", v9); v10 = json_object_new_int(i[7]); json_object_object_add(v8, "para_type", v10); v11 = i[7]; if ( v11 != 1 ) break; v7 = json_object_new_int(i[8]); LABEL_10: ++v5; json_object_object_add(v8, "para_value", v7); a1 = json_object_array_add(v4, v8); } if ( v11 && v11 <= 6 ) { v7 = json_object_new_string(i[8]); goto LABEL_10; } if ( v8 ) json_object_put(v8); return -1; } // 119A8: using guessed type int __fastcall json_object_new_string(_DWORD); // 11A44: using guessed type int __fastcall json_object_array_add(_DWORD, _DWORD); // 11A50: using guessed type int __fastcall json_object_new_object(_DWORD); // 11B58: using guessed type int __fastcall json_object_new_int(_DWORD); // 11B94: using guessed type int __fastcall json_object_object_add(_DWORD, _DWORD, _DWORD); // 11DA4: using guessed type int __fastcall json_object_put(_DWORD); //----- (00011FD4) -------------------------------------------------------- int __fastcall sub_11FD4(unsigned int a1, const char *a2, char *nptr, int a4) { bool v4; // zf size_t v9; // r0 void *v10; // r8 size_t v11; // r0 size_t v12; // r0 v4 = nptr == 0; if ( nptr ) v4 = a4 == 0; if ( !v4 && a2 ) { if ( a1 == 1 ) { *(_DWORD *)(a4 + 28) = atoi(nptr); goto LABEL_13; } if ( a1 ) { if ( a1 <= 6 ) { v9 = strlen(nptr); v10 = malloc(v9 + 1); *(_DWORD *)(a4 + 28) = v10; if ( v10 ) { v11 = strlen(nptr); memset(v10, 0, v11 + 1); v12 = strlen(nptr); strncpy(*(char **)(a4 + 28), nptr, v12); LABEL_13: *(_DWORD *)(a4 + 24) = a1; strncpy((char *)a4, a2, 0x14u); return 0; } } } } return -1; } //----- (000120A4) -------------------------------------------------------- void __fastcall sub_120A4(int *a1) { int v2; // r4 int *i; // r5 void *v4; // r0 bool v5; // cc if ( a1 ) { v2 = 0; for ( i = a1; ; i += 8 ) { v5 = v2 < 9; if ( v2 <= 9 ) v5 = v2 < *a1; if ( !v5 ) break; if ( (unsigned int)(i[7] - 2) <= 4 ) { v4 = (void *)i[8]; if ( v4 ) { free(v4); i[8] = 0; } } ++v2; } *a1 = 0; } } //----- (000125A8) -------------------------------------------------------- int __fastcall sub_125A8(const char *a1, int a2, int a3, int a4) { return sub_13D5C(a1, a2, a3, a4, 0, 0); } //----- (000125C0) -------------------------------------------------------- int __fastcall sub_125C0(int a1, int a2, int a3) { bool v3; // zf int v5; // r8 int v7; // r6 time_t v8; // r0 int v9; // r1 char v10; // r1 FILE *v11; // r0 FILE *v12; // r10 int RSA_PUBKEY; // r7 int v14; // r0 size_t v15; // r9 int v16; // r6 _BYTE *v17; // r0 _BYTE *v18; // r5 int i; // r3 char v20; // r1 v3 = a1 == 0; if ( a1 ) v3 = a3 == 0; v5 = a3; if ( v3 ) return -1; v7 = 0; if ( a2 <= 0 ) return -1; v8 = time(0); srand(v8); do { v9 = rand() % 36; if ( v9 > 25 ) v10 = v9 + 22; else v10 = v9 + 97; *(_BYTE *)(a1 + v7++) = v10; } while ( v7 != a2 ); v11 = fopen("/etc/verify_pub.key", "r"); v12 = v11; if ( !v11 ) { perror("open key file error"); return -1; } RSA_PUBKEY = PEM_read_RSA_PUBKEY(v11, 0, 0, 0); if ( !RSA_PUBKEY ) return -1; v14 = RSA_size(); v15 = v14 + 1; v16 = v14; v17 = malloc(v14 + 1); v18 = v17; if ( !v17 ) return -1; memset(v17, 0, v15); if ( RSA_public_encrypt(v16, a1, v18, RSA_PUBKEY) < 0 ) return -1; RSA_free(RSA_PUBKEY); fclose(v12); for ( i = 0; ; ++i ) { v5 += 2; if ( i >= v16 ) break; *(_BYTE *)(v5 - 2) = a0123456789abcd[(unsigned __int8)v18[i] >> 4]; v20 = v18[i]; *(_BYTE *)(v5 - 1) = a0123456789abcd[v20 & 0xF]; } free(v18); return 0; } // 11924: using guessed type int __fastcall RSA_public_encrypt(_DWORD, _DWORD, _DWORD, _DWORD); // 119C0: using guessed type int RSA_size(void); // 11A68: using guessed type int __fastcall RSA_free(_DWORD); // 11D38: using guessed type int __fastcall PEM_read_RSA_PUBKEY(_DWORD, _DWORD, _DWORD, _DWORD); //----- (00012710) -------------------------------------------------------- int __fastcall sub_12710(int a1, int a2) { int v4; // r5 int v5; // r0 int v6; // r5 int v7; // r0 int v8; // r5 const char *string; // r1 int v10; // r0 int v11; // r7 int i; // r5 _DWORD *v13; // r9 int v14; // r6 _DWORD *v15; // r7 int v16; // r0 int v17; // r7 int v18; // r5 _DWORD *v19; // r7 int k; // r6 int v21; // r0 int v22; // r7 int m; // r5 double *v24; // r6 int n; // r7 int v26; // r0 int v27; // r7 int v28; // r5 const char *v29; // r7 int ii; // r6 int v31; // r4 int v32; // r0 int v33; // r5 int v34; // r0 int v35; // r5 const char *v36; // r1 int v37; // r0 int v38; // r6 int jj; // r4 int kk; // r5 int v41; // r0 int v42; // r0 int v43; // r0 int v44; // r0 int v45; // r0 int v46; // r4 int v47; // r0 int v48; // r0 int v49; // r0 int v50; // r0 int v51; // r4 int v52; // r0 int v53; // r0 int v54; // r0 int result; // r0 const char *v56; // r0 double *v57; // r6 int v58; // r0 int v59; // r10 char *v60; // r6 int v61; // r0 const char *v62; // r1 char *v63; // r0 _DWORD *j; // r6 int v65; // r0 _DWORD *v66; // r6 int idx; // r0 int v68; // r9 _DWORD *v69; // r5 int v70; // r0 int v71; // r10 int v72; // r0 int v73; // r0 int boolean; // r0 double v75; // r0 int v76; // r0 int v77; // r0 int v78; // r0 int v79; // [sp+Ch] [bp-330h] int v80; // [sp+Ch] [bp-330h] _DWORD s[203]; // [sp+10h] [bp-32Ch] BYREF memset(s, 0, 0x328u); v4 = json_object_object_get(a1, "enable"); if ( !v4 ) goto LABEL_4; if ( ((int (*)(void))json_object_get_type)() == 1 ) { boolean = json_object_get_boolean(v4); LABEL_158: s[0] = boolean; goto LABEL_7; } if ( json_object_get_type(v4) == 3 ) { boolean = json_object_get_int(v4) != 0; goto LABEL_158; } LABEL_4: if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get boolean with error obj or value type is unmatch.\n", "jcs_test_callback_add", 453); s[0] = 0; LABEL_7: if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.enable=%d\n", "jcs_test_callback_add", 454, s[0]); v5 = json_object_object_get(a1, "max_band"); v6 = v5; if ( !v5 ) goto LABEL_12; if ( json_object_get_type(v5) == 3 ) { v73 = json_object_get_int(v6); LABEL_154: s[1] = v73; goto LABEL_15; } if ( json_object_get_type(v6) == 2 ) { v73 = (int)json_object_get_double(v6); goto LABEL_154; } LABEL_12: if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Warning: Get int with error obj or value type is unmatch.\n", "jcs_test_callback_add", 459); s[1] = -1; LABEL_15: if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.max_band=%d\n", "jcs_test_callback_add", 460, s[1]); v7 = json_object_object_get(a1, 115031); v8 = v7; if ( v7 && json_object_get_type(v7) == 6 ) { string = (const char *)json_object_get_string(v8); } else { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get string with error obj or value type is unmatch.\n", "jcs_test_callback_add", 464); string = &byte_1C90F; } strncpy((char *)&s[2], string, 0xFFu); HIBYTE(s[65]) = 0; if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.url=%s\n", "jcs_test_callback_add", 465, (const char *)&s[2]); v10 = json_object_object_get(a1, "hours"); v11 = v10; if ( v10 ) { if ( json_object_get_type(v10) != 5 ) { if ( json_object_get_type(v11) == 4 ) { i = json_object_object_length(v11); if ( !i ) goto LABEL_29; } goto LABEL_27; } v66 = s; for ( i = 0; ; ++i ) { if ( i >= json_object_array_length(v11) || i == 4 ) goto LABEL_29; idx = json_object_array_get_idx(v11, i); v68 = idx; if ( idx ) { if ( json_object_get_type(idx) == 3 ) { v76 = json_object_get_int(v68); LABEL_166: v66[68] = v76; goto LABEL_140; } if ( json_object_get_type(v68) == 2 ) { v76 = (int)json_object_get_double(v68); goto LABEL_166; } } if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get int with error obj or value type is unmatch.\n", "jcs_test_callback_add", 469); v66[68] = -1; LABEL_140: ++v66; } } LABEL_27: i = dword_2D33C; if ( dword_2D33C ) { i = 0; printf( "[JCS_ERR]%s()/%d Warning: Get intArray with error obj or value type is unmatch.\n", "jcs_test_callback_add", 469); } LABEL_29: v13 = s; v14 = 0; v15 = s; while ( v14 < i ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.hours[%d]=%d\n", "jcs_test_callback_add", 472, v14, v15[68]); ++v14; ++v15; } v16 = json_object_object_get(a1, "switchs"); v17 = v16; if ( v16 ) { if ( json_object_get_type(v16) != 5 ) { if ( json_object_get_type(v17) == 4 ) { v18 = json_object_object_length(v17); if ( !v18 ) goto LABEL_39; } goto LABEL_37; } v18 = 0; for ( j = s; ; ++j ) { if ( v18 >= json_object_array_length(v17) || v18 == 4 ) goto LABEL_39; v65 = json_object_array_get_idx(v17, v18); if ( v65 ) { v80 = v65; if ( json_object_get_type(v65) == 1 ) { v77 = json_object_get_boolean(v80); LABEL_168: j[72] = v77; goto LABEL_130; } if ( json_object_get_type(v80) == 3 ) { v77 = json_object_get_int(v80) != 0; goto LABEL_168; } } if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get boolean with error obj or value type is unmatch.\n", "jcs_test_callback_add", 477); j[72] = 0; LABEL_130: ++v18; } } LABEL_37: v18 = dword_2D33C; if ( dword_2D33C ) { v18 = 0; printf( "[JCS_ERR]%s()/%d Warning: Get booleanArray with error obj or value type is unmatch.\n", "jcs_test_callback_add", 477); } LABEL_39: v19 = s; for ( k = 0; k < v18; ++k ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.switchs[%d]=%d\n", "jcs_test_callback_add", 480, k, v19[72]); ++v19; } v21 = json_object_object_get(a1, "weights"); v22 = v21; if ( v21 ) { if ( json_object_get_type(v21) != 5 ) { if ( json_object_get_type(v22) == 4 ) { m = json_object_object_length(v22); if ( !m ) goto LABEL_49; } goto LABEL_47; } v57 = (double *)&s[76]; for ( m = 0; ; ++m ) { if ( m >= json_object_array_length(v22) || m == 5 ) goto LABEL_49; v58 = json_object_array_get_idx(v22, m); v59 = v58; if ( v58 ) { if ( json_object_get_type(v58) == 2 ) { v75 = json_object_get_double(v59); LABEL_163: *v57 = v75; goto LABEL_111; } if ( json_object_get_type(v59) == 3 ) { v75 = (double)json_object_get_int(v59); goto LABEL_163; } } if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get double with error obj or value type is unmatch.\n", "jcs_test_callback_add", 485); *v57 = 0.0; LABEL_111: ++v57; } } LABEL_47: m = dword_2D33C; if ( dword_2D33C ) { m = 0; printf( "[JCS_ERR]%s()/%d Warning: Get doubleArray with error obj or value type is unmatch.\n", "jcs_test_callback_add", 485); } LABEL_49: v24 = (double *)&s[76]; for ( n = 0; n < m; ++n ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.weights[%d]=%f\n", "jcs_test_callback_add", 488, n, *v24); ++v24; } v26 = json_object_object_get(a1, "names"); v27 = v26; if ( !v26 ) { LABEL_57: v28 = dword_2D33C; if ( dword_2D33C ) { v28 = 0; printf( "[JCS_ERR]%s()/%d Warning: Get stringArray with error obj or value type is unmatch.\n", "jcs_test_callback_add", 493); } goto LABEL_59; } if ( json_object_get_type(v26) != 5 ) { if ( json_object_get_type(v27) == 4 ) { v28 = json_object_object_length(v27); if ( !v28 ) goto LABEL_59; } goto LABEL_57; } v28 = 0; v60 = (char *)&s[86]; while ( v28 < json_object_array_length(v27) && v28 != 3 ) { v61 = json_object_array_get_idx(v27, v28); if ( v61 && (v79 = v61, json_object_get_type(v61) == 6) ) { v62 = (const char *)json_object_get_string(v79); v63 = v60; } else { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get string with error obj or value type is unmatch.\n", "jcs_test_callback_add", 493); v62 = &byte_1C90F; v63 = v60; } ++v28; strncpy(v63, v62, 0x7Fu); v60[127] = 0; v60 += 128; } LABEL_59: v29 = (const char *)&s[86]; for ( ii = 0; ii < v28; ++ii ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.names[%d]=%s\n", "jcs_test_callback_add", 496, ii, v29); v29 += 128; } v31 = json_object_object_get(a1, "sub"); v32 = json_object_object_get(v31, "foo"); v33 = v32; if ( !v32 ) goto LABEL_67; if ( json_object_get_type(v32) == 3 ) { v72 = json_object_get_int(v33); LABEL_152: s[182] = v72; goto LABEL_70; } if ( json_object_get_type(v33) == 2 ) { v72 = (int)json_object_get_double(v33); goto LABEL_152; } LABEL_67: if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Warning: Get int with error obj or value type is unmatch.\n", "jcs_test_callback_add", 504); s[182] = -1; LABEL_70: if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.sub.foo=%d\n", "jcs_test_callback_add", 505, s[182]); v34 = json_object_object_get(v31, "bar"); v35 = v34; if ( v34 && json_object_get_type(v34) == 6 ) { v36 = (const char *)json_object_get_string(v35); } else { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get string with error obj or value type is unmatch.\n", "jcs_test_callback_add", 508); v36 = &byte_1C90F; } strncpy((char *)&s[183], v36, 0x3Fu); HIBYTE(s[198]) = 0; if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.sub.bar=%s\n", "jcs_test_callback_add", 509, (const char *)&s[183]); v37 = json_object_object_get(v31, "xiaopang"); v38 = v37; if ( v37 ) { if ( json_object_get_type(v37) != 5 ) { if ( json_object_get_type(v38) == 4 ) { jj = json_object_object_length(v38); if ( !jj ) goto LABEL_84; } goto LABEL_82; } v69 = s; for ( jj = 0; ; ++jj ) { if ( jj >= json_object_array_length(v38) || jj == 3 ) goto LABEL_84; v70 = json_object_array_get_idx(v38, jj); v71 = v70; if ( v70 ) { if ( json_object_get_type(v70) == 3 ) { v78 = json_object_get_int(v71); LABEL_173: v69[199] = v78; goto LABEL_150; } if ( json_object_get_type(v71) == 2 ) { v78 = (int)json_object_get_double(v71); goto LABEL_173; } } if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get int with error obj or value type is unmatch.\n", "jcs_test_callback_add", 512); v69[199] = -1; LABEL_150: ++v69; } } LABEL_82: jj = dword_2D33C; if ( dword_2D33C ) { jj = 0; printf( "[JCS_ERR]%s()/%d Warning: Get intArray with error obj or value type is unmatch.\n", "jcs_test_callback_add", 512); } LABEL_84: for ( kk = 0; kk < jj; ++kk ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d entry.sub.xiaopang[%d]=%d\n", "jcs_test_callback_add", 515, kk, v13[199]); ++v13; } v41 = json_object_new_boolean(1); json_object_object_add(a2, "ret", v41); v42 = json_object_new_double(0, 1076428800); json_object_object_add(a2, "money", v42); v43 = json_object_new_int(10); json_object_object_add(a2, "fn", v43); v44 = json_object_new_string("wuzhenyu"); v45 = json_object_object_add(a2, 108439, v44); v46 = json_object_new_array(v45); v47 = json_object_new_int(2); json_object_array_add(v46, v47); v48 = json_object_new_int(3); json_object_array_add(v46, v48); v49 = json_object_new_int(4); json_object_array_add(v46, v49); v50 = json_object_object_add(a2, "list", v46); v51 = json_object_new_object(v50); v52 = json_object_new_string("example"); json_object_object_add(v51, "title", v52); v53 = json_object_new_int(133); json_object_object_add(v51, "refcnt", v53); v54 = json_object_new_int(23); json_object_object_add(v51, "page", v54); result = json_object_object_add(a2, "data", v51); if ( dword_2D38C ) { v56 = (const char *)json_object_to_json_string_ext(a2, 0); return printf("[JCS_DBG]%s()/%d out_obj=%s\n", "jcs_test_callback_add", 549, v56); } return result; } // 1193C: using guessed type int __fastcall json_object_array_length(_DWORD); // 1196C: using guessed type int __fastcall json_object_get_type(_DWORD); // 1199C: using guessed type int __fastcall json_object_new_array(_DWORD); // 119A8: using guessed type int __fastcall json_object_new_string(_DWORD); // 119D8: using guessed type double __fastcall json_object_get_double(_DWORD); // 11A14: using guessed type int __fastcall json_object_get_string(_DWORD); // 11A2C: using guessed type int __fastcall json_object_array_get_idx(_DWORD, _DWORD); // 11A44: using guessed type int __fastcall json_object_array_add(_DWORD, _DWORD); // 11A50: using guessed type int __fastcall json_object_new_object(_DWORD); // 11A5C: using guessed type int __fastcall json_object_object_length(_DWORD); // 11AF8: using guessed type int __fastcall json_object_to_json_string_ext(_DWORD, _DWORD); // 11B10: using guessed type int __fastcall json_object_get_int(_DWORD); // 11B58: using guessed type int __fastcall json_object_new_int(_DWORD); // 11B88: using guessed type int __fastcall json_object_get_boolean(_DWORD); // 11B94: using guessed type int __fastcall json_object_object_add(_DWORD, _DWORD, _DWORD); // 11C6C: using guessed type int __fastcall json_object_new_double(_DWORD, _DWORD); // 11D14: using guessed type int __fastcall json_object_object_get(_DWORD, _DWORD); // 11DBC: using guessed type int __fastcall json_object_new_boolean(_DWORD); // 2D33C: using guessed type int dword_2D33C; // 2D38C: using guessed type int dword_2D38C; //----- (00013338) -------------------------------------------------------- int __fastcall sub_13338(const char *a1) { int v2; // r8 void *v3; // r7 ssize_t v4; // r0 int v5; // r0 int v6; // r9 int v7; // r4 int v8; // r11 int v9; // r0 bool v10; // zf const char *v11; // r1 int v12; // r10 int v13; // r4 unsigned int v15; // r0 int v16; // r0 void (__fastcall *v17)(int, int); // r3 int v18; // r0 bool v19; // zf const char *v20; // r10 size_t v21; // r0 int v22; // r3 bool v23; // zf const char *string; // r0 int v25; // [sp+Ch] [bp-148h] int v26; // [sp+10h] [bp-144h] char dest[127]; // [sp+18h] [bp-13Ch] BYREF char v28; // [sp+97h] [bp-BDh] struct sockaddr s; // [sp+98h] [bp-BCh] BYREF char v30[68]; // [sp+108h] [bp-4Ch] BYREF socklen_t len[2]; // [sp+14Ch] [bp-8h] BYREF v2 = socket(1, 2, 0); if ( v2 < 0 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Create receive socket failed.\n", "jcs_work_task", 195); } else { memset(&s, 0, 0x6Eu); s.sa_family = 1; strcpy(s.sa_data, a1); len[0] = strlen(s.sa_data) + 2; unlink(a1); if ( bind(v2, &s, len[0]) < 0 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Bind socket failed.\n", 109015, 207); } else { v3 = sub_17D44(131073); if ( v3 ) { while ( 1 ) { while ( 1 ) { do { while ( !dword_2D390 ) sleep(1u); v4 = recvfrom(v2, v3, 0x20000u, 0, &s, len); } while ( v4 <= 0 ); *((_BYTE *)v3 + v4) = 0; if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d ==========Process Start=========\n", "jcs_work_task", 236); if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d Rcv json: %s\n", "jcs_work_task", 237, (const char *)v3); v5 = json_tokener_parse(v3); v25 = v5; if ( v5 ) break; if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Invalid json string: %s\n", "jcs_work_task", 243, (const char *)v3); } v6 = json_object_object_get(v5, 108439); v7 = json_object_object_get(v25, "op"); v8 = json_object_object_get(v25, "clt_path"); v9 = json_object_object_get(v25, "data"); v10 = v9 == 0; if ( v9 ) v10 = v7 == 0; v26 = v9; if ( v10 || !v6 ) break; if ( v8 ) { if ( json_object_get_type(v8) == 6 ) { string = (const char *)json_object_get_string(v8); strncpy(dest, string, 0x7Fu); v28 = 0; } else { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get string with error obj or value type is unmatch.\n", "jcs_work_task", 259); strncpy(dest, &byte_1C90F, 0x7Fu); v28 = 0; } } if ( json_object_get_type(v6) == 6 ) { v11 = (const char *)json_object_get_string(v6); } else { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get string with error obj or value type is unmatch.\n", "jcs_work_task", 261); v11 = &byte_1C90F; } strncpy(v30, v11, 0x40u); v30[64] = 0; if ( json_object_get_type(v7) == 3 ) { v15 = json_object_get_int(v7); } else { if ( json_object_get_type(v7) != 2 ) { if ( dword_2D33C ) printf( "[JCS_ERR]%s()/%d Warning: Get int with error obj or value type is unmatch.\n", "jcs_work_task", 262); v12 = -1; LABEL_31: v13 = dword_2D33C; if ( !dword_2D33C ) goto LABEL_32; printf("[JCS_ERR]%s()/%d Operation wrong, op=%d.\n", "jcs_work_task", 265, v12); LABEL_45: v13 = 0; goto LABEL_32; } v15 = (unsigned int)json_object_get_double(v7); } v12 = v15; if ( v15 > 3 ) goto LABEL_31; v13 = json_object_new_object(v15); v16 = sub_173B8(dword_2D394, (int)v30); if ( v16 && (v17 = *(void (__fastcall **)(int, int))(v16 + 4 * v12 + 68)) != 0 ) { v17(v26, v13); } else if ( dword_2D33C ) { printf( "[JCS_ERR]%s()/%d No callback operation [name=%s,t=%d] registered.\n", "jcs_work_task", 275, v30, v12); } v18 = json_object_to_json_string_ext(v13, 0); v19 = v18 == 0; if ( v18 ) v19 = v8 == 0; v20 = (const char *)v18; if ( !v19 ) { memset(&s, 0, 0x6Eu); s.sa_family = 1; strcpy(s.sa_data, dest); len[0] = strlen(s.sa_data) + 2; do { v21 = strlen(v20); if ( sendto(v2, v20, v21, 0, &s, len[0]) > 0 ) break; v22 = *_errno_location(); v23 = v22 == 11; if ( v22 != 11 ) v23 = v22 == 4; } while ( v23 ); } LABEL_32: json_object_put(v25); if ( v13 ) json_object_put(v13); if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d ==========Process End=========\n\n\n", "jcs_work_task", 316); } v13 = dword_2D33C; if ( !dword_2D33C ) goto LABEL_32; printf("[JCS_ERR]%s()/%d Parse json string failed, no expected field.\n", "jcs_work_task", 253); goto LABEL_45; } if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Malloc buffer failed.\n", 109015, 216); } close(v2); } return 0; } // 118AC: using guessed type int __fastcall json_tokener_parse(_DWORD); // 1196C: using guessed type int __fastcall json_object_get_type(_DWORD); // 119D8: using guessed type double __fastcall json_object_get_double(_DWORD); // 11A14: using guessed type int __fastcall json_object_get_string(_DWORD); // 11A50: using guessed type int __fastcall json_object_new_object(_DWORD); // 11AF8: using guessed type int __fastcall json_object_to_json_string_ext(_DWORD, _DWORD); // 11B10: using guessed type int __fastcall json_object_get_int(_DWORD); // 11D14: using guessed type int __fastcall json_object_object_get(_DWORD, _DWORD); // 11DA4: using guessed type int __fastcall json_object_put(_DWORD); // 2D33C: using guessed type int dword_2D33C; // 2D38C: using guessed type int dword_2D38C; // 2D390: using guessed type int dword_2D390; // 2D394: using guessed type int dword_2D394; //----- (00013874) -------------------------------------------------------- int sub_13874() { int result; // r0 if ( dword_2D38C ) return printf("[JCS_DBG]%s()/%d in call GET back\n", "jcs_test_callback_get", 555); return result; } // 2D38C: using guessed type int dword_2D38C; //----- (000138A0) -------------------------------------------------------- int sub_138A0() { int result; // r0 if ( dword_2D38C ) return printf("[JCS_DBG]%s()/%d in call DEL back\n", "jcs_test_callback_del", 566); return result; } // 2D38C: using guessed type int dword_2D38C; //----- (000138CC) -------------------------------------------------------- int __fastcall sub_138CC(const char *a1, const char *a2) { bool v2; // zf int result; // r0 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; if ( !v2 ) return strcmp(a1, a2) == 0; result = dword_2D33C; if ( dword_2D33C ) { printf("[JCS_ERR]%s()/%d inputs error.\n", "jcs_hash_cmp_func", 157); return 0; } return result; } // 2D33C: using guessed type int dword_2D33C; //----- (00013920) -------------------------------------------------------- unsigned int __fastcall sub_13920(char *a1) { size_t v2; // r1 unsigned int result; // r0 if ( a1 ) { v2 = strlen(a1); return sub_175D8((unsigned __int8 *)a1, v2, 0); } else { result = dword_2D33C; if ( dword_2D33C ) { printf("[JCS_ERR]%s()/%d inputs error.\n", "jcs_hash_key_func", 111); return 0; } } return result; } // 2D33C: using guessed type int dword_2D33C; //----- (00013978) -------------------------------------------------------- unsigned int __fastcall sub_13978(char *a1) { unsigned int result; // r0 if ( a1 ) return sub_13920(a1); result = dword_2D33C; if ( dword_2D33C ) { printf("[JCS_ERR]%s()/%d inputs error.\n", "jcs_hash_obj_func", 136); return 0; } return result; } // 2D33C: using guessed type int dword_2D33C; //----- (000139C0) -------------------------------------------------------- int __fastcall sub_139C0(const char *a1, unsigned int a2, int a3) { bool v3; // zf int result; // r0 int v8; // r10 char *v9; // r0 char *v10; // r6 v3 = a1 == 0; if ( a1 ) v3 = a3 == 0; if ( v3 || a2 > 3 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Invalid parameters.\n", 109127, 326); return -1; } v8 = sub_173B8(dword_2D394, (int)a1); if ( v8 ) { *(_DWORD *)(v8 + 4 * a2 + 68) = a3; return 0; } else { v9 = (char *)sub_17D44(84); v10 = v9; if ( !v9 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Malloc register entry failed.\n", 109127, 341); return -1; } memset(v9, 0, 0x54u); strncpy(v10, a1, 0x40u); *(_DWORD *)&v10[4 * a2 + 68] = a3; result = sub_17108((int (__fastcall **)(int))dword_2D394, (int)v10); if ( result ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Add to hash table failed.\n", 109127, 351); return -1; } } return result; } // 2D33C: using guessed type int dword_2D33C; // 2D394: using guessed type int dword_2D394; //----- (00013AE0) -------------------------------------------------------- int sub_13AE0() { int result; // r0 __pid_t v1; // r0 if ( dword_2D398 ) { result = dword_2D38C; if ( !dword_2D38C ) return result; printf("[JCS_DBG]%s()/%d jcs has been inited already!\n", "jcs_init", 364); return 0; } if ( dword_2D394 ) { if ( dword_2D38C ) printf("[JCS_DBG]%s()/%d jcs callback table has existed already!\n", "jcs_init", 370); goto LABEL_7; } dword_2D394 = (int)sub_17070((int)sub_13978, (int)sub_13920, (int)sub_138CC, 256); if ( dword_2D394 ) { v1 = getpid(); if ( sub_14600(v1, byte_2D39C) >= 0 ) { LABEL_7: dword_2D398 = 1; return 0; } if ( !dword_2D33C ) return -1; printf("[JCS_ERR]%s()/%d Get process name failed.\n", 109149, 386); } else if ( dword_2D33C ) { printf("[JCS_ERR]%s()/%d Malloc jcs callback table failed.\n", 109149, 380); } return -1; } // 2D33C: using guessed type int dword_2D33C; // 2D38C: using guessed type int dword_2D38C; // 2D394: using guessed type int dword_2D394; // 2D398: using guessed type int dword_2D398; //----- (00013C04) -------------------------------------------------------- int sub_13C04() { int result; // r0 char *v1; // r0 int v2; // r6 char *v3; // r0 int v4; // r6 pthread_t v5; // [sp+4h] [bp-4h] BYREF result = 0; v5 = 0; if ( !dword_2D390 ) { v1 = (char *)sub_17D44(128); v2 = (int)v1; if ( v1 ) { sprintf(v1, "%s.%s", "/tmp/jcs.ui.srv", byte_2D39C); sub_18088(&v5, "jcs_ui", (int)sub_13338, v2); v3 = (char *)sub_17D44(128); v4 = (int)v3; if ( v3 ) { sprintf(v3, "%s.%s", "/tmp/jcs.service.srv", byte_2D39C); sub_18088(&v5, "jcs_service", (int)sub_13338, v4); dword_2D390 = 1; return 0; } if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Malloc jcs path failed.\n", 109158, 416); } else if ( dword_2D33C ) { printf("[JCS_ERR]%s()/%d Malloc jcs path failed.\n", 109158, 406); } return -1; } return result; } // 2D33C: using guessed type int dword_2D33C; // 2D390: using guessed type int dword_2D390; //----- (00013D10) -------------------------------------------------------- int sub_13D10() { sub_139C0("example", 0, (int)sub_12710); sub_139C0("example", 1u, (int)sub_138A0); return sub_139C0("example", 3u, (int)sub_13874); } //----- (00013D5C) -------------------------------------------------------- int __fastcall sub_13D5C(const char *a1, int a2, int a3, int a4, int *a5, int a6) { bool v9; // zf int v10; // r0 int v11; // r5 size_t v12; // r4 int v13; // r0 int v14; // r4 int v15; // r0 int v16; // r0 int v17; // r0 const char *v18; // r0 char *v19; // r7 size_t v20; // r9 socklen_t addr_len; // r10 int v22; // r6 bool v23; // zf int v24; // r6 _BOOL4 v26; // r3 ssize_t v27; // r8 int v28; // r3 bool v29; // zf int v30; // r0 char s[128]; // [sp+10h] [bp-17Ch] BYREF char src[128]; // [sp+90h] [bp-FCh] BYREF struct sockaddr addr; // [sp+110h] [bp-7Ch] BYREF int optval; // [sp+180h] [bp-Ch] BYREF int v36; // [sp+184h] [bp-8h] memset(s, 0, sizeof(s)); memset(src, 0, sizeof(src)); v9 = a1 == 0; if ( a1 ) v9 = a2 == 0; optval = 0; v36 = 0; if ( v9 || !a4 ) return -1; sprintf(s, "%s.%s", "/tmp/jcs.service.srv", a1); v10 = syscall(224); sprintf(src, "%s.%d.cclt", s, v10); v11 = socket(1, 2, 0); if ( v11 < 0 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Create socket failed.\n", "jcs_send_to_process", 616); return -1; } memset(&addr, 0, 0x6Eu); addr.sa_family = 1; strcpy(addr.sa_data, src); v12 = strlen(addr.sa_data); unlink(src); v13 = bind(v11, &addr, v12 + 2); if ( v13 < 0 ) { v14 = dword_2D33C; if ( dword_2D33C ) { v14 = 0; printf("[JCS_ERR]%s()/%d Bind socket failed.\n", "jcs_send_to_process", 628); } v19 = 0; } else { v14 = json_object_new_object(v13); v15 = json_object_new_string(a2); json_object_object_add(v14, 108439, v15); v16 = json_object_new_int(a3); json_object_object_add(v14, "op", v16); v17 = json_object_new_string(src); json_object_object_add(v14, "clt_path", v17); json_object_object_add(v14, "data", a4); v18 = (const char *)json_object_to_json_string_ext(v14, 0); v19 = (char *)v18; if ( v18 ) { v20 = strlen(v18); memset(&addr, 0, 0x6Eu); addr.sa_family = 1; strcpy(addr.sa_data, s); addr_len = strlen(addr.sa_data) + 2; while ( sendto(v11, v19, v20, 0, &addr, addr_len) != v20 ) { v22 = *_errno_location(); v23 = v22 == 11; if ( v22 != 11 ) v23 = v22 == 4; if ( !v23 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d send %s failed.\n", "jcs_send_to_process", 662, v19); v19 = 0; goto LABEL_20; } } if ( a6 ) { optval = a6; v36 = 0; setsockopt(v11, 1, 20, &optval, 8u); } v19 = (char *)sub_17DE0(1, 131073); if ( v19 ) { while ( 1 ) { v27 = recvfrom(v11, v19, 0x20000u, 0, 0, 0); if ( v27 > 0 ) break; if ( a6 ) { v26 = *_errno_location() == 4; } else { v28 = *_errno_location(); v29 = v28 == 11; if ( v28 != 11 ) v29 = v28 == 4; v26 = v29; } if ( !v26 ) { if ( v27 ) { if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d receive failed.\n", "jcs_send_to_process", 690); goto LABEL_20; } break; } } if ( !a5 ) { v24 = 0; goto LABEL_21; } v30 = json_tokener_parse(v19); *a5 = v30; if ( v30 ) { v24 = 0; goto LABEL_21; } if ( dword_2D33C ) printf("[JCS_ERR]%s()/%d Invalid json string: %s\n", "jcs_send_to_process", 700, v19); } } } LABEL_20: v24 = -1; LABEL_21: unlink(src); close(v11); if ( v19 ) sub_17D98(v19); if ( v14 ) json_object_put(v14); return v24; } // 118AC: using guessed type int __fastcall json_tokener_parse(_DWORD); // 119A8: using guessed type int __fastcall json_object_new_string(_DWORD); // 11A50: using guessed type int __fastcall json_object_new_object(_DWORD); // 11AF8: using guessed type int __fastcall json_object_to_json_string_ext(_DWORD, _DWORD); // 11B58: using guessed type int __fastcall json_object_new_int(_DWORD); // 11B94: using guessed type int __fastcall json_object_object_add(_DWORD, _DWORD, _DWORD); // 11DA4: using guessed type int __fastcall json_object_put(_DWORD); // 2D33C: using guessed type int dword_2D33C; //----- (00014600) -------------------------------------------------------- int __fastcall sub_14600(int a1, const char *a2) { FILE *v4; // r5 int result; // r0 char v6[256]; // [sp+0h] [bp-144h] BYREF char s[68]; // [sp+100h] [bp-44h] BYREF memset(s, 0, 0x40u); memset(v6, 0, sizeof(v6)); if ( !a2 ) return -1; sprintf(s, "/proc/%d/status", a1); v4 = fopen(s, "r"); if ( !v4 ) return -1; if ( !fgets(v6, 255, v4) ) { fclose(v4); return -1; } fclose(v4); sscanf(v6, "%*s %s", a2); result = dword_2D3E8; if ( dword_2D3E8 ) { printf("[UAC_COMM_DBG]%s()/line %d : task name: %s\n", "uac_com_get_name_by_pid", 802, a2); return 0; } return result; } // 2D3E8: using guessed type int dword_2D3E8; //----- (000146E0) -------------------------------------------------------- int __fastcall sub_146E0(const char *a1, const char *a2, int a3, int a4) { bool v4; // zf int v5; // r4 bool v6; // zf int v7; // r0 char *v8; // r5 int v9; // r6 const char *v10; // r3 unsigned int v11; // r2 int v13; // r2 bool v14; // zf const char *v15; // r0 int v16; // r2 char *v17; // r1 int v18; // r2 bool v19; // zf int *v20; // r7 int i; // r6 int v22; // r10 int v23; // r3 unsigned int v24; // r8 size_t v25; // r8 int v26; // r6 int v27; // r3 int v28; // r7 int v29; // r7 int *v30; // r8 _DWORD *v31; // r8 int v32; // r10 int v33; // r6 int v34; // r3 bool v35; // zf int v36; // r7 int *v37; // r8 _DWORD *v38; // r9 int j; // r10 int v40; // r11 _DWORD *v41; // r9 int m; // r10 int v43; // r11 __int64 v44; // r0 float v45; // r0 double v46; // r0 _DWORD *v47; // r8 int k; // r7 int v49; // r10 float v50; // r0 __int64 v51; // r0 double v52; // r0 unsigned int v53; // r6 size_t v54; // r6 int v55; // [sp+Ch] [bp-40h] int v56; // [sp+10h] [bp-3Ch] _BYTE v60[16]; // [sp+20h] [bp-2Ch] BYREF int v61; // [sp+30h] [bp-1Ch] v4 = a1 == 0; if ( a1 ) v4 = a2 == 0; v5 = a3; if ( v4 ) return -1; v6 = a3 == 0; if ( a3 ) v6 = a4 == 0; if ( v6 ) return -1; v7 = uci_alloc_context(); v56 = v7; if ( !v7 ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : alloc uci ctx error\n", "uac_com_uci_parse_req", 1124); return -1; } v8 = (char *)sub_17D44(256); if ( !v8 ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : malloc error\n", 111402, 1131); goto LABEL_24; } v55 = 0; v9 = -1; while ( 2 ) { if ( v55 >= a4 ) goto LABEL_25; if ( v55 != *(_DWORD *)v5 ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : idx not valid, should be array index.\n", 111402, 1141); goto LABEL_24; } v10 = *(const char **)(v5 + 4); if ( !v10 || !*(_DWORD *)(v5 + 28) || (v11 = *(_DWORD *)(v5 + 8), v11 > 5) || !*(_WORD *)(v5 + 24) || !*(_WORD *)(v5 + 26) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : paras not valid\n", 111402, 1148); goto LABEL_24; } switch ( v11 ) { case 1u: case 4u: *(_DWORD *)(v5 + 32) = 0; if ( *(_DWORD *)(v5 + 20) || *(_DWORD *)(v5 + 16) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : not necessary paras specified.\n", 111447, 936); goto LABEL_24; } sprintf(v8, "%s.%s.%s", a1, a2, v10); if ( uci_lookup_ptr(v56, v60, v8, 1) || !v61 ) goto LABEL_155; v18 = *(_DWORD *)(v61 + 20); if ( v18 ) { if ( v18 != 1 ) { LABEL_45: if ( *(_DWORD *)(v5 + 8) == 1 ) { v53 = *(unsigned __int16 *)(v5 + 26); if ( v53 <= 1 ) v54 = 0; else v54 = v53 - 1; strncpy(*(char **)(v5 + 28), *(const char **)(v61 + 24), v54); *(_BYTE *)(*(_DWORD *)(v5 + 28) + v54) = 0; goto LABEL_79; } v20 = *(int **)(v61 + 24); for ( i = 0; ; ++i ) { if ( v20 == (int *)(v61 + 24) ) goto LABEL_136; if ( i >= *(unsigned __int16 *)(v5 + 24) ) break; v24 = *(unsigned __int16 *)(v5 + 26); if ( v24 <= 1 ) v25 = 0; else v25 = v24 - 1; if ( *(_DWORD *)(v5 + 8) == 1 ) { strncpy(*(char **)(v5 + 28), (const char *)v20[3], v25); v23 = *(_DWORD *)(v5 + 28); } else { v22 = *(_DWORD *)(v5 + 28); strncpy(*(char **)(v22 + 4 * i), (const char *)v20[3], v25); v23 = *(_DWORD *)(v22 + 4 * i); } *(_BYTE *)(v23 + v25) = 0; v20 = (int *)*v20; } if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]element out of range\n"; v16 = 987; v17 = "_uac_com_uci_string_prase"; goto LABEL_35; } goto LABEL_24; } v19 = *(_DWORD *)(v5 + 8) == 1; } else { v19 = *(_DWORD *)(v5 + 8) == 4; } if ( v19 ) { LABEL_155: if ( !*(_DWORD *)(v5 + 12) ) goto LABEL_80; if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : not_null option[%s] not found or type mismatch\n"; v16 = 949; v17 = "_uac_com_uci_string_prase"; goto LABEL_35; } goto LABEL_24; } goto LABEL_45; case 2u: case 5u: if ( *(_DWORD *)(v5 + 20) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : not necessary paras specified.\n", 111473, 1011); goto LABEL_24; } *(_DWORD *)(v5 + 32) = 0; sprintf(v8, "%s.%s.%s", a1, a2, v10); if ( uci_lookup_ptr(v56, v60, v8, 1) ) goto LABEL_84; v33 = v61; if ( !v61 ) goto LABEL_84; v34 = *(_DWORD *)(v61 + 20); if ( v34 ) { if ( v34 != 1 ) goto LABEL_92; v35 = *(_DWORD *)(v5 + 8) == 2; } else { v35 = *(_DWORD *)(v5 + 8) == 5; } if ( v35 ) { LABEL_84: if ( *(_DWORD *)(v5 + 12) ) { if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : not_null option[%s] not found or type mismatch\n"; v16 = 1026; v17 = "_uac_com_uci_float_prase"; goto LABEL_35; } goto LABEL_24; } goto LABEL_80; } LABEL_92: if ( *(_DWORD *)(v5 + 8) != 2 ) { v36 = 0; v37 = *(int **)(v61 + 24); i = 0; LABEL_95: if ( v37 == (int *)(v61 + 24) ) goto LABEL_136; if ( i >= *(unsigned __int16 *)(v5 + 24) ) { if ( !dword_2D340 ) goto LABEL_24; v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]element out of range\n"; v16 = 1088; v17 = "_uac_com_uci_float_prase"; } else { v38 = *(_DWORD **)(v5 + 16); if ( !v38 ) { v46 = atof((const char *)v37[3]); goto LABEL_132; } for ( j = 0; j < *v38; ++j ) { v40 = v38[1] + 16 * j; if ( *(_DWORD *)v40 && !strcmp(*(const char **)v40, (const char *)v37[3]) ) { v46 = *(double *)(v40 + 8); LABEL_132: if ( *(_WORD *)(v5 + 26) == 8 ) { *(double *)(*(_DWORD *)(v5 + 28) + 8 * i) = v46; } else { v45 = v46; *(float *)(*(_DWORD *)(v5 + 28) + v36) = v45; } ++i; v37 = (int *)*v37; v36 += 4; goto LABEL_95; } } if ( !dword_2D340 ) goto LABEL_24; v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]transfer string to double failed.\n"; v16 = 1094; v17 = "_uac_com_uci_float_prase"; } goto LABEL_35; } v47 = *(_DWORD **)(v5 + 16); if ( v47 ) { for ( k = 0; k < *v47; ++k ) { v49 = v47[1] + 16 * k; if ( *(_DWORD *)v49 && !strcmp(*(const char **)v49, *(const char **)(v33 + 24)) ) { v52 = *(double *)(v49 + 8); goto LABEL_159; } } if ( !dword_2D340 ) goto LABEL_24; v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]transfer string to double failed.\n"; v16 = 1075; v17 = "_uac_com_uci_float_prase"; LABEL_35: printf(v15, v17, v16); goto LABEL_24; } v52 = atof((const char *)*(_DWORD *)(v61 + 24)); LABEL_159: if ( *(_WORD *)(v5 + 26) == 8 ) { *(double *)*(_DWORD *)(v5 + 28) = v52; } else { v50 = v52; **(float **)(v5 + 28) = v50; } goto LABEL_79; default: *(_DWORD *)(v5 + 32) = 0; v13 = *(_DWORD *)(v5 + 20); v14 = v13 == 16; if ( v13 != 16 ) v14 = v13 == 10; if ( !v14 && v13 != 8 && v13 != 2 ) { if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]base not valid\n"; v16 = 824; v17 = "_uac_com_uci_int_prase"; goto LABEL_35; } goto LABEL_24; } sprintf(v8, "%s.%s.%s", a1, a2, v10); if ( uci_lookup_ptr(v56, v60, v8, 1) ) goto LABEL_75; v26 = v61; if ( !v61 ) goto LABEL_75; v27 = *(_DWORD *)(v61 + 20); if ( v27 ) { if ( v27 == 1 && !*(_DWORD *)(v5 + 8) ) { LABEL_75: if ( *(_DWORD *)(v5 + 12) ) { if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : not_null option[%s] not found or type mismatch\n"; v16 = 837; v17 = "_uac_com_uci_int_prase"; goto LABEL_35; } goto LABEL_24; } goto LABEL_80; } } else if ( *(_DWORD *)(v5 + 8) == 3 ) { goto LABEL_75; } v28 = *(_DWORD *)(v5 + 8); if ( !v28 ) { v31 = *(_DWORD **)(v5 + 16); if ( v31 ) { while ( 1 ) { if ( v28 >= *v31 ) { if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]transfer string to llint failed.\n"; v16 = 892; v17 = "_uac_com_uci_int_prase"; goto LABEL_35; } goto LABEL_24; } v32 = v31[1] + 16 * v28; if ( *(_DWORD *)v32 ) { if ( !strcmp(*(const char **)v32, *(const char **)(v26 + 24)) ) break; } ++v28; } v51 = *(_QWORD *)(v32 + 8); } else { v51 = strtoll((const char *)*(_DWORD *)(v61 + 24), (char **)*(_DWORD *)(v5 + 16), *(_DWORD *)(v5 + 20)); } switch ( *(_WORD *)(v5 + 26) ) { case 1: **(_BYTE **)(v5 + 28) = v51; break; case 2: **(_WORD **)(v5 + 28) = v51; break; case 8: *(_QWORD *)*(_DWORD *)(v5 + 28) = v51; break; default: **(_DWORD **)(v5 + 28) = v51; break; } LABEL_79: *(_DWORD *)(v5 + 32) = 1; LABEL_80: v5 += 36; v9 = 0; ++v55; continue; } v29 = 0; v30 = *(int **)(v61 + 24); i = 0; LABEL_108: if ( v30 == (int *)(v61 + 24) ) { LABEL_136: *(_DWORD *)(v5 + 32) = i; goto LABEL_80; } if ( i >= *(unsigned __int16 *)(v5 + 24) ) { if ( !dword_2D340 ) goto LABEL_24; v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]element out of range\n"; v16 = 905; v17 = "_uac_com_uci_int_prase"; goto LABEL_35; } v41 = *(_DWORD **)(v5 + 16); if ( !v41 ) { v44 = strtoll((const char *)v30[3], (char **)*(_DWORD *)(v5 + 16), *(_DWORD *)(v5 + 20)); goto LABEL_122; } for ( m = 0; m < *v41; ++m ) { v43 = v41[1] + 16 * m; if ( *(_DWORD *)v43 && !strcmp(*(const char **)v43, (const char *)v30[3]) ) { v44 = *(_QWORD *)(v43 + 8); LABEL_122: switch ( *(_WORD *)(v5 + 26) ) { case 1: *(_BYTE *)(*(_DWORD *)(v5 + 28) + i) = v44; break; case 2: *(_WORD *)(*(_DWORD *)(v5 + 28) + 2 * i) = v44; break; case 8: *(_QWORD *)(*(_DWORD *)(v5 + 28) + 8 * i) = v44; break; default: *(_DWORD *)(*(_DWORD *)(v5 + 28) + v29) = v44; break; } v30 = (int *)*v30; ++i; v29 += 4; goto LABEL_108; } } if ( dword_2D340 ) { v15 = "[UAC_COMM_ERR]%s()/line %d : [%s]transfer string to llint failed.\n"; v16 = 912; v17 = "_uac_com_uci_int_prase"; goto LABEL_35; } LABEL_24: v9 = -1; LABEL_25: uci_free_context(v56); if ( v8 ) sub_17D98(v8); return v9; } } } // 147A8: control flows out of bounds to 147AC // 14CF4: control flows out of bounds to 14CF8 // 14E18: control flows out of bounds to 14E1C // 11A38: using guessed type int __fastcall uci_lookup_ptr(_DWORD, _DWORD, _DWORD, _DWORD); // 11B28: using guessed type int __fastcall uci_free_context(_DWORD); // 11BC4: using guessed type int uci_alloc_context(void); // 2D340: using guessed type int dword_2D340; //----- (0001502C) -------------------------------------------------------- bool sub_1502C() { _DWORD v1[6]; // [sp+0h] [bp-2Ch] BYREF __int16 v2; // [sp+18h] [bp-14h] __int16 v3; // [sp+1Ah] [bp-12h] char *v4; // [sp+1Ch] [bp-10h] int v5; // [sp+20h] [bp-Ch] char v6; // [sp+27h] [bp-5h] BYREF v6 = 0; v1[0] = 0; v1[1] = 113314; memset(&v1[2], 0, 12); v1[5] = 10; v4 = &v6; v5 = 0; v2 = 1; v3 = 1; if ( sub_146E0("device_info", "info", (int)v1, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_dev_is_wired", 771); v6 = 0; } return v6 == 0; } // 2D340: using guessed type int dword_2D340; //----- (000150E4) -------------------------------------------------------- int __fastcall sub_150E4(char *a1, int a2) { bool v2; // cc _DWORD v7[10]; // [sp+4h] [bp-28h] BYREF v2 = (int)a1 <= 0; if ( a1 ) v2 = a2 <= 1; if ( v2 ) return -1; if ( dword_2D474 ) { strncpy(a1, byte_2D478, a2 - 1); a1[a2 - 1] = 0; return 0; } else { if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_type", 596); v7[0] = 0; v7[1] = 115048; v7[2] = 1; v7[3] = 1; v7[4] = 0; v7[5] = 0; v7[6] = 8454145; v7[7] = byte_2D478; v7[8] = 0; if ( sub_146E0("device_info", "info", (int)v7, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_type", 605); return -1; } dword_2D474 = 1; strncpy(a1, byte_2D478, a2 - 1); a1[a2 - 1] = 0; return 0; } } // 2D340: using guessed type int dword_2D340; // 2D3E8: using guessed type int dword_2D3E8; // 2D474: using guessed type int dword_2D474; //----- (00015210) -------------------------------------------------------- int __fastcall sub_15210(char *a1, int a2) { bool v2; // cc _DWORD v7[10]; // [sp+4h] [bp-28h] BYREF v2 = (int)a1 <= 0; if ( a1 ) v2 = a2 <= 1; if ( v2 ) return -1; if ( dword_2D4FC ) { strncpy(a1, byte_2D500, a2 - 1); a1[a2 - 1] = 0; return 0; } else { if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_model", 556); v7[0] = 0; v7[1] = 115035; v7[2] = 1; v7[3] = 1; v7[4] = 0; v7[5] = 0; v7[6] = 8454145; v7[7] = byte_2D500; v7[8] = 0; if ( sub_146E0("device_info", "info", (int)v7, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_model", 565); return -1; } dword_2D4FC = 1; strncpy(a1, byte_2D500, a2 - 1); a1[a2 - 1] = 0; return 0; } } // 2D340: using guessed type int dword_2D340; // 2D3E8: using guessed type int dword_2D3E8; // 2D4FC: using guessed type int dword_2D4FC; //----- (0001533C) -------------------------------------------------------- int __fastcall sub_1533C(char *a1, int a2) { bool v2; // cc _DWORD v7[10]; // [sp+4h] [bp-28h] BYREF v2 = (int)a1 <= 0; if ( a1 ) v2 = a2 <= 1; if ( v2 ) return -1; if ( dword_2D584 ) { strncpy(a1, byte_2D588, a2 - 1); a1[a2 - 1] = 0; return 0; } else { if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_vendor_url", 515); v7[0] = 0; v7[1] = 115018; v7[2] = 1; v7[3] = 1; v7[4] = 0; v7[5] = 0; v7[6] = 8454145; v7[7] = byte_2D588; v7[8] = 0; if ( sub_146E0("device_info", "info", (int)v7, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_vendor_url", 524); return -1; } dword_2D584 = 1; strncpy(a1, byte_2D588, a2 - 1); a1[a2 - 1] = 0; return 0; } } // 2D340: using guessed type int dword_2D340; // 2D3E8: using guessed type int dword_2D3E8; // 2D584: using guessed type int dword_2D584; //----- (00015468) -------------------------------------------------------- int __fastcall sub_15468(_DWORD *a1) { int result; // r0 _DWORD v3[9]; // [sp+4h] [bp-24h] BYREF if ( !a1 ) return -1; if ( dword_2D60C ) { *a1 = dword_2D610; return 0; } if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_product_id", 475); v3[0] = 0; v3[1] = 115007; v3[2] = 0; v3[3] = 1; v3[4] = 0; v3[5] = 16; v3[6] = 262145; v3[7] = &dword_2D610; v3[8] = 0; result = sub_146E0("device_info", "info", (int)v3, 1); if ( result ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_product_id", 484); return -1; } dword_2D60C = 1; *a1 = dword_2D610; return result; } // 2D340: using guessed type int dword_2D340; // 2D3E8: using guessed type int dword_2D3E8; // 2D60C: using guessed type int dword_2D60C; // 2D610: using guessed type int dword_2D610; //----- (00015D28) -------------------------------------------------------- int __fastcall sub_15D28(char *a1, unsigned int a2) { bool v2; // cc _DWORD v7[8]; // [sp+14h] [bp-28h] BYREF int v8; // [sp+34h] [bp-8h] v2 = a1 != 0; if ( a1 ) v2 = a2 > 1; if ( !v2 ) return -1; if ( dword_2D950 ) { strncpy(a1, dest, a2 - 1); a1[a2 - 1] = 0; return 0; } else { if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_sales_method", 202); v7[0] = 0; v7[1] = 113590; v7[2] = 1; memset(&v7[3], 0, 12); v7[6] = 8454145; v7[7] = dest; v8 = 0; if ( sub_146E0("device_info", "info", (int)v7, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_sales_method", 211); return -1; } if ( !v8 ) { if ( dword_2D3E8 ) printf( "[UAC_COMM_DBG]%s()/line %d : Read fields '%s.%s.%s' failed, use default sales method '%s'.\n", "uac_com_get_dev_sales_method", 216, "device_info", "info", "sales_method", "channel"); strncpy(dest, "channel", 0x80u); } dword_2D950 = 1; strncpy(a1, dest, a2 - 1); a1[a2 - 1] = 0; return 0; } } // 2D340: using guessed type int dword_2D340; // 2D3E8: using guessed type int dword_2D3E8; // 2D950: using guessed type int dword_2D950; //----- (00015EC4) -------------------------------------------------------- int sub_15EC4() { int result; // r0 _DWORD v1[6]; // [sp+4h] [bp-44h] BYREF __int16 v2; // [sp+1Ch] [bp-2Ch] __int16 v3; // [sp+1Eh] [bp-2Ah] char *v4; // [sp+20h] [bp-28h] int v5; // [sp+24h] [bp-24h] char s[32]; // [sp+28h] [bp-20h] BYREF memset(s, 0, sizeof(s)); result = dword_2D344; if ( (unsigned int)dword_2D344 > 2 ) { if ( dword_2D3E8 ) printf("[UAC_COMM_DBG]%s()/line %d : Start to init value first time.\n", "uac_com_get_dev_vendor", 128); v1[0] = 0; v1[1] = 113842; v1[4] = 0; v1[5] = 0; v3 = 32; v5 = 0; v1[2] = 1; v1[3] = 1; v2 = 1; v4 = s; if ( sub_146E0("device_info", "info", (int)v1, 1) ) { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : uci req parse failed.\n", "uac_com_get_dev_vendor", 137); } else if ( !strncmp(s, "0x00010001", 0xAu) ) { dword_2D344 = 1; } else if ( !strncmp(s, "0x00020001", 0xAu) ) { dword_2D344 = 2; } else if ( !strncmp(s, "0x00000001", 0xAu) ) { dword_2D344 = 0; } else { if ( dword_2D340 ) printf("[UAC_COMM_ERR]%s()/line %d : invalid vendor_name:%s\n\n", "uac_com_get_dev_vendor", 155, s); dword_2D344 = 3; } return dword_2D344; } return result; } // 2D340: using guessed type int dword_2D340; // 2D344: using guessed type int dword_2D344; // 2D3E8: using guessed type int dword_2D3E8; //----- (00016058) -------------------------------------------------------- int __fastcall sub_16058(char *a1, size_t a2) { int v3; // r0 v3 = sub_15EC4(); if ( v3 == 1 ) { snprintf(a1, a2, "MERCURY"); } else if ( v3 == 2 ) { snprintf(a1, a2, "FAST"); } else { snprintf(a1, a2, "TP-LINK"); } return 0; } //----- (00016FB0) -------------------------------------------------------- _DWORD *__fastcall sub_16FB0(int a1, int a2, int a3, int a4, signed int a5) { bool v5; // zf int v10; // r9 _DWORD *v11; // r5 void *v12; // r11 int v13; // r11 _DWORD *v14; // r0 void *v16; // r0 v5 = a1 == 0; if ( a1 ) v5 = a2 == 0; if ( v5 ) return 0; v10 = 0; if ( !a3 ) return 0; v11 = sub_17D44(32); if ( v11 ) { v12 = sub_17DE0(a5, 12); v11[7] = v12; if ( v12 ) { v13 = 0; while ( v13 != a5 ) { ++v13; v14 = (_DWORD *)(v11[7] + v10); v10 += 12; sub_177E4(v14); } *v11 = a1; v11[1] = a2; v11[2] = a3; v11[6] = a4; v11[5] = v13; v11[4] = 0; } else { v16 = v11; v11 = 0; sub_17D98(v16); } } return v11; } //----- (00017070) -------------------------------------------------------- _DWORD *__fastcall sub_17070(int a1, int a2, int a3, signed int a4) { return sub_16FB0(a1, a2, a3, 0, a4); } //----- (00017084) -------------------------------------------------------- _DWORD *__fastcall sub_17084(int a1, int a2, int a3) { return sub_16FB0(a1, a2, a3, 1, 29); } //----- (0001709C) -------------------------------------------------------- void __fastcall sub_1709C(_DWORD *a1) { int v2; // r5 unsigned int i; // r6 _DWORD *v4; // r0 void *v5; // r7 void *v6; // r0 if ( a1 ) { v2 = 0; for ( i = 0; i < a1[5]; ++i ) { while ( 1 ) { v4 = (_DWORD *)sub_1782C((int *)(a1[7] + v2)); v5 = v4; if ( !v4 ) break; sub_17B04(v4); sub_17D98(v5); } v2 += 12; } v6 = (void *)a1[7]; a1[5] = 0; sub_17D98(v6); sub_17D98(a1); } } //----- (00017108) -------------------------------------------------------- int __fastcall sub_17108(int (__fastcall **a1)(int), int a2) { bool v2; // zf unsigned int v5; // r1 unsigned int v6; // r7 int *i; // r0 int *v8; // r0 int result; // r0 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; if ( v2 ) return -1; v5 = (unsigned int)a1[5]; if ( !v5 ) return -1; if ( a1[6] != (int (__fastcall *)(int))1 || 100 * ((int)a1[4] + 1) / v5 <= 0x64 || (result = sub_17204(a1, 1)) == 0 ) { v6 = 12 * ((*a1)(a2) % (unsigned int)a1[5]); for ( i = (int *)sub_1782C((int *)((char *)a1[7] + v6)); i; i = (int *)sub_178CC(i) ) { if ( a2 == i[3] ) return -4; } v8 = (int *)sub_17D44(16); if ( v8 ) { v8[3] = a2; sub_179D4((int)a1[7] + v6, v8); a1[4] = (int (__fastcall *)(int))((char *)a1[4] + 1); return 0; } else { return -2; } } return result; } //----- (00017204) -------------------------------------------------------- int __fastcall sub_17204(int (__fastcall **a1)(int), int a2) { int v2; // r6 int *v4; // r7 int v5; // r3 int (__fastcall *v6)(int); // r3 int (__fastcall *v7)(int); // r0 int v9; // r5 unsigned int v10; // r8 _DWORD *v11; // r0 int *v12; // r10 int v13; // r8 int *i; // r5 int v15; // r9 v2 = (int)a1[5]; v4 = (int *)a1[7]; if ( a2 ) v5 = 2 * v2; else v5 = (unsigned int)v2 >> 1; if ( a2 ) v6 = (int (__fastcall *)(int))(v5 + 3); else v6 = (int (__fastcall *)(int))(v5 - 1); a1[5] = v6; v7 = (int (__fastcall *)(int))sub_17DE0((signed int)a1[5], 12); a1[7] = v7; if ( v7 ) { v9 = 0; v10 = 0; while ( v10 < (unsigned int)a1[5] ) { ++v10; v11 = (_DWORD *)((char *)a1[7] + v9); v9 += 12; sub_177E4(v11); } v12 = v4; v13 = 0; a1[4] = 0; while ( v13 < v2 ) { for ( i = (int *)sub_1782C(v12); i; i = (int *)v15 ) { sub_17108(a1, i[3]); v15 = sub_178CC(i); sub_17D98(i); } ++v13; v12 += 3; } sub_17D98(v4); return 0; } else { a1[5] = (int (__fastcall *)(int))v2; a1[7] = (int (__fastcall *)(int))v4; return -2; } } //----- (000172E8) -------------------------------------------------------- int __fastcall sub_172E8(int a1, int a2) { bool v2; // zf unsigned int v6; // r1 int *i; // r0 int *v8; // r6 int v9; // r2 int v10; // r3 unsigned int v11; // r1 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; if ( v2 ) return -1; v6 = (unsigned int)(*(int (__fastcall **)(int))a1)(a2) % *(_DWORD *)(a1 + 20); for ( i = (int *)sub_1782C((int *)(*(_DWORD *)(a1 + 28) + 12 * v6)); ; i = (int *)sub_178CC(i) ) { v8 = i; if ( !i ) return -5; if ( i[3] == a2 ) break; } sub_17B04(i); sub_17D98(v8); v9 = *(_DWORD *)(a1 + 24); v10 = *(_DWORD *)(a1 + 16) - 1; *(_DWORD *)(a1 + 16) = v10; if ( v9 != 1 ) return 0; v11 = *(_DWORD *)(a1 + 20); if ( v11 <= 0x1D ) return 0; if ( 100 * v10 / v11 <= 9 ) { sub_17204((int (__fastcall **)(int))a1, 0); return 0; } return 0; } //----- (000173B8) -------------------------------------------------------- int __fastcall sub_173B8(int a1, int a2) { bool v2; // zf unsigned int v5; // r1 int result; // r0 int *v7; // r4 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; if ( v2 ) return 0; v5 = (unsigned int)(*(int (__fastcall **)(int))(a1 + 4))(a2) % *(_DWORD *)(a1 + 20); for ( result = sub_1782C((int *)(*(_DWORD *)(a1 + 28) + 12 * v5)); ; result = sub_178CC(v7) ) { v7 = (int *)result; if ( !result ) break; if ( (*(int (__fastcall **)(_DWORD, int))(a1 + 8))(*(_DWORD *)(result + 12), a2) ) return v7[3]; } return result; } //----- (00017438) -------------------------------------------------------- int __fastcall sub_17438(int result, int (__fastcall *a2)(int, int), int a3) { int v3; // r6 int v6; // r7 unsigned int v7; // r5 int *i; // r11 int *v9; // r9 int v10; // r3 v3 = result; if ( result && *(_DWORD *)(result + 16) ) { v6 = *(_DWORD *)(result + 20); v7 = 0; while ( v7 < *(_DWORD *)(v3 + 20) ) { result = sub_1782C((int *)(*(_DWORD *)(v3 + 28) + 12 * v7)); for ( i = (int *)result; ; i = v9 ) { if ( !i ) { ++v7; v10 = v6; goto LABEL_12; } result = sub_178CC(i); v9 = (int *)result; if ( a2 ) { result = a2(i[3], a3); v10 = *(_DWORD *)(v3 + 20); if ( v6 != v10 ) break; } } v7 = 0; LABEL_12: v6 = v10; } } return result; } //----- (000174D8) -------------------------------------------------------- int __fastcall sub_174D8(int result, unsigned int a2, int a3, int (__fastcall *a4)(int, int), int a5) { int v5; // r8 unsigned int v9; // r3 bool v10; // cc int v11; // r7 int v12; // r9 int v13; // r10 unsigned int v14; // r6 int *i; // r2 int *v16; // r3 int v17; // r0 int v18; // r2 int *v19; // [sp+4h] [bp-8h] int *v20; // [sp+4h] [bp-8h] v5 = result; if ( result ) { v9 = *(_DWORD *)(result + 16); v10 = (int)v9 <= 0; if ( v9 ) v10 = a3 <= 0; if ( !v10 ) { v11 = 0; if ( a2 < v9 ) { v12 = *(_DWORD *)(result + 20); v13 = 0; v14 = 0; while ( v14 < *(_DWORD *)(v5 + 20) ) { result = sub_1782C((int *)(*(_DWORD *)(v5 + 28) + 12 * v14)); for ( i = (int *)result; ; i = v16 ) { while ( 1 ) { if ( !i ) { ++v14; v18 = v12; goto LABEL_21; } if ( v13 >= (int)a2 ) break; result = sub_178CC(i); ++v13; i = (int *)result; } v19 = i; result = sub_178CC(i); v16 = (int *)result; if ( a4 ) { v17 = v19[3]; v20 = v16; result = a4(v17, a5); v18 = *(_DWORD *)(v5 + 20); v16 = v20; if ( v12 != v18 ) break; } if ( ++v11 >= a3 ) return result; } v14 = 0; LABEL_21: v12 = v18; } } } } return result; } //----- (000175C8) -------------------------------------------------------- int __fastcall sub_175C8(int a1) { if ( a1 ) return *(_DWORD *)(a1 + 16); else return -1; } //----- (000175D8) -------------------------------------------------------- unsigned int __fastcall sub_175D8(unsigned __int8 *a1, unsigned int a2, int a3) { unsigned int v4; // r12 unsigned int result; // r0 unsigned __int8 *v6; // r2 int v7; // r4 int v8; // r5 unsigned int v9; // r0 unsigned int v10; // r0 unsigned int v11; // r2 unsigned int v12; // r1 unsigned __int8 *v13; // r12 v4 = a2; result = a3 + a2; v6 = a1; while ( v4 > 3 ) { v4 -= 4; v7 = *v6 + (v6[1] << 8) + (v6[2] << 16); v8 = v6[3]; v6 += 4; v9 = ~((v7 + (v8 << 24) + result) << 15) + v7 + (v8 << 24) + result; v10 = (9 * (v9 ^ (v9 >> 10))) ^ ((9 * (v9 ^ (v9 >> 10))) >> 6); result = (~(v10 << 11) + v10) ^ ((~(v10 << 11) + v10) >> 16); } v11 = a2 >> 2; v12 = a2 - 4 * (a2 >> 2); v13 = &a1[4 * v11]; if ( v12 != 2 ) { if ( v12 != 3 ) { if ( v12 != 1 ) return result; goto LABEL_7; } result += v13[2] << 16; } result ^= v13[1] << 8; LABEL_7: result += a1[4 * v11]; return result; } //----- (00017684) -------------------------------------------------------- int __fastcall sub_17684(int a1, int a2, int (__fastcall *a3)(int, int), int a4) { unsigned int v7; // r1 int *v8; // r7 int result; // r0 int v10; // r5 if ( !a1 || !*(_DWORD *)(a1 + 16) ) return -1; if ( !a3 ) return -1; v7 = (unsigned int)(*(int (__fastcall **)(int))(a1 + 4))(a2) % *(_DWORD *)(a1 + 20); v8 = (int *)sub_1782C((int *)(*(_DWORD *)(a1 + 28) + 12 * v7)); result = -1; while ( v8 ) { v10 = sub_178CC(v8); result = a3(v8[3], a4); v8 = (int *)v10; } return result; } //----- (00017714) -------------------------------------------------------- int __fastcall sub_17714(int a1, int a2) { bool v2; // zf unsigned int v5; // r1 int v6; // r0 unsigned int v7; // r7 unsigned int v8; // r8 int *v9; // r0 int result; // r0 v2 = a1 == 0; if ( a1 ) v2 = a2 == 0; if ( v2 ) return -1; v5 = *(_DWORD *)(a1 + 20); if ( !v5 ) return -1; if ( *(_DWORD *)(a1 + 24) != 1 || 100 * (*(_DWORD *)(a1 + 16) + 1) / v5 <= 0x64 || (result = sub_17204((int (__fastcall **)(int))a1, 1)) == 0 ) { v6 = (*(int (__fastcall **)(int))a1)(a2); v7 = *(_DWORD *)(a1 + 20); v8 = v6; v9 = (int *)sub_17D44(16); if ( v9 ) { v9[3] = a2; sub_179D4(*(_DWORD *)(a1 + 28) + 12 * (v8 % v7), v9); ++*(_DWORD *)(a1 + 16); return 0; } else { return -2; } } return result; } //----- (000177E4) -------------------------------------------------------- _DWORD *__fastcall sub_177E4(_DWORD *result) { if ( result ) { *result = result; result[1] = result; result[2] = 0; } else if ( dword_2D370 ) { return (_DWORD *)printf("[UAC_LIST_ERROR]%s()/line %d : Input head invalid.\n", "uac_list_init", 79); } return result; } // 2D370: using guessed type int dword_2D370; //----- (0001782C) -------------------------------------------------------- int __fastcall sub_1782C(int *a1) { int result; // r0 if ( a1 ) { result = *a1; if ( (int *)*a1 == a1 ) return 0; } else { result = dword_2D370; if ( dword_2D370 ) { printf("[UAC_LIST_ERROR]%s()/line %d : Input head invalid.\n", "uac_list_first", 174); return 0; } } return result; } // 2D370: using guessed type int dword_2D370; //----- (0001787C) -------------------------------------------------------- int __fastcall sub_1787C(int a1) { int result; // r0 if ( a1 ) { result = *(_DWORD *)(a1 + 4); if ( result == a1 ) return 0; } else { result = dword_2D370; if ( dword_2D370 ) { printf("[UAC_LIST_ERROR]%s()/line %d : Input head invalid.\n", "uac_list_last", 200); return 0; } } return result; } // 2D370: using guessed type int dword_2D370; //----- (000178CC) -------------------------------------------------------- int __fastcall sub_178CC(int *a1) { int result; // r0 if ( a1 ) { result = *a1; if ( *a1 == a1[2] ) return 0; } else { result = dword_2D370; if ( dword_2D370 ) { printf("[UAC_LIST_ERROR]%s()/line %d : Input entry invalid.\n", "uac_list_next", 227); return 0; } } return result; } // 2D370: using guessed type int dword_2D370; //----- (00017920) -------------------------------------------------------- int __fastcall sub_17920(int a1) { int result; // r0 if ( a1 ) { result = *(_DWORD *)(a1 + 4); if ( result == *(_DWORD *)(a1 + 8) ) return 0; } else { result = dword_2D370; if ( dword_2D370 ) { printf("[UAC_LIST_ERROR]%s()/line %d : Input entry invalid.\n", "uac_list_prev", 253); return 0; } } return result; } // 2D370: using guessed type int dword_2D370; //----- (000179D4) -------------------------------------------------------- int __fastcall sub_179D4(int result, int *a2) { bool v2; // zf int v3; // r3 v2 = result == 0; if ( result ) v2 = a2 == 0; if ( v2 ) { if ( dword_2D370 ) return printf("[UAC_LIST_ERROR]%s()/line %d : Input head or entry invalid.\n", "uac_list_insert_last", 314); } else { v3 = *(_DWORD *)(result + 4); *a2 = result; a2[1] = v3; *(_DWORD *)(result + 4) = a2; *(_DWORD *)a2[1] = a2; a2[2] = result; ++*(_DWORD *)(result + 8); } return result; } // 2D370: using guessed type int dword_2D370; //----- (00017B04) -------------------------------------------------------- _DWORD *__fastcall sub_17B04(_DWORD *result) { if ( result ) { *(_DWORD *)(*result + 4) = result[1]; *(_DWORD *)result[1] = *result; --*(_DWORD *)(result[2] + 8); result[2] = 0; *result = 0; result[1] = 0; } else if ( dword_2D370 ) { return (_DWORD *)printf("[UAC_LIST_ERROR]%s()/line %d : Input entry invalid.\n", "uac_list_remove", 429); } return result; } // 2D370: using guessed type int dword_2D370; //----- (00017B70) -------------------------------------------------------- int __fastcall sub_17B70(int a1) { int result; // r0 if ( a1 ) return *(_DWORD *)(a1 + 8); result = dword_2D370; if ( dword_2D370 ) { printf("[UAC_LIST_ERROR]%s()/line %d : Input head invalid.\n", "uac_list_size", 463); return 0; } return result; } // 2D370: using guessed type int dword_2D370; //----- (00017BB8) -------------------------------------------------------- int *__fastcall sub_17BB8(int *result, int *a2) { bool v2; // zf int v4; // r4 int *v5; // r6 v2 = result == 0; if ( result ) v2 = a2 == 0; v4 = (int)result; if ( v2 ) { if ( dword_2D370 ) return (int *)printf("[UAC_LIST_ERROR]%s()/line %d : Input inlist or outlist invalid.\n", "uac_list_move", 491); } else { while ( 1 ) { result = (int *)sub_1782C(a2); v5 = result; if ( !result ) break; sub_17B04(result); sub_179D4(v4, v5); } } return result; } // 2D370: using guessed type int dword_2D370; //----- (00017C24) -------------------------------------------------------- int sub_17C24() { return puts( " Returns (by copy) a struct containing various summary statistics:\n" " arena: current total non-mmapped bytes allocated from system\n" " ordblks: the number of free chunks\n" " smblks: the number of fastbin blocks (i.e., small chunks that\n" " have been freed but not use resused or consolidated)\n" " hblks: current number of mmapped regions\n" " hblkhd: total bytes held in mmapped regions\n" " usmblks: the maximum total allocated space. This will be greater\n" " than current total if trimming has occurred.\n" " fsmblks: total bytes held in fastbin blocks\n" " uordblks: current total allocated space (normal or mmapped)\n" " fordblks: total free space\n" " keepcost: the maximum number of bytes that could ideally be released\n" " back to system via malloc_trim. (\"ideally\" means that\n" " it ignores page restrictions etc.)\n" " Because these fields are ints, but internal bookkeeping may\n" " be kept as longs, the reported values may wrap around zero and\n" " thus be inaccurate."); } //----- (00017C30) -------------------------------------------------------- int sub_17C30() { struct mallinfo v1; // [sp+0h] [bp-2Ch] BYREF mallinfo(&v1); printf("arena = %d\n", v1.arena); printf("ordblks = %d\n", v1.ordblks); printf("smblks = %d\n", v1.smblks); printf("hblks = %d\n", v1.hblks); printf("hblkhd = %d\n", v1.hblkhd); printf("usmblks = %d\n", v1.usmblks); printf("fsmblks = %d\n", v1.fsmblks); printf("uordblks = %d\n", v1.uordblks); printf("fordblks = %d\n", v1.fordblks); return printf("keepcost = %d\n", v1.keepcost); } //----- (00017CE8) -------------------------------------------------------- void sub_17CE8() { dword_2D9D8 = 1; } // 2D9D8: using guessed type int dword_2D9D8; //----- (00017CFC) -------------------------------------------------------- void sub_17CFC() { dword_2D9D8 = 0; } // 2D9D8: using guessed type int dword_2D9D8; //----- (00017D10) -------------------------------------------------------- int sub_17D10() { return dword_2D9D8; } // 2D9D8: using guessed type int dword_2D9D8; //----- (00017D20) -------------------------------------------------------- void sub_17D20() { dword_2D9DC = 0; } // 2D9DC: using guessed type int dword_2D9DC; //----- (00017D34) -------------------------------------------------------- int sub_17D34() { return dword_2D9DC; } // 2D9DC: using guessed type int dword_2D9DC; //----- (00017D44) -------------------------------------------------------- void *__fastcall sub_17D44(signed int a1) { void *v1; // r5 void *v2; // r0 bool v3; // zf if ( a1 <= 0 ) return 0; v2 = malloc(a1); v3 = v2 == 0; if ( v2 ) v3 = dword_2D9D8 == 0; v1 = v2; if ( !v3 ) { pthread_mutex_lock(&stru_2D9E0); ++dword_2D9DC; pthread_mutex_unlock(&stru_2D9E0); } return v1; } // 2D9D8: using guessed type int dword_2D9D8; // 2D9DC: using guessed type int dword_2D9DC; // 2D9E0: using guessed type pthread_mutex_t; //----- (00017D98) -------------------------------------------------------- void __fastcall sub_17D98(void *ptr) { bool v2; // zf v2 = ptr == 0; if ( ptr ) v2 = dword_2D9D8 == 0; if ( !v2 ) { pthread_mutex_lock(&stru_2D9E0); --dword_2D9DC; pthread_mutex_unlock(&stru_2D9E0); } free(ptr); } // 2D9D8: using guessed type int dword_2D9D8; // 2D9DC: using guessed type int dword_2D9DC; // 2D9E0: using guessed type pthread_mutex_t stru_2D9E0; //----- (00017DE0) -------------------------------------------------------- void *__fastcall sub_17DE0(signed int a1, signed int a2) { bool v2; // cc void *v5; // r4 void *v6; // r0 bool v7; // zf v2 = a1 <= 0; if ( a1 > 0 ) v2 = a2 <= 0; if ( v2 ) return 0; v6 = calloc(a1, a2); v5 = v6; if ( v6 ) memset(v6, 0, a2 * a1); v7 = v5 == 0; if ( v5 ) v7 = dword_2D9D8 == 0; if ( !v7 ) { pthread_mutex_lock(&stru_2D9E0); ++dword_2D9DC; pthread_mutex_unlock(&stru_2D9E0); } return v5; } // 2D9D8: using guessed type int dword_2D9D8; // 2D9DC: using guessed type int dword_2D9DC; // 2D9E0: using guessed type pthread_mutex_t stru_2D9E0; //----- (00017E5C) -------------------------------------------------------- void *__fastcall sub_17E5C(void *a1, int a2) { if ( a2 <= 0 && a1 == 0 ) return 0; if ( a2 <= 0 ) { sub_17D98(a1); return 0; } if ( a1 ) return realloc(a1, a2); else return sub_17D44(a2); } //----- (00017EAC) -------------------------------------------------------- int __fastcall sub_17EAC(int a1) { printf( "Thread \"%s\": tid=%p, pid=%d, ck=%p, ck_cnt=%lu, pre_ck=%p, pre_ck_cnt=%lu\n", (const char *)(a1 + 4), *(const void **)(a1 + 44), *(_DWORD *)(a1 + 40), *(const void **)(a1 + 48), *(_DWORD *)(a1 + 52), *(const void **)(a1 + 56), *(_DWORD *)(a1 + 60)); return 0; } //----- (00017EF8) -------------------------------------------------------- void __fastcall __noreturn start_routine(int *a1, int a2, int a3) { int v4; // r6 int v5; // r0 v4 = pthread_self(); pthread_detach(v4); prctl(15, a1 + 1, 0, 0, 0, a2, a3); v5 = syscall(224); a1[11] = v4; a1[10] = v5; pthread_setcanceltype(1, 0); pthread_setcancelstate(0, 0); pthread_mutex_lock(&mutex); sub_179D4((int)dword_2DA10, a1 + 16); pthread_mutex_unlock(&mutex); pthread_setspecific(dword_2DA1C, a1); ((void (__fastcall *)(int))*a1)(a1[9]); pthread_mutex_lock(&mutex); sub_17B04(a1 + 16); pthread_mutex_unlock(&mutex); sub_17D98(a1); pthread_exit(0); } // 2DA10: using guessed type _DWORD dword_2DA10[3]; // 2DA1C: using guessed type int dword_2DA1C; //----- (00017FB8) -------------------------------------------------------- _DWORD *__fastcall sub_17FB8(int a1, pthread_mutexattr_t a2, int a3) { _DWORD *result; // r0 pthread_mutexattr_t attr; // [sp+4h] [bp-8h] BYREF int v5; // [sp+8h] [bp-4h] attr = a2; v5 = a3; if ( !dword_2DA20 ) { pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, 1); pthread_mutex_init(&mutex, &attr); pthread_mutexattr_destroy(&attr); pthread_key_create((pthread_key_t *)&dword_2DA1C, 0); result = sub_177E4(dword_2DA10); dword_2DA20 = 1; } return result; } // 118E8: using guessed type int __fastcall pthread_mutexattr_settype(_DWORD, _DWORD); // 2DA10: using guessed type _DWORD dword_2DA10[3]; // 2DA1C: using guessed type int dword_2DA1C; // 2DA20: using guessed type int dword_2DA20; //----- (00018018) -------------------------------------------------------- int __fastcall sub_18018(int a1, int a2, int a3, int a4) { int v5; // r4 int *v6; // r3 _BYTE v8[8]; // [sp+4h] [bp-10h] BYREF int *v9; // [sp+Ch] [bp-8h] int vars10; // [sp+24h] [bp+10h] _DWORD _28[2]; // [sp+28h] [bp+14h] BYREF vars10 = a2; _28[0] = a3; _28[1] = a4; v5 = a2; sigemptyset((sigset_t *)v8); v9 = _28; while ( v5 > 0 ) { v6 = v9; --v5; ++v9; sigaddset((sigset_t *)v8, *v6); } return pthread_sigmask(a1, (const __sigset_t *)v8, 0); } //----- (00018088) -------------------------------------------------------- int __fastcall sub_18088(pthread_t *a1, const char *a2, int a3, int a4) { bool v4; // zf void *v9; // r0 void *v10; // r4 pthread_attr_t attr; // [sp+4h] [bp-28h] BYREF v4 = a1 == 0; if ( a1 ) v4 = a3 == 0; if ( v4 || !a2 ) { printf("[THREAD_ERR]%s %d: inputs error.\r\n", 116724, 175); return -1; } if ( pthread_attr_init(&attr) ) { printf("[THREAD_ERR]%s %d: pthread_attr_init error.\r\n", 116724, 181); return -1; } pthread_attr_setstacksize(&attr, 0x10000u); v9 = sub_17D44(76); v10 = v9; if ( !v9 ) { pthread_attr_destroy(&attr); printf("[THREAD_ERR]%s %d: malloc failed.\r\n", 116724, 190); return -1; } memset(v9, 0, 0x4Cu); *(_DWORD *)v10 = a3; *((_DWORD *)v10 + 9) = a4; strncpy((char *)v10 + 4, a2, 0x1Fu); if ( pthread_create(a1, &attr, (void *(*)(void *))start_routine, v10) ) { pthread_attr_destroy(&attr); sub_17D98(v10); printf("[THREAD_ERR]%s %d: create thread failed.\r\n", 116724, 203); return -1; } pthread_attr_destroy(&attr); return 0; } //----- (000181B4) -------------------------------------------------------- _DWORD *__fastcall sub_181B4(int a1) { _DWORD *result; // r0 result = pthread_getspecific(dword_2DA1C); if ( result ) { result[12] = a1; ++result[13]; } return result; } // 2DA1C: using guessed type int dword_2DA1C; //----- (000181E4) -------------------------------------------------------- int __fastcall sub_181E4(int result) { void (__fastcall *v1)(int *); // r4 int *i; // r0 int *v3; // r6 int v4; // r5 v1 = (void (__fastcall *)(int *))result; if ( result ) { pthread_mutex_lock(&mutex); for ( i = (int *)sub_1782C(dword_2DA10); i; i = (int *)v4 ) { v3 = i - 16; v4 = sub_178CC(i); v1(v3); } return pthread_mutex_unlock(&mutex); } return result; } // 2DA10: using guessed type _DWORD dword_2DA10[3]; //----- (00018238) -------------------------------------------------------- int __fastcall sub_18238(void *a1) { void *v3; // r1 if ( !a1 ) return -1; memset(a1, 0, 0x4Cu); v3 = pthread_getspecific(dword_2DA1C); if ( !v3 ) return -1; memcpy(a1, v3, 0x4Cu); return 0; } // 2DA1C: using guessed type int dword_2DA1C; //----- (00018288) -------------------------------------------------------- int __fastcall sub_18288(int a1, _DWORD *a2) { int *v3; // r0 int *v4; // r5 void *v5; // r0 int v6; // r4 if ( !a2 ) return -1; memset(a2, 0, 0x4Cu); pthread_mutex_lock(&mutex); v3 = (int *)sub_1782C(dword_2DA10); while ( 1 ) { v4 = v3; if ( !v3 ) break; v3 = (int *)sub_178CC(v3); if ( a2[11] == *(v4 - 5) ) { v5 = a2; v6 = 0; memcpy(v5, v4 - 16, 0x4Cu); goto LABEL_6; } } v6 = -1; LABEL_6: pthread_mutex_unlock(&mutex); return v6; } // 2DA10: using guessed type _DWORD dword_2DA10[3]; //----- (00018318) -------------------------------------------------------- int sub_18318() { return sub_181E4((int)sub_17EAC); } //----- (00018324) -------------------------------------------------------- int __fastcall sub_18324(unsigned __int8 *a1, unsigned __int8 *a2) { unsigned __int8 *v2; // r12 int v3; // t1 int v4; // t1 int v5; // r2 int v6; // r3 int result; // r0 v2 = a1; if ( a1 ) { if ( a2 ) { while ( 1 ) { v3 = *v2++; result = v3; v4 = *a2++; v5 = *(__int16 *)(_ctype_tolower + 2 * result); v6 = *(__int16 *)(_ctype_tolower + 2 * v4); if ( v5 != v6 ) break; if ( !result ) return result; } return v5 - v6; } else { return 1; } } else { result = (int)a2; if ( a2 ) return 1; } return result; } // 2D37C: using guessed type int _ctype_tolower; //----- (0001838C) -------------------------------------------------------- int __fastcall sub_1838C(unsigned __int8 *a1) { int v1; // r3 int v2; // r3 int v3; // r2 int v4; // r3 int v5; // r2 int v6; // r2 int v7; // r3 int v8; // r2 int v9; // r2 int v10; // r3 int v11; // r3 int v12; // r2 int v13; // r0 v1 = *a1; if ( (unsigned __int8)(v1 - 48) > 9u ) { if ( (unsigned int)(v1 - 65) > 5 ) { if ( (unsigned int)(v1 - 97) > 5 ) return 0; v2 = v1 - 87; } else { v2 = v1 - 55; } } else { v2 = v1 - 48; } v3 = a1[1]; v4 = 16 * v2; if ( (unsigned __int8)(v3 - 48) > 9u ) { if ( (unsigned int)(v3 - 65) > 5 ) { if ( (unsigned int)(v3 - 97) > 5 ) return 0; v6 = v3 - 87; } else { v6 = v3 - 55; } v5 = v6 + v4; } else { v5 = v3 - 48 + v4; } v7 = a1[2]; v8 = 16 * v5; if ( (unsigned __int8)(v7 - 48) > 9u ) { if ( (unsigned int)(v7 - 65) <= 5 ) { v10 = v7 - 55; LABEL_20: v9 = v10 + v8; goto LABEL_21; } if ( (unsigned int)(v7 - 97) <= 5 ) { v10 = v7 - 87; goto LABEL_20; } return 0; } v9 = v7 - 48 + v8; LABEL_21: v11 = a1[3]; v12 = 16 * v9; v13 = v11 - 48; if ( (unsigned __int8)(v11 - 48) <= 9u ) return v13 + v12; if ( (unsigned int)(v11 - 65) <= 5 ) { v13 = v11 - 55; return v13 + v12; } if ( (unsigned int)(v11 - 97) <= 5 ) { v13 = v11 - 87; return v13 + v12; } return 0; } //----- (00018498) -------------------------------------------------------- unsigned __int8 *__fastcall sub_18498(int a1, _BYTE *a2) { unsigned __int8 *v3; // r5 int v4; // r0 _BYTE *v5; // r3 int v6; // r2 bool v7; // zf _BYTE *v8; // r0 _BYTE *v9; // r8 bool *v10; // r6 int v11; // r3 bool v12; // zf bool v13; // r2 unsigned __int8 *v14; // r1 unsigned int v15; // r3 int v17; // r3 int v18; // r0 unsigned int v19; // r7 bool v20; // cc int v21; // r0 int v22; // r2 bool *v23; // r3 int v24; // r0 int v25; // r0 int v26; // r0 if ( *a2 != 34 ) { v3 = 0; dword_2DA24 = (int)a2; return v3; } v3 = a2 + 1; v4 = 0; v5 = a2 + 1; while ( 1 ) { v6 = (unsigned __int8)*v5; v7 = v6 == 0; if ( *v5 ) v7 = v6 == 34; if ( v7 ) break; if ( !++v4 ) break; if ( v6 == 92 ) v5 += 2; else ++v5; } v8 = off_2D374(v4 + 1); v9 = v8; if ( !v8 ) return 0; v10 = v8; while ( 1 ) { v11 = *v3; v12 = v11 == 0; if ( *v3 ) v12 = v11 == 34; v13 = !v12; if ( v12 ) break; v14 = v3 + 1; if ( v11 == 92 ) { v15 = v3[1]; if ( v15 == 110 ) { LOBYTE(v15) = 10; LABEL_29: *v10++ = v15; goto LABEL_30; } if ( v15 <= 0x6E ) { if ( v15 == 98 ) { LOBYTE(v15) = 8; } else if ( v15 == 102 ) { LOBYTE(v15) = 12; } goto LABEL_29; } if ( v15 == 116 ) { *v10++ = 9; goto LABEL_30; } if ( v15 != 117 ) { if ( v15 == 114 ) LOBYTE(v15) = 13; goto LABEL_29; } v18 = sub_1838C(v3 + 2); v14 = v3 + 5; v19 = v18; v20 = v18 != 0; if ( v18 ) v20 = (unsigned int)(v18 - 56320) > 0x3FF; if ( v20 ) { if ( (unsigned int)(v18 - 55296) > 0x3FF ) goto LABEL_50; if ( v3[6] == 92 && v3[7] == 117 ) { v21 = sub_1838C(v3 + 8); v14 = v3 + 11; if ( (unsigned int)(v21 - 56320) <= 0x3FF ) { v19 = ((v19 << 10) & 0xFFFFF | v21 & 0x3FF) + 0x10000; LABEL_50: if ( v19 > 0x7F ) { if ( v19 > 0x7FF ) { if ( v19 > 0xFFFF ) v22 = 4; else v22 = 3; } else { v22 = 2; } } else { v22 = 1; } v23 = &v10[v22]; if ( v22 != 3 ) { if ( v22 != 4 ) { if ( v22 != 2 ) { LABEL_56: v10 = &v23[v22 - 1]; *(v23 - 1) = v19 | *(_BYTE *)(v22 + 116977); goto LABEL_30; } LABEL_65: v26 = v19 & 0x3F; v19 >>= 6; *--v23 = ~((unsigned int)~(v26 << 25) >> 25); goto LABEL_56; } v24 = v19 & 0x3F; v19 >>= 6; *(v23 - 1) = ~((unsigned int)~(v24 << 25) >> 25); v23 = v10 + 3; } v25 = v19 & 0x3F; v19 >>= 6; *--v23 = ~((unsigned int)~(v25 << 25) >> 25); goto LABEL_65; } } } LABEL_30: v3 = v14 + 1; } else { *v10++ = v11; ++v3; } } *v10 = v13; v17 = *v3; *(_DWORD *)(a1 + 16) = v9; if ( v17 == 34 ) ++v3; *(_DWORD *)(a1 + 12) = 4; return v3; } // 2D374: using guessed type void *(*off_2D374)(size_t size); // 2DA24: using guessed type int dword_2DA24; //----- (000186F8) -------------------------------------------------------- unsigned __int8 *__fastcall sub_186F8(unsigned __int8 *a1) { unsigned __int8 *result; // r0 unsigned int v3; // r2 unsigned int v4; // t1 do { result = a1; if ( !a1 ) break; v4 = *a1++; v3 = v4; if ( !v4 ) break; } while ( v3 <= 0x20 ); return result; } //----- (0001871C) -------------------------------------------------------- void *sub_1871C() { void *v0; // r0 void *v1; // r4 v0 = off_2D374(0x28u); v1 = v0; if ( v0 ) memset(v0, 0, 0x28u); return v1; } // 2D374: using guessed type void *(*off_2D374)(size_t size); //----- (00018750) -------------------------------------------------------- _DWORD *__fastcall sub_18750(_DWORD *result) { if ( result ) { if ( *result ) return (_DWORD *)(strlen((const char *)(*result + result[2])) + result[2]); else return 0; } return result; } //----- (00018784) -------------------------------------------------------- void *__fastcall sub_18784(const char *a1) { size_t v2; // r5 void *v3; // r0 void *v4; // r4 v2 = strlen(a1) + 1; v3 = off_2D374(v2); v4 = v3; if ( v3 ) memcpy(v3, a1, v2); return v4; } // 2D374: using guessed type void *(*off_2D374)(size_t size); //----- (000187C4) -------------------------------------------------------- _DWORD *__fastcall sub_187C4(int *a1) { _DWORD *result; // r0 int *v3; // r2 _DWORD *v4; // r3 int v5; // t1 int v6; // r2 result = sub_1871C(); if ( result ) { v3 = a1 + 10; v4 = result; do { v5 = *a1++; *v4++ = v5; } while ( a1 != v3 ); v6 = result[3]; result[8] = 0; result[1] = 0; result[3] = v6 | 0x100; *result = 0; } return result; } //----- (00018810) -------------------------------------------------------- char *__fastcall sub_18810(char **a1, int a2) { char *result; // r0 char *v4; // r5 char *v5; // r1 int v6; // r7 int v7; // r7 size_t v8; // r7 char *v9; // r0 if ( !a1 ) return 0; result = *a1; if ( !*a1 ) return result; v4 = a1[2]; v5 = &v4[a2]; if ( (int)v5 <= (int)a1[1] ) return &result[(_DWORD)v4]; v6 = (unsigned int)(v5 - 1) | ((int)(v5 - 1) >> 1) | ((int)((unsigned int)(v5 - 1) | ((int)(v5 - 1) >> 1)) >> 2); v7 = v6 | (v6 >> 4) | ((v6 | (v6 >> 4)) >> 8); v8 = (v7 | (v7 >> 16)) + 1; v9 = (char *)off_2D374(v8); v4 = v9; if ( v9 ) { memcpy(v9, *a1, (size_t)a1[1]); off_2D378(*a1); *a1 = v4; a1[1] = (char *)v8; result = a1[2]; return &result[(_DWORD)v4]; } off_2D378(*a1); a1[1] = 0; *a1 = 0; return 0; } // 2D374: using guessed type void *(*off_2D374)(size_t size); // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (000188C0) -------------------------------------------------------- char *__fastcall sub_188C0(int *a1, char **a2) { int v2; // r6 int v4; // r5 char *v6; // r0 char *v7; // r4 double v9; // r0 char *v10; // r0 double v11; // r0 double v12; // r0 char *v13; // r0 double v14; // r0 v2 = a1[7]; v4 = a1[6]; if ( *((double *)a1 + 3) == 0.0 ) { if ( a2 ) v6 = sub_18810(a2, 2); else v6 = (char *)off_2D374(2u); v7 = v6; if ( v6 ) strcpy(v6, "0"); } else { v9 = (double)a1[5] - COERCE_DOUBLE(__PAIR64__(v2, v4)); HIDWORD(v9) &= ~0x80000000; if ( v9 > 2.22044605e-16 || COERCE_DOUBLE(__PAIR64__(v2, v4)) > 2147483650.0 || COERCE_DOUBLE(__PAIR64__(v2, v4)) < -2147483650.0 ) { if ( a2 ) v10 = sub_18810(a2, 64); else v10 = (char *)off_2D374(0x40u); v7 = v10; if ( v10 ) { v11 = floor(COERCE_DOUBLE(__PAIR64__(v2, v4))) - COERCE_DOUBLE(__PAIR64__(v2, v4)); HIDWORD(v11) &= ~0x80000000; if ( v11 > 2.22044605e-16 || (HIDWORD(v14) = v2 & 0x7FFFFFFF, LODWORD(v14) = v4, v14 >= 1.0e60) ) { LODWORD(v12) = v4; HIDWORD(v12) = v2 & 0x7FFFFFFF; if ( v12 < 0.000001 || COERCE_DOUBLE(__PAIR64__(v2 & 0x7FFFFFFF, v4)) > 1000000000.0 ) sprintf(v7, "%e", v4, v2); else sprintf(v7, "%f", v4, v2); } else { sprintf(v7, "%.0f", v4, v2); } } } else { if ( a2 ) v13 = sub_18810(a2, 21); else v13 = (char *)off_2D374(0x15u); v7 = v13; if ( v13 ) sprintf(v13, "%d", a1[5]); } } return v7; } // 2D374: using guessed type void *(*off_2D374)(size_t size); //----- (00018B08) -------------------------------------------------------- char *__fastcall sub_18B08(const char *a1, char **a2) { const char *v2; // r7 const char *v4; // r6 const char *v5; // r2 int i; // r3 bool v7; // cc _BOOL4 v8; // r4 const char *v9; // r8 unsigned int v10; // r4 unsigned int v11; // t1 int v12; // r8 char *v13; // r0 char *v14; // r5 char *v15; // r4 unsigned int v16; // r3 char *v17; // r4 unsigned int v19; // r8 unsigned int v20; // r10 unsigned int v21; // t1 char *v22; // r0 unsigned int v23; // t1 bool v24; // cc unsigned int v25; // r2 char v26; // r3 char *v27; // r0 v2 = a1; if ( !a1 ) { if ( a2 ) v27 = sub_18810(a2, 3); else v27 = (char *)off_2D374(3u); v14 = v27; if ( v27 ) strcpy(v27, "\"\""); return v14; } v4 = a1; v5 = a1; for ( i = 0; ; i |= v8 ) { v9 = v5; v11 = *(unsigned __int8 *)v5++; v10 = v11; if ( !v11 ) break; v7 = v10 > 0x22; if ( v10 != 34 ) v7 = v10 - 1 > 0x1E; v8 = !v7 || v10 == 92; } if ( !i ) { v12 = v9 - a1; if ( a2 ) v13 = sub_18810(a2, v12 + 3); else v13 = (char *)off_2D374(v12 + 3); v14 = v13; if ( v13 ) { *v13 = 34; v15 = v13 + 1; strcpy(v13 + 1, v2); LOBYTE(v16) = 0; v15[v12] = 34; v17 = &v15[v12]; goto LABEL_16; } return v14; } while ( 1 ) { v21 = *(unsigned __int8 *)v2++; v20 = v21; if ( !v21 ) break; v19 = v10 + 1; if ( v10 == -1 ) { v10 = 0; break; } if ( strchr(asc_1C908, v20) ) { v19 = v10 + 2; } else if ( v20 <= 0x1F ) { v19 = v10 + 6; } v10 = v19; } if ( a2 ) v22 = sub_18810(a2, v10 + 3); else v22 = (char *)off_2D374(v10 + 3); v14 = v22; if ( !v22 ) return v14; *v22 = 34; v17 = v22 + 1; while ( 1 ) { v23 = *(unsigned __int8 *)v4++; v16 = v23; if ( !v23 ) break; v24 = v16 > 0x22; if ( v16 != 34 ) v24 = v16 > 0x1F; if ( !v24 || v16 == 92 ) { *v17 = 92; v25 = *((unsigned __int8 *)v4 - 1); if ( v25 == 12 ) { v17[1] = 102; LABEL_49: v17 += 2; } else { if ( v25 <= 0xC ) { switch ( v25 ) { case 9u: v26 = 116; break; case 0xAu: v26 = 110; break; case 8u: v26 = 98; break; default: goto LABEL_43; } goto LABEL_48; } if ( v25 == 34 || v25 == 92 ) { v17[1] = v25; goto LABEL_49; } if ( v25 == 13 ) { v26 = 114; LABEL_48: v17[1] = v26; goto LABEL_49; } LABEL_43: sprintf(v17 + 1, "u%04x", v25); v17 += 6; } } else { *v17++ = v16; } } *v17 = 34; LABEL_16: v17[1] = v16; return v14; } // 2D374: using guessed type void *(*off_2D374)(size_t size); //----- (00018D60) -------------------------------------------------------- char *__fastcall sub_18D60(int *a1, int a2, int a3, char **a4) { int v4; // r12 char *result; // r0 char *v6; // r4 const char *v7; // r0 char **v8; // r1 char *v9; // r0 const char *v10; // r1 char **v11; // r1 const char *v12; // r0 if ( !a1 ) return 0; v4 = a1[3]; if ( a4 ) { switch ( (char)v4 ) { case 0: v9 = sub_18810(a4, 6); v6 = v9; if ( !v9 ) return v6; v10 = "false"; break; case 1: v9 = sub_18810(a4, 5); v6 = v9; if ( !v9 ) return v6; v10 = "true"; break; case 2: v9 = sub_18810(a4, 5); v6 = v9; if ( !v9 ) return v6; v10 = "null"; break; case 3: v11 = a4; goto LABEL_22; case 4: v7 = (const char *)a1[4]; v8 = a4; goto LABEL_11; case 5: goto LABEL_9; case 6: goto LABEL_5; default: return 0; } strcpy(v9, v10); return v6; } switch ( (char)v4 ) { case 0: v12 = "false"; goto LABEL_27; case 1: v12 = "true"; goto LABEL_27; case 2: v12 = "null"; LABEL_27: result = (char *)sub_18784(v12); break; case 3: v11 = 0; LABEL_22: result = sub_188C0(a1, v11); break; case 4: v7 = (const char *)a1[4]; v8 = 0; LABEL_11: result = sub_18B08(v7, v8); break; case 5: a4 = 0; LABEL_9: result = sub_194FC((int)a1, a2, a3, (int)a4); break; case 6: a4 = 0; LABEL_5: result = sub_18EAC((int)a1, a2, a3, (int)a4); break; default: return 0; } return result; } // 18D84: control flows out of bounds to 18D88 // 18E48: control flows out of bounds to 18E4C //----- (00018EAC) -------------------------------------------------------- char *__fastcall sub_18EAC(int a1, int a2, int a3, int a4) { int v5; // r5 int v7; // r7 _DWORD *v8; // r8 int v9; // r6 int v10; // r1 char *v11; // r0 char *v12; // r2 int v13; // r5 int jj; // r3 int v16; // r10 int v17; // r6 char *v18; // r0 _BYTE *v19; // r0 int v20; // r8 int i; // r6 char *v22; // r0 int j; // r3 _DWORD *v24; // r0 int v25; // r11 char v26; // r3 int v27; // r11 size_t v28; // r0 int v29; // r1 int k; // r3 size_t v31; // r10 void *v32; // r9 int v33; // r3 int v34; // r7 char *v35; // r8 int v36; // r11 int v37; // r6 char *v38; // r0 const char *v39; // r5 char *v40; // r0 bool v41; // zf int v42; // r5 int v43; // r6 int v44; // r4 int m; // r5 int v46; // r0 int v47; // r0 _BYTE *v48; // r0 int v49; // r10 int v50; // r3 _BYTE *v51; // r11 const char *v52; // r0 size_t v53; // r7 char *v54; // r3 char *v55; // r7 const char *v56; // r0 size_t v57; // r0 char v58; // r3 bool v59; // zf int n; // r3 int ii; // r3 void *src; // [sp+4h] [bp-20h] const char *srca; // [sp+4h] [bp-20h] int v64; // [sp+8h] [bp-1Ch] const char **v65; // [sp+8h] [bp-1Ch] void *s; // [sp+Ch] [bp-18h] int v67; // [sp+10h] [bp-14h] const char **v68; // [sp+10h] [bp-14h] int v69; // [sp+14h] [bp-10h] int v70; // [sp+1Ch] [bp-8h] v5 = a2; v7 = a4; v8 = *(_DWORD **)(a1 + 8); v9 = 0; while ( v8 ) { v8 = (_DWORD *)*v8; ++v9; } if ( v9 ) { if ( a4 ) { v16 = *(_DWORD *)(a4 + 8); if ( a3 ) v17 = 2; else v17 = 1; v18 = sub_18810((char **)a4, v17 + 1); if ( v18 ) { *v18 = 123; if ( a3 ) { v18[1] = 10; v19 = v18 + 2; } else { v19 = v18 + 1; } v20 = v5 + 1; *v19 = 0; *(_DWORD *)(v7 + 8) += v17; for ( i = *(_DWORD *)(a1 + 8); i; i = *(_DWORD *)i ) { if ( a3 ) { v22 = sub_18810((char **)v7, v5 + 1); if ( !v22 ) return v22; for ( j = 0; j < v20; ++j ) v22[j] = 9; *(_DWORD *)(v7 + 8) += v20; } sub_18B08(*(const char **)(i + 32), (char **)v7); v24 = sub_18750((_DWORD *)v7); if ( a3 ) v25 = 2; else v25 = 1; *(_DWORD *)(v7 + 8) = v24; v22 = sub_18810((char **)v7, v25); if ( !v22 ) return v22; *v22 = 58; if ( a3 ) v26 = 9; else v26 = v22[1]; v22[1] = v26; *(_DWORD *)(v7 + 8) += v25; sub_18D60((int *)i, v5 + 1, a3, (char **)v7); *(_DWORD *)(v7 + 8) = sub_18750((_DWORD *)v7); v27 = *(_DWORD *)i; if ( *(_DWORD *)i ) v27 = 1; if ( a3 ) ++v27; v22 = sub_18810((char **)v7, v27 + 1); if ( !v22 ) return v22; if ( *(_DWORD *)i ) *v22++ = 44; if ( a3 ) *v22++ = 10; *v22 = 0; *(_DWORD *)(v7 + 8) += v27; } if ( a3 ) v29 = v5 + 2; else v29 = 2; v22 = sub_18810((char **)v7, v29); if ( !v22 ) return v22; if ( a3 ) { for ( k = 0; k < v5; ++k ) v22[k] = 9; v16 = v5 & ~(v5 >> 31); v22 += v16; } *v22 = 125; v22[1] = 0; return (char *)(*(_DWORD *)v7 + v16); } else { return 0; } } else { v31 = (size_t)&off_2D374; v32 = off_2D374(4 * v9); if ( v32 ) { s = off_2D374(4 * v9); if ( s ) { memset(v32, 0, 4 * v9); memset(s, 0, 4 * v9); if ( a3 ) v31 = v5 + 8; v33 = v5 + 1; if ( !a3 ) v31 = 7; v69 = v5 + 1; if ( a3 ) v33 = v5 + 3; v34 = *(_DWORD *)(a1 + 8); if ( !a3 ) v33 = 0; v35 = 0; v36 = v9; v64 = 0; v67 = v33 + 2; v37 = v5; while ( v34 ) { v38 = sub_18B08(*(const char **)(v34 + 32), 0); *(_DWORD *)&v35[(_DWORD)s] = v38; v39 = v38; v40 = sub_18D60((int *)v34, v69, a3, 0); v41 = v40 == 0; if ( v40 ) v41 = v39 == 0; *(_DWORD *)&v35[(_DWORD)v32] = v40; if ( v41 ) { v64 = 1; } else { src = (void *)strlen(v40); v31 += (size_t)src + v67 + strlen(v39); } v34 = *(_DWORD *)v34; v35 += 4; } v42 = v37; v43 = v36; if ( v64 || (v48 = off_2D374(v31)) == 0 ) { v44 = 0; for ( m = 0; m < v36; ++m ) { v46 = *(_DWORD *)((char *)s + v44); if ( v46 ) off_2D378(v46); v47 = *(_DWORD *)((char *)v32 + v44); if ( v47 ) off_2D378(v47); v44 += 4; } v7 = 0; off_2D378(s); off_2D378(v32); } else { if ( !a3 ) v35 = v48 + 1; *v48 = 123; if ( a3 ) { v35 = v48 + 2; v48[1] = 10; } v49 = 0; v65 = (const char **)v32; *v35 = 0; v50 = v36 - 1; v68 = (const char **)s; v51 = v48; v70 = v50; while ( v49 < v43 ) { if ( a3 ) { for ( n = 0; n < v69; ++n ) v35[n] = 9; v35 += v69 & ~(v69 >> 31); } v52 = *v68++; srca = v52; v53 = strlen(v52); memcpy(v35, srca, v53); v54 = &v35[v53]; v35[v53] = 58; if ( a3 ) { v55 = v54 + 2; v54[1] = 9; } else { v55 = v54 + 1; } strcpy(v55, *v65); v56 = *v65++; v57 = strlen(v56); v58 = v70; v59 = v49++ == v70; if ( !v59 ) v58 = 44; v35 = &v55[v57]; if ( !v59 ) { v55[v57] = v58; ++v35; } if ( a3 ) *v35++ = 10; *v35 = 0; off_2D378(*(v68 - 1)); off_2D378(*(v65 - 1)); } v7 = (int)v51; off_2D378(s); off_2D378(v32); if ( a3 ) { for ( ii = 0; ii < v42; ++ii ) v35[ii] = 9; if ( v42 >= 0 ) v35 += v42; } *v35 = 125; v35[1] = 0; } } else { off_2D378(v32); } } } } else { if ( a4 ) { if ( a3 ) v10 = a2 + 4; else v10 = 3; v11 = sub_18810((char **)a4, v10); } else { if ( a3 ) v28 = a2 + 4; else v28 = 3; v11 = (char *)off_2D374(v28); } v7 = (int)v11; if ( v11 ) { if ( !a3 ) v5 = (int)(v11 + 1); *v11 = 123; if ( a3 ) { v12 = v11 + 2; v11[1] = 10; v13 = v5 - 1; for ( jj = 0; jj < v13; ++jj ) v12[jj] = 9; if ( v13 < 0 ) v5 = (int)(v11 + 2); else v5 = (int)&v12[v13]; } *(_BYTE *)v5 = 125; *(_BYTE *)(v5 + 1) = 0; } } return (char *)v7; } // 2D374: using guessed type void *(*off_2D374)(size_t size); // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (000194FC) -------------------------------------------------------- char *__fastcall sub_194FC(int a1, int a2, int a3, int a4) { int v6; // r4 char *v7; // r8 int v8; // r5 char *v9; // r0 char *v11; // r0 int *v12; // r5 int v13; // r7 char *v14; // r0 _BYTE *v15; // r8 char *v16; // r0 const char **v17; // r0 const char **v18; // r11 int *v19; // r7 const char **v20; // r9 char **v21; // r10 size_t v22; // r8 char *v23; // r0 size_t v24; // r0 int v25; // r3 _BOOL4 v26; // r3 int i; // r4 int v28; // r0 int v29; // t1 char *v30; // r0 char *v31; // r10 _BYTE *v32; // r7 const char *v33; // t1 size_t v34; // r8 void *v35; // r0 int v37; // [sp+4h] [bp-10h] int v38; // [sp+8h] [bp-Ch] v6 = a4; v7 = *(char **)(a1 + 8); v8 = 0; while ( v7 ) { v7 = *(char **)v7; ++v8; } if ( v8 ) { if ( a4 ) { v38 = *(_DWORD *)(a4 + 8); v11 = sub_18810((char **)a4, 1); if ( v11 ) { *v11 = 91; ++*(_DWORD *)(v6 + 8); v12 = *(int **)(a1 + 8); if ( a3 ) v13 = 2; else v13 = 1; while ( v12 ) { sub_18D60(v12, a2 + 1, a3, (char **)v6); *(_DWORD *)(v6 + 8) = sub_18750((_DWORD *)v6); if ( *v12 ) { v14 = sub_18810((char **)v6, v13 + 1); v7 = v14; if ( !v14 ) return v7; *v14 = 44; if ( a3 ) { v14[1] = 32; v15 = v14 + 2; } else { v15 = v14 + 1; } *v15 = 0; *(_DWORD *)(v6 + 8) += v13; } v12 = (int *)*v12; } v16 = sub_18810((char **)v6, 2); if ( v16 ) { v16[1] = 0; *v16 = 93; return (char *)(*(_DWORD *)v6 + v38); } else { return 0; } } } else { v17 = (const char **)off_2D374(4 * v8); v18 = v17; if ( v17 ) { memset(v17, 0, 4 * v8); v19 = *(int **)(a1 + 8); v20 = v18; v21 = (char **)v18; v22 = 5; v37 = a2 + 1; while ( 1 ) { v26 = v6 == 0; if ( !v19 ) v26 = 0; if ( !v26 ) break; v23 = sub_18D60(v19, v37, a3, 0); *v21++ = v23; if ( v23 ) { v24 = strlen(v23); v6 = 0; if ( a3 ) v25 = 3; else v25 = 2; v22 += v25 + v24; } else { v6 = 1; } v19 = (int *)*v19; } if ( v6 || (v30 = (char *)off_2D374(v22)) == 0 ) { for ( i = 0; i < v8; ++i ) { v29 = (int)*v20++; v28 = v29; if ( v29 ) off_2D378(v28); } v7 = 0; off_2D378(v18); } else { v31 = v30; *v30 = 91; v32 = v30 + 1; v30[1] = 0; while ( v6 < v8 ) { v33 = *v20++; v34 = strlen(v33); v35 = v32; v32 += v34; memcpy(v35, v33, v34); if ( v6 != v8 - 1 ) { *v32 = 44; if ( a3 ) { v32[1] = 32; v32 += 2; } else { ++v32; } *v32 = 0; } ++v6; off_2D378(*(v20 - 1)); } v7 = v31; off_2D378(v18); *v32 = 93; v32[1] = 0; } } else { return 0; } } } else { if ( a4 ) v9 = sub_18810((char **)a4, 3); else v9 = (char *)off_2D374(3u); v7 = v9; if ( v9 ) strcpy(v9, "[]"); } return v7; } // 2D374: using guessed type void *(*off_2D374)(size_t size); // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (0001985C) -------------------------------------------------------- unsigned __int8 *__fastcall sub_1985C(int a1, const char *a2) { unsigned __int8 *v2; // r4 int v4; // r3 _DWORD *v6; // r6 unsigned __int8 *v7; // r0 unsigned __int8 *v8; // r0 unsigned __int8 *v9; // r0 int v10; // r3 int v11; // r5 unsigned __int8 *v12; // r0 unsigned __int8 *v13; // r0 int v14; // r3 _DWORD *v15; // r0 unsigned __int8 *v16; // r0 unsigned __int8 *v17; // r0 unsigned __int8 *v18; // r0 int v19; // r3 unsigned __int8 *v20; // r0 unsigned __int8 *v21; // r0 int v23; // r3 double v24; // r8 unsigned __int8 *v25; // r6 unsigned __int8 *v26; // r7 int v27; // t1 double v28; // r0 int v29; // t1 double v30; // r10 int v31; // r7 bool v32; // zf int i; // r7 int v34; // r6 int v35; // r3 unsigned __int8 *v36; // r3 int v37; // t1 int v38; // r2 double v39; // r0 unsigned int v40; // r3 unsigned __int8 *v41; // r6 int v42; // r0 _DWORD *v43; // r6 unsigned __int8 *v44; // r0 unsigned __int8 *v45; // r0 int v46; // r3 _DWORD *v47; // r0 unsigned __int8 *v48; // r0 unsigned __int8 *v49; // r0 double v50; // [sp+0h] [bp-Ch] v2 = (unsigned __int8 *)a2; if ( !a2 ) return v2; if ( !strncmp(a2, "null", 4u) ) { *(_DWORD *)(a1 + 12) = 2; LABEL_29: v2 += 4; return v2; } if ( !strncmp((const char *)v2, "false", 5u) ) { *(_DWORD *)(a1 + 12) = 0; v2 += 5; return v2; } if ( !strncmp((const char *)v2, "true", 4u) ) { *(_DWORD *)(a1 + 12) = 1; *(_DWORD *)(a1 + 20) = 1; goto LABEL_29; } v4 = *v2; if ( v4 != 34 ) { if ( (unsigned int)(v4 - 48) > 9 && v4 != 45 ) { if ( v4 == 91 ) { *(_DWORD *)(a1 + 12) = 5; v2 = sub_186F8(v2 + 1); if ( *v2 == 93 ) return ++v2; v43 = sub_1871C(); *(_DWORD *)(a1 + 8) = v43; if ( !v43 ) return 0; v44 = sub_186F8(v2); v45 = (unsigned __int8 *)sub_1985C(v43, v44); v2 = sub_186F8(v45); if ( v2 ) { while ( 1 ) { v46 = *v2; if ( v46 != 44 ) break; v47 = sub_1871C(); v11 = (int)v47; if ( !v47 ) return (unsigned __int8 *)v11; *v43 = v47; v47[1] = v43; v48 = sub_186F8(v2 + 1); v49 = (unsigned __int8 *)sub_1985C(v11, v48); v2 = sub_186F8(v49); if ( !v2 ) return v2; v43 = (_DWORD *)v11; } if ( v46 == 93 ) return ++v2; LABEL_77: dword_2DA24 = (int)v2; } } else { if ( v4 != 123 ) { dword_2DA24 = (int)v2; return 0; } *(_DWORD *)(a1 + 12) = 6; v2 = sub_186F8(v2 + 1); if ( *v2 == 125 ) return ++v2; v6 = sub_1871C(); *(_DWORD *)(a1 + 8) = v6; if ( v6 ) { v7 = sub_186F8(v2); v8 = sub_18498((int)v6, v7); v9 = sub_186F8(v8); v2 = v9; if ( !v9 ) return v2; v10 = v6[4]; v11 = 0; v6[4] = 0; v6[8] = v10; if ( *v9 != 58 ) { dword_2DA24 = (int)v9; return (unsigned __int8 *)v11; } v12 = sub_186F8(v9 + 1); v13 = (unsigned __int8 *)sub_1985C(v6, v12); v2 = sub_186F8(v13); if ( !v2 ) return v2; while ( 1 ) { v14 = *v2; if ( v14 != 44 ) break; v15 = sub_1871C(); v11 = (int)v15; if ( !v15 ) return (unsigned __int8 *)v11; *v6 = v15; v15[1] = v6; v16 = sub_186F8(v2 + 1); v17 = sub_18498(v11, v16); v18 = sub_186F8(v17); v2 = v18; if ( !v18 ) return v2; v19 = *(_DWORD *)(v11 + 16); *(_DWORD *)(v11 + 16) = 0; *(_DWORD *)(v11 + 32) = v19; if ( *v18 != 58 ) goto LABEL_77; v20 = sub_186F8(v18 + 1); v21 = (unsigned __int8 *)sub_1985C(v11, v20); v2 = sub_186F8(v21); if ( !v2 ) return v2; v6 = (_DWORD *)v11; } if ( v14 == 125 ) return ++v2; goto LABEL_77; } } return 0; } if ( v4 == 45 ) { ++v2; v23 = -1074790400; } else { v23 = 1072693248; } LODWORD(v50) = 0; HIDWORD(v50) = v23; if ( *v2 == 48 ) ++v2; if ( (unsigned int)*v2 - 49 <= 8 ) { v25 = v2; v26 = v2; v24 = 0.0; do { v27 = *v25++; v2 = v25; v28 = v24 * 10.0 + (double)(v27 - 48); v29 = *++v26; v24 = v28; } while ( (unsigned int)(v29 - 48) <= 9 ); } else { v24 = 0.0; } v30 = 0.0; if ( *v2 == 46 ) { v40 = v2[1]; if ( v40 > 0x2F && v40 <= 0x39 ) { while ( 1 ) { v41 = v2 + 1; v42 = v2[1]; v2 += 2; v24 = v24 * 10.0 + (double)(v42 - 48); v30 = v30 - 1.0; if ( (unsigned int)v41[1] - 48 > 9 ) break; v2 = v41; } } } v31 = *v2; v32 = v31 == 101; if ( v31 != 101 ) v32 = v31 == 69; i = v32; if ( !v32 ) { v34 = 1; LABEL_56: v39 = v50 * v24 * pow(10.0, v30 + (double)(v34 * i)); *(double *)(a1 + 24) = v39; *(_DWORD *)(a1 + 12) = 3; *(_DWORD *)(a1 + 20) = (int)v39; return v2; } v35 = v2[1]; if ( v35 == 43 ) { v36 = v2 + 2; } else { if ( v35 == 45 ) { v36 = v2 + 2; v34 = -1; goto LABEL_53; } v36 = v2 + 1; } v34 = 1; LABEL_53: for ( i = 0; ; i = v38 + 10 * i ) { v2 = v36; v37 = *v36++; v38 = v37 - 48; if ( (unsigned __int8)(v37 - 48) > 9u ) break; } goto LABEL_56; } return sub_18498(a1, v2); } // 2DA24: using guessed type int dword_2DA24; //----- (00019D88) -------------------------------------------------------- int sub_19D88() { return dword_2DA24; } // 2DA24: using guessed type int dword_2DA24; //----- (00019D98) -------------------------------------------------------- int __fastcall sub_19D98(int result) { void *(*v1)(size_t); // r2 void (*v2)(void *); // r2 if ( result ) { v1 = *(void *(**)(size_t))result; if ( !*(_DWORD *)result ) v1 = malloc; off_2D374 = v1; v2 = *(void (**)(void *))(result + 4); if ( !v2 ) v2 = free; } else { off_2D374 = malloc; v2 = free; } off_2D378 = (int (__fastcall *)(_DWORD))v2; return result; } // 2D374: using guessed type void *(*off_2D374)(size_t size); // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (00019DEC) -------------------------------------------------------- int __fastcall sub_19DEC(int result) { _DWORD *i; // r4 _DWORD *v2; // r6 int v3; // r0 int v4; // r0 for ( i = (_DWORD *)result; i; i = v2 ) { v2 = (_DWORD *)*i; if ( (i[3] & 0x100) == 0 && i[2] ) sub_19DEC(); if ( (i[3] & 0x100) == 0 ) { v3 = i[4]; if ( v3 ) off_2D378(v3); } if ( (i[3] & 0x200) == 0 ) { v4 = i[8]; if ( v4 ) off_2D378(v4); } result = off_2D378(i); } return result; } // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (00019E7C) -------------------------------------------------------- int __fastcall sub_19E7C(unsigned __int8 *a1, unsigned __int8 **a2, int a3) { void *v6; // r0 int v7; // r6 unsigned __int8 *v8; // r0 unsigned __int8 *v9; // r0 unsigned __int8 *v10; // r5 int v12; // r0 int v13; // r0 v6 = sub_1871C(); dword_2DA24 = 0; v7 = (int)v6; if ( v6 ) { v8 = sub_186F8(a1); v9 = sub_1985C(v7, (const char *)v8); v10 = v9; if ( v9 ) { if ( a3 && (v10 = sub_186F8(v9), *v10) ) { v12 = v7; v7 = 0; sub_19DEC(v12); dword_2DA24 = (int)v10; } else if ( a2 ) { *a2 = v10; } } else { v13 = v7; v7 = 0; sub_19DEC(v13); } } return v7; } // 2DA24: using guessed type int dword_2DA24; //----- (00019F14) -------------------------------------------------------- int __fastcall sub_19F14(unsigned __int8 *a1) { return sub_19E7C(a1, 0, 0); } //----- (00019F20) -------------------------------------------------------- char *__fastcall sub_19F20(int *a1) { return sub_18D60(a1, 0, 1, 0); } //----- (00019F30) -------------------------------------------------------- char *__fastcall sub_19F30(int *a1) { return sub_18D60(a1, 0, 0, 0); } //----- (00019F40) -------------------------------------------------------- char *__fastcall sub_19F40(int *a1, char *a2, int a3) { char *v7[3]; // [sp+4h] [bp-Ch] BYREF v7[2] = 0; v7[0] = (char *)off_2D374((size_t)a2); v7[1] = a2; return sub_18D60(a1, 0, a3, v7); } // 2D374: using guessed type void *(*off_2D374)(size_t size); //----- (00019FA8) -------------------------------------------------------- _DWORD *__fastcall sub_19FA8(int a1, int a2) { _DWORD *result; // r0 bool v3; // zf bool v4; // nf result = *(_DWORD **)(a1 + 8); while ( 1 ) { v3 = result == 0; v4 = (int)result < 0; if ( result ) { v3 = a2 == 0; v4 = a2 < 0; } if ( v4 || v3 ) break; result = (_DWORD *)*result; --a2; } return result; } //----- (00019FC8) -------------------------------------------------------- int **__fastcall sub_19FC8(int a1, unsigned __int8 *a2) { int **i; // r4 for ( i = *(int ***)(a1 + 8); i && sub_18324((unsigned __int8 *)i[8], a2); i = (int **)*i ) ; return i; } //----- (0001A000) -------------------------------------------------------- int __fastcall sub_1A000(int result, int a2) { _DWORD *v2; // r3 v2 = *(_DWORD **)(result + 8); if ( a2 ) { if ( v2 ) { while ( *v2 ) v2 = (_DWORD *)*v2; *v2 = a2; *(_DWORD *)(a2 + 4) = v2; } else { *(_DWORD *)(result + 8) = a2; } } return result; } //----- (0001A038) -------------------------------------------------------- int __fastcall sub_1A038(int result, const char *a2, int a3) { int v4; // r4 int v6; // r0 v4 = result; if ( a3 ) { v6 = *(_DWORD *)(a3 + 32); if ( v6 ) off_2D378(v6); *(_DWORD *)(a3 + 32) = sub_18784(a2); return sub_1A000(v4, a3); } return result; } // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (0001A084) -------------------------------------------------------- int __fastcall sub_1A084(int result, int a2, int a3) { int v4; // r4 int v6; // r0 int v7; // r3 v4 = result; if ( a3 ) { if ( (*(_DWORD *)(a3 + 12) & 0x200) == 0 ) { v6 = *(_DWORD *)(a3 + 32); if ( v6 ) off_2D378(v6); } v7 = *(_DWORD *)(a3 + 12); *(_DWORD *)(a3 + 32) = a2; *(_DWORD *)(a3 + 12) = v7 | 0x200; return sub_1A000(v4, a3); } return result; } // 2D378: using guessed type int (__fastcall *off_2D378)(_DWORD); //----- (0001A0E0) -------------------------------------------------------- int __fastcall sub_1A0E0(int a1, int *a2) { _DWORD *v3; // r1 v3 = sub_187C4(a2); return sub_1A000(a1, (int)v3); } //----- (0001A100) -------------------------------------------------------- int __fastcall sub_1A100(int a1, const char *a2, int *a3) { _DWORD *v5; // r0 v5 = sub_187C4(a3); return sub_1A038(a1, a2, (int)v5); } //----- (0001A128) -------------------------------------------------------- _DWORD *__fastcall sub_1A128(int a1, int a2) { _DWORD *result; // r0 bool v4; // cc _DWORD *v5; // r2 result = *(_DWORD **)(a1 + 8); while ( 1 ) { v4 = (int)result <= 0; if ( result ) v4 = a2 <= 0; if ( v4 ) break; result = (_DWORD *)*result; --a2; } if ( result ) { v5 = (_DWORD *)result[1]; if ( v5 ) *v5 = *result; if ( *result ) *(_DWORD *)(*result + 4) = result[1]; if ( result == *(_DWORD **)(a1 + 8) ) *(_DWORD *)(a1 + 8) = *result; *result = 0; result[1] = 0; } return result; } //----- (0001A190) -------------------------------------------------------- int __fastcall sub_1A190(int a1, int a2) { _DWORD *v2; // r0 v2 = sub_1A128(a1, a2); return sub_19DEC((int)v2); } //----- (0001A1A0) -------------------------------------------------------- _DWORD *__fastcall sub_1A1A0(int a1, unsigned __int8 *a2) { int **v4; // r4 int i; // r5 v4 = *(int ***)(a1 + 8); for ( i = 0; ; ++i ) { if ( !v4 ) return 0; if ( !sub_18324((unsigned __int8 *)v4[8], a2) ) break; v4 = (int **)*v4; } return sub_1A128(a1, i); } //----- (0001A1F4) -------------------------------------------------------- int __fastcall sub_1A1F4(int a1, unsigned __int8 *a2) { _DWORD *v2; // r0 v2 = sub_1A1A0(a1, a2); return sub_19DEC((int)v2); } //----- (0001A204) -------------------------------------------------------- int __fastcall sub_1A204(int result, int a2, _DWORD *a3) { _DWORD *v3; // r3 bool v4; // zf bool v5; // nf v3 = *(_DWORD **)(result + 8); while ( 1 ) { v4 = v3 == 0; v5 = (int)v3 < 0; if ( v3 ) { v4 = a2 == 0; v5 = a2 < 0; } if ( v5 || v4 ) break; v3 = (_DWORD *)*v3; --a2; } if ( !v3 ) return sub_1A000(result, (int)a3); *a3 = v3; a3[1] = v3[1]; v3[1] = a3; if ( v3 == *(_DWORD **)(result + 8) ) *(_DWORD *)(result + 8) = a3; else *(_DWORD *)a3[1] = a3; return result; } //----- (0001A258) -------------------------------------------------------- _DWORD *__fastcall sub_1A258(int a1, int a2, _DWORD *a3) { _DWORD *result; // r0 bool v5; // zf bool v6; // nf _DWORD *v7; // r1 result = *(_DWORD **)(a1 + 8); while ( 1 ) { v5 = result == 0; v6 = (int)result < 0; if ( result ) { v5 = a2 == 0; v6 = a2 < 0; } if ( v6 || v5 ) break; result = (_DWORD *)*result; --a2; } if ( result ) { v7 = (_DWORD *)*result; v5 = *result == 0; *a3 = *result; a3[1] = result[1]; if ( !v5 ) v7[1] = a3; if ( result == *(_DWORD **)(a1 + 8) ) *(_DWORD *)(a1 + 8) = a3; else *(_DWORD *)a3[1] = a3; result[1] = 0; *result = 0; return (_DWORD *)sub_19DEC((int)result); } return result; } //----- (0001A2BC) -------------------------------------------------------- _DWORD *__fastcall sub_1A2BC(_DWORD *result, unsigned __int8 *a2, _DWORD *a3) { int v3; // r4 int **v6; // r6 int v7; // r7 v3 = (int)result; v6 = (int **)result[2]; v7 = 0; while ( v6 ) { result = (_DWORD *)sub_18324((unsigned __int8 *)v6[8], a2); if ( !result ) { a3[8] = sub_18784((const char *)a2); return sub_1A258(v3, v7, a3); } v6 = (int **)*v6; ++v7; } return result; } //----- (0001A31C) -------------------------------------------------------- _DWORD *sub_1A31C() { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = 2; return result; } //----- (0001A334) -------------------------------------------------------- _DWORD *sub_1A334() { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = 1; return result; } //----- (0001A34C) -------------------------------------------------------- _DWORD *sub_1A34C() { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = 0; return result; } //----- (0001A364) -------------------------------------------------------- _DWORD *__fastcall sub_1A364(int a1) { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = a1 != 0; return result; } //----- (0001A388) -------------------------------------------------------- double *__fastcall sub_1A388(double a1) { double *result; // r0 result = (double *)sub_1871C(); if ( result ) { result[3] = a1; *((_DWORD *)result + 3) = 3; *((_DWORD *)result + 5) = (int)a1; } return result; } //----- (0001A3C4) -------------------------------------------------------- _DWORD *__fastcall sub_1A3C4(const char *a1) { _DWORD *v2; // r4 v2 = sub_1871C(); if ( v2 ) { v2[3] = 4; v2[4] = sub_18784(a1); } return v2; } //----- (0001A3F4) -------------------------------------------------------- _DWORD *sub_1A3F4() { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = 5; return result; } //----- (0001A40C) -------------------------------------------------------- _DWORD *sub_1A40C() { _DWORD *result; // r0 result = sub_1871C(); if ( result ) result[3] = 6; return result; } //----- (0001A424) -------------------------------------------------------- _DWORD *__fastcall sub_1A424(int *a1, int a2) { _DWORD *v4; // r5 int v5; // r4 _DWORD *v6; // r6 int v7; // t1 double *v8; // r0 bool v9; // zf bool v10; // cc v4 = 0; v5 = 0; v6 = sub_1A3F4(); while ( 1 ) { v10 = (int)v6 < 0; if ( v6 ) v10 = v5 < a2; if ( !v10 ) break; v7 = *a1++; v8 = sub_1A388((double)v7); v9 = v5++ == 0; if ( !v9 ) { *v4 = v8; *((_DWORD *)v8 + 1) = v4; } v4 = v8; if ( v9 ) v6[2] = v8; } return v6; } //----- (0001A47C) -------------------------------------------------------- _DWORD *__fastcall sub_1A47C(float *a1, int a2) { _DWORD *v4; // r5 int v5; // r4 _DWORD *v6; // r6 float v7; // t1 double *v8; // r0 bool v9; // zf bool v10; // cc v4 = 0; v5 = 0; v6 = sub_1A3F4(); while ( 1 ) { v10 = (int)v6 < 0; if ( v6 ) v10 = v5 < a2; if ( !v10 ) break; v7 = *a1++; v8 = sub_1A388(v7); v9 = v5++ == 0; if ( !v9 ) { *v4 = v8; *((_DWORD *)v8 + 1) = v4; } v4 = v8; if ( v9 ) v6[2] = v8; } return v6; } //----- (0001A4D4) -------------------------------------------------------- _DWORD *__fastcall sub_1A4D4(double *a1, int a2) { _DWORD *v4; // r5 int v5; // r4 _DWORD *v6; // r6 double v7; // t1 double *v8; // r0 bool v9; // zf bool v10; // cc v4 = 0; v5 = 0; v6 = sub_1A3F4(); while ( 1 ) { v10 = (int)v6 < 0; if ( v6 ) v10 = v5 < a2; if ( !v10 ) break; v7 = *a1++; v8 = sub_1A388(v7); v9 = v5++ == 0; if ( !v9 ) { *v4 = v8; *((_DWORD *)v8 + 1) = v4; } v4 = v8; if ( v9 ) v6[2] = v8; } return v6; } //----- (0001A528) -------------------------------------------------------- _DWORD *__fastcall sub_1A528(const char **a1, int a2) { _DWORD *v4; // r6 int v5; // r5 _DWORD *v6; // r7 const char *v7; // t1 _DWORD *v8; // r0 bool v9; // zf bool v10; // cc v4 = 0; v5 = 0; v6 = sub_1A3F4(); while ( 1 ) { v10 = (int)v6 < 0; if ( v6 ) v10 = v5 < a2; if ( !v10 ) break; v7 = *a1++; v8 = sub_1A3C4(v7); v9 = v5++ == 0; if ( !v9 ) { *v4 = v8; v8[1] = v4; } v4 = v8; if ( v9 ) v6[2] = v8; } return v6; } //----- (0001A57C) -------------------------------------------------------- _DWORD *__fastcall sub_1A57C(int a1, int a2) { _DWORD *v4; // r4 _DWORD *v5; // r0 const char *v6; // r0 _DWORD *v7; // r6 const char *v8; // r0 _DWORD *v9; // r6 int *v10; // r5 int v11; // r0 int v13; // r0 int v14; // r0 if ( !a1 ) return 0; v5 = sub_1871C(); v4 = v5; if ( v5 ) { v5[3] = *(_DWORD *)(a1 + 12) & 0xFFFFFEFF; v5[5] = *(_DWORD *)(a1 + 20); *((_QWORD *)v5 + 3) = *(_QWORD *)(a1 + 24); v6 = *(const char **)(a1 + 16); if ( v6 && (v7 = sub_18784(v6), (v4[4] = v7) == 0) || (v8 = *(const char **)(a1 + 32)) != 0 && (v7 = sub_18784(v8), (v4[8] = v7) == 0) ) { v14 = (int)v4; v4 = v7; sub_19DEC(v14); } else if ( a2 ) { v9 = *(_DWORD **)(a1 + 8); v10 = 0; while ( v9 ) { v11 = sub_1A57C(v9, 1); if ( !v11 ) { v13 = (int)v4; v4 = 0; sub_19DEC(v13); return v4; } if ( v10 ) *v10 = v11; else v4[2] = v11; if ( v10 ) *(_DWORD *)(v11 + 4) = v10; v10 = (int *)v11; v9 = (_DWORD *)*v9; } } } return v4; } //----- (0001A668) -------------------------------------------------------- char *__fastcall sub_1A668(char *result) { char *v1; // r2 _BYTE *v2; // r2 int v3; // r3 char v4; // t1 int v5; // r3 bool v6; // zf int v7; // r1 char *v8; // r3 int v9; // r1 int v10; // t1 bool v11; // zf v1 = result; while ( 1 ) { v3 = (unsigned __int8)*result; if ( !*result ) break; switch ( v3 ) { case 32: case 9: case 13: case 10: goto LABEL_10; case 47: v7 = (unsigned __int8)result[1]; if ( v7 == 47 ) { v8 = result; do { result = v8; v10 = (unsigned __int8)*v8++; v9 = v10; v11 = v10 == 10; if ( v10 != 10 ) v11 = v9 == 0; } while ( !v11 ); } else { if ( v7 != 42 ) { LABEL_9: *v1++ = v3; goto LABEL_10; } while ( *result && (*result != 42 || result[1] != 47) ) ++result; result += 2; } break; case 34: *v1 = 34; v2 = v1 + 1; ++result; while ( 1 ) { v5 = (unsigned __int8)*result; v6 = v5 == 34; if ( v5 != 34 ) v6 = v5 == 0; if ( v6 ) break; if ( v5 == 92 ) { *v2 = 92; ++result; ++v2; } v4 = *result++; *v2++ = v4; } *v2 = v5; v1 = v2 + 1; LABEL_10: ++result; break; default: goto LABEL_9; } } *v1 = v3; return result; } //----- (0001A760) -------------------------------------------------------- // Alternative name is '_fini' void term_proc() { ; } // nfuncs=362 queued=129 decompiled=129 lumina nreq=0 worse=0 better=0 // ALL OK, 129 function(s) have been successfully decompiled