Best Python code snippet using fMBT_python
fmbtrdp.py
Source:fmbtrdp.py
...75UINT32 = ctypes.c_uint3276UINT64 = ctypes.c_uint6477VOID_P = ctypes.c_void_p78VOID_PP = ctypes.POINTER(VOID_P)79def _align64(field_name, field_type, offset64=None):80 rv = []81 if offset64 == None:82 offset64 = (_align64.offset8 + 7) / 883 if _align64.offset8 < offset64 * 8:84 rv += [("_padding%s" % (str(offset64).zfill(4)),85 ctypes.c_uint8 * (offset64 * 8 - _align64.offset8))]86 _align64.offset8 = offset64 * 887 elif _align64.offset8 > offset64 * 8:88 raise ValueError("Struct filled up to 64-bit block %s, invalid offset: %s" %89 (_align64.offset8 / 8.0, offset64))90 rv += [(field_name, field_type)]91 _align64.offset8 += ctypes.sizeof(field_type)92 return rv93#### Colors, freerdp/codec/color.h94CLRCONV_ALPHA = 195CLRCONV_INVERT = 296CLRCONV_RGB555 = 497CLRBUF_16BPP = 898CLRBUF_24BPP = 1699CLRBUF_32BPP = 32100#### Settings, freerdp/settings.h101# Encryption Methods102ENCRYPTION_METHOD_NONE = 0x00000000103ENCRYPTION_METHOD_40BIT = 0x00000001104ENCRYPTION_METHOD_128BIT = 0x00000002105ENCRYPTION_METHOD_56BIT = 0x00000008106ENCRYPTION_METHOD_FIPS = 0x00000010107# Encryption Levels108ENCRYPTION_LEVEL_NONE = 0x00000000109ENCRYPTION_LEVEL_LOW = 0x00000001110ENCRYPTION_LEVEL_CLIENT_COMPATIBLE = 0x00000002111ENCRYPTION_LEVEL_HIGH = 0x00000003112ENCRYPTION_LEVEL_FIPS = 0x00000004113# struct rdp_setting, incomplete, trying out basic stuff114_align64.offset8 = 0115class RdpSettings(ctypes.Structure):116 _fields_ = (117 _align64("instance", VOID_P) +118 # Core Parameters119 _align64("ServerMode", BOOL, 16) +120 _align64("ShareId", UINT32, 17) +121 _align64("PduSource", UINT32, 18) +122 _align64("ServerPort", UINT32, 19) +123 _align64("ServerHostname", CHAR_P, 20) +124 _align64("Username", CHAR_P, 21) +125 _align64("Password", CHAR_P, 22) +126 _align64("Domain", CHAR_P, 23) +127 _align64("PasswordHash", CHAR_P, 24) +128 _align64("WaitForOutputBufferFlush", BOOL, 25) +129 # Client/Server Core Data130 _align64("RdpVersion", UINT32, 128) +131 _align64("DesktopWidth", UINT32, 129) +132 _align64("DesktopHeight", UINT32, 130) +133 _align64("ColorDepth", UINT32, 131) +134 _align64("ConnectionType", UINT32, 132) +135 _align64("ClientBuild", UINT32, 133) +136 _align64("ClientHostname", CHAR_P, 134) +137 _align64("ClientProductId", CHAR_P, 135) +138 _align64("EarlyCapabilityFlags", UINT32, 136) +139 _align64("NetworkAutoDetect", BOOL, 137) +140 _align64("SupportAsymetricKeys", BOOL, 138) +141 _align64("SupportErrorInfoPdu", BOOL, 139) +142 _align64("SupportStatusInfoPdu", BOOL, 140) +143 _align64("SupportMonitorLayoutPdu", BOOL, 141) +144 _align64("SupportGraphicsPipeline", BOOL, 142) +145 _align64("SupportDynamicTimeZone", BOOL, 143) +146 _align64("SupportHeartbeatPdu", BOOL, 144) +147 # Client/Server Security Data148 _align64("DisableEncryption", BOOL, 192) +149 _align64("EncryptionMethods", UINT32, 193) +150 _align64("ExtEncryptionMethods", UINT32, 194) +151 _align64("EncryptionLevel", UINT32, 195) +152 _align64("ServerRandom", BYTE_P, 196) +153 _align64("ServerRandomLength", UINT32, 197) +154 _align64("ServerCertificate", BYTE_P, 198) +155 _align64("ServerCertificateLength", UINT32, 199) +156 _align64("ClientRandom", BYTE_P, 200) +157 _align64("ClientRandomLength", UINT32, 201) +158 # Protocol Security159 _align64("TlsSecurity", BOOL, 1088) +160 _align64("NlaSecurity", BOOL, 1089) +161 _align64("RdpSecurity", BOOL, 1090) +162 _align64("ExtSecurity", BOOL, 1091) +163 _align64("Authentication", BOOL, 1092) +164 _align64("RequestedProtocols", UINT32, 1093) +165 _align64("SelectedProtocol", UINT32, 1094) +166 _align64("NegotiationFlags", UINT32, 1095) +167 _align64("NegotiateSecurityLayer", BOOL, 1096) +168 _align64("RestrictedAdminModeRequired", BOOL, 1097) +169 _align64("AuthenticationServiceClass", CHAR_P, 1098) +170 _align64("DisableCredentialsDelegation", BOOL, 1099) +171 _align64("AuthenticationLevel", BOOL, 1100) +172 _align64("PermittedTLSCiphers", CHAR_P, 1101) +173 # Window Settings174 _align64("Workarea", BOOL, 1536) +175 _align64("Fullscreen", BOOL, 1537) +176 _align64("PercentScreen", UINT32, 1538) +177 _align64("GrabKeyboard", BOOL, 1539) +178 _align64("Decorations", BOOL, 1540) +179 _align64("MouseMotion", BOOL, 1541) +180 _align64("WindowTitle", CHAR_P, 1542) +181 _align64("ParentWindowId", UINT64, 1543) +182 _align64("AsyncInput", BOOL, 1544) +183 _align64("AsyncUpdate", BOOL, 1545) +184 _align64("AsyncChannels", BOOL, 1546) +185 _align64("AsyncTransport", BOOL, 1547) +186 _align64("ToggleFullscreen", BOOL, 1548) +187 _align64("WmClass", CHAR_P, 1549) +188 _align64("EmbeddedWindow", BOOL, 1550) +189 _align64("SmartSizing", BOOL, 1551) +190 _align64("XPan", INT, 1552) +191 _align64("YPan", INT, 1553) +192 _align64("ScalingFactor", DOUBLE, 1554) +193 # Input Capabilities194 _align64("KeyboardLayout", UINT32, 2624) +195 _align64("KeyboardType", UINT32, 2625) +196 _align64("KeyboardSubType", UINT32, 2626) +197 _align64("KeyboardFunctionKey", UINT32, 2627) +198 _align64("ImeFileName", CHAR_P, 2628) +199 _align64("UnicodeInput", BOOL, 2629) +200 _align64("FastPathInput", BOOL, 2630) +201 _align64("MultiTouchInput", BOOL, 2631) +202 _align64("MultiTouchGestures", BOOL, 2632) +203 _align64("KeyboardHook", UINT32, 2633)204 )205RdpSettings_P = ctypes.POINTER(RdpSettings)206# Adding stuff to structs:207# query-replace-regexp208# ALIGN64 \([^ ]*\) \([^; ]*\); /\* \([0-9]*\) \*/209# ->210# _align64("\2", \1, \3) +211#### Input, freerdp/input.h212# keyboard Flags213KBD_FLAGS_EXTENDED = 0x0100214KBD_FLAGS_DOWN = 0x4000215KBD_FLAGS_RELEASE = 0x8000216# Pointer Flags217PTR_FLAGS_WHEEL = 0x0200218PTR_FLAGS_WHEEL_NEGATIVE = 0x0100219PTR_FLAGS_MOVE = 0x0800220PTR_FLAGS_DOWN = 0x8000221PTR_FLAGS_BUTTON1 = 0x1000222PTR_FLAGS_BUTTON2 = 0x2000223PTR_FLAGS_BUTTON3 = 0x4000224WheelRotationMask = 0x01FF225# Extended Pointer Flags226PTR_XFLAGS_DOWN = 0x8000227PTR_XFLAGS_BUTTON1 = 0x0001228PTR_XFLAGS_BUTTON2 = 0x0002229# Keyboard Toggle Flags230KBD_SYNC_SCROLL_LOCK = 0x00000001231KBD_SYNC_NUM_LOCK = 0x00000002232KBD_SYNC_CAPS_LOCK = 0x00000004233KBD_SYNC_KANA_LOCK = 0x00000008234RDP_CLIENT_INPUT_PDU_HEADER_LENGTH = 4235# Pointers to these structs are needed before definition of the struct236class RdpContext(ctypes.Structure):237 pass238class RdpGdi(ctypes.Structure):239 pass240class RdpInput(ctypes.Structure):241 pass242class RdpFreerdp(ctypes.Structure):243 pass244RdpContext_P = ctypes.POINTER(RdpContext)245RdpGdi_P = ctypes.POINTER(RdpGdi)246RdpInput_P = ctypes.POINTER(RdpInput)247RdpFreerdp_P = ctypes.POINTER(RdpFreerdp)248RdppSynchronizeEvent = ctypes.CFUNCTYPE(None, RdpInput_P, UINT32) # input, flags249RdppKeyboardEvent = ctypes.CFUNCTYPE(None, RdpInput_P, UINT16, UINT16) # input, flags, code250RdppUnicodeKeyboardEvent = ctypes.CFUNCTYPE(None, RdpInput_P, UINT16, UINT16) # input, flags, code251RdppMouseEvent = ctypes.CFUNCTYPE(None, RdpInput_P, UINT16, UINT16, UINT16) # input, flags, x, y252RdppExtendedMouseEvent = ctypes.CFUNCTYPE(None, RdpInput_P, UINT16, UINT16, UINT16) # input, flags, x, y253# struct rdp_input254_align64.offset8 = 0255RdpInput._fields_ = (256 _align64("context", RdpContext_P) +257 _align64("param1", VOID_P, 1) +258 _align64("SynchronizeEvent", RdppSynchronizeEvent, 16) +259 _align64("KeyboardEvent", RdppKeyboardEvent, 17) +260 _align64("UnicodeKeyboardEvent", RdppUnicodeKeyboardEvent, 18) +261 _align64("MouseEvent", RdppMouseEvent, 19) +262 _align64("ExtendedMouseEvent", RdppExtendedMouseEvent, 20)263)264#### GDI, see freerdp/freerdp.h265# struct rdp_gdi266_align64.offset8 = 0267RdpGdi._fields_ = (268 ("context", RdpContext_P),269 ("width", INT),270 ("height", INT),271 ("dstBpp", INT),272 ("srcBpp", INT),273 ("cursor_x", INT),274 ("cursor_y", INT),275 ("bytesPerPixel", INT),276 ("hdc", VOID_P), # HGDI_DC277 ("clrconv", VOID_P), # HCLRCONV278 ("primary", VOID_P), # gdiBitmap*279 ("drawing", VOID_P), # gdiBitmap*280 ("primary_buffer", BYTE_P), # BYTE_P281 ("textColor", UINT),282 ("rfx_context", VOID_P),283 ("nsc_context", VOID_P),284 ("tile", VOID_P), # gdiBitmap*285 ("image", VOID_P) # gdiBitmap*286)287#### Core, see freerdp/freerdp.h288# struct rdp_context289_align64.offset8 = 0290RdpContext._fields_ = (291 _align64("instance", RdpFreerdp_P, 0) +292 _align64("peer", VOID_P, 1) + # freerdp_peer*293 _align64("ServerMode", BOOL, 2) +294 _align64("LastError", UINT32, 3) +295 _align64("argc", INT, 16) +296 _align64("argv", CHAR_PP, 17) +297 _align64("pubSub", VOID_P, 18) + # wPubSub*298 _align64("rdp", VOID_P, 32) + # rdpRdp*299 _align64("gdi", RdpGdi_P, 33) +300 _align64("rail", VOID_P, 34) + # rdpRail*301 _align64("cache", VOID_P, 35) + # rdpCache*302 _align64("channels", VOID_P, 36) + # rdpChannels*303 _align64("graphics", VOID_P, 37) + # rdpGraphics*304 _align64("input", RdpInput_P, 38) +305 _align64("update", VOID_P, 39) + # rdpUpdate*306 _align64("settings", RdpSettings_P, 40) +307 _align64("metrics", VOID_P, 41) + # rdpMetrics*308 _align64("padding", UINT64, 63) # size_of(RdpContext) will be needed309)310RdppPreConnect = ctypes.CFUNCTYPE(BOOL, RdpFreerdp_P)311RdppPostConnect = ctypes.CFUNCTYPE(BOOL, RdpFreerdp_P)312# struct rdp_freerdp313_align64.offset8 = 0314RdpFreerdp._fields_ = (315 _align64("context", RdpContext_P, 0) +316 _align64("pClientEntryPoints", VOID_P) +317 _align64("input", RdpInput_P, 16) +318 _align64("update", VOID_P, 17) + # rdpUpdate*319 _align64("settings", RdpSettings_P, 18) +320 _align64("ContextSize", SIZE_T, 32) +321 _align64("ContextNew", VOID_P, 33) + # pContextNew322 _align64("ContextFree", VOID_P, 34) + # pContextFree323 _align64("PreConnect", RdppPreConnect, 48) +324 _align64("PostConnect", RdppPostConnect, 49) +325 _align64("Authenticate", VOID_P, 50) + # pAuthenticate326 _align64("VerifyCertificate", VOID_P, 51) + # pVerifyCertificate327 _align64("VerifyChangedCertificate", VOID_P, 52) + # pVerifyChangedCertificate328 _align64("VerifyX509Certificate", VOID_P, 53) + # pVerifyX509Certificate329 _align64("LogonErrorInfo", VOID_P, 54) + # pLogonErrorInfo330 _align64("PostDisconnect", VOID_P, 55) + # pPostDisconnect331 _align64("GatewayAuthenticate", VOID_P, 56) + # pAuthenticate332 _align64("SendChannelData", VOID_P, 64) + # pSendChannelData333 _align64("ReceiveChannelData", VOID_P, 65) # pReceiveChannelData334)335def _load_lib(libname):336 try:337 return ctypes.CDLL(libname)338 except OSError, e:339 raise ImportError('loading library "%s" failed: %s' % (libname, e))340libcore = _load_lib("libfreerdp-core.so.1.2")341libgdi = _load_lib("libfreerdp-gdi.so.1.2")342libutils = _load_lib("libfreerdp-utils.so.1.2")343libwinpr = _load_lib("libwinpr.so.1.1")344libcore.freerdp_new.argtypes = []345libcore.freerdp_new.restype = RdpFreerdp_P346libcore.freerdp_free.argtypes = [RdpFreerdp_P]347libcore.freerdp_free.restype = None...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!