// // cocos2d::CCImage::_saveImageToPNG from 0x18007be30 to 0x18007c5af (1919 bytes) // // 3 xrefs: // > cocos2d::CCImage::saveToFile @ 0x18007d4d7 // > @ 0x1801438a8 // > @ 0x1801b4e00 // // This function is hookable on this platform! // // Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings // char __fastcall cocos2d::CCImage::_saveImageToPNG(cocos2d::CCImage *this, const char *a2, char a3) { __int64 v3; // rax __int64 v5; // rax FILE *v6; // rcx FILE *v7; // r15 signed int v8; // edi __int64 v9; // r12 char *v10; // r14 unsigned int m_nHeight; // r9d __m128i *v12; // rdx __m128i v13; // xmm4 __m128i si128; // xmm7 __m128i v15; // xmm5 unsigned int v16; // ecx __m128i v17; // xmm6 __m128i v18; // xmm4 __m128i v19; // xmm3 unsigned int v20; // eax __m128i v21; // xmm1 unsigned __int8 *m_pData; // r10 __int64 v23; // r11 unsigned __int8 **v24; // rdx __int64 v25; // rcx __int64 v26; // r8 unsigned __int8 *v27; // rax _BYTE *v28; // rsi __m128i v29; // xmm4 int v30; // eax int v31; // r10d int m_nWidth; // ecx int v33; // eax int v34; // edx int v35; // edx signed int v36; // r8d __m128i *v37; // r9 __m128i v38; // xmm7 __m128i v39; // xmm5 unsigned int v40; // ecx __m128i v41; // xmm6 __m128i v42; // xmm3 unsigned int v43; // eax __m128i v44; // xmm1 int v45; // ecx __int64 v46; // r9 char *v47; // rdx char *v48; // rcx __int64 v49; // rax unsigned int v50; // r9d __m128i *v51; // rdx __m128i v52; // xmm3 __m128i v53; // xmm5 __m128i v54; // xmm3 unsigned int v55; // ecx __m128i v56; // xmm4 __m128i v57; // xmm2 __m128i v58; // xmm0 unsigned int v59; // eax __m128i v60; // xmm1 unsigned __int8 *v61; // r10 __int64 v62; // r11 unsigned __int8 **v63; // rdx __int64 v64; // r8 __int64 v65; // rcx unsigned __int8 *v66; // rax __int64 v67; // [rsp+8h] [rbp-59h] BYREF int v68; // [rsp+30h] [rbp-31h] int v69; // [rsp+38h] [rbp-29h] int v70; // [rsp+40h] [rbp-21h] int v71; // [rsp+48h] [rbp-19h] char v72; // [rsp+58h] [rbp-9h] __int64 v73; // [rsp+60h] [rbp-1h] BYREF __int64 info_struct; // [rsp+68h] [rbp+7h] BYREF FILE *Stream[2]; // [rsp+70h] [rbp+Fh] v72 = 0; if ( !a2 ) return 0; Stream[0] = fopen(a2, "wb"); if ( !Stream[0] ) return 0; v3 = png_create_write_struct("1.6.40", 0, 0, 0); v73 = v3; if ( !v3 ) { fclose(Stream[0]); return 0; } info_struct = png_create_info_struct(v3); if ( !info_struct ) { fclose(Stream[0]); png_destroy_write_struct(&v73, 0); return 0; } v5 = png_set_longjmp_fn(v73, longjmp, 256); if ( (unsigned int)_intrinsic_setjmp(v5, &v67) ) { v6 = Stream[0]; LABEL_10: fclose(v6); png_destroy_write_struct(&v73, &info_struct); return v72; } v7 = Stream[0]; png_init_io(v73, Stream[0]); if ( a3 || !this->m_bHasAlpha ) { v8 = 0; v71 = 0; v70 = 0; v69 = 0; v68 = 2; } else { v8 = 0; v71 = 0; v70 = 0; v69 = 0; v68 = 6; } png_set_IHDR(v73, info_struct, this->m_nWidth, this->m_nHeight, 8, v68, v69, v70, v71); v9 = png_malloc(v73, 768); png_set_PLTE(v73, info_struct, v9, 256); png_write_info(v73, info_struct); png_set_packing(v73); v10 = (char *)malloc(8LL * this->m_nHeight); if ( !v10 ) { LABEL_16: v6 = v7; goto LABEL_10; } if ( !this->m_bHasAlpha ) { m_nHeight = this->m_nHeight; if ( this->m_nHeight && m_nHeight >= 8 && dword_1801A4360 >= 2 ) { v12 = (__m128i *)(v10 + 32); v13 = _mm_loadl_epi64((const __m128i *)&this->m_pData); si128 = _mm_load_si128((const __m128i *)&xmmword_180101250); v15 = _mm_load_si128((const __m128i *)&xmmword_180101260); v16 = 4; v17 = _mm_cvtepu16_epi32(_mm_shufflelo_epi16(_mm_cvtsi32_si128((__int16)this->m_nWidth), 0)); v18 = _mm_unpacklo_epi64(v13, v13); do { v19 = _mm_move_epi64(si128); v12 += 4; v12[-6] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v17), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v8), 0), v19)), _mm_move_epi64(v15))), v18); v8 += 8; v20 = v16 + 2; v21 = _mm_cvtsi32_si128(v16); v12[-5] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v17), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v16 - 2), 0), v19)), _mm_move_epi64(v15))), v18); v16 += 8; v12[-4] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32(_mm_move_epi64(v17), _mm_add_epi32(_mm_shuffle_epi32(v21, 0), v19)), _mm_move_epi64(v15))), v18); v12[-3] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v17), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v20), 0), v19)), _mm_move_epi64(v15))), v18); } while ( v8 < (int)(m_nHeight & 0xFFFFFFF8) ); } if ( v8 < (int)m_nHeight ) { m_pData = this->m_pData; v23 = 3 * (unsigned int)this->m_nWidth; v24 = (unsigned __int8 **)&v10[8 * v8]; v25 = m_nHeight - v8; v26 = 3 * v8 * this->m_nWidth; do { v27 = &m_pData[v26]; v26 += v23; *v24++ = v27; --v25; } while ( v25 ); } LABEL_50: png_write_image(v73, v10); free(v10); goto LABEL_51; } if ( !a3 ) { v50 = this->m_nHeight; if ( this->m_nHeight && v50 >= 8 && dword_1801A4360 >= 2 ) { v51 = (__m128i *)(v10 + 32); v52 = _mm_loadl_epi64((const __m128i *)&this->m_pData); v53 = _mm_load_si128((const __m128i *)&xmmword_180101250); v54 = _mm_unpacklo_epi64(v52, v52); v55 = 4; v56 = _mm_cvtepu16_epi32(_mm_shufflelo_epi16(_mm_cvtsi32_si128((__int16)this->m_nWidth), 0)); do { v57 = _mm_move_epi64(v53); v58 = _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v8), 0), v57); v51 += 4; v8 += 8; v51[-6] = _mm_add_epi64(_mm_cvtepi32_epi64(_mm_slli_epi32(_mm_mullo_epi32(_mm_move_epi64(v56), v58), 2u)), v54); v59 = v55 + 2; v60 = _mm_cvtsi32_si128(v55); v51[-5] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_slli_epi32( _mm_mullo_epi32( _mm_move_epi64(v56), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v55 - 2), 0), v57)), 2u)), v54); v55 += 8; v51[-4] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_slli_epi32( _mm_mullo_epi32(_mm_move_epi64(v56), _mm_add_epi32(_mm_shuffle_epi32(v60, 0), v57)), 2u)), v54); v51[-3] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_slli_epi32( _mm_mullo_epi32( _mm_move_epi64(v56), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v59), 0), v57)), 2u)), v54); } while ( v8 < (int)(v50 & 0xFFFFFFF8) ); } if ( v8 < (int)v50 ) { v61 = this->m_pData; v62 = 4 * (unsigned int)this->m_nWidth; v63 = (unsigned __int8 **)&v10[8 * v8]; v64 = 4 * v8 * this->m_nWidth; v65 = v50 - v8; do { v66 = &v61[v64]; v64 += v62; *v63++ = v66; --v65; } while ( v65 ); } goto LABEL_50; } v28 = operator new(3 * this->m_nWidth * this->m_nHeight); v29 = _mm_unpacklo_epi64((__m128i)(unsigned __int64)v28, (__m128i)(unsigned __int64)v28); if ( !v28 ) goto LABEL_16; LOWORD(v30) = this->m_nHeight; v31 = 0; if ( (_WORD)v30 ) { LOWORD(m_nWidth) = this->m_nWidth; do { v33 = 0; if ( (_WORD)m_nWidth ) { do { v28[3 * v33 + 3 * v31 * (unsigned __int16)m_nWidth] = this->m_pData[4 * v33 + 4 * v31 * (unsigned __int16)m_nWidth]; v34 = v33 + v31 * this->m_nWidth; v28[3 * v34 + 1] = this->m_pData[4 * v34 + 1]; v35 = v33 + v31 * this->m_nWidth; ++v33; v28[3 * v35 + 2] = this->m_pData[4 * v35 + 2]; m_nWidth = this->m_nWidth; } while ( v33 < m_nWidth ); } v30 = this->m_nHeight; ++v31; } while ( v31 < v30 ); } v36 = (unsigned __int16)v30; if ( (unsigned __int16)v30 >= 8u && dword_1801A4360 >= 2 ) { v37 = (__m128i *)(v10 + 32); v38 = _mm_load_si128((const __m128i *)&xmmword_180101250); v39 = _mm_load_si128((const __m128i *)&xmmword_180101260); v40 = 4; v41 = _mm_cvtepu16_epi32(_mm_shufflelo_epi16(_mm_cvtsi32_si128((__int16)this->m_nWidth), 0)); do { v42 = _mm_move_epi64(v38); v37 += 4; v37[-6] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v41), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v8), 0), v42)), _mm_move_epi64(v39))), v29); v8 += 8; v43 = v40 + 2; v44 = _mm_cvtsi32_si128(v40); v37[-5] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v41), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v40 - 2), 0), v42)), _mm_move_epi64(v39))), v29); v40 += 8; v37[-4] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32(_mm_move_epi64(v41), _mm_add_epi32(_mm_shuffle_epi32(v44, 0), v42)), _mm_move_epi64(v39))), v29); v37[-3] = _mm_add_epi64( _mm_cvtepi32_epi64( _mm_mullo_epi32( _mm_mullo_epi32( _mm_move_epi64(v41), _mm_add_epi32(_mm_shuffle_epi32(_mm_cvtsi32_si128(v43), 0), v42)), _mm_move_epi64(v39))), v29); } while ( v8 < (int)(v36 & 0xFFFFFFF8) ); } if ( v8 < v36 ) { v45 = this->m_nWidth; v46 = (unsigned int)(3 * v45); v47 = &v10[8 * v8]; v48 = &v28[3 * v8 * v45]; v49 = (unsigned int)(v36 - v8); do { *(_QWORD *)v47 = v48; v47 += 8; v48 += v46; --v49; } while ( v49 ); } png_write_image(v73, v10); free(v10); j_j_free_0(v28); LABEL_51: png_write_end(v73, info_struct); png_free(v73, v9); png_destroy_write_struct(&v73, &info_struct); fclose(v7); return 1; }
GD Web Decomp Icon

GD Web Decomp

Raw Source