2022-04-29 14:13:58 -04:00
/ *
* Copyright ( c ) 2014 - 2015 Sylvain Peyrefitte
*
* This file is part of node - rdpjs .
*
* node - rdpjs is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* /
var caps = require ( './caps' ) ;
var type = require ( '../../core' ) . type ;
var log = require ( '../../core' ) . log ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240576.aspx
* /
var PDUType = {
PDUTYPE _DEMANDACTIVEPDU : 0x11 ,
PDUTYPE _CONFIRMACTIVEPDU : 0x13 ,
PDUTYPE _DEACTIVATEALLPDU : 0x16 ,
PDUTYPE _DATAPDU : 0x17 ,
PDUTYPE _SERVER _REDIR _PKT : 0x1A
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240577.aspx
* /
var PDUType2 = {
PDUTYPE2 _UPDATE : 0x02 ,
PDUTYPE2 _CONTROL : 0x14 ,
PDUTYPE2 _POINTER : 0x1B ,
PDUTYPE2 _INPUT : 0x1C ,
PDUTYPE2 _SYNCHRONIZE : 0x1F ,
PDUTYPE2 _REFRESH _RECT : 0x21 ,
PDUTYPE2 _PLAY _SOUND : 0x22 ,
PDUTYPE2 _SUPPRESS _OUTPUT : 0x23 ,
PDUTYPE2 _SHUTDOWN _REQUEST : 0x24 ,
PDUTYPE2 _SHUTDOWN _DENIED : 0x25 ,
PDUTYPE2 _SAVE _SESSION _INFO : 0x26 ,
PDUTYPE2 _FONTLIST : 0x27 ,
PDUTYPE2 _FONTMAP : 0x28 ,
PDUTYPE2 _SET _KEYBOARD _INDICATORS : 0x29 ,
PDUTYPE2 _BITMAPCACHE _PERSISTENT _LIST : 0x2B ,
PDUTYPE2 _BITMAPCACHE _ERROR _PDU : 0x2C ,
PDUTYPE2 _SET _KEYBOARD _IME _STATUS : 0x2D ,
PDUTYPE2 _OFFSCRCACHE _ERROR _PDU : 0x2E ,
PDUTYPE2 _SET _ERROR _INFO _PDU : 0x2F ,
PDUTYPE2 _DRAWNINEGRID _ERROR _PDU : 0x30 ,
PDUTYPE2 _DRAWGDIPLUS _ERROR _PDU : 0x31 ,
PDUTYPE2 _ARC _STATUS _PDU : 0x32 ,
PDUTYPE2 _STATUS _INFO _PDU : 0x36 ,
PDUTYPE2 _MONITOR _LAYOUT _PDU : 0x37
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240577.aspx
* /
var StreamId = {
STREAM _UNDEFINED : 0x00 ,
STREAM _LOW : 0x01 ,
STREAM _MED : 0x02 ,
STREAM _HI : 0x04
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240577.aspx
* /
var CompressionOrder = {
CompressionTypeMask : 0x0F ,
PACKET _COMPRESSED : 0x20 ,
PACKET _AT _FRONT : 0x40 ,
PACKET _FLUSHED : 0x80
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240577.aspx
* /
var CompressionType = {
PACKET _COMPR _TYPE _8K : 0x0 ,
PACKET _COMPR _TYPE _64K : 0x1 ,
PACKET _COMPR _TYPE _RDP6 : 0x2 ,
PACKET _COMPR _TYPE _RDP61 : 0x3 ,
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240492.aspx
* /
var Action = {
CTRLACTION _REQUEST _CONTROL : 0x0001 ,
CTRLACTION _GRANTED _CONTROL : 0x0002 ,
CTRLACTION _DETACH : 0x0003 ,
CTRLACTION _COOPERATE : 0x0004
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240495.aspx
* /
var PersistentKeyListFlag = {
PERSIST _FIRST _PDU : 0x01 ,
PERSIST _LAST _PDU : 0x02
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240612.aspx
* /
var BitmapFlag = {
BITMAP _COMPRESSION : 0x0001 ,
NO _BITMAP _COMPRESSION _HDR : 0x0400
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240608.aspx
* /
var UpdateType = {
UPDATETYPE _ORDERS : 0x0000 ,
UPDATETYPE _BITMAP : 0x0001 ,
UPDATETYPE _PALETTE : 0x0002 ,
UPDATETYPE _SYNCHRONIZE : 0x0003
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240608.aspx
* /
var UpdateType = {
UPDATETYPE _ORDERS : 0x0000 ,
UPDATETYPE _BITMAP : 0x0001 ,
UPDATETYPE _PALETTE : 0x0002 ,
UPDATETYPE _SYNCHRONIZE : 0x0003
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240583.aspx
* /
var InputMessageType = {
INPUT _EVENT _SYNC : 0x0000 ,
INPUT _EVENT _UNUSED : 0x0002 ,
INPUT _EVENT _SCANCODE : 0x0004 ,
INPUT _EVENT _UNICODE : 0x0005 ,
INPUT _EVENT _MOUSE : 0x8001 ,
INPUT _EVENT _MOUSEX : 0x8002
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240586.aspx
* /
var PointerFlag = {
PTRFLAGS _HWHEEL : 0x0400 ,
PTRFLAGS _WHEEL : 0x0200 ,
PTRFLAGS _WHEEL _NEGATIVE : 0x0100 ,
WheelRotationMask : 0x01FF ,
PTRFLAGS _MOVE : 0x0800 ,
PTRFLAGS _DOWN : 0x8000 ,
PTRFLAGS _BUTTON1 : 0x1000 ,
PTRFLAGS _BUTTON2 : 0x2000 ,
PTRFLAGS _BUTTON3 : 0x4000
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240584.aspx
* /
var KeyboardFlag = {
KBDFLAGS _EXTENDED : 0x0100 ,
KBDFLAGS _DOWN : 0x4000 ,
KBDFLAGS _RELEASE : 0x8000
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240622.aspx
* /
var FastPathUpdateType = {
FASTPATH _UPDATETYPE _ORDERS : 0x0 ,
FASTPATH _UPDATETYPE _BITMAP : 0x1 ,
FASTPATH _UPDATETYPE _PALETTE : 0x2 ,
FASTPATH _UPDATETYPE _SYNCHRONIZE : 0x3 ,
FASTPATH _UPDATETYPE _SURFCMDS : 0x4 ,
FASTPATH _UPDATETYPE _PTR _NULL : 0x5 ,
FASTPATH _UPDATETYPE _PTR _DEFAULT : 0x6 ,
FASTPATH _UPDATETYPE _PTR _POSITION : 0x8 ,
2022-06-24 01:10:07 -04:00
FASTPATH _UPDATETYPE _COLOR : 0x9 , // Mouse cursor
2022-04-29 14:13:58 -04:00
FASTPATH _UPDATETYPE _CACHED : 0xA ,
FASTPATH _UPDATETYPE _POINTER : 0xB
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240622.aspx
* /
var FastPathOutputCompression = {
FASTPATH _OUTPUT _COMPRESSION _USED : 0x2
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240648.aspx
* /
var Display = {
SUPPRESS _DISPLAY _UPDATES : 0x00 ,
ALLOW _DISPLAY _UPDATES : 0x01
} ;
/ * *
* @ see https : //msdn.microsoft.com/en-us/library/cc240588.aspx
* /
var ToogleFlag = {
TS _SYNC _SCROLL _LOCK : 0x00000001 ,
TS _SYNC _NUM _LOCK : 0x00000002 ,
TS _SYNC _CAPS _LOCK : 0x00000004 ,
TS _SYNC _KANA _LOCK : 0x00000008
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240544.aspx
* /
var ErrorInfo = {
ERRINFO _RPC _INITIATED _DISCONNECT : 0x00000001 ,
ERRINFO _RPC _INITIATED _LOGOFF : 0x00000002 ,
ERRINFO _IDLE _TIMEOUT : 0x00000003 ,
ERRINFO _LOGON _TIMEOUT : 0x00000004 ,
ERRINFO _DISCONNECTED _BY _OTHERCONNECTION : 0x00000005 ,
ERRINFO _OUT _OF _MEMORY : 0x00000006 ,
ERRINFO _SERVER _DENIED _CONNECTION : 0x00000007 ,
ERRINFO _SERVER _INSUFFICIENT _PRIVILEGES : 0x00000009 ,
ERRINFO _SERVER _FRESH _CREDENTIALS _REQUIRED : 0x0000000A ,
ERRINFO _RPC _INITIATED _DISCONNECT _BYUSER : 0x0000000B ,
ERRINFO _LOGOFF _BY _USER : 0x0000000C ,
ERRINFO _LICENSE _INTERNAL : 0x00000100 ,
ERRINFO _LICENSE _NO _LICENSE _SERVER : 0x00000101 ,
ERRINFO _LICENSE _NO _LICENSE : 0x00000102 ,
ERRINFO _LICENSE _BAD _CLIENT _MSG : 0x00000103 ,
ERRINFO _LICENSE _HWID _DOESNT _MATCH _LICENSE : 0x00000104 ,
ERRINFO _LICENSE _BAD _CLIENT _LICENSE : 0x00000105 ,
ERRINFO _LICENSE _CANT _FINISH _PROTOCOL : 0x00000106 ,
ERRINFO _LICENSE _CLIENT _ENDED _PROTOCOL : 0x00000107 ,
ERRINFO _LICENSE _BAD _CLIENT _ENCRYPTION : 0x00000108 ,
ERRINFO _LICENSE _CANT _UPGRADE _LICENSE : 0x00000109 ,
ERRINFO _LICENSE _NO _REMOTE _CONNECTIONS : 0x0000010A ,
ERRINFO _CB _DESTINATION _NOT _FOUND : 0x0000400 ,
ERRINFO _CB _LOADING _DESTINATION : 0x0000402 ,
ERRINFO _CB _REDIRECTING _TO _DESTINATION : 0x0000404 ,
ERRINFO _CB _SESSION _ONLINE _VM _WAKE : 0x0000405 ,
ERRINFO _CB _SESSION _ONLINE _VM _BOOT : 0x0000406 ,
ERRINFO _CB _SESSION _ONLINE _VM _NO _DNS : 0x0000407 ,
ERRINFO _CB _DESTINATION _POOL _NOT _FREE : 0x0000408 ,
ERRINFO _CB _CONNECTION _CANCELLED : 0x0000409 ,
ERRINFO _CB _CONNECTION _ERROR _INVALID _SETTINGS : 0x0000410 ,
ERRINFO _CB _SESSION _ONLINE _VM _BOOT _TIMEOUT : 0x0000411 ,
ERRINFO _CB _SESSION _ONLINE _VM _SESSMON _FAILED : 0x0000412 ,
ERRINFO _UNKNOWNPDUTYPE2 : 0x000010C9 ,
ERRINFO _UNKNOWNPDUTYPE : 0x000010CA ,
ERRINFO _DATAPDUSEQUENCE : 0x000010CB ,
ERRINFO _CONTROLPDUSEQUENCE : 0x000010CD ,
ERRINFO _INVALIDCONTROLPDUACTION : 0x000010CE ,
ERRINFO _INVALIDINPUTPDUTYPE : 0x000010CF ,
ERRINFO _INVALIDINPUTPDUMOUSE : 0x000010D0 ,
ERRINFO _INVALIDREFRESHRECTPDU : 0x000010D1 ,
ERRINFO _CREATEUSERDATAFAILED : 0x000010D2 ,
ERRINFO _CONNECTFAILED : 0x000010D3 ,
ERRINFO _CONFIRMACTIVEWRONGSHAREID : 0x000010D4 ,
ERRINFO _CONFIRMACTIVEWRONGORIGINATOR : 0x000010D5 ,
ERRINFO _PERSISTENTKEYPDUBADLENGTH : 0x000010DA ,
ERRINFO _PERSISTENTKEYPDUILLEGALFIRST : 0x000010DB ,
ERRINFO _PERSISTENTKEYPDUTOOMANYTOTALKEYS : 0x000010DC ,
ERRINFO _PERSISTENTKEYPDUTOOMANYCACHEKEYS : 0x000010DD ,
ERRINFO _INPUTPDUBADLENGTH : 0x000010DE ,
ERRINFO _BITMAPCACHEERRORPDUBADLENGTH : 0x000010DF ,
ERRINFO _SECURITYDATATOOSHORT : 0x000010E0 ,
ERRINFO _VCHANNELDATATOOSHORT : 0x000010E1 ,
ERRINFO _SHAREDATATOOSHORT : 0x000010E2 ,
ERRINFO _BADSUPRESSOUTPUTPDU : 0x000010E3 ,
ERRINFO _CONFIRMACTIVEPDUTOOSHORT : 0x000010E5 ,
ERRINFO _CAPABILITYSETTOOSMALL : 0x000010E7 ,
ERRINFO _CAPABILITYSETTOOLARGE : 0x000010E8 ,
ERRINFO _NOCURSORCACHE : 0x000010E9 ,
ERRINFO _BADCAPABILITIES : 0x000010EA ,
ERRINFO _VIRTUALCHANNELDECOMPRESSIONERR : 0x000010EC ,
ERRINFO _INVALIDVCCOMPRESSIONTYPE : 0x000010ED ,
ERRINFO _INVALIDCHANNELID : 0x000010EF ,
ERRINFO _VCHANNELSTOOMANY : 0x000010F0 ,
ERRINFO _REMOTEAPPSNOTENABLED : 0x000010F3 ,
ERRINFO _CACHECAPNOTSET : 0x000010F4 ,
ERRINFO _BITMAPCACHEERRORPDUBADLENGTH2 : 0x000010F5 ,
ERRINFO _OFFSCRCACHEERRORPDUBADLENGTH : 0x000010F6 ,
ERRINFO _DNGCACHEERRORPDUBADLENGTH : 0x000010F7 ,
ERRINFO _GDIPLUSPDUBADLENGTH : 0x000010F8 ,
ERRINFO _SECURITYDATATOOSHORT2 : 0x00001111 ,
ERRINFO _SECURITYDATATOOSHORT3 : 0x00001112 ,
ERRINFO _SECURITYDATATOOSHORT4 : 0x00001113 ,
ERRINFO _SECURITYDATATOOSHORT5 : 0x00001114 ,
ERRINFO _SECURITYDATATOOSHORT6 : 0x00001115 ,
ERRINFO _SECURITYDATATOOSHORT7 : 0x00001116 ,
ERRINFO _SECURITYDATATOOSHORT8 : 0x00001117 ,
ERRINFO _SECURITYDATATOOSHORT9 : 0x00001118 ,
ERRINFO _SECURITYDATATOOSHORT10 : 0x00001119 ,
ERRINFO _SECURITYDATATOOSHORT11 : 0x0000111A ,
ERRINFO _SECURITYDATATOOSHORT12 : 0x0000111B ,
ERRINFO _SECURITYDATATOOSHORT13 : 0x0000111C ,
ERRINFO _SECURITYDATATOOSHORT14 : 0x0000111D ,
ERRINFO _SECURITYDATATOOSHORT15 : 0x0000111E ,
ERRINFO _SECURITYDATATOOSHORT16 : 0x0000111F ,
ERRINFO _SECURITYDATATOOSHORT17 : 0x00001120 ,
ERRINFO _SECURITYDATATOOSHORT18 : 0x00001121 ,
ERRINFO _SECURITYDATATOOSHORT19 : 0x00001122 ,
ERRINFO _SECURITYDATATOOSHORT20 : 0x00001123 ,
ERRINFO _SECURITYDATATOOSHORT21 : 0x00001124 ,
ERRINFO _SECURITYDATATOOSHORT22 : 0x00001125 ,
ERRINFO _SECURITYDATATOOSHORT23 : 0x00001126 ,
ERRINFO _BADMONITORDATA : 0x00001129 ,
ERRINFO _VCDECOMPRESSEDREASSEMBLEFAILED : 0x0000112A ,
ERRINFO _VCDATATOOLONG : 0x0000112B ,
ERRINFO _BAD _FRAME _ACK _DATA : 0x0000112C ,
ERRINFO _GRAPHICSMODENOTSUPPORTED : 0x0000112D ,
ERRINFO _GRAPHICSSUBSYSTEMRESETFAILED : 0x0000112E ,
ERRINFO _GRAPHICSSUBSYSTEMFAILED : 0x0000112F ,
ERRINFO _TIMEZONEKEYNAMELENGTHTOOSHORT : 0x00001130 ,
ERRINFO _TIMEZONEKEYNAMELENGTHTOOLONG : 0x00001131 ,
ERRINFO _DYNAMICDSTDISABLEDFIELDMISSING : 0x00001132 ,
ERRINFO _VCDECODINGERROR : 0x00001133 ,
ERRINFO _UPDATESESSIONKEYFAILED : 0x00001191 ,
ERRINFO _DECRYPTFAILED : 0x00001192 ,
ERRINFO _ENCRYPTFAILED : 0x00001193 ,
ERRINFO _ENCPKGMISMATCH : 0x00001194 ,
ERRINFO _DECRYPTFAILED2 : 0x00001195
} ;
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240576.aspx
* @ param length { integer } length of entire pdu packet
* @ param pduType { PDUType . * } type of pdu packet
* @ param userId { integer }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function shareControlHeader ( length , pduType , userId , opt ) {
var self = {
totalLength : new type . UInt16Le ( length ) ,
pduType : new type . UInt16Le ( pduType ) ,
// for xp sp3 and deactiveallpdu PDUSource may not be present
PDUSource : new type . UInt16Le ( userId , { optional : true } )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240577.aspx
* @ param length { integer } lezngth of entire packet
* @ param pduType2 { PDUType2 . * } sub PDU type
* @ param shareId { integer } global layer id
* @ param opt { object } type option
* @ returns { type . Component }
* /
function shareDataHeader ( length , pduType2 , shareId , opt ) {
var self = {
shareId : new type . UInt32Le ( shareId ) ,
pad1 : new type . UInt8 ( ) ,
streamId : new type . UInt8 ( StreamId . STREAM _LOW ) ,
uncompressedLength : new type . UInt16Le ( function ( ) {
return length . value - 8 ;
} ) ,
pduType2 : new type . UInt8 ( pduType2 ) ,
compressedType : new type . UInt8 ( ) ,
compressedLength : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240485.aspx
* @ param capabilities { type . Component } capabilities array
* @ param opt { object } type option
* @ returns { type . Component }
* /
function demandActivePDU ( capabilities , opt ) {
var self = {
_ _PDUTYPE _ _ : PDUType . PDUTYPE _DEMANDACTIVEPDU ,
shareId : new type . UInt32Le ( ) ,
lengthSourceDescriptor : new type . UInt16Le ( function ( ) {
return self . sourceDescriptor . size ( ) ;
} ) ,
lengthCombinedCapabilities : new type . UInt16Le ( function ( ) {
return self . numberCapabilities . size ( ) + self . pad2Octets . size ( ) + self . capabilitySets . size ( ) ;
} ) ,
sourceDescriptor : new type . BinaryString ( Buffer . from ( 'node-rdpjs' , 'binary' ) , { readLength : new type . CallableValue ( function ( ) {
return self . lengthSourceDescriptor . value
} ) } ) ,
numberCapabilities : new type . UInt16Le ( function ( ) {
return self . capabilitySets . obj . length ;
} ) ,
pad2Octets : new type . UInt16Le ( ) ,
capabilitySets : capabilities || new type . Factory ( function ( s ) {
self . capabilitySets = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numberCapabilities . value ; i ++ ) {
self . capabilitySets . obj . push ( caps . capability ( ) . read ( s ) )
}
} ) ,
sessionId : new type . UInt32Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240488.aspx
* @ param capabilities { type . Component } capabilities array
* @ param shareId { integer } session id
* @ param opt { object } type option
* @ returns { type . Component }
* /
function confirmActivePDU ( capabilities , shareId , opt ) {
var self = {
_ _PDUTYPE _ _ : PDUType . PDUTYPE _CONFIRMACTIVEPDU ,
shareId : new type . UInt32Le ( shareId ) ,
originatorId : new type . UInt16Le ( 0x03EA , { constant : true } ) ,
lengthSourceDescriptor : new type . UInt16Le ( function ( ) {
return self . sourceDescriptor . size ( ) ;
} ) ,
lengthCombinedCapabilities : new type . UInt16Le ( function ( ) {
return self . numberCapabilities . size ( ) + self . pad2Octets . size ( ) + self . capabilitySets . size ( ) ;
} ) ,
sourceDescriptor : new type . BinaryString ( Buffer . from ( 'rdpy' , 'binary' ) , { readLength : new type . CallableValue ( function ( ) {
return self . lengthSourceDescriptor . value
} ) } ) ,
numberCapabilities : new type . UInt16Le ( function ( ) {
return self . capabilitySets . obj . length ;
} ) ,
pad2Octets : new type . UInt16Le ( ) ,
capabilitySets : capabilities || new type . Factory ( function ( s ) {
self . capabilitySets = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numberCapabilities . value ; i ++ ) {
self . capabilitySets . obj . push ( caps . capability ( ) . read ( s ) )
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240536.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function deactiveAllPDU ( opt ) {
var self = {
_ _PDUTYPE _ _ : PDUType . PDUTYPE _DEACTIVATEALLPDU ,
shareId : new type . UInt32Le ( ) ,
lengthSourceDescriptor : new type . UInt16Le ( function ( ) {
return self . sourceDescriptor . size ( ) ;
} ) ,
sourceDescriptor : new type . BinaryString ( Buffer . from ( 'rdpy' , 'binary' ) , { readLength : new type . CallableValue ( function ( ) {
self . lengthSourceDescriptor
} ) } )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240490.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function synchronizeDataPDU ( targetUser , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _SYNCHRONIZE ,
messageType : new type . UInt16Le ( 1 , { constant : true } ) ,
targetUser : new type . UInt16Le ( targetUser )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240492.aspx
* @ param action { integer }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function controlDataPDU ( action , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _CONTROL ,
action : new type . UInt16Le ( action ) ,
grantId : new type . UInt16Le ( ) ,
controlId : new type . UInt32Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240544.aspx
* @ param errorInfo { integer }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function errorInfoDataPDU ( errorInfo , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _SET _ERROR _INFO _PDU ,
errorInfo : new type . UInt32Le ( errorInfo )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240498.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function fontListDataPDU ( opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _FONTLIST ,
numberFonts : new type . UInt16Le ( ) ,
totalNumFonts : new type . UInt16Le ( ) ,
listFlags : new type . UInt16Le ( 0x0003 ) ,
entrySize : new type . UInt16Le ( 0x0032 )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240498.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function fontMapDataPDU ( opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _FONTMAP ,
numberEntries : new type . UInt16Le ( ) ,
totalNumEntries : new type . UInt16Le ( ) ,
mapFlags : new type . UInt16Le ( 0x0003 ) ,
entrySize : new type . UInt16Le ( 0x0004 )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240496.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function persistentListEntry ( opt ) {
var self = {
key1 : new type . UInt32Le ( ) ,
key2 : new type . UInt32Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240495.aspx
* @ param entries { type . Component }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function persistentListPDU ( entries , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _BITMAPCACHE _PERSISTENT _LIST ,
numEntriesCache0 : new type . UInt16Le ( ) ,
numEntriesCache1 : new type . UInt16Le ( ) ,
numEntriesCache2 : new type . UInt16Le ( ) ,
numEntriesCache3 : new type . UInt16Le ( ) ,
numEntriesCache4 : new type . UInt16Le ( ) ,
totalEntriesCache0 : new type . UInt16Le ( ) ,
totalEntriesCache1 : new type . UInt16Le ( ) ,
totalEntriesCache2 : new type . UInt16Le ( ) ,
totalEntriesCache3 : new type . UInt16Le ( ) ,
totalEntriesCache4 : new type . UInt16Le ( ) ,
bitMask : new type . UInt8 ( ) ,
pad2 : new type . UInt8 ( ) ,
pad3 : new type . UInt16Le ( ) ,
entries : entries || new type . Factory ( function ( s ) {
var numEntries = self . numEntriesCache0 . value + self . numEntriesCache1 . value + self . numEntriesCache2 . value + self . numEntriesCache3 . value + self . numEntriesCache4 . value ;
self . entries = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < numEntries ; i ++ ) {
self . entries . obj . push ( persistentListEntry ( ) . read ( s ) ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see https : //msdn.microsoft.com/en-us/library/cc240588.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function synchronizeEvent ( opt ) {
var self = {
_ _INPUT _MESSAGE _TYPE _ _ : InputMessageType . INPUT _EVENT _SYNC ,
pad2Octets : new type . UInt16Le ( ) ,
toggleFlags : new type . UInt32Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240586.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function pointerEvent ( opt ) {
var self = {
_ _INPUT _MESSAGE _TYPE _ _ : InputMessageType . INPUT _EVENT _MOUSE ,
pointerFlags : new type . UInt16Le ( ) ,
xPos : new type . UInt16Le ( ) ,
yPos : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240584.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function scancodeKeyEvent ( opt ) {
var self = {
_ _INPUT _MESSAGE _TYPE _ _ : InputMessageType . INPUT _EVENT _SCANCODE ,
keyboardFlags : new type . UInt16Le ( ) ,
keyCode : new type . UInt16Le ( ) ,
pad2Octets : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240585.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function unicodeKeyEvent ( opt ) {
var self = {
_ _INPUT _MESSAGE _TYPE _ _ : InputMessageType . INPUT _EVENT _UNICODE ,
keyboardFlags : new type . UInt16Le ( ) ,
unicode : new type . UInt16Le ( ) ,
pad2Octets : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240583.aspx
* @ param slowPathInputData { type . Component } message generate for slow path input event
* @ param opt { object } type option
* @ returns { type . Component }
* /
function slowPathInputEvent ( slowPathInputData , opt ) {
var self = {
eventTime : new type . UInt32Le ( ) ,
messageType : new type . UInt16Le ( function ( ) {
return self . slowPathInputData . obj . _ _INPUT _MESSAGE _TYPE _ _ ;
} ) ,
slowPathInputData : slowPathInputData || new type . Factory ( function ( s ) {
switch ( self . messageType . value ) {
case InputMessageType . INPUT _EVENT _SYNC :
self . slowPathInputData = synchronizeEvent ( ) . read ( s ) ;
break ;
case InputMessageType . INPUT _EVENT _MOUSE :
self . slowPathInputData = pointerEvent ( ) . read ( s ) ;
break ;
case InputMessageType . INPUT _EVENT _SCANCODE :
self . slowPathInputData = scancodeKeyEvent ( ) . read ( s ) ;
break ;
case InputMessageType . INPUT _EVENT _UNICODE :
self . slowPathInputData = unicodeKeyEvent ( ) . read ( s ) ;
break ;
default :
log . error ( 'unknown slowPathInputEvent ' + self . messageType . value ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc746160.aspx
* @ param inputs { type . Component } list of inputs
* @ param opt { object } type option
* @ returns { type . Component }
* /
function clientInputEventPDU ( inputs , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _INPUT ,
numEvents : new type . UInt16Le ( function ( ) {
return self . slowPathInputEvents . obj . length ;
} ) ,
pad2Octets : new type . UInt16Le ( ) ,
slowPathInputEvents : inputs || new type . Factory ( function ( s ) {
self . slowPathInputEvents = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numEvents . value ; i ++ ) {
self . slowPathInputEvents . obj . push ( slowPathInputEvent ( ) . read ( s ) ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ param opt { object } type option
* @ returns { type . Component }
* /
function shutdownRequestPDU ( opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _SHUTDOWN _REQUEST
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ param opt { object } type option
* @ returns { type . Component }
* /
function shutdownDeniedPDU ( opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _SHUTDOWN _DENIED
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240643.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function inclusiveRectangle ( opt ) {
var self = {
left : new type . UInt16Le ( ) ,
top : new type . UInt16Le ( ) ,
right : new type . UInt16Le ( ) ,
bottom : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240648.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function supressOutputDataPDU ( opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _SUPPRESS _OUTPUT ,
allowDisplayUpdates : new type . UInt8 ( ) ,
pad3Octets : new type . Component ( [ new type . UInt8 ( ) , new type . UInt8 ( ) , new type . UInt8 ( ) ] ) ,
desktopRect : inclusiveRectangle ( { conditional : function ( ) {
return self . allowDisplayUpdates . value === Display . ALLOW _DISPLAY _UPDATES ;
} } )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240646.aspx
* @ param rectangles { type . Component } list of inclusive rectangles
* @ param opt { object } type option
* @ returns { type . Component }
* /
function refreshRectPDU ( rectangles , opt ) {
var self = {
_ _PDUTYPE2 _ _ : PDUType2 . PDUTYPE2 _REFRESH _RECT ,
numberOfAreas : UInt8 ( function ( ) {
return self . areasToRefresh . obj . length ;
} ) ,
pad3Octets : new type . Component ( [ new type . UInt8 ( ) , new type . UInt8 ( ) , new type . UInt8 ( ) ] ) ,
areasToRefresh : rectangles || new type . Factory ( function ( s ) {
self . areasToRefresh = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numberOfAreas . value ; i ++ ) {
self . areasToRefresh . obj . push ( inclusiveRectangle ( ) . read ( s ) ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240644.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function bitmapCompressedDataHeader ( opt ) {
var self = {
cbCompFirstRowSize : new type . UInt16Le ( 0x0000 , { constant : true } ) ,
// compressed data size
cbCompMainBodySize : new type . UInt16Le ( ) ,
cbScanWidth : new type . UInt16Le ( ) ,
// uncompressed data size
cbUncompressedSize : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see
* @ param coord { object }
* . destLeft { integer }
* . destTop { integer }
* . destRight { integer }
* . destBottom { integer }
* . width { integer }
* . height { integer }
* . bitsPerPixel { integer }
* . data { Buffer }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function bitmapData ( coord , opt ) {
coord = coord || { } ;
var self = {
destLeft : new type . UInt16Le ( coord . destLeft ) ,
destTop : new type . UInt16Le ( coord . destTop ) ,
destRight : new type . UInt16Le ( coord . destRight ) ,
destBottom : new type . UInt16Le ( coord . destBottom ) ,
width : new type . UInt16Le ( coord . width ) ,
height : new type . UInt16Le ( coord . height ) ,
bitsPerPixel : new type . UInt16Le ( coord . bitsPerPixel ) ,
flags : new type . UInt16Le ( ) ,
bitmapLength : new type . UInt16Le ( function ( ) {
return self . bitmapComprHdr . size ( ) + self . bitmapDataStream . size ( ) ;
} ) ,
bitmapComprHdr : bitmapCompressedDataHeader ( { conditional : function ( ) {
return ( self . flags . value & BitmapFlag . BITMAP _COMPRESSION ) && ! ( self . flags . value & BitmapFlag . NO _BITMAP _COMPRESSION _HDR ) ;
} } ) ,
bitmapDataStream : new type . BinaryString ( coord . data , { readLength : new type . CallableValue ( function ( ) {
if ( ! self . flags . value & BitmapFlag . BITMAP _COMPRESSION || ( self . flags . value & BitmapFlag . NO _BITMAP _COMPRESSION _HDR ) ) {
return self . bitmapLength . value ;
}
else {
return self . bitmapComprHdr . cbCompMainBodySize . value ;
}
} ) } )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/dd306368.aspx
* @ param data { type . Component } list of bitmap data type
* @ param opt { object } type option
* @ returns { type . Component }
* /
function bitmapUpdateDataPDU ( data , opt ) {
var self = {
_ _UPDATE _TYPE _ _ : UpdateType . UPDATETYPE _BITMAP ,
numberRectangles : new type . UInt16Le ( function ( ) {
return self . rectangles . obj . length ;
} ) ,
rectangles : data || new type . Factory ( function ( s ) {
self . rectangles = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numberRectangles . value ; i ++ ) {
self . rectangles . obj . push ( bitmapData ( ) . read ( s ) ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see https : //msdn.microsoft.com/en-us/library/cc240613.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
function synchronizeUpdateDataPDU ( opt ) {
var self = {
pad2Octets : new type . UInt16Le ( )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240608.aspx
* @ param updateData { type . Component } update data ( ex : bitmapUpdateDataPDU )
* @ param opt { object } type option
* @ returns { type . Component }
* /
function updateDataPDU ( updateData , opt ) {
var self = {
_ _PDUTYPE2 _ : PDUType2 . PDUTYPE2 _UPDATE _ _ ,
updateType : new type . UInt16Le ( function ( ) {
return self . updateData . obj . _ _UPDATE _TYPE _ _ ;
} ) ,
updateData : updateData || new type . Factory ( function ( s ) {
var options = { readLength : new type . CallableValue ( function ( ) {
return opt . readLength . value - 2 ;
} ) } ;
switch ( self . updateType . value ) {
case UpdateType . UPDATETYPE _BITMAP :
self . updateData = bitmapUpdateDataPDU ( null , options ) . read ( s ) ;
break ;
case UpdateType . UPDATETYPE _SYNCHRONIZE :
// do nothing artefact of protocol
self . updateData = synchronizeUpdateDataPDU ( null , options ) . read ( s ) ;
break ;
default :
self . updateData = new type . BinaryString ( null , options ) . read ( s ) ;
log . debug ( 'unknown updateDataPDU ' + self . updateType . value ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ param pduData { type . Component }
* @ param shareId { integer }
* @ param opt { object } type option
* @ returns { type . Component }
* /
function dataPDU ( pduData , shareId , opt ) {
var self = {
_ _PDUTYPE _ _ : PDUType . PDUTYPE _DATAPDU ,
shareDataHeader : shareDataHeader ( new type . CallableValue ( function ( ) {
return new type . Component ( self ) . size ( ) ;
} ) , function ( ) {
return self . pduData . obj . _ _PDUTYPE2 _ _ ;
} , shareId ) ,
pduData : pduData || new type . Factory ( function ( s ) {
//compute local readLength
var options = { readLength : new type . CallableValue ( function ( ) {
return opt . readLength . value - self . shareDataHeader . size ( ) ;
} ) } ;
switch ( self . shareDataHeader . obj . pduType2 . value ) {
case PDUType2 . PDUTYPE2 _SYNCHRONIZE :
self . pduData = synchronizeDataPDU ( null , options ) . read ( s )
break ;
case PDUType2 . PDUTYPE2 _CONTROL :
self . pduData = controlDataPDU ( null , options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _SET _ERROR _INFO _PDU :
self . pduData = errorInfoDataPDU ( null , options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _FONTLIST :
self . pduData = fontListDataPDU ( options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _FONTMAP :
self . pduData = fontMapDataPDU ( options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _BITMAPCACHE _PERSISTENT _LIST :
self . pduData = persistentListPDU ( null , options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _INPUT :
self . pduData = clientInputEventPDU ( null , options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _SHUTDOWN _REQUEST :
self . pduData = shutdownRequestPDU ( options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _SHUTDOWN _DENIED :
self . pduData = shutdownDeniedPDU ( options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _SUPPRESS _OUTPUT :
self . pduData = supressOutputDataPDU ( options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _REFRESH _RECT :
self . pduData = refreshRectPDU ( null , options ) . read ( s ) ;
break ;
case PDUType2 . PDUTYPE2 _UPDATE :
self . pduData = updateDataPDU ( null , options ) . read ( s ) ;
break ;
default :
self . pduData = new type . BinaryString ( null , options ) . read ( s ) ;
log . debug ( 'unknown PDUType2 ' + self . shareDataHeader . obj . pduType2 . value ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* @ param userId { integer }
* @ param pduMessage { type . Component } pdu message
* @ param opt { object } type option
* @ returns { type . Component }
* /
function pdu ( userId , pduMessage , opt ) {
var self = {
shareControlHeader : shareControlHeader ( function ( ) {
return new type . Component ( self ) . size ( ) ;
} , function ( ) {
return pduMessage . obj . _ _PDUTYPE _ _ ;
} , userId ) ,
pduMessage : pduMessage || new type . Factory ( function ( s ) {
// compute local common options
var options = { readLength : new type . CallableValue ( function ( ) {
return self . shareControlHeader . obj . totalLength . value - self . shareControlHeader . size ( ) ;
} ) } ;
switch ( self . shareControlHeader . obj . pduType . value ) {
case PDUType . PDUTYPE _DEMANDACTIVEPDU :
self . pduMessage = demandActivePDU ( null , options ) . read ( s ) ;
break ;
case PDUType . PDUTYPE _CONFIRMACTIVEPDU :
self . pduMessage = confirmActivePDU ( null , options ) . read ( s ) ;
break ;
case PDUType . PDUTYPE _DEACTIVATEALLPDU :
self . pduMessage = deactiveAllPDU ( options ) . read ( s ) ;
break ;
case PDUType . PDUTYPE _DATAPDU :
self . pduMessage = dataPDU ( null , null , options ) . read ( s ) ;
break ;
default :
self . pduMessage = new type . BinaryString ( null , options ) . read ( s ) ;
log . debug ( 'unknown pdu type ' + self . shareControlHeader . obj . pduType . value ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
2022-05-15 02:00:57 -04:00
const ClipPDUMsgType = {
CB _MONITOR _READY : 0x0001 ,
CB _FORMAT _LIST : 0x0002 ,
CB _FORMAT _LIST _RESPONSE : 0x0003 ,
CB _FORMAT _DATA _REQUEST : 0x0004 ,
CB _FORMAT _DATA _RESPONSE : 0x0005 ,
CB _TEMP _DIRECTORY : 0x0006 ,
CB _CLIP _CAPS : 0x0007 ,
CB _FILECONTENTS _REQUEST : 0x0008
}
/ * *
* @ returns { type . Component }
* /
function clipPDU ( ) {
const self = {
header : new type . Factory ( function ( s ) {
self . header = new type . Component ( {
msgType : new type . UInt16Le ( ) . read ( s ) ,
msgFlags : new type . UInt16Le ( ) . read ( s ) ,
dataLen : new type . UInt32Le ( ) . read ( s )
} )
} )
}
return new type . Component ( self ) ;
}
2022-04-29 14:13:58 -04:00
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/dd306368.aspx
* @ param opt { object } type option
* @ returns { type . Component }
* /
2022-06-24 01:10:07 -04:00
function fastPathBitmapUpdateDataPDU ( opt ) {
2022-04-29 14:13:58 -04:00
var self = {
_ _FASTPATH _UPDATE _TYPE _ _ : FastPathUpdateType . FASTPATH _UPDATETYPE _BITMAP ,
header : new type . UInt16Le ( FastPathUpdateType . FASTPATH _UPDATETYPE _BITMAP , { constant : true } ) ,
numberRectangles : new type . UInt16Le ( function ( ) {
return self . rectangles . obj . length ;
} ) ,
rectangles : new type . Factory ( function ( s ) {
self . rectangles = new type . Component ( [ ] ) ;
for ( var i = 0 ; i < self . numberRectangles . value ; i ++ ) {
self . rectangles . obj . push ( bitmapData ( ) . read ( s ) ) ;
}
} )
} ;
return new type . Component ( self , opt ) ;
}
2022-06-24 01:10:07 -04:00
// This is a table of cursorid to cursor name.
// Created by movering the mouse over this page: https://www.w3schools.com/csSref/tryit.asp?filename=trycss_cursor
const cursorIdTable = {
// Normal style mouse cursor
903013897 : 'alias' ,
370524792 : 'all-scroll' ,
853046751 : 'cell' ,
2101250798 : 'col-resize' ,
703681364 : 'copy' ,
992638936 : 'crosshair' ,
1539083673 : 'ew-resize' ,
1919796298 : 'grab' ,
1010243511 : 'grabbing' ,
1247283057 : 'help' ,
1390892051 : 'none' ,
885751489 : 'not-allowed' ,
1732952247 : 'row-resize' ,
747144997 : 'url' ,
2018345610 : 'zoom-in' ,
347367048 : 'zoom-out' ,
1872942890 : 'default' ,
1737852989 : 'text' ,
1932827019 : 'ns-resize' ,
1884471290 : 'nesw-resize' ,
1204065391 : 'nwse-resize' ,
2030531519 : 'progress' ,
1050842114 : 'pointer' ,
// Black style cursors
1258195498 : 'default' ,
219484254 : 'all-scroll' ,
399295089 : 'text' ,
1912613597 : 'wait' ,
864127801 : 'ew-resize' ,
23245044 : 'nesw-resize' ,
1966995494 : 'not-allowed' ,
1873216615 : 'help' ,
255126408 : 'nesw-resize' ,
157191894 : 'ns-resize' ,
1768446509 : 'pointer' ,
1032011501 : 'crosshair'
}
function fastPathPointerUpdateDataPDU ( opt , cursorId , cursorStr ) {
var self = {
_ _FASTPATH _UPDATE _TYPE _ _ : FastPathUpdateType . FASTPATH _UPDATETYPE _COLOR ,
header : new type . UInt16Le ( FastPathUpdateType . FASTPATH _UPDATETYPE _COLOR , { constant : true } ) ,
cursorId : cursorId ,
cursorStr : cursorStr
} ;
return new type . Component ( self , opt ) ;
}
2022-04-29 14:13:58 -04:00
/ * *
* @ see http : //msdn.microsoft.com/en-us/library/cc240622.aspx
* @ param updateData { type . Component }
* @ param opt { object } type option
* @ returns { type . Component }
* /
2022-06-24 01:10:07 -04:00
function fastPathUpdatePDU ( updateData , opt ) {
2022-04-29 14:13:58 -04:00
var self = {
updateHeader : new type . UInt8 ( function ( ) {
return self . updateData . obj . _ _FASTPATH _UPDATE _TYPE _ _ ;
} ) ,
compressionFlags : new type . UInt8 ( null , { conditional : function ( ) {
return ( self . updateHeader . value >> 4 ) & FastPathOutputCompression . FASTPATH _OUTPUT _COMPRESSION _USED ;
} } ) ,
size : new type . UInt16Le ( function ( ) {
return self . updateData . size ( ) ;
} ) ,
updateData : updateData || new type . Factory ( function ( s ) {
var options = { readLength : new type . CallableValue ( function ( ) {
return self . size . value ;
} ) } ;
switch ( self . updateHeader . value & 0xf ) {
2022-06-24 01:10:07 -04:00
case FastPathUpdateType . FASTPATH _UPDATETYPE _BITMAP : {
self . updateData = fastPathBitmapUpdateDataPDU ( options ) . read ( s ) ;
break ;
}
case FastPathUpdateType . FASTPATH _UPDATETYPE _COLOR : {
var data = new type . BinaryString ( null , options ) . read ( s ) ;
// Hash the data to get a cursor id.
// This is a hack since the cursor bitmap is sent but we can't use that, we has hash the bitmap and use that as a hint as to what cursor we need to display
const hasher = require ( 'crypto' ) . createHash ( 'sha384' ) ;
hasher . update ( data . value ) ;
const cursorid = Math . abs ( hasher . digest ( ) . readInt32BE ( 0 ) ) ;
const cursorStr = cursorIdTable [ cursorid ] ;
//if (cursorStr == null) { console.log('Unknown cursorId: ' + cursorid); }
self . updateData = fastPathPointerUpdateDataPDU ( options , cursorid , cursorStr ) ;
break ;
}
default : {
self . updateData = new type . BinaryString ( null , options ) . read ( s ) ;
log . debug ( 'unknown fast path pdu type ' + ( self . updateHeader . value & 0xf ) ) ;
}
2022-04-29 14:13:58 -04:00
}
} )
} ;
return new type . Component ( self , opt ) ;
}
/ * *
* Module exports
* /
module . exports = {
PDUType : PDUType ,
PDUType2 : PDUType2 ,
StreamId : StreamId ,
CompressionOrder : CompressionOrder ,
CompressionType : CompressionType ,
Action : Action ,
PersistentKeyListFlag : PersistentKeyListFlag ,
BitmapFlag : BitmapFlag ,
UpdateType : UpdateType ,
InputMessageType : InputMessageType ,
PointerFlag : PointerFlag ,
KeyboardFlag : KeyboardFlag ,
FastPathOutputCompression : FastPathOutputCompression ,
Display : Display ,
ToogleFlag : ToogleFlag ,
ErrorInfo : ErrorInfo ,
FastPathUpdateType : FastPathUpdateType ,
shareControlHeader : shareControlHeader ,
shareDataHeader : shareDataHeader ,
demandActivePDU : demandActivePDU ,
confirmActivePDU : confirmActivePDU ,
deactiveAllPDU : deactiveAllPDU ,
pdu : pdu ,
synchronizeDataPDU : synchronizeDataPDU ,
controlDataPDU : controlDataPDU ,
errorInfoDataPDU : errorInfoDataPDU ,
fontListDataPDU : fontListDataPDU ,
fontMapDataPDU : fontMapDataPDU ,
persistentListPDU : persistentListPDU ,
synchronizeEvent : synchronizeEvent ,
pointerEvent : pointerEvent ,
scancodeKeyEvent : scancodeKeyEvent ,
unicodeKeyEvent : unicodeKeyEvent ,
slowPathInputEvent : slowPathInputEvent ,
clientInputEventPDU : clientInputEventPDU ,
shutdownRequestPDU : shutdownRequestPDU ,
shutdownDeniedPDU : shutdownDeniedPDU ,
supressOutputDataPDU : supressOutputDataPDU ,
refreshRectPDU : refreshRectPDU ,
bitmapData : bitmapData ,
bitmapUpdateDataPDU : bitmapUpdateDataPDU ,
updateDataPDU : updateDataPDU ,
dataPDU : dataPDU ,
fastPathBitmapUpdateDataPDU : fastPathBitmapUpdateDataPDU ,
2022-05-15 02:00:57 -04:00
fastPathUpdatePDU : fastPathUpdatePDU ,
clipPDU : clipPDU ,
ClipPDUMsgType : ClipPDUMsgType
2022-04-29 14:13:58 -04:00
} ;