By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!echo %@winapi[kernel32,GetSystemTimePreciseAsFileTime,pint64]
31291239
echo %@eval[31291239=h]
1DD7767
echo %{pshell test.ps1}
134394848605158668
echo %@eval[%{pshell test.ps1}=h]
1DD77671ACCCE74
if (-not ('PreciseSystemTime' -as [type])) {
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
public static class PreciseSystemTime
{
[StructLayout(LayoutKind.Sequential)]
private struct FILETIME
{
public uint LowDateTime;
public uint HighDateTime;
}
[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern void GetSystemTimePreciseAsFileTime(out FILETIME fileTime);
public static long GetFileTimeTicks()
{
FILETIME ft;
GetSystemTimePreciseAsFileTime(out ft);
return ((long)ft.HighDateTime << 32) | ft.LowDateTime;
}
}
'@
}
$ticks = [PreciseSystemTime]::GetFileTimeTicks()
$ticks
v:\> set x=%@unicode[%@winapi[kernel32,GetSystemTimePreciseAsFileTime,buffer]] & set y=%_agenow
v:\> echo %@eval[(%@word[3,%x] * 2**48) + (%@word[2,%x] * 2**32) + (%@word[1,%x] * 2**16) + %@word[0,%x]=h]
1DD7763CDA7B569
v:\> echo %@eval[%y=h]
1DD7763CDA7C6A2
v:\> echo %@ascii[%@winapi[kernel32,GetSystemTimePreciseAsFileTime,buffer]]
51952 47254 30561 477 60496 15122 659
@setlocal
@echo off
set x=%@winapi[kernel32,GetSystemTimePreciseAsFileTime,buffer]
set x=%@unicode[%x]
set low=%@eval[(%@word[1,%x] << 16) + %@word[0,%x]=h]
set high=%@eval[(%@word[3,%x] << 16) + %@word[2,%x]=h]
echo X : %x
echo Low : %Low
echo High: %High
endlocal
R:\>test.btm
X : 1232826 30573 477 16106 18603 32764
Low : 777FCFBA
High: 3EEA01DD
R:\>test.btm
X : 17194 40907 30573 477 16106 18603 32764
Low : 9FCB432A
High: 1DD776D
R:\>test.btm
X : 35153 42392 30573 477 16106 18603 32764
Low : A5988951
High: 1DD776D
Given how I'm processing it when I use "buffer", isn't it binary to begin with? How else might it work?@WINAPI and @CAPI really ought to support binary buffers.
Given how I'm processing it when I use "buffer", isn't it binary to begin with? How else might it work?
BBUF=%handle.set agenow=%@eval[%@makeage[%_date,%_time] + %_tzo * 60 * 10000000]
Huh! What's PINT64 all about?@WINAPI has never supported returning 64-bit values. (It does support passing 64-bit values to the Windows API.)
Also, your syntax is wrong.
Huh! What's PINT64 all about?
And what syntax is wrong?
v:\> echo %@eval[%@winapi[kernel32,GetSystemTimePreciseAsFileTime,pint64]=h]^
More? & echo %@eval[%_agenow=h]
1DD77C7
1DD77C7C579123B
INT WINAPI _AGENOW ( LPWSTR psz )
{
ULONGLONG ft;
GetSystemTimePreciseAsFileTime((FILETIME*) &ft);
Sprintf(psz, L"%I64u", ft);
return 0;
}
Then what's happening here? GetSystemTimePreciseAsFileTime is writing something at a location given to it by TCC, and whats being echo'd
is exactly equal to the high DWORD of the precise system time as a file time.
Code:v:\> echo %@eval[%@winapi[kernel32,GetSystemTimePreciseAsFileTime,pint64]=h]^ More? & echo %@eval[%_agenow=h] 1DD77C7 1DD77C7C579123B
It seems I could give a 64-bit value (PINT64=value) but the function doesn't require one. If the buffer is big enough to pass a 64-bit value then it's big enough to to hold a FILETIME. @WINAPI knows I said PINT64; can't it read all 8 bytes?
If I'm way off-base here, please enlighten me by explaining in gory detail what the code above is doing.
I don't know enough to comment further. This thread grew out of my desire to use @WINAPI on GetSystemTimePreciseAsFileTime.
v:\> help @buftoint
@BUFTOINT[buffer,size] size = 1, 2, 4, 8
v:\> echo %@buftoint[%@winapi[kernel32,GetSystemTimePreciseAsFileTime,buffer],8] & echo %_agenow
134395782729243948
134395782729286430
set agenow=%@eval[%@makeage[%_date,%_time] + %_tzo * 60 * 10000000]