in reply to Random Numbers under XP: Translating XS to Win32::API
Are you having problems? :)
There is no entrypoint 'RtlGenRandom' exported from advapi32.dll. The function documented under that name is exported as 'SystemFunction36' (and may go away in future versions).
#! perl -slw use strict; sub random { my $count = shift; use Win32::API::Prototype; ApiLink( 'ADVAPI32.DLL', 'BOOLEAN SystemFunction036( PVOID b, ULON +G n )' ) or die $^E; our $RtlGenRandom; *RtlGenRandom = *SystemFunction036; my $buffer = chr( 0 ) x ( 4 * $count ); if( RtlGenRandom( $buffer, 4 * $count ) ) { return [ unpack 'V*', $buffer ]; } else { warn "rtlGenRandom failed : $^E"; return; } } print for @{ random( 10 ) }; __END__ P:\test>471107 Name "main::SystemFunction036" used only once: possible typo at P:\tes +t\471107.pl line 11. 2938396619 3012541328 434618806 2806772272 1411585649 1621144589 2620908003 1934412219 3486653462 3699174573
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Random Numbers under XP: Translating XS to Win32::API
by jdhedden (Deacon) on Jun 29, 2005 at 20:05 UTC | |
by BrowserUk (Patriarch) on Jun 29, 2005 at 20:20 UTC |