format PE console
entry start

include '%fasminc%\win32a.inc'

struct TIME_OF_DAY_INFO
	tod_elapsedt		dd ?
	tod_msecs		dd ?
	tod_hours		dd ?
	tod_mins		dd ?
	tod_secs		dd ?
	tod_hunds		dd ?
	tod_timezone		dd ?
	tod_tinterval		dd ?
	tod_day			dd ?
	tod_month		dd ?
	tod_year		dd ?
	tod_weekday		dd ?
ends

crlf	equ 10,13

section '.data' data readable writeable
buff		rb MAX_PATH

ffformat	db '%lu_%02lu_%02lu_%02lu%02lu',0

pcTodAddr	dd ?
pcTod		TIME_OF_DAY_INFO

section '.code' code readable executable
; start
start:
	invoke	NetRemoteTOD,NULL,pcTodAddr
	invoke	RtlMoveMemory,pcTod,[pcTodAddr],sizeof.TIME_OF_DAY_INFO
	invoke	NetApiBufferFree,[pcTodAddr]
	cinvoke	wsprintf,buff,ffformat,[pcTod.tod_year],[pcTod.tod_month],[pcTod.tod_day],[pcTod.tod_hours],[pcTod.tod_mins]
	invoke	OutputDebugString,buff
	invoke	ExitProcess,0

section '.idata' import data readable
	library	kernel32,			'KERNEL32.DLL',\
		user32,				'USER32.DLL',\
		netapi32,			'NETAPI32.DLL'
         
	include '%fasminc%\api\Kernel32.inc'
	include '%fasminc%\api\User32.inc'
	import	netapi32,\
		NetRemoteTOD,			'NetRemoteTOD',\
		NetApiBufferFree,		'NetApiBufferFree'