| |
|
|
 Frank Abbing | data pack without Dll, only through API.
================================================================================
================================================================================/
data pack/entpacken without Dll, only through API.
© 2008 Frank Abbing, http://frabbing.de
Def RtlCompressBuffer(8) !"ntdll.dll", "RtlCompressBuffer"
Def RtlDecompressBuffer(6) !"ntdll.dll", "RtlDecompressBuffer"
Def RtlGetCompressionWorkSpaceSize(3) !"ntdll.dll", "RtlGetCompressionWorkSpaceSize"
Def RtlMoveMemory(3) !"kernel32.dll", "RtlMoveMemory"
Speicherbereich pack. Parameter: (Speicherbereich, amount Bytes in the Speicherbereich)
Proc CompressBuffer
Parameters bbereich#, cbx&
Declare cstatus&, bworkspacesize&, fworkspacesize&, cbereich#, workspace#
cstatus&=0
Ifnot RtlGetCompressionWorkSpaceSize(2, Addr(bworkspacesize&), Addr(fworkspacesize&))
Dim workspace#,bworkspacesize&
Dim cbereich#,cbx&+400
Ifnot RtlCompressBuffer(2,bbereich#,cbx&,cbereich#,cbx&+400,0,Addr(bworkspacesize&),workspace#)
Clear bbereich#
Long bbereich#,0=cbx&
RtlMoveMemory(bbereich#+4,cbereich#,bworkspacesize&)
cstatus&=bworkspacesize&+4
EndIf
Dispose workspace#
Dispose cbereich#
Endif
Return cstatus&
Return: amount the gepackten Bytes. The gepackten data get in whom übergebenen Speicherbereich copies.
ENDPROC
Originale Speichergrösse detect. Parameter: (gepackter Speicherbereich#)
Proc GetDecompressSize
Parameters bbereich#
Return Long(bbereich#,0)
ENDPROC
Speicherbereich entpacken. Parameter: (gepackter Speicherbereich, amount Bytes in the gepackten Speicherbereich, suitor Speicherbereich)
Proc DecompressBuffer
Parameters bbereich#, cbx&, cbereich#
Declare bworkspacesize&
Ifnot RtlDecompressBuffer(2,cbereich#,Long(bbereich#,0),bbereich#+4,cbx&-4,Addr(bworkspacesize&))
Return bworkspacesize&
EndIf
Return 0
Return: amount the entgepackten Bytes.
ENDPROC
================================================================================
================================================================================/
====> HAUPTPROGRAMM
Declare area#, area2#, Text$, x&, xcopy&, newbytes&
Cls
While 1
Text$=LoadFile $("Datei to that pack aussuchen","")
If Text$<>""
pack testing
x&=FileSize(text $)
xcopy&=x&
If x&
Dim area#, x&+400
BlockRead(Text$, area#, 0, x&)
newbytes&=CompressBuffer(area#, x&)
If newbytes&
Set("Decimals",2)
Print "Dateiname: "+Text$
Print "Originalgrösse lying with "+Str $(x&)+" Bytes, comprimiert with "+Str $(newbytes&)+" Bytes."
Print "Packrate lying with "+Str $(100-(newbytes&*100/x&))+" percent."
Text$=text $+".pck"
BlockWrite Text$, area#, 0, newbytes&
Dispose area#
Entpacken testing
x&=FileSize(text $)
If x&
Dim area#, x&
BlockRead(Text$, area#, 0, x&)
newbytes&=GetDecompressSize(area #)
Dim area2#,newbytes&
x&=DecompressBuffer(area#, x&, area2#)
If x&
Text$=text $+".org"
BlockWrite Text$, area2#, 0, x&
Print "Dateiname: "+Text$
Print "Decomprimierte Originalgrösse totals "+Str $(x&)+" Bytes."
Print
Else
Print Text$+" couldn't entpackt go."
Print
EndIf
Dispose area2#
Dispose area#
EndIf
Else
Dispose area#
Print Text$+" couldn't gepackt go."
EndIf
EndIf
Else
BREAK
EndIf
EndWhile
WaitInput
End
|
|
|
| |
|
|
|
 | |
|
| |
|
|
|
 Frank Abbing | Nachtrag: gives one as first Parameter with RtlCompressBuffer() and RtlDecomressBuffer() in lieu of the 2 a $102 on, then access is a höhere Packrate. though on cost the speed. |
|
|
| |
|
|
|
 | How could one best sure Verify, whether these function on the system too bereitsteht? with XProfan ImportDLL to function search, if The DLL existert? |
|
|
| |
|
|
|
 Frank Abbing | APIs LoadLibrary() and then GetProcAddress(). so mach ichs in Assembler. having it not made, because it too so by me well funktionierte. For this go under 98 The functions not found, during tappt im dunkeln in of my Assemblerversion very well found go. but me shining, there existieren tappt im dunkeln of course, having but no Auswirkungen. ex XP (Start the Documentation) are The NTDLL.DLL-functions but sure present, therefore recommend I sooner a Betriebssystem-Test. |
|
|
| |
|
|
|
 Jac de Lad | an typische Frank-ingenuity.  |
|
|
| Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 09/05/08 ▲ |
|
|
|
|
 Michael Wodrich | Yes, there close I on...  |
|
|
| Programmieren, das spannendste Detektivspiel der Welt. | 09/06/08 ▲ |
|
|
|
|
 Frank Abbing | |
|
| |
|
|
|
 Bernhard Künzel | have with the Compress.exe tested, where with manchen Graphics a Error Message appear. To little memory for Bereichs-Variable! row 413! in the attachment are 4 Graphics, where these Error Message appear. |
|
|
| |
|
|
|
 Frank Abbing | which Windowsversion (Please in the Signatur indicate )? Huh, row 413? so much Lines has the code Yes with Weitem not.  there the Source settled is, can you gladly The cause explore. My Tests verliefen any fehlerfrei. |
|
|
| |
|
|
|
 Bernhard Künzel | Hello Frank, Win Version XP Home SP2 Profan Version XProfan11ßRC9 Test with your Compress.exe: in the MessageBox comes The Error Message "Zu little memory for Bereichs-Variable!" row 413! and in the Profanfenster standing ".....couldn't gepackt werden" with your Source: here comes only The Message in the Profanfenster ".....couldn't gepackt werden"
lg Bernhard |
|
|
| |
|
|
|
 Frank Abbing | sees from, as would your main memory to incline gagangen. Profan can so plenty memory not any more reservieren. this is then no Bug, therefore no Error Message, separate one discontinue with information. i'm therefore so pingelig, I just sure to put would like, that the code fehlerfrei runs. |
|
|
| |
|
|