 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Jan 30, 2015 2:57 pm Post subject: MemoryStream and write method [bug] |
|
|
| Code: | myStream = createMemoryStream()
table = {1,2,3,4,5}
myStream.write(table)
print(myStream.Size) -- prints zero
myStream.write(table,4)
print(myStream.Size) -- prints 1
myStream.write(table,5)
print(myStream.Size) -- prints 2
myStream.write(dwordToByteTable(1))
print(myStream.Size) -- prints 2
myStream.write(dwordToByteTable(1),4)
print(myStream.Size) -- prints 3 |
Conclusion:
write(table) - doesn't work
write(table,n) - writes first byte
I wanted to write dwords and etc. I have to make workarounds:
| Code: | myStream = createMemoryStream()
myStream.fixedwrite = function (t)
for _,v in ipairs(t) do myStream.write({v},1) end
end
myStream.writeDword = function (v)
myStream.fixedwrite(dwordToByteTable(v))
end
myStream.writeDword(1)
print(myStream.Size) -- prints 4
myStream.fixedwrite({1,2,3,4,5})
print(myStream.Size) -- prints 9
|
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25831 Location: The netherlands
|
Posted: Fri Jan 30, 2015 3:44 pm Post subject: |
|
|
fixed in the svn
But just wondering, what do you need memorystream for ?
(Check the java lua files for another example of stream editing. Lua has no issue with 0-bytes in strings)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Jan 30, 2015 5:05 pm Post subject: |
|
|
| Quote: | | what do you need memorystream for ? |
Check test mp3.ct
| Code: | header = {
0x46464952,0x0000443B,0x45564157,0x20746D66,0x0000001E,0x00020055,
0x0000AC44,0x00001B58,0x00000001,0x0001000C,0x00000002,0x00010001,
0x61660571,0x00047463,0x2FF80000,0x61640014
} -- 44100Hz , Stereo
-- fix MemoryStream write, and add other useful methods
if oldcreateMemoryStream==nil then oldcreateMemoryStream = createMemoryStream end
function createMemoryStream()
local obj = oldcreateMemoryStream()
local oldwrite=obj.write
obj.write = function (t,n) -- override default write
local count=0
for _,v in ipairs(t) do
if count==n then break end
oldwrite({v},1)
count=count+1
end
end
obj.writeDword = function (v) obj.write(dwordToByteTable(v)) end
obj.writeWord = function (v) obj.write(wordToByteTable(v)) end
return obj
end
function convertMP3ToRIFFMP3(stream, stereo, rate)
local riffmp3 = createMemoryStream()
for i,v in ipairs(header) do repeat
if i==2 then riffmp3.writeDword(stream.Size+0x24) break end
riffmp3.writeDword(v)
until true end
riffmp3.writeWord(0x6174)
riffmp3.writeDword(stream.Size)
riffmp3.copyFrom(stream,stream.Size)
if stereo==false then riffmp3.Position = 0x16; riffmp3.writeWord(1) end
if tonumber(rate) then riffmp3.Position = 0x18; riffmp3.writeDword(rate) end
riffmp3.Position = riffmp3.Size - 1
return riffmp3
end
mp3stream = findTableFile([[shutdown.mp3]]).Stream
--convertMP3ToRIFFMP3(stream, stereo, rate)
--convertMP3ToRIFFMP3(stream) == convertMP3ToRIFFMP3(stream, true, 44100)
--convertMP3ToRIFFMP3(stream, false) == convertMP3ToRIFFMP3(stream, false, 44100)
if riffmp3stream==nil then riffmp3stream = convertMP3ToRIFFMP3(mp3stream) end
playSound(riffmp3stream, false)
|
test mp3.ct (44100Hz, variable bitrate, 2 channels)= 23KB and test mp3.cetrainer = 18KB
test wav.ct (22050Hz, 2 channels)= 136KB
| Description: |
|
 Download |
| Filename: |
test mp3.ct |
| Filesize: |
22.39 KB |
| Downloaded: |
542 Time(s) |
| Description: |
|
 Download |
| Filename: |
test wav.ct |
| Filesize: |
135.94 KB |
| Downloaded: |
669 Time(s) |
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25831 Location: The netherlands
|
Posted: Fri Jan 30, 2015 5:47 pm Post subject: |
|
|
ah nice
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Jan 30, 2015 7:46 pm Post subject: |
|
|
In previous CT it is:
| Code: | | convertMP3ToRIFFMP3(mp3stream) |
In this CT file, the same WAVE file was converted to MP3. This time with ffmpeg and
-ac 2 -ar 32000 -aq 9
Conversion to RIFFMP3:
| Code: | | convertMP3ToRIFFMP3(mp3stream,true,32000) |
Size: 12KB (CETRAINER: 9KB)
| Description: |
|
 Download |
| Filename: |
test2 mp3.ct |
| Filesize: |
11.84 KB |
| Downloaded: |
661 Time(s) |
_________________
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|