红警杀吧 关注:256贴子:3,374

<HackTool>解密NCGR工具发布!

只看楼主收藏回复

老规矩,二楼链接!


IP属地:陕西1楼2014-05-01 18:56回复
    链接楼


    IP属地:陕西2楼2014-05-01 18:56
    收起回复
      先下一个看看好不好用


      IP属地:陕西来自Android客户端3楼2014-05-01 19:46
      收起回复
        保存着 问下NCGR是什么


        来自Android客户端4楼2014-05-02 08:08
        收起回复
          n是Nintendo
          r是resource
          G是graphic
          l是palate
          s是sequence
          c不太清楚


          IP属地:陕西来自Android客户端5楼2014-05-02 08:13
          收起回复
            把c++部分转换为vb代码了,不保证能用
            http://pan.baidu.com/share/link?shareid=685372066&uk=2098617728


            IP属地:陕西来自Android客户端6楼2014-05-02 12:56
            收起回复
              快挂了,看半天不知道哪里出了问题
              Imports System.IO
              Public Class NCGRDecoder
              Const M = 48
              Const N = 1078
              Private Shared Sub fseek(strm As MemoryStream, offset As Long, location As SeekOrigin)
              strm.Seek(offset, location)
              End Sub
              Private Shared Function getc(strm As MemoryStream) As Byte
              Return CByte(strm.ReadByte())
              End Function
              Private Shared Function putc(Value As Byte, strm As MemoryStream) As Byte
              strm.WriteByte(Value)
              Return Value
              End Function
              Private Shared Function fprintf(strm As MemoryStream, format As String, ParamArray Values() As Object) As Integer
              Dim fm As String() = format.Substring(1, format.Length - 1).Split({"%"}, StringSplitOptions.None)
              Dim i As Integer = 0
              For Each v In Values
              Select Case fm(i)
              Case "c"
              putc(CByte(v), strm)
              Case Else
              Throw New NotsupportedException
              End Select
              i += 1
              Next
              Return Values.Length
              End Function
              Private Shared Sub fclose(strm As MemoryStream)
              strm.Close()
              End Sub
              Public Shared Sub DecodeFile(NCGRfile As String, NSCRfile As String, NCLRfile As String, Outfile As String)
              Dim cgr As New BinaryReader(New FileStream(NCGRfile, FileMode.Open))
              Dim scr As New BinaryReader(New FileStream(NSCRfile, FileMode.Open))
              Dim clr As New BinaryReader(New FileStream(NCLRfile, FileMode.Open))
              Dim outbyte As Byte() = DecodeData(cgr.ReadBytes(CInt(cgr.BaseStream.Length)), scr.ReadBytes(CInt(scr.BaseStream.Length)), clr.ReadBytes(CInt(clr.BaseStream.Length)))
              cgr.Close()
              scr.Close()
              clr.Close()
              Dim bm As New BinaryWriter(New FileStream(Outfile, FileMode.OpenOrCreate))
              bm.Write(outbyte)
              bm.Close()
              End Sub


              IP属地:陕西7楼2014-05-02 17:34
              回复
                Public Shared Function DecodeData(NCGRfile As Byte(), NSCRfile As Byte(), NCLRfile As Byte()) As Byte()
                Dim bmp_size, pixel, width, x_number, height, y_number, color_mode, clr16_number, hv_mode, i, j, k, templow, temphigh, tempscr, tempclr, tempR, tempG, tempB As Integer
                Dim ncgr As New MemoryStream(NCGRfile)
                Dim nscr As New MemoryStream(NSCRfile)
                Dim nclr As New MemoryStream(NCLRfile)
                fseek(nscr, 24, 0)
                templow = getc(nscr)
                temphigh = getc(nscr)
                width = templow + (temphigh << 8)
                x_number = width \ 8
                templow = getc(nscr)
                temphigh = getc(nscr)
                height = templow + (temphigh << 8)
                y_number = height \ 8
                pixel = width * height
                bmp_size = N + pixel
                Dim bmpbuff(bmp_size - 1) As Byte
                Dim bmp As New MemoryStream(bmpbuff)
                fseek(bmp, 0, 0)
                fprintf(bmp, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", Asc("B"), Asc("M"),
                bmp_size And &HFF, bmp_size >> 8 And &HFF,
                bmp_size >> 16 And &HFF, bmp_size >> 24 And &HFF, 0, 0, 0, 0,
                54, 4, 0, 0, 40, 0,
                0, 0, width And &HFF, width >> 8 And &HFF, 0, 0,
                height And &HFF, height >> 8 And &HFF, 0, 0, 1, 0,
                8, 0, 0, 0, 0, 0,
                pixel And &HFF, pixel >> 8 And &HFF, pixel >> 16 And &HFF, pixel >> 24 And &HFF)
                fseek(bmp, 54, 0)
                fseek(nclr, 40, 0)
                For i = 0 To 255
                templow = getc(nclr)
                temphigh = getc(nclr)
                tempclr = templow + (temphigh << 8)
                tempR = (tempclr And &H1F) * 8
                tempG = (tempclr >> 5 And &H1F) * 8
                tempB = (tempclr >> 10 And &H1F) * 8
                fprintf(bmp, "%c%c%c%c", tempB, tempG, tempR, 0)
                Next
                fseek(nclr, 24, 0)
                color_mode = getc(nclr)
                fclose(nclr)
                fseek(nscr, 36, 0)
                Const Color_256 = 4
                Const Color_16 = 3
                Const Rotate_None = 0
                Const Rotate_H = 4
                Const Rotate_V = 8
                Const Rotate_HV = 12
                If color_mode = Color_256 Then
                For i = 0 To x_number * y_number - 1
                templow = getc(nscr)
                temphigh = getc(nscr)
                hv_mode = temphigh And &HC
                temphigh = temphigh And 3
                tempscr = templow + (temphigh << 8)
                fseek(ncgr, M + tempscr * 64, 0)
                If hv_mode = Rotate_None Then
                fseek(bmp, -(i \ x_number * width * 8 + width - (i Mod x_number) * 8), SeekOrigin.End)
                For j = 0 To 7
                For k = 0 To 7
                putc(getc(ncgr), bmp)
                Next
                fseek(bmp, -(width + 8), SeekOrigin.Current)
                Next
                ElseIf hv_mode = Rotate_H Then


                IP属地:陕西8楼2014-05-02 17:35
                回复
                  fseek(bmp, -(i \ x_number * width * 8 + width - (i Mod x_number) * 8 - 7), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 7
                  putc(getc(ncgr), bmp)
                  fseek(bmp, -2, SeekOrigin.Current)
                  Next
                  fseek(bmp, -(width - 8), SeekOrigin.Current)
                  Next
                  ElseIf hv_mode = Rotate_V Then
                  fseek(bmp, -(i \ x_number * width * 8 + width * 8 - (i Mod x_number) * 8), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 7
                  putc(getc(ncgr), bmp)
                  Next
                  fseek(bmp, width - 8, SeekOrigin.Current)
                  Next
                  ElseIf hv_mode = Rotate_HV Then
                  fseek(bmp, -(i \ x_number * width * 8 + width * 8 - (i Mod x_number) * 8 - 7), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 7
                  putc(getc(ncgr), bmp)
                  fseek(bmp, -2, SeekOrigin.Current)
                  Next
                  fseek(bmp, width + 8, SeekOrigin.Current)
                  Next
                  End If
                  Next
                  ElseIf color_mode = Color_16 Then
                  For i = 0 To x_number * y_number - 1
                  templow = getc(nscr)
                  temphigh = getc(nscr)
                  clr16_number = temphigh >> 4 And &HF
                  hv_mode = temphigh And &HC
                  temphigh = temphigh And 3
                  tempscr = templow + (temphigh << 8)
                  fseek(ncgr, M + tempscr * 32, 0)
                  If hv_mode = Rotate_None Then
                  fseek(bmp, -(i \ x_number * width * 8 + width - (i Mod x_number) * 8), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 3
                  temphigh = getc(ncgr)
                  templow = temphigh And &HF
                  temphigh = (temphigh >> 4) And &HF
                  templow += clr16_number << 4
                  temphigh += clr16_number << 4
                  putc(CByte(templow), bmp)
                  putc(CByte(temphigh), bmp)
                  Next
                  fseek(bmp, -(width + 8), SeekOrigin.Current)
                  Next
                  ElseIf hv_mode = Rotate_H Then
                  fseek(bmp, -(i \ x_number * width * 8 + width - (i Mod x_number) * 8 - 6), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 3
                  temphigh = getc(ncgr)
                  templow = temphigh And &HF
                  temphigh = temphigh >> 4 And &HF
                  templow += clr16_number << 4
                  temphigh += clr16_number << 4
                  putc(CByte(temphigh), bmp)
                  putc(CByte(templow), bmp)
                  fseek(bmp, -4, SeekOrigin.Current)
                  Next
                  fseek(bmp, -(width - 8), SeekOrigin.Current)
                  Next
                  ElseIf hv_mode = Rotate_V Then
                  fseek(bmp, -(i \ x_number * width * 8 + width * 8 - (i Mod x_number) * 8), SeekOrigin.End)
                  For j = 0 To 7
                  For k = 0 To 3
                  temphigh = getc(ncgr)
                  templow = temphigh And &HF
                  temphigh = temphigh >> 4 And &HF
                  templow += clr16_number << 4
                  temphigh += clr16_number << 4
                  putc(CByte(templow), bmp)
                  putc(CByte(temphigh), bmp)
                  Next
                  fseek(bmp, width - 8, SeekOrigin.Current)
                  Next
                  ElseIf hv_mode = Rotate_HV Then


                  IP属地:陕西9楼2014-05-02 17:35
                  收起回复
                    fseek(bmp, -(i \ x_number * width * 8 + width * 8 - (i Mod x_number) * 8 - 6), SeekOrigin.End)
                    For j = 0 To 7
                    For k = 0 To 3
                    temphigh = getc(ncgr)
                    templow = temphigh And &HF
                    temphigh = temphigh >> 4 And &HF
                    templow += clr16_number << 4
                    temphigh += clr16_number << 4
                    putc(CByte(temphigh), bmp)
                    putc(CByte(templow), bmp)
                    fseek(bmp, -4, SeekOrigin.Current)
                    Next
                    fseek(bmp, width + 8, SeekOrigin.Current)
                    Next
                    End If
                    Next
                    End If
                    fclose(bmp)
                    fclose(nscr)
                    fclose(ncgr)
                    Return bmpbuff
                    End Function
                    End Class


                    IP属地:陕西10楼2014-05-02 17:35
                    回复
                      c++语言版代码在二楼


                      IP属地:陕西11楼2014-05-02 17:36
                      回复
                        代码诊断完毕。是文件指针设置错误了,写了一个tile之后指针跳到了不正确的位置,覆盖了上个tile的数据导致整张图像都悲剧了。
                        我估计是fseek实现错误了。


                        IP属地:陕西12楼2014-05-03 17:07
                        收起回复
                          发现Bug:检测完成的判定有个小问题,在低端机可能会在错误的时候提示完成。
                          更正:
                          Dim cmp=opendialog.FileNames.Length
                          ...
                          decode()
                          cmp-=1
                          if cmp=0 Then Dispatcher.BeginInvoke(Sub()msg(“ok”))


                          IP属地:陕西来自Android客户端13楼2014-05-04 20:53
                          回复
                            这个不能沉了。以后转换更多代码,大多从ARM指令转换


                            IP属地:陕西来自Android客户端14楼2014-05-06 00:56
                            回复
                              搞到tinke的源码了,估计对编写转换器有帮助,因为那里面记录了文件结构


                              IP属地:陕西来自Android客户端15楼2014-05-07 13:24
                              回复