Share your advanced PureBasic knowledge/code with the community.
bingo
Enthusiast
Posts: 210 Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:
Post
by bingo » Thu Mar 15, 2007 10:59 am
Code: Select all
Import "ntdll.lib"
RtlComputeCrc32(dwInitial.l,pData.l,iLen.l)
EndImport
buffer.s = "1234567" + Space(512) + "1234567"
lenbuffer.l = Len(buffer)
counter.l = 999999
For s=1 To 3
timer = GetTickCount_()
For i=1 To counter
CRC32Fingerprint(@buffer,lenbuffer)
Next
Debug "pb... " + Str(GetTickCount_() - timer)
Debug Hex(CRC32Fingerprint(@buffer,lenbuffer))
timer = GetTickCount_()
For i=1 To counter
RtlComputeCrc32(0,@buffer,lenbuffer)
Next
Debug "api..." + Str(GetTickCount_() - timer)
Debug Hex(RtlComputeCrc32(0,@buffer,lenbuffer))
Next
my xp pc:
pb... 1860
D359D67E
api...1484
D359D67E
pb... 1844
D359D67E
api...1484
D359D67E
pb... 1828
D359D67E
api...1485
D359D67E
my vista pc:
pb... 2247
D359D67E
api...1903
D359D67E
pb... 2199
D359D67E
api...1857
D359D67E
pb... 2215
D359D67E
api...1872
D359D67E
RtlComputeCrc32 15-20% faster as CRC32Fingerprint ?
["1:0>1"]
SFSxOI
Addict
Posts: 2970 Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....
Post
by SFSxOI » Thu Mar 15, 2007 1:20 pm
hmmm...nice idea but doesn't work here on my Vista Pc. Unresolved External Symbol - RtlComputeCrc32.
Rescator
Addict
Posts: 1769 Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway
Post
by Rescator » Thu Mar 15, 2007 1:43 pm
That function is not in the PSDK, also ntdll is not documented "officially".
I would not rely on anything in it as it could change from Windows release/build to the next.
PS! The reason it is faster is that it most likely use file memory mapping,
not to mention being on a kernel level I think?
bingo
Enthusiast
Posts: 210 Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:
Post
by bingo » Thu Mar 15, 2007 1:47 pm
RtlComputeCrc32 is not in pb-standard ntdll.lib ! create a new or use
http://kyf.net/tmp/ntdll.zip and it works ...
["1:0>1"]
okasvi
Enthusiast
Posts: 150 Joined: Wed Apr 27, 2005 9:41 pm
Location: Finland
Post
by okasvi » Mon Mar 19, 2007 1:56 pm
or just use LoadLibrary/GetProcAddress...
Rings
Moderator
Posts: 1435 Joined: Sat Apr 26, 2003 1:11 am
Post
by Rings » Mon Mar 19, 2007 2:33 pm
Did not work with w2k, works with win-xp
here is a more friendly version:
Code: Select all
LibName.s="ntdll.dll"
FuncName.s="RtlComputeCrc32"
Prototype PrototypeRtlComputeCrc32(dwInitial.l,pData.l,iLen.l)
LibNR=LoadLibrary_(Libname)
If LibNR
FuncPointer=GetProcAddress_(LibNR,FuncName)
If FuncPointer
RtlComputeCrc32.PrototypeRtlComputeCrc32=FuncPointer
buffer.s = "1234567" + Space(512) + "1234567"
lenbuffer.l = Len(buffer)
counter.l = 999999
For s=1 To 3
timer = GetTickCount_()
For i=1 To counter
CRC32Fingerprint(@buffer,lenbuffer)
Next
Debug "pb... " + Str(GetTickCount_() - timer)
Debug Hex(CRC32Fingerprint(@buffer,lenbuffer))
timer = GetTickCount_()
For i=1 To counter
RtlComputeCrc32(0,@buffer,lenbuffer)
Next
Debug "api..." + Str(GetTickCount_() - timer)
Debug Hex(RtlComputeCrc32(0,@buffer,lenbuffer))
Next
Else
Debug "Cannot find entrypoint for " + Funcname
EndIf
FreeLibrary_(LibNR)
Else
Debug "Cannot open library " + Libname
EndIf
SPAMINATOR NR.1
blueznl
PureBasic Expert
Posts: 6166 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Mon Mar 19, 2007 3:02 pm
Highly distracting signature, Rings...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide
right here ... )
Seldon
Enthusiast
Posts: 405 Joined: Fri Aug 22, 2003 7:12 am
Location: Italia
Post
by Seldon » Fri Mar 23, 2007 9:44 am
Hi ! What are the specs for the Vista PC ? I hope it is slower than the one with XP because of a slower CPU and not for the OS.